Mercurial > gftp.yaz
annotate lib/gftp.h @ 879:a41a3590d696
2007-2-14 Brian Masney <masneyb@gftp.org>
* lib/gftp.h src/gtk/gtkui.c src/uicommon/gftpui.c - added refreshing
field to the gftp_request structure. If this is set in
gftpui_common_cmd_open(), then the refresh command is not ran after
a connection is made to the server. This field is currently only
enabled when running called from the refresh function in the GTK+
port. It fixes an issue where the refresh command was being ran
twice. (closes #171732)
author | masneyb |
---|---|
date | Thu, 15 Feb 2007 01:06:49 +0000 |
parents | 2d4e6fca8e7c |
children | 14476a8a4d2b |
rev | line source |
---|---|
1 | 1 /*****************************************************************************/ |
2 /* gftp.h - include file for the whole ftp program */ | |
122 | 3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */ |
1 | 4 /* */ |
5 /* This program is free software; you can redistribute it and/or modify */ | |
6 /* it under the terms of the GNU General Public License as published by */ | |
7 /* the Free Software Foundation; either version 2 of the License, or */ | |
8 /* (at your option) any later version. */ | |
9 /* */ | |
10 /* This program is distributed in the hope that it will be useful, */ | |
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | |
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | |
13 /* GNU General Public License for more details. */ | |
14 /* */ | |
15 /* You should have received a copy of the GNU General Public License */ | |
16 /* along with this program; if not, write to the Free Software */ | |
17 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
18 /*****************************************************************************/ | |
19 | |
33 | 20 /* $Id$ */ |
21 | |
1 | 22 #ifndef __GFTP_H |
23 #define __GFTP_H | |
24 | |
548 | 25 #ifndef _GNU_SOURCE |
26 #define _GNU_SOURCE | |
27 #endif | |
28 | |
1 | 29 #ifdef HAVE_CONFIG_H |
30 #include "config.h" | |
31 #endif | |
32 | |
435 | 33 /* *BSD include 64bit off_t but _LARGEFILE_SOURCE is not defined. */ |
34 #if defined (SIZEOF_OFF_T) && SIZEOF_OFF_T > 4 && !defined (_LARGEFILE_SOURCE) | |
423 | 35 #define _LARGEFILE_SOURCE 1 |
36 #endif | |
37 | |
437 | 38 #if defined (_LARGEFILE_SOURCE) && !defined (_LARGEFILE64_SOURCE) |
39 #define _LARGEFILE64_SOURCE 1 | |
40 #endif | |
41 | |
1 | 42 #include <sys/types.h> |
43 #include <sys/stat.h> | |
44 #include <sys/socket.h> | |
45 #include <sys/time.h> | |
46 #ifndef TIOCGWINSZ | |
47 #include <sys/ioctl.h> | |
48 #endif | |
49 #include <sys/wait.h> | |
50 #include <sys/utsname.h> | |
51 #include <netinet/in.h> | |
52 #include <arpa/inet.h> | |
53 #include <glib.h> | |
54 #include <limits.h> | |
55 #include <netdb.h> | |
56 #include <stdio.h> | |
57 #include <stdarg.h> | |
58 #include <stdlib.h> | |
59 #include <errno.h> | |
60 #include <fcntl.h> | |
61 #include <unistd.h> | |
62 #include <ctype.h> | |
63 #include <time.h> | |
64 #include <utime.h> | |
65 #include <signal.h> | |
66 #include <termios.h> | |
67 #include <pwd.h> | |
68 #include <setjmp.h> | |
69 #include <dirent.h> | |
70 #include <grp.h> | |
71 #include <math.h> | |
72 | |
325 | 73 #ifdef HAVE_STDINT_H |
74 #include <stdint.h> | |
75 #endif | |
76 | |
460 | 77 #ifdef HAVE_INTTYPES_H |
78 #include <inttypes.h> | |
79 #endif | |
80 | |
1 | 81 #ifdef HAVE_STRING_H |
82 #include <string.h> | |
83 #else | |
84 #include <strings.h> | |
85 #endif | |
86 | |
168 | 87 #ifdef USE_SSL |
88 #include <openssl/bio.h> | |
89 #include <openssl/err.h> | |
90 #include <openssl/rand.h> | |
91 #include <openssl/ssl.h> | |
92 #include <openssl/x509v3.h> | |
93 #endif | |
94 | |
1 | 95 #ifdef ENABLE_NLS |
96 #include <libintl.h> | |
97 #include <locale.h> | |
98 #define _(String) gettext (String) | |
99 #else | |
100 #define _(String) String | |
101 #endif | |
102 #define N_(String) String | |
103 | |
104 #ifndef AF_LOCAL | |
105 #define AF_LOCAL AF_UNIX | |
106 #endif | |
107 | |
146 | 108 #ifdef HAVE_GETADDRINFO |
109 #define HAVE_IPV6 | |
516 | 110 #define GFTP_GET_AI_FAMILY(request) ((request) != NULL && (request)->hostp != NULL ? (request)->hostp->ai_family : -1) |
146 | 111 #else |
112 #define GFTP_GET_AI_FAMILY(request) AF_INET | |
113 #endif | |
114 | |
351 | 115 /* Solaris needs this included for major()/minor() */ |
116 #ifdef HAVE_SYS_MKDEV_H | |
117 #include <sys/mkdev.h> | |
118 #endif | |
119 | |
48 | 120 /* We need the major() and minor() macros in the user interface. If they aren't |
121 defined by the system, we'll just define them here. */ | |
122 #ifndef major | |
123 #warning major macro was not defined by the system. Defining one that is probably wrong for your system | |
124 #define major(dev) (((dev) >> 8) & 0xff) | |
125 #endif | |
126 | |
127 #ifndef minor | |
128 #warning minor macro was not defined by the system. Defining one that is probably wrong for your system | |
129 #define minor(dev) ((dev) & 0xff) | |
130 #endif | |
131 | |
201 | 132 #ifdef WITH_DMALLOC |
133 | |
134 #undef g_malloc | |
135 #define g_malloc(size) \ | |
136 _malloc_leap(__FILE__, __LINE__, size) | |
137 | |
138 #undef g_malloc0 | |
139 #define g_malloc0(size) \ | |
140 _calloc_leap(__FILE__, __LINE__, 1, size) | |
141 | |
142 #undef g_realloc | |
143 #define g_realloc(ptr, size) \ | |
144 _realloc_leap(__FILE__, __LINE__, ptr, size) | |
145 | |
146 #undef g_strdup | |
147 #define g_strdup(str) \ | |
148 _strdup_leap(__FILE__, __LINE__, str) | |
149 | |
150 #undef g_free | |
151 #define g_free(ptr) \ | |
152 _free_leap(__FILE__, __LINE__, ptr) | |
153 | |
1 | 154 #include <dmalloc.h> |
201 | 155 |
1 | 156 #endif |
157 | |
338 | 158 #ifdef __GNUC__ |
159 # define GFTP_LOG_FUNCTION_ATTRIBUTES __attribute__((format(printf, 3, 4))) | |
160 #else | |
161 # define GFTP_LOG_FUNCTION_ATTRIBUTES | |
162 #endif | |
163 | |
649 | 164 #if defined (_LARGEFILE_SOURCE) && !defined (__hppa__) && !defined (__hppa) |
532 | 165 #define GFTP_OFF_T_HEX_PRINTF_MOD "%llx" |
166 #define GFTP_OFF_T_INTL_PRINTF_MOD "%'lld" | |
167 #define GFTP_OFF_T_PRINTF_MOD "%lld" | |
168 #define GFTP_OFF_T_11PRINTF_MOD "%11lld" | |
169 #define gftp_parse_file_size(str) strtoll (str, NULL, 10) | |
516 | 170 #else |
532 | 171 #define GFTP_OFF_T_HEX_PRINTF_MOD "%lx" |
172 #define GFTP_OFF_T_INTL_PRINTF_MOD "%'ld" | |
173 #define GFTP_OFF_T_PRINTF_MOD "%ld" | |
174 #define GFTP_OFF_T_11PRINTF_MOD "%11ld" | |
175 #define gftp_parse_file_size(str) strtol (str, NULL, 10) | |
516 | 176 #endif |
177 | |
91 | 178 /* Server types (used by FTP protocol from SYST command) */ |
122 | 179 #define GFTP_DIRTYPE_UNIX 1 |
180 #define GFTP_DIRTYPE_EPLF 2 | |
181 #define GFTP_DIRTYPE_CRAY 3 | |
182 #define GFTP_DIRTYPE_NOVELL 4 | |
183 #define GFTP_DIRTYPE_DOS 5 | |
184 #define GFTP_DIRTYPE_VMS 6 | |
185 #define GFTP_DIRTYPE_OTHER 7 | |
358 | 186 #define GFTP_DIRTYPE_MVS 8 |
91 | 187 |
84 | 188 /* Error types */ |
341 | 189 #define GFTP_ERETRYABLE -1 /* Temporary failure. The GUI |
190 should wait briefly */ | |
191 #define GFTP_EFATAL -2 /* Fatal error */ | |
192 #define GFTP_ERETRYABLE_NO_WAIT -3 /* Temporary failure. The GUI | |
193 should not wait and should | |
194 reconnect */ | |
426 | 195 #define GFTP_ENOTRANS -4 /* Custom error. This is |
196 returned when a FXP transfer | |
197 is requested */ | |
442 | 198 #define GFTP_ETIMEDOUT -5 /* Connected timed out */ |
84 | 199 |
1 | 200 /* Some general settings */ |
201 #define BASE_CONF_DIR "~/.gftp" | |
202 #define CONFIG_FILE BASE_CONF_DIR "/gftprc" | |
203 #define BOOKMARKS_FILE BASE_CONF_DIR "/bookmarks" | |
204 #define LOG_FILE BASE_CONF_DIR "/gftp.log" | |
205 #define MAX_HIST_LEN 10 | |
356 | 206 #define GFTP_URL_USAGE "[[protocol://][user[:pass]@]site[:port][/directory]]" |
1 | 207 |
208 typedef enum gftp_logging_level_tag | |
209 { | |
210 gftp_logging_send, | |
211 gftp_logging_recv, | |
212 gftp_logging_error, | |
354 | 213 gftp_logging_misc, |
214 gftp_logging_misc_nolog /* Log to the screen, but don't log to disk */ | |
1 | 215 } gftp_logging_level; |
216 | |
217 typedef struct gftp_file_tag gftp_file; | |
218 | |
219 #define GFTP_TRANS_ACTION_OVERWRITE 1 | |
220 #define GFTP_TRANS_ACTION_RESUME 2 | |
221 #define GFTP_TRANS_ACTION_SKIP 3 | |
222 | |
16 | 223 #define GFTP_SORT_COL_FILE 1 |
224 #define GFTP_SORT_COL_SIZE 2 | |
225 #define GFTP_SORT_COL_USER 3 | |
226 #define GFTP_SORT_COL_GROUP 4 | |
227 #define GFTP_SORT_COL_DATETIME 5 | |
228 #define GFTP_SORT_COL_ATTRIBS 6 | |
229 | |
499 | 230 #define GFTP_IS_SPECIAL_DEVICE(mode) (S_ISBLK (mode) || S_ISCHR (mode)) |
231 | |
1 | 232 struct gftp_file_tag |
233 { | |
765 | 234 /*@null@*/ char *file, /* Our filename */ |
235 *user, /* User that owns it */ | |
236 *group, /* Group that owns it */ | |
237 *destfile; /* Full pathname to the destination for the | |
1 | 238 file transfer */ |
122 | 239 |
240 int fd; /* Already open fd for this file */ | |
241 /* FIXME - add fd_open function */ | |
242 | |
1 | 243 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
|
244 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
|
245 startsize; /* Size to start the transfer at */ |
499 | 246 mode_t st_mode; /* File attributes */ |
852 | 247 |
248 dev_t st_dev; /* The device and associated inode. These */ | |
249 ino_t st_ino; /* two fields are used for detecting loops */ | |
250 /* with symbolic links. */ | |
251 | |
499 | 252 unsigned int selected : 1, /* Is this file selected? */ |
1 | 253 was_sel : 1, /* Was this file selected before */ |
254 shown : 1, /* Is this file shown? */ | |
255 done_view : 1, /* View the file when done transfering? */ | |
256 done_edit : 1, /* Edit the file when done transfering? */ | |
257 done_rm : 1, /* Remove the file when done */ | |
258 transfer_done : 1, /* Is current file transfer done? */ | |
862 | 259 retry_transfer : 1, /* Is current file transfer done? */ |
787 | 260 is_fd : 1, /* Is this a file descriptor? */ |
261 exists_other_side; /* The file exists on the other side during | |
262 the file transfer */ | |
1 | 263 char transfer_action; /* See the GFTP_TRANS_ACTION_* vars above */ |
765 | 264 /*@null@*/ void *user_data; |
1 | 265 }; |
266 | |
267 | |
268 typedef struct gftp_proxy_hosts_tag | |
269 { | |
303 | 270 /* FIXME - add IPV6 stuff here */ |
122 | 271 |
272 gint32 ipv4_network_address, | |
1 | 273 ipv4_netmask; |
274 char *domain; | |
275 } gftp_proxy_hosts; | |
276 | |
136 | 277 |
278 /* Note, these numbers must match up to the index number in config_file.c | |
279 in the declaration of gftp_option_types */ | |
280 typedef enum | |
281 { | |
282 gftp_option_type_text = 0, | |
283 gftp_option_type_textcombo = 1, | |
284 gftp_option_type_textcomboedt = 2, | |
285 gftp_option_type_hidetext = 3, | |
286 gftp_option_type_int = 4, | |
287 gftp_option_type_checkbox = 5, | |
288 gftp_option_type_intcombo = 6, | |
289 gftp_option_type_float = 7, | |
290 gftp_option_type_color = 8, | |
291 gftp_option_type_notebook = 9 | |
292 } gftp_option_type_enum; | |
293 | |
294 | |
295 #define GFTP_PORT_GTK (1 << 1) | |
296 #define GFTP_PORT_TEXT (1 << 2) | |
297 #define GFTP_PORT_ALL (GFTP_PORT_GTK | GFTP_PORT_TEXT) | |
298 | |
299 | |
300 typedef struct gftp_config_list_vars_tag | |
301 { | |
302 char *key; | |
303 void * (*read_func) (char *buf, int line); | |
304 void (*write_func) (FILE *fd, void *data); | |
305 GList * list; | |
306 unsigned int num_items; | |
307 char *header; | |
308 } gftp_config_list_vars; | |
309 | |
310 | |
201 | 311 #define GFTP_CVARS_FLAGS_DYNMEM (1 << 1) |
312 #define GFTP_CVARS_FLAGS_DYNLISTMEM (1 << 2) | |
227 | 313 #define GFTP_CVARS_FLAGS_SHOW_BOOKMARK (1 << 3) |
136 | 314 |
315 typedef struct gftp_config_vars_tag | |
316 { | |
765 | 317 /*@null@*/ char *key, /* variable name */ |
318 *description; /* How this field will show up in the dialog */ | |
136 | 319 int otype; /* Type of option this is */ |
765 | 320 /*@null@*/ void *value; |
321 /*@null@*/ void *listdata; /* For options that have several different | |
136 | 322 options, this is a list of all the options. |
323 Each option_type that uses this will use this | |
324 field differently */ | |
325 int flags; /* See GFTP_CVARS_FLAGS_* above */ | |
765 | 326 /*@null@*/ char *comment; /* Comment to write out to the config file */ |
136 | 327 int ports_shown; /* What ports of gFTP is this option shown in */ |
765 | 328 /*@null@*/ void *user_data; /* Data that the GUI can store here (Widget in gtk+) */ |
136 | 329 } gftp_config_vars; |
330 | |
331 | |
332 typedef struct gftp_option_type_tag | |
333 { | |
334 int (*read_function) (char *str, gftp_config_vars * cv, int line); | |
765 | 335 int (*write_function) (gftp_config_vars * cv, /*@out@*/ char *buf, |
336 size_t buflen, int to_config_file); | |
207 | 337 void (*copy_function) (gftp_config_vars * cv, gftp_config_vars * dest_cv); |
227 | 338 int (*compare_function) (gftp_config_vars * cv1, gftp_config_vars * cv2); |
229 | 339 void *(*ui_print_function) (gftp_config_vars * cv, void *user_data, void *value); |
136 | 340 void (*ui_save_function) (gftp_config_vars * cv, void *user_data); |
139 | 341 void (*ui_cancel_function) (gftp_config_vars * cv, void *user_data); |
136 | 342 void *user_data; |
343 } gftp_option_type_var; | |
344 | |
345 | |
346 #define GFTP_TEXTCOMBOEDT_EDITABLE (1 << 0) | |
347 | |
348 typedef struct gftp_textcomboedt_data_tag | |
349 { | |
765 | 350 /*@null@*/ char *description, |
351 *text; | |
136 | 352 int flags; |
353 } gftp_textcomboedt_data; | |
354 | |
355 | |
1 | 356 typedef struct gftp_request_tag gftp_request; |
357 | |
186 | 358 typedef void (*gftp_logging_func) ( gftp_logging_level level, |
765 | 359 /*@null@*/ gftp_request * request, |
186 | 360 const char *string, ... ); |
361 | |
570 | 362 #define GFTP_ANONYMOUS_USER "anonymous" |
555 | 363 #define gftp_need_username(request) ((request)->need_username && ((request)->username == NULL || *(request)->username == '\0')) |
570 | 364 #define gftp_need_password(request) ((request)->need_password && (request)->username != NULL && *(request)->username != '\0' && strcasecmp ((request)->username, GFTP_ANONYMOUS_USER) != 0 && ((request)->password == NULL || *(request)->password == '\0')) |
553 | 365 |
1 | 366 struct gftp_request_tag |
367 { | |
368 int protonum; /* Current number of the protocol this is | |
369 set to */ | |
370 char *hostname, /* Hostname we will connect to */ | |
371 *username, /* Username for host*/ | |
372 *password, /* Password for host */ | |
373 *account, /* Account for host (FTP only) */ | |
374 *directory, /* Current working directory */ | |
375 *url_prefix, /* URL Prefix (ex: ftp) */ | |
376 *last_ftp_response, /* Last response from server */ | |
377 *last_dir_entry; /* Last dir entry from server */ | |
378 size_t last_dir_entry_len; /* Length of last_dir_entry */ | |
379 | |
122 | 380 unsigned int port; /* Port of remote site */ |
1 | 381 |
169 | 382 int datafd, /* Data connection */ |
58 | 383 cachefd; /* For the directory cache */ |
1 | 384 int wakeup_main_thread[2]; /* FD that gets written to by the threads |
385 to wakeup the parent */ | |
122 | 386 |
387 /* One of these are used to lookup the IP address of the host we are | |
388 connecting to */ | |
1 | 389 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) |
572 | 390 struct addrinfo *hostp, |
391 *current_hostp; | |
1 | 392 #else |
122 | 393 struct hostent host, *hostp; |
641 | 394 int curhost; |
1 | 395 #endif |
396 | |
547 | 397 int ai_family; |
122 | 398 int server_type; /* The type of server we are connected to. |
399 See GFTP_DIRTYPE_* above */ | |
151 | 400 unsigned int free_hostp : 1, /* Should we free the hostp structure |
401 in gftp_destroy_request() */ | |
402 use_proxy : 1, | |
1 | 403 always_connected : 1, |
404 need_hostport : 1, | |
553 | 405 need_username : 1, |
406 need_password : 1, | |
1 | 407 use_cache : 1, /* Enable or disable the cache */ |
408 cached : 1, /* Is this directory listing cached? */ | |
41 | 409 cancel : 1, /* If a signal is received, should |
410 we cancel this operation */ | |
832 | 411 stopable : 1, |
879 | 412 refreshing : 1, |
832 | 413 use_local_encoding : 1; |
1 | 414 |
415 off_t gotbytes; | |
416 | |
417 void *protocol_data; | |
418 | |
419 gftp_logging_func logging_function; | |
420 void *user_data; | |
421 | |
173 | 422 int (*init) ( gftp_request * request ); |
309 | 423 void (*copy_param_options) ( gftp_request * dest_request, |
424 gftp_request * src_request ); | |
168 | 425 ssize_t (*read_function) ( gftp_request * request, |
426 void *ptr, | |
427 size_t size, | |
428 int fd ); | |
429 ssize_t (*write_function) ( gftp_request * request, | |
430 const char *ptr, | |
431 size_t size, | |
432 int fd ); | |
1 | 433 void (*destroy) ( gftp_request * request ); |
434 int (*connect) ( gftp_request * request ); | |
168 | 435 int (*post_connect) ( gftp_request * request ); |
1 | 436 void (*disconnect) ( gftp_request * request ); |
58 | 437 off_t (*get_file) ( gftp_request * request, |
1 | 438 const char *filename, |
58 | 439 int fd, |
1 | 440 off_t startsize ); |
441 int (*put_file) ( gftp_request * request, | |
442 const char *filename, | |
58 | 443 int fd, |
1 | 444 off_t startsize, |
445 off_t totalsize ); | |
765 | 446 off_t (*transfer_file) ( gftp_request * fromreq, |
1 | 447 const char *fromfile, |
448 off_t fromsize, | |
449 gftp_request * toreq, | |
450 const char *tofile, | |
451 off_t tosize ); | |
58 | 452 ssize_t (*get_next_file_chunk) ( gftp_request * request, |
1 | 453 char *buf, |
454 size_t size ); | |
58 | 455 ssize_t (*put_next_file_chunk) ( gftp_request * request, |
1 | 456 char *buf, |
457 size_t size ); | |
458 int (*end_transfer) ( gftp_request * request ); | |
40 | 459 int (*abort_transfer) ( gftp_request * request ); |
520 | 460 int (*stat_filename) ( gftp_request * request, |
461 const char *filename, | |
787 | 462 mode_t * mode, |
463 off_t * filesize ); | |
1 | 464 int (*list_files) ( gftp_request * request ); |
465 int (*get_next_file) ( gftp_request * request, | |
466 gftp_file *fle, | |
58 | 467 int fd ); |
485 | 468 ssize_t (*get_next_dirlist_line) ( gftp_request * request, |
469 int fd, | |
470 char *buf, | |
471 size_t buflen ); | |
1 | 472 off_t (*get_file_size) ( gftp_request * request, |
473 const char *filename ); | |
474 int (*chdir) ( gftp_request * request, | |
475 const char *directory ); | |
476 int (*rmdir) ( gftp_request * request, | |
477 const char *directory ); | |
478 int (*rmfile) ( gftp_request * request, | |
479 const char *filename ); | |
480 int (*mkdir) ( gftp_request * request, | |
481 const char *directory ); | |
482 int (*rename) ( gftp_request * request, | |
483 const char *oldname, | |
484 const char *newname ); | |
485 int (*chmod) ( gftp_request * request, | |
486 const char *filename, | |
499 | 487 mode_t mode ); |
1 | 488 int (*set_file_time) ( gftp_request * request, |
489 const char *filename, | |
490 time_t datettime ); | |
491 int (*site) ( gftp_request * request, | |
478 | 492 int specify_site, |
1 | 493 const char *filename ); |
494 int (*parse_url) ( gftp_request * request, | |
495 const char *url ); | |
177 | 496 int (*set_config_options) ( gftp_request * request ); |
63 | 497 void (*swap_socks) ( gftp_request * dest, |
498 gftp_request * source ); | |
1 | 499 |
136 | 500 gftp_config_vars * local_options_vars; |
501 int num_local_options_vars; | |
502 GHashTable * local_options_hash; | |
168 | 503 #ifdef USE_SSL |
504 SSL * ssl; | |
505 #endif | |
184 | 506 |
507 #if GLIB_MAJOR_VERSION > 1 | |
508 GIConv iconv; | |
509 unsigned int iconv_initialized : 1; | |
842 | 510 char *iconv_charset; |
184 | 511 #endif |
1 | 512 }; |
513 | |
514 | |
136 | 515 typedef struct gftp_transfer_tag |
1 | 516 { |
517 gftp_request * fromreq, | |
518 * toreq; | |
519 | |
305 | 520 unsigned int cancel : 1, |
1 | 521 ready : 1, |
522 started : 1, | |
523 done : 1, | |
524 show : 1, | |
525 stalled : 1, | |
303 | 526 conn_error_no_timeout : 1, |
1 | 527 next_file : 1, |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
528 skip_file : 1; |
1 | 529 |
530 struct timeval starttime, | |
531 lasttime; | |
532 | |
533 double kbs; | |
534 | |
535 GList * files, | |
536 * curfle, | |
537 * updfle; | |
538 | |
19 | 539 long numfiles, |
540 numdirs, | |
541 current_file_number, | |
542 current_file_retries; | |
1 | 543 |
544 off_t curtrans, /* Current transfered bytes for this file */ | |
377 | 545 tot_file_trans, /* Total number of bytes in the file being |
546 transferred */ | |
1 | 547 curresumed, /* Resumed bytes for this file */ |
548 trans_bytes, /* Amount of data transfered for entire | |
549 transfer */ | |
550 total_bytes, /* Grand total bytes for whole transfer */ | |
551 resumed_bytes; /* Grand total of resumed bytes for whole | |
552 transfer */ | |
553 | |
554 void * fromwdata, | |
555 * towdata; | |
556 | |
122 | 557 GStaticMutex statmutex, |
558 structmutex; | |
559 | |
125 | 560 void *user_data; |
876 | 561 void *thread_id; |
1 | 562 void *clist; |
136 | 563 } gftp_transfer; |
1 | 564 |
565 | |
566 typedef struct gftp_log_tag | |
567 { | |
568 char *msg; | |
569 gftp_logging_level type; | |
570 } gftp_log; | |
571 | |
572 | |
573 typedef struct supported_gftp_protocols_tag | |
574 { | |
765 | 575 /*@null@*/ char *name; /* Description of protocol */ |
576 /*@null@*/ int (*init) (gftp_request * request); /* Init function */ | |
577 /*@null@*/ void (*register_options) (void); /* Protocol options */ | |
578 /*@null@*/ char *url_prefix; /* URL Prefix */ | |
542 | 579 unsigned int default_port; /* Default port */ |
341 | 580 unsigned int shown : 1, /* Whether this protocol is |
122 | 581 shown or not to the user in |
582 the protocol dropdown box */ | |
341 | 583 use_threads : 1; /* Whether or not operations in |
584 this protocol should use | |
585 threads */ | |
1 | 586 } supported_gftp_protocols; |
587 | |
588 | |
122 | 589 typedef struct gftp_bookmarks_tag gftp_bookmarks_var; |
1 | 590 |
591 struct gftp_bookmarks_tag | |
592 { | |
609 | 593 char *path, /* Path */ |
594 *oldpath, /* Old path name */ | |
595 *hostname, /* Our actual internet hostname */ | |
1 | 596 *protocol, /* Protocol we will connect through */ |
597 *remote_dir, /* Initial directory */ | |
598 *local_dir, /* Init local directory */ | |
599 *user, /* Username to log in as */ | |
600 *pass, /* Our password */ | |
601 *acct; /* Account */ | |
602 | |
603 unsigned int port, /* The port we will connect to */ | |
604 isfolder : 1, /* If this is set, then the children field can | |
605 be non-NULL */ | |
606 save_password : 1; /* Save this password */ | |
122 | 607 gftp_bookmarks_var *children, /* The children of this node. */ |
608 *prev, /* The parent of this node */ | |
609 *next; /* The next sibling of this node */ | |
1 | 610 gpointer cnode; |
611 | |
199 | 612 gftp_config_vars * local_options_vars; |
613 int num_local_options_vars; | |
614 GHashTable * local_options_hash; | |
1 | 615 }; |
616 | |
617 | |
618 typedef struct gftp_file_extensions_tag | |
619 { | |
620 char *ext, /* The file extension to register */ | |
621 *filename, /* The xpm file to display */ | |
622 *view_program, /* The program used to view this file */ | |
623 *ascii_binary; /* Is this a ASCII transfer or a BINARY transfer */ | |
516 | 624 unsigned int stlen; /* How long is the file extension. */ |
1 | 625 } gftp_file_extensions; |
626 | |
627 | |
628 typedef struct gftp_color_tag | |
629 { | |
630 gushort red, | |
631 green, | |
632 blue; | |
633 } gftp_color; | |
634 | |
635 | |
58 | 636 typedef struct gftp_getline_buffer_tag |
637 { | |
638 char *buffer, | |
639 *curpos; | |
640 size_t max_bufsize, | |
641 cur_bufsize; | |
179 | 642 unsigned int eof : 1; |
58 | 643 } gftp_getline_buffer; |
644 | |
126 | 645 |
122 | 646 /* Global config options. These are defined in options.h */ |
765 | 647 /*@null@*/ extern GList * gftp_file_transfers, * gftp_file_transfer_logs, |
648 * gftp_options_list; | |
649 /*@null@*/ extern GHashTable * gftp_global_options_htable, * gftp_bookmarks_htable, | |
650 * gftp_config_list_htable; | |
651 /*@null@*/ extern gftp_bookmarks_var * gftp_bookmarks; | |
652 /*@null@*/ extern FILE * gftp_logfd; | |
122 | 653 extern gftp_config_vars gftp_global_config_vars[]; |
1 | 654 extern supported_gftp_protocols gftp_protocols[]; |
122 | 655 extern char gftp_version[]; |
201 | 656 extern int gftp_configuration_changed; |
122 | 657 |
658 /* This is defined in config_file.c */ | |
659 | |
660 extern gftp_option_type_var gftp_option_types[]; | |
1 | 661 |
662 /* cache.c */ | |
182 | 663 void gftp_generate_cache_description ( gftp_request * request, |
765 | 664 /*@out@*/ char *description, |
182 | 665 size_t len, |
666 int ignore_directory ); | |
667 | |
58 | 668 int gftp_new_cache_entry ( gftp_request * request ); |
1 | 669 |
58 | 670 int gftp_find_cache_entry ( gftp_request * request ); |
1 | 671 |
672 void gftp_clear_cache_files ( void ); | |
673 | |
47 | 674 void gftp_delete_cache_entry ( gftp_request * request, |
182 | 675 char *descr, |
47 | 676 int ignore_directory ); |
1 | 677 |
678 /* config_file.c */ | |
198 | 679 int gftp_config_parse_args ( char *str, |
680 int numargs, | |
681 int lineno, | |
765 | 682 /*@out@*/ char **first, |
198 | 683 ... ); |
684 | |
122 | 685 void gftp_add_bookmark ( gftp_bookmarks_var * newentry ); |
686 | |
124 | 687 void gftp_read_config_file ( char *global_data_path ); |
1 | 688 |
122 | 689 void gftp_write_bookmarks_file ( void ); |
1 | 690 |
691 void gftp_write_config_file ( void ); | |
692 | |
122 | 693 GHashTable * build_bookmarks_hash_table ( gftp_bookmarks_var * entry ); |
694 | |
695 void print_bookmarks ( gftp_bookmarks_var * bookmarks ); | |
696 | |
374 | 697 void gftp_lookup_global_option ( const char * key, |
765 | 698 /*@out@*/ void *value ); |
26 | 699 |
122 | 700 void gftp_lookup_request_option ( gftp_request * request, |
374 | 701 const char * key, |
765 | 702 /*@out@*/ void *value ); |
703 | |
1 | 704 |
229 | 705 void gftp_lookup_bookmark_option ( gftp_bookmarks_var * bm, |
374 | 706 const char * key, |
229 | 707 void *value ); |
708 | |
374 | 709 void gftp_set_global_option ( const char * key, |
227 | 710 const void *value ); |
122 | 711 |
712 void gftp_set_request_option ( gftp_request * request, | |
374 | 713 const char * key, |
229 | 714 const void *value ); |
715 | |
716 void gftp_set_bookmark_option ( gftp_bookmarks_var * bm, | |
374 | 717 const char * key, |
229 | 718 const void *value ); |
122 | 719 |
720 void gftp_register_config_vars ( gftp_config_vars *config_vars ); | |
1 | 721 |
201 | 722 void gftp_copy_local_options ( gftp_config_vars ** new_options_vars, |
723 GHashTable ** new_options_hash, | |
429 | 724 int *new_num_local_options_vars, |
201 | 725 gftp_config_vars * orig_options, |
726 int num_local_options_vars ); | |
727 | |
728 void gftp_config_free_options ( gftp_config_vars * options_vars, | |
729 GHashTable * options_hash, | |
730 int num_options_vars ); | |
731 | |
732 void gftp_bookmarks_destroy ( gftp_bookmarks_var * bookmarks ); | |
733 | |
218 | 734 void gftp_free_proxy_hosts ( GList * proxy_hosts ); |
735 | |
736 GList * gftp_copy_proxy_hosts ( GList * proxy_hosts ); | |
737 | |
1 | 738 /* misc.c */ |
765 | 739 /*@null@*/ char *insert_commas ( off_t number, |
1 | 740 char *dest_str, |
741 size_t dest_len ); | |
742 | |
743 char *alltrim ( char *str ); | |
744 | |
555 | 745 char *gftp_expand_path ( gftp_request * request, |
746 const char *src ); | |
1 | 747 |
748 void make_nonnull ( char **str ); | |
749 | |
821 | 750 int gftp_match_filespec ( gftp_request * request, |
751 const char *filename, | |
374 | 752 const char *filespec ); |
1 | 753 |
754 int gftp_parse_command_line ( int *argc, | |
755 char ***argv ); | |
756 | |
757 void gftp_usage ( void ); | |
758 | |
759 gint string_hash_compare ( gconstpointer path1, | |
760 gconstpointer path2 ); | |
761 | |
762 guint string_hash_function ( gconstpointer key ); | |
763 | |
852 | 764 gint uint_hash_compare ( gconstpointer path1, |
765 gconstpointer path2 ); | |
766 | |
767 guint uint_hash_function ( gconstpointer key ); | |
768 | |
1 | 769 void free_file_list ( GList * filelist ); |
770 | |
771 gftp_file * copy_fdata ( gftp_file * fle ); | |
772 | |
773 int compare_request ( gftp_request * request1, | |
774 gftp_request * request2, | |
775 int compare_dirs ); | |
776 | |
129 | 777 gftp_transfer * gftp_tdata_new ( void ); |
778 | |
1 | 779 void free_tdata ( gftp_transfer * tdata ); |
780 | |
368 | 781 gftp_request * gftp_copy_request ( gftp_request * req ); |
1 | 782 |
16 | 783 GList * gftp_sort_filelist ( GList * filelist, |
784 int column, | |
785 int asds ); | |
786 | |
830 | 787 char * gftp_gen_ls_string ( gftp_request * request, |
788 gftp_file * fle, | |
131 | 789 char *file_prefixstr, |
790 char *file_suffixstr ); | |
791 | |
168 | 792 char * base64_encode ( char *str ); |
793 | |
609 | 794 void gftp_free_bookmark ( gftp_bookmarks_var * entry, |
795 int free_node ); | |
199 | 796 |
201 | 797 void gftp_shutdown ( void ); |
199 | 798 |
207 | 799 GList * get_next_selection ( GList * selection, |
800 GList ** list, | |
801 int *curnum ); | |
802 | |
555 | 803 char * gftp_build_path ( gftp_request * request, |
804 const char *first_element, | |
227 | 805 ... ); |
806 | |
290 | 807 void gftp_locale_init ( void ); |
808 | |
330 | 809 char * gftp_scramble_password ( const char *password ); |
810 | |
811 char * gftp_descramble_password ( const char *password ); | |
812 | |
378 | 813 int gftp_get_transfer_action ( gftp_request * request, |
814 gftp_file * fle ); | |
815 | |
483 | 816 char * gftp_get_share_dir ( void ); |
817 | |
402 | 818 /* mkstemps.c */ |
819 int mkstemps ( char *template, | |
820 int suffix_len ); | |
821 | |
1 | 822 /* protocols.c */ |
823 #define GFTP_FTP_NUM 0 | |
389 | 824 #define GFTP_FTPS_NUM 1 |
825 #define GFTP_HTTP_NUM 2 | |
826 #define GFTP_HTTPS_NUM 3 | |
827 #define GFTP_LOCAL_NUM 4 | |
828 #define GFTP_SSHV2_NUM 5 | |
829 #define GFTP_BOOKMARK_NUM 6 | |
661 | 830 #define GFTP_FSP_NUM 7 |
122 | 831 |
1 | 832 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \ |
169 | 833 ((request)->datafd > 0 || \ |
58 | 834 (request)->cached || \ |
835 (request)->always_connected)) | |
1 | 836 |
837 | |
173 | 838 int rfc959_init ( gftp_request * request ); |
1 | 839 |
122 | 840 void rfc959_register_module ( void ); |
841 | |
1 | 842 int rfc959_get_next_file ( gftp_request * request, |
843 gftp_file *fle, | |
58 | 844 int fd ); |
1 | 845 |
451 | 846 int rfc959_connect ( gftp_request * request ); |
847 | |
389 | 848 int ftps_init ( gftp_request * request ); |
849 | |
850 void ftps_register_module ( void ); | |
851 | |
173 | 852 int rfc2068_init ( gftp_request * request ); |
1 | 853 |
122 | 854 void rfc2068_register_module ( void ); |
855 | |
173 | 856 int https_init ( gftp_request * request ); |
168 | 857 |
858 void https_register_module ( void ); | |
859 | |
173 | 860 int local_init ( gftp_request * request ); |
1 | 861 |
122 | 862 void local_register_module ( void ); |
863 | |
173 | 864 int sshv2_init ( gftp_request * request ); |
1 | 865 |
122 | 866 void sshv2_register_module ( void ); |
867 | |
174 | 868 void ssl_register_module ( void ); |
869 | |
173 | 870 int bookmark_init ( gftp_request * request ); |
1 | 871 |
122 | 872 void bookmark_register_module ( void ); |
873 | |
661 | 874 int fsp_init ( gftp_request * request ); |
875 | |
876 void fsp_register_module ( void ); | |
877 | |
1 | 878 gftp_request *gftp_request_new ( void ); |
879 | |
67 | 880 void gftp_request_destroy ( gftp_request * request, |
881 int free_request ); | |
1 | 882 |
309 | 883 void gftp_copy_param_options ( gftp_request * dest_request, |
884 gftp_request * src_request ); | |
885 | |
598 | 886 void gftp_file_destroy ( gftp_file *file, |
887 int free_it ); | |
1 | 888 |
889 int gftp_connect ( gftp_request * request ); | |
890 | |
891 void gftp_disconnect ( gftp_request * request ); | |
892 | |
58 | 893 off_t gftp_get_file ( gftp_request * request, |
1 | 894 const char *filename, |
58 | 895 int fd, |
244 | 896 off_t startsize ); |
1 | 897 |
898 int gftp_put_file ( gftp_request * request, | |
899 const char *filename, | |
58 | 900 int fd, |
244 | 901 off_t startsize, |
902 off_t totalsize ); | |
1 | 903 |
261 | 904 off_t gftp_transfer_file ( gftp_request *fromreq, |
1 | 905 const char *fromfile, |
58 | 906 int fromfd, |
244 | 907 off_t fromsize, |
1 | 908 gftp_request *toreq, |
909 const char *tofile, | |
58 | 910 int tofd, |
244 | 911 off_t tosize ); |
1 | 912 |
58 | 913 ssize_t gftp_get_next_file_chunk ( gftp_request * request, |
1 | 914 char *buf, |
915 size_t size ); | |
916 | |
58 | 917 ssize_t gftp_put_next_file_chunk ( gftp_request * request, |
1 | 918 char *buf, |
919 size_t size ); | |
920 | |
921 int gftp_list_files ( gftp_request * request ); | |
922 | |
765 | 923 /*@null@*/ char * gftp_string_to_utf8 ( gftp_request * request, |
838 | 924 const char *str, |
925 size_t *dest_len ); | |
291 | 926 |
765 | 927 /*@null@*/ char * gftp_string_from_utf8 ( gftp_request * request, |
845 | 928 int force_local, |
929 const char *str, | |
930 size_t *dest_len ); | |
931 | |
932 /*@null@*/ char * gftp_filename_to_utf8 ( gftp_request * request, | |
933 const char *str, | |
934 size_t *dest_len ); | |
935 | |
936 /*@null@*/ char * gftp_filename_from_utf8 ( gftp_request * request, | |
838 | 937 const char *str, |
938 size_t *dest_len ); | |
186 | 939 |
87 | 940 int gftp_parse_bookmark ( gftp_request * request, |
243 | 941 gftp_request * local_request, |
275 | 942 const char * bookmark, |
943 int *refresh_local ); | |
87 | 944 |
1 | 945 int gftp_parse_url ( gftp_request * request, |
946 const char *url ); | |
947 | |
948 int gftp_get_next_file ( gftp_request * request, | |
377 | 949 const char *filespec, |
1 | 950 gftp_file *fle ); |
951 | |
952 int gftp_end_transfer ( gftp_request * request ); | |
953 | |
40 | 954 int gftp_abort_transfer ( gftp_request * request ); |
955 | |
520 | 956 int gftp_stat_filename ( gftp_request * request, |
957 const char *filename, | |
787 | 958 mode_t * mode, |
959 off_t * filesize ); | |
500 | 960 |
1 | 961 void gftp_set_hostname ( gftp_request * request, |
962 const char *hostname ); | |
963 | |
964 void gftp_set_username ( gftp_request * request, | |
965 const char *username ); | |
966 | |
967 void gftp_set_password ( gftp_request * request, | |
968 const char *password ); | |
969 | |
970 void gftp_set_account ( gftp_request * request, | |
971 const char *account ); | |
972 | |
973 int gftp_set_directory ( gftp_request * request, | |
974 const char *directory ); | |
975 | |
976 void gftp_set_port ( gftp_request * request, | |
977 unsigned int port ); | |
978 | |
979 int gftp_remove_directory ( gftp_request * request, | |
980 const char *directory ); | |
981 | |
982 int gftp_remove_file ( gftp_request * request, | |
983 const char *file ); | |
984 | |
985 int gftp_make_directory ( gftp_request * request, | |
986 const char *directory ); | |
987 | |
988 int gftp_rename_file ( gftp_request * request, | |
989 const char *oldname, | |
990 const char *newname ); | |
991 | |
992 int gftp_chmod ( gftp_request * request, | |
993 const char *file, | |
499 | 994 mode_t mode ); |
1 | 995 |
996 int gftp_set_file_time ( gftp_request * request, | |
997 const char *file, | |
998 time_t datetime ); | |
999 | |
765 | 1000 int gftp_site_cmd ( gftp_request * request, |
478 | 1001 int specify_site, |
1 | 1002 const char *command ); |
1003 | |
58 | 1004 off_t gftp_get_file_size ( gftp_request * request, |
1 | 1005 const char *filename ); |
1006 | |
1007 void gftp_calc_kbs ( gftp_transfer * tdata, | |
1008 ssize_t num_read ); | |
1009 | |
102 | 1010 time_t parse_time ( char *str, |
1011 char **endpos ); | |
1012 | |
91 | 1013 int gftp_parse_ls ( gftp_request * request, |
1014 const char *lsoutput, | |
485 | 1015 gftp_file *fle, |
1016 int fd ); | |
1 | 1017 |
1018 int gftp_get_all_subdirs ( gftp_transfer * transfer, | |
1019 void (*update_func) | |
1020 ( gftp_transfer * transfer )); | |
1021 | |
1022 int gftp_connect_server ( gftp_request * request, | |
122 | 1023 char *service, |
1024 char *proxy_hostname, | |
516 | 1025 unsigned int proxy_port ); |
1 | 1026 |
122 | 1027 #if !defined (HAVE_GETADDRINFO) || !defined (HAVE_GAI_STRERROR) |
1 | 1028 |
1029 struct hostent *r_gethostbyname ( const char *name, | |
1030 struct hostent *result_buf, | |
1031 int *h_errnop ); | |
1032 | |
56 | 1033 #endif |
1034 | |
1 | 1035 struct servent *r_getservbyname ( const char *name, |
1036 const char *proto, | |
765 | 1037 /*@out@*/ struct servent *result_buf, |
1 | 1038 int *h_errnop ); |
122 | 1039 |
177 | 1040 int gftp_set_config_options ( gftp_request * request ); |
1 | 1041 |
1042 void print_file_list ( GList * list ); | |
1043 | |
201 | 1044 void gftp_free_getline_buffer ( gftp_getline_buffer ** rbuf ); |
168 | 1045 |
58 | 1046 ssize_t gftp_get_line ( gftp_request * request, |
765 | 1047 /*@out@*/ gftp_getline_buffer ** rbuf, |
1048 /*@out@*/ char * str, | |
41 | 1049 size_t len, |
58 | 1050 int fd ); |
1051 | |
168 | 1052 ssize_t gftp_fd_read ( gftp_request * request, |
58 | 1053 void *ptr, |
1054 size_t size, | |
1055 int fd ); | |
41 | 1056 |
168 | 1057 ssize_t gftp_fd_write ( gftp_request * request, |
58 | 1058 const char *ptr, |
41 | 1059 size_t size, |
58 | 1060 int fd ); |
1061 | |
1062 ssize_t gftp_writefmt ( gftp_request * request, | |
1063 int fd, | |
1064 const char *fmt, | |
1065 ... ); | |
1066 | |
168 | 1067 int gftp_fd_set_sockblocking ( gftp_request * request, |
58 | 1068 int fd, |
1069 int non_blocking ); | |
41 | 1070 |
63 | 1071 void gftp_swap_socks ( gftp_request * dest, |
1072 gftp_request * source ); | |
1073 | |
122 | 1074 void gftp_calc_kbs ( gftp_transfer * tdata, |
1075 ssize_t num_read ); | |
1076 | |
125 | 1077 int gftp_get_transfer_status ( gftp_transfer * tdata, |
1078 ssize_t num_read ); | |
1079 | |
182 | 1080 int gftp_fd_open ( gftp_request * request, |
1081 const char *pathname, | |
1082 int flags, | |
1083 mode_t perms ); | |
1084 | |
792 | 1085 void gftp_setup_startup_directory ( gftp_request * request, |
1086 const char *option_name ); | |
422 | 1087 |
542 | 1088 unsigned int gftp_protocol_default_port ( gftp_request * request ); |
1089 | |
146 | 1090 /* pty.c */ |
210 | 1091 char * gftp_get_pty_impl ( void ); |
179 | 1092 |
458 | 1093 pid_t gftp_exec ( gftp_request * request, |
1094 int *fdm, | |
1095 int *ptymfd, | |
210 | 1096 char **args ); |
146 | 1097 |
499 | 1098 char *gftp_convert_attributes_from_mode_t ( mode_t mode ); |
1099 | |
1100 mode_t gftp_convert_attributes_to_mode_t ( char *attribs ); | |
1101 | |
1102 | |
168 | 1103 #ifdef USE_SSL |
1104 /* sslcommon.c */ | |
1105 int gftp_ssl_startup ( gftp_request * request ); | |
1106 | |
1107 int gftp_ssl_session_setup ( gftp_request * request ); | |
1108 | |
1109 void gftp_ssl_free ( gftp_request * request ); | |
1110 | |
1111 ssize_t gftp_ssl_read ( gftp_request * request, | |
1112 void *ptr, | |
1113 size_t size, | |
1114 int fd ); | |
1115 | |
1116 ssize_t gftp_ssl_write ( gftp_request * request, | |
1117 const char *ptr, | |
1118 size_t size, | |
1119 int fd ); | |
1120 #endif /* USE_SSL */ | |
1121 | |
460 | 1122 /* UI dependent functions that must be implemented */ |
1123 int gftpui_protocol_ask_yes_no ( gftp_request * request, | |
1124 char *title, | |
1125 char *question ); | |
1126 | |
484 | 1127 char *gftpui_protocol_ask_user_input ( gftp_request * request, |
1128 char *title, | |
1129 char *question, | |
1130 int shown ); | |
1131 | |
469 | 1132 void gftpui_protocol_update_timeout ( gftp_request * request ); |
1133 | |
1 | 1134 #endif |
1135 |