Clean up private header.

This commit is contained in:
Michael R Sweet 2023-10-02 05:27:40 -04:00
parent a83f7f50ff
commit 87ca4db73f
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244

View File

@ -1,7 +1,7 @@
// //
// Private header file for PDFio. // Private header file for PDFio.
// //
// Copyright © 2021-2022 by Michael R Sweet. // Copyright © 2021-2023 by Michael R Sweet.
// //
// Licensed under Apache License v2.0. See the file "LICENSE" for more // Licensed under Apache License v2.0. See the file "LICENSE" for more
// information. // information.
@ -10,18 +10,12 @@
#ifndef PDFIO_PRIVATE_H #ifndef PDFIO_PRIVATE_H
# define PDFIO_PRIVATE_H # define PDFIO_PRIVATE_H
//
// Include necessary headers...
//
# ifdef _WIN32 # ifdef _WIN32
/* # define _CRT_SECURE_NO_WARNINGS // Disable bogus VS warnings/errors...
* Disable bogus VS warnings/errors...
*/
# define _CRT_SECURE_NO_WARNINGS
# endif // _WIN32 # endif // _WIN32
# include "pdfio.h" # include "pdfio.h"
# include <stdarg.h> # include <stdarg.h>
# include <stdint.h> # include <stdint.h>
@ -32,18 +26,7 @@
# ifdef _WIN32 # ifdef _WIN32
# include <io.h> # include <io.h>
# include <direct.h> # include <direct.h>
# define access _access // Map standard POSIX/C99 names
/*
* Microsoft renames the POSIX functions to _name, and introduces
* a broken compatibility layer using the original names. As a result,
* random crashes can occur when, for example, strdup() allocates memory
* from a different heap than used by malloc() and free().
*
* To avoid moronic problems like this, we #define the POSIX function
* names to the corresponding non-standard Microsoft names.
*/
# define access _access
# define close _close # define close _close
# define fileno _fileno # define fileno _fileno
# define lseek _lseek # define lseek _lseek
@ -56,12 +39,7 @@
# define unlink _unlink # define unlink _unlink
# define vsnprintf _vsnprintf # define vsnprintf _vsnprintf
# define write _write # define write _write
# define F_OK 00 // POSIX parameters/flags
/*
* Map various parameters for POSIX...
*/
# define F_OK 00
# define W_OK 02 # define W_OK 02
# define R_OK 04 # define R_OK 04
# define O_RDONLY _O_RDONLY # define O_RDONLY _O_RDONLY
@ -71,7 +49,7 @@
# define O_BINARY _O_BINARY # define O_BINARY _O_BINARY
# else // !_WIN32 # else // !_WIN32
# include <unistd.h> # include <unistd.h>
# define O_BINARY 0 # define O_BINARY 0 // Used on Windows for binary files...
# endif // _WIN32 # endif // _WIN32
# include <string.h> # include <string.h>
# include <ctype.h> # include <ctype.h>
@ -411,4 +389,5 @@ extern void _pdfioValueDelete(_pdfio_value_t *v) _PDFIO_INTERNAL;
extern _pdfio_value_t *_pdfioValueRead(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_token_t *ts, _pdfio_value_t *v, size_t depth) _PDFIO_INTERNAL; extern _pdfio_value_t *_pdfioValueRead(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_token_t *ts, _pdfio_value_t *v, size_t depth) _PDFIO_INTERNAL;
extern bool _pdfioValueWrite(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_value_t *v, off_t *length) _PDFIO_INTERNAL; extern bool _pdfioValueWrite(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_value_t *v, off_t *length) _PDFIO_INTERNAL;
#endif // !PDFIO_PRIVATE_H #endif // !PDFIO_PRIVATE_H