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