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