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