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