Mercurial > gftp.yaz
annotate lib/gftp.h @ 102:3b573c8ef706
2003-2-6 Brian Masney <masneyb@gftp.org>
* lib/gftp.h lib/protocols.c lib/rfc2068.c - put in new
parse_time() function that should work across all locales.
It uses strptime() internally.
* lib/misc.c - remove note from close statement
author | masneyb |
---|---|
date | Fri, 07 Feb 2003 01:24:13 +0000 |
parents | 5f9ad9facf0e |
children | 76e2b58a9440 |
rev | line source |
---|---|
1 | 1 /*****************************************************************************/ |
2 /* gftp.h - include file for the whole ftp program */ | |
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */ | |
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) */ |
100 #define GFTP_TYPE_UNIX 1 | |
101 #define GFTP_TYPE_EPLF 2 | |
102 #define GFTP_TYPE_CRAY 3 | |
103 #define GFTP_TYPE_NOVELL 4 | |
104 #define GFTP_TYPE_DOS 5 | |
105 #define GFTP_TYPE_VMS 6 | |
106 #define GFTP_TYPE_OTHER 7 | |
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 */ | |
163 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
|
164 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
|
165 startsize; /* Size to start the transfer at */ |
1 | 166 unsigned int isdir : 1, /* File type */ |
167 isexe : 1, | |
168 islink : 1, | |
169 ascii : 1, /* Transfer in ASCII mode */ | |
170 selected : 1, /* Is this file selected? */ | |
171 was_sel : 1, /* Was this file selected before */ | |
172 shown : 1, /* Is this file shown? */ | |
173 done_view : 1, /* View the file when done transfering? */ | |
174 done_edit : 1, /* Edit the file when done transfering? */ | |
175 done_rm : 1, /* Remove the file when done */ | |
176 transfer_done : 1, /* Is current file transfer done? */ | |
177 is_fd : 1; /* Is this a file descriptor? */ | |
178 char transfer_action; /* See the GFTP_TRANS_ACTION_* vars above */ | |
87 | 179 void *node; /* FIXME Pointer to the node for the gui */ |
58 | 180 int fd; |
1 | 181 }; |
182 | |
183 | |
184 typedef struct gftp_proxy_hosts_tag | |
185 { | |
186 gint32 ipv4_network_address, | |
187 ipv4_netmask; | |
188 char *domain; | |
189 } gftp_proxy_hosts; | |
190 | |
191 | |
192 typedef struct gftp_request_tag gftp_request; | |
193 | |
194 struct gftp_request_tag | |
195 { | |
196 int protonum; /* Current number of the protocol this is | |
197 set to */ | |
198 char *hostname, /* Hostname we will connect to */ | |
199 *username, /* Username for host*/ | |
200 *password, /* Password for host */ | |
201 *account, /* Account for host (FTP only) */ | |
202 *directory, /* Current working directory */ | |
203 *proxy_config, /* Proxy configuration */ | |
204 *proxy_hostname, /* Proxy hostname */ | |
205 *proxy_username, /* Proxy username */ | |
206 *proxy_password, /* Proxy password */ | |
207 *proxy_account, /* Proxy account (FTP only) */ | |
208 *url_prefix, /* URL Prefix (ex: ftp) */ | |
209 *protocol_name, /* Protocol description */ | |
210 *last_ftp_response, /* Last response from server */ | |
211 *last_dir_entry; /* Last dir entry from server */ | |
212 size_t last_dir_entry_len; /* Length of last_dir_entry */ | |
213 | |
214 unsigned int port, /* Port of remote site */ | |
215 proxy_port; /* Port of the proxy server */ | |
216 | |
58 | 217 int sockfd, /* Control connection (read) */ |
218 datafd, /* Data connection */ | |
219 cachefd; /* For the directory cache */ | |
1 | 220 int wakeup_main_thread[2]; /* FD that gets written to by the threads |
221 to wakeup the parent */ | |
222 | |
223 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
224 struct addrinfo *hostp; /* Remote host we are connected to */ | |
225 #else | |
226 struct hostent host, *hostp; /* Remote host we are connected to */ | |
227 #endif | |
228 | |
91 | 229 int data_type, /* ASCII or BINARY (FTP only) */ |
230 server_type; /* The type of server we are connected to */ | |
1 | 231 unsigned int use_proxy : 1, /* Go out of proxy server */ |
232 always_connected : 1, | |
233 need_hostport : 1, | |
234 need_userpass : 1, | |
235 use_cache : 1, /* Enable or disable the cache */ | |
236 use_threads : 1, /* Whether we need to spawn a thread | |
237 for this protocol */ | |
238 cached : 1, /* Is this directory listing cached? */ | |
41 | 239 cancel : 1, /* If a signal is received, should |
240 we cancel this operation */ | |
1 | 241 stopable : 1; |
242 | |
243 off_t gotbytes; | |
244 | |
245 void *protocol_data; | |
246 | |
247 gftp_logging_func logging_function; | |
248 void *user_data; | |
249 | |
250 void (*init) ( gftp_request * request ); | |
251 void (*destroy) ( gftp_request * request ); | |
252 int (*connect) ( gftp_request * request ); | |
253 void (*disconnect) ( gftp_request * request ); | |
58 | 254 off_t (*get_file) ( gftp_request * request, |
1 | 255 const char *filename, |
58 | 256 int fd, |
1 | 257 off_t startsize ); |
258 int (*put_file) ( gftp_request * request, | |
259 const char *filename, | |
58 | 260 int fd, |
1 | 261 off_t startsize, |
262 off_t totalsize ); | |
263 long (*transfer_file) ( gftp_request * fromreq, | |
264 const char *fromfile, | |
265 off_t fromsize, | |
266 gftp_request * toreq, | |
267 const char *tofile, | |
268 off_t tosize ); | |
58 | 269 ssize_t (*get_next_file_chunk) ( gftp_request * request, |
1 | 270 char *buf, |
271 size_t size ); | |
58 | 272 ssize_t (*put_next_file_chunk) ( gftp_request * request, |
1 | 273 char *buf, |
274 size_t size ); | |
275 int (*end_transfer) ( gftp_request * request ); | |
40 | 276 int (*abort_transfer) ( gftp_request * request ); |
1 | 277 int (*list_files) ( gftp_request * request ); |
278 int (*get_next_file) ( gftp_request * request, | |
279 gftp_file *fle, | |
58 | 280 int fd ); |
1 | 281 int (*set_data_type) ( gftp_request * request, |
282 int data_type ); | |
283 off_t (*get_file_size) ( gftp_request * request, | |
284 const char *filename ); | |
285 int (*chdir) ( gftp_request * request, | |
286 const char *directory ); | |
287 int (*rmdir) ( gftp_request * request, | |
288 const char *directory ); | |
289 int (*rmfile) ( gftp_request * request, | |
290 const char *filename ); | |
291 int (*mkdir) ( gftp_request * request, | |
292 const char *directory ); | |
293 int (*rename) ( gftp_request * request, | |
294 const char *oldname, | |
295 const char *newname ); | |
296 int (*chmod) ( gftp_request * request, | |
297 const char *filename, | |
298 int mode ); | |
299 int (*set_file_time) ( gftp_request * request, | |
300 const char *filename, | |
301 time_t datettime ); | |
302 int (*site) ( gftp_request * request, | |
303 const char *filename ); | |
304 int (*parse_url) ( gftp_request * request, | |
305 const char *url ); | |
58 | 306 void (*set_config_options) ( gftp_request * request ); |
63 | 307 void (*swap_socks) ( gftp_request * dest, |
308 gftp_request * source ); | |
1 | 309 |
310 /* Options */ | |
311 gftp_transfer_type transfer_type; /* Passive or non-passive (FTP only) */ | |
312 int network_timeout, | |
313 retries, | |
314 sleep_time, | |
315 passive_transfer; | |
316 float maxkbs; | |
317 char *sftpserv_path; | |
318 }; | |
319 | |
320 | |
321 typedef struct gftp_transfer_tag gftp_transfer; | |
322 | |
323 struct gftp_transfer_tag | |
324 { | |
325 gftp_request * fromreq, | |
326 * toreq; | |
327 | |
328 unsigned int transfer_direction : 1, | |
329 cancel : 1, | |
330 ready : 1, | |
331 started : 1, | |
332 done : 1, | |
333 show : 1, | |
334 stalled : 1, | |
335 next_file : 1, | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
336 skip_file : 1; |
1 | 337 |
338 struct timeval starttime, | |
339 lasttime; | |
340 | |
341 double kbs; | |
342 | |
343 GList * files, | |
344 * curfle, | |
345 * updfle; | |
346 | |
19 | 347 long numfiles, |
348 numdirs, | |
349 current_file_number, | |
350 current_file_retries; | |
1 | 351 |
352 off_t curtrans, /* Current transfered bytes for this file */ | |
353 curresumed, /* Resumed bytes for this file */ | |
354 trans_bytes, /* Amount of data transfered for entire | |
355 transfer */ | |
356 total_bytes, /* Grand total bytes for whole transfer */ | |
357 resumed_bytes; /* Grand total of resumed bytes for whole | |
358 transfer */ | |
359 | |
360 void * fromwdata, | |
361 * towdata; | |
362 | |
363 void *statmutex, | |
364 *structmutex; | |
365 void *node; | |
366 void *clist; | |
367 }; | |
368 | |
369 | |
370 typedef struct gftp_log_tag | |
371 { | |
372 char *msg; | |
373 gftp_logging_level type; | |
374 } gftp_log; | |
375 | |
376 | |
377 typedef struct supported_gftp_protocols_tag | |
378 { | |
379 char *name; /* Description of protocol */ | |
380 void (*init) (gftp_request * request); /* Init function */ | |
381 char *url_prefix; /* URL Prefix */ | |
382 int shown; /* Whether this protocol is shown or not to the user | |
383 in the protocol dropdown box */ | |
384 } supported_gftp_protocols; | |
385 | |
386 | |
387 typedef struct gftp_bookmarks_tag gftp_bookmarks; | |
388 | |
389 struct gftp_bookmarks_tag | |
390 { | |
391 char *path; /* Path */ | |
392 char *hostname, /* Our actual internet hostname */ | |
393 *protocol, /* Protocol we will connect through */ | |
394 *remote_dir, /* Initial directory */ | |
395 *local_dir, /* Init local directory */ | |
396 *user, /* Username to log in as */ | |
397 *pass, /* Our password */ | |
398 *acct; /* Account */ | |
399 | |
400 unsigned int port, /* The port we will connect to */ | |
401 isfolder : 1, /* If this is set, then the children field can | |
402 be non-NULL */ | |
403 save_password : 1; /* Save this password */ | |
404 gftp_bookmarks *children, /* The children of this node. */ | |
405 *prev, /* The parent of this node */ | |
406 *next; /* The next sibling of this node */ | |
407 gpointer cnode; | |
408 | |
409 /* Site options */ | |
410 char *sftpserv_path; /* Path to the sftp server */ | |
411 }; | |
412 | |
413 | |
414 typedef struct gftp_file_extensions_tag | |
415 { | |
416 char *ext, /* The file extension to register */ | |
417 *filename, /* The xpm file to display */ | |
418 *view_program, /* The program used to view this file */ | |
419 *ascii_binary; /* Is this a ASCII transfer or a BINARY transfer */ | |
420 int stlen; /* How long is the file extension. */ | |
421 } gftp_file_extensions; | |
422 | |
423 | |
424 typedef struct gftp_color_tag | |
425 { | |
426 gushort red, | |
427 green, | |
428 blue; | |
429 } gftp_color; | |
430 | |
431 | |
432 typedef struct gftp_config_vars_tag | |
433 { | |
434 char *key, /* variable name */ | |
435 *description; /* How this field will show up in the dialog */ | |
436 gpointer var; /* Pointer to our variable */ | |
37 | 437 int type; /* See defines below */ |
1 | 438 char *comment; /* Comment to write out to the config file */ |
439 gpointer widget; | |
37 | 440 int ports_shown; /* What ports of gFTP is this option shown in */ |
1 | 441 } gftp_config_vars; |
442 | |
443 #define CONFIG_INTTEXT 1 | |
444 #define CONFIG_FLOATTEXT 2 | |
445 #define CONFIG_CHECKBOX 3 | |
446 #define CONFIG_LABEL 4 | |
447 #define CONFIG_NOTEBOOK 5 | |
448 #define CONFIG_HIDEINT 6 | |
449 #define CONFIG_TABLE 7 | |
450 #define CONFIG_CHARTEXT 8 | |
451 #define CONFIG_COMBO 9 | |
452 #define CONFIG_TEXT 10 | |
453 #define CONFIG_COLOR 11 | |
454 #define CONFIG_UINTTEXT 12 | |
455 #define CONFIG_CHARPASS 13 | |
456 | |
37 | 457 #define GFTP_PORT_GTK (1 << 1) |
458 #define GFTP_PORT_TEXT (1 << 2) | |
459 #define GFTP_PORT_ALL (GFTP_PORT_GTK | GFTP_PORT_TEXT) | |
460 | |
1 | 461 typedef struct gftp_proxy_type_tag |
462 { | |
463 char *key, | |
464 *description; | |
465 } gftp_proxy_type; | |
466 | |
467 #define GFTP_CUSTOM_PROXY_NUM 8 | |
468 | |
58 | 469 typedef struct gftp_getline_buffer_tag |
470 { | |
471 char *buffer, | |
472 *curpos; | |
473 size_t max_bufsize, | |
474 cur_bufsize; | |
475 } gftp_getline_buffer; | |
476 | |
1 | 477 /* Global config options */ |
478 extern supported_gftp_protocols gftp_protocols[]; | |
479 extern char version[], *emailaddr, *edit_program, *view_program, | |
480 *firewall_host, *firewall_username, *firewall_password, | |
481 *firewall_account, *proxy_config, *http_proxy_host, | |
41 | 482 *http_proxy_username, *http_proxy_password, |
1 | 483 *startup_directory, *ssh_prog_name, *ssh_extra_params, |
101 | 484 **ssh_extra_params_list, *default_protocol, *ssh2_sftp_path; |
1 | 485 extern int num_ssh_extra_params; |
486 extern FILE * logfd; | |
487 extern double maxkbs; | |
488 extern GList * proxy_hosts, * registered_exts, * viewedit_processes, | |
489 * file_transfers, * file_transfer_logs; | |
490 extern gftp_bookmarks * bookmarks; | |
491 extern int do_one_transfer_at_a_time, start_file_transfers, | |
492 transfer_in_progress, passive_transfer, sort_dirs_first, | |
74 | 493 show_hidden_files, refresh_files, listbox_local_width, |
494 listbox_remote_width, listbox_file_height, transfer_height, | |
495 log_height, retries, sleep_time, network_timeout, use_http11, | |
496 listbox_dblclick_action, file_trans_column, local_columns[6], | |
497 remote_columns[6], resolve_symlinks, firewall_port, http_proxy_port, | |
84 | 498 overwrite_by_default, append_file_transfers, |
74 | 499 ssh_need_userpass, ssh_use_askpass, sshv2_use_sftp_subsys, |
500 local_sortcol, local_sortasds, remote_sortcol, remote_sortasds; | |
1 | 501 extern guint max_log_window_size; |
502 extern GHashTable * bookmarks_htable, * config_htable; | |
503 extern GList * localhistory, * remotehistory, * host_history, * port_history, | |
504 * user_history; | |
505 extern unsigned int host_len, port_len, user_len, localhistlen, remotehistlen; | |
506 extern volatile sig_atomic_t viewedit_process_done; | |
507 extern gftp_config_vars config_file_vars[]; | |
508 extern gftp_proxy_type proxy_type[]; | |
509 extern gftp_color send_color, recv_color, error_color, misc_color; | |
91 | 510 extern struct lconv *my_localeinfo; |
1 | 511 |
512 /* cache.c */ | |
58 | 513 int gftp_new_cache_entry ( gftp_request * request ); |
1 | 514 |
58 | 515 int gftp_find_cache_entry ( gftp_request * request ); |
1 | 516 |
517 void gftp_clear_cache_files ( void ); | |
518 | |
47 | 519 void gftp_delete_cache_entry ( gftp_request * request, |
520 int ignore_directory ); | |
1 | 521 |
522 /* config_file.c */ | |
523 void gftp_read_config_file ( char **argv, | |
524 int get_xpms ); | |
525 | |
526 void gftp_read_bookmarks ( void ); | |
527 | |
528 void add_to_bookmark ( gftp_bookmarks *newentry ); | |
529 | |
530 void gftp_write_config_file ( void ); | |
531 | |
26 | 532 void gftp_write_bookmarks_file ( void ); |
533 | |
1 | 534 GHashTable * build_bookmarks_hash_table ( gftp_bookmarks * entry ); |
535 | |
536 void print_bookmarks ( gftp_bookmarks * bookmarks ); | |
537 | |
538 /* misc.c */ | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
539 char *insert_commas ( off_t number, |
1 | 540 char *dest_str, |
541 size_t dest_len ); | |
542 | |
543 char *alltrim ( char *str ); | |
544 | |
545 char *expand_path ( const char *src ); | |
546 | |
547 void remove_double_slashes ( char *string ); | |
548 | |
549 void make_nonnull ( char **str ); | |
550 | |
551 int copyfile ( char *source, | |
552 char *dest ); | |
553 | |
554 char *get_xpm_path ( char *filename, | |
555 int quit_on_err ); | |
556 | |
557 int gftp_match_filespec ( char *filename, | |
558 char *filespec ); | |
559 | |
560 int gftp_parse_command_line ( int *argc, | |
561 char ***argv ); | |
562 | |
563 void gftp_usage ( void ); | |
564 | |
565 gint string_hash_compare ( gconstpointer path1, | |
566 gconstpointer path2 ); | |
567 | |
568 guint string_hash_function ( gconstpointer key ); | |
569 | |
570 void free_file_list ( GList * filelist ); | |
571 | |
572 void free_fdata ( gftp_file * fle ); | |
573 | |
574 gftp_file * copy_fdata ( gftp_file * fle ); | |
575 | |
576 int compare_request ( gftp_request * request1, | |
577 gftp_request * request2, | |
578 int compare_dirs ); | |
579 | |
580 void free_tdata ( gftp_transfer * tdata ); | |
581 | |
582 gftp_request * copy_request ( gftp_request * req ); | |
583 | |
584 int ptym_open ( char *pts_name ); | |
585 | |
586 int ptys_open ( int fdm, | |
587 char *pts_name ); | |
588 | |
589 int tty_raw ( int fd ); | |
590 | |
591 char **make_ssh_exec_args ( gftp_request * request, | |
592 char *execname, | |
593 int use_sftp_subsys, | |
594 char *portstring ); | |
595 | |
596 char * ssh_start_login_sequence ( gftp_request * request, | |
597 int fd ); | |
598 | |
599 #ifdef G_HAVE_GINT64 | |
600 gint64 hton64 ( gint64 val ); | |
601 #endif | |
602 | |
16 | 603 GList * gftp_sort_filelist ( GList * filelist, |
604 int column, | |
605 int asds ); | |
606 | |
1 | 607 /* protocols.c */ |
608 #define GFTP_GET_HOSTNAME(request) (request->hostname) | |
609 #define GFTP_GET_USERNAME(request) (request->username) | |
610 #define GFTP_GET_PASSWORD(request) (request->password) | |
611 #define GFTP_GET_ACCOUNT(request) (request->account) | |
612 #define GFTP_GET_DIRECTORY(request) (request->directory) | |
613 #define GFTP_GET_PORT(request) (request->port) | |
614 #define GFTP_GET_PROXY_CONFIG(request) (request->proxy_config) | |
615 #define GFTP_GET_PROXY_HOSTNAME(request) (request->proxy_hostname) | |
616 #define GFTP_GET_PROXY_USERNAME(request) (request->proxy_username) | |
617 #define GFTP_GET_PROXY_PASSWORD(request) (request->proxy_password) | |
618 #define GFTP_GET_PROXY_ACCOUNT(request) (request->proxy_account) | |
619 #define GFTP_GET_PROXY_PORT(request) (request->proxy_port) | |
620 #define GFTP_GET_URL_PREFIX(request) (request->url_prefix) | |
621 #define GFTP_GET_PROTOCOL_NAME(request) (request->protocol_name) | |
622 #define GFTP_GET_LAST_RESPONSE(request) (request->last_ftp_response) | |
623 #define GFTP_GET_LAST_DIRENT(request) (request->last_dir_entry) | |
624 #define GFTP_GET_LAST_DIRENT_LEN(request) (request->last_dir_entry_len) | |
625 #define GFTP_GET_CONTROL_FD(request) (request->sockfd) | |
626 #define GFTP_GET_DATA_FD(request) (request->datafd) | |
627 #define GFTP_GET_DATA_TYPE(request) (request->data_type) | |
628 #define GFTP_GET_TRANSFER_TYPE(request) (request->transfer_type) | |
629 #define GFTP_SET_TRANSFER_TYPE(request,val) (request->transfer_type = (val)) | |
630 #define GFTP_GET_LOGGING(request) (request->logging) | |
631 #define GFTP_SET_LOGGING(request, val) (request->logging = (val)) | |
632 #define GFTP_UNSAFE_SYMLINKS(request) (request->unsafe_symlinks) | |
633 #define GFTP_FTP_NUM 0 | |
634 #define GFTP_HTTP_NUM 1 | |
635 #define GFTP_LOCAL_NUM 2 | |
636 #define GFTP_SSHV2_NUM 3 | |
637 #define GFTP_BOOKMARK_NUM 4 | |
638 #define GFTP_TYPE_BINARY 1 | |
639 #define GFTP_TYPE_ASCII 2 | |
640 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \ | |
58 | 641 ((request)->sockfd > 0 || \ |
642 (request)->cached || \ | |
643 (request)->always_connected)) | |
1 | 644 |
645 | |
646 void rfc959_init ( gftp_request * request ); | |
647 | |
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 | |
654 void local_init ( gftp_request * request ); | |
655 | |
656 void sshv2_init ( gftp_request * request ); | |
657 | |
658 void bookmark_init ( gftp_request * request ); | |
659 | |
660 gftp_request *gftp_request_new ( void ); | |
661 | |
67 | 662 void gftp_request_destroy ( gftp_request * request, |
663 int free_request ); | |
1 | 664 |
665 void gftp_file_destroy ( gftp_file *file ); | |
666 | |
667 int gftp_connect ( gftp_request * request ); | |
668 | |
669 void gftp_disconnect ( gftp_request * request ); | |
670 | |
58 | 671 off_t gftp_get_file ( gftp_request * request, |
1 | 672 const char *filename, |
58 | 673 int fd, |
1 | 674 size_t startsize ); |
675 | |
676 int gftp_put_file ( gftp_request * request, | |
677 const char *filename, | |
58 | 678 int fd, |
1 | 679 size_t startsize, |
680 size_t totalsize ); | |
681 | |
682 long gftp_transfer_file ( gftp_request *fromreq, | |
683 const char *fromfile, | |
58 | 684 int fromfd, |
1 | 685 size_t fromsize, |
686 gftp_request *toreq, | |
687 const char *tofile, | |
58 | 688 int tofd, |
1 | 689 size_t tosize ); |
690 | |
58 | 691 ssize_t gftp_get_next_file_chunk ( gftp_request * request, |
1 | 692 char *buf, |
693 size_t size ); | |
694 | |
58 | 695 ssize_t gftp_put_next_file_chunk ( gftp_request * request, |
1 | 696 char *buf, |
697 size_t size ); | |
698 | |
699 int gftp_list_files ( gftp_request * request ); | |
700 | |
87 | 701 int gftp_parse_bookmark ( gftp_request * request, |
702 const char * bookmark ); | |
703 | |
1 | 704 int gftp_parse_url ( gftp_request * request, |
705 const char *url ); | |
706 | |
707 int gftp_get_next_file ( gftp_request * request, | |
708 char *filespec, | |
709 gftp_file *fle ); | |
710 | |
711 int gftp_end_transfer ( gftp_request * request ); | |
712 | |
40 | 713 int gftp_abort_transfer ( gftp_request * request ); |
714 | |
1 | 715 int gftp_read_response ( gftp_request * request ); |
716 | |
717 int gftp_set_data_type ( gftp_request * request, | |
718 int data_type ); | |
719 | |
720 void gftp_set_hostname ( gftp_request * request, | |
721 const char *hostname ); | |
722 | |
723 void gftp_set_username ( gftp_request * request, | |
724 const char *username ); | |
725 | |
726 void gftp_set_password ( gftp_request * request, | |
727 const char *password ); | |
728 | |
729 void gftp_set_account ( gftp_request * request, | |
730 const char *account ); | |
731 | |
732 int gftp_set_directory ( gftp_request * request, | |
733 const char *directory ); | |
734 | |
735 void gftp_set_port ( gftp_request * request, | |
736 unsigned int port ); | |
737 | |
738 void gftp_set_proxy_hostname ( gftp_request * request, | |
739 const char *hostname ); | |
740 | |
741 void gftp_set_proxy_username ( gftp_request * request, | |
742 const char *username ); | |
743 | |
744 void gftp_set_proxy_password ( gftp_request * request, | |
745 const char *password ); | |
746 | |
747 void gftp_set_proxy_account ( gftp_request * request, | |
748 const char *account ); | |
749 | |
750 void gftp_set_proxy_port ( gftp_request * request, | |
751 unsigned int port ); | |
752 | |
753 int gftp_remove_directory ( gftp_request * request, | |
754 const char *directory ); | |
755 | |
756 int gftp_remove_file ( gftp_request * request, | |
757 const char *file ); | |
758 | |
759 int gftp_make_directory ( gftp_request * request, | |
760 const char *directory ); | |
761 | |
762 int gftp_rename_file ( gftp_request * request, | |
763 const char *oldname, | |
764 const char *newname ); | |
765 | |
766 int gftp_chmod ( gftp_request * request, | |
767 const char *file, | |
768 int mode ); | |
769 | |
770 int gftp_set_file_time ( gftp_request * request, | |
771 const char *file, | |
772 time_t datetime ); | |
773 | |
774 char gftp_site_cmd ( gftp_request * request, | |
775 const char *command ); | |
776 | |
777 void gftp_set_proxy_config ( gftp_request * request, | |
778 const char *proxy_config ); | |
779 | |
58 | 780 off_t gftp_get_file_size ( gftp_request * request, |
1 | 781 const char *filename ); |
782 | |
783 int gftp_need_proxy ( gftp_request * request, | |
784 char *service ); | |
785 | |
786 char *gftp_convert_ascii ( char *buf, | |
787 ssize_t *len, | |
788 int direction ); | |
789 | |
790 void gftp_calc_kbs ( gftp_transfer * tdata, | |
791 ssize_t num_read ); | |
792 | |
102 | 793 time_t parse_time ( char *str, |
794 char **endpos ); | |
795 | |
91 | 796 int gftp_parse_ls ( gftp_request * request, |
797 const char *lsoutput, | |
1 | 798 gftp_file *fle ); |
799 | |
800 int gftp_get_all_subdirs ( gftp_transfer * transfer, | |
801 void (*update_func) | |
802 ( gftp_transfer * transfer )); | |
803 | |
804 int gftp_get_file_transfer_mode ( char *filename, | |
805 int def ); | |
806 | |
807 int gftp_connect_server ( gftp_request * request, | |
808 char *service ); | |
809 | |
810 void gftp_set_sftpserv_path ( gftp_request * request, | |
811 char *path ); | |
812 | |
813 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
814 | |
815 int get_port ( struct addrinfo *addr ); | |
816 | |
817 #else | |
818 | |
819 struct hostent *r_gethostbyname ( const char *name, | |
820 struct hostent *result_buf, | |
821 int *h_errnop ); | |
822 | |
56 | 823 #endif |
824 | |
1 | 825 struct servent *r_getservbyname ( const char *name, |
826 const char *proto, | |
827 struct servent *result_buf, | |
828 int *h_errnop ); | |
829 void gftp_set_config_options ( gftp_request * request ); | |
830 | |
831 void print_file_list ( GList * list ); | |
832 | |
58 | 833 ssize_t gftp_get_line ( gftp_request * request, |
834 gftp_getline_buffer ** rbuf, | |
41 | 835 char * str, |
836 size_t len, | |
58 | 837 int fd ); |
838 | |
839 ssize_t gftp_read ( gftp_request * request, | |
840 void *ptr, | |
841 size_t size, | |
842 int fd ); | |
41 | 843 |
58 | 844 ssize_t gftp_write ( gftp_request * request, |
845 const char *ptr, | |
41 | 846 size_t size, |
58 | 847 int fd ); |
848 | |
849 ssize_t gftp_writefmt ( gftp_request * request, | |
850 int fd, | |
851 const char *fmt, | |
852 ... ); | |
853 | |
854 int gftp_set_sockblocking ( gftp_request * request, | |
855 int fd, | |
856 int non_blocking ); | |
41 | 857 |
63 | 858 void gftp_swap_socks ( gftp_request * dest, |
859 gftp_request * source ); | |
860 | |
1 | 861 #endif |
862 |