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