1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2004-2006, 2008 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19
20 #include <aecvsserver/directo_list.h>
21
22
23 void
directory_list_constructor(directory_list_ty * dlp)24 directory_list_constructor(directory_list_ty *dlp)
25 {
26 dlp->length = 0;
27 dlp->maximum = 0;
28 dlp->item = 0;
29 }
30
31
32 void
directory_list_destructor(directory_list_ty * dlp)33 directory_list_destructor(directory_list_ty *dlp)
34 {
35 size_t j;
36
37 for (j = 0; j < dlp->length; ++j)
38 directory_destructor(dlp->item+ j);
39 delete [] dlp->item;
40 dlp->length = 0;
41 dlp->maximum = 0;
42 dlp->item = 0;
43 }
44
45
46 void
directory_list_rewind(directory_list_ty * dlp)47 directory_list_rewind(directory_list_ty *dlp)
48 {
49 size_t j;
50
51 for (j = 0; j < dlp->length; ++j)
52 directory_destructor(dlp->item + j);
53 dlp->length = 0;
54 }
55
56
57 void
directory_list_append(directory_list_ty * dlp,string_ty * client_side,string_ty * server_side)58 directory_list_append(directory_list_ty *dlp, string_ty *client_side,
59 string_ty *server_side)
60 {
61 directory_ty *dp;
62
63 if (dlp->length >= dlp->maximum)
64 {
65 dlp->maximum = dlp->maximum * 2 + 4;
66 directory_ty *new_item = new directory_ty [dlp->maximum];
67 for (size_t j = 0; j < dlp->length; ++j)
68 new_item[j] = dlp->item[j];
69 delete [] dlp->item;
70 dlp->item = new_item;
71 }
72 dp = dlp->item + dlp->length++;
73 directory_constructor(dp, client_side, server_side);
74 }
75