annotate lib/fsplib/fsplib.h @ 968:ce365745f7ba

2008-11-30 Brian Masney <masneyb@gftp.org> * lib/ftps.c - warning fixes for the FTPS protocol when OpenSSL support is disabled.
author masneyb
date Sun, 30 Nov 2008 14:29:48 +0000
parents 26fb4e66736c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
662
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1 #ifndef _FSPLIB_H
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
2 #define _FSPLIB_H 1
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
3 #include <time.h>
739
ba82724da370 2006-5-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 667
diff changeset
4 #include <dirent.h>
ba82724da370 2006-5-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 667
diff changeset
5 #include <sys/stat.h>
962
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
6 #include <stddef.h>
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
7
662
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
8 /* The FSP v2 protocol support library - public interface */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
9
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
10 /*
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
11 This file is part of fsplib - FSP protocol stack implemented in C
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
12 language. See http://fsp.sourceforge.net for more information.
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
13
962
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
14 Copyright (c) 2003-2005 by Radim HSN Kolar (hsn@sendmail.cz)
662
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
15
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
16 You may copy or modify this file in any manner you wish, provided
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
17 that this notice is always included, and that you hold the author
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
18 harmless for any loss or damage resulting from the installation or
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
19 use of this software.
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
20
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
21 This is a free software. Be creative.
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
22 Let me know of any bugs and suggestions.
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
23 */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
24
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
25 /* definition of FSP protocol v2 commands */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
26
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
27 #define FSP_CC_VERSION 0x10 /* return server's version string. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
28 #define FSP_CC_INFO 0x11 /* return server's extended info block */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
29 #define FSP_CC_ERR 0x40 /* error response from server. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
30 #define FSP_CC_GET_DIR 0x41 /* get a directory listing. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
31 #define FSP_CC_GET_FILE 0x42 /* get a file. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
32 #define FSP_CC_UP_LOAD 0x43 /* open a file for writing. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
33 #define FSP_CC_INSTALL 0x44 /* close a file opened for writing. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
34 #define FSP_CC_DEL_FILE 0x45 /* delete a file. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
35 #define FSP_CC_DEL_DIR 0x46 /* delete a directory. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
36 #define FSP_CC_GET_PRO 0x47 /* get directory protection. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
37 #define FSP_CC_SET_PRO 0x48 /* set directory protection. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
38 #define FSP_CC_MAKE_DIR 0x49 /* create a directory. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
39 #define FSP_CC_BYE 0x4A /* finish a session. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
40 #define FSP_CC_GRAB_FILE 0x4B /* atomic get+delete a file. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
41 #define FSP_CC_GRAB_DONE 0x4C /* atomic get+delete a file done. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
42 #define FSP_CC_STAT 0x4D /* get information about file. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
43 #define FSP_CC_RENAME 0x4E /* rename file or directory. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
44 #define FSP_CC_CH_PASSWD 0x4F /* change password */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
45 #define FSP_CC_LIMIT 0x80 /* # > 0x7f for future cntrl blk ext. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
46 #define FSP_CC_TEST 0x81 /* reserved for testing */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
47
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
48 /* FSP v2 packet size */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
49 #define FSP_HSIZE 12 /* 12 bytes for v2 header */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
50 #define FSP_SPACE 1024 /* maximum payload. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
51 #define FSP_MAXPACKET FSP_HSIZE+FSP_SPACE /* maximum packet size. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
52
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
53 /* byte offsets of fields in the FSP v2 header */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
54 #define FSP_OFFSET_CMD 0
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
55 #define FSP_OFFSET_SUM 1
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
56 #define FSP_OFFSET_KEY 2
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
57 #define FSP_OFFSET_SEQ 4
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
58 #define FSP_OFFSET_LEN 6
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
59 #define FSP_OFFSET_POS 8
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
60
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
61 /* types of directory entry */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
62 #define FSP_RDTYPE_END 0x00
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
63 #define FSP_RDTYPE_FILE 0x01
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
64 #define FSP_RDTYPE_DIR 0x02
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
65 #define FSP_RDTYPE_LINK 0x03
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
66 #define FSP_RDTYPE_SKIP 0x2A
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
67
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
68 /* definition of directory bitfield for directory information */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
69 /* directory information is just going to be a bitfield encoding
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
70 * of which protection bits are set/unset
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
71 */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
72
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
73 #define FSP_PRO_BYTES 1 /* currently only 8 bits or less of info */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
74 #define FSP_DIR_OWNER 0x01 /* does caller own directory */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
75 #define FSP_DIR_DEL 0x02 /* can files be deleted from this dir */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
76 #define FSP_DIR_ADD 0x04 /* can files be added to this dir */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
77 #define FSP_DIR_MKDIR 0x08 /* can new subdirectories be created */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
78 #define FSP_DIR_GET 0x10 /* are files readable by non-owners? */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
79 #define FSP_DIR_README 0x20 /* does this dir contain an readme file? */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
80 #define FSP_DIR_LIST 0x40 /* public can list directory */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
81 #define FSP_DIR_RENAME 0x80 /* can files be renamed in this dir */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
82
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
83 /* decoded FSP packet */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
84 typedef struct FSP_PKT {
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
85 unsigned char cmd; /* message code. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
86 unsigned char sum; /* message checksum. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
87 unsigned short key; /* message key. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
88 unsigned short seq; /* message sequence number. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
89 unsigned short len; /* number of bytes in buf 1. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
90 unsigned int pos; /* location in the file. */ unsigned short xlen; /* number of bytes in buf 2 */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
91
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
92 unsigned char buf[FSP_SPACE]; /* packet payload */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
93 } FSP_PKT;
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
94
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
95 /* FSP host:port */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
96 typedef struct FSP_SESSION {
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
97 void * lock; /* key locking */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
98 unsigned int timeout; /* send timeout 1/1000s*/
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
99 unsigned int maxdelay; /* maximum recv. delay */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
100 unsigned short seq; /* sequence number */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
101 unsigned int dupes; /* total pkt. dupes */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
102 unsigned int resends; /* total pkt. sends */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
103 unsigned int trips; /* total pkt trips */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
104 unsigned long rtts; /* cumul. rtt */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
105 unsigned int last_rtt; /* last rtt */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
106 unsigned int last_delay; /* last delay time */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
107 unsigned int last_dupes; /* last dupes */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
108 unsigned int last_resends;/* last resends */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
109 int fd; /* i/o descriptor */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
110 char *password; /* host acccess password */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
111 } FSP_SESSION;
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
112
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
113 /* fsp directory handle */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
114 typedef struct FSP_DIR {
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
115 char *dirname; /* directory name */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
116 short inuse; /* in use counter */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
117 int dirpos; /* current directory pos. */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
118 unsigned short blocksize; /* size of directory block */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
119 unsigned char *data; /* raw directory data */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
120 unsigned int datasize; /* size of raw dir. data */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
121 } FSP_DIR;
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
122
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
123 /* fsp directory entry */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
124 typedef struct FSP_RDENTRY {
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
125 char name[255 + 1]; /* entry name */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
126 unsigned short namlen; /* length */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
127 unsigned char type; /* field type */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
128 unsigned short reclen; /* directory record length */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
129 unsigned int size;
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
130 unsigned int lastmod;
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
131 } FSP_RDENTRY;
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
132
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
133 /* fsp file handle */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
134 typedef struct FSP_FILE {
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
135 FSP_PKT in,out; /* io packets */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
136 FSP_SESSION *s; /* master session */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
137 char *name; /* filename for upload */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
138 unsigned char writing; /* opened for writing */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
139 unsigned char eof; /* EOF reached? */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
140 unsigned char err; /* i/o error? */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
141 int bufpos; /* position in buffer */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
142 unsigned int pos; /* position of next packet */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
143 } FSP_FILE;
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
144
962
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
145
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
146 typedef union dirent_workaround {
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
147 struct dirent dirent;
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
148 char fill[offsetof (struct dirent, d_name) + MAXNAMLEN + 1];
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
149 } dirent_workaround;
26fb4e66736c 2008-11-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 739
diff changeset
150
662
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
151 /* function prototypes */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
152
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
153 /* session management */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
154 FSP_SESSION * fsp_open_session(const char *host,unsigned short port, const char *password);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
155 void fsp_close_session(FSP_SESSION *s);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
156
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
157 /* packet encoding/decoding */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
158 size_t fsp_pkt_write(const FSP_PKT *p,void *space);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
159 int fsp_pkt_read(FSP_PKT *p,const void *space,size_t recv_len);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
160
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
161 /* send/receive round-trip */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
162 int fsp_transaction(FSP_SESSION *s,FSP_PKT *p,FSP_PKT *rpkt);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
163
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
164 /* directory listing commands */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
165 FSP_DIR * fsp_opendir(FSP_SESSION *s,const char *dirname);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
166 int fsp_readdir_r(FSP_DIR *dir,struct dirent *entry, struct dirent **result);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
167 long fsp_telldir(FSP_DIR *dirp);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
168 void fsp_seekdir(FSP_DIR *dirp, long loc);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
169 void fsp_rewinddir(FSP_DIR *dirp);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
170 struct dirent * fsp_readdir(FSP_DIR *dirp);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
171 int fsp_readdir_native(FSP_DIR *dir,FSP_RDENTRY *entry, FSP_RDENTRY **result);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
172 int fsp_closedir(FSP_DIR *dirp);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
173 /* high level file i/o */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
174 FSP_FILE * fsp_fopen(FSP_SESSION *session, const char *path,const char *modeflags);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
175 size_t fsp_fread(void *ptr,size_t size,size_t nmemb,FSP_FILE *file);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
176 size_t fsp_fwrite(const void * source, size_t size, size_t count, FSP_FILE * file);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
177 int fsp_fclose(FSP_FILE *file);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
178 int fsp_fpurge(FSP_FILE *file);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
179 int fsp_fflush(FSP_FILE *file);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
180 int fsp_fseek(FSP_FILE *stream, long offset, int whence);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
181 long fsp_ftell(FSP_FILE *f);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
182 void fsp_rewind(FSP_FILE *f);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
183 /* misc. functions */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
184 int fsp_stat(FSP_SESSION *s,const char *path,struct stat *sb);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
185 int fsp_mkdir(FSP_SESSION *s,const char *directory);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
186 int fsp_rmdir(FSP_SESSION *s,const char *directory);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
187 int fsp_unlink(FSP_SESSION *s,const char *directory);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
188 int fsp_rename(FSP_SESSION *s,const char *from, const char *to);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
189 int fsp_access(FSP_SESSION *s,const char *path, int mode);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
190 /* fsp protocol specific functions */
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
191 int fsp_getpro(FSP_SESSION *s,const char *directory,unsigned char *result);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
192 int fsp_install(FSP_SESSION *s,const char *fname,time_t timestamp);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
193 int fsp_canupload(FSP_SESSION *s,const char *fname);
be9663e0be00 2005-1-16 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
194 #endif