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