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