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