Mercurial > gftp.yaz
annotate lib/protocols.c @ 40:66c064fd05bc
2002-10-17 Brian Masney <masneyb@gftp.org>
* lib/protocols.c - add gftp_abort_transfer function. Also, in
gftp_transfer_file, when we do a gftp_put_file, if that fails,
try to abort the transfer.
* lib/rfc959.c - add rfc959_abort_transfer function
* lib/rfc2068.c, lib/local.c - point abort_transfer pointer to
rfc2068_end_transfer and local_end_transfer respectively
* lib/ssh.c, lib/sshv2.c - add FIXME to implement abort function
* src/gtk/transfer.c - when we stop a transfer, try to abort it
first. If that fails, disconnect from the site completely
author | masneyb |
---|---|
date | Fri, 18 Oct 2002 02:53:52 +0000 |
parents | 474d562c7268 |
children | 4bcfaf6307b5 |
rev | line source |
---|---|
1 | 1 /*****************************************************************************/ |
2 /* protocols.c - Skeleton functions for the protocols gftp supports */ | |
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */ | |
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" | |
33 | 21 static const char cvsid[] = "$Id$"; |
1 | 22 |
23 static time_t parse_time ( char **str ); | |
24 static int gftp_parse_ls_eplf ( char *str, | |
25 gftp_file * fle ); | |
26 static int gftp_parse_ls_unix ( char *str, | |
27 int cols, | |
28 gftp_file * fle ); | |
29 static int gftp_parse_ls_nt ( char *str, | |
30 gftp_file * fle ); | |
31 static int gftp_parse_ls_novell ( char *str, | |
32 gftp_file * fle ); | |
33 static char *copy_token ( char **dest, | |
34 char *source ); | |
35 static char *goto_next_token ( char *pos ); | |
36 static GList * gftp_get_dir_listing ( gftp_transfer * transfer, | |
37 int getothdir ); | |
38 static GHashTable * gftp_gen_dir_hash ( gftp_request * request ); | |
39 static void gftp_destroy_dir_hash ( GHashTable * dirhash ); | |
40 static void destroy_hash_ent ( gpointer key, | |
41 gpointer value, | |
42 gpointer user_data ); | |
43 | |
44 gftp_request * | |
45 gftp_request_new (void) | |
46 { | |
47 gftp_request *request; | |
48 | |
49 request = g_malloc0 (sizeof (*request)); | |
50 request->sockfd = NULL; | |
51 request->datafd = NULL; | |
52 request->data_type = GFTP_TYPE_BINARY; | |
53 return (request); | |
54 } | |
55 | |
56 | |
57 void | |
58 gftp_request_destroy (gftp_request * request) | |
59 { | |
60 g_return_if_fail (request != NULL); | |
61 | |
62 gftp_disconnect (request); | |
63 | |
64 if (request->destroy != NULL) | |
65 request->destroy (request); | |
66 | |
67 if (request->hostname) | |
68 g_free (request->hostname); | |
69 if (request->username) | |
70 g_free (request->username); | |
71 if (request->password) | |
72 { | |
73 memset (request->password, 0, strlen (request->password)); | |
74 g_free (request->password); | |
75 } | |
76 if (request->account) | |
77 { | |
78 memset (request->account, 0, strlen (request->account)); | |
79 g_free (request->account); | |
80 } | |
81 if (request->directory) | |
82 g_free (request->directory); | |
83 if (request->proxy_config) | |
84 g_free (request->proxy_config); | |
85 if (request->proxy_hostname) | |
86 g_free (request->proxy_hostname); | |
87 if (request->proxy_username) | |
88 g_free (request->proxy_username); | |
89 if (request->proxy_password) | |
90 g_free (request->proxy_password); | |
91 if (request->proxy_account) | |
92 g_free (request->proxy_account); | |
93 if (request->last_ftp_response) | |
94 g_free (request->last_ftp_response); | |
95 if (request->protocol_data) | |
96 g_free (request->protocol_data); | |
97 if (request->sftpserv_path) | |
98 g_free (request->sftpserv_path); | |
99 memset (request, 0, sizeof (*request)); | |
100 g_free (request); | |
101 } | |
102 | |
103 | |
104 void | |
105 gftp_file_destroy (gftp_file * file) | |
106 { | |
107 g_return_if_fail (file != NULL); | |
108 | |
109 if (file->file) | |
110 g_free (file->file); | |
111 if (file->user) | |
112 g_free (file->user); | |
113 if (file->group) | |
114 g_free (file->group); | |
115 if (file->attribs) | |
116 g_free (file->attribs); | |
117 if (file->destfile) | |
118 g_free (file->destfile); | |
119 memset (file, 0, sizeof (*file)); | |
120 } | |
121 | |
122 | |
123 int | |
124 gftp_connect (gftp_request * request) | |
125 { | |
126 g_return_val_if_fail (request != NULL, -2); | |
127 | |
128 if (request->connect == NULL) | |
129 return (-2); | |
130 | |
131 if (request->sftpserv_path == NULL) | |
132 { | |
133 switch (request->protonum) | |
134 { | |
135 case GFTP_SSH_NUM: | |
136 request->sftpserv_path = g_strconcat (ssh1_sftp_path, NULL); | |
137 break; | |
138 case GFTP_SSHV2_NUM: | |
139 request->sftpserv_path = g_strconcat (ssh2_sftp_path, NULL); | |
140 break; | |
141 } | |
142 } | |
143 | |
144 gftp_set_config_options (request); | |
145 | |
146 return (request->connect (request)); | |
147 } | |
148 | |
149 | |
150 void | |
151 gftp_disconnect (gftp_request * request) | |
152 { | |
153 g_return_if_fail (request != NULL); | |
154 | |
155 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
156 if (request->hostp) | |
157 freeaddrinfo (request->hostp); | |
158 #endif | |
159 request->hostp = NULL; | |
160 | |
161 if (request->sftpserv_path != NULL) | |
162 { | |
163 g_free (request->sftpserv_path); | |
164 request->sftpserv_path = NULL; | |
165 } | |
166 | |
167 request->cached = 0; | |
168 if (request->disconnect == NULL) | |
169 return; | |
170 request->disconnect (request); | |
171 } | |
172 | |
173 | |
174 size_t | |
175 gftp_get_file (gftp_request * request, const char *filename, FILE * fd, | |
176 size_t startsize) | |
177 { | |
178 g_return_val_if_fail (request != NULL, -2); | |
179 | |
180 request->cached = 0; | |
181 if (request->get_file == NULL) | |
182 return (-2); | |
183 return (request->get_file (request, filename, fd, startsize)); | |
184 } | |
185 | |
186 | |
187 int | |
188 gftp_put_file (gftp_request * request, const char *filename, FILE * fd, | |
189 size_t startsize, size_t totalsize) | |
190 { | |
191 g_return_val_if_fail (request != NULL, -2); | |
192 | |
193 request->cached = 0; | |
194 if (request->put_file == NULL) | |
195 return (-2); | |
196 return (request->put_file (request, filename, fd, startsize, totalsize)); | |
197 } | |
198 | |
199 | |
200 long | |
201 gftp_transfer_file (gftp_request * fromreq, const char *fromfile, | |
202 FILE * fromfd, size_t fromsize, | |
203 gftp_request * toreq, const char *tofile, | |
204 FILE * tofd, size_t tosize) | |
205 { | |
206 long size; | |
207 | |
208 g_return_val_if_fail (fromreq != NULL, -2); | |
209 g_return_val_if_fail (fromfile != NULL, -2); | |
210 g_return_val_if_fail (toreq != NULL, -2); | |
211 g_return_val_if_fail (tofile != NULL, -2); | |
212 | |
213 if (strcmp (fromreq->protocol_name, toreq->protocol_name) == 0) | |
214 { | |
215 if (fromreq->transfer_file == NULL) | |
216 return (-2); | |
217 return (fromreq->transfer_file (fromreq, fromfile, fromsize, toreq, | |
218 tofile, tosize)); | |
219 } | |
220 | |
221 fromreq->cached = 0; | |
222 toreq->cached = 0; | |
223 if ((size = gftp_get_file (fromreq, fromfile, fromfd, tosize)) < 0) | |
224 return (-2); | |
225 | |
226 if (gftp_put_file (toreq, tofile, tofd, tosize, size) != 0) | |
227 { | |
40 | 228 if (gftp_abort_transfer (fromreq) != 0) |
229 gftp_end_transfer (fromreq); | |
230 | |
1 | 231 return (-2); |
232 } | |
233 | |
234 return (size); | |
235 } | |
236 | |
237 | |
238 size_t | |
239 gftp_get_next_file_chunk (gftp_request * request, char *buf, size_t size) | |
240 { | |
241 struct timeval tv; | |
242 fd_set fset; | |
243 size_t len; | |
244 | |
245 g_return_val_if_fail (request != NULL, -2); | |
246 g_return_val_if_fail (buf != NULL, -2); | |
247 | |
248 if (request->get_next_file_chunk != NULL) | |
249 return (request->get_next_file_chunk (request, buf, size)); | |
250 | |
251 FD_ZERO (&fset); | |
252 FD_SET (fileno (request->datafd), &fset); | |
253 tv.tv_sec = request->network_timeout; | |
254 tv.tv_usec = 0; | |
255 if (select (fileno (request->datafd) + 1, &fset, NULL, NULL, &tv) <= 0) | |
256 { | |
257 request->logging_function (gftp_logging_error, request->user_data, | |
258 _("Connection to %s timed out\n"), | |
259 request->hostname); | |
260 gftp_disconnect (request); | |
261 return (-1); | |
262 } | |
263 | |
264 if ((len = read (fileno (request->datafd), buf, size)) == -1) | |
265 { | |
266 request->logging_function (gftp_logging_error, request->user_data, | |
267 _("Error reading from host %s: %s\n"), | |
268 request->hostname, | |
269 g_strerror (errno)); | |
270 gftp_disconnect (request); | |
271 return (-1); | |
272 } | |
273 return (len); | |
274 } | |
275 | |
276 | |
277 size_t | |
278 gftp_put_next_file_chunk (gftp_request * request, char *buf, size_t size) | |
279 { | |
280 struct timeval tv; | |
281 size_t len, ret; | |
282 fd_set fset; | |
283 char *pos; | |
284 | |
285 g_return_val_if_fail (request != NULL, -2); | |
286 | |
287 ret = size; | |
288 if (request->put_next_file_chunk != NULL) | |
289 return (request->put_next_file_chunk (request, buf, size)); | |
290 | |
291 if (size == 0) | |
292 return (0); | |
293 | |
294 pos = buf; | |
295 while (size > 0) | |
296 { | |
297 FD_ZERO (&fset); | |
298 FD_SET (fileno (request->datafd), &fset); | |
299 tv.tv_sec = request->network_timeout; | |
300 tv.tv_usec = 0; | |
301 if (!select (fileno (request->datafd) + 1, NULL, &fset, NULL, &tv)) | |
302 { | |
303 request->logging_function (gftp_logging_error, request->user_data, | |
304 _("Connection to %s timed out\n"), | |
305 request->hostname); | |
306 gftp_disconnect (request); | |
307 return (-1); | |
308 } | |
309 | |
310 if ((len = write (fileno (request->datafd), pos, size)) < 0) | |
311 { | |
312 request->logging_function (gftp_logging_error, request->user_data, | |
313 _("Error writing to host %s: %s\n"), | |
314 request->hostname, | |
315 g_strerror (errno)); | |
316 gftp_disconnect (request); | |
317 return (-1); | |
318 } | |
319 size -= len; | |
320 pos += len; | |
321 } | |
322 | |
323 return (ret); | |
324 } | |
325 | |
326 | |
327 int | |
328 gftp_end_transfer (gftp_request * request) | |
329 { | |
330 int ret; | |
331 | |
332 g_return_val_if_fail (request != NULL, -2); | |
333 | |
40 | 334 if (!request->cached && |
335 request->end_transfer != NULL) | |
336 ret = request->end_transfer (request); | |
337 else | |
338 ret = 0; | |
1 | 339 |
340 if (request->cachefd != NULL) | |
341 { | |
342 fclose (request->cachefd); | |
343 request->cachefd = NULL; | |
344 } | |
345 | |
346 if (request->last_dir_entry) | |
347 { | |
348 g_free (request->last_dir_entry); | |
349 request->last_dir_entry = NULL; | |
350 request->last_dir_entry_len = 0; | |
351 } | |
352 | |
353 return (ret); | |
354 } | |
355 | |
356 | |
357 int | |
40 | 358 gftp_abort_transfer (gftp_request * request) |
359 { | |
360 g_return_val_if_fail (request != NULL, -2); | |
361 | |
362 if (request->abort_transfer == NULL) | |
363 return (-2); | |
364 | |
365 return (request->abort_transfer (request)); | |
366 } | |
367 | |
368 | |
369 int | |
1 | 370 gftp_list_files (gftp_request * request) |
371 { | |
372 FILE * fd; | |
373 | |
374 g_return_val_if_fail (request != NULL, -2); | |
375 | |
376 request->cached = 0; | |
377 if (request->use_cache && (fd = gftp_find_cache_entry (request)) != NULL) | |
378 { | |
379 request->logging_function (gftp_logging_misc, request->user_data, | |
380 _("Loading directory listing %s from cache\n"), | |
381 request->directory); | |
382 | |
383 request->cachefd = fd; | |
384 request->cached = 1; | |
385 return (0); | |
386 } | |
387 else if (request->use_cache) | |
388 { | |
389 request->cachefd = gftp_new_cache_entry (request); | |
390 request->cached = 0; | |
391 } | |
392 | |
393 if (request->list_files == NULL) | |
394 return (-2); | |
395 return (request->list_files (request)); | |
396 } | |
397 | |
398 | |
399 int | |
400 gftp_get_next_file (gftp_request * request, char *filespec, gftp_file * fle) | |
401 { | |
402 FILE * fd; | |
403 int ret; | |
404 | |
405 g_return_val_if_fail (request != NULL, -2); | |
406 | |
407 if (request->get_next_file == NULL) | |
408 return (-2); | |
409 | |
410 if (request->cached && request->cachefd != NULL) | |
411 fd = request->cachefd; | |
412 else | |
413 fd = request->datafd; | |
414 | |
415 memset (fle, 0, sizeof (*fle)); | |
416 do | |
417 { | |
418 gftp_file_destroy (fle); | |
419 ret = request->get_next_file (request, fle, fd); | |
420 | |
421 if (ret >= 0 && !request->cached && request->cachefd != NULL && | |
422 request->last_dir_entry != NULL) | |
423 { | |
424 fwrite (request->last_dir_entry, 1, request->last_dir_entry_len, | |
425 request->cachefd); | |
426 if (ferror (request->cachefd)) | |
427 { | |
428 request->logging_function (gftp_logging_error, request->user_data, | |
429 _("Error: Cannot write to cache: %s\n"), | |
430 g_strerror (errno)); | |
431 fclose (request->cachefd); | |
432 request->cachefd = NULL; | |
433 } | |
434 } | |
435 } while (ret > 0 && !gftp_match_filespec (fle->file, filespec)); | |
436 | |
437 return (ret); | |
438 } | |
439 | |
440 | |
441 int | |
442 gftp_parse_url (gftp_request * request, const char *url) | |
443 { | |
444 char *pos, *endpos, *endhostpos, *str, tempchar; | |
445 const char *stpos; | |
446 int len, i; | |
447 | |
448 g_return_val_if_fail (request != NULL, -2); | |
449 g_return_val_if_fail (url != NULL, -2); | |
450 | |
451 for (stpos = url; *stpos == ' '; stpos++); | |
452 | |
453 if ((pos = strstr (stpos, "://")) != NULL) | |
454 { | |
455 *pos = '\0'; | |
456 | |
457 for (i = 0; gftp_protocols[i].url_prefix; i++) | |
458 { | |
459 if (strcmp (gftp_protocols[i].url_prefix, stpos) == 0) | |
460 break; | |
461 } | |
462 | |
463 if (gftp_protocols[i].url_prefix == NULL) | |
464 return (-2); | |
465 *pos = ':'; | |
466 } | |
467 else | |
468 { | |
469 for (i = 0; gftp_protocols[i].url_prefix; i++) | |
470 { | |
471 if (strcmp (gftp_protocols[i].name, default_protocol) == 0) | |
472 break; | |
473 } | |
474 | |
475 if (gftp_protocols[i].url_prefix == NULL) | |
476 i = GFTP_FTP_NUM; | |
477 } | |
478 | |
479 gftp_protocols[i].init (request); | |
480 | |
481 if (request->parse_url != NULL) | |
482 return (request->parse_url (request, url)); | |
483 | |
484 if (i == GFTP_LOCAL_NUM) | |
485 { | |
486 request->directory = g_malloc (strlen (stpos + 6) + 1); | |
487 strcpy (request->directory, stpos + 6); | |
488 return (0); | |
489 } | |
490 | |
491 for (; *stpos == ' '; stpos++); | |
492 str = g_malloc (strlen (stpos) + 1); | |
493 strcpy (str, stpos); | |
494 for (pos = str + strlen (str) - 1; *pos == ' '; pos--) | |
495 *pos = '\0'; | |
496 | |
497 pos = str; | |
498 len = strlen (request->url_prefix); | |
499 if (strncmp (pos, request->url_prefix, len) == 0 | |
500 && strncmp (pos + len, "://", 3) == 0) | |
501 pos += len + 3; | |
502 | |
503 if ((endhostpos = strchr (pos, '@')) != NULL) | |
504 { | |
505 /* A user/password was entered */ | |
506 if ((endpos = strchr (pos, ':')) == NULL || endhostpos < endpos) | |
507 { | |
508 /* No password was entered */ | |
509 gftp_set_password (request, ""); | |
510 endpos = endhostpos; | |
511 } | |
512 | |
513 *endpos = '\0'; | |
514 gftp_set_username (request, pos); | |
515 | |
516 pos = endpos + 1; | |
517 if ((endpos = strchr (pos, '@')) != NULL) | |
518 { | |
519 if (strchr (endpos + 1, '@') != NULL) | |
520 endpos = strchr (endpos + 1, '@'); | |
521 *endpos = '\0'; | |
522 gftp_set_password (request, pos); | |
523 | |
524 pos = endpos + 1; | |
525 } | |
526 } | |
527 | |
528 /* Now get the hostname and an optional port and optional directory */ | |
529 endhostpos = pos + strlen (pos); | |
530 if ((endpos = strchr (pos, ':')) != NULL) | |
531 endhostpos = endpos; | |
532 else if ((endpos = strchr (pos, '/')) != NULL) | |
533 endhostpos = endpos; | |
534 tempchar = *endhostpos; | |
535 *endhostpos = '\0'; | |
536 gftp_set_hostname (request, pos); | |
537 *endhostpos = tempchar; | |
538 | |
539 if ((endpos = strchr (pos, ':')) != NULL) | |
540 { | |
541 /* A port was entered */ | |
542 pos = endpos + 1; | |
543 gftp_set_port (request, strtol (pos, NULL, 10)); | |
544 } | |
545 if ((endpos = strchr (pos, '/')) != NULL) | |
546 gftp_set_directory (request, endpos); | |
547 g_free (str); | |
548 return (0); | |
549 } | |
550 | |
551 | |
552 int | |
553 gftp_set_data_type (gftp_request * request, int data_type) | |
554 { | |
555 g_return_val_if_fail (request != NULL, -2); | |
556 | |
557 if (request->set_data_type == NULL) | |
558 return (-2); | |
559 return (request->set_data_type (request, data_type)); | |
560 } | |
561 | |
562 | |
563 void | |
564 gftp_set_hostname (gftp_request * request, const char *hostname) | |
565 { | |
566 g_return_if_fail (request != NULL); | |
567 g_return_if_fail (hostname != NULL); | |
568 | |
569 if (request->hostname) | |
570 g_free (request->hostname); | |
571 request->hostname = g_malloc (strlen (hostname) + 1); | |
572 strcpy (request->hostname, hostname); | |
573 } | |
574 | |
575 | |
576 void | |
577 gftp_set_username (gftp_request * request, const char *username) | |
578 { | |
579 g_return_if_fail (request != NULL); | |
580 g_return_if_fail (username != NULL); | |
581 | |
582 if (request->username) | |
583 g_free (request->username); | |
584 request->username = g_malloc (strlen (username) + 1); | |
585 strcpy (request->username, username); | |
586 } | |
587 | |
588 | |
589 void | |
590 gftp_set_password (gftp_request * request, const char *password) | |
591 { | |
592 g_return_if_fail (request != NULL); | |
593 g_return_if_fail (password != NULL); | |
594 | |
595 if (request->password) | |
596 g_free (request->password); | |
597 request->password = g_malloc (strlen (password) + 1); | |
598 strcpy (request->password, password); | |
599 } | |
600 | |
601 | |
602 void | |
603 gftp_set_account (gftp_request * request, const char *account) | |
604 { | |
605 g_return_if_fail (request != NULL); | |
606 g_return_if_fail (account != NULL); | |
607 | |
608 if (request->account) | |
609 g_free (request->account); | |
610 request->account = g_malloc (strlen (account) + 1); | |
611 strcpy (request->account, account); | |
612 } | |
613 | |
614 | |
615 int | |
616 gftp_set_directory (gftp_request * request, const char *directory) | |
617 { | |
618 g_return_val_if_fail (request != NULL, -2); | |
619 g_return_val_if_fail (directory != NULL, -2); | |
620 | |
621 | |
622 if (request->sockfd == NULL) | |
623 { | |
624 if (directory != request->directory) | |
625 { | |
626 if (request->directory) | |
627 g_free (request->directory); | |
628 request->directory = g_malloc (strlen (directory) + 1); | |
629 strcpy (request->directory, directory); | |
630 } | |
631 return (0); | |
632 } | |
633 else if (request->chdir == NULL) | |
634 return (-2); | |
635 return (request->chdir (request, directory)); | |
636 } | |
637 | |
638 | |
639 void | |
640 gftp_set_port (gftp_request * request, unsigned int port) | |
641 { | |
642 g_return_if_fail (request != NULL); | |
643 | |
644 request->port = port; | |
645 } | |
646 | |
647 | |
648 void | |
649 gftp_set_proxy_hostname (gftp_request * request, const char *hostname) | |
650 { | |
651 g_return_if_fail (request != NULL); | |
652 g_return_if_fail (hostname != NULL); | |
653 | |
654 if (request->proxy_hostname) | |
655 g_free (request->proxy_hostname); | |
656 request->proxy_hostname = g_malloc (strlen (hostname) + 1); | |
657 strcpy (request->proxy_hostname, hostname); | |
658 } | |
659 | |
660 | |
661 void | |
662 gftp_set_proxy_username (gftp_request * request, const char *username) | |
663 { | |
664 g_return_if_fail (request != NULL); | |
665 g_return_if_fail (username != NULL); | |
666 | |
667 if (request->proxy_username) | |
668 g_free (request->proxy_username); | |
669 request->proxy_username = g_malloc (strlen (username) + 1); | |
670 strcpy (request->proxy_username, username); | |
671 } | |
672 | |
673 | |
674 void | |
675 gftp_set_proxy_password (gftp_request * request, const char *password) | |
676 { | |
677 g_return_if_fail (request != NULL); | |
678 g_return_if_fail (password != NULL); | |
679 | |
680 if (request->proxy_password) | |
681 g_free (request->proxy_password); | |
682 request->proxy_password = g_malloc (strlen (password) + 1); | |
683 strcpy (request->proxy_password, password); | |
684 } | |
685 | |
686 | |
687 void | |
688 gftp_set_proxy_account (gftp_request * request, const char *account) | |
689 { | |
690 g_return_if_fail (request != NULL); | |
691 g_return_if_fail (account != NULL); | |
692 | |
693 if (request->proxy_account) | |
694 g_free (request->proxy_account); | |
695 request->proxy_account = g_malloc (strlen (account) + 1); | |
696 strcpy (request->proxy_account, account); | |
697 } | |
698 | |
699 | |
700 void | |
701 gftp_set_proxy_port (gftp_request * request, unsigned int port) | |
702 { | |
703 g_return_if_fail (request != NULL); | |
704 | |
705 request->proxy_port = port; | |
706 } | |
707 | |
708 | |
709 int | |
710 gftp_remove_directory (gftp_request * request, const char *directory) | |
711 { | |
712 g_return_val_if_fail (request != NULL, -2); | |
713 | |
714 if (request->rmdir == NULL) | |
715 return (-2); | |
716 return (request->rmdir (request, directory)); | |
717 } | |
718 | |
719 | |
720 int | |
721 gftp_remove_file (gftp_request * request, const char *file) | |
722 { | |
723 g_return_val_if_fail (request != NULL, -2); | |
724 | |
725 if (request->rmfile == NULL) | |
726 return (-2); | |
727 return (request->rmfile (request, file)); | |
728 } | |
729 | |
730 | |
731 int | |
732 gftp_make_directory (gftp_request * request, const char *directory) | |
733 { | |
734 g_return_val_if_fail (request != NULL, -2); | |
735 | |
736 if (request->mkdir == NULL) | |
737 return (-2); | |
738 return (request->mkdir (request, directory)); | |
739 } | |
740 | |
741 | |
742 int | |
743 gftp_rename_file (gftp_request * request, const char *oldname, | |
744 const char *newname) | |
745 { | |
746 g_return_val_if_fail (request != NULL, -2); | |
747 | |
748 if (request->rename == NULL) | |
749 return (-2); | |
750 return (request->rename (request, oldname, newname)); | |
751 } | |
752 | |
753 | |
754 int | |
755 gftp_chmod (gftp_request * request, const char *file, int mode) | |
756 { | |
757 g_return_val_if_fail (request != NULL, -2); | |
758 | |
759 if (request->chmod == NULL) | |
760 return (-2); | |
761 return (request->chmod (request, file, mode)); | |
762 } | |
763 | |
764 | |
765 int | |
766 gftp_set_file_time (gftp_request * request, const char *file, time_t datetime) | |
767 { | |
768 g_return_val_if_fail (request != NULL, -2); | |
769 | |
770 if (request->set_file_time == NULL) | |
771 return (-2); | |
772 return (request->set_file_time (request, file, datetime)); | |
773 } | |
774 | |
775 | |
776 char | |
777 gftp_site_cmd (gftp_request * request, const char *command) | |
778 { | |
779 g_return_val_if_fail (request != NULL, -2); | |
780 | |
781 if (request->site == NULL) | |
782 return (-2); | |
783 return (request->site (request, command)); | |
784 } | |
785 | |
786 | |
787 void | |
788 gftp_set_proxy_config (gftp_request * request, const char *proxy_config) | |
789 { | |
790 int len; | |
791 | |
792 g_return_if_fail (request != NULL); | |
793 g_return_if_fail (proxy_config != NULL); | |
794 | |
795 if (request->proxy_config != NULL) | |
796 g_free (request->proxy_config); | |
797 | |
798 len = strlen (proxy_config); | |
799 | |
800 if (len > 0 && (proxy_config[len - 1] != 'n' || | |
801 proxy_config[len - 2] != '%')) | |
802 len += 2; | |
803 | |
804 request->proxy_config = g_malloc (len + 1); | |
805 strcpy (request->proxy_config, proxy_config); | |
806 if (len != strlen (proxy_config)) | |
807 { | |
808 request->proxy_config[len - 2] = '%'; | |
809 request->proxy_config[len - 1] = 'n'; | |
810 request->proxy_config[len] = '\0'; | |
811 } | |
812 } | |
813 | |
814 | |
815 long | |
816 gftp_get_file_size (gftp_request * request, const char *filename) | |
817 { | |
818 g_return_val_if_fail (request != NULL, 0); | |
819 | |
820 if (request->get_file_size == NULL) | |
821 return (0); | |
822 return (request->get_file_size (request, filename)); | |
823 } | |
824 | |
825 | |
826 int | |
827 gftp_need_proxy (gftp_request * request, char *service) | |
828 { | |
829 gftp_proxy_hosts * hostname; | |
830 unsigned char addy[4]; | |
831 struct sockaddr *addr; | |
832 GList * templist; | |
833 gint32 netaddr; | |
834 char *pos; | |
835 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
836 struct addrinfo hints; | |
837 int port, errnum; | |
838 char serv[8]; | |
839 | |
840 request->hostp = NULL; | |
841 if (proxy_hosts == NULL) | |
842 return (request->proxy_hostname != NULL | |
843 && *request->proxy_hostname != '\0' | |
844 && request->proxy_config != NULL | |
845 && *request->proxy_config != '\0'); | |
846 | |
847 memset (&hints, 0, sizeof (hints)); | |
848 hints.ai_flags = AI_CANONNAME; | |
849 hints.ai_family = AF_INET; | |
850 hints.ai_socktype = SOCK_STREAM; | |
851 | |
852 port = request->use_proxy ? request->proxy_port : request->port; | |
853 if (port == 0) | |
854 strcpy (serv, service); | |
855 else | |
856 snprintf (serv, sizeof (serv), "%d", port); | |
857 | |
858 request->logging_function (gftp_logging_misc, request->user_data, | |
859 _("Looking up %s\n"), request->hostname); | |
860 | |
861 if ((errnum = getaddrinfo (request->hostname, serv, &hints, | |
862 &request->hostp)) != 0) | |
863 { | |
864 request->logging_function (gftp_logging_error, request->user_data, | |
865 _("Cannot look up hostname %s: %s\n"), | |
866 request->hostname, gai_strerror (errnum)); | |
867 return (-1); | |
868 } | |
869 | |
870 addr = request->hostp->ai_addr; | |
871 | |
872 #else /* !HAVE_GETADDRINFO */ | |
873 | |
874 request->hostp = NULL; | |
875 if (proxy_hosts == NULL) | |
876 return (request->proxy_hostname != NULL | |
877 && *request->proxy_hostname != '\0' | |
878 && request->proxy_config != NULL | |
879 && *request->proxy_config != '\0'); | |
880 | |
881 request->logging_function (gftp_logging_misc, request->user_data, | |
882 _("Looking up %s\n"), request->hostname); | |
883 | |
884 if (!(request->hostp = r_gethostbyname (request->hostname, &request->host, | |
885 NULL))) | |
886 { | |
887 request->logging_function (gftp_logging_error, request->user_data, | |
888 _("Cannot look up hostname %s: %s\n"), | |
889 request->hostname, g_strerror (errno)); | |
890 return (-1); | |
891 } | |
892 | |
893 addr = (struct sockaddr *) request->host.h_addr_list[0]; | |
894 | |
895 #endif /* HAVE_GETADDRINFO */ | |
896 | |
897 templist = proxy_hosts; | |
898 while (templist != NULL) | |
899 { | |
900 hostname = templist->data; | |
901 if (hostname->domain && | |
902 strlen (request->hostname) > strlen (hostname->domain)) | |
903 { | |
904 pos = request->hostname + strlen (request->hostname) - | |
905 strlen (hostname->domain); | |
906 if (strcmp (hostname->domain, pos) == 0) | |
907 return (0); | |
908 } | |
909 | |
910 if (hostname->ipv4_network_address != 0) | |
911 { | |
912 memcpy (addy, addr, sizeof (addy)); | |
913 netaddr = | |
914 (((addy[0] & 0xff) << 24) | ((addy[1] & 0xff) << 16) | | |
915 ((addy[2] & 0xff) << 8) | (addy[3] & 0xff)) & | |
916 hostname->ipv4_netmask; | |
917 if (netaddr == hostname->ipv4_network_address) | |
918 return (0); | |
919 } | |
920 templist = templist->next; | |
921 } | |
922 return (request->proxy_hostname != NULL && *request->proxy_hostname != '\0' | |
923 && request->proxy_config != NULL && *request->proxy_config != '\0'); | |
924 } | |
925 | |
926 | |
927 char * | |
928 gftp_convert_ascii (char *buf, ssize_t *len, int direction) | |
929 { | |
930 ssize_t i, j, newsize; | |
931 char *tempstr; | |
932 | |
933 if (direction == GFTP_DIRECTION_DOWNLOAD) | |
934 { | |
935 for (i = 0, j = 0; i < *len; i++) | |
936 { | |
937 if (buf[i] != '\r') | |
938 buf[j++] = buf[i]; | |
939 else | |
940 --*len; | |
941 } | |
942 tempstr = buf; | |
943 } | |
944 else | |
945 { | |
946 newsize = 0; | |
947 for (i = 0; i < *len; i++) | |
948 { | |
949 newsize++; | |
950 if (i > 0 && buf[i] == '\n' && buf[i - 1] != '\r') | |
951 newsize++; | |
952 } | |
953 tempstr = g_malloc (newsize); | |
954 | |
955 for (i = 0, j = 0; i < *len; i++) | |
956 { | |
957 if (i > 0 && buf[i] == '\n' && buf[i - 1] != '\r') | |
958 tempstr[j++] = '\r'; | |
959 tempstr[j++] = buf[i]; | |
960 } | |
961 *len = newsize; | |
962 } | |
963 return (tempstr); | |
964 } | |
965 | |
966 | |
967 int | |
968 gftp_parse_ls (const char *lsoutput, gftp_file * fle) | |
969 { | |
970 int result, cols; | |
971 char *str, *pos; | |
972 | |
973 g_return_val_if_fail (lsoutput != NULL, -2); | |
974 g_return_val_if_fail (fle != NULL, -2); | |
975 | |
976 str = g_malloc (strlen (lsoutput) + 1); | |
977 strcpy (str, lsoutput); | |
978 memset (fle, 0, sizeof (*fle)); | |
979 | |
980 if (str[strlen (str) - 1] == '\n') | |
981 str[strlen (str) - 1] = '\0'; | |
982 if (str[strlen (str) - 1] == '\r') | |
983 str[strlen (str) - 1] = '\0'; | |
984 if (*lsoutput == '+') /* EPLF format */ | |
985 result = gftp_parse_ls_eplf (str, fle); | |
986 else if (isdigit ((int) str[0]) && str[2] == '-') /* DOS/WinNT format */ | |
987 result = gftp_parse_ls_nt (str, fle); | |
988 else if (str[1] == ' ' && str[2] == '[') /* Novell format */ | |
989 result = gftp_parse_ls_novell (str, fle); | |
990 else | |
991 { | |
992 /* UNIX/MacOS format */ | |
993 | |
994 /* If there is no space between the attribs and links field, just make one */ | |
995 if (strlen (str) > 10) | |
996 str[10] = ' '; | |
997 | |
998 /* Determine the number of columns */ | |
999 cols = 0; | |
1000 pos = str; | |
1001 while (*pos != '\0') | |
1002 { | |
1003 while (*pos != '\0' && *pos != ' ' && *pos != '\t') | |
1004 { | |
1005 if (*pos == ':') | |
1006 break; | |
1007 pos++; | |
1008 } | |
1009 | |
1010 cols++; | |
1011 | |
1012 if (*pos == ':') | |
1013 { | |
1014 cols++; | |
1015 break; | |
1016 } | |
1017 | |
1018 while (*pos == ' ' || *pos == '\t') | |
1019 pos++; | |
1020 } | |
1021 | |
1022 if (cols > 6) | |
1023 result = gftp_parse_ls_unix (str, cols, fle); | |
1024 else | |
1025 result = -2; | |
1026 } | |
1027 g_free (str); | |
1028 | |
1029 if (fle->attribs == NULL) | |
1030 return (result); | |
1031 | |
1032 if (*fle->attribs == 'd') | |
1033 fle->isdir = 1; | |
1034 if (*fle->attribs == 'l') | |
1035 fle->islink = 1; | |
1036 if (strchr (fle->attribs, 'x') != NULL && !fle->isdir && !fle->islink) | |
1037 fle->isexe = 1; | |
1038 if (*fle->attribs == 'b') | |
1039 fle->isblock = 1; | |
1040 if (*fle->attribs == 'c') | |
1041 fle->ischar = 1; | |
1042 if (*fle->attribs == 's') | |
1043 fle->issocket = 1; | |
1044 if (*fle->attribs == 'p') | |
1045 fle->isfifo = 1; | |
1046 | |
1047 return (result); | |
1048 } | |
1049 | |
1050 | |
1051 static time_t | |
1052 parse_time (char **str) | |
1053 { | |
1054 const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1055 "Aug", "Sep", "Oct", "Nov", "Dec" }; |
1 | 1056 char *startpos, *endpos, *datepos; |
1057 struct tm curtime, tt; | |
1058 time_t t; | |
1059 int i; | |
1060 | |
1061 startpos = *str; | |
1062 memset (&tt, 0, sizeof (tt)); | |
1063 tt.tm_isdst = -1; | |
1064 if (isdigit ((int) startpos[0]) && startpos[2] == '-') | |
1065 { | |
1066 /* This is how DOS will return the date/time */ | |
1067 /* 07-06-99 12:57PM */ | |
1068 if ((endpos = strchr (startpos, '-')) == NULL) | |
1069 { | |
1070 g_free (str); | |
1071 return (0); | |
1072 } | |
1073 tt.tm_mon = strtol (startpos, NULL, 10) - 1; | |
1074 | |
1075 startpos = endpos + 1; | |
1076 if ((endpos = strchr (startpos, '-')) == NULL) | |
1077 { | |
1078 g_free (str); | |
1079 return (0); | |
1080 } | |
1081 tt.tm_mday = strtol (startpos, NULL, 10); | |
1082 | |
1083 startpos = endpos + 1; | |
1084 if ((endpos = strchr (startpos, ' ')) == NULL) | |
1085 { | |
1086 g_free (str); | |
1087 return (0); | |
1088 } | |
1089 tt.tm_year = strtol (startpos, NULL, 10); | |
1090 | |
1091 while (*endpos == ' ') | |
1092 endpos++; | |
1093 | |
1094 startpos = endpos + 1; | |
1095 if ((endpos = strchr (startpos, ':')) == NULL) | |
1096 { | |
1097 g_free (str); | |
1098 return (0); | |
1099 } | |
1100 tt.tm_hour = strtol (startpos, NULL, 10); | |
1101 | |
1102 startpos = endpos + 1; | |
1103 while ((*endpos != 'A') && (*endpos != 'P')) | |
1104 endpos++; | |
1105 if (*endpos == 'P') | |
1106 { | |
1107 if (tt.tm_hour == 12) | |
1108 tt.tm_hour = 0; | |
1109 else | |
1110 tt.tm_hour += 12; | |
1111 } | |
1112 tt.tm_min = strtol (startpos, NULL, 10); | |
1113 } | |
1114 else | |
1115 { | |
1116 /* This is how most UNIX, Novell, and MacOS ftp servers send their time */ | |
1117 /* Jul 06 12:57 */ | |
1118 t = time (NULL); | |
1119 curtime = *localtime (&t); | |
1120 | |
1121 /* Get the month */ | |
1122 if ((endpos = strchr (startpos, ' ')) == NULL) | |
1123 return (0); | |
1124 for (i = 0; i < 12; i++) | |
1125 { | |
1126 if (strncmp (months[i], startpos, 3) == 0) | |
1127 { | |
1128 tt.tm_mon = i; | |
1129 break; | |
1130 } | |
1131 } | |
1132 | |
1133 /* Skip the blanks till we get to the next entry */ | |
1134 startpos = endpos + 1; | |
1135 while (*startpos == ' ') | |
1136 startpos++; | |
1137 | |
1138 /* Get the day */ | |
1139 if ((endpos = strchr (startpos, ' ')) == NULL) | |
1140 return (0); | |
1141 tt.tm_mday = strtol (startpos, NULL, 10); | |
1142 | |
1143 /* Skip the blanks till we get to the next entry */ | |
1144 startpos = endpos + 1; | |
1145 while (*startpos == ' ') | |
1146 startpos++; | |
1147 | |
1148 if ((datepos = strchr (startpos, ':')) != NULL) | |
1149 { | |
1150 /* No year was specified. We will use the current year */ | |
1151 tt.tm_year = curtime.tm_year; | |
1152 | |
1153 /* If the date is in the future, than the year is from last year */ | |
1154 if ((tt.tm_mon > curtime.tm_mon) || | |
1155 ((tt.tm_mon == curtime.tm_mon) && tt.tm_mday > curtime.tm_mday)) | |
1156 tt.tm_year--; | |
1157 | |
1158 /* Get the hours and the minutes */ | |
1159 tt.tm_hour = strtol (startpos, NULL, 10); | |
1160 tt.tm_min = strtol (datepos + 1, NULL, 10); | |
1161 } | |
1162 else | |
1163 { | |
1164 /* Get the year. The hours and minutes will be assumed to be 0 */ | |
1165 tt.tm_year = strtol (startpos, NULL, 10) - 1900; | |
1166 } | |
1167 } | |
1168 *str = startpos; | |
1169 return (mktime (&tt)); | |
1170 } | |
1171 | |
1172 | |
1173 static int | |
1174 gftp_parse_ls_eplf (char *str, gftp_file * fle) | |
1175 { | |
1176 char *startpos; | |
1177 | |
1178 startpos = str; | |
1179 fle->attribs = g_malloc (11); | |
1180 strcpy (fle->attribs, "----------"); | |
1181 while (startpos) | |
1182 { | |
1183 startpos++; | |
1184 switch (*startpos) | |
1185 { | |
1186 case '/': | |
1187 *fle->attribs = 'd'; | |
1188 break; | |
1189 case 's': | |
1190 fle->size = strtol (startpos + 1, NULL, 10); | |
1191 break; | |
1192 case 'm': | |
1193 fle->datetime = strtol (startpos + 1, NULL, 10); | |
1194 break; | |
1195 } | |
1196 startpos = strchr (startpos, ','); | |
1197 } | |
1198 if ((startpos = strchr (str, 9)) == NULL) | |
1199 return (-2); | |
1200 fle->file = g_malloc (strlen (startpos)); | |
1201 strcpy (fle->file, startpos + 1); | |
1202 fle->user = g_malloc (8); | |
1203 strcpy (fle->user, _("unknown")); | |
1204 fle->group = g_malloc (8); | |
1205 strcpy (fle->group, _("unknown")); | |
1206 return (0); | |
1207 } | |
1208 | |
1209 | |
1210 static int | |
1211 gftp_parse_ls_unix (char *str, int cols, gftp_file * fle) | |
1212 { | |
1213 char *endpos, *startpos; | |
1214 | |
1215 startpos = str; | |
1216 /* Copy file attributes */ | |
1217 if ((startpos = copy_token (&fle->attribs, startpos)) == NULL) | |
1218 return (-2); | |
1219 | |
1220 if (cols >= 9) | |
1221 { | |
1222 /* Skip the number of links */ | |
1223 startpos = goto_next_token (startpos); | |
1224 | |
1225 /* Copy the user that owns this file */ | |
1226 if ((startpos = copy_token (&fle->user, startpos)) == NULL) | |
1227 return (-2); | |
1228 | |
1229 /* Copy the group that owns this file */ | |
1230 if ((startpos = copy_token (&fle->group, startpos)) == NULL) | |
1231 return (-2); | |
1232 } | |
1233 else | |
1234 { | |
1235 fle->group = g_malloc (8); | |
1236 strcpy (fle->group, _("unknown")); | |
1237 if (cols == 8) | |
1238 { | |
1239 if ((startpos = copy_token (&fle->user, startpos)) == NULL) | |
1240 return (-2); | |
1241 } | |
1242 else | |
1243 { | |
1244 fle->user = g_malloc (8); | |
1245 strcpy (fle->user, _("unknown")); | |
1246 } | |
1247 startpos = goto_next_token (startpos); | |
1248 } | |
1249 | |
39 | 1250 /* FIXME - this is a bug if there is some extra spaces in the file */ |
1 | 1251 /* See if this is a Cray directory listing. It has the following format: |
1252 drwx------ 2 feiliu g913 DK common 4096 Sep 24 2001 wv */ | |
1253 if (cols == 11 && strstr (str, "->") == NULL) | |
1254 { | |
1255 startpos = goto_next_token (startpos); | |
1256 startpos = goto_next_token (startpos); | |
1257 } | |
1258 | |
1259 /* See if this is a block or character device. We will store the major number | |
1260 in the high word and the minor number in the low word. */ | |
1261 if ((fle->attribs[0] == 'b' || fle->attribs[0] == 'u' || | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1262 fle->attribs[0] == 'c') && |
1 | 1263 ((endpos = strchr (startpos, ',')) != NULL)) |
1264 { | |
1265 fle->size = strtol (startpos, NULL, 10) << 16; | |
1266 | |
1267 startpos = endpos + 1; | |
1268 while (*startpos == ' ') | |
1269 startpos++; | |
1270 | |
1271 /* Get the minor number */ | |
1272 if ((endpos = strchr (startpos, ' ')) == NULL) | |
1273 return (-2); | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1274 fle->size |= strtol (startpos, NULL, 10) & 0xFF; |
1 | 1275 } |
1276 else | |
1277 { | |
1278 /* This is a regular file */ | |
1279 if ((endpos = strchr (startpos, ' ')) == NULL) | |
1280 return (-2); | |
1281 fle->size = strtol (startpos, NULL, 10); | |
1282 } | |
1283 | |
1284 /* Skip the blanks till we get to the next entry */ | |
1285 startpos = endpos + 1; | |
1286 while (*startpos == ' ') | |
1287 startpos++; | |
1288 | |
1289 if ((fle->datetime = parse_time (&startpos)) == 0) | |
1290 return (-2); | |
1291 | |
1292 /* Skip the blanks till we get to the next entry */ | |
1293 startpos = goto_next_token (startpos); | |
1294 | |
1295 /* Parse the filename. If this file is a symbolic link, remove the -> part */ | |
1296 if (fle->attribs[0] == 'l' && ((endpos = strstr (startpos, "->")) != NULL)) | |
1297 *(endpos - 1) = '\0'; | |
1298 fle->file = g_malloc (strlen (startpos) + 1); | |
1299 | |
1300 strcpy (fle->file, startpos); | |
1301 | |
1302 /* Uncomment this if you want to strip the spaces off of the end of the file. | |
1303 I don't want to do this by default since there are valid filenames with | |
1304 spaces at the end of them. Some broken FTP servers like the Paradyne IPC | |
1305 DSLAMS append a bunch of spaces at the end of the file. | |
1306 for (endpos = fle->file + strlen (fle->file) - 1; | |
1307 *endpos == ' '; | |
1308 *endpos-- = '\0'); | |
1309 */ | |
1310 | |
1311 return (0); | |
1312 } | |
1313 | |
1314 | |
1315 static int | |
1316 gftp_parse_ls_nt (char *str, gftp_file * fle) | |
1317 { | |
1318 char *startpos; | |
1319 | |
1320 startpos = str; | |
1321 if ((fle->datetime = parse_time (&startpos)) == 0) | |
1322 return (-2); | |
1323 | |
1324 /* No such thing on Windoze.. */ | |
1325 fle->user = g_malloc (8); | |
1326 strcpy (fle->user, _("unknown")); | |
1327 fle->group = g_malloc (8); | |
1328 strcpy (fle->group, _("unknown")); | |
1329 | |
1330 startpos = goto_next_token (startpos); | |
1331 fle->attribs = g_malloc (11); | |
1332 if (startpos[0] == '<') | |
1333 strcpy (fle->attribs, "drwxrwxrwx"); | |
1334 else | |
1335 { | |
1336 strcpy (fle->attribs, "-rw-rw-rw-"); | |
1337 fle->size = strtol (startpos, NULL, 10); | |
1338 } | |
1339 startpos = goto_next_token (startpos); | |
1340 fle->file = g_malloc (strlen (startpos) + 1); | |
1341 strcpy (fle->file, startpos); | |
1342 return (0); | |
1343 } | |
1344 | |
1345 | |
1346 static int | |
1347 gftp_parse_ls_novell (char *str, gftp_file * fle) | |
1348 { | |
1349 char *startpos; | |
1350 | |
1351 if (str[12] != ' ') | |
1352 return (-2); | |
1353 str[12] = '\0'; | |
1354 fle->attribs = g_malloc (13); | |
1355 strcpy (fle->attribs, str); | |
1356 startpos = str + 13; | |
1357 | |
1358 while ((*startpos == ' ' || *startpos == '\t') && *startpos != '\0') | |
1359 startpos++; | |
1360 | |
1361 if ((startpos = copy_token (&fle->user, startpos)) == NULL) | |
1362 return (-2); | |
1363 | |
1364 fle->group = g_malloc (8); | |
1365 strcpy (fle->group, _("unknown")); | |
1366 | |
1367 fle->size = strtol (startpos, NULL, 10); | |
1368 | |
1369 startpos = goto_next_token (startpos); | |
1370 if ((fle->datetime = parse_time (&startpos)) == 0) | |
1371 return (-2); | |
1372 | |
1373 startpos = goto_next_token (startpos); | |
1374 fle->file = g_malloc (strlen (startpos) + 1); | |
1375 strcpy (fle->file, startpos); | |
1376 return (0); | |
1377 } | |
1378 | |
1379 | |
1380 static char * | |
1381 copy_token (char **dest, char *source) | |
1382 { | |
1383 /* This function is used internally by gftp_parse_ls () */ | |
39 | 1384 char *endpos, savepos; |
1 | 1385 |
1386 endpos = source; | |
1387 while (*endpos != ' ' && *endpos != '\t' && *endpos != '\0') | |
1388 endpos++; | |
1389 if (*endpos == '\0') | |
1390 return (NULL); | |
39 | 1391 |
1392 savepos = *endpos; | |
1 | 1393 *endpos = '\0'; |
1394 *dest = g_malloc (endpos - source + 1); | |
1395 strcpy (*dest, source); | |
39 | 1396 *endpos = savepos; |
1 | 1397 |
1398 /* Skip the blanks till we get to the next entry */ | |
1399 source = endpos + 1; | |
1400 while ((*source == ' ' || *source == '\t') && *source != '\0') | |
1401 source++; | |
1402 return (source); | |
1403 } | |
1404 | |
1405 | |
1406 static char * | |
1407 goto_next_token (char *pos) | |
1408 { | |
1409 while (*pos != ' ' && *pos != '\t' && *pos != '\0') | |
1410 pos++; | |
39 | 1411 |
1 | 1412 if (pos == '\0') |
1413 return (pos); | |
39 | 1414 |
1 | 1415 while ((*pos == ' ' || *pos == '\t') && *pos != '\0') |
1416 pos++; | |
39 | 1417 |
1 | 1418 return (pos); |
1419 } | |
1420 | |
1421 | |
1422 static GList * | |
1423 gftp_get_dir_listing (gftp_transfer * transfer, int getothdir) | |
1424 { | |
1425 unsigned long *newsize; | |
1426 GHashTable * dirhash; | |
1427 GList * templist; | |
1428 gftp_file * fle; | |
1429 char *newname; | |
1430 | |
1431 if (getothdir && transfer->toreq) | |
1432 dirhash = gftp_gen_dir_hash (transfer->toreq); | |
1433 else | |
1434 dirhash = NULL; | |
1435 | |
1436 if (gftp_list_files (transfer->fromreq) != 0) | |
1437 return (NULL); | |
1438 | |
1439 fle = g_malloc (sizeof (*fle)); | |
1440 templist = NULL; | |
1441 while (gftp_get_next_file (transfer->fromreq, NULL, fle) > 0) | |
1442 { | |
1443 if (strcmp (fle->file, ".") == 0 || strcmp (fle->file, "..") == 0) | |
1444 { | |
1445 gftp_file_destroy (fle); | |
1446 continue; | |
1447 } | |
1448 | |
1449 if (dirhash && | |
1450 (newsize = g_hash_table_lookup (dirhash, fle->file)) != NULL) | |
1451 fle->startsize = *newsize; | |
1452 | |
1453 if (transfer->toreq) | |
1454 fle->destfile = g_strconcat (transfer->toreq->directory, "/", | |
1455 fle->file, NULL); | |
1456 newname = g_strconcat (transfer->fromreq->directory, "/", fle->file, NULL); | |
1457 g_free (fle->file); | |
1458 fle->file = newname; | |
1459 | |
1460 templist = g_list_append (templist, fle); | |
1461 | |
1462 fle = g_malloc (sizeof (*fle)); | |
1463 } | |
1464 gftp_end_transfer (transfer->fromreq); | |
1465 | |
1466 gftp_file_destroy (fle); | |
1467 g_free (fle); | |
1468 | |
1469 if (dirhash) | |
1470 gftp_destroy_dir_hash (dirhash); | |
1471 | |
1472 | |
1473 return (templist); | |
1474 } | |
1475 | |
1476 | |
1477 int | |
1478 gftp_get_all_subdirs (gftp_transfer * transfer, | |
1479 void (*update_func) (gftp_transfer * transfer)) | |
1480 { | |
1481 char *oldfromdir, *oldtodir, *newname; | |
1482 GList * templist, * lastlist; | |
1483 int forcecd, remotechanged; | |
1484 unsigned long *newsize; | |
1485 GHashTable * dirhash; | |
1486 gftp_file * curfle; | |
1487 | |
1488 g_return_val_if_fail (transfer != NULL, -1); | |
1489 g_return_val_if_fail (transfer->fromreq != NULL, -1); | |
1490 g_return_val_if_fail (transfer->files != NULL, -1); | |
1491 | |
1492 if (transfer->toreq != NULL) | |
1493 dirhash = gftp_gen_dir_hash (transfer->toreq); | |
1494 else | |
1495 dirhash = NULL; | |
1496 | |
1497 for (lastlist = transfer->files; ; lastlist = lastlist->next) | |
1498 { | |
1499 curfle = lastlist->data; | |
1500 if (dirhash && | |
1501 (newsize = g_hash_table_lookup (dirhash, curfle->file)) != NULL) | |
1502 curfle->startsize = *newsize; | |
1503 | |
1504 if (transfer->toreq) | |
1505 curfle->destfile = g_strconcat (transfer->toreq->directory, "/", | |
1506 curfle->file, NULL); | |
1507 newname = g_strconcat (transfer->fromreq->directory, transfer->fromreq->directory[strlen (transfer->fromreq->directory) - 1] == '/' ? "" : "/", curfle->file, NULL); | |
1508 g_free (curfle->file); | |
1509 curfle->file = newname; | |
1510 | |
1511 if (lastlist->next == NULL) | |
1512 break; | |
1513 } | |
1514 | |
1515 if (dirhash) | |
1516 gftp_destroy_dir_hash (dirhash); | |
1517 | |
1518 oldfromdir = oldtodir = NULL; | |
1519 remotechanged = 0; | |
1520 forcecd = 0; | |
1521 for (templist = transfer->files; templist != NULL; templist = templist->next) | |
1522 { | |
1523 curfle = templist->data; | |
1524 | |
1525 if (curfle->isdir) | |
1526 { | |
1527 oldfromdir = transfer->fromreq->directory; | |
1528 transfer->fromreq->directory = curfle->file; | |
1529 | |
1530 if (transfer->toreq) | |
1531 { | |
1532 oldtodir = transfer->toreq->directory; | |
1533 transfer->toreq->directory = curfle->destfile; | |
1534 } | |
1535 forcecd = 1; | |
1536 if (gftp_set_directory (transfer->fromreq, | |
1537 transfer->fromreq->directory) == 0) | |
1538 { | |
1539 if (curfle->startsize > 0 && transfer->toreq) | |
1540 { | |
1541 remotechanged = 1; | |
1542 if (gftp_set_directory (transfer->toreq, | |
1543 transfer->toreq->directory) != 0) | |
1544 curfle->startsize = 0; | |
1545 } | |
1546 | |
1547 lastlist->next = gftp_get_dir_listing (transfer, | |
1548 curfle->startsize > 0); | |
1549 if (lastlist->next != NULL) | |
1550 { | |
1551 lastlist->next->prev = lastlist; | |
1552 for (; lastlist->next != NULL; lastlist = lastlist->next); | |
1553 } | |
1554 transfer->numdirs++; | |
1555 if (update_func) | |
1556 update_func (transfer); | |
1557 } | |
1558 else | |
1559 curfle->transfer_action = GFTP_TRANS_ACTION_SKIP; | |
1560 | |
1561 transfer->fromreq->directory = oldfromdir; | |
1562 if (transfer->toreq) | |
1563 transfer->toreq->directory = oldtodir; | |
1564 } | |
1565 else | |
1566 { | |
1567 curfle->ascii = gftp_get_file_transfer_mode (curfle->file, | |
1568 transfer->fromreq->data_type) == GFTP_TYPE_ASCII; | |
1569 transfer->numfiles++; | |
1570 } | |
1571 } | |
1572 | |
1573 if (forcecd) | |
1574 gftp_set_directory (transfer->fromreq, transfer->fromreq->directory); | |
1575 if (remotechanged && transfer->toreq) | |
1576 gftp_set_directory (transfer->toreq, transfer->toreq->directory); | |
1577 | |
1578 if (update_func) | |
1579 { | |
1580 transfer->numfiles = transfer->numdirs = -1; | |
1581 update_func (transfer); | |
1582 } | |
1583 return (0); | |
1584 } | |
1585 | |
1586 | |
1587 static GHashTable * | |
1588 gftp_gen_dir_hash (gftp_request * request) | |
1589 { | |
1590 unsigned long *newsize; | |
1591 GHashTable * dirhash; | |
1592 gftp_file * fle; | |
1593 char * newname; | |
1594 | |
1595 | |
1596 dirhash = g_hash_table_new (string_hash_function, string_hash_compare); | |
1597 if (gftp_list_files (request) == 0) | |
1598 { | |
1599 fle = g_malloc0 (sizeof (*fle)); | |
1600 while (gftp_get_next_file (request, NULL, fle) > 0) | |
1601 { | |
1602 newname = fle->file; | |
1603 newsize = g_malloc (sizeof (unsigned long)); | |
1604 *newsize = fle->size; | |
1605 g_hash_table_insert (dirhash, newname, newsize); | |
1606 fle->file = NULL; | |
1607 gftp_file_destroy (fle); | |
1608 } | |
1609 gftp_end_transfer (request); | |
1610 g_free (fle); | |
1611 } | |
1612 else | |
1613 { | |
1614 g_hash_table_destroy (dirhash); | |
1615 dirhash = NULL; | |
1616 } | |
1617 return (dirhash); | |
1618 } | |
1619 | |
1620 | |
1621 static void | |
1622 gftp_destroy_dir_hash (GHashTable * dirhash) | |
1623 { | |
1624 g_hash_table_foreach (dirhash, destroy_hash_ent, NULL); | |
1625 g_hash_table_destroy (dirhash); | |
1626 } | |
1627 | |
1628 | |
1629 static void | |
1630 destroy_hash_ent (gpointer key, gpointer value, gpointer user_data) | |
1631 { | |
1632 | |
1633 g_free (key); | |
1634 g_free (value); | |
1635 } | |
1636 | |
1637 | |
1638 int | |
1639 gftp_get_file_transfer_mode (char *filename, int def) | |
1640 { | |
1641 gftp_file_extensions * tempext; | |
1642 GList * templist; | |
1643 int stlen, ret; | |
1644 | |
1645 if (!use_default_dl_types) | |
1646 return (def); | |
1647 | |
1648 ret = def; | |
1649 stlen = strlen (filename); | |
1650 for (templist = registered_exts; templist != NULL; templist = templist->next) | |
1651 { | |
1652 tempext = templist->data; | |
1653 | |
1654 if (stlen >= tempext->stlen && | |
1655 strcmp (&filename[stlen - tempext->stlen], tempext->ext) == 0) | |
1656 { | |
1657 if (toupper (*tempext->ascii_binary == 'A')) | |
1658 ret = GFTP_TYPE_ASCII; | |
1659 else if (toupper (*tempext->ascii_binary == 'B')) | |
1660 ret = GFTP_TYPE_BINARY; | |
1661 break; | |
1662 } | |
1663 } | |
1664 | |
1665 return (ret); | |
1666 } | |
1667 | |
1668 | |
1669 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
1670 int | |
1671 get_port (struct addrinfo *addr) | |
1672 { | |
1673 struct sockaddr_in * saddr; | |
1674 int port; | |
1675 | |
1676 if (addr->ai_family == AF_INET) | |
1677 { | |
1678 saddr = (struct sockaddr_in *) addr->ai_addr; | |
1679 port = ntohs (saddr->sin_port); | |
1680 } | |
1681 else | |
1682 port = 0; | |
1683 | |
1684 return (port); | |
1685 } | |
1686 #endif | |
1687 | |
1688 | |
1689 int | |
1690 gftp_connect_server (gftp_request * request, char *service) | |
1691 { | |
1692 char *connect_host, *disphost; | |
1693 int port, sock; | |
1694 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
1695 struct addrinfo hints, *res; | |
1696 char serv[8]; | |
1697 int errnum; | |
1698 | |
1699 if ((request->use_proxy = gftp_need_proxy (request, service)) < 0) | |
1700 return (-1); | |
1701 else if (request->use_proxy == 1) | |
1702 request->hostp = NULL; | |
1703 | |
1704 memset (&hints, 0, sizeof (hints)); | |
1705 hints.ai_flags = AI_CANONNAME; | |
1706 hints.ai_family = AF_INET; | |
1707 hints.ai_socktype = SOCK_STREAM; | |
1708 | |
1709 connect_host = request->use_proxy ? request->proxy_hostname : | |
1710 request->hostname; | |
1711 port = request->use_proxy ? request->proxy_port : request->port; | |
1712 | |
1713 if (request->hostp == NULL) | |
1714 { | |
1715 if (port == 0) | |
1716 strcpy (serv, service); | |
1717 else | |
1718 snprintf (serv, sizeof (serv), "%d", port); | |
1719 | |
1720 request->logging_function (gftp_logging_misc, request->user_data, | |
1721 _("Looking up %s\n"), connect_host); | |
1722 if ((errnum = getaddrinfo (connect_host, serv, &hints, | |
1723 &request->hostp)) != 0) | |
1724 { | |
1725 request->logging_function (gftp_logging_error, request->user_data, | |
1726 _("Cannot look up hostname %s: %s\n"), | |
1727 connect_host, gai_strerror (errnum)); | |
1728 return (-1); | |
1729 } | |
1730 } | |
1731 | |
1732 disphost = connect_host; | |
1733 for (res = request->hostp; res != NULL; res = res->ai_next) | |
1734 { | |
1735 disphost = res->ai_canonname ? res->ai_canonname : connect_host; | |
1736 port = get_port (res); | |
1737 if ((sock = socket (res->ai_family, res->ai_socktype, | |
1738 res->ai_protocol)) < 0) | |
1739 { | |
1740 request->logging_function (gftp_logging_error, request->user_data, | |
1741 _("Failed to create a socket: %s\n"), | |
1742 g_strerror (errno)); | |
1743 continue; | |
1744 } | |
1745 | |
1746 request->logging_function (gftp_logging_misc, request->user_data, | |
1747 _("Trying %s:%d\n"), disphost, port); | |
1748 | |
1749 if (connect (sock, res->ai_addr, res->ai_addrlen) == -1) | |
1750 { | |
1751 request->logging_function (gftp_logging_error, request->user_data, | |
1752 _("Cannot connect to %s: %s\n"), | |
1753 disphost, g_strerror (errno)); | |
1754 close (sock); | |
1755 continue; | |
1756 } | |
1757 break; | |
1758 } | |
1759 | |
1760 if (res == NULL) | |
1761 { | |
1762 if (request->hostp != NULL) | |
1763 { | |
1764 freeaddrinfo (request->hostp); | |
1765 request->hostp = NULL; | |
1766 } | |
1767 return (-1); | |
1768 } | |
1769 | |
1770 #else /* !HAVE_GETADDRINFO */ | |
1771 struct sockaddr_in remote_address; | |
1772 struct servent serv_struct; | |
1773 int curhost; | |
1774 | |
1775 if ((request->use_proxy = gftp_need_proxy (request, service)) < 0) | |
1776 return (-1); | |
1777 else if (request->use_proxy == 1) | |
1778 request->hostp = NULL; | |
1779 | |
1780 if ((sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) | |
1781 { | |
1782 request->logging_function (gftp_logging_error, request->user_data, | |
1783 _("Failed to create a socket: %s\n"), | |
1784 g_strerror (errno)); | |
1785 return (-1); | |
1786 } | |
1787 | |
1788 memset (&remote_address, 0, sizeof (remote_address)); | |
1789 remote_address.sin_family = AF_INET; | |
1790 | |
1791 connect_host = request->use_proxy ? request->proxy_hostname : | |
1792 request->hostname; | |
1793 port = htons (request->use_proxy ? request->proxy_port : request->port); | |
1794 | |
1795 if (port == 0) | |
1796 { | |
1797 if (!r_getservbyname (service, "tcp", &serv_struct, NULL)) | |
1798 { | |
1799 port = htons (21); | |
1800 request->port = 21; | |
1801 } | |
1802 else | |
1803 { | |
1804 port = serv_struct.s_port; | |
1805 request->port = ntohs (serv_struct.s_port); | |
1806 } | |
1807 } | |
1808 remote_address.sin_port = port; | |
1809 | |
1810 if (request->hostp == NULL) | |
1811 { | |
1812 request->logging_function (gftp_logging_misc, request->user_data, | |
1813 _("Looking up %s\n"), connect_host); | |
1814 if (!(request->hostp = r_gethostbyname (connect_host, &request->host, | |
1815 NULL))) | |
1816 { | |
1817 request->logging_function (gftp_logging_error, request->user_data, | |
1818 _("Cannot look up hostname %s: %s\n"), | |
1819 connect_host, g_strerror (errno)); | |
1820 close (sock); | |
1821 return (-1); | |
1822 } | |
1823 } | |
1824 | |
1825 disphost = NULL; | |
1826 for (curhost = 0; request->host.h_addr_list[curhost] != NULL; curhost++) | |
1827 { | |
1828 disphost = request->host.h_name; | |
1829 memcpy (&remote_address.sin_addr, request->host.h_addr_list[curhost], | |
1830 request->host.h_length); | |
1831 request->logging_function (gftp_logging_misc, request->user_data, | |
1832 _("Trying %s:%d\n"), | |
1833 request->host.h_name, ntohs (port)); | |
1834 | |
1835 if (connect (sock, (struct sockaddr *) &remote_address, | |
1836 sizeof (remote_address)) == -1) | |
1837 { | |
1838 request->logging_function (gftp_logging_error, request->user_data, | |
1839 _("Cannot connect to %s: %s\n"), | |
1840 connect_host, g_strerror (errno)); | |
1841 } | |
1842 break; | |
1843 } | |
1844 | |
1845 if (request->host.h_addr_list[curhost] == NULL) | |
1846 { | |
1847 close (sock); | |
1848 return (-1); | |
1849 } | |
1850 port = ntohs (port); | |
1851 #endif /* HAVE_GETADDRINFO */ | |
1852 | |
1853 request->logging_function (gftp_logging_misc, request->user_data, | |
1854 _("Connected to %s:%d\n"), connect_host, port); | |
1855 return (sock); | |
1856 } | |
1857 | |
1858 | |
1859 void | |
1860 gftp_set_config_options (gftp_request * request) | |
1861 { | |
1862 request->transfer_type = passive_transfer ? gftp_transfer_passive : gftp_transfer_active; | |
1863 request->network_timeout = network_timeout; | |
1864 request->retries = retries; | |
1865 request->sleep_time = sleep_time; | |
1866 request->maxkbs = maxkbs; | |
1867 | |
1868 if (request->protonum == GFTP_SSHV2_NUM || | |
1869 request->protonum == GFTP_SSH_NUM) | |
1870 request->need_userpass = ssh_need_userpass; | |
1871 | |
1872 /* Set up the proxy server settings. If we are using a HTTP proxy for FTP, | |
1873 then set up the HTTP proxy settings */ | |
1874 if ((strcmp (request->protocol_name, "FTP") == 0 || | |
1875 strcmp (request->protocol_name, "HTTP") == 0) && | |
1876 proxy_config != NULL) | |
1877 { | |
1878 if (strcmp (request->protocol_name, "FTP") == 0 && | |
1879 strcmp (proxy_config, "http") != 0) | |
1880 { | |
1881 gftp_set_proxy_hostname (request, firewall_host); | |
1882 gftp_set_proxy_port (request, firewall_port); | |
1883 gftp_set_proxy_username (request, firewall_username); | |
1884 gftp_set_proxy_password (request, firewall_password); | |
1885 gftp_set_proxy_account (request, firewall_account); | |
1886 gftp_set_proxy_config (request, proxy_config); | |
1887 } | |
1888 else | |
1889 { | |
1890 gftp_set_proxy_hostname (request, http_proxy_host); | |
1891 gftp_set_proxy_port (request, http_proxy_port); | |
1892 gftp_set_proxy_username (request, http_proxy_username); | |
1893 gftp_set_proxy_password (request, http_proxy_password); | |
1894 | |
1895 | |
1896 if (request->proxy_config == NULL) | |
1897 { | |
1898 if (strcmp (GFTP_GET_PROTOCOL_NAME (request), "FTP") == 0) | |
1899 { | |
1900 gftp_protocols[GFTP_HTTP_NUM].init (request); | |
1901 request->proxy_config = g_malloc (4); | |
1902 strcpy (request->proxy_config, "ftp"); | |
1903 } | |
1904 else | |
1905 { | |
1906 request->proxy_config = g_malloc (5); | |
1907 strcpy (request->proxy_config, "http"); | |
1908 } | |
1909 } | |
1910 } | |
1911 } | |
1912 } | |
1913 | |
1914 | |
1915 void | |
1916 gftp_set_sftpserv_path (gftp_request * request, char *path) | |
1917 { | |
1918 g_return_if_fail (request != NULL); | |
1919 | |
1920 if (request->sftpserv_path) | |
1921 g_free (request->sftpserv_path); | |
1922 | |
1923 if (path != NULL && *path != '\0') | |
1924 { | |
1925 request->sftpserv_path = g_malloc (strlen (path) + 1); | |
1926 strcpy (request->sftpserv_path, path); | |
1927 } | |
1928 else | |
1929 request->sftpserv_path = NULL; | |
1930 } | |
1931 | |
1932 | |
1933 void | |
1934 print_file_list (GList * list) | |
1935 { | |
1936 gftp_file * tempfle; | |
1937 GList * templist; | |
1938 | |
1939 printf ("--START OF FILE LISTING - TOP TO BOTTOM--\n"); | |
1940 for (templist = list; ; templist = templist->next) | |
1941 { | |
1942 tempfle = templist->data; | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1943 #if defined (_LARGEFILE_SOURCE) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1944 printf ("%s:%s:%lld:%lld:%s:%s:%s\n", |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1945 #else |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1946 printf ("%s:%s:%ld:%ld:%s:%s:%s\n", |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1947 #endif |
16 | 1948 tempfle->file, tempfle->destfile, |
1949 tempfle->size, tempfle->startsize, | |
1950 tempfle->user, tempfle->group, tempfle->attribs); | |
1 | 1951 if (templist->next == NULL) |
1952 break; | |
1953 } | |
1954 | |
1955 printf ("--START OF FILE LISTING - BOTTOM TO TOP--\n"); | |
1956 for (; ; templist = templist->prev) | |
1957 { | |
1958 tempfle = templist->data; | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1959 #if defined (_LARGEFILE_SOURCE) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1960 printf ("%s:%s:%lld:%lld:%s:%s:%s\n", |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1961 #else |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1962 printf ("%s:%s:%ld:%ld:%s:%s:%s\n", |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
7
diff
changeset
|
1963 #endif |
16 | 1964 tempfle->file, tempfle->destfile, |
1965 tempfle->size, tempfle->startsize, | |
1966 tempfle->user, tempfle->group, tempfle->attribs); | |
1 | 1967 if (templist == list) |
1968 break; | |
1969 } | |
1970 printf ("--END OF FILE LISTING--\n"); | |
1971 } | |
1972 |