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