/src/libjpeg-turbo.main/jinclude.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * jinclude.h |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1991-1994, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright (C) 2022, D. R. Commander. |
8 | | * For conditions of distribution and use, see the accompanying README.ijg |
9 | | * file. |
10 | | * |
11 | | * This file exists to provide a single place to fix any problems with |
12 | | * including the wrong system include files. (Common problems are taken |
13 | | * care of by the standard jconfig symbols, but on really weird systems |
14 | | * you may have to edit this file.) |
15 | | * |
16 | | * NOTE: this file is NOT intended to be included by applications using the |
17 | | * JPEG library. Most applications need only include jpeglib.h. |
18 | | */ |
19 | | |
20 | | #ifndef __JINCLUDE_H__ |
21 | | #define __JINCLUDE_H__ |
22 | | |
23 | | /* Include auto-config file to find out which system include files we need. */ |
24 | | |
25 | | #include "jconfig.h" /* auto configuration options */ |
26 | | #include "jconfigint.h" |
27 | | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ |
28 | | |
29 | | /* |
30 | | * Note that the core JPEG library does not require <stdio.h>; |
31 | | * only the default error handler and data source/destination modules do. |
32 | | * But we must pull it in because of the references to FILE in jpeglib.h. |
33 | | * You can remove those references if you want to compile without <stdio.h>. |
34 | | */ |
35 | | |
36 | | #include <stddef.h> |
37 | | #include <stdlib.h> |
38 | | #include <stdio.h> |
39 | | #include <string.h> |
40 | | |
41 | | /* |
42 | | * These macros/inline functions facilitate using Microsoft's "safe string" |
43 | | * functions with Visual Studio builds without the need to scatter #ifdefs |
44 | | * throughout the code base. |
45 | | */ |
46 | | |
47 | | |
48 | | #ifdef _MSC_VER |
49 | | |
50 | | #define SNPRINTF(str, n, format, ...) \ |
51 | | _snprintf_s(str, n, _TRUNCATE, format, ##__VA_ARGS__) |
52 | | |
53 | | #else |
54 | | |
55 | 543k | #define SNPRINTF snprintf |
56 | | |
57 | | #endif |
58 | | |
59 | | |
60 | | #ifndef NO_GETENV |
61 | | |
62 | | #ifdef _MSC_VER |
63 | | |
64 | | static INLINE int GETENV_S(char *buffer, size_t buffer_size, const char *name) |
65 | | { |
66 | | size_t required_size; |
67 | | |
68 | | return (int)getenv_s(&required_size, buffer, buffer_size, name); |
69 | | } |
70 | | |
71 | | #else /* _MSC_VER */ |
72 | | |
73 | | #include <errno.h> |
74 | | |
75 | | /* This provides a similar interface to the Microsoft/C11 getenv_s() function, |
76 | | * but other than parameter validation, it has no advantages over getenv(). |
77 | | */ |
78 | | |
79 | | static INLINE int GETENV_S(char *buffer, size_t buffer_size, const char *name) |
80 | 161k | { |
81 | 161k | char *env; |
82 | | |
83 | 161k | if (!buffer) { |
84 | 0 | if (buffer_size == 0) |
85 | 0 | return 0; |
86 | 0 | else |
87 | 0 | return (errno = EINVAL); |
88 | 0 | } |
89 | 161k | if (buffer_size == 0) |
90 | 0 | return (errno = EINVAL); |
91 | 161k | if (!name) { |
92 | 0 | *buffer = 0; |
93 | 0 | return 0; |
94 | 0 | } |
95 | | |
96 | 161k | env = getenv(name); |
97 | 161k | if (!env) |
98 | 161k | { |
99 | 161k | *buffer = 0; |
100 | 161k | return 0; |
101 | 161k | } |
102 | | |
103 | 0 | if (strlen(env) + 1 > buffer_size) { |
104 | 0 | *buffer = 0; |
105 | 0 | return ERANGE; |
106 | 0 | } |
107 | | |
108 | 0 | strncpy(buffer, env, buffer_size); |
109 | |
|
110 | 0 | return 0; |
111 | 0 | } Unexecuted instantiation: turbojpeg.c:GETENV_S Unexecuted instantiation: transupp.c:GETENV_S Unexecuted instantiation: jdatadst-tj.c:GETENV_S Unexecuted instantiation: jdatasrc-tj.c:GETENV_S Unexecuted instantiation: rdbmp.c:GETENV_S Unexecuted instantiation: rdppm.c:GETENV_S Unexecuted instantiation: wrbmp.c:GETENV_S Unexecuted instantiation: wrppm.c:GETENV_S Unexecuted instantiation: jcapimin.c:GETENV_S Unexecuted instantiation: jcapistd.c:GETENV_S Unexecuted instantiation: jccolor.c:GETENV_S Unexecuted instantiation: jcinit.c:GETENV_S Unexecuted instantiation: jcmainct.c:GETENV_S Unexecuted instantiation: jcmarker.c:GETENV_S Unexecuted instantiation: jcmaster.c:GETENV_S Unexecuted instantiation: jcomapi.c:GETENV_S Unexecuted instantiation: jcparam.c:GETENV_S Unexecuted instantiation: jcphuff.c:GETENV_S Unexecuted instantiation: jcprepct.c:GETENV_S Unexecuted instantiation: jcsample.c:GETENV_S Unexecuted instantiation: jctrans.c:GETENV_S Unexecuted instantiation: jdapimin.c:GETENV_S Unexecuted instantiation: jdapistd.c:GETENV_S Unexecuted instantiation: jdinput.c:GETENV_S Unexecuted instantiation: jdmarker.c:GETENV_S Unexecuted instantiation: jdmaster.c:GETENV_S Unexecuted instantiation: jdmerge.c:GETENV_S Unexecuted instantiation: jdphuff.c:GETENV_S Unexecuted instantiation: jdpostct.c:GETENV_S Unexecuted instantiation: jdsample.c:GETENV_S Unexecuted instantiation: jdtrans.c:GETENV_S Unexecuted instantiation: jerror.c:GETENV_S Unexecuted instantiation: jquant1.c:GETENV_S Unexecuted instantiation: jquant2.c:GETENV_S Unexecuted instantiation: jutils.c:GETENV_S Line | Count | Source | 80 | 156k | { | 81 | 156k | char *env; | 82 | | | 83 | 156k | if (!buffer) { | 84 | 0 | if (buffer_size == 0) | 85 | 0 | return 0; | 86 | 0 | else | 87 | 0 | return (errno = EINVAL); | 88 | 0 | } | 89 | 156k | if (buffer_size == 0) | 90 | 0 | return (errno = EINVAL); | 91 | 156k | if (!name) { | 92 | 0 | *buffer = 0; | 93 | 0 | return 0; | 94 | 0 | } | 95 | | | 96 | 156k | env = getenv(name); | 97 | 156k | if (!env) | 98 | 156k | { | 99 | 156k | *buffer = 0; | 100 | 156k | return 0; | 101 | 156k | } | 102 | | | 103 | 0 | if (strlen(env) + 1 > buffer_size) { | 104 | 0 | *buffer = 0; | 105 | 0 | return ERANGE; | 106 | 0 | } | 107 | | | 108 | 0 | strncpy(buffer, env, buffer_size); | 109 | |
| 110 | 0 | return 0; | 111 | 0 | } |
Unexecuted instantiation: jmemnobs.c:GETENV_S Unexecuted instantiation: jcarith.c:GETENV_S Unexecuted instantiation: jdarith.c:GETENV_S Line | Count | Source | 80 | 4.28k | { | 81 | 4.28k | char *env; | 82 | | | 83 | 4.28k | if (!buffer) { | 84 | 0 | if (buffer_size == 0) | 85 | 0 | return 0; | 86 | 0 | else | 87 | 0 | return (errno = EINVAL); | 88 | 0 | } | 89 | 4.28k | if (buffer_size == 0) | 90 | 0 | return (errno = EINVAL); | 91 | 4.28k | if (!name) { | 92 | 0 | *buffer = 0; | 93 | 0 | return 0; | 94 | 0 | } | 95 | | | 96 | 4.28k | env = getenv(name); | 97 | 4.28k | if (!env) | 98 | 4.28k | { | 99 | 4.28k | *buffer = 0; | 100 | 4.28k | return 0; | 101 | 4.28k | } | 102 | | | 103 | 0 | if (strlen(env) + 1 > buffer_size) { | 104 | 0 | *buffer = 0; | 105 | 0 | return ERANGE; | 106 | 0 | } | 107 | | | 108 | 0 | strncpy(buffer, env, buffer_size); | 109 | |
| 110 | 0 | return 0; | 111 | 0 | } |
Unexecuted instantiation: jccoefct.c:GETENV_S Unexecuted instantiation: jcdctmgr.c:GETENV_S Unexecuted instantiation: jchuff.c:GETENV_S Unexecuted instantiation: jdcoefct.c:GETENV_S Unexecuted instantiation: jdcolor.c:GETENV_S Unexecuted instantiation: jddctmgr.c:GETENV_S Unexecuted instantiation: jdhuff.c:GETENV_S Unexecuted instantiation: jdmainct.c:GETENV_S Unexecuted instantiation: jfdctflt.c:GETENV_S Unexecuted instantiation: jfdctfst.c:GETENV_S Unexecuted instantiation: jfdctint.c:GETENV_S Unexecuted instantiation: jidctflt.c:GETENV_S Unexecuted instantiation: jidctfst.c:GETENV_S Unexecuted instantiation: jidctint.c:GETENV_S Unexecuted instantiation: jidctred.c:GETENV_S Unexecuted instantiation: jaricom.c:GETENV_S |
112 | | |
113 | | #endif /* _MSC_VER */ |
114 | | |
115 | | #endif /* NO_GETENV */ |
116 | | |
117 | | |
118 | | #ifndef NO_PUTENV |
119 | | |
120 | | #ifdef _WIN32 |
121 | | |
122 | | #define PUTENV_S(name, value) _putenv_s(name, value) |
123 | | |
124 | | #else |
125 | | |
126 | | /* This provides a similar interface to the Microsoft _putenv_s() function, but |
127 | | * other than parameter validation, it has no advantages over setenv(). |
128 | | */ |
129 | | |
130 | | static INLINE int PUTENV_S(const char *name, const char *value) |
131 | 0 | { |
132 | 0 | if (!name || !value) |
133 | 0 | return (errno = EINVAL); |
134 | | |
135 | 0 | setenv(name, value, 1); |
136 | |
|
137 | 0 | return errno; |
138 | 0 | } Unexecuted instantiation: turbojpeg.c:PUTENV_S Unexecuted instantiation: transupp.c:PUTENV_S Unexecuted instantiation: jdatadst-tj.c:PUTENV_S Unexecuted instantiation: jdatasrc-tj.c:PUTENV_S Unexecuted instantiation: rdbmp.c:PUTENV_S Unexecuted instantiation: rdppm.c:PUTENV_S Unexecuted instantiation: wrbmp.c:PUTENV_S Unexecuted instantiation: wrppm.c:PUTENV_S Unexecuted instantiation: jcapimin.c:PUTENV_S Unexecuted instantiation: jcapistd.c:PUTENV_S Unexecuted instantiation: jccolor.c:PUTENV_S Unexecuted instantiation: jcinit.c:PUTENV_S Unexecuted instantiation: jcmainct.c:PUTENV_S Unexecuted instantiation: jcmarker.c:PUTENV_S Unexecuted instantiation: jcmaster.c:PUTENV_S Unexecuted instantiation: jcomapi.c:PUTENV_S Unexecuted instantiation: jcparam.c:PUTENV_S Unexecuted instantiation: jcphuff.c:PUTENV_S Unexecuted instantiation: jcprepct.c:PUTENV_S Unexecuted instantiation: jcsample.c:PUTENV_S Unexecuted instantiation: jctrans.c:PUTENV_S Unexecuted instantiation: jdapimin.c:PUTENV_S Unexecuted instantiation: jdapistd.c:PUTENV_S Unexecuted instantiation: jdinput.c:PUTENV_S Unexecuted instantiation: jdmarker.c:PUTENV_S Unexecuted instantiation: jdmaster.c:PUTENV_S Unexecuted instantiation: jdmerge.c:PUTENV_S Unexecuted instantiation: jdphuff.c:PUTENV_S Unexecuted instantiation: jdpostct.c:PUTENV_S Unexecuted instantiation: jdsample.c:PUTENV_S Unexecuted instantiation: jdtrans.c:PUTENV_S Unexecuted instantiation: jerror.c:PUTENV_S Unexecuted instantiation: jquant1.c:PUTENV_S Unexecuted instantiation: jquant2.c:PUTENV_S Unexecuted instantiation: jutils.c:PUTENV_S Unexecuted instantiation: jmemmgr.c:PUTENV_S Unexecuted instantiation: jmemnobs.c:PUTENV_S Unexecuted instantiation: jcarith.c:PUTENV_S Unexecuted instantiation: jdarith.c:PUTENV_S Unexecuted instantiation: jsimd.c:PUTENV_S Unexecuted instantiation: jccoefct.c:PUTENV_S Unexecuted instantiation: jcdctmgr.c:PUTENV_S Unexecuted instantiation: jchuff.c:PUTENV_S Unexecuted instantiation: jdcoefct.c:PUTENV_S Unexecuted instantiation: jdcolor.c:PUTENV_S Unexecuted instantiation: jddctmgr.c:PUTENV_S Unexecuted instantiation: jdhuff.c:PUTENV_S Unexecuted instantiation: jdmainct.c:PUTENV_S Unexecuted instantiation: jfdctflt.c:PUTENV_S Unexecuted instantiation: jfdctfst.c:PUTENV_S Unexecuted instantiation: jfdctint.c:PUTENV_S Unexecuted instantiation: jidctflt.c:PUTENV_S Unexecuted instantiation: jidctfst.c:PUTENV_S Unexecuted instantiation: jidctint.c:PUTENV_S Unexecuted instantiation: jidctred.c:PUTENV_S Unexecuted instantiation: jaricom.c:PUTENV_S |
139 | | |
140 | | #endif /* _WIN32 */ |
141 | | |
142 | | #endif /* NO_PUTENV */ |
143 | | |
144 | | |
145 | | #endif /* JINCLUDE_H */ |