Mercurial > gftp.yaz
annotate lib/gftp.h @ 210:82ebd1b05345
2003-7-6 Brian Masney <masneyb@gftp.org>
* lib/pty.c lib/gftp.h - added gftp_exec_with_new_pty() and
gftp_exec_without_new_pty()
* lib/sshv2.c - use the 2 new functions above
* lib/pty.c lib/gftp.h - split open_ptys() to _gftp_ptym_open()
and _gftp_ptys_open()
* lib/sslcommon.c - don't do thread setup if we are compiling against
glib 1.2. I do not want to link against the pthread library because
that would make the text port dependant on pthreads being installed on
the box
author | masneyb |
---|---|
date | Sun, 06 Jul 2003 13:52:43 +0000 |
parents | cf4098008615 |
children | de6a2e8e51cb |
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) | |
136 | 277 |
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); |
136 | 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 |
207 | 720 GList * get_next_selection ( GList * selection, |
721 GList ** list, | |
722 int *curnum ); | |
723 | |
1 | 724 /* protocols.c */ |
725 #define GFTP_FTP_NUM 0 | |
726 #define GFTP_HTTP_NUM 1 | |
168 | 727 #define GFTP_HTTPS_NUM 2 |
728 #define GFTP_LOCAL_NUM 3 | |
729 #define GFTP_SSHV2_NUM 4 | |
730 #define GFTP_BOOKMARK_NUM 5 | |
122 | 731 |
1 | 732 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \ |
169 | 733 ((request)->datafd > 0 || \ |
58 | 734 (request)->cached || \ |
735 (request)->always_connected)) | |
1 | 736 |
737 | |
173 | 738 int rfc959_init ( gftp_request * request ); |
1 | 739 |
122 | 740 void rfc959_register_module ( void ); |
741 | |
1 | 742 int rfc959_get_next_file ( gftp_request * request, |
743 gftp_file *fle, | |
58 | 744 int fd ); |
1 | 745 |
173 | 746 int rfc2068_init ( gftp_request * request ); |
1 | 747 |
122 | 748 void rfc2068_register_module ( void ); |
749 | |
173 | 750 int https_init ( gftp_request * request ); |
168 | 751 |
752 void https_register_module ( void ); | |
753 | |
173 | 754 int local_init ( gftp_request * request ); |
1 | 755 |
122 | 756 void local_register_module ( void ); |
757 | |
173 | 758 int sshv2_init ( gftp_request * request ); |
1 | 759 |
122 | 760 void sshv2_register_module ( void ); |
761 | |
174 | 762 void ssl_register_module ( void ); |
763 | |
173 | 764 int bookmark_init ( gftp_request * request ); |
1 | 765 |
122 | 766 void bookmark_register_module ( void ); |
767 | |
1 | 768 gftp_request *gftp_request_new ( void ); |
769 | |
67 | 770 void gftp_request_destroy ( gftp_request * request, |
771 int free_request ); | |
1 | 772 |
773 void gftp_file_destroy ( gftp_file *file ); | |
774 | |
775 int gftp_connect ( gftp_request * request ); | |
776 | |
777 void gftp_disconnect ( gftp_request * request ); | |
778 | |
58 | 779 off_t gftp_get_file ( gftp_request * request, |
1 | 780 const char *filename, |
58 | 781 int fd, |
1 | 782 size_t startsize ); |
783 | |
784 int gftp_put_file ( gftp_request * request, | |
785 const char *filename, | |
58 | 786 int fd, |
1 | 787 size_t startsize, |
788 size_t totalsize ); | |
789 | |
790 long gftp_transfer_file ( gftp_request *fromreq, | |
791 const char *fromfile, | |
58 | 792 int fromfd, |
1 | 793 size_t fromsize, |
794 gftp_request *toreq, | |
795 const char *tofile, | |
58 | 796 int tofd, |
1 | 797 size_t tosize ); |
798 | |
58 | 799 ssize_t gftp_get_next_file_chunk ( gftp_request * request, |
1 | 800 char *buf, |
801 size_t size ); | |
802 | |
58 | 803 ssize_t gftp_put_next_file_chunk ( gftp_request * request, |
1 | 804 char *buf, |
805 size_t size ); | |
806 | |
807 int gftp_list_files ( gftp_request * request ); | |
808 | |
186 | 809 #if GLIB_MAJOR_VERSION > 1 |
810 char * gftp_string_to_utf8 ( gftp_request * request, | |
811 char *str ); | |
812 #endif | |
813 | |
87 | 814 int gftp_parse_bookmark ( gftp_request * request, |
815 const char * bookmark ); | |
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 |