Mercurial > gftp.yaz
annotate lib/gftp.h @ 139:c363b08e0118
2003-4-21 Brian Masney <masneyb@gftp.org>
* lib/gftp.h - added ui_cancel_function to struct gftp_option_type_var
* src/gtk/gftp-gtk.c - added custom_edit_value to struct
gftp_textcomboedt_widget_data
* src/gtk/options_dialog.c - fixups for gftp_option_type_textcomboedt.
The value will always convert %n to \n when reading in and then do the
opposite conversion when saving the variable. Also, added tooltips to
the options
* lib/rfc959.c - remove FIXME comment
author | masneyb |
---|---|
date | Tue, 22 Apr 2003 01:42:05 +0000 |
parents | 84b3e69807a2 |
children | 782f84694489 |
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); | |
139 | 255 void (*ui_cancel_function) (gftp_config_vars * cv, void *user_data); |
136 | 256 void *user_data; |
257 } gftp_option_type_var; | |
258 | |
259 | |
260 #define GFTP_TEXTCOMBOEDT_EDITABLE (1 << 0) | |
261 | |
262 typedef struct gftp_textcomboedt_data_tag | |
263 { | |
264 char *description, | |
265 *text; | |
266 int flags; | |
267 } gftp_textcomboedt_data; | |
268 | |
269 | |
1 | 270 typedef struct gftp_request_tag gftp_request; |
271 | |
272 struct gftp_request_tag | |
273 { | |
274 int protonum; /* Current number of the protocol this is | |
275 set to */ | |
276 char *hostname, /* Hostname we will connect to */ | |
277 *username, /* Username for host*/ | |
278 *password, /* Password for host */ | |
279 *account, /* Account for host (FTP only) */ | |
280 *directory, /* Current working directory */ | |
281 *url_prefix, /* URL Prefix (ex: ftp) */ | |
282 *last_ftp_response, /* Last response from server */ | |
283 *last_dir_entry; /* Last dir entry from server */ | |
284 size_t last_dir_entry_len; /* Length of last_dir_entry */ | |
285 | |
122 | 286 unsigned int port; /* Port of remote site */ |
1 | 287 |
58 | 288 int sockfd, /* Control connection (read) */ |
289 datafd, /* Data connection */ | |
290 cachefd; /* For the directory cache */ | |
1 | 291 int wakeup_main_thread[2]; /* FD that gets written to by the threads |
292 to wakeup the parent */ | |
122 | 293 |
294 /* One of these are used to lookup the IP address of the host we are | |
295 connecting to */ | |
1 | 296 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) |
122 | 297 struct addrinfo *hostp; |
1 | 298 #else |
122 | 299 struct hostent host, *hostp; |
1 | 300 #endif |
301 | |
122 | 302 int server_type; /* The type of server we are connected to. |
303 See GFTP_DIRTYPE_* above */ | |
304 unsigned int use_proxy : 1, | |
1 | 305 always_connected : 1, |
306 need_hostport : 1, | |
307 need_userpass : 1, | |
308 use_cache : 1, /* Enable or disable the cache */ | |
309 use_threads : 1, /* Whether we need to spawn a thread | |
310 for this protocol */ | |
311 cached : 1, /* Is this directory listing cached? */ | |
41 | 312 cancel : 1, /* If a signal is received, should |
313 we cancel this operation */ | |
1 | 314 stopable : 1; |
315 | |
316 off_t gotbytes; | |
317 | |
318 void *protocol_data; | |
319 | |
320 gftp_logging_func logging_function; | |
321 void *user_data; | |
322 | |
323 void (*init) ( gftp_request * request ); | |
324 void (*destroy) ( gftp_request * request ); | |
325 int (*connect) ( gftp_request * request ); | |
326 void (*disconnect) ( gftp_request * request ); | |
58 | 327 off_t (*get_file) ( gftp_request * request, |
1 | 328 const char *filename, |
58 | 329 int fd, |
1 | 330 off_t startsize ); |
331 int (*put_file) ( gftp_request * request, | |
332 const char *filename, | |
58 | 333 int fd, |
1 | 334 off_t startsize, |
335 off_t totalsize ); | |
336 long (*transfer_file) ( gftp_request * fromreq, | |
337 const char *fromfile, | |
338 off_t fromsize, | |
339 gftp_request * toreq, | |
340 const char *tofile, | |
341 off_t tosize ); | |
58 | 342 ssize_t (*get_next_file_chunk) ( gftp_request * request, |
1 | 343 char *buf, |
344 size_t size ); | |
58 | 345 ssize_t (*put_next_file_chunk) ( gftp_request * request, |
1 | 346 char *buf, |
347 size_t size ); | |
348 int (*end_transfer) ( gftp_request * request ); | |
40 | 349 int (*abort_transfer) ( gftp_request * request ); |
1 | 350 int (*list_files) ( gftp_request * request ); |
351 int (*get_next_file) ( gftp_request * request, | |
352 gftp_file *fle, | |
58 | 353 int fd ); |
1 | 354 off_t (*get_file_size) ( gftp_request * request, |
355 const char *filename ); | |
356 int (*chdir) ( gftp_request * request, | |
357 const char *directory ); | |
358 int (*rmdir) ( gftp_request * request, | |
359 const char *directory ); | |
360 int (*rmfile) ( gftp_request * request, | |
361 const char *filename ); | |
362 int (*mkdir) ( gftp_request * request, | |
363 const char *directory ); | |
364 int (*rename) ( gftp_request * request, | |
365 const char *oldname, | |
366 const char *newname ); | |
367 int (*chmod) ( gftp_request * request, | |
368 const char *filename, | |
369 int mode ); | |
370 int (*set_file_time) ( gftp_request * request, | |
371 const char *filename, | |
372 time_t datettime ); | |
373 int (*site) ( gftp_request * request, | |
374 const char *filename ); | |
375 int (*parse_url) ( gftp_request * request, | |
376 const char *url ); | |
58 | 377 void (*set_config_options) ( gftp_request * request ); |
63 | 378 void (*swap_socks) ( gftp_request * dest, |
379 gftp_request * source ); | |
1 | 380 |
136 | 381 gftp_config_vars * local_options_vars; |
382 int num_local_options_vars; | |
383 GHashTable * local_options_hash; | |
1 | 384 }; |
385 | |
386 | |
136 | 387 typedef struct gftp_transfer_tag |
1 | 388 { |
389 gftp_request * fromreq, | |
390 * toreq; | |
391 | |
392 unsigned int transfer_direction : 1, | |
393 cancel : 1, | |
394 ready : 1, | |
395 started : 1, | |
396 done : 1, | |
397 show : 1, | |
398 stalled : 1, | |
399 next_file : 1, | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
400 skip_file : 1; |
1 | 401 |
402 struct timeval starttime, | |
403 lasttime; | |
404 | |
405 double kbs; | |
406 | |
407 GList * files, | |
408 * curfle, | |
409 * updfle; | |
410 | |
19 | 411 long numfiles, |
412 numdirs, | |
413 current_file_number, | |
414 current_file_retries; | |
1 | 415 |
416 off_t curtrans, /* Current transfered bytes for this file */ | |
417 curresumed, /* Resumed bytes for this file */ | |
418 trans_bytes, /* Amount of data transfered for entire | |
419 transfer */ | |
420 total_bytes, /* Grand total bytes for whole transfer */ | |
421 resumed_bytes; /* Grand total of resumed bytes for whole | |
422 transfer */ | |
423 | |
424 void * fromwdata, | |
425 * towdata; | |
426 | |
122 | 427 GStaticMutex statmutex, |
428 structmutex; | |
429 | |
125 | 430 void *user_data; |
1 | 431 void *clist; |
136 | 432 } gftp_transfer; |
1 | 433 |
434 | |
435 typedef struct gftp_log_tag | |
436 { | |
437 char *msg; | |
438 gftp_logging_level type; | |
439 } gftp_log; | |
440 | |
441 | |
442 typedef struct supported_gftp_protocols_tag | |
443 { | |
444 char *name; /* Description of protocol */ | |
445 void (*init) (gftp_request * request); /* Init function */ | |
122 | 446 void (*register_options) (void); /* Protocol options */ |
1 | 447 char *url_prefix; /* URL Prefix */ |
122 | 448 int shown; /* Whether this protocol is |
449 shown or not to the user in | |
450 the protocol dropdown box */ | |
1 | 451 } supported_gftp_protocols; |
452 | |
453 | |
122 | 454 typedef struct gftp_bookmarks_tag gftp_bookmarks_var; |
1 | 455 |
456 struct gftp_bookmarks_tag | |
457 { | |
458 char *path; /* Path */ | |
459 char *hostname, /* Our actual internet hostname */ | |
460 *protocol, /* Protocol we will connect through */ | |
461 *remote_dir, /* Initial directory */ | |
462 *local_dir, /* Init local directory */ | |
463 *user, /* Username to log in as */ | |
464 *pass, /* Our password */ | |
465 *acct; /* Account */ | |
466 | |
467 unsigned int port, /* The port we will connect to */ | |
468 isfolder : 1, /* If this is set, then the children field can | |
469 be non-NULL */ | |
470 save_password : 1; /* Save this password */ | |
122 | 471 gftp_bookmarks_var *children, /* The children of this node. */ |
472 *prev, /* The parent of this node */ | |
473 *next; /* The next sibling of this node */ | |
1 | 474 gpointer cnode; |
475 | |
476 /* Site options */ | |
477 char *sftpserv_path; /* Path to the sftp server */ | |
478 }; | |
479 | |
480 | |
481 typedef struct gftp_file_extensions_tag | |
482 { | |
483 char *ext, /* The file extension to register */ | |
484 *filename, /* The xpm file to display */ | |
485 *view_program, /* The program used to view this file */ | |
486 *ascii_binary; /* Is this a ASCII transfer or a BINARY transfer */ | |
487 int stlen; /* How long is the file extension. */ | |
488 } gftp_file_extensions; | |
489 | |
490 | |
491 typedef struct gftp_color_tag | |
492 { | |
493 gushort red, | |
494 green, | |
495 blue; | |
496 } gftp_color; | |
497 | |
498 | |
58 | 499 typedef struct gftp_getline_buffer_tag |
500 { | |
501 char *buffer, | |
502 *curpos; | |
503 size_t max_bufsize, | |
504 cur_bufsize; | |
505 } gftp_getline_buffer; | |
506 | |
126 | 507 |
122 | 508 /* Global config options. These are defined in options.h */ |
509 extern GList * gftp_file_transfers, * gftp_file_transfer_logs, | |
510 * gftp_options_list; | |
511 extern GHashTable * gftp_global_options_htable, * gftp_bookmarks_htable, | |
512 * gftp_config_list_htable; | |
513 extern gftp_config_vars gftp_global_config_vars[]; | |
1 | 514 extern supported_gftp_protocols gftp_protocols[]; |
122 | 515 extern gftp_bookmarks_var * gftp_bookmarks; |
516 extern char gftp_version[]; | |
517 extern FILE * gftp_logfd; | |
518 | |
519 /* This is defined in config_file.c */ | |
520 | |
521 extern gftp_option_type_var gftp_option_types[]; | |
1 | 522 |
523 /* cache.c */ | |
58 | 524 int gftp_new_cache_entry ( gftp_request * request ); |
1 | 525 |
58 | 526 int gftp_find_cache_entry ( gftp_request * request ); |
1 | 527 |
528 void gftp_clear_cache_files ( void ); | |
529 | |
47 | 530 void gftp_delete_cache_entry ( gftp_request * request, |
531 int ignore_directory ); | |
1 | 532 |
533 /* config_file.c */ | |
122 | 534 void gftp_add_bookmark ( gftp_bookmarks_var * newentry ); |
535 | |
124 | 536 void gftp_read_config_file ( char *global_data_path ); |
1 | 537 |
122 | 538 void gftp_write_bookmarks_file ( void ); |
1 | 539 |
540 void gftp_write_config_file ( void ); | |
541 | |
122 | 542 GHashTable * build_bookmarks_hash_table ( gftp_bookmarks_var * entry ); |
543 | |
544 void print_bookmarks ( gftp_bookmarks_var * bookmarks ); | |
545 | |
546 void gftp_lookup_global_option ( char * key, | |
547 void *value ); | |
26 | 548 |
122 | 549 void gftp_lookup_request_option ( gftp_request * request, |
550 char * key, | |
551 void *value ); | |
1 | 552 |
122 | 553 void gftp_set_global_option ( char * key, |
554 void *value ); | |
555 | |
556 void gftp_set_request_option ( gftp_request * request, | |
557 char * key, | |
558 void *value ); | |
559 | |
560 void gftp_register_config_vars ( gftp_config_vars *config_vars ); | |
1 | 561 |
562 /* misc.c */ | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
563 char *insert_commas ( off_t number, |
1 | 564 char *dest_str, |
565 size_t dest_len ); | |
566 | |
567 char *alltrim ( char *str ); | |
568 | |
569 char *expand_path ( const char *src ); | |
570 | |
571 void remove_double_slashes ( char *string ); | |
572 | |
573 void make_nonnull ( char **str ); | |
574 | |
575 int copyfile ( char *source, | |
576 char *dest ); | |
577 | |
578 char *get_xpm_path ( char *filename, | |
579 int quit_on_err ); | |
580 | |
581 int gftp_match_filespec ( char *filename, | |
582 char *filespec ); | |
583 | |
584 int gftp_parse_command_line ( int *argc, | |
585 char ***argv ); | |
586 | |
587 void gftp_usage ( void ); | |
588 | |
589 gint string_hash_compare ( gconstpointer path1, | |
590 gconstpointer path2 ); | |
591 | |
592 guint string_hash_function ( gconstpointer key ); | |
593 | |
594 void free_file_list ( GList * filelist ); | |
595 | |
596 void free_fdata ( gftp_file * fle ); | |
597 | |
598 gftp_file * copy_fdata ( gftp_file * fle ); | |
599 | |
600 int compare_request ( gftp_request * request1, | |
601 gftp_request * request2, | |
602 int compare_dirs ); | |
603 | |
129 | 604 gftp_transfer * gftp_tdata_new ( void ); |
605 | |
1 | 606 void free_tdata ( gftp_transfer * tdata ); |
607 | |
136 | 608 void gftp_copy_local_options ( gftp_request * dest, |
609 gftp_request * source ); | |
610 | |
1 | 611 gftp_request * copy_request ( gftp_request * req ); |
612 | |
124 | 613 int ptym_open ( char *pts_name, |
614 size_t len ); | |
1 | 615 |
616 int ptys_open ( int fdm, | |
617 char *pts_name ); | |
618 | |
619 int tty_raw ( int fd ); | |
620 | |
16 | 621 GList * gftp_sort_filelist ( GList * filelist, |
622 int column, | |
623 int asds ); | |
624 | |
125 | 625 mode_t gftp_parse_attribs ( char *attribs ); |
626 | |
131 | 627 char * gftp_gen_ls_string ( gftp_file * fle, |
628 char *file_prefixstr, | |
629 char *file_suffixstr ); | |
630 | |
1 | 631 /* protocols.c */ |
632 #define GFTP_FTP_NUM 0 | |
633 #define GFTP_HTTP_NUM 1 | |
634 #define GFTP_LOCAL_NUM 2 | |
635 #define GFTP_SSHV2_NUM 3 | |
636 #define GFTP_BOOKMARK_NUM 4 | |
122 | 637 |
1 | 638 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \ |
58 | 639 ((request)->sockfd > 0 || \ |
640 (request)->cached || \ | |
641 (request)->always_connected)) | |
1 | 642 |
643 | |
644 void rfc959_init ( gftp_request * request ); | |
645 | |
122 | 646 void rfc959_register_module ( void ); |
647 | |
1 | 648 int rfc959_get_next_file ( gftp_request * request, |
649 gftp_file *fle, | |
58 | 650 int fd ); |
1 | 651 |
652 void rfc2068_init ( gftp_request * request ); | |
653 | |
122 | 654 void rfc2068_register_module ( void ); |
655 | |
1 | 656 void local_init ( gftp_request * request ); |
657 | |
122 | 658 void local_register_module ( void ); |
659 | |
1 | 660 void sshv2_init ( gftp_request * request ); |
661 | |
122 | 662 void sshv2_register_module ( void ); |
663 | |
1 | 664 void bookmark_init ( gftp_request * request ); |
665 | |
122 | 666 void bookmark_register_module ( void ); |
667 | |
1 | 668 gftp_request *gftp_request_new ( void ); |
669 | |
67 | 670 void gftp_request_destroy ( gftp_request * request, |
671 int free_request ); | |
1 | 672 |
673 void gftp_file_destroy ( gftp_file *file ); | |
674 | |
675 int gftp_connect ( gftp_request * request ); | |
676 | |
677 void gftp_disconnect ( gftp_request * request ); | |
678 | |
58 | 679 off_t gftp_get_file ( gftp_request * request, |
1 | 680 const char *filename, |
58 | 681 int fd, |
1 | 682 size_t startsize ); |
683 | |
684 int gftp_put_file ( gftp_request * request, | |
685 const char *filename, | |
58 | 686 int fd, |
1 | 687 size_t startsize, |
688 size_t totalsize ); | |
689 | |
690 long gftp_transfer_file ( gftp_request *fromreq, | |
691 const char *fromfile, | |
58 | 692 int fromfd, |
1 | 693 size_t fromsize, |
694 gftp_request *toreq, | |
695 const char *tofile, | |
58 | 696 int tofd, |
1 | 697 size_t tosize ); |
698 | |
58 | 699 ssize_t gftp_get_next_file_chunk ( gftp_request * request, |
1 | 700 char *buf, |
701 size_t size ); | |
702 | |
58 | 703 ssize_t gftp_put_next_file_chunk ( gftp_request * request, |
1 | 704 char *buf, |
705 size_t size ); | |
706 | |
707 int gftp_list_files ( gftp_request * request ); | |
708 | |
87 | 709 int gftp_parse_bookmark ( gftp_request * request, |
710 const char * bookmark ); | |
711 | |
1 | 712 int gftp_parse_url ( gftp_request * request, |
713 const char *url ); | |
714 | |
715 int gftp_get_next_file ( gftp_request * request, | |
716 char *filespec, | |
717 gftp_file *fle ); | |
718 | |
719 int gftp_end_transfer ( gftp_request * request ); | |
720 | |
40 | 721 int gftp_abort_transfer ( gftp_request * request ); |
722 | |
1 | 723 void gftp_set_hostname ( gftp_request * request, |
724 const char *hostname ); | |
725 | |
726 void gftp_set_username ( gftp_request * request, | |
727 const char *username ); | |
728 | |
729 void gftp_set_password ( gftp_request * request, | |
730 const char *password ); | |
731 | |
732 void gftp_set_account ( gftp_request * request, | |
733 const char *account ); | |
734 | |
735 int gftp_set_directory ( gftp_request * request, | |
736 const char *directory ); | |
737 | |
738 void gftp_set_port ( gftp_request * request, | |
739 unsigned int port ); | |
740 | |
741 int gftp_remove_directory ( gftp_request * request, | |
742 const char *directory ); | |
743 | |
744 int gftp_remove_file ( gftp_request * request, | |
745 const char *file ); | |
746 | |
747 int gftp_make_directory ( gftp_request * request, | |
748 const char *directory ); | |
749 | |
750 int gftp_rename_file ( gftp_request * request, | |
751 const char *oldname, | |
752 const char *newname ); | |
753 | |
754 int gftp_chmod ( gftp_request * request, | |
755 const char *file, | |
756 int mode ); | |
757 | |
758 int gftp_set_file_time ( gftp_request * request, | |
759 const char *file, | |
760 time_t datetime ); | |
761 | |
762 char gftp_site_cmd ( gftp_request * request, | |
763 const char *command ); | |
764 | |
58 | 765 off_t gftp_get_file_size ( gftp_request * request, |
1 | 766 const char *filename ); |
767 | |
768 void gftp_calc_kbs ( gftp_transfer * tdata, | |
769 ssize_t num_read ); | |
770 | |
102 | 771 time_t parse_time ( char *str, |
772 char **endpos ); | |
773 | |
91 | 774 int gftp_parse_ls ( gftp_request * request, |
775 const char *lsoutput, | |
1 | 776 gftp_file *fle ); |
777 | |
778 int gftp_get_all_subdirs ( gftp_transfer * transfer, | |
779 void (*update_func) | |
780 ( gftp_transfer * transfer )); | |
781 | |
782 int gftp_connect_server ( gftp_request * request, | |
122 | 783 char *service, |
784 char *proxy_hostname, | |
785 int proxy_port ); | |
1 | 786 |
122 | 787 #if !defined (HAVE_GETADDRINFO) || !defined (HAVE_GAI_STRERROR) |
1 | 788 |
789 struct hostent *r_gethostbyname ( const char *name, | |
790 struct hostent *result_buf, | |
791 int *h_errnop ); | |
792 | |
56 | 793 #endif |
794 | |
1 | 795 struct servent *r_getservbyname ( const char *name, |
796 const char *proto, | |
797 struct servent *result_buf, | |
798 int *h_errnop ); | |
122 | 799 |
1 | 800 void gftp_set_config_options ( gftp_request * request ); |
801 | |
802 void print_file_list ( GList * list ); | |
803 | |
58 | 804 ssize_t gftp_get_line ( gftp_request * request, |
805 gftp_getline_buffer ** rbuf, | |
41 | 806 char * str, |
807 size_t len, | |
58 | 808 int fd ); |
809 | |
810 ssize_t gftp_read ( gftp_request * request, | |
811 void *ptr, | |
812 size_t size, | |
813 int fd ); | |
41 | 814 |
58 | 815 ssize_t gftp_write ( gftp_request * request, |
816 const char *ptr, | |
41 | 817 size_t size, |
58 | 818 int fd ); |
819 | |
820 ssize_t gftp_writefmt ( gftp_request * request, | |
821 int fd, | |
822 const char *fmt, | |
823 ... ); | |
824 | |
825 int gftp_set_sockblocking ( gftp_request * request, | |
826 int fd, | |
827 int non_blocking ); | |
41 | 828 |
63 | 829 void gftp_swap_socks ( gftp_request * dest, |
830 gftp_request * source ); | |
831 | |
122 | 832 void gftp_calc_kbs ( gftp_transfer * tdata, |
833 ssize_t num_read ); | |
834 | |
125 | 835 int gftp_get_transfer_status ( gftp_transfer * tdata, |
836 ssize_t num_read ); | |
837 | |
1 | 838 #endif |
839 |