Mercurial > gftp.yaz
annotate lib/gftp.h @ 91:8c37d73d3f1f
2003-1-21 Brian Masney <masneyb@gftp.org>
* lib/gftp.h - added server type defines. Added server_type field to
gftp_request
* lib/local.c - use S_ISDIR and S_ISLINK macros
* lib/protocols.c - (gftp_parse_ls*) - use hints from server_type for
parsing directory listing
* lib/rfc959.c - added function rfc959_syst. Call this on startup
* lib/protocols.c lib/rfc959.c lib/sshv2.c - pass request structure
to gftp_parse_ls
* lib/sshv2.c - set server_type to be GFTP_TYPE_UNIX
author | masneyb |
---|---|
date | Tue, 21 Jan 2003 23:46:03 +0000 |
parents | 6df043359b41 |
children | 5f9ad9facf0e |
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, |
484 **ssh_extra_params_list, *default_protocol, *ssh1_sftp_path, | |
485 *ssh2_sftp_path; | |
486 extern int num_ssh_extra_params; | |
487 extern FILE * logfd; | |
488 extern double maxkbs; | |
489 extern GList * proxy_hosts, * registered_exts, * viewedit_processes, | |
490 * file_transfers, * file_transfer_logs; | |
491 extern gftp_bookmarks * bookmarks; | |
492 extern int do_one_transfer_at_a_time, start_file_transfers, | |
493 transfer_in_progress, passive_transfer, sort_dirs_first, | |
74 | 494 show_hidden_files, refresh_files, listbox_local_width, |
495 listbox_remote_width, listbox_file_height, transfer_height, | |
496 log_height, retries, sleep_time, network_timeout, use_http11, | |
497 listbox_dblclick_action, file_trans_column, local_columns[6], | |
498 remote_columns[6], resolve_symlinks, firewall_port, http_proxy_port, | |
84 | 499 overwrite_by_default, append_file_transfers, |
74 | 500 ssh_need_userpass, ssh_use_askpass, sshv2_use_sftp_subsys, |
501 local_sortcol, local_sortasds, remote_sortcol, remote_sortasds; | |
1 | 502 extern guint max_log_window_size; |
503 extern GHashTable * bookmarks_htable, * config_htable; | |
504 extern GList * localhistory, * remotehistory, * host_history, * port_history, | |
505 * user_history; | |
506 extern unsigned int host_len, port_len, user_len, localhistlen, remotehistlen; | |
507 extern volatile sig_atomic_t viewedit_process_done; | |
508 extern gftp_config_vars config_file_vars[]; | |
509 extern gftp_proxy_type proxy_type[]; | |
510 extern gftp_color send_color, recv_color, error_color, misc_color; | |
91 | 511 extern struct lconv *my_localeinfo; |
1 | 512 |
513 /* cache.c */ | |
58 | 514 int gftp_new_cache_entry ( gftp_request * request ); |
1 | 515 |
58 | 516 int gftp_find_cache_entry ( gftp_request * request ); |
1 | 517 |
518 void gftp_clear_cache_files ( void ); | |
519 | |
47 | 520 void gftp_delete_cache_entry ( gftp_request * request, |
521 int ignore_directory ); | |
1 | 522 |
523 /* config_file.c */ | |
524 void gftp_read_config_file ( char **argv, | |
525 int get_xpms ); | |
526 | |
527 void gftp_read_bookmarks ( void ); | |
528 | |
529 void add_to_bookmark ( gftp_bookmarks *newentry ); | |
530 | |
531 void gftp_write_config_file ( void ); | |
532 | |
26 | 533 void gftp_write_bookmarks_file ( void ); |
534 | |
1 | 535 GHashTable * build_bookmarks_hash_table ( gftp_bookmarks * entry ); |
536 | |
537 void print_bookmarks ( gftp_bookmarks * bookmarks ); | |
538 | |
539 /* misc.c */ | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
540 char *insert_commas ( off_t number, |
1 | 541 char *dest_str, |
542 size_t dest_len ); | |
543 | |
544 char *alltrim ( char *str ); | |
545 | |
546 char *expand_path ( const char *src ); | |
547 | |
548 void remove_double_slashes ( char *string ); | |
549 | |
550 void make_nonnull ( char **str ); | |
551 | |
552 int copyfile ( char *source, | |
553 char *dest ); | |
554 | |
555 char *get_xpm_path ( char *filename, | |
556 int quit_on_err ); | |
557 | |
558 int gftp_match_filespec ( char *filename, | |
559 char *filespec ); | |
560 | |
561 int gftp_parse_command_line ( int *argc, | |
562 char ***argv ); | |
563 | |
564 void gftp_usage ( void ); | |
565 | |
566 gint string_hash_compare ( gconstpointer path1, | |
567 gconstpointer path2 ); | |
568 | |
569 guint string_hash_function ( gconstpointer key ); | |
570 | |
571 void free_file_list ( GList * filelist ); | |
572 | |
573 void free_fdata ( gftp_file * fle ); | |
574 | |
575 gftp_file * copy_fdata ( gftp_file * fle ); | |
576 | |
577 int compare_request ( gftp_request * request1, | |
578 gftp_request * request2, | |
579 int compare_dirs ); | |
580 | |
581 void free_tdata ( gftp_transfer * tdata ); | |
582 | |
583 gftp_request * copy_request ( gftp_request * req ); | |
584 | |
585 int ptym_open ( char *pts_name ); | |
586 | |
587 int ptys_open ( int fdm, | |
588 char *pts_name ); | |
589 | |
590 int tty_raw ( int fd ); | |
591 | |
592 char **make_ssh_exec_args ( gftp_request * request, | |
593 char *execname, | |
594 int use_sftp_subsys, | |
595 char *portstring ); | |
596 | |
597 char * ssh_start_login_sequence ( gftp_request * request, | |
598 int fd ); | |
599 | |
600 #ifdef G_HAVE_GINT64 | |
601 gint64 hton64 ( gint64 val ); | |
602 #endif | |
603 | |
16 | 604 GList * gftp_sort_filelist ( GList * filelist, |
605 int column, | |
606 int asds ); | |
607 | |
1 | 608 /* protocols.c */ |
609 #define GFTP_GET_HOSTNAME(request) (request->hostname) | |
610 #define GFTP_GET_USERNAME(request) (request->username) | |
611 #define GFTP_GET_PASSWORD(request) (request->password) | |
612 #define GFTP_GET_ACCOUNT(request) (request->account) | |
613 #define GFTP_GET_DIRECTORY(request) (request->directory) | |
614 #define GFTP_GET_PORT(request) (request->port) | |
615 #define GFTP_GET_PROXY_CONFIG(request) (request->proxy_config) | |
616 #define GFTP_GET_PROXY_HOSTNAME(request) (request->proxy_hostname) | |
617 #define GFTP_GET_PROXY_USERNAME(request) (request->proxy_username) | |
618 #define GFTP_GET_PROXY_PASSWORD(request) (request->proxy_password) | |
619 #define GFTP_GET_PROXY_ACCOUNT(request) (request->proxy_account) | |
620 #define GFTP_GET_PROXY_PORT(request) (request->proxy_port) | |
621 #define GFTP_GET_URL_PREFIX(request) (request->url_prefix) | |
622 #define GFTP_GET_PROTOCOL_NAME(request) (request->protocol_name) | |
623 #define GFTP_GET_LAST_RESPONSE(request) (request->last_ftp_response) | |
624 #define GFTP_GET_LAST_DIRENT(request) (request->last_dir_entry) | |
625 #define GFTP_GET_LAST_DIRENT_LEN(request) (request->last_dir_entry_len) | |
626 #define GFTP_GET_CONTROL_FD(request) (request->sockfd) | |
627 #define GFTP_GET_DATA_FD(request) (request->datafd) | |
628 #define GFTP_GET_DATA_TYPE(request) (request->data_type) | |
629 #define GFTP_GET_TRANSFER_TYPE(request) (request->transfer_type) | |
630 #define GFTP_SET_TRANSFER_TYPE(request,val) (request->transfer_type = (val)) | |
631 #define GFTP_GET_LOGGING(request) (request->logging) | |
632 #define GFTP_SET_LOGGING(request, val) (request->logging = (val)) | |
633 #define GFTP_UNSAFE_SYMLINKS(request) (request->unsafe_symlinks) | |
634 #define GFTP_FTP_NUM 0 | |
635 #define GFTP_HTTP_NUM 1 | |
636 #define GFTP_LOCAL_NUM 2 | |
637 #define GFTP_SSHV2_NUM 3 | |
638 #define GFTP_BOOKMARK_NUM 4 | |
639 #define GFTP_TYPE_BINARY 1 | |
640 #define GFTP_TYPE_ASCII 2 | |
641 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \ | |
58 | 642 ((request)->sockfd > 0 || \ |
643 (request)->cached || \ | |
644 (request)->always_connected)) | |
1 | 645 |
646 | |
647 void rfc959_init ( gftp_request * request ); | |
648 | |
649 int rfc959_get_next_file ( gftp_request * request, | |
650 gftp_file *fle, | |
58 | 651 int fd ); |
1 | 652 |
653 void rfc2068_init ( gftp_request * request ); | |
654 | |
655 void local_init ( gftp_request * request ); | |
656 | |
657 void sshv2_init ( gftp_request * request ); | |
658 | |
659 void bookmark_init ( gftp_request * request ); | |
660 | |
661 gftp_request *gftp_request_new ( void ); | |
662 | |
67 | 663 void gftp_request_destroy ( gftp_request * request, |
664 int free_request ); | |
1 | 665 |
666 void gftp_file_destroy ( gftp_file *file ); | |
667 | |
668 int gftp_connect ( gftp_request * request ); | |
669 | |
670 void gftp_disconnect ( gftp_request * request ); | |
671 | |
58 | 672 off_t gftp_get_file ( gftp_request * request, |
1 | 673 const char *filename, |
58 | 674 int fd, |
1 | 675 size_t startsize ); |
676 | |
677 int gftp_put_file ( gftp_request * request, | |
678 const char *filename, | |
58 | 679 int fd, |
1 | 680 size_t startsize, |
681 size_t totalsize ); | |
682 | |
683 long gftp_transfer_file ( gftp_request *fromreq, | |
684 const char *fromfile, | |
58 | 685 int fromfd, |
1 | 686 size_t fromsize, |
687 gftp_request *toreq, | |
688 const char *tofile, | |
58 | 689 int tofd, |
1 | 690 size_t tosize ); |
691 | |
58 | 692 ssize_t gftp_get_next_file_chunk ( gftp_request * request, |
1 | 693 char *buf, |
694 size_t size ); | |
695 | |
58 | 696 ssize_t gftp_put_next_file_chunk ( gftp_request * request, |
1 | 697 char *buf, |
698 size_t size ); | |
699 | |
700 int gftp_list_files ( gftp_request * request ); | |
701 | |
87 | 702 int gftp_parse_bookmark ( gftp_request * request, |
703 const char * bookmark ); | |
704 | |
1 | 705 int gftp_parse_url ( gftp_request * request, |
706 const char *url ); | |
707 | |
708 int gftp_get_next_file ( gftp_request * request, | |
709 char *filespec, | |
710 gftp_file *fle ); | |
711 | |
712 int gftp_end_transfer ( gftp_request * request ); | |
713 | |
40 | 714 int gftp_abort_transfer ( gftp_request * request ); |
715 | |
1 | 716 int gftp_read_response ( gftp_request * request ); |
717 | |
718 int gftp_set_data_type ( gftp_request * request, | |
719 int data_type ); | |
720 | |
721 void gftp_set_hostname ( gftp_request * request, | |
722 const char *hostname ); | |
723 | |
724 void gftp_set_username ( gftp_request * request, | |
725 const char *username ); | |
726 | |
727 void gftp_set_password ( gftp_request * request, | |
728 const char *password ); | |
729 | |
730 void gftp_set_account ( gftp_request * request, | |
731 const char *account ); | |
732 | |
733 int gftp_set_directory ( gftp_request * request, | |
734 const char *directory ); | |
735 | |
736 void gftp_set_port ( gftp_request * request, | |
737 unsigned int port ); | |
738 | |
739 void gftp_set_proxy_hostname ( gftp_request * request, | |
740 const char *hostname ); | |
741 | |
742 void gftp_set_proxy_username ( gftp_request * request, | |
743 const char *username ); | |
744 | |
745 void gftp_set_proxy_password ( gftp_request * request, | |
746 const char *password ); | |
747 | |
748 void gftp_set_proxy_account ( gftp_request * request, | |
749 const char *account ); | |
750 | |
751 void gftp_set_proxy_port ( gftp_request * request, | |
752 unsigned int port ); | |
753 | |
754 int gftp_remove_directory ( gftp_request * request, | |
755 const char *directory ); | |
756 | |
757 int gftp_remove_file ( gftp_request * request, | |
758 const char *file ); | |
759 | |
760 int gftp_make_directory ( gftp_request * request, | |
761 const char *directory ); | |
762 | |
763 int gftp_rename_file ( gftp_request * request, | |
764 const char *oldname, | |
765 const char *newname ); | |
766 | |
767 int gftp_chmod ( gftp_request * request, | |
768 const char *file, | |
769 int mode ); | |
770 | |
771 int gftp_set_file_time ( gftp_request * request, | |
772 const char *file, | |
773 time_t datetime ); | |
774 | |
775 char gftp_site_cmd ( gftp_request * request, | |
776 const char *command ); | |
777 | |
778 void gftp_set_proxy_config ( gftp_request * request, | |
779 const char *proxy_config ); | |
780 | |
58 | 781 off_t gftp_get_file_size ( gftp_request * request, |
1 | 782 const char *filename ); |
783 | |
784 int gftp_need_proxy ( gftp_request * request, | |
785 char *service ); | |
786 | |
787 char *gftp_convert_ascii ( char *buf, | |
788 ssize_t *len, | |
789 int direction ); | |
790 | |
791 void gftp_calc_kbs ( gftp_transfer * tdata, | |
792 ssize_t num_read ); | |
793 | |
91 | 794 int gftp_parse_ls ( gftp_request * request, |
795 const char *lsoutput, | |
1 | 796 gftp_file *fle ); |
797 | |
798 int gftp_get_all_subdirs ( gftp_transfer * transfer, | |
799 void (*update_func) | |
800 ( gftp_transfer * transfer )); | |
801 | |
802 int gftp_get_file_transfer_mode ( char *filename, | |
803 int def ); | |
804 | |
805 int gftp_connect_server ( gftp_request * request, | |
806 char *service ); | |
807 | |
808 void gftp_set_sftpserv_path ( gftp_request * request, | |
809 char *path ); | |
810 | |
811 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) | |
812 | |
813 int get_port ( struct addrinfo *addr ); | |
814 | |
815 #else | |
816 | |
817 struct hostent *r_gethostbyname ( const char *name, | |
818 struct hostent *result_buf, | |
819 int *h_errnop ); | |
820 | |
56 | 821 #endif |
822 | |
1 | 823 struct servent *r_getservbyname ( const char *name, |
824 const char *proto, | |
825 struct servent *result_buf, | |
826 int *h_errnop ); | |
827 void gftp_set_config_options ( gftp_request * request ); | |
828 | |
829 void print_file_list ( GList * list ); | |
830 | |
58 | 831 ssize_t gftp_get_line ( gftp_request * request, |
832 gftp_getline_buffer ** rbuf, | |
41 | 833 char * str, |
834 size_t len, | |
58 | 835 int fd ); |
836 | |
837 ssize_t gftp_read ( gftp_request * request, | |
838 void *ptr, | |
839 size_t size, | |
840 int fd ); | |
41 | 841 |
58 | 842 ssize_t gftp_write ( gftp_request * request, |
843 const char *ptr, | |
41 | 844 size_t size, |
58 | 845 int fd ); |
846 | |
847 ssize_t gftp_writefmt ( gftp_request * request, | |
848 int fd, | |
849 const char *fmt, | |
850 ... ); | |
851 | |
852 int gftp_set_sockblocking ( gftp_request * request, | |
853 int fd, | |
854 int non_blocking ); | |
41 | 855 |
63 | 856 void gftp_swap_socks ( gftp_request * dest, |
857 gftp_request * source ); | |
858 | |
1 | 859 #endif |
860 |