Imported Robodoc.
[robodoc.git] / Source / util.h
1 #ifndef ROBODOC_UTIL_H
2 #define ROBODOC_UTIL_H
3 /*
4 Copyright (C) 1994-2007  Frans Slothouber, Jacco van Weert, Petteri Kettunen,
5 Bernd Koesling, Thomas Aglassinger, Anthon Pang, Stefan Kost, David Druffner,
6 Sasha Vasko, Kai Hofmann, Thierry Pierron, Friedrich Haase, and Gergely Budai.
7
8 This file is part of ROBODoc
9
10 ROBODoc is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 */
24
25
26 /* TODO all the functions that operate
27  on headers should be in headers.h */
28
29 #include "headers.h"
30 #include "document.h"
31
32 typedef int         (
33     *TCompare )         (
34     void *,
35     void * );
36
37
38 void                RB_SetCurrentFile(
39     char *filename );
40 char               *RB_GetCurrentFile(
41      );
42
43 char               *RB_FilePart(
44     char * );
45 void                RB_Analyse_Defaults_File(
46     void );
47
48 void                RB_Slow_Sort(
49     void );
50 void                RB_Reverse_List(
51     void );
52 void                RB_Insert_In_List(
53     struct RB_header **,
54     struct RB_header * );
55 void                RB_Remove_From_List(
56     struct RB_header **,
57     struct RB_header * );
58 struct RB_header   *RB_Alloc_Header(
59     void );
60 void                RB_Free_Header(
61     struct RB_header * );
62 char               *RB_StrDup(
63     char * );
64 char               *RB_StrDupLen(
65     char *str,
66     size_t length );
67 char               *RB_CookStr(
68     char * );
69 void                RB_Say(
70     char *,
71     long mode,
72     ... );
73 void                RB_Warning_Full(
74     char *arg_filename,
75     int arg_line_number,
76     char *arg_format,
77     ... );
78 void                RB_Warning(
79     char *format,
80     ... );
81 void                RB_Panic(
82     char *,
83     ... );
84 int                 RB_Str_Case_Cmp(
85     char *s,
86     char *t );
87 void                RB_TimeStamp(
88     FILE *f );
89 char               *RB_Skip_Whitespace(
90     char *buf );
91
92 void               *RB_Calloc(
93     size_t count,
94     size_t size );
95 void               *RB_Malloc(
96     size_t size );
97 void                RB_Free(
98     void *p );
99 void                RB_FputcLatin1ToUtf8(
100     FILE *fp,
101     int c );
102 void                RB_CopyFile(
103     char *sourceFileName,
104     char *destinationFileName );
105 int                 RB_Match(
106     char *target,
107     char *wildcard_expression );
108 void                RB_QuickSort(
109     void **array,
110     int left,
111     int right,
112     TCompare f );
113 void                RB_StripCR(
114     char *line );
115 int                 Stat_Path(
116     char required,
117     char *path );
118
119 char               *ExpandTab(
120     char *line );
121
122 int                 RB_ContainsNL(
123     char *line );
124 char               *RB_ReadWholeLine(
125     FILE *file,
126     char *buf,
127     int *arg_readChars );
128 void                RB_FreeLineBuffer(
129      );
130 char               *Path_2_Win32Path(
131     char *path );
132
133 void               *RB_malloc(
134     size_t bytes );
135 void                Make_crc32_table(
136     void );
137 unsigned long       RB_crc32(
138     unsigned char *buf,
139     unsigned int len,
140     unsigned long crc32 );
141
142 char               *RB_Get_Saved_CWD(
143     void );
144 void                RB_Change_To_Docdir(
145     struct RB_Document *document );
146 void                RB_Change_Back_To_CWD(
147     void );
148 FILE               *Open_Pipe(
149     char *pipe_name );
150 void                Close_Pipe(
151     FILE *arg_pipe );
152
153
154 void                _RB_Mem_Check(
155     void *ptr,
156     const char *fname,
157     const char *funcname,
158     int linenum );
159
160
161
162 int utf8_isalnum(unsigned int arg_c);
163 int utf8_isalpha(unsigned int arg_c);
164 int utf8_iscntrl(unsigned int arg_c);
165 int utf8_isdigit(unsigned int arg_c);
166 int utf8_isgraph(unsigned int arg_c);
167 int utf8_islower(unsigned int arg_c);
168 int utf8_isprint(unsigned int arg_c);
169 int utf8_ispunct(unsigned int arg_c);
170 int utf8_isspace(unsigned int arg_c);
171 int utf8_isxdigit(unsigned int arg_c);
172
173
174 /****f* Utilities/RB_Mem_Check
175  * FUNCTION
176  *   Check for memory allocation failures.
177  * SOURCE
178  */
179
180 #define RB_Mem_Check(ptr) if (!ptr) RB_Panic("%s:%s:%d: Out of memory!\n", __FILE__, __FUNCTION__, __LINE__)
181
182 /*******/
183
184 #endif /* ROBODOC_UTIL_H */