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