Add forgotten files 1.4.70b
[polyglot.git] / pgheader.h
1 #ifndef PGHEADER_H
2 #define PGHEADER_H
3
4 #define PGHEADER_NO_ERROR 0
5 #define PGHEADER_OS_ERROR 1
6 #define PGHEADER_BAD_FORMAT 2
7 #define PGHEADER_NO_HEADER 3
8 #define PGHEADER_NAME_COLLISION 4
9 #define PGHEADER_BAD_PARAMETER 5
10 #define PGHEADER_BAD_HEADER 6
11
12
13 const char * pgheader_version;
14 const char * pgheader_magic;
15
16 /* This does some heuristic tests to make it reasonably sure we are dealing
17    with a Polyglot book.
18 */
19 int pgheader_detect(const char *infile);
20
21 /* "variants" is a linefeed separated list of supported variants.
22    "comments" is a free format string which may contain linefeeds.
23    "header" must be freed if the function returns without error.
24 */
25 int pgheader_create(char **header, const char *variants, const char *comment);
26
27 /* "variants" and "comment" must be freed if the function returns 
28    without error.
29 */
30 int pgheader_parse(const char *header, char **variants, char **comment);
31
32 /*  "raw_header" is a byte array ready for prepending to a book file.
33     It must be freed after use.
34  */
35 int pgheader_create_raw(char **raw_header, const char *header, unsigned int *size);
36
37 /* "header" must be freed if the function returns without error.
38 */
39 int pgheader_read(char **header, const char *infile);
40
41 int pgheader_write(const char *header, const char *infile, const char *outfile);
42 int pgheader_delete(const char *infile, const char *outfile);
43
44 void pgheader_error(const char *prompt, int ret);
45
46 #endif
47