Annotation of embedaddon/strongswan/src/libimcv/pts/pts_file_meta.c, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2011 Sansar Choinyambuu
        !             3:  * HSR Hochschule fuer Technik Rapperswil
        !             4:  *
        !             5:  * This program is free software; you can redistribute it and/or modify it
        !             6:  * under the terms of the GNU General Public License as published by the
        !             7:  * Free Software Foundation; either version 2 of the License, or (at your
        !             8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
        !             9:  *
        !            10:  * This program is distributed in the hope that it will be useful, but
        !            11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        !            13:  * for more details.
        !            14:  */
        !            15: 
        !            16: #include "pts_file_meta.h"
        !            17: 
        !            18: #include <collections/linked_list.h>
        !            19: #include <utils/debug.h>
        !            20: 
        !            21: typedef struct private_pts_file_meta_t private_pts_file_meta_t;
        !            22: 
        !            23: /**
        !            24:  * Private data of a pts_file_meta_t object.
        !            25:  *
        !            26:  */
        !            27: struct private_pts_file_meta_t {
        !            28: 
        !            29:        /**
        !            30:         * Public pts_file_meta_t interface.
        !            31:         */
        !            32:        pts_file_meta_t public;
        !            33: 
        !            34:        /**
        !            35:         * List of File Metadata
        !            36:         */
        !            37:        linked_list_t *list;
        !            38: };
        !            39: 
        !            40: /**
        !            41:  * Free an pts_file_metadata_t object
        !            42:  */
        !            43: static void free_entry(pts_file_metadata_t *entry)
        !            44: {
        !            45:        if (entry)
        !            46:        {
        !            47:                free(entry->filename);
        !            48:                free(entry);
        !            49:        }
        !            50: }
        !            51: 
        !            52: METHOD(pts_file_meta_t, get_file_count, int,
        !            53:        private_pts_file_meta_t *this)
        !            54: {
        !            55:        return this->list->get_count(this->list);
        !            56: }
        !            57: 
        !            58: METHOD(pts_file_meta_t, add, void,
        !            59:        private_pts_file_meta_t *this, pts_file_metadata_t *metadata)
        !            60: {
        !            61:        this->list->insert_last(this->list, metadata);
        !            62: }
        !            63: 
        !            64: METHOD(pts_file_meta_t, create_enumerator, enumerator_t*,
        !            65:        private_pts_file_meta_t *this)
        !            66: {
        !            67:        return this->list->create_enumerator(this->list);
        !            68: }
        !            69: 
        !            70: METHOD(pts_file_meta_t, destroy, void,
        !            71:        private_pts_file_meta_t *this)
        !            72: {
        !            73:        this->list->destroy_function(this->list, (void *)free_entry);
        !            74:        free(this);
        !            75: }
        !            76: 
        !            77: /**
        !            78:  * See header
        !            79:  */
        !            80: pts_file_meta_t *pts_file_meta_create()
        !            81: {
        !            82:        private_pts_file_meta_t *this;
        !            83: 
        !            84:        INIT(this,
        !            85:                .public = {
        !            86:                        .get_file_count = _get_file_count,
        !            87:                        .add = _add,
        !            88:                        .create_enumerator = _create_enumerator,
        !            89:                        .destroy = _destroy,
        !            90:                },
        !            91:                .list = linked_list_create(),
        !            92:        );
        !            93: 
        !            94:        return &this->public;
        !            95: }
        !            96: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>