Mercurial > gftp.yaz
annotate lib/gftp.h @ 122:76e2b58a9440
2003-4-5 Brian Masney <masneyb@gftp.org>
* lib/config_file.c lib/options.h lib/gftp.h lib/rfc959.c
lib/rfc2068.c lib/ssh.c - added new internal configuration interface.
Rather than having a global variable for each option, I have a global
hash table (gftp_global_options_htable) that I can look up option names
by name using gftp_lookup_global_option(). I also an options hash
associated with a request structure, so I will be able to call
gftp_lookup_request_option(). I will be able to override options with
bookmarks or while transfers are in progress very easily now. Also, all
options no longer have to appear in config_file.c, the per protocol
options can appear inside their own file
* lib/gftp.h lib/bookmarks.c lib/local.c lib/rfc959.c lib/rfc2068.c -
remove set_data_type and protocol name from struct gftp_request
* lib/rfc959.c - renamed all firewall_* variables to ftp_proxy_* in
the config file
* lib/gftp.h lib/protocols.c lib/rfc959.c - renamed all GFTP_TYPE_*
vars to GFTP_DIRTYPE_*
* lib/gftp.h - removed ascii field and renamed the node pointer to
user_data in struct gftp_file. In gftp_request, removed any setting
that is now stored in the global/local hash tables. Added
register_module() pointer that will be called whenever the protocol is
first loaded into gftp
* lib/rfc959.c src/text/gftp-text.c - moved the ascii/binary
translation to rfc959.c. Also, moved any instance of automatically
setting the data type to rfc959.c as well.
* lib/misc.c lib/sshv2.c - moved all ssh functions from misc.c to
sshv2.c. I had these origionally in misc.c because I used to have 2
different SSH protocols
* lib/protocols.c src/text/gftp-text.c - added gftp_calc_kbs() to
protocols.c. This no longer needs to be in the different ports
* src/text/gftp-text.c - read/write options based on new configuration
interface
* Use new configuration interface in all source files
* Updated copyright dates on all source files
* Note: GTK+ port is completely broken at the moment. I'll upload
those changes whenever I get them done
author | masneyb |
---|---|
date | Sat, 05 Apr 2003 16:30:45 +0000 |
parents | 3b573c8ef706 |
children | 65048c959029 |
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 | |
195 typedef struct gftp_request_tag gftp_request; | |
196 | |
197 struct gftp_request_tag | |
198 { | |
199 int protonum; /* Current number of the protocol this is | |
200 set to */ | |
201 char *hostname, /* Hostname we will connect to */ | |
202 *username, /* Username for host*/ | |
203 *password, /* Password for host */ | |
204 *account, /* Account for host (FTP only) */ | |
205 *directory, /* Current working directory */ | |
206 *url_prefix, /* URL Prefix (ex: ftp) */ | |
207 *last_ftp_response, /* Last response from server */ | |
208 *last_dir_entry; /* Last dir entry from server */ | |
209 size_t last_dir_entry_len; /* Length of last_dir_entry */ | |
210 | |
122 | 211 unsigned int port; /* Port of remote site */ |
1 | 212 |
58 | 213 int sockfd, /* Control connection (read) */ |
214 datafd, /* Data connection */ | |
215 cachefd; /* For the directory cache */ | |
1 | 216 int wakeup_main_thread[2]; /* FD that gets written to by the threads |
217 to wakeup the parent */ | |
122 | 218 |
219 /* One of these are used to lookup the IP address of the host we are | |
220 connecting to */ | |
1 | 221 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) |
122 | 222 struct addrinfo *hostp; |
1 | 223 #else |
122 | 224 struct hostent host, *hostp; |
1 | 225 #endif |
226 | |
122 | 227 int server_type; /* The type of server we are connected to. |
228 See GFTP_DIRTYPE_* above */ | |
229 unsigned int use_proxy : 1, | |
1 | 230 always_connected : 1, |
231 need_hostport : 1, | |
232 need_userpass : 1, | |
233 use_cache : 1, /* Enable or disable the cache */ | |
234 use_threads : 1, /* Whether we need to spawn a thread | |
235 for this protocol */ | |
236 cached : 1, /* Is this directory listing cached? */ | |
41 | 237 cancel : 1, /* If a signal is received, should |
238 we cancel this operation */ | |
1 | 239 stopable : 1; |
240 | |
241 off_t gotbytes; | |
242 | |
243 void *protocol_data; | |
244 | |
245 gftp_logging_func logging_function; | |
246 void *user_data; | |
247 | |
248 void (*init) ( gftp_request * request ); | |
249 void (*destroy) ( gftp_request * request ); | |
250 int (*connect) ( gftp_request * request ); | |
251 void (*disconnect) ( gftp_request * request ); | |
58 | 252 off_t (*get_file) ( gftp_request * request, |
1 | 253 const char *filename, |
58 | 254 int fd, |
1 | 255 off_t startsize ); |
256 int (*put_file) ( gftp_request * request, | |
257 const char *filename, | |
58 | 258 int fd, |
1 | 259 off_t startsize, |
260 off_t totalsize ); | |
261 long (*transfer_file) ( gftp_request * fromreq, | |
262 const char *fromfile, | |
263 off_t fromsize, | |
264 gftp_request * toreq, | |
265 const char *tofile, | |
266 off_t tosize ); | |
58 | 267 ssize_t (*get_next_file_chunk) ( gftp_request * request, |
1 | 268 char *buf, |
269 size_t size ); | |
58 | 270 ssize_t (*put_next_file_chunk) ( gftp_request * request, |
1 | 271 char *buf, |
272 size_t size ); | |
273 int (*end_transfer) ( gftp_request * request ); | |
40 | 274 int (*abort_transfer) ( gftp_request * request ); |
1 | 275 int (*list_files) ( gftp_request * request ); |
276 int (*get_next_file) ( gftp_request * request, | |
277 gftp_file *fle, | |
58 | 278 int fd ); |
1 | 279 off_t (*get_file_size) ( gftp_request * request, |
280 const char *filename ); | |
281 int (*chdir) ( gftp_request * request, | |
282 const char *directory ); | |
283 int (*rmdir) ( gftp_request * request, | |
284 const char *directory ); | |
285 int (*rmfile) ( gftp_request * request, | |
286 const char *filename ); | |
287 int (*mkdir) ( gftp_request * request, | |
288 const char *directory ); | |
289 int (*rename) ( gftp_request * request, | |
290 const char *oldname, | |
291 const char *newname ); | |
292 int (*chmod) ( gftp_request * request, | |
293 const char *filename, | |
294 int mode ); | |
295 int (*set_file_time) ( gftp_request * request, | |
296 const char *filename, | |
297 time_t datettime ); | |
298 int (*site) ( gftp_request * request, | |
299 const char *filename ); | |
300 int (*parse_url) ( gftp_request * request, | |
301 const char *url ); | |
58 | 302 void (*set_config_options) ( gftp_request * request ); |
63 | 303 void (*swap_socks) ( gftp_request * dest, |
304 gftp_request * source ); | |
1 | 305 |
122 | 306 GHashTable * local_options; |
1 | 307 }; |
308 | |
309 | |
310 typedef struct gftp_transfer_tag gftp_transfer; | |
311 | |
312 struct gftp_transfer_tag | |
313 { | |
314 gftp_request * fromreq, | |
315 * toreq; | |
316 | |
317 unsigned int transfer_direction : 1, | |
318 cancel : 1, | |
319 ready : 1, | |
320 started : 1, | |
321 done : 1, | |
322 show : 1, | |
323 stalled : 1, | |
324 next_file : 1, | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
325 skip_file : 1; |
1 | 326 |
327 struct timeval starttime, | |
328 lasttime; | |
329 | |
330 double kbs; | |
331 | |
332 GList * files, | |
333 * curfle, | |
334 * updfle; | |
335 | |
19 | 336 long numfiles, |
337 numdirs, | |
338 current_file_number, | |
339 current_file_retries; | |
1 | 340 |
341 off_t curtrans, /* Current transfered bytes for this file */ | |
342 curresumed, /* Resumed bytes for this file */ | |
343 trans_bytes, /* Amount of data transfered for entire | |
344 transfer */ | |
345 total_bytes, /* Grand total bytes for whole transfer */ | |
346 resumed_bytes; /* Grand total of resumed bytes for whole | |
347 transfer */ | |
348 | |
349 void * fromwdata, | |
350 * towdata; | |
351 | |
122 | 352 GStaticMutex statmutex, |
353 structmutex; | |
354 | |
1 | 355 void *node; |
356 void *clist; | |
357 }; | |
358 | |
359 | |
360 typedef struct gftp_log_tag | |
361 { | |
362 char *msg; | |
363 gftp_logging_level type; | |
364 } gftp_log; | |
365 | |
366 | |
367 typedef struct supported_gftp_protocols_tag | |
368 { | |
369 char *name; /* Description of protocol */ | |
370 void (*init) (gftp_request * request); /* Init function */ | |
122 | 371 void (*register_options) (void); /* Protocol options */ |
1 | 372 char *url_prefix; /* URL Prefix */ |
122 | 373 int shown; /* Whether this protocol is |
374 shown or not to the user in | |
375 the protocol dropdown box */ | |
1 | 376 } supported_gftp_protocols; |
377 | |
378 | |
122 | 379 typedef struct gftp_bookmarks_tag gftp_bookmarks_var; |
1 | 380 |
381 struct gftp_bookmarks_tag | |
382 { | |
383 char *path; /* Path */ | |
384 char *hostname, /* Our actual internet hostname */ | |
385 *protocol, /* Protocol we will connect through */ | |
386 *remote_dir, /* Initial directory */ | |
387 *local_dir, /* Init local directory */ | |
388 *user, /* Username to log in as */ | |
389 *pass, /* Our password */ | |
390 *acct; /* Account */ | |
391 | |
392 unsigned int port, /* The port we will connect to */ | |
393 isfolder : 1, /* If this is set, then the children field can | |
394 be non-NULL */ | |
395 save_password : 1; /* Save this password */ | |
122 | 396 gftp_bookmarks_var *children, /* The children of this node. */ |
397 *prev, /* The parent of this node */ | |
398 *next; /* The next sibling of this node */ | |
1 | 399 gpointer cnode; |
400 | |
401 /* Site options */ | |
402 char *sftpserv_path; /* Path to the sftp server */ | |
403 }; | |
404 | |
405 | |
406 typedef struct gftp_file_extensions_tag | |
407 { | |
408 char *ext, /* The file extension to register */ | |
409 *filename, /* The xpm file to display */ | |
410 *view_program, /* The program used to view this file */ | |
411 *ascii_binary; /* Is this a ASCII transfer or a BINARY transfer */ | |
412 int stlen; /* How long is the file extension. */ | |
413 } gftp_file_extensions; | |
414 | |
415 | |
416 typedef struct gftp_color_tag | |
417 { | |
418 gushort red, | |
419 green, | |
420 blue; | |
421 } gftp_color; | |
422 | |
423 | |
122 | 424 /* Note, these numbers must match up to the index number in config_file.c |
425 in the declaration of gftp_option_types */ | |
426 typedef enum | |
1 | 427 { |
122 | 428 gftp_option_type_text = 0, |
429 gftp_option_type_textarray = 1, | |
430 gftp_option_type_int = 2, | |
431 gftp_option_type_float = 3, | |
432 gftp_option_type_checkbox = 4, | |
433 gftp_option_type_color = 5, | |
434 gftp_option_type_notebook = 6, | |
435 gftp_option_type_newtable = 7, | |
436 gftp_option_type_hidetext = 8, | |
437 gftp_option_type_label = 9, | |
438 gftp_option_type_textbox = 10, | |
439 gftp_option_type_subtree = 11, | |
440 gftp_option_type_intcombo = 12, | |
441 gftp_option_type_charcombo = 13, | |
442 gftp_option_type_table = 14 | |
443 } gftp_option_type_enum; | |
1 | 444 |
445 | |
37 | 446 #define GFTP_PORT_GTK (1 << 1) |
447 #define GFTP_PORT_TEXT (1 << 2) | |
448 #define GFTP_PORT_ALL (GFTP_PORT_GTK | GFTP_PORT_TEXT) | |
449 | |
122 | 450 |
451 typedef struct gftp_config_list_vars_tag | |
452 { | |
453 char *key; | |
454 void * (*read_func) (char *buf, int line); | |
455 void (*write_func) (FILE *fd, void *data); | |
456 GList * list; | |
457 unsigned int num_items; | |
458 char *header; | |
459 } gftp_config_list_vars; | |
460 | |
461 | |
462 #define GFTP_CVARS_FLAGS_DYNMEM (1 << 1) | |
463 | |
464 | |
465 typedef struct gftp_config_vars_tag | |
466 { | |
467 char *key, /* variable name */ | |
468 *description; /* How this field will show up in the dialog */ | |
469 int otype; /* Type of option this is */ | |
470 void *value; | |
471 void *listdata; /* For options that have several different | |
472 options, this is a list of all the options. | |
473 Each option_type that uses this will use this | |
474 field differently */ | |
475 int flags; /* See GFTP_CVARS_FLAGS_* above */ | |
476 char *comment; /* Comment to write out to the config file */ | |
477 int ports_shown; /* What ports of gFTP is this option shown in */ | |
478 void *user_data; /* Data that the GUI can store here (Widget in gtk+) */ | |
479 } gftp_config_vars; | |
480 | |
481 | |
482 typedef struct gftp_option_type_tag | |
483 { | |
484 int (*read_function) (char *str, gftp_config_vars * cv, int line); | |
485 int (*write_function) (gftp_config_vars * cv, FILE * fd, int to_config_file); | |
486 int (*ui_print_function) (char *label, void *ptr, void *user_data); | |
487 int (*config_copy_function) (void *dest, void *src); | |
488 void *user_data; | |
489 } gftp_option_type_var; | |
490 | |
491 | |
492 typedef struct gftp_proxy_type_var_tag | |
1 | 493 { |
494 char *key, | |
495 *description; | |
122 | 496 } gftp_proxy_type_var; |
1 | 497 |
498 #define GFTP_CUSTOM_PROXY_NUM 8 | |
499 | |
58 | 500 typedef struct gftp_getline_buffer_tag |
501 { | |
502 char *buffer, | |
503 *curpos; | |
504 size_t max_bufsize, | |
505 cur_bufsize; | |
506 } gftp_getline_buffer; | |
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_proxy_type_var gftp_proxy_type[]; |
516 extern gftp_bookmarks_var * gftp_bookmarks; | |
517 extern char gftp_version[]; | |
518 extern FILE * gftp_logfd; | |
519 | |
520 /* This is defined in config_file.c */ | |
521 | |
522 extern gftp_option_type_var gftp_option_types[]; | |
1 | 523 |
524 /* cache.c */ | |
58 | 525 int gftp_new_cache_entry ( gftp_request * request ); |
1 | 526 |
58 | 527 int gftp_find_cache_entry ( gftp_request * request ); |
1 | 528 |
529 void gftp_clear_cache_files ( void ); | |
530 | |
47 | 531 void gftp_delete_cache_entry ( gftp_request * request, |
532 int ignore_directory ); | |
1 | 533 |
534 /* config_file.c */ | |
122 | 535 void gftp_add_bookmark ( gftp_bookmarks_var * newentry ); |
536 | |
1 | 537 void gftp_read_config_file ( char **argv, |
538 int get_xpms ); | |
539 | |
122 | 540 void gftp_write_bookmarks_file ( void ); |
1 | 541 |
542 void gftp_write_config_file ( void ); | |
543 | |
122 | 544 GHashTable * build_bookmarks_hash_table ( gftp_bookmarks_var * entry ); |
545 | |
546 void print_bookmarks ( gftp_bookmarks_var * bookmarks ); | |
547 | |
548 void gftp_lookup_global_option ( char * key, | |
549 void *value ); | |
26 | 550 |
122 | 551 void gftp_lookup_request_option ( gftp_request * request, |
552 char * key, | |
553 void *value ); | |
1 | 554 |
122 | 555 void gftp_set_global_option ( char * key, |
556 void *value ); | |
557 | |
558 void gftp_set_request_option ( gftp_request * request, | |
559 char * key, | |
560 void *value ); | |
561 | |
562 void gftp_register_config_vars ( gftp_config_vars *config_vars ); | |
1 | 563 |
564 /* misc.c */ | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
565 char *insert_commas ( off_t number, |
1 | 566 char *dest_str, |
567 size_t dest_len ); | |
568 | |
569 char *alltrim ( char *str ); | |
570 | |
571 char *expand_path ( const char *src ); | |
572 | |
573 void remove_double_slashes ( char *string ); | |
574 | |
575 void make_nonnull ( char **str ); | |
576 | |
577 int copyfile ( char *source, | |
578 char *dest ); | |
579 | |
580 char *get_xpm_path ( char *filename, | |
581 int quit_on_err ); | |
582 | |
583 int gftp_match_filespec ( char *filename, | |
584 char *filespec ); | |
585 | |
586 int gftp_parse_command_line ( int *argc, | |
587 char ***argv ); | |
588 | |
589 void gftp_usage ( void ); | |
590 | |
591 gint string_hash_compare ( gconstpointer path1, | |
592 gconstpointer path2 ); | |
593 | |
594 guint string_hash_function ( gconstpointer key ); | |
595 | |
596 void free_file_list ( GList * filelist ); | |
597 | |
598 void free_fdata ( gftp_file * fle ); | |
599 | |
600 gftp_file * copy_fdata ( gftp_file * fle ); | |
601 | |
602 int compare_request ( gftp_request * request1, | |
603 gftp_request * request2, | |
604 int compare_dirs ); | |
605 | |
606 void free_tdata ( gftp_transfer * tdata ); | |
607 | |
608 gftp_request * copy_request ( gftp_request * req ); | |
609 | |
610 int ptym_open ( char *pts_name ); | |
611 | |
612 int ptys_open ( int fdm, | |
613 char *pts_name ); | |
614 | |
615 int tty_raw ( int fd ); | |
616 | |
16 | 617 GList * gftp_sort_filelist ( GList * filelist, |
618 int column, | |
619 int asds ); | |
620 | |
1 | 621 /* protocols.c */ |
622 #define GFTP_FTP_NUM 0 | |
623 #define GFTP_HTTP_NUM 1 | |
624 #define GFTP_LOCAL_NUM 2 | |
625 #define GFTP_SSHV2_NUM 3 | |
626 #define GFTP_BOOKMARK_NUM 4 | |
122 | 627 |
1 | 628 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \ |
58 | 629 ((request)->sockfd > 0 || \ |
630 (request)->cached || \ | |
631 (request)->always_connected)) | |
1 | 632 |
633 | |
634 void rfc959_init ( gftp_request * request ); | |
635 | |
122 | 636 void rfc959_register_module ( void ); |
637 | |
1 | 638 int rfc959_get_next_file ( gftp_request * request, |
639 gftp_file *fle, | |
58 | 640 int fd ); |
1 | 641 |
642 void rfc2068_init ( gftp_request * request ); | |
643 | |
122 | 644 void rfc2068_register_module ( void ); |
645 | |
1 | 646 void local_init ( gftp_request * request ); |
647 | |
122 | 648 void local_register_module ( void ); |
649 | |
1 | 650 void sshv2_init ( gftp_request * request ); |
651 | |
122 | 652 void sshv2_register_module ( void ); |
653 | |
1 | 654 void bookmark_init ( gftp_request * request ); |
655 | |
122 | 656 void bookmark_register_module ( void ); |
657 | |
1 | 658 gftp_request *gftp_request_new ( void ); |
659 | |
67 | 660 void gftp_request_destroy ( gftp_request * request, |
661 int free_request ); | |
1 | 662 |
663 void gftp_file_destroy ( gftp_file *file ); | |
664 | |
665 int gftp_connect ( gftp_request * request ); | |
666 | |
667 void gftp_disconnect ( gftp_request * request ); | |
668 | |
58 | 669 off_t gftp_get_file ( gftp_request * request, |
1 | 670 const char *filename, |
58 | 671 int fd, |
1 | 672 size_t startsize ); |
673 | |
674 int gftp_put_file ( gftp_request * request, | |
675 const char *filename, | |
58 | 676 int fd, |
1 | 677 size_t startsize, |
678 size_t totalsize ); | |
679 | |
680 long gftp_transfer_file ( gftp_request *fromreq, | |
681 const char *fromfile, | |
58 | 682 int fromfd, |
1 | 683 size_t fromsize, |
684 gftp_request *toreq, | |
685 const char *tofile, | |
58 | 686 int tofd, |
1 | 687 size_t tosize ); |
688 | |
58 | 689 ssize_t gftp_get_next_file_chunk ( gftp_request * request, |
1 | 690 char *buf, |
691 size_t size ); | |
692 | |
58 | 693 ssize_t gftp_put_next_file_chunk ( gftp_request * request, |
1 | 694 char *buf, |
695 size_t size ); | |
696 | |
697 int gftp_list_files ( gftp_request * request ); | |
698 | |
87 | 699 int gftp_parse_bookmark ( gftp_request * request, |
700 const char * bookmark ); | |
701 | |
1 | 702 int gftp_parse_url ( gftp_request * request, |
703 const char *url ); | |
704 | |
705 int gftp_get_next_file ( gftp_request * request, | |
706 char *filespec, | |
707 gftp_file *fle ); | |
708 | |
709 int gftp_end_transfer ( gftp_request * request ); | |
710 | |
40 | 711 int gftp_abort_transfer ( gftp_request * request ); |
712 | |
1 | 713 void gftp_set_hostname ( gftp_request * request, |
714 const char *hostname ); | |
715 | |
716 void gftp_set_username ( gftp_request * request, | |
717 const char *username ); | |
718 | |
719 void gftp_set_password ( gftp_request * request, | |
720 const char *password ); | |
721 | |
722 void gftp_set_account ( gftp_request * request, | |
723 const char *account ); | |
724 | |
725 int gftp_set_directory ( gftp_request * request, | |
726 const char *directory ); | |
727 | |
728 void gftp_set_port ( gftp_request * request, | |
729 unsigned int port ); | |
730 | |
731 int gftp_remove_directory ( gftp_request * request, | |
732 const char *directory ); | |
733 | |
734 int gftp_remove_file ( gftp_request * request, | |
735 const char *file ); | |
736 | |
737 int gftp_make_directory ( gftp_request * request, | |
738 const char *directory ); | |
739 | |
740 int gftp_rename_file ( gftp_request * request, | |
741 const char *oldname, | |
742 const char *newname ); | |
743 | |
744 int gftp_chmod ( gftp_request * request, | |
745 const char *file, | |
746 int mode ); | |
747 | |
748 int gftp_set_file_time ( gftp_request * request, | |
749 const char *file, | |
750 time_t datetime ); | |
751 | |
752 char gftp_site_cmd ( gftp_request * request, | |
753 const char *command ); | |
754 | |
58 | 755 off_t gftp_get_file_size ( gftp_request * request, |
1 | 756 const char *filename ); |
757 | |
758 void gftp_calc_kbs ( gftp_transfer * tdata, | |
759 ssize_t num_read ); | |
760 | |
102 | 761 time_t parse_time ( char *str, |
762 char **endpos ); | |
763 | |
91 | 764 int gftp_parse_ls ( gftp_request * request, |
765 const char *lsoutput, | |
1 | 766 gftp_file *fle ); |
767 | |
768 int gftp_get_all_subdirs ( gftp_transfer * transfer, | |
769 void (*update_func) | |
770 ( gftp_transfer * transfer )); | |
771 | |
772 int gftp_connect_server ( gftp_request * request, | |
122 | 773 char *service, |
774 char *proxy_hostname, | |
775 int proxy_port ); | |
1 | 776 |
122 | 777 #if !defined (HAVE_GETADDRINFO) || !defined (HAVE_GAI_STRERROR) |
1 | 778 |
779 struct hostent *r_gethostbyname ( const char *name, | |
780 struct hostent *result_buf, | |
781 int *h_errnop ); | |
782 | |
56 | 783 #endif |
784 | |
1 | 785 struct servent *r_getservbyname ( const char *name, |
786 const char *proto, | |
787 struct servent *result_buf, | |
788 int *h_errnop ); | |
122 | 789 |
1 | 790 void gftp_set_config_options ( gftp_request * request ); |
791 | |
792 void print_file_list ( GList * list ); | |
793 | |
58 | 794 ssize_t gftp_get_line ( gftp_request * request, |
795 gftp_getline_buffer ** rbuf, | |
41 | 796 char * str, |
797 size_t len, | |
58 | 798 int fd ); |
799 | |
800 ssize_t gftp_read ( gftp_request * request, | |
801 void *ptr, | |
802 size_t size, | |
803 int fd ); | |
41 | 804 |
58 | 805 ssize_t gftp_write ( gftp_request * request, |
806 const char *ptr, | |
41 | 807 size_t size, |
58 | 808 int fd ); |
809 | |
810 ssize_t gftp_writefmt ( gftp_request * request, | |
811 int fd, | |
812 const char *fmt, | |
813 ... ); | |
814 | |
815 int gftp_set_sockblocking ( gftp_request * request, | |
816 int fd, | |
817 int non_blocking ); | |
41 | 818 |
63 | 819 void gftp_swap_socks ( gftp_request * dest, |
820 gftp_request * source ); | |
821 | |
122 | 822 void gftp_calc_kbs ( gftp_transfer * tdata, |
823 ssize_t num_read ); | |
824 | |
1 | 825 #endif |
826 |