1 /***************************************************************************
2  *  Pinfo is a ncurses based lynx style info documentation browser
3  *
4  *  Copyright (C) 1999  Przemek Borys <pborys@dione.ids.pl>
5  *  Copyright (C) 2005  Bas Zoetekouw <bas@debian.org>
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of version 2 of the GNU General Public License as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful, but
12  *  WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
19  *  USA
20  ***************************************************************************/
21 
22 #ifndef __FILEHANDLING_FUNCTIONS_H
23 #define __FILEHANDLING_FUNCTIONS_H
24 
25 #include <dirent.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <unistd.h>
29 #include <errno.h>
30 
31 
32 #define INFO_TAG 0x1f
33 #define INDIRECT_TAG 0x7f
34 
35 void initpaths ();
36 void addrawpath (char *filename);
37 
38 /*  seek to a node in certain info file */
39 int seeknode (int tag_table_pos, FILE ** Id);
40 
41 /*
42  * free allocated memory, hold by buf (node** content, stored line by line),
43  * and type (a char* pointer, which stores the node header).
44  */
45 void freeitem (char **type, char ***buf, unsigned long *lines);
46 
47 /*
48  * reads a node from 'id' to 'buf', and the header of node to 'type'. It sets
49  * the numer of read lines to *lines. Warning! First line of 'buf' is left
50  * empty.
51  */
52 void read_item (FILE * id, char **type, char ***buf, unsigned long *lines);
53 /* searches for indirect entry of info file */
54 int seek_indirect (FILE * id);
55 /* as above, but with tag table entry */
56 int seek_tag_table (FILE * id,int quiet);
57 /*
58  * loads indirect table (from a special node, stored in message, of lines
59  * length)
60  */
61 void load_indirect (char **message, unsigned long lines);
62 /* loads tag table (as above) */
63 void load_tag_table (char **message, unsigned long lines);
64 /* opens info file */
65 FILE *openinfo (char *filename, int number);
66 /* opens dir info file */
67 FILE *opendirfile (int number);
68 
69 /* creates tag table for info file */
70 void create_tag_table (FILE * id);
71 /* creates tag table for indirect info */
72 void create_indirect_tag_table ();
73 
74 /*
75  * look up a name, which was specified by the user in cmd line, in dir
76  * entries. If found, return filedescriptor of the info file, which holds
77  * needed entry. Also set `first node' to the name of node, which describes
78  * the problem. Arguments:
79  * type: a pointer to char*, which will hold the header line of dir entry
80  * message: a pointer to char** buffer, which will hold the dir page line by
81  *          line
82  * lines: pointer to long, which holds the number of lines in dir entry
83  */
84 FILE *
85 dirpage_lookup (char **type, char ***message, unsigned long *lines,
86 		char *filename, char **first_node);
87 
88 /* removes trailing .gz, .bz2, etc. */
89 void strip_compression_suffix (char *file);
90 /* removes trailing .info */
91 void strip_info_suffix (char *file);
92 
93 #endif
94