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