Implement JPEG image object support.

This commit is contained in:
Michael R Sweet
2021-05-25 16:31:32 -04:00
parent eb4477ce9b
commit 128d5f0d42
2 changed files with 282 additions and 6 deletions

View File

@ -18,8 +18,51 @@
# include <stdarg.h>
# include <errno.h>
# include <inttypes.h>
# include <fcntl.h>
# include <unistd.h>
# ifdef _WIN32
# include <io.h>
# include <direct.h>
/*
* 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 fileno _fileno
# define lseek _lseek
# define mkdir(d,p) _mkdir(d)
# define open _open
# define read _read
# define rmdir _rmdir
# define snprintf _snprintf
# define strdup _strdup
# define unlink _unlink
# define vsnprintf _vsnprintf
# define write _write
/*
* Map various parameters for POSIX...
*/
# define F_OK 00
# define W_OK 02
# define R_OK 04
# define O_RDONLY _O_RDONLY
# define O_WRONLY _O_WRONLY
# define O_CREAT _O_CREAT
# define O_TRUNC _O_TRUNC
# define O_BINARY _O_BINARY
# else // !_WIN32
# include <fcntl.h>
# include <unistd.h>
# define O_BINARY 0
# endif // _WIN32
# include <string.h>
# include <ctype.h>
# include <zlib.h>