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