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