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