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
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.)
16 * NOTE: this file is NOT intended to be included by applications using the
17 * JPEG library. Most applications need only include jpeglib.h.
20 #ifndef __JINCLUDE_H__
21 #define __JINCLUDE_H__
23 /* Include auto-config file to find out which system include files we need. */
25 #include "jconfig.h" /* auto configuration options */
26 #include "jconfigint.h"
27 #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
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>.
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.
50 #define SNPRINTF(str, n, format, ...) \
51 _snprintf_s(str, n, _TRUNCATE, format, ##__VA_ARGS__)
55 #define SNPRINTF snprintf
64 static INLINE
int GETENV_S(char *buffer
, size_t buffer_size
, const char *name
)
68 return (int)getenv_s(&required_size
, buffer
, buffer_size
, name
);
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().
79 static INLINE
int GETENV_S(char *buffer
, size_t buffer_size
, const char *name
)
87 return (errno
= EINVAL
);
90 return (errno
= EINVAL
);
103 if (strlen(env
) + 1 > buffer_size
) {
108 strncpy(buffer
, env
, buffer_size
);
113 #endif /* _MSC_VER */
115 #endif /* NO_GETENV */
122 #define PUTENV_S(name, value) _putenv_s(name, value)
126 /* This provides a similar interface to the Microsoft _putenv_s() function, but
127 * other than parameter validation, it has no advantages over setenv().
130 static INLINE
int PUTENV_S(const char *name
, const char *value
)
133 return (errno
= EINVAL
);
135 setenv(name
, value
, 1);
142 #endif /* NO_PUTENV */
145 #endif /* JINCLUDE_H */