The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ftpparse.h
Go to the documentation of this file.
1 #ifndef FTPPARSE_H
2 #define FTPPARSE_H
3 
4 #include <time.h>
5 
6 /*
7 ftpparse(&fp,buf,len) tries to parse one line of LIST output.
8 
9 The line is an array of len characters stored in buf.
10 It should not include the terminating CR LF; so buf[len] is typically CR.
11 
12 If ftpparse() can't find a filename, it returns 0.
13 
14 If ftpparse() can find a filename, it fills in fp and returns 1.
15 fp is a struct ftpparse, defined below.
16 The name is an array of fp.namelen characters stored in fp.name;
17 fp.name points somewhere within buf.
18 */
19 
20 struct ftpparse {
21  char *name; /* not necessarily 0-terminated */
22  int namelen;
23  int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */
24  int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */
25  int sizetype;
26  long size; /* number of octets */
27  int mtimetype;
28  time_t mtime; /* modification time */
29  int idtype;
30  char *id; /* not necessarily 0-terminated */
31  int idlen;
32 } ;
33 
34 #define FTPPARSE_SIZE_UNKNOWN 0
35 #define FTPPARSE_SIZE_BINARY 1 /* size is the number of octets in TYPE I */
36 #define FTPPARSE_SIZE_ASCII 2 /* size is the number of octets in TYPE A */
37 
38 #define FTPPARSE_MTIME_UNKNOWN 0
39 #define FTPPARSE_MTIME_LOCAL 1 /* time is correct */
40 #define FTPPARSE_MTIME_REMOTEMINUTE 2 /* time zone and secs are unknown */
41 #define FTPPARSE_MTIME_REMOTEDAY 3 /* time zone and time of day are unknown */
42 /*
43 When a time zone is unknown, it is assumed to be GMT. You may want
44 to use localtime() for LOCAL times, along with an indication that the
45 time is correct in the local time zone, and gmtime() for REMOTE* times.
46 */
47 
48 #define FTPPARSE_ID_UNKNOWN 0
49 #define FTPPARSE_ID_FULL 1 /* unique identifier for files on this FTP server */
50 
51 extern int ftpparse(struct ftpparse *,char *,int);
52 
53 #endif
char * id
Definition: ftpparse.h:30
int flagtrycwd
Definition: ftpparse.h:23
char * name
Definition: ftpparse.h:21
int mtimetype
Definition: ftpparse.h:27
int idlen
Definition: ftpparse.h:31
int sizetype
Definition: ftpparse.h:25
int namelen
Definition: ftpparse.h:22
int flagtryretr
Definition: ftpparse.h:24
time_t mtime
Definition: ftpparse.h:28
int idtype
Definition: ftpparse.h:29
int ftpparse(struct ftpparse *fp, char *buf, int len)
Definition: ftpparse.c:144
long size
Definition: ftpparse.h:26