ftpparse.h

00001 #ifndef FTPPARSE_H
00002 #define FTPPARSE_H
00003 
00004 #include <time.h>
00005 
00006 /*
00007 ftpparse(&fp,buf,len) tries to parse one line of LIST output.
00008 
00009 The line is an array of len characters stored in buf.
00010 It should not include the terminating CR LF; so buf[len] is typically CR.
00011 
00012 If ftpparse() can't find a filename, it returns 0.
00013 
00014 If ftpparse() can find a filename, it fills in fp and returns 1.
00015 fp is a struct ftpparse, defined below.
00016 The name is an array of fp.namelen characters stored in fp.name;
00017 fp.name points somewhere within buf.
00018 */
00019 
00020 struct ftpparse {
00021   char *name; /* not necessarily 0-terminated */
00022   int namelen;
00023   int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */
00024   int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */
00025   int sizetype;
00026   long size; /* number of octets */
00027   int mtimetype;
00028   time_t mtime; /* modification time */
00029   int idtype;
00030   char *id; /* not necessarily 0-terminated */
00031   int idlen;
00032 } ;
00033 
00034 #define FTPPARSE_SIZE_UNKNOWN 0
00035 #define FTPPARSE_SIZE_BINARY 1 /* size is the number of octets in TYPE I */
00036 #define FTPPARSE_SIZE_ASCII 2 /* size is the number of octets in TYPE A */
00037 
00038 #define FTPPARSE_MTIME_UNKNOWN 0
00039 #define FTPPARSE_MTIME_LOCAL 1 /* time is correct */
00040 #define FTPPARSE_MTIME_REMOTEMINUTE 2 /* time zone and secs are unknown */
00041 #define FTPPARSE_MTIME_REMOTEDAY 3 /* time zone and time of day are unknown */
00042 /*
00043 When a time zone is unknown, it is assumed to be GMT. You may want
00044 to use localtime() for LOCAL times, along with an indication that the
00045 time is correct in the local time zone, and gmtime() for REMOTE* times.
00046 */
00047 
00048 #define FTPPARSE_ID_UNKNOWN 0
00049 #define FTPPARSE_ID_FULL 1 /* unique identifier for files on this FTP server */
00050 
00051 extern int ftpparse(struct ftpparse *,char *,int);
00052 
00053 #endif