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