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