comparison 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
comparison
equal deleted inserted replaced
57:72f6ca02c83a 58:c01d91c10f6c
163 done_rm : 1, /* Remove the file when done */ 163 done_rm : 1, /* Remove the file when done */
164 transfer_done : 1, /* Is current file transfer done? */ 164 transfer_done : 1, /* Is current file transfer done? */
165 is_fd : 1; /* Is this a file descriptor? */ 165 is_fd : 1; /* Is this a file descriptor? */
166 char transfer_action; /* See the GFTP_TRANS_ACTION_* vars above */ 166 char transfer_action; /* See the GFTP_TRANS_ACTION_* vars above */
167 void *node; /* Pointer to the node for the gui */ 167 void *node; /* Pointer to the node for the gui */
168 FILE * fd; 168 int fd;
169 }; 169 };
170 170
171 171
172 typedef struct gftp_proxy_hosts_tag 172 typedef struct gftp_proxy_hosts_tag
173 { 173 {
200 size_t last_dir_entry_len; /* Length of last_dir_entry */ 200 size_t last_dir_entry_len; /* Length of last_dir_entry */
201 201
202 unsigned int port, /* Port of remote site */ 202 unsigned int port, /* Port of remote site */
203 proxy_port; /* Port of the proxy server */ 203 proxy_port; /* Port of the proxy server */
204 204
205 FILE *sockfd, /* Control connection (read) */ 205 int sockfd, /* Control connection (read) */
206 *sockfd_write, /* Control connection (write) */ 206 datafd, /* Data connection */
207 *datafd, /* Data connection */ 207 cachefd; /* For the directory cache */
208 *cachefd; /* For the directory cache */
209 int wakeup_main_thread[2]; /* FD that gets written to by the threads 208 int wakeup_main_thread[2]; /* FD that gets written to by the threads
210 to wakeup the parent */ 209 to wakeup the parent */
211 210
212 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) 211 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR)
213 struct addrinfo *hostp; /* Remote host we are connected to */ 212 struct addrinfo *hostp; /* Remote host we are connected to */
237 236
238 void (*init) ( gftp_request * request ); 237 void (*init) ( gftp_request * request );
239 void (*destroy) ( gftp_request * request ); 238 void (*destroy) ( gftp_request * request );
240 int (*connect) ( gftp_request * request ); 239 int (*connect) ( gftp_request * request );
241 void (*disconnect) ( gftp_request * request ); 240 void (*disconnect) ( gftp_request * request );
242 long (*get_file) ( gftp_request * request, 241 off_t (*get_file) ( gftp_request * request,
243 const char *filename, 242 const char *filename,
244 FILE * fd, 243 int fd,
245 off_t startsize ); 244 off_t startsize );
246 int (*put_file) ( gftp_request * request, 245 int (*put_file) ( gftp_request * request,
247 const char *filename, 246 const char *filename,
248 FILE * fd, 247 int fd,
249 off_t startsize, 248 off_t startsize,
250 off_t totalsize ); 249 off_t totalsize );
251 long (*transfer_file) ( gftp_request * fromreq, 250 long (*transfer_file) ( gftp_request * fromreq,
252 const char *fromfile, 251 const char *fromfile,
253 off_t fromsize, 252 off_t fromsize,
254 gftp_request * toreq, 253 gftp_request * toreq,
255 const char *tofile, 254 const char *tofile,
256 off_t tosize ); 255 off_t tosize );
257 size_t (*get_next_file_chunk) ( gftp_request * request, 256 ssize_t (*get_next_file_chunk) ( gftp_request * request,
258 char *buf, 257 char *buf,
259 size_t size ); 258 size_t size );
260 size_t (*put_next_file_chunk) ( gftp_request * request, 259 ssize_t (*put_next_file_chunk) ( gftp_request * request,
261 char *buf, 260 char *buf,
262 size_t size ); 261 size_t size );
263 int (*end_transfer) ( gftp_request * request ); 262 int (*end_transfer) ( gftp_request * request );
264 int (*abort_transfer) ( gftp_request * request ); 263 int (*abort_transfer) ( gftp_request * request );
265 int (*list_files) ( gftp_request * request ); 264 int (*list_files) ( gftp_request * request );
266 int (*get_next_file) ( gftp_request * request, 265 int (*get_next_file) ( gftp_request * request,
267 gftp_file *fle, 266 gftp_file *fle,
268 FILE *fd ); 267 int fd );
269 int (*set_data_type) ( gftp_request * request, 268 int (*set_data_type) ( gftp_request * request,
270 int data_type ); 269 int data_type );
271 off_t (*get_file_size) ( gftp_request * request, 270 off_t (*get_file_size) ( gftp_request * request,
272 const char *filename ); 271 const char *filename );
273 int (*chdir) ( gftp_request * request, 272 int (*chdir) ( gftp_request * request,
289 time_t datettime ); 288 time_t datettime );
290 int (*site) ( gftp_request * request, 289 int (*site) ( gftp_request * request,
291 const char *filename ); 290 const char *filename );
292 int (*parse_url) ( gftp_request * request, 291 int (*parse_url) ( gftp_request * request,
293 const char *url ); 292 const char *url );
293 void (*set_config_options) ( gftp_request * request );
294 294
295 /* Options */ 295 /* Options */
296 gftp_transfer_type transfer_type; /* Passive or non-passive (FTP only) */ 296 gftp_transfer_type transfer_type; /* Passive or non-passive (FTP only) */
297 int network_timeout, 297 int network_timeout,
298 retries, 298 retries,
448 char *key, 448 char *key,
449 *description; 449 *description;
450 } gftp_proxy_type; 450 } gftp_proxy_type;
451 451
452 #define GFTP_CUSTOM_PROXY_NUM 8 452 #define GFTP_CUSTOM_PROXY_NUM 8
453
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;
453 461
454 /* Global config options */ 462 /* Global config options */
455 extern supported_gftp_protocols gftp_protocols[]; 463 extern supported_gftp_protocols gftp_protocols[];
456 extern char version[], *emailaddr, *edit_program, *view_program, 464 extern char version[], *emailaddr, *edit_program, *view_program,
457 *firewall_host, *firewall_username, *firewall_password, 465 *firewall_host, *firewall_username, *firewall_password,
486 extern gftp_config_vars config_file_vars[]; 494 extern gftp_config_vars config_file_vars[];
487 extern gftp_proxy_type proxy_type[]; 495 extern gftp_proxy_type proxy_type[];
488 extern gftp_color send_color, recv_color, error_color, misc_color; 496 extern gftp_color send_color, recv_color, error_color, misc_color;
489 497
490 /* cache.c */ 498 /* cache.c */
491 FILE * gftp_new_cache_entry ( gftp_request * request ); 499 int gftp_new_cache_entry ( gftp_request * request );
492 500
493 FILE * gftp_find_cache_entry ( gftp_request * request ); 501 int gftp_find_cache_entry ( gftp_request * request );
494 502
495 void gftp_clear_cache_files ( void ); 503 void gftp_clear_cache_files ( void );
496 504
497 void gftp_delete_cache_entry ( gftp_request * request, 505 void gftp_delete_cache_entry ( gftp_request * request,
498 int ignore_directory ); 506 int ignore_directory );
587 GList * gftp_sort_filelist ( GList * filelist, 595 GList * gftp_sort_filelist ( GList * filelist,
588 int column, 596 int column,
589 int asds ); 597 int asds );
590 598
591 /* protocols.c */ 599 /* protocols.c */
592 #define GFTP_CONNECTED(request) (request->sockfd != NULL)
593 #define GFTP_GET_HOSTNAME(request) (request->hostname) 600 #define GFTP_GET_HOSTNAME(request) (request->hostname)
594 #define GFTP_GET_USERNAME(request) (request->username) 601 #define GFTP_GET_USERNAME(request) (request->username)
595 #define GFTP_GET_PASSWORD(request) (request->password) 602 #define GFTP_GET_PASSWORD(request) (request->password)
596 #define GFTP_GET_ACCOUNT(request) (request->account) 603 #define GFTP_GET_ACCOUNT(request) (request->account)
597 #define GFTP_GET_DIRECTORY(request) (request->directory) 604 #define GFTP_GET_DIRECTORY(request) (request->directory)
622 #define GFTP_BOOKMARK_NUM 4 629 #define GFTP_BOOKMARK_NUM 4
623 #define GFTP_SSH_NUM 5 630 #define GFTP_SSH_NUM 5
624 #define GFTP_TYPE_BINARY 1 631 #define GFTP_TYPE_BINARY 1
625 #define GFTP_TYPE_ASCII 2 632 #define GFTP_TYPE_ASCII 2
626 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \ 633 #define GFTP_IS_CONNECTED(request) ((request) != NULL && \
627 ((request)->sockfd != NULL || \ 634 ((request)->sockfd > 0 || \
628 (request)->cached)) 635 (request)->cached || \
636 (request)->always_connected))
629 637
630 638
631 void rfc959_init ( gftp_request * request ); 639 void rfc959_init ( gftp_request * request );
632 640
633 int rfc959_get_next_file ( gftp_request * request, 641 int rfc959_get_next_file ( gftp_request * request,
634 gftp_file *fle, 642 gftp_file *fle,
635 FILE *fd ); 643 int fd );
636 644
637 void rfc2068_init ( gftp_request * request ); 645 void rfc2068_init ( gftp_request * request );
638 646
639 void local_init ( gftp_request * request ); 647 void local_init ( gftp_request * request );
640 648
652 660
653 int gftp_connect ( gftp_request * request ); 661 int gftp_connect ( gftp_request * request );
654 662
655 void gftp_disconnect ( gftp_request * request ); 663 void gftp_disconnect ( gftp_request * request );
656 664
657 size_t gftp_get_file ( gftp_request * request, 665 off_t gftp_get_file ( gftp_request * request,
658 const char *filename, 666 const char *filename,
659 FILE * fd, 667 int fd,
660 size_t startsize ); 668 size_t startsize );
661 669
662 int gftp_put_file ( gftp_request * request, 670 int gftp_put_file ( gftp_request * request,
663 const char *filename, 671 const char *filename,
664 FILE * fd, 672 int fd,
665 size_t startsize, 673 size_t startsize,
666 size_t totalsize ); 674 size_t totalsize );
667 675
668 long gftp_transfer_file ( gftp_request *fromreq, 676 long gftp_transfer_file ( gftp_request *fromreq,
669 const char *fromfile, 677 const char *fromfile,
670 FILE * fromfd, 678 int fromfd,
671 size_t fromsize, 679 size_t fromsize,
672 gftp_request *toreq, 680 gftp_request *toreq,
673 const char *tofile, 681 const char *tofile,
674 FILE * tofd, 682 int tofd,
675 size_t tosize ); 683 size_t tosize );
676 684
677 size_t gftp_get_next_file_chunk ( gftp_request * request, 685 ssize_t gftp_get_next_file_chunk ( gftp_request * request,
678 char *buf, 686 char *buf,
679 size_t size ); 687 size_t size );
680 688
681 size_t gftp_put_next_file_chunk ( gftp_request * request, 689 ssize_t gftp_put_next_file_chunk ( gftp_request * request,
682 char *buf, 690 char *buf,
683 size_t size ); 691 size_t size );
684 692
685 int gftp_list_files ( gftp_request * request ); 693 int gftp_list_files ( gftp_request * request );
686 694
758 const char *command ); 766 const char *command );
759 767
760 void gftp_set_proxy_config ( gftp_request * request, 768 void gftp_set_proxy_config ( gftp_request * request,
761 const char *proxy_config ); 769 const char *proxy_config );
762 770
763 long gftp_get_file_size ( gftp_request * request, 771 off_t gftp_get_file_size ( gftp_request * request,
764 const char *filename ); 772 const char *filename );
765 773
766 int gftp_need_proxy ( gftp_request * request, 774 int gftp_need_proxy ( gftp_request * request,
767 char *service ); 775 char *service );
768 776
807 int *h_errnop ); 815 int *h_errnop );
808 void gftp_set_config_options ( gftp_request * request ); 816 void gftp_set_config_options ( gftp_request * request );
809 817
810 void print_file_list ( GList * list ); 818 void print_file_list ( GList * list );
811 819
812 char *gftp_fgets ( gftp_request * request, 820 ssize_t gftp_get_line ( gftp_request * request,
821 gftp_getline_buffer ** rbuf,
813 char * str, 822 char * str,
814 size_t len, 823 size_t len,
815 FILE * fd ); 824 int fd );
816 825
817 size_t gftp_fwrite ( gftp_request * request, 826 ssize_t gftp_read ( gftp_request * request,
818 const void *ptr, 827 void *ptr,
819 size_t size, 828 size_t size,
820 FILE * fd ); 829 int fd );
821 830
822 #endif 831 ssize_t gftp_write ( gftp_request * request,
823 832 const char *ptr,
833 size_t size,
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 );
844
845 #endif
846