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