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