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 "robodoc.h"
30 #include "headers.h"
31 #include "document.h"
32 
33 typedef int         (
34     *TCompare )         (
35     void *,
36     void * );
37 
38 
39 void                RB_SetCurrentFile(
40     char *filename );
41 char               *RB_GetCurrentFile(
42      );
43 
44 char               *RB_FilePart(
45     char * );
46 void                RB_Analyse_Defaults_File(
47     void );
48 
49 void                RB_Slow_Sort(
50     void );
51 void                RB_Reverse_List(
52     void );
53 void                RB_Insert_In_List(
54     struct RB_header **,
55     struct RB_header * );
56 void                RB_Remove_From_List(
57     struct RB_header **,
58     struct RB_header * );
59 struct RB_header   *RB_Alloc_Header(
60     void );
61 void                RB_Free_Header(
62     struct RB_header * );
63 char               *RB_StrDup(
64     char * );
65 char               *RB_StrDupLen(
66     char *str,
67     size_t length );
68 char               *RB_CookStr(
69     char * );
70 void                RB_Say(
71     char *,
72     long mode,
73     ... );
74 void                RB_Warning_Full(
75     char *arg_filename,
76     int arg_line_number,
77     char *arg_format,
78     ... );
79 void                RB_Warning(
80     char *format,
81     ... );
82 void                RB_Panic(
83     char *,
84     ... );
85 int                 RB_Str_Case_Cmp(
86     char *s,
87     char *t );
88 void                RB_TimeStamp(
89     FILE *f );
90 char               *RB_Skip_Whitespace(
91     char *buf );
92 
93 void               *RB_Calloc(
94     size_t count,
95     size_t size );
96 void               *RB_Malloc(
97     size_t size );
98 void                RB_Free(
99     void *p );
100 void                RB_FputcLatin1ToUtf8(
101     FILE *fp,
102     int c );
103 void                RB_CopyFile(
104     char *sourceFileName,
105     char *destinationFileName );
106 int                 RB_Match(
107     char *target,
108     char *wildcard_expression );
109 void                RB_QuickSort(
110     void **array,
111     int left,
112     int right,
113     TCompare f );
114 void                RB_StripCR(
115     char *line );
116 int                 Stat_Path(
117     char required,
118     char *path );
119 
120 char               *ExpandTab(
121     char *line );
122 
123 int                 RB_ContainsNL(
124     char *line );
125 char               *RB_ReadWholeLine(
126     FILE *file,
127     char *buf,
128     int *arg_readChars );
129 void                RB_FreeLineBuffer(
130      );
131 
132 void               *RB_malloc(
133     size_t bytes );
134 
135 void                RB_Change_To_Docdir(
136     char * );
137 void                RB_Change_Back_To_CWD(
138     void );
139 
140 FILE               *RB_Open_Pipe(
141     char *pipe_name );
142 void                RB_Close_Pipe(
143     FILE *arg_pipe );
144 
145 FILE               *RB_Open_File(
146     char *,
147     char * );
148 void                RB_Close_File(
149     FILE * );
150 
151 
152 void                _RB_Mem_Check(
153     void *ptr,
154     const char *fname,
155     const char *funcname,
156     int linenum );
157 
158 
159 
160 int                 utf8_isalnum(
161     unsigned int arg_c );
162 int                 utf8_isalpha(
163     unsigned int arg_c );
164 int                 utf8_iscntrl(
165     unsigned int arg_c );
166 int                 utf8_isdigit(
167     unsigned int arg_c );
168 int                 utf8_isgraph(
169     unsigned int arg_c );
170 int                 utf8_islower(
171     unsigned int arg_c );
172 int                 utf8_isprint(
173     unsigned int arg_c );
174 int                 utf8_ispunct(
175     unsigned int arg_c );
176 int                 utf8_isspace(
177     unsigned int arg_c );
178 int                 utf8_isxdigit(
179     unsigned int arg_c );
180 
181 #ifndef HAVE_SNPRINTF
182 int                 snprintf(
183     char *,
184     size_t,
185     const char *,
186     ... );
187 #endif
188 
189 void strtolower(
190     char *str
191     );
192 
193 /****f* Utilities/RB_Mem_Check
194  * FUNCTION
195  *   Check for memory allocation failures.
196  * SOURCE
197  */
198 
199 #define RB_Mem_Check(ptr) if (!ptr) RB_Panic("%s:%s:%d: Out of memory!\n", __FILE__, __FUNCTION__, __LINE__)
200 
201 /*******/
202 
203 #endif /* ROBODOC_UTIL_H */
204