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