CARMA C++
arcfile.h
1 #ifndef arcfile_h
2 #define arcfile_h
3 
4 /*
5  * Enumerate the known types of archive file.
6  */
7 typedef enum {
8  ARC_LOG_FILE, /* A file of time-stamped log messages */
9  ARC_DAT_FILE, /* A file of binary archive data */
10  ARC_GRAB_FILE, /* A time-stamped binary image from the frame grabber */
11 /* The following entry must be the last */
12  ARC_NUM_TYPE /* The number of file types listed above */
13 } ArcFileType;
14 
15 /*
16  * Achive filename timestamps are recorded in containers
17  * of the following type.
18  */
19 typedef struct {
20  long mjd; /* The Modified Julian Date from the file name */
21  long sec; /* The time of day (seconds) from the file name */
22 } ArcTimeStamp;
23 
24 /*
25  * Construct the full path name of an archive-file.
26  * This function calls pathname(), so ~ expansion of home
27  * directories is supported.
28  *
29  * The returned file-name is malloc()'d memory, so the caller
30  * should pass it to free() when it becomes redundant.
31  *
32  * The utc argument specifies the time-stamp of the file as
33  * a Modified Julian Date split into day-number and time-of-day
34  * components. If utc==NULL the current time will be substituted.
35  *
36  * The type argument is used to select between known 3-letter file-name
37  * extensions.
38  */
39 char *arc_path_name(char *dir, ArcTimeStamp *utc, ArcFileType type);
40 
41 /*
42  * Construct an archive file name in a given buffer.
43  * Note that buffer must have room for at least
44  * arc_file_name_length() + 1 bytes. See arc_path_name for the
45  * meaning of the utc and type arguments.
46  */
47 int arc_file_name(ArcTimeStamp *utc, ArcFileType type, char *buffer);
48 
49 /*
50  * Decode the time-stamp and file type from an archive file name.
51  * If the file name is invalid, non-zero is returned, and if 'complain'
52  * is true an error message will be printed to stderr.
53  */
54 int arc_file_id(char *path, int complain, ArcTimeStamp *utc, ArcFileType *type);
55 
56 /*
57  * All archive file names are the same length (excluding the directory
58  * name. Return this length.
59  */
60 int arc_file_name_length(void);
61 
62 #endif