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