Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / include / schily.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)schily.h 1.54 06/01/12 Copyright 1985-2006 J. Schilling */
14 /*
15  *      Definitions for libschily
16  *
17  *      This file should be included past:
18  *
19  *      mconfig.h / config.h
20  *      standard.h
21  *      stdio.h
22  *      stdlib.h        (better use stdxlib.h)
23  *      unistd.h        (better use unixstd.h) needed LARGEFILE support
24  *      string.h
25  *      sys/types.h
26  *
27  *      If you need stdio.h, you must include it before schily.h
28  *
29  *      NOTE: If you need ctype.h and did not include stdio.h you need to
30  *      include ctype.h past schily.h as OpenBSD does not follow POSIX and
31  *      defines EOF in ctype.h
32  *
33  *      Copyright (c) 1985-2006 J. Schilling
34  */
35 /*
36  * This program is free software; you can redistribute it and/or modify
37  * it under the terms of the GNU General Public License version 2
38  * as published by the Free Software Foundation.
39  *
40  * This program is distributed in the hope that it will be useful,
41  * but WITHOUT ANY WARRANTY; without even the implied warranty of
42  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43  * GNU General Public License for more details.
44  *
45  * You should have received a copy of the GNU General Public License along with
46  * this program; see the file COPYING.  If not, write to the Free Software
47  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
48  */
49
50 #ifndef _SCHILY_H
51 #define _SCHILY_H
52
53 #ifndef _STANDARD_H
54 #include <standard.h>
55 #endif
56 #ifndef _CCOMDEFS_H
57 #include <ccomdefs.h>
58 #endif
59
60 #ifdef  __cplusplus
61 extern "C" {
62 #endif
63
64 #if     defined(_INCL_SYS_TYPES_H) || defined(off_t)
65 #       ifndef  FOUND_OFF_T
66 #       define  FOUND_OFF_T
67 #       endif
68 #endif
69 #if     defined(_INCL_SYS_TYPES_H) || defined(size_t)
70 #       ifndef  FOUND_SIZE_T
71 #       define  FOUND_SIZE_T
72 #       endif
73 #endif
74
75 #ifdef  __never_def__
76 /*
77  * It turns out that we cannot use the folloginw definition because there are
78  * some platforms that do not behave application friendly. These are mainly
79  * BSD-4.4 based systems (which #undef a definition when size_t is available.
80  * We actually removed this code because of a problem with QNX Neutrino.
81  * For this reason, it is important not to include <sys/types.h> directly but
82  * via the Schily SING include files so we know whether it has been included
83  * before we come here.
84  */
85 #if     defined(_SIZE_T)        || defined(_T_SIZE_)    || defined(_T_SIZE) || \
86         defined(__SIZE_T)       || defined(_SIZE_T_)    || \
87         defined(_GCC_SIZE_T)    || defined(_SIZET_)     || \
88         defined(__sys_stdtypes_h) || defined(___int_size_t_h) || defined(size_t)
89
90 #ifndef FOUND_SIZE_T
91 #       define  FOUND_SIZE_T    /* We already included a size_t definition */
92 #endif
93 #endif
94 #endif  /* __never_def__ */
95
96 #if     defined(HAVE_LARGEFILES)
97 #       define  _fcons          _fcons64
98 #       define  fdup            fdup64
99 #       define  fileluopen      fileluopen64
100 #       define  fileopen        fileopen64
101 #       define  filemopen       filemopen64
102 #       define  filepos         filepos64
103 #       define  filereopen      filereopen64
104 #       define  fileseek        fileseek64
105 #       define  filesize        filesize64
106 #       define  filestat        filestat64
107 #       define  _openfd         _openfd64
108 #endif
109
110 #ifdef  EOF     /* stdio.h has been included */
111 extern  int     _cvmod(const char *, int *, int *);
112 extern  FILE    *_fcons(FILE *, int, int);
113 extern  FILE    *fdup(FILE *);
114 extern  int     fdown(FILE *);
115 extern  int     rols_fexecl(const char *, FILE *, FILE *, FILE *, const char *, ...);
116 extern  int     rols_fexecle(const char *, FILE *, FILE *, FILE *, const char *, ...);
117                 /* 6th arg not const, fexecv forces av[ac] = NULL */
118 extern  int     rols_fexecv(const char *, FILE *, FILE *, FILE *, int, char **);
119 extern  int     rols_fexecve(const char *, FILE *, FILE *, FILE *, char * const *, 
120                                                           char * const *);
121 extern  int     fspawnv(FILE *, FILE *, FILE *, int, char * const *);
122 extern  int     fspawnl(FILE *, FILE *, FILE *, const char *, const char *, ...);
123 extern  int     fspawnv_nowait(FILE *, FILE *, FILE *, const char *, int, 
124                                                                                 char *const*);
125 extern  int     rols_fgetline(FILE *, char *, int);
126 extern  int     fgetstr(FILE *, char *, int);
127 extern  void    file_raise(FILE *, int);
128 extern  int     fileclose(FILE *);
129 extern  FILE    *fileluopen(int, const char *);
130 extern  FILE    *fileopen(const char *, const char *);
131 #ifdef  _INCL_SYS_TYPES_H
132 extern  FILE    *filemopen(const char *, const char *, mode_t);
133 #endif
134 #ifdef  FOUND_OFF_T
135 extern  off_t   filepos(FILE *);
136 #endif
137 extern  int     fileread(FILE *, void *, int);
138 extern  int     ffileread(FILE *, void *, int);
139 extern  FILE    *filereopen(const char *, const char *, FILE *);
140 #ifdef  FOUND_OFF_T
141 extern  int     fileseek(FILE *, off_t);
142 extern  off_t   filesize(FILE *);
143 #endif
144 #ifdef  S_IFMT
145 extern  int     filestat(FILE *, struct stat *);
146 #endif
147 extern  int     filewrite(FILE *, void *, int);
148 extern  int     ffilewrite(FILE *, void *, int);
149 extern  int     flush(void);
150 extern  int     fpipe(FILE **);
151 extern  int     getbroken(FILE *, char *, char, char **, int);
152 extern  int     ofindline(FILE *, char, const char *, int, char **, int);
153 extern  int     peekc(FILE *);
154
155 #ifdef  __never_def__
156 /*
157  * We cannot define this or we may get into problems with DOS based systems.
158  */
159 extern  int     spawnv(FILE *, FILE *, FILE *, int, char * const *);
160 extern  int     spawnl(FILE *, FILE *, FILE *, const char *, const char *, ...);
161 extern  int     spawnv_nowait(FILE *, FILE *, FILE *, const char *, int, 
162                                                                           char *const*);
163 #endif  /* __never_def__m */
164 #endif  /* EOF */
165
166 extern  int     _niread(int, void *, int);
167 extern  int     _niwrite(int, void *, int);
168 extern  int     _nixread(int, void *, int);
169 extern  int     _nixwrite(int, void *, int);
170 extern  int     _openfd(const char *, int);
171 extern  int     on_comerr(void (*fun)(int, void *), void *arg);
172 /*PRINTFLIKE1*/
173 extern  void    comerr(const char *, ...) __printflike__(1, 2);
174 /*PRINTFLIKE2*/
175 extern  void    comerrno(int, const char *, ...) __printflike__(2, 3);
176 /*PRINTFLIKE1*/
177 extern  int     errmsg(const char *, ...) __printflike__(1, 2);
178 /*PRINTFLIKE2*/
179 extern  int     errmsgno(int, const char *, ...) __printflike__(2, 3);
180 #ifdef  FOUND_SIZE_T
181 /*PRINTFLIKE3*/
182 extern  int     serrmsg(char *, size_t, const char *, ...) __printflike__(3, 4);
183 /*PRINTFLIKE4*/
184 extern  int     serrmsgno(int, char *, size_t, const char *, ...) __printflike__(4, 5);
185 #endif
186 extern  void    comexit(int);
187 extern  char    *errmsgstr(int);
188 /*PRINTFLIKE1*/
189 extern  int     schily_error(const char *, ...) __printflike__(1, 2);
190 extern  char    *fillbytes(void *, int, char);
191 extern  char    *findbytes(const void *, int, char);
192 extern  int     findline(const char *, char, const char *, int, char **, int);
193 extern  int     rols_getline(char *, int);
194 extern  int     getstr(char *, int);
195 extern  int     breakline(char *, char, char **, int);
196 extern  int     getallargs(int *, char * const**, const char *, ...);
197 extern  int     getargs(int *, char * const**, const char *, ...);
198 extern  int     getfiles(int *, char * const**, const char *);
199 extern  char    *astoi(const char *, int *);
200 extern  char    *astol(const char *, long *);
201 extern  char    *astolb(const char *, long *, int base);
202 #ifdef  _UTYPES_H
203 extern  char    *astoll(const char *, Llong *);
204 extern  char    *astollb(const char *, Llong *, int);
205 extern  char    *astoull(const char *, Ullong *);
206 extern  char    *astoullb(const char *, Ullong *, int);
207 #endif
208
209 /*extern        void    handlecond __PR((const char *, SIGBLK *, int(*)(const char *, long, long), long));*/
210 /*extern        void    unhandlecond __PR((SIGBLK *));*/
211
212 extern  int             patcompile(const unsigned char *, int, int *);
213 extern  unsigned char   *patmatch(const unsigned char *, const int *,
214                                                                                          const unsigned char *, int, int, int, int[]);
215 extern  unsigned char   *patlmatch(const unsigned char *, const int *,
216                                                                                           const unsigned char *, int, int, int, int[]);
217
218 extern  char    *movebytes(const void *, void *, int);
219
220 extern  void    save_args(int, char **);
221 extern  int     saved_ac(void);
222 extern  char    **saved_av(void);
223 extern  char    *saved_av0(void);
224 #ifndef seterrno
225 extern  int     seterrno(int);
226 #endif
227 extern  void    set_progname(const char *);
228 extern  char    *get_progname(void);
229
230 extern  void    setfp(void * const *);
231 extern  int     wait_chld(int);         /* for fspawnv_nowait() */
232 extern  int     geterrno(void);
233 extern  void    raisecond(const char *, long);
234 extern  char    *strcatl(char *, ...);
235 extern  int     streql(const char *, const char *);
236 #ifdef  va_arg
237 extern  int     format(void (*)(char, long), long, const char *, va_list);
238 #else
239 extern  int     format(void (*)(char, long), long, const char *, void *);
240 #endif
241
242 extern  int     ftoes(char *, double, int, int);
243 extern  int     ftofs(char *, double, int, int);
244
245 extern  void    swabbytes(void *, int);
246 extern  char    **getmainfp(void);
247 extern  char    **getavp(void);
248 extern  char    *getav0(void);
249 extern  void    **getfp(void);
250 extern  int     flush_reg_windows(int);
251 extern  int     cmpbytes(const void *, const void *, int);
252 extern  int     cmpnullbytes(const void *, int);
253
254 #ifdef  nonono
255 #if     defined(HAVE_LARGEFILES)
256 /*
257  * To allow this, we need to figure out how to do autoconfiguration for off64_t
258  */
259 extern  FILE    *_fcons64(FILE *, int, int);
260 extern  FILE    *fdup64(FILE *);
261 extern  FILE    *fileluopen64(int, const char *);
262 extern  FILE    *fileopen64(const char *, const char *);
263 #ifdef  FOUND_OFF_T
264 extern  off64_t filepos64(FILE *);
265 #endif
266 extern  FILE    *filereopen64(const char *, const char *, FILE *);
267 #ifdef  FOUND_OFF_T
268 extern  int     fileseek64(FILE *, off64_t);
269 extern  off64_t filesize64(FILE *);
270 #endif
271 #ifdef  S_IFMT
272 extern  int     filestat64(FILE *, struct stat *);
273 #endif
274 extern  int     _openfd64(const char *, int);
275 #endif
276 #endif
277
278 #ifdef  __cplusplus
279 }
280 #endif
281
282 #if defined(_JOS) || defined(JOS)
283 #       ifndef  _JOS_IO_H
284 #       include <jos_io.h>
285 #       endif
286 #endif
287
288 #endif  /* _SCHILY_H */