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