iconv: Bail out of the loop when an illegal sequence of bytes occurs.
[elinks/elinks-j605.git] / src / osdep / stub.h
blob00986472112b4040b4ae223aa6251ecfedbc0623
1 #ifndef EL__OSDEP_STUB_H
2 #define EL__OSDEP_STUB_H
4 #include <ctype.h>
5 #include <string.h>
7 #if 0
8 #ifdef CONFIG_DEBUG
9 #define CONFIG_OWN_LIBC
10 #endif
11 #endif
13 #ifdef CONFIG_OWN_LIBC
15 #undef HAVE_BCOPY /* prevent using bcopy() stub for memmove() */
16 #undef HAVE_ISDIGIT
17 #undef HAVE_MEMMOVE
18 #undef HAVE_MEMPCPY
19 #undef HAVE_RAISE
20 #undef HAVE_STPCPY
21 #undef HAVE_STRCASECMP
22 #undef HAVE_STRCASESTR
23 #undef HAVE_STRDUP
24 #undef HAVE_STRERROR
25 #undef HAVE_STRNCASECMP
26 #undef HAVE_STRSTR
27 #undef HAVE_INET_NTOP
29 #endif /* CONFIG_OWN_LIBC */
32 /* These stubs are exception to our "Use (unsigned char *)!" rule. This is
33 * because the stubbed functions are defined using (char *), and we could get
34 * in trouble with this. Or when you use (foo ? strstr() : strcasestr()) and
35 * one of these is system and another stub, we're in trouble and get "Pointer
36 * type mismatch in conditional expression", game over. */
39 /** strchr() */
41 #ifndef HAVE_STRCHR
42 #ifdef HAVE_INDEX /* for old BSD systems. */
44 #undef strchr
45 #define strchr(a, b) index(a, b)
46 #undef strrchr
47 #define strrchr(a, b) rindex(a, b)
49 #else /* ! HAVE_INDEX */
50 # error You have neither strchr() nor index() function. Please go upgrade your system.
51 #endif /* HAVE_INDEX */
52 #endif /* HAVE_STRCHR */
54 #ifndef HAVE_ISDIGIT
55 #undef isdigit
56 #define isdigit(a) elinks_isdigit(a)
57 int elinks_isdigit(int);
58 #endif
60 /** strerror() */
61 #ifndef HAVE_STRERROR
62 #undef strerror
63 #define strerror(e) elinks_strerror(e)
64 const char *elinks_strerror(int);
65 #endif
67 /** strstr() */
68 #ifndef HAVE_STRSTR
69 #undef strstr
70 #define strstr(a, b) elinks_strstr(a, b)
71 char *elinks_strstr(const char *, const char *);
72 #endif
74 /** memmove() */
75 #ifndef HAVE_MEMMOVE
76 #ifdef HAVE_BCOPY
77 # define memmove(dst, src, n) bcopy(src, dst, n)
78 #else
79 #undef memmove
80 #define memmove(dst, src, n) elinks_memmove(dst, src, n)
81 void *elinks_memmove(void *, const void *, size_t);
82 #endif
83 #endif
85 /** strcasecmp() */
86 #ifndef HAVE_STRCASECMP
87 #undef strcasecmp
88 #define strcasecmp(a, b) elinks_strcasecmp(a, b)
89 int elinks_strcasecmp(const char *, const char *);
90 #endif
92 /** strncasecmp() */
93 #ifndef HAVE_STRNCASECMP
94 #undef strncasecmp
95 #define strncasecmp(a, b, l) elinks_strncasecmp(a, b, l)
96 int elinks_strncasecmp(const char *, const char *, size_t);
97 #endif
99 /** strcasestr() */
100 #ifndef HAVE_STRCASESTR
101 #undef strcasestr
102 #define strcasestr(a, b) elinks_strcasestr(a, b)
103 char *elinks_strcasestr(const char *, const char *);
104 #endif
106 /** strdup() */
107 #ifndef HAVE_STRDUP
108 #undef strdup
109 #define strdup(s) elinks_strdup(s)
110 char *elinks_strdup(const char *);
111 #endif
113 /* stpcpy() */
114 #ifndef HAVE_STPCPY
115 #undef stpcpy
116 #define stpcpy(d, s) elinks_stpcpy(d, s)
117 char *elinks_stpcpy(char *, const char *);
118 #endif
120 /* mempcpy() */
121 #ifndef HAVE_MEMPCPY
122 #undef mempcpy
123 #define mempcpy(dest, src, n) elinks_mempcpy(dest, src, n)
124 void *elinks_mempcpy(void *, const void *, size_t);
125 #endif
127 /* memrchr() */
128 #ifndef HAVE_MEMRCHR
129 #undef memrchr
130 #define memrchr(src, c, n) elinks_memrchr(src, c, n)
131 void *elinks_memrchr(const void *s, int c, size_t n);
132 #endif
134 /* raise() */
135 #ifndef HAVE_RAISE
136 #undef raise
137 #define raise(signal) elinks_raise(signal)
138 int elinks_raise(int signal);
139 #endif
141 /* inet_ntop() */
142 #ifndef HAVE_INET_NTOP
143 #undef inet_ntop
144 #define inet_ntop(af, src, dst, size) elinks_inet_ntop(af, src, dst, size)
145 const char *elinks_inet_ntop(int af, const void *src, char *dst, size_t size);
146 #endif
148 /* Silence various sparse warnings. */
150 #ifndef __builtin_stpcpy
151 extern char *__builtin_stpcpy(char *dest, const char *src);
152 #endif
154 #ifndef __builtin_mempcpy
155 extern void *__builtin_mempcpy(void *dest, const void *src, size_t n);
156 #endif
158 #if 0
159 #ifndef __builtin_va_copy
160 #define __builtin_va_copy(dest, src) do { dest = src; } while (0)
161 #endif
162 #endif
164 #endif