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