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