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