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