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