Mercurial > gftp.yaz
annotate lib/gftp.h @ 84:7ef60ce2bdb2
2002-12-29 Brian Masney <masneyb@gftp.org>
* lib/ssh.c lib/config_file.c lib/Makefile.am lib/gftp.h lib/options.h - removed old legacy SSH protocol and option to enable this protocol
* lib/gftp.h - added GFTP_ERETRYABLE and GFTP_EFATAL error codes
* lib/bookmark.c lib/local.c lib/protocols.c lib/rfc959.c lib/rfc2068.c
lib/sshv2.c - return new error codes instead of -1 or -2
* lib/misc.c (gftp_*_sort_function_ds) - changed return values
* src/gtk/transfer.c (connect_thread) - if return value of
gftp_connect() is GFTP_EFATAL, don't attempt to retry the connection
author | masneyb |
---|---|
date | Sun, 29 Dec 2002 15:16:27 +0000 |
parents | f4f6f44225d3 |
children | 759c7d019a89 |
rev | line source |
---|---|
1 | 1 /*****************************************************************************/ |
2 /* gftp.h - include file for the whole ftp program */ | |
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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
18 /*****************************************************************************/ | |
19 | |
33 | 20 /* $Id$ */ |
21 | |
1 | 22 #ifndef __GFTP_H |
23 #define __GFTP_H | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 #include "config.h" | |
27 #endif | |
28 | |
29 #include <sys/types.h> | |
30 #include <sys/stat.h> | |
31 #include <sys/socket.h> | |
32 #include <sys/time.h> | |
33 #ifndef TIOCGWINSZ | |
34 #include <sys/ioctl.h> | |
35 #endif | |
36 #include <sys/wait.h> | |
37 #include <sys/utsname.h> | |
48 | 38 #include <sys/sysmacros.h> |
1 | 39 #include <netinet/in.h> |
40 #include <arpa/inet.h> | |
41 #include <glib.h> | |
42 #include <limits.h> | |
43 #include <netdb.h> | |
44 #include <stdio.h> | |
45 #include <stdarg.h> | |
46 #include <stdlib.h> | |
47 #include <errno.h> | |
48 #include <fcntl.h> | |
49 #include <unistd.h> | |
50 #include <ctype.h> | |
51 #include <time.h> | |
52 #include <utime.h> | |
53 #include <signal.h> | |
54 #include <termios.h> | |
55 #include <pwd.h> | |
56 #include <setjmp.h> | |
57 #include <dirent.h> | |
58 #include <grp.h> | |
59 #include <math.h> | |
60 | |
80 | 61 #ifdef HAVE_GRANTPT |
62 #include <stropts.h> | |
63 #endif | |
64 | |
1 | 65 #ifdef HAVE_STRING_H |
66 #include <string.h> | |
67 #else | |
68 #include <strings.h> | |
69 #endif | |
70 | |
71 #ifdef ENABLE_NLS | |
72 #include <libintl.h> | |
73 #include <locale.h> | |
74 #define _(String) gettext (String) | |
75 #else | |
76 #define _(String) String | |
77 #endif | |
78 #define N_(String) String | |
79 | |
80 #ifndef AF_LOCAL | |
81 #define AF_LOCAL AF_UNIX | |
82 #endif | |
83 | |
48 | 84 /* We need the major() and minor() macros in the user interface. If they aren't |
85 defined by the system, we'll just define them here. */ | |
86 #ifndef major | |
87 #warning major macro was not defined by the system. Defining one that is probably wrong for your system | |
88 #define major(dev) (((dev) >> 8) & 0xff) | |
89 #endif | |
90 | |
91 #ifndef minor | |
92 #warning minor macro was not defined by the system. Defining one that is probably wrong for your system | |
93 #define minor(dev) ((dev) & 0xff) | |
94 #endif | |
95 | |
1 | 96 #ifdef HAVE_DMALLOC |
97 #include <dmalloc.h> | |
98 #endif | |
99 | |
84 | 100 /* Error types */ |
101 #define GFTP_ERETRYABLE -1 | |
102 #define GFTP_EFATAL -2 | |
103 | |
1 | 104 /* Some general settings */ |
105 #define BASE_CONF_DIR "~/.gftp" | |
106 #define CONFIG_FILE BASE_CONF_DIR "/gftprc" | |
107 #define BOOKMARKS_FILE BASE_CONF_DIR "/bookmarks" | |
108 #define LOG_FILE BASE_CONF_DIR "/gftp.log" | |
109 #define MAX_HIST_LEN 10 | |
110 | |
111 typedef enum gftp_transfer_type_tag | |
112 { | |
113 gftp_transfer_passive, | |
114 gftp_transfer_active | |
115 } gftp_transfer_type; | |
116 | |
117 | |
118 typedef enum gftp_logging_level_tag | |
119 { | |
120 gftp_logging_send, | |
121 gftp_logging_recv, | |
122 gftp_logging_error, | |
123 gftp_logging_misc | |
124 } gftp_logging_level; | |
125 | |
126 typedef void (*gftp_logging_func) ( gftp_logging_level level, | |
127 void *ptr, | |
128 const char *string, ... ); | |
129 | |
130 | |
131 typedef struct gftp_file_tag gftp_file; | |
132 | |
133 #define GFTP_TRANS_ACTION_OVERWRITE 1 | |
134 #define GFTP_TRANS_ACTION_RESUME 2 | |
135 #define GFTP_TRANS_ACTION_SKIP 3 | |
136 | |
137 #define GFTP_DIRECTION_DOWNLOAD 0 | |
138 #define GFTP_DIRECTION_UPLOAD 1 | |
139 | |
16 | 140 #define GFTP_SORT_COL_FILE 1 |
141 #define GFTP_SORT_COL_SIZE 2 | |
142 #define GFTP_SORT_COL_USER 3 | |
143 #define GFTP_SORT_COL_GROUP 4 | |
144 #define GFTP_SORT_COL_DATETIME 5 | |
145 #define GFTP_SORT_COL_ATTRIBS 6 | |
146 | |
1 | 147 struct gftp_file_tag |
148 { | |
149 char *file, /* Our filename */ | |
150 *user, /* User that owns it */ | |
151 *group, /* Group that owns it */ | |
152 *attribs, /* Attribs (-rwxr-x-rx) */ | |
153 *destfile; /* Full pathname to the destination for the | |
154 file transfer */ | |
155 time_t datetime; /* File date and time */ | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
156 off_t size, /* Size of the file */ |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
157 startsize; /* Size to start the transfer at */ |
1 | 158 unsigned int isdir : 1, /* File type */ |
159 isexe : 1, | |
160 islink : 1, | |
161 isblock : 1, | |
162 ischar : 1, | |
163 issocket : 1, | |
164 isfifo : 1, | |
165 ascii : 1, /* Transfer in ASCII mode */ | |
166 selected : 1, /* Is this file selected? */ | |
167 was_sel : 1, /* Was this file selected before */ | |
168 shown : 1, /* Is this file shown? */ | |
169 done_view : 1, /* View the file when done transfering? */ | |
170 done_edit : 1, /* Edit the file when done transfering? */ | |
171 done_rm : 1, /* Remove the file when done */ | |
172 transfer_done : 1, /* Is current file transfer done? */ | |
173 is_fd : 1; /* Is this a file descriptor? */ | |
174 char transfer_action; /* See the GFTP_TRANS_ACTION_* vars above */ | |
175 void *node; /* Pointer to the node for the gui */ | |
58 | 176 int fd; |
1 | 177 }; |
178 | |
179 | |
180 typedef struct gftp_proxy_hosts_tag | |
181 { | |
182 gint32 ipv4_network_address, | |
183 ipv4_netmask; | |
184 char *domain; | |
185 } gftp_proxy_hosts; | |
186 | |
187 | |
188 typedef struct gftp_request_tag gftp_request; | |
189 | |
190 struct gftp_request_tag | |
191 { | |
192 int protonum; /* Current number of the protocol this is | |
193 set to */ | |
194 char *hostname, /* Hostname we will connect to */ | |
195 *username, /* Username for host*/ | |
196 *password, /* Password for host */ | |
197 *account, /* Account for host (FTP only) */ | |
198 *directory, /* Current working directory */ | |
199 *proxy_config, /* Proxy configuration */ | |
200 *proxy_hostname, /* Proxy hostname */ | |
201 *proxy_username, /* Proxy username */ | |
202 *proxy_password, /* Proxy password */ | |
203 *proxy_account, /* Proxy account (FTP only) */ | |
204 *url_prefix, /* URL Prefix (ex: ftp) */ | |
205 *protocol_name, /* Protocol description */ | |
206 *last_ftp_response, /* Last response from server */ | |
207 *last_dir_entry; /* Last dir entry from server */ | |
208 size_t last_dir_entry_len; /* Length of last_dir_entry */ | |
209 | |
210 unsigned int port, /* Port of remote site */ | |
211 proxy_port; /* Port of the proxy server */ | |
212 | |
58 | 213 int sockfd, /* Control connection (read) */ |
214 datafd, /* Data connection */ | |
215 cachefd; /* For the directory cache */ | |
1 | 216 int wakeup_main_thread[2]; /* FD that gets written to by the threads |
217 to wakeup the parent */ | |
218 | |
219 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
220 struct addrinfo *hostp; /* Remote host we are connected to */ | |
221 #else | |
222 struct hostent host, *hostp; /* Remote host we are connected to */ | |
223 #endif | |
224 | |
225 int data_type; /* ASCII or BINARY (FTP only) */ | |
226 unsigned int use_proxy : 1, /* Go out of proxy server */ | |
227 always_connected : 1, | |
228 need_hostport : 1, | |
229 need_userpass : 1, | |
230 use_cache : 1, /* Enable or disable the cache */ | |
231 use_threads : 1, /* Whether we need to spawn a thread | |
232 for this protocol */ | |
233 cached : 1, /* Is this directory listing cached? */ | |
41 | 234 cancel : 1, /* If a signal is received, should |
235 we cancel this operation */ | |
1 | 236 stopable : 1; |
237 | |
238 off_t gotbytes; | |
239 | |
240 void *protocol_data; | |
241 | |
242 gftp_logging_func logging_function; | |
243 void *user_data; | |
244 | |
245 void (*init) ( gftp_request * request ); | |
246 void (*destroy) ( gftp_request * request ); | |
247 int (*connect) ( gftp_request * request ); | |
248 void (*disconnect) ( gftp_request * request ); | |
58 | 249 off_t (*get_file) ( gftp_request * request, |
1 | 250 const char *filename, |
58 | 251 int fd, |
1 | 252 off_t startsize ); |
253 int (*put_file) ( gftp_request * request, | |
254 const char *filename, | |
58 | 255 int fd, |
1 | 256 off_t startsize, |
257 off_t totalsize ); | |
258 long (*transfer_file) ( gftp_request * fromreq, | |
259 const char *fromfile, | |
260 off_t fromsize, | |
261 gftp_request * toreq, | |
262 const char *tofile, | |
263 off_t tosize ); | |
58 | 264 ssize_t (*get_next_file_chunk) ( gftp_request * request, |
1 | 265 char *buf, |
266 size_t size ); | |
58 | 267 ssize_t (*put_next_file_chunk) ( gftp_request * request, |
1 | 268 char *buf, |
269 size_t size ); | |
270 int (*end_transfer) ( gftp_request * request ); | |
40 | 271 int (*abort_transfer) ( gftp_request * request ); |
1 | 272 int (*list_files) ( gftp_request * request ); |
273 int (*get_next_file) ( gftp_request * request, | |
274 gftp_file *fle, | |
58 | 275 int fd ); |
1 | 276 int (*set_data_type) ( gftp_request * request, |
277 int data_type ); | |
278 off_t (*get_file_size) ( gftp_request * request, | |
279 const char *filename ); | |
280 int (*chdir) ( gftp_request * request, | |
281 const char *directory ); | |
282 int (*rmdir) ( gftp_request * request, | |
283 const char *directory ); | |
284 int (*rmfile) ( gftp_request * request, | |
285 const char *filename ); | |
286 int (*mkdir) ( gftp_request * request, | |
287 const char *directory ); | |
288 int (*rename) ( gftp_request * request, | |
289 const char *oldname, | |
290 const char *newname ); | |
291 int (*chmod) ( gftp_request * request, | |
292 const char *filename, | |
293 int mode ); | |
294 int (*set_file_time) ( gftp_request * request, | |
295 const char *filename, | |
296 time_t datettime ); | |
297 int (*site) ( gftp_request * request, | |
298 const char *filename ); | |
299 int (*parse_url) ( gftp_request * request, | |
300 const char *url ); | |
58 | 301 void (*set_config_options) ( gftp_request * request ); |
63 | 302 void (*swap_socks) ( gftp_request * dest, |
303 gftp_request * source ); | |
1 | 304 |
305 /* Options */ | |
306 gftp_transfer_type transfer_type; /* Passive or non-passive (FTP only) */ | |
307 int network_timeout, | |
308 retries, | |
309 sleep_time, | |
310 passive_transfer; | |
311 float maxkbs; | |
312 char *sftpserv_path; | |
313 }; | |
314 | |
315 | |
316 typedef struct gftp_transfer_tag gftp_transfer; | |
317 | |
318 struct gftp_transfer_tag | |
319 { | |
320 gftp_request * fromreq, | |
321 * toreq; | |
322 | |
323 unsigned int transfer_direction : 1, | |
324 cancel : 1, | |
325 ready : 1, | |
326 started : 1, | |
327 done : 1, | |
328 show : 1, | |
329 stalled : 1, | |
330 next_file : 1, | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
331 skip_file : 1; |
1 | 332 |
333 struct timeval starttime, | |
334 lasttime; | |
335 | |
336 double kbs; | |
337 | |
338 GList * files, | |
339 * curfle, | |
340 * updfle; | |
341 | |
19 | 342 long numfiles, |
343 numdirs, | |
344 current_file_number, | |
345 current_file_retries; | |
1 | 346 |
347 off_t curtrans, /* Current transfered bytes for this file */ | |
348 curresumed, /* Resumed bytes for this file */ | |
349 trans_bytes, /* Amount of data transfered for entire | |
350 transfer */ | |
351 total_bytes, /* Grand total bytes for whole transfer */ | |
352 resumed_bytes; /* Grand total of resumed bytes for whole | |
353 transfer */ | |
354 | |
355 void * fromwdata, | |
356 * towdata; | |
357 | |
358 void *statmutex, | |
359 *structmutex; | |
360 void *node; | |
361 void *clist; | |
362 }; | |
363 | |
364 | |
365 typedef struct gftp_log_tag | |
366 { | |
367 char *msg; | |
368 gftp_logging_level type; | |
369 } gftp_log; | |
370 | |
371 | |
372 typedef struct supported_gftp_protocols_tag | |
373 { | |
374 char *name; /* Description of protocol */ | |
375 void (*init) (gftp_request * request); /* Init function */ | |
376 char *url_prefix; /* URL Prefix */ | |
377 int shown; /* Whether this protocol is shown or not to the user | |
378 in the protocol dropdown box */ | |
379 } supported_gftp_protocols; | |
380 | |
381 | |
382 typedef struct gftp_bookmarks_tag gftp_bookmarks; | |
383 | |
384 struct gftp_bookmarks_tag | |
385 { | |
386 char *path; /* Path */ | |
387 char *hostname, /* Our actual internet hostname */ | |
388 *protocol, /* Protocol we will connect through */ | |
389 *remote_dir, /* Initial directory */ | |
390 *local_dir, /* Init local directory */ | |
391 *user, /* Username to log in as */ | |
392 *pass, /* Our password */ | |
393 *acct; /* Account */ | |
394 | |
395 unsigned int port, /* The port we will connect to */ | |
396 isfolder : 1, /* If this is set, then the children field can | |
397 be non-NULL */ | |
398 save_password : 1; /* Save this password */ | |
399 gftp_bookmarks *children, /* The children of this node. */ | |
400 *prev, /* The parent of this node */ | |
401 *next; /* The next sibling of this node */ | |
402 gpointer cnode; | |
403 | |
404 /* Site options */ | |
405 char *sftpserv_path; /* Path to the sftp server */ | |
406 }; | |
407 | |
408 | |
409 typedef struct gftp_file_extensions_tag | |
410 { | |
411 char *ext, /* The file extension to register */ | |
412 *filename, /* The xpm file to display */ | |
413 *view_program, /* The program used to view this file */ | |
414 *ascii_binary; /* Is this a ASCII transfer or a BINARY transfer */ | |
415 int stlen; /* How long is the file extension. */ | |
416 } gftp_file_extensions; | |
417 | |
418 | |
419 typedef struct gftp_color_tag | |
420 { | |
421 gushort red, | |
422 green, | |
423 blue; | |
424 } gftp_color; | |
425 | |
426 | |
427 typedef struct gftp_config_vars_tag | |
428 { | |
429 char *key, /* variable name */ | |
430 *description; /* How this field will show up in the dialog */ | |
431 gpointer var; /* Pointer to our variable */ | |
37 | 432 int type; /* See defines below */ |
1 | 433 char *comment; /* Comment to write out to the config file */ |
434 gpointer widget; | |
37 | 435 int ports_shown; /* What ports of gFTP is this option shown in */ |
1 | 436 } gftp_config_vars; |
437 | |
438 #define CONFIG_INTTEXT 1 | |
439 #define CONFIG_FLOATTEXT 2 | |
440 #define CONFIG_CHECKBOX 3 | |
441 #define CONFIG_LABEL 4 | |
442 #define CONFIG_NOTEBOOK 5 | |
443 #define CONFIG_HIDEINT 6 | |
444 #define CONFIG_TABLE 7 | |
445 #define CONFIG_CHARTEXT 8 | |
446 #define CONFIG_COMBO 9 | |
447 #define CONFIG_TEXT 10 | |
448 #define CONFIG_COLOR 11 | |
449 #define CONFIG_UINTTEXT 12 | |
450 #define CONFIG_CHARPASS 13 | |
451 | |
37 | 452 #define GFTP_PORT_GTK (1 << 1) |
453 #define GFTP_PORT_TEXT (1 << 2) | |
454 #define GFTP_PORT_ALL (GFTP_PORT_GTK | GFTP_PORT_TEXT) | |
455 | |
1 | 456 typedef struct gftp_proxy_type_tag |
457 { | |
458 char *key, | |
459 *description; | |
460 } gftp_proxy_type; | |
461 | |
462 #define GFTP_CUSTOM_PROXY_NUM 8 | |
463 | |
58 | 464 typedef struct gftp_getline_buffer_tag |
465 { | |
466 char *buffer, | |
467 *curpos; | |
468 size_t max_bufsize, | |
469 cur_bufsize; | |
470 } gftp_getline_buffer; | |
471 | |
1 | 472 /* Global config options */ |
473 extern supported_gftp_protocols gftp_protocols[]; | |
474 extern char version[], *emailaddr, *edit_program, *view_program, | |
475 *firewall_host, *firewall_username, *firewall_password, | |
476 *firewall_account, *proxy_config, *http_proxy_host, | |
41 | 477 *http_proxy_username, *http_proxy_password, |
1 | 478 *startup_directory, *ssh_prog_name, *ssh_extra_params, |
479 **ssh_extra_params_list, *default_protocol, *ssh1_sftp_path, | |
480 *ssh2_sftp_path; | |
481 extern int num_ssh_extra_params; | |
482 extern FILE * logfd; | |
483 extern double maxkbs; | |
484 extern GList * proxy_hosts, * registered_exts, * viewedit_processes, | |
485 * file_transfers, * file_transfer_logs; | |
486 extern gftp_bookmarks * bookmarks; | |
487 extern int do_one_transfer_at_a_time, start_file_transfers, | |
488 transfer_in_progress, passive_transfer, sort_dirs_first, | |
74 | 489 show_hidden_files, refresh_files, listbox_local_width, |
490 listbox_remote_width, listbox_file_height, transfer_height, | |
491 log_height, retries, sleep_time, network_timeout, use_http11, | |
492 listbox_dblclick_action, file_trans_column, local_columns[6], | |
493 remote_columns[6], resolve_symlinks, firewall_port, http_proxy_port, | |
84 | 494 overwrite_by_default, append_file_transfers, |
74 | 495 ssh_need_userpass, ssh_use_askpass, sshv2_use_sftp_subsys, |
496 local_sortcol, local_sortasds, remote_sortcol, remote_sortasds; | |
1 | 497 extern guint max_log_window_size; |
498 extern GHashTable * bookmarks_htable, * config_htable; | |
499 extern GList * localhistory, * remotehistory, * host_history, * port_history, | |
500 * user_history; | |
501 extern unsigned int host_len, port_len, user_len, localhistlen, remotehistlen; | |
502 extern volatile sig_atomic_t viewedit_process_done; | |
503 extern gftp_config_vars config_file_vars[]; | |
504 extern gftp_proxy_type proxy_type[]; | |
505 extern gftp_color send_color, recv_color, error_color, misc_color; | |
506 | |
507 /* cache.c */ | |
58 | 508 int gftp_new_cache_entry ( gftp_request * request ); |
1 | 509 |
58 | 510 int gftp_find_cache_entry ( gftp_request * request ); |
1 | 511 |
512 void gftp_clear_cache_files ( void ); | |
513 | |
47 | 514 void gftp_delete_cache_entry ( gftp_request * request, |
515 int ignore_directory ); | |
1 | 516 |
517 /* config_file.c */ | |
518 void gftp_read_config_file ( char **argv, | |
519 int get_xpms ); | |
520 | |
521 void gftp_read_bookmarks ( void ); | |
522 | |
523 void add_to_bookmark ( gftp_bookmarks *newentry ); | |
524 | |
525 void gftp_write_config_file ( void ); | |
526 | |
26 | 527 void gftp_write_bookmarks_file ( void ); |
528 | |
1 | 529 GHashTable * build_bookmarks_hash_table ( gftp_bookmarks * entry ); |
530 | |
531 void print_bookmarks ( gftp_bookmarks * bookmarks ); | |
532 | |
533 /* misc.c */ | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
534 char *insert_commas ( off_t number, |
1 | 535 char *dest_str, |
536 size_t dest_len ); | |
537 | |
538 long file_countlf ( int filefd, | |
539 long endpos ); | |
540 | |
541 char *alltrim ( char *str ); | |
542 | |
543 char *expand_path ( const char *src ); | |
544 | |
545 void remove_double_slashes ( char *string ); | |
546 | |
547 void make_nonnull ( char **str ); | |
548 | |
549 int copyfile ( char *source, | |
550 char *dest ); | |
551 | |
552 char *get_xpm_path ( char *filename, | |
553 int quit_on_err ); | |
554 | |
555 int gftp_match_filespec ( char *filename, | |
556 char *filespec ); | |
557 | |
558 int gftp_parse_command_line ( int *argc, | |
559 char ***argv ); | |
560 | |
561 void gftp_usage ( void ); | |
562 | |
563 gint string_hash_compare ( gconstpointer path1, | |
564 gconstpointer path2 ); | |
565 | |
566 guint string_hash_function ( gconstpointer key ); | |
567 | |
568 void free_file_list ( GList * filelist ); | |
569 | |
570 void free_fdata ( gftp_file * fle ); | |
571 | |
572 gftp_file * copy_fdata ( gftp_file * fle ); | |
573 | |
574 int compare_request ( gftp_request * request1, | |
575 gftp_request * request2, | |
576 int compare_dirs ); | |
577 | |
578 void free_tdata ( gftp_transfer * tdata ); | |
579 | |
580 gftp_request * copy_request ( gftp_request * req ); | |
581 | |
582 int ptym_open ( char *pts_name ); | |
583 | |
584 int ptys_open ( int fdm, | |
585 char *pts_name ); | |
586 | |
587 int tty_raw ( int fd ); | |
588 | |
589 char **make_ssh_exec_args ( gftp_request * request, | |
590 char *execname, | |
591 int use_sftp_subsys, | |
592 char *portstring ); | |
593 | |
594 char * ssh_start_login_sequence ( gftp_request * request, | |
595 int fd ); | |
596 | |
597 #ifdef G_HAVE_GINT64 | |
598 gint64 hton64 ( gint64 val ); | |
599 #endif | |
600 | |
16 | 601 GList * gftp_sort_filelist ( GList * filelist, |
602 int column, | |
603 int asds ); | |
604 | |
1 | 605 /* protocols.c */ |
606 #define GFTP_GET_HOSTNAME(request) (request->hostname) | |
607 #define GFTP_GET_USERNAME(request) (request->username) | |
608 #define GFTP_GET_PASSWORD(request) (request->password) | |
609 #define GFTP_GET_ACCOUNT(request) (request->account) | |
610 #define GFTP_GET_DIRECTORY(request) (request->directory) | |
611 #define GFTP_GET_PORT(request) (request->port) | |
612 #define GFTP_GET_PROXY_CONFIG(request) (request->proxy_config) | |
613 #define GFTP_GET_PROXY_HOSTNAME(request) (request->proxy_hostname) | |
614 #define GFTP_GET_PROXY_USERNAME(request) (request->proxy_username) | |
615 #define GFTP_GET_PROXY_PASSWORD(request) (request->proxy_password) | |
616 #define GFTP_GET_PROXY_ACCOUNT(request) (request->proxy_account) | |
617 #define GFTP_GET_PROXY_PORT(request) (request->proxy_port) | |
618 #define GFTP_GET_URL_PREFIX(request) (request->url_prefix) | |
619 #define GFTP_GET_PROTOCOL_NAME(request) (request->protocol_name) | |
620 #define GFTP_GET_LAST_RESPONSE(request) (request->last_ftp_response) | |
621 #define GFTP_GET_LAST_DIRENT(request) (request->last_dir_entry) | |
622 #define GFTP_GET_LAST_DIRENT_LEN(request) (request->last_dir_entry_len) | |
623 #define GFTP_GET_CONTROL_FD(request) (request->sockfd) | |
624 #define GFTP_GET_DATA_FD(request) (request->datafd) | |
625 #define GFTP_GET_DATA_TYPE(request) (request->data_type) | |
626 #define GFTP_GET_TRANSFER_TYPE(request) (request->transfer_type) | |
627 #define GFTP_SET_TRANSFER_TYPE(request,val) (request->transfer_type = (val)) | |
628 #define GFTP_GET_LOGGING(request) (request->logging) | |
629 #define GFTP_SET_LOGGING(request, val) (request->logging = (val)) | |
630 #define GFTP_UNSAFE_SYMLINKS(request) (request->unsafe_symlinks) | |
631 #define GFTP_FTP_NUM 0 | |
632 #define GFTP_HTTP_NUM 1 | |
633 #define GFTP_LOCAL_NUM 2 | |
634 #define GFTP_SSHV2_NUM 3 | |
635 #define GFTP_BOOKMARK_NUM 4 | |
636 #define GFTP_TYPE_BINARY 1 | |
637 #define GFTP_TYPE_ASCII 2 | |
638 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \ | |
58 | 639 ((request)->sockfd > 0 || \ |
640 (request)->cached || \ | |
641 (request)->always_connected)) | |
1 | 642 |
643 | |
644 void rfc959_init ( gftp_request * request ); | |
645 | |
646 int rfc959_get_next_file ( gftp_request * request, | |
647 gftp_file *fle, | |
58 | 648 int fd ); |
1 | 649 |
650 void rfc2068_init ( gftp_request * request ); | |
651 | |
652 void local_init ( gftp_request * request ); | |
653 | |
654 void sshv2_init ( gftp_request * request ); | |
655 | |
656 void bookmark_init ( gftp_request * request ); | |
657 | |
658 gftp_request *gftp_request_new ( void ); | |
659 | |
67 | 660 void gftp_request_destroy ( gftp_request * request, |
661 int free_request ); | |
1 | 662 |
663 void gftp_file_destroy ( gftp_file *file ); | |
664 | |
665 int gftp_connect ( gftp_request * request ); | |
666 | |
667 void gftp_disconnect ( gftp_request * request ); | |
668 | |
58 | 669 off_t gftp_get_file ( gftp_request * request, |
1 | 670 const char *filename, |
58 | 671 int fd, |
1 | 672 size_t startsize ); |
673 | |
674 int gftp_put_file ( gftp_request * request, | |
675 const char *filename, | |
58 | 676 int fd, |
1 | 677 size_t startsize, |
678 size_t totalsize ); | |
679 | |
680 long gftp_transfer_file ( gftp_request *fromreq, | |
681 const char *fromfile, | |
58 | 682 int fromfd, |
1 | 683 size_t fromsize, |
684 gftp_request *toreq, | |
685 const char *tofile, | |
58 | 686 int tofd, |
1 | 687 size_t tosize ); |
688 | |
58 | 689 ssize_t gftp_get_next_file_chunk ( gftp_request * request, |
1 | 690 char *buf, |
691 size_t size ); | |
692 | |
58 | 693 ssize_t gftp_put_next_file_chunk ( gftp_request * request, |
1 | 694 char *buf, |
695 size_t size ); | |
696 | |
697 int gftp_list_files ( gftp_request * request ); | |
698 | |
699 int gftp_parse_url ( gftp_request * request, | |
700 const char *url ); | |
701 | |
702 int gftp_get_next_file ( gftp_request * request, | |
703 char *filespec, | |
704 gftp_file *fle ); | |
705 | |
706 int gftp_end_transfer ( gftp_request * request ); | |
707 | |
40 | 708 int gftp_abort_transfer ( gftp_request * request ); |
709 | |
1 | 710 int gftp_read_response ( gftp_request * request ); |
711 | |
712 int gftp_set_data_type ( gftp_request * request, | |
713 int data_type ); | |
714 | |
715 void gftp_set_hostname ( gftp_request * request, | |
716 const char *hostname ); | |
717 | |
718 void gftp_set_username ( gftp_request * request, | |
719 const char *username ); | |
720 | |
721 void gftp_set_password ( gftp_request * request, | |
722 const char *password ); | |
723 | |
724 void gftp_set_account ( gftp_request * request, | |
725 const char *account ); | |
726 | |
727 int gftp_set_directory ( gftp_request * request, | |
728 const char *directory ); | |
729 | |
730 void gftp_set_port ( gftp_request * request, | |
731 unsigned int port ); | |
732 | |
733 void gftp_set_proxy_hostname ( gftp_request * request, | |
734 const char *hostname ); | |
735 | |
736 void gftp_set_proxy_username ( gftp_request * request, | |
737 const char *username ); | |
738 | |
739 void gftp_set_proxy_password ( gftp_request * request, | |
740 const char *password ); | |
741 | |
742 void gftp_set_proxy_account ( gftp_request * request, | |
743 const char *account ); | |
744 | |
745 void gftp_set_proxy_port ( gftp_request * request, | |
746 unsigned int port ); | |
747 | |
748 int gftp_remove_directory ( gftp_request * request, | |
749 const char *directory ); | |
750 | |
751 int gftp_remove_file ( gftp_request * request, | |
752 const char *file ); | |
753 | |
754 int gftp_make_directory ( gftp_request * request, | |
755 const char *directory ); | |
756 | |
757 int gftp_rename_file ( gftp_request * request, | |
758 const char *oldname, | |
759 const char *newname ); | |
760 | |
761 int gftp_chmod ( gftp_request * request, | |
762 const char *file, | |
763 int mode ); | |
764 | |
765 int gftp_set_file_time ( gftp_request * request, | |
766 const char *file, | |
767 time_t datetime ); | |
768 | |
769 char gftp_site_cmd ( gftp_request * request, | |
770 const char *command ); | |
771 | |
772 void gftp_set_proxy_config ( gftp_request * request, | |
773 const char *proxy_config ); | |
774 | |
58 | 775 off_t gftp_get_file_size ( gftp_request * request, |
1 | 776 const char *filename ); |
777 | |
778 int gftp_need_proxy ( gftp_request * request, | |
779 char *service ); | |
780 | |
781 char *gftp_convert_ascii ( char *buf, | |
782 ssize_t *len, | |
783 int direction ); | |
784 | |
785 void gftp_calc_kbs ( gftp_transfer * tdata, | |
786 ssize_t num_read ); | |
787 | |
788 int gftp_parse_ls ( const char *lsoutput, | |
789 gftp_file *fle ); | |
790 | |
791 int gftp_get_all_subdirs ( gftp_transfer * transfer, | |
792 void (*update_func) | |
793 ( gftp_transfer * transfer )); | |
794 | |
795 int gftp_get_file_transfer_mode ( char *filename, | |
796 int def ); | |
797 | |
798 int gftp_connect_server ( gftp_request * request, | |
799 char *service ); | |
800 | |
801 void gftp_set_sftpserv_path ( gftp_request * request, | |
802 char *path ); | |
803 | |
804 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
805 | |
806 int get_port ( struct addrinfo *addr ); | |
807 | |
808 #else | |
809 | |
810 struct hostent *r_gethostbyname ( const char *name, | |
811 struct hostent *result_buf, | |
812 int *h_errnop ); | |
813 | |
56 | 814 #endif |
815 | |
1 | 816 struct servent *r_getservbyname ( const char *name, |
817 const char *proto, | |
818 struct servent *result_buf, | |
819 int *h_errnop ); | |
820 void gftp_set_config_options ( gftp_request * request ); | |
821 | |
822 void print_file_list ( GList * list ); | |
823 | |
58 | 824 ssize_t gftp_get_line ( gftp_request * request, |
825 gftp_getline_buffer ** rbuf, | |
41 | 826 char * str, |
827 size_t len, | |
58 | 828 int fd ); |
829 | |
830 ssize_t gftp_read ( gftp_request * request, | |
831 void *ptr, | |
832 size_t size, | |
833 int fd ); | |
41 | 834 |
58 | 835 ssize_t gftp_write ( gftp_request * request, |
836 const char *ptr, | |
41 | 837 size_t size, |
58 | 838 int fd ); |
839 | |
840 ssize_t gftp_writefmt ( gftp_request * request, | |
841 int fd, | |
842 const char *fmt, | |
843 ... ); | |
844 | |
845 int gftp_set_sockblocking ( gftp_request * request, | |
846 int fd, | |
847 int non_blocking ); | |
41 | 848 |
63 | 849 void gftp_swap_socks ( gftp_request * dest, |
850 gftp_request * source ); | |
851 | |
1 | 852 #endif |
853 |