annotate lib/misc.c @ 330:532eb171d5c2

2003-12-7 Brian Masney <masneyb@gftp.org> * lib/config_file.c lib/gftp.h lib/misc.c lib/options.h - added scramble passwords option. This patch is mostly from Aurelien Jarno <lists@aurel32.net>, but it was modified by me quite a bit. This is not safe, and can be broken. That is why it's labeled scrambled passwords instead of encrypt passwords. * acinclude.m4 - fix to AC_INTL_PRINTF
author masneyb
date Mon, 08 Dec 2003 02:53:24 +0000
parents 51bb530a100c
children 3fccdc9eb16f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2 /* misc.c - general purpose routines */
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
102
3b573c8ef706 2003-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 87
diff changeset
20 static const char cvsid[] = "$Id$";
3b573c8ef706 2003-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 87
diff changeset
21
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22 #include "gftp.h"
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
23 #include "options.h"
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24
328
51bb530a100c 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
25 #ifdef HAVE_INTL_PRINTF
289
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
26
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
27 char *
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
28 insert_commas (off_t number, char *dest_str, size_t dest_len)
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
29 {
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
30 if (dest_str != NULL)
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
31 {
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
32 #if defined (_LARGEFILE_SOURCE)
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
33 g_snprintf (dest_str, dest_len, "%'lld", number);
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
34 #else
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
35 g_snprintf (dest_str, dest_len, "%'ld", number);
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
36 #endif
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
37 }
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
38 else
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
39 {
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
40 #if defined (_LARGEFILE_SOURCE)
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
41 dest_str = g_strdup_printf ("%'lld", number);
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
42 #else
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
43 dest_str = g_strdup_printf ("%'ld", number);
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
44 #endif
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
45 }
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
46
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
47 return (dest_str);
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
48 }
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
49
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
50 #else
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
51
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
52 char *
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 13
diff changeset
53 insert_commas (off_t number, char *dest_str, size_t dest_len)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
54 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
55 char *frompos, *topos, src[50], *dest;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
56 int len, num, rem, i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
57
220
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
58 #if defined (_LARGEFILE_SOURCE)
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
59 g_snprintf (src, sizeof (src), "%lld", number);
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
60 #else
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
61 g_snprintf (src, sizeof (src), "%ld", number);
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
62 #endif
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
63
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
64 if (dest_str != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
65 *dest_str = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
66
220
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
67 len = strlen (src);
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
68 if (len == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
69 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
70 if (dest_str != NULL)
249
094e83b55cb1 2003-8-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 247
diff changeset
71 {
094e83b55cb1 2003-8-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 247
diff changeset
72 strncpy (dest_str, "0", dest_len);
094e83b55cb1 2003-8-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 247
diff changeset
73 dest_str[dest_len - 1] = '\0';
094e83b55cb1 2003-8-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 247
diff changeset
74 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
75 else
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
76 dest_str = g_strdup ("0");
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 return (dest_str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80 len += len / 3;
220
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
81
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
82 if (dest_str != NULL && len > dest_len)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
83 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
84
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
85 for (i=0; i<dest_len - 1; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
86 dest_str[i] = 'X';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
87 dest_str[dest_len - 1] = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
88 return (dest_str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
89 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
90
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
91 if (dest_str == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
92 dest = g_malloc0 (len);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
93 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
94 dest = dest_str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
95
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
96 num = strlen (src) / 3 - 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
97 rem = strlen (src) % 3;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
98 frompos = src;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
99 topos = dest;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
100 for (i = 0; i < rem; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
101 *topos++ = *frompos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
102
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103 if (*frompos != '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 if (rem != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 *topos++ = ',';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107 while (num > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109 for (i = 0; i < 3; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110 *topos++ = *frompos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
111 *topos++ = ',';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112 num--;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 for (i = 0; i < 3; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 *topos++ = *frompos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
117 *topos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 return (dest);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120
289
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
121 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123 char *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 alltrim (char *str)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126 char *pos, *newpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 int diff;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 pos = str + strlen (str) - 1;
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
130 while (pos >= str && (*pos == ' ' || *pos == '\t'))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131 *pos-- = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 pos = str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 diff = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 while (*pos++ == ' ')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 diff++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
137
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
138 if (diff == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139 return (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141 pos = str + diff;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
142 newpos = str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
143 while (*pos != '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
144 *newpos++ = *pos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
145 *newpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
146
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
147 return (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
148 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
149
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
150
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
151 char *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 expand_path (const char *src)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 {
307
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
154 char *str, *pos, *endpos, *prevpos, *newstr, *tempstr, *ntoken,
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
155 tempchar;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 struct passwd *pw;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
157
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158 pw = NULL;
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
159 str = g_strdup (src);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
161 if (*str == '~')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 if (*(str + 1) == '/' || *(str + 1) == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 pw = getpwuid (geteuid ());
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
167 if ((pos = strchr (str, '/')) != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 *pos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170 pw = getpwnam (str + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172 if (pos != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 *pos = '/';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 endpos = str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 newstr = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 while ((pos = strchr (endpos, '/')) != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 pos++;
204
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
182
307
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
183 for (ntoken = pos; *ntoken == '/'; ntoken++);
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
184
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
185 if ((endpos = strchr (ntoken, '/')) == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 endpos = pos + strlen (pos);
204
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
187
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 tempchar = *endpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 *endpos = '\0';
204
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
190
307
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
191 if (strcmp (ntoken, "..") == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 if (newstr != NULL && (prevpos = strrchr (newstr, '/')) != NULL)
307
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
194 {
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
195 *prevpos = '\0';
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
196 if (*newstr == '\0')
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
197 {
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
198 g_free (newstr);
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
199 newstr = NULL;
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
200 }
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
201 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 }
307
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
203 else if (strcmp (ntoken, ".") != 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 if (newstr == NULL)
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
206 newstr = g_strdup (pos - 1);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 tempstr = g_strconcat (newstr, pos - 1, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 g_free (newstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 newstr = tempstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 }
204
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
214
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215 *endpos = tempchar;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 if (*endpos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 break;
204
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
218
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 endpos = pos + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221
204
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
222 if (endpos != NULL && *endpos != '\0' && newstr == NULL)
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
223 {
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
224 if (strcmp (endpos, "..") == 0)
307
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
225 newstr = g_strdup ("/");
204
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
226 else
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
227 newstr = g_strdup (endpos);
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
228 }
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
229
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
230 if (newstr == NULL || *newstr == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232 if (newstr != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233 g_free (newstr);
204
9b2de8d3fafe 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 203
diff changeset
234
247
f41650dc896c 2003-8-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
235 newstr = g_strdup ("/");
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 g_free (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 if (pw != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 if ((pos = strchr (newstr, '/')) == NULL)
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
243 str = g_strdup (pw->pw_dir);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244 else
247
f41650dc896c 2003-8-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
245 str = gftp_build_path (pw->pw_dir, pos, NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 g_free (newstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 newstr = str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 return (newstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
256 make_nonnull (char **str)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 if (*str == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259 *str = g_malloc0 (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
262
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
263 /* FIXME - is there a replacement for this */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
264 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
265 gftp_match_filespec (char *filename, char *filespec)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
266 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267 char *filepos, *wcpos, *pos, *newpos, search_str[20];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 size_t len, curlen;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270 if (filename == NULL || *filename == '\0' ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
271 filespec == NULL || *filespec == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
272 return(1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
273
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274 filepos = filename;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
275 wcpos = filespec;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 while(1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
278 if (*wcpos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279 return (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
280 else if (*filepos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
281 return(0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
282 else if(*wcpos == '?')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
283 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
284 wcpos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
285 filepos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
286 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
287 else if(*wcpos == '*' && *(wcpos+1) == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
288 return(1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
289 else if(*wcpos == '*')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
290 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
291 len = sizeof (search_str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
292 for (pos = wcpos + 1, newpos = search_str, curlen = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
293 *pos != '*' && *pos != '?' && *pos != '\0' && curlen < len;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
294 curlen++, *newpos++ = *pos++);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
295 *newpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
296
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
297 if ((filepos = strstr (filepos, search_str)) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
298 return(0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
299 wcpos += curlen + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
300 filepos += curlen;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
301 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
302 else if(*wcpos++ != *filepos++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
303 return(0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
304 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
305 return (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
306 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
307
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
308
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
309 static void
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
310 gftp_info (void)
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
311 {
260
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
312 int i;
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
313
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
314 printf ("%s\n", gftp_version);
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
315
307
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
316 #ifdef _REENTRANT
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
317 printf ("#define _REENTRANT\n");
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
318 #endif
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
319
289
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
320 #ifdef _GNU_SOURCE
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
321 printf ("#define _GNU_SOURCE\n");
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
322 #endif
5f66f09e5194 2003-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 260
diff changeset
323
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
324 #ifdef _LARGEFILE_SOURCE
260
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
325 printf ("#define _LARGEFILE_SOURCE\n");
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
326 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
327
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
328 #ifdef _FILE_OFFSET_BITS
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
329 printf ("#define _FILE_OFFSET_BITS %d\n", _FILE_OFFSET_BITS);
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
330 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
331
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
332 printf ("sizeof (off_t) = %d\n", sizeof (off_t));
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
333
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
334 #ifdef HAVE_GETADDRINFO
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
335 printf ("#define HAVE_GETADDRINFO\n");
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
336 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
337
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
338 #ifdef HAVE_GAI_STRERROR
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
339 printf ("#define HAVE_GAI_STRERROR\n");
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
340 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
341
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
342 #ifdef HAVE_GETDTABLESIZE
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
343 printf ("#define HAVE_GETDTABLESIZE\n");
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
344 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
345
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
346 #ifdef G_HAVE_GINT64
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
347 printf ("#define G_HAVE_GINT64\n");
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
348 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
349
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
350 #ifdef HAVE_LIBREADLINE
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
351 printf ("#define HAVE_LIBREADLINE\n");
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
352 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
353
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
354 #ifdef ENABLE_NLS
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
355 printf ("#define ENABLE_NLS\n");
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
356 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
357
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
358 #ifdef HAVE_GETTEXT
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
359 printf ("#define HAVE_GETTEXT\n");
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
360 #endif
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
361
328
51bb530a100c 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
362 #ifdef HAVE_INTL_PRINTF
51bb530a100c 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
363 printf ("#define HAVE_INTL_PRINTF\n");
51bb530a100c 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
364 #endif
51bb530a100c 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
365
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
366 printf ("glib version: %d.%d.%d\n", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
367 GLIB_MICRO_VERSION);
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
368
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
369 printf ("PTY implementation: %s\n", gftp_get_pty_impl ());
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
370
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
371 #ifdef USE_SSL
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
372 printf ("OpenSSL version: 0x%lx\n", OPENSSL_VERSION_NUMBER);
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
373 #endif
260
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
374
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
375 printf ("Enabled protocols: ");
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
376 for (i=0; gftp_protocols[i].name != NULL; i++)
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
377 {
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
378 printf ("%s ", gftp_protocols[i].name);
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
379 }
71d0098c3735 2003-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 249
diff changeset
380 printf ("\n");
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
381 }
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
382
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
383
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385 gftp_parse_command_line (int *argc, char ***argv)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 if (*argc > 1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388 {
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
389 if (strcmp (argv[0][1], "--help") == 0 ||
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
390 strcmp (argv[0][1], "-h") == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 gftp_usage ();
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
392 else if (strcmp (argv[0][1], "--version") == 0 ||
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
393 strcmp (argv[0][1], "-v") == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
394 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
395 printf ("%s\n", gftp_version);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 exit (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397 }
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
398 else if (strcmp (argv[0][1], "--info") == 0)
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
399 {
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
400 gftp_info ();
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
401 exit (0);
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
402 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
403 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
405 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
407
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
408 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
409 gftp_usage (void)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
410 {
162
12a043d992a1 2003-5-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
411 printf (_("usage: gftp [[protocol://][user[:pass]@]site[:port][/directory]]\n"));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
412 exit (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
413 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
414
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
415
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
416 gint
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417 string_hash_compare (gconstpointer path1, gconstpointer path2)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
418 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
419 return (strcmp ((char *) path1, (char *) path2) == 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
420 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
421
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
422
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
423 guint
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
424 string_hash_function (gconstpointer key)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
425 {
59
618423504fe0 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
426 guint ret;
618423504fe0 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
427 int i;
618423504fe0 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
428
618423504fe0 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
429 ret = 0;
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
430 for (i=0; ((char *) key)[i] != '\0' && i < 3; i++)
59
618423504fe0 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
431 ret += ((char *) key)[i];
618423504fe0 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
432
618423504fe0 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
433 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
434 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
435
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
436
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
437 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
438 free_file_list (GList * filelist)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
439 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
440 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
441 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
442
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
443 templist = filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
444 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
445 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
446 tempfle = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
447 free_fdata (tempfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
448 templist = templist->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
449 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
450 g_list_free (filelist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
451 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
452
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
453
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
454 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
455 free_fdata (gftp_file * fle)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
456 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
457 if (fle->file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
458 g_free (fle->file);
184
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
459 if (fle->utf8_file)
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
460 g_free (fle->utf8_file);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
461 if (fle->user)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
462 g_free (fle->user);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
463 if (fle->group)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
464 g_free (fle->group);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
465 if (fle->attribs)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
466 g_free (fle->attribs);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
467 if (fle->destfile)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
468 g_free (fle->destfile);
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
469 if (fle->fd > 0)
102
3b573c8ef706 2003-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 87
diff changeset
470 close (fle->fd);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
471 g_free (fle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
472 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
473
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
474
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
475 gftp_file *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
476 copy_fdata (gftp_file * fle)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
477 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
478 gftp_file * newfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
479
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
480 newfle = g_malloc0 (sizeof (*newfle));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
481 memcpy (newfle, fle, sizeof (*newfle));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
482
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
483 if (fle->file)
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
484 newfle->file = g_strdup (fle->file);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
485
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
486 if (fle->utf8_file)
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
487 newfle->utf8_file = g_strdup (fle->utf8_file);
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
488
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
489 if (fle->user)
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
490 newfle->user = g_strdup (fle->user);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
491
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
492 if (fle->group)
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
493 newfle->group = g_strdup (fle->group);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
494
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
495 if (fle->attribs)
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
496 newfle->attribs = g_strdup (fle->attribs);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
497
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
498 if (fle->destfile)
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
499 newfle->destfile = g_strdup (fle->destfile);
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
500
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
501 return (newfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
502 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
503
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
504
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
505 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
506 compare_request (gftp_request * request1, gftp_request * request2,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
507 int compare_dirs)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
508 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
509 char *strarr[3][2];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
510 int i, ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
511
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
512 ret = 1;
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
513 if (request1->protonum == request2->protonum &&
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
514 request1->port == request2->port)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
515 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
516 strarr[0][0] = request1->hostname;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
517 strarr[0][1] = request2->hostname;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
518 strarr[1][0] = request1->username;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
519 strarr[1][1] = request2->username;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
520 if (compare_dirs)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
521 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
522 strarr[2][0] = request1->directory;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
523 strarr[2][1] = request2->directory;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
524 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
525 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
526 strarr[2][0] = strarr[2][1] = "";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
527
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
528 for (i = 0; i < 3; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
529 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
530 if ((strarr[i][0] && !strarr[i][1]) ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
531 (!strarr[i][0] && strarr[i][1]))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
532 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
533 ret = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
534 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
535 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
536
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
537 if (strarr[i][0] && strarr[i][1] &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
538 strcmp (strarr[i][0], strarr[i][1]) != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
539 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
540 ret = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
541 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
542 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
543 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
544 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
545 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
546 ret = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
547 return (ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
548 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
549
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
550
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
551 gftp_transfer *
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
552 gftp_tdata_new (void)
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
553 {
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
554 #if GLIB_MAJOR_VERSION == 1
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
555 static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
556 #endif
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
557 gftp_transfer * tdata;
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
558
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
559 tdata = g_malloc0 (sizeof (*tdata));
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
560
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
561 #if GLIB_MAJOR_VERSION == 1
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
562 tdata->statmutex = init_mutex;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
563 tdata->structmutex = init_mutex;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
564 #else
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
565 g_static_mutex_init (&tdata->statmutex);
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
566 g_static_mutex_init (&tdata->structmutex);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
567 #endif
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
568
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
569 return (tdata);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
570 }
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
571
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 125
diff changeset
572
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
573 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
574 free_tdata (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
575 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
576 if (tdata->fromreq != NULL)
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
577 gftp_request_destroy (tdata->fromreq, 1);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
578 if (tdata->toreq != NULL)
67
aa971a4bb16f 2002-11-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
579 gftp_request_destroy (tdata->toreq, 1);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
580 free_file_list (tdata->files);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
581 g_free (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
582 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
583
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
584
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
585 gftp_request *
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
586 copy_request (gftp_request * req, int copy_local_options)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
587 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
588 gftp_request * newreq;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
589
66
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
590 newreq = gftp_request_new ();
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
591
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
592 if (req->hostname)
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
593 newreq->hostname = g_strdup (req->hostname);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
594 if (req->username)
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
595 newreq->username = g_strdup (req->username);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
596 if (req->password)
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
597 newreq->password = g_strdup (req->password);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
598 if (req->account)
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
599 newreq->account = g_strdup (req->account);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
600 if (req->directory)
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
601 newreq->directory = g_strdup (req->directory);
66
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
602 newreq->port = req->port;
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
603 newreq->use_proxy = req->use_proxy;
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
604 newreq->logging_function = req->logging_function;
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
605 newreq->free_hostp = 0;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 290
diff changeset
606 newreq->hostp = NULL;
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
607
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
608 if (copy_local_options)
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
609 gftp_copy_local_options (&newreq->local_options_vars,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
610 &newreq->local_options_hash,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
611 req->local_options_vars,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
612 req->num_local_options_vars);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
613
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
614 if (req->init (newreq) < 0)
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
615 {
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
616 gftp_request_destroy (newreq, 1);
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
617 return (NULL);
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
618 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
619
309
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 307
diff changeset
620 gftp_copy_param_options (newreq, req);
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 307
diff changeset
621
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
622 return (newreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
623 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
624
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
625
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
626 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
627 gftp_file_sort_function_as (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
628 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
629 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
630
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
631 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
632 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
633 return (strcmp (f1->file, f2->file));
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
634 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
635
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
636
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
637 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
638 gftp_file_sort_function_ds (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
639 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
640 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
641 gint ret;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
642
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
643 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
644 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
645 ret = strcmp (f1->file, f2->file);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 80
diff changeset
646 return (ret * -1);
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
647 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
648
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
649
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
650 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
651 gftp_user_sort_function_as (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
652 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
653 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
654
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
655 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
656 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
657 return (strcmp (f1->user, f2->user));
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
658 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
659
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
660
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
661 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
662 gftp_user_sort_function_ds (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
663 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
664 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
665 gint ret;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
666
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
667 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
668 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
669 ret = strcmp (f1->user, f2->user);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 80
diff changeset
670 return (ret * -1);
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
671 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
672
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
673
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
674 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
675 gftp_group_sort_function_as (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
676 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
677 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
678
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
679 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
680 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
681 return (strcmp (f1->group, f2->group));
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
682 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
683
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
684
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
685 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
686 gftp_group_sort_function_ds (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
687 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
688 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
689 gint ret;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
690
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
691 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
692 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
693 ret = strcmp (f1->group, f2->group);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 80
diff changeset
694 return (ret * -1);
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
695 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
696
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
697
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
698 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
699 gftp_attribs_sort_function_as (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
700 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
701 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
702
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
703 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
704 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
705 return (strcmp (f1->attribs, f2->attribs));
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
706 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
707
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
708
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
709 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
710 gftp_attribs_sort_function_ds (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
711 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
712 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
713 gint ret;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
714
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
715 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
716 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
717 ret = strcmp (f1->attribs, f2->attribs);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 80
diff changeset
718 return (ret * -1);
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
719 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
720
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
721
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
722 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
723 gftp_size_sort_function_as (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
724 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
725 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
726
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
727 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
728 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
729 if (f1->size < f2->size)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
730 return (-1);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
731 else if (f1->size == f2->size)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
732 return (0);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
733 else
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
734 return (1);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
735 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
736
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
737
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
738 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
739 gftp_size_sort_function_ds (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
740 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
741 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
742
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
743 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
744 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
745 if (f1->size < f2->size)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
746 return (1);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
747 else if (f1->size == f2->size)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
748 return (0);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
749 else
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
750 return (-1);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
751 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
752
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
753
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
754 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
755 gftp_datetime_sort_function_as (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
756 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
757 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
758
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
759 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
760 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
761 if (f1->datetime < f2->datetime)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
762 return (-1);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
763 else if (f1->datetime == f2->datetime)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
764 return (0);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
765 else
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
766 return (1);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
767 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
768
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
769
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
770 static gint
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
771 gftp_datetime_sort_function_ds (gconstpointer a, gconstpointer b)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
772 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
773 const gftp_file * f1, * f2;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
774
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
775 f1 = a;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
776 f2 = b;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
777 if (f1->datetime < f2->datetime)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
778 return (1);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
779 else if (f1->datetime == f2->datetime)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
780 return (0);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
781 else
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
782 return (-1);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
783 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
784
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
785
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
786 GList *
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
787 gftp_sort_filelist (GList * filelist, int column, int asds)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
788 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
789 GList * files, * dirs, * dotdot, * tempitem, * insitem;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
790 GCompareFunc sortfunc;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
791 gftp_file * tempfle;
325
0fcc6468a0af 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
792 intptr_t sort_dirs_first;
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
793
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
794 files = dirs = dotdot = NULL;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
795
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
796 if (column == GFTP_SORT_COL_FILE)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
797 sortfunc = asds ? gftp_file_sort_function_as : gftp_file_sort_function_ds;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
798 else if (column == GFTP_SORT_COL_SIZE)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
799 sortfunc = asds ? gftp_size_sort_function_as : gftp_size_sort_function_ds;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
800 else if (column == GFTP_SORT_COL_USER)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
801 sortfunc = asds ? gftp_user_sort_function_as : gftp_user_sort_function_ds;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
802 else if (column == GFTP_SORT_COL_GROUP)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
803 sortfunc = asds ?
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
804 gftp_group_sort_function_as : gftp_group_sort_function_ds;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
805 else if (column == GFTP_SORT_COL_DATETIME)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
806 sortfunc = asds ?
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
807 gftp_datetime_sort_function_as : gftp_datetime_sort_function_ds;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
808 else if (column == GFTP_SORT_COL_ATTRIBS)
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
809 sortfunc = asds ?
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
810 gftp_attribs_sort_function_as : gftp_attribs_sort_function_ds;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
811 else /* Don't sort */
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
812 return (filelist);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
813
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
814 sort_dirs_first = 1;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 102
diff changeset
815 gftp_lookup_global_option ("sort_dirs_first", &sort_dirs_first);
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
816
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
817 for (tempitem = filelist; tempitem != NULL; )
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
818 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
819 tempfle = tempitem->data;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
820 insitem = tempitem;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
821 tempitem = tempitem->next;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
822 insitem->next = NULL;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
823
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
824 if (dotdot == NULL && strcmp (tempfle->file, "..") == 0)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
825 dotdot = insitem;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
826 else if (sort_dirs_first && tempfle->isdir)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
827 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
828 insitem->next = dirs;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
829 dirs = insitem;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
830 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
831 else
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
832 {
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
833 insitem->next = files;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
834 files = insitem;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
835 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
836 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
837
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
838 if (dirs != NULL)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
839 dirs = g_list_sort (dirs, sortfunc);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
840 if (files != NULL)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
841 files = g_list_sort (files, sortfunc);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
842
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
843 filelist = dotdot;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
844
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
845 if (filelist == NULL)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
846 filelist = dirs;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
847 else
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
848 filelist = g_list_concat (filelist, dirs);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
849
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
850 if (filelist == NULL)
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
851 filelist = files;
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
852 else
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
853 filelist = g_list_concat (filelist, files);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
854
39
474d562c7268 2002-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
855 /* I haven't check this, but I'm pretty sure some older versions of glib
474d562c7268 2002-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
856 had a bug that the prev pointer wasn't being sent to NULL */
474d562c7268 2002-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
857 filelist->prev = NULL;
16
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
858 return (filelist);
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
859 }
ddb983d8574b * Improved directory sorting algorithm
masneyb
parents: 14
diff changeset
860
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
861
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
862 mode_t
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
863 gftp_parse_attribs (char *attribs)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
864 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
865 mode_t mode;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
866 int cur;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
867
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
868 cur = 0;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
869 if (attribs[1] == 'r')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
870 cur += 4;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
871 if (attribs[2] == 'w')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
872 cur += 2;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
873 if (attribs[3] == 'x' ||
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
874 attribs[3] == 's')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
875 cur += 1;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
876 mode = cur;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
877
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
878 cur = 0;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
879 if (attribs[4] == 'r')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
880 cur += 4;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
881 if (attribs[5] == 'w')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
882 cur += 2;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
883 if (attribs[6] == 'x' ||
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
884 attribs[6] == 's')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
885 cur += 1;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
886 mode = (mode * 10) + cur;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
887
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
888 cur = 0;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
889 if (attribs[7] == 'r')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
890 cur += 4;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
891 if (attribs[8] == 'w')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
892 cur += 2;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
893 if (attribs[9] == 'x' ||
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
894 attribs[9] == 's')
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
895 cur += 1;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
896 mode = (mode * 10) + cur;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
897
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
898 return (mode);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
899 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
900
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
901
131
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
902 char *
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
903 gftp_gen_ls_string (gftp_file * fle, char *file_prefixstr, char *file_suffixstr)
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
904 {
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
905 char *tempstr1, *tempstr2, *ret, tstr[50];
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
906 struct tm *lt;
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
907 time_t t;
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
908
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
909 lt = localtime (&fle->datetime);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
910
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
911 tempstr1 = g_strdup_printf ("%10s %8s %8s", fle->attribs, fle->user,
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
912 fle->group);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
913
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
914 if (fle->attribs && (*fle->attribs == 'b' || *fle->attribs == 'c'))
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
915 tempstr2 = g_strdup_printf ("%d, %d", major (fle->size), minor (fle->size));
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
916 else
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
917 {
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
918 #if defined (_LARGEFILE_SOURCE)
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
919 tempstr2 = g_strdup_printf ("%11lld", fle->size);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
920 #else
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
921 tempstr2 = g_strdup_printf ("%11ld", fle->size);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
922 #endif
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
923 }
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
924
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
925 time (&t);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
926
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
927 if (fle->datetime > t || t - 3600*24*90 > fle->datetime)
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
928 strftime (tstr, sizeof (tstr), "%b %d %Y", lt);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
929 else
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
930 strftime (tstr, sizeof (tstr), "%b %d %H:%M", lt);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
931
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
932 if (file_prefixstr == NULL)
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
933 file_prefixstr = "";
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
934 if (file_suffixstr == NULL)
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
935 file_suffixstr = "";
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
936
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
937 ret = g_strdup_printf ("%s %s %s %s%s%s", tempstr1, tempstr2, tstr,
184
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
938 file_prefixstr,
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
939 fle->utf8_file != NULL ? fle->utf8_file : fle->file,
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
940 file_suffixstr);
131
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
941
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
942 g_free (tempstr1);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
943 g_free (tempstr2);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
944
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
945 return (ret);
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
946 }
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
947
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
948
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
949 #if !defined (HAVE_GETADDRINFO) || !defined (HAVE_GAI_STRERROR)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
950
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
951 struct hostent *
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
952 r_gethostbyname (const char *name, struct hostent *result_buf, int *h_errnop)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
953 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
954 static GStaticMutex hostfunclock = G_STATIC_MUTEX_INIT;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
955 struct hostent *hent;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
956
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
957 if (g_thread_supported ())
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
958 g_static_mutex_lock (&hostfunclock);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
959
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
960 if ((hent = gethostbyname (name)) == NULL)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
961 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
962 if (h_errnop)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
963 *h_errnop = h_errno;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
964 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
965 else
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
966 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
967 *result_buf = *hent;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
968 hent = result_buf;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
969 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
970
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
971 if (g_thread_supported ())
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
972 g_static_mutex_unlock (&hostfunclock);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
973
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
974 return (hent);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
975 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
976
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
977 #endif /* !HAVE_GETADDRINFO */
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
978
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
979 struct servent *
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
980 r_getservbyname (const char *name, const char *proto,
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
981 struct servent *result_buf, int *h_errnop)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
982 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
983 static GStaticMutex servfunclock = G_STATIC_MUTEX_INIT;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
984 struct servent *sent;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
985
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
986 if (g_thread_supported ())
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
987 g_static_mutex_lock (&servfunclock);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
988
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
989 if ((sent = getservbyname (name, proto)) == NULL)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
990 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
991 if (h_errnop)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
992 *h_errnop = h_errno;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
993 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
994 else
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
995 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
996 *result_buf = *sent;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
997 sent = result_buf;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
998 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
999
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1000 if (g_thread_supported ())
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1001 g_static_mutex_unlock (&servfunclock);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1002 return (sent);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1003 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1004
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1005
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1006 char *
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1007 base64_encode (char *str)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1008 {
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1009
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1010 /* The standard to Base64 encoding can be found in RFC2045 */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1011
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1012 char *newstr, *newpos, *fillpos, *pos;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1013 unsigned char table[64], encode[3];
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1014 int i, num;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1015
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1016 for (i = 0; i < 26; i++)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1017 {
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1018 table[i] = 'A' + i;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1019 table[i + 26] = 'a' + i;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1020 }
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1021
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1022 for (i = 0; i < 10; i++)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1023 table[i + 52] = '0' + i;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1024
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1025 table[62] = '+';
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1026 table[63] = '/';
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1027
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1028 num = strlen (str) / 3;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1029 if (strlen (str) % 3 > 0)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1030 num++;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1031 newstr = g_malloc (num * 4 + 1);
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1032 newstr[num * 4] = '\0';
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1033 newpos = newstr;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1034
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1035 pos = str;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1036 while (*pos != '\0')
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1037 {
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1038 memset (encode, 0, sizeof (encode));
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1039 for (i = 0; i < 3 && *pos != '\0'; i++)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1040 encode[i] = *pos++;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1041
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1042 fillpos = newpos;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1043 *newpos++ = table[encode[0] >> 2];
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1044 *newpos++ = table[(encode[0] & 3) << 4 | encode[1] >> 4];
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1045 *newpos++ = table[(encode[1] & 0xF) << 2 | encode[2] >> 6];
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1046 *newpos++ = table[encode[2] & 0x3F];
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1047 while (i < 3)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1048 fillpos[++i] = '=';
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1049 }
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1050 return (newstr);
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1051 }
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 162
diff changeset
1052
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1053
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1054 void
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1055 gftp_free_bookmark (gftp_bookmarks_var * entry)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1056 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1057 if (entry->hostname)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1058 g_free (entry->hostname);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1059 if (entry->remote_dir)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1060 g_free (entry->remote_dir);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1061 if (entry->local_dir)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1062 g_free (entry->local_dir);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1063 if (entry->user)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1064 g_free (entry->user);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1065 if (entry->pass)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1066 g_free (entry->pass);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1067 if (entry->acct)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1068 g_free (entry->acct);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1069 if (entry->protocol)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1070 g_free (entry->protocol);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1071
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1072 if (entry->local_options_vars != NULL)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1073 {
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1074 gftp_config_free_options (entry->local_options_vars,
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1075 entry->local_options_hash,
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1076 entry->num_local_options_vars);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1077
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1078 entry->local_options_vars = NULL;
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1079 entry->local_options_hash = NULL;
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1080 entry->num_local_options_vars = 0;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1081 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1082 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1083
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1084
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1085 void
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1086 gftp_shutdown (void)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1087 {
203
95e669973a84 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1088 #ifdef WITH_DMALLOC
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1089 gftp_config_vars * cv;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1090 GList * templist;
203
95e669973a84 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1091 #endif
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1092
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1093 if (gftp_logfd != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1094 fclose (gftp_logfd);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1095
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1096 gftp_clear_cache_files ();
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1097
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1098 if (gftp_configuration_changed)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1099 gftp_write_config_file ();
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1100
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1101 #ifdef WITH_DMALLOC
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1102 if (gftp_global_options_htable != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1103 g_hash_table_destroy (gftp_global_options_htable);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1104
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1105 if (gftp_config_list_htable != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1106 g_hash_table_destroy (gftp_config_list_htable);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1107
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1108 if (gftp_bookmarks_htable != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1109 g_hash_table_destroy (gftp_bookmarks_htable);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1110
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1111 for (templist = gftp_options_list;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1112 templist != NULL;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1113 templist = templist->next)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1114 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1115 cv = templist->data;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1116 gftp_config_free_options (cv, NULL, -1);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1117 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1118
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1119 gftp_bookmarks_destroy (gftp_bookmarks);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1120
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1121 dmalloc_shutdown ();
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1122 #endif
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1123
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1124 exit (0);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1125 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1126
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1127
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1128 GList *
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1129 get_next_selection (GList * selection, GList ** list, int *curnum)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1130 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1131 gftp_file * tempfle;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1132 int i, newpos;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1133
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1134 newpos = GPOINTER_TO_INT (selection->data);
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1135 i = *curnum - newpos;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1136
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1137 if (i < 0)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1138 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1139 while (i != 0)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1140 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1141 tempfle = (*list)->data;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1142 if (tempfle->shown)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1143 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1144 ++*curnum;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1145 i++;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1146 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1147 *list = (*list)->next;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1148 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1149 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1150 else if (i > 0)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1151 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1152 while (i != 0)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1153 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1154 tempfle = (*list)->data;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1155 if (tempfle->shown)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1156 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1157 --*curnum;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1158 i--;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1159 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1160 *list = (*list)->prev;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1161 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1162 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1163
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1164 tempfle = (*list)->data;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1165 while ((*list)->next && !tempfle->shown)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1166 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1167 *list = (*list)->next;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1168 tempfle = (*list)->data;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1169 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1170 return (selection->next);
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1171 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1172
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 204
diff changeset
1173
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1174 char *
245
41af60bc1f88 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 244
diff changeset
1175 gftp_build_path (const char *first_element, ...)
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1176 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1177 const char *element;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1178 size_t len, retlen;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1179 int add_separator;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1180 va_list args;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1181 char *ret;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1182
245
41af60bc1f88 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 244
diff changeset
1183 g_return_val_if_fail (first_element != NULL, NULL);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1184
247
f41650dc896c 2003-8-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
1185 ret = g_strdup (first_element);
f41650dc896c 2003-8-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
1186 retlen = strlen (ret);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1187
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1188 va_start (args, first_element);
247
f41650dc896c 2003-8-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
1189 for (element = va_arg (args, char *);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1190 element != NULL;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1191 element = va_arg (args, char *))
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1192 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1193 len = strlen (element);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1194
307
76c912483d1d 2003-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
1195 if (retlen > 0 && ret[retlen - 1] == '/')
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1196 add_separator = 0;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1197 else
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1198 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1199 add_separator = 1;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1200 len++;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1201 }
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1202
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1203 retlen += len;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1204 ret = g_realloc (ret, retlen + 1);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1205
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1206 if (add_separator)
245
41af60bc1f88 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 244
diff changeset
1207 strncat (ret, "/", retlen);
41af60bc1f88 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 244
diff changeset
1208
41af60bc1f88 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 244
diff changeset
1209 strncat (ret, element, retlen);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1210 }
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1211
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1212 return (ret);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1213 }
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 220
diff changeset
1214
244
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1215
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1216 off_t
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1217 gftp_parse_file_size (char *str)
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1218 {
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1219 #if defined (_LARGEFILE_SOURCE)
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1220 return (strtoll (str, NULL, 10));
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1221 #else
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1222 return (strtol (str, NULL, 10));
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1223 #endif
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1224 }
afbbc72b73e2 2003-8-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 243
diff changeset
1225
290
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1226
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1227 void
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1228 gftp_locale_init (void)
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1229 {
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1230 #ifdef HAVE_GETTEXT
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1231
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1232 setlocale (LC_ALL, "");
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1233 textdomain ("gftp");
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 309
diff changeset
1234 bindtextdomain ("gftp", LOCALE_DIR);
290
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1235
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1236 #if GLIB_MAJOR_VERSION > 1
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1237 bind_textdomain_codeset ("gftp", "UTF-8");
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1238 #endif
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1239
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 309
diff changeset
1240 #endif /* HAVE_GETTEXT */
290
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1241 }
6e255984c0b0 2003-10-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 289
diff changeset
1242
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1243 /* Very primary encryption/decryption to make the passwords unreadable
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1244 with 'cat ~/.gftp/bookmarks'.
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1245
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1246 Each character is separated in two nibbles. Then each nibble is stored
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1247 under the form 01xxxx01. The resulted string is prefixed by a '$'.
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1248 */
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1249
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1250
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1251 char *
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1252 gftp_scramble_password (const char *password)
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1253 {
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1254 char *newstr, *newpos;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1255
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1256 if (strcmp (password, "@EMAIL@") == 0)
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1257 return (g_strdup (password));
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1258
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1259 newstr = g_malloc (strlen(password) * 2 + 2);
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1260 newpos = newstr;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1261
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1262 *newpos++ = '$';
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1263
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1264 while (*password != 0)
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1265 {
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1266 *newpos++ = ((*password >> 2) & 0x3c) | 0x41;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1267 *newpos++ = ((*password << 2) & 0x3c) | 0x41;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1268 password++;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1269 }
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1270 *newpos = 0;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1271
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1272 return (newstr);
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1273 }
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1274
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1275
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1276 char *
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1277 gftp_descramble_password (const char *password)
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1278 {
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1279 const char *passwordpos;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1280 char *newstr, *newpos;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1281 int error;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1282
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1283 if (*password != '$')
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1284 return (g_strdup (password));
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1285
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1286 passwordpos = password + 1;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1287 newstr = g_malloc (strlen (passwordpos) / 2 + 1);
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1288 newpos = newstr;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1289
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1290 error = 0;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1291 while (*passwordpos != '\0' && (*passwordpos + 1) != '\0')
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1292 {
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1293 if ((*passwordpos & 0xc3) != 0x41 ||
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1294 (*(passwordpos + 1) & 0xc3) != 0x41)
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1295 {
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1296 error = 1;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1297 break;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1298 }
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1299
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1300 *newpos++ = ((*passwordpos & 0x3c) << 2) |
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1301 ((*(passwordpos + 1) & 0x3c) >> 2);
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1302
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1303 passwordpos += 2;
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1304 }
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1305
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1306 if (error)
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1307 {
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1308 g_free (newstr);
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1309 return (g_strdup (password));
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1310 }
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1311
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1312 *newpos = '\0';
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1313 return (newstr);
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1314 }
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 328
diff changeset
1315