]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/libc-extension.hh
11ee88cef0ffd50491d954ffa3dd85a1b22a9cf0
[lilypond.git] / flower / include / libc-extension.hh
1 /*
2   libc-extension.hh -- declare some string.h extensions
3
4   source file of the flowerlib
5
6   (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #ifndef LIBC_EXTENSION_HH
10 #define LIBC_EXTENSION_HH
11
12 #include <stddef.h>
13 #include <stdarg.h>
14
15 #include "config.hh"
16
17 char *strnlwr (char *start, int n);
18 char *strnupr (char *start, int n);
19
20 #if ! HAVE_MEMMEM               /* GNU extension. */
21 void *memmem (void const* haystack, int haystack_len,
22               void const *needle, int needle_len);
23 #endif /* HAVE_MEMMEM */
24
25 #if ! HAVE_SNPRINTF             /* GNU extension. */
26 int snprintf (char *str, size_t n, char const *format, ...);
27 #endif
28
29 #if ! HAVE_VSNPRINTF            /* GNU extension. */
30 int vsnprintf (char *str, size_t, char const *format, va_list args);
31 #endif
32
33 #ifndef isinf
34 #if ! HAVE_ISINF                /* BSD extension. */
35 int isinf (double x);
36 #endif
37 #endif
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 #if ! HAVE_FOPENCOOKIE          /* GNU extension. */
44
45 #include <stdio.h>
46 #include <unistd.h>
47
48 #if (! defined (__off64_t) && ! defined (__off64_t_defined)) || ! defined (__cplusplus)
49 #define off64_t unsigned long long
50 #endif
51
52 #if HAVE_LIBIO_H
53 #include <libio.h>
54 #else
55
56 #define cookie_io_functions_t le_cookie_io_functions_t 
57   typedef struct
58   {
59     ssize_t (*read) (void *, char *, size_t);
60     ssize_t (*write) (void *, char const *, size_t);
61     int (*seek) (void *, off64_t *, int);
62     int (*close) (void *);
63   } cookie_io_functions_t;
64
65 #endif /* ! HAVE_LIBIO_H */
66
67   FILE *fopencookie (void *cookie, char const *modes,
68                      cookie_io_functions_t io_funcs);
69
70 #if ! HAVE_FUNOPEN
71
72   int handle_cookie_io_fclose (FILE *);
73   int handle_cookie_io_fprintf (FILE *file, char const *format, ...);
74   int handle_cookie_io_putc (int c, FILE *file);
75
76 /* FIXME: ttftool uses fclose fopencookie fprintf and putc only.  if
77           ALIAS_FILE_TO_FILECOOKIE, blondly redefine those functions
78           to wrappers that check for and handle Memory_out_stream.  */
79 #ifdef ALIAS_FILE_TO_FILECOOKIE
80
81 #define fclose handle_cookie_io_fclose
82 #define fprintf handle_cookie_io_fprintf
83 #ifdef putc
84 #define std_putc putc
85 #undef putc
86 #endif
87 #define putc handle_cookie_io_putc
88
89 #endif /* ALIAS_FILE_TO_FILECOOKIE */
90   
91 #endif /* ! HAVE_FUNOPEN */
92
93 #endif /* ! HAVE_FOPENCOOKIE */
94
95 #ifdef __cplusplus
96 } /* extern "C" */
97 #endif
98
99 unsigned char *memrchr (unsigned char const *p, int n, char c);
100 unsigned char *strrev (unsigned char *byte, int length_i);
101
102 double my_round (double);
103
104 #endif /* LIBC_EXTENSION_HH */