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