-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftpinfo.c
175 lines (135 loc) · 2.85 KB
/
ftpinfo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* This source file is Copyright 1995 by Evan Scott.
* All rights reserved.
* Permission is granted to distribute this file provided no
* fees beyond distribution costs are levied.
*/
#include "FTPMount.h" /* 03-03-02 rri */
#include "tcp.h"
#include "site.h"
#include "split.h"
#include "ftpinfo.h"
#include "connect.h"
/*
* ftpinfo routines
*/
void add_ftpinfo(struct info_header* ih, unsigned char* name, unsigned char* comment, struct DateStamp ds,
unsigned long size, unsigned long blocks, unsigned long flags)
{
ftpinfo* fi;
verify(ih, V_info_header);
fi = allocate(sizeof(*fi) + strlen(name) + 1 + strlen(comment) + 1, V_ftpinfo);
if (!fi)
return;
ensure(fi, V_ftpinfo);
// Name, dann ein Nullbyte, dann den Kommentar speichern
strcpy(fi->name, name);
strcpy(fi->name + strlen(name) + 1, comment);
fi->modified = ds;
fi->size = size;
fi->blocks = blocks;
fi->flags = flags;
// fi->next = ih->infos;
// ih->infos = fi;
/* instead of adding to front, and getting reversed lists, add to end */
*(ih->last_info_p) = fi;
ih->last_info_p = &(fi->next);
fi->next = nil;
return;
}
void free_info_header(struct info_header* ih)
{
ftpinfo *fi, *fin;
verify(ih, V_info_header);
fi = ih->infos;
while (fi)
{
verify(fi, V_ftpinfo);
fin = fi->next;
deallocate(fi, V_ftpinfo);
fi = fin;
}
if (ih->next)
ih->next->prev = ih->prev;
*(ih->prev) = ih->next;
deallocate(ih, V_info_header);
return;
}
struct info_header* new_info_header(site* sp, unsigned char* name)
{
struct info_header* ih;
verify(sp, V_site);
ih = (struct info_header *)allocate(sizeof(*ih) + strlen(name) + 1, V_info_header);
if (!ih) return nil;
ensure(ih, V_info_header);
ih->infos = nil;
ih->last_info_p = &(ih->infos);
ih->next = sp->infos;
if (sp->infos) sp->infos->prev = &(ih->next);
sp->infos = ih;
ih->prev = &(sp->infos);
strcpy(ih->name, name);
ih->case_sensitive = sp->case_sensitive;
return ih;
}
struct info_header* find_info_header(site* sp, unsigned char* name)
{
struct info_header* ih;
verify(sp, V_site);
ih = sp->infos;
if (sp->case_sensitive)
{
while (ih)
{
if (strcmp(ih->name, name) == 0) return ih;
ih = ih->next;
}
}
else
{
while (ih)
{
if (strcasecmp(ih->name, name) == 0) return ih;
ih = ih->next;
}
}
return nil;
}
ftpinfo* find_info(struct info_header* ih, unsigned char* name)
{
ftpinfo *fi, *found;
found = nil;
fi = ih->infos;
if (ih->case_sensitive)
{
while (fi)
{
if (strcmp(fi->name, name) == 0 && !(fi->flags & MYFLAG_DELETED))
{
found = fi;
break;
}
fi = fi->next;
}
}
else
{
found = nil;
while (fi)
{
if (!(fi->flags & MYFLAG_DELETED))
{
if (strcasecmp(fi->name, name) == 0)
{
found = fi;
if (strcasecmp(fi->name, name) == 0)
{
break;
}
}
}
fi = fi->next;
}
}
return found;
}