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