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