OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // <stdio.h>-lookalike-ish. Note that this is a C header, so that crappy (and | 5 // <stdio.h>-lookalike-ish. Note that this is a C header, so that crappy (and |
6 // non-crappy) C programs can use it. | 6 // non-crappy) C programs can use it. |
7 // | 7 // |
8 // In general, functions/types/macros are given "mojio_"/"MOJIO_"/etc. prefixes. | 8 // In general, functions/types/macros are given "mojio_"/"MOJIO_"/etc. prefixes. |
9 // There are a handful of exceptions (noted below). | 9 // There are a handful of exceptions (noted below). |
10 // | 10 // |
11 // One should be able to have a drop-in <stdio.h> replacement using just (C99) | 11 // One should be able to have a drop-in <stdio.h> replacement using just (C99) |
12 // inline functions, typedefs, and macro definitions. (For "native" apps, doing | 12 // inline functions, typedefs, and macro definitions. (For "native" apps, doing |
13 // so in C is somewhat problematic, due to conflicts with the "native" C | 13 // so in C is somewhat problematic, due to conflicts with the "native" C |
14 // library.) | 14 // library.) |
15 // | 15 // |
16 // TODO(vtl): The lack of |restrict|s in certain functions is slightly | 16 // TODO(vtl): The lack of |restrict|s in certain functions is slightly |
17 // mysterious to me, but it's consistent with glibc. I don't know what the | 17 // mysterious to me, but it's consistent with glibc. I don't know what the |
18 // standard specifies. | 18 // standard specifies. |
19 | 19 |
20 #ifndef MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_STDIO_H_ | 20 #ifndef MOJO_SERVICES_FILES_C_MOJIO_STDIO_H_ |
21 #define MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_STDIO_H_ | 21 #define MOJO_SERVICES_FILES_C_MOJIO_STDIO_H_ |
22 | 22 |
23 // Includes -------------------------------------------------------------------- | 23 // Includes -------------------------------------------------------------------- |
24 | 24 |
25 // We need |va_list|. | 25 // We need |va_list|. |
26 #include <stdarg.h> | 26 #include <stdarg.h> |
27 | 27 |
28 // <stdio.h> is required to define |NULL| (as a macro) and |size_t|. We don't | 28 // <stdio.h> is required to define |NULL| (as a macro) and |size_t|. We don't |
29 // define our own (with prefixes), and just use the standard ones from | 29 // define our own (with prefixes), and just use the standard ones from |
30 // <stddef.h>. | 30 // <stddef.h>. |
31 #include <stddef.h> | 31 #include <stddef.h> |
32 | 32 |
33 #include "files/public/c/mojio_config.h" | 33 #include "files/c/mojio_config.h" |
34 | 34 |
35 // Macros ---------------------------------------------------------------------- | 35 // Macros ---------------------------------------------------------------------- |
36 | 36 |
37 // Default buffer size. | 37 // Default buffer size. |
38 #define MOJIO_BUFSIZ MOJIO_CONFIG_BUFSIZ | 38 #define MOJIO_BUFSIZ MOJIO_CONFIG_BUFSIZ |
39 | 39 |
40 // |EOF|: -1 in the known universe. Probably nothing would work if different. | 40 // |EOF|: -1 in the known universe. Probably nothing would work if different. |
41 #define MOJIO_EOF (-1) | 41 #define MOJIO_EOF (-1) |
42 | 42 |
43 // Recommended size for arrays meant to hold a filename. | 43 // Recommended size for arrays meant to hold a filename. |
(...skipping 149 matching lines...) Loading... |
193 // Globals --------------------------------------------------------------------- | 193 // Globals --------------------------------------------------------------------- |
194 | 194 |
195 extern MOJIO_FILE* mojio_stdin; | 195 extern MOJIO_FILE* mojio_stdin; |
196 extern MOJIO_FILE* mojio_stdout; | 196 extern MOJIO_FILE* mojio_stdout; |
197 extern MOJIO_FILE* mojio_stderr; | 197 extern MOJIO_FILE* mojio_stderr; |
198 | 198 |
199 #ifdef __cplusplus | 199 #ifdef __cplusplus |
200 } // extern "C" | 200 } // extern "C" |
201 #endif | 201 #endif |
202 | 202 |
203 #endif // MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_STDIO_H_ | 203 #endif // MOJO_SERVICES_FILES_C_MOJIO_STDIO_H_ |
OLD | NEW |