yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | #ifndef COMMON_H |
| 2 | #define COMMON_H |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <string.h> |
| 7 | #include <ctype.h> |
| 8 | #include <stdarg.h> |
| 9 | |
| 10 | #include <utime.h> |
| 11 | #include <unistd.h> |
| 12 | |
| 13 | #include <sys/types.h> |
| 14 | #include <sys/stat.h> |
| 15 | #include "png.h" |
| 16 | |
| 17 | #define MKDIR(d,m) mkdir(d,m) |
| 18 | |
| 19 | #if (PNG_LIBPNG_VER < 10004) |
| 20 | # error libpng version 1.0.4 or later is required. |
| 21 | #endif |
| 22 | |
| 23 | #if (PNG_LIBPNG_VER == 10207) || (PNG_LIBPNG_VER == 10206) || \ |
| 24 | (PNG_LIBPNG_VER == 10017) || (PNG_LIBPNG_VER == 10016) |
| 25 | # error Libpng versions 1.2.7, 1.2.6, 1.0.17, and 1.0.16 |
| 26 | # error have a bug that will cause png2bmp to crash. |
| 27 | # error Update your libpng to latest version. |
| 28 | # error "http://www.libpng.org/pub/png/libpng.html" |
| 29 | #endif |
| 30 | |
| 31 | #if !defined(PNG_READ_tRNS_SUPPORTED) || !defined(PNG_WRITE_tRNS_SUPPORTED) |
| 32 | # error This software requires tRNS chunk support. |
| 33 | #endif |
| 34 | |
| 35 | #ifndef png_jmpbuf /* pngconf.h (libpng 1.0.6 or later) */ |
| 36 | # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) |
| 37 | #endif |
| 38 | |
| 39 | |
| 40 | #define PATHDELIM '/' |
| 41 | #define IsPathDelim(c) ((c)==PATHDELIM) |
| 42 | #define IsOptChar(c) ((c)=='-') |
| 43 | #define IsDBCSLead(c) (0) |
| 44 | |
| 45 | typedef char CHAR; |
| 46 | typedef unsigned char BYTE; |
| 47 | typedef short SHORT; |
| 48 | typedef unsigned short WORD; |
| 49 | typedef int INT; |
| 50 | typedef unsigned int UINT; |
| 51 | typedef long LONG; |
| 52 | typedef unsigned long DWORD; |
| 53 | typedef enum { FALSE = 0, TRUE = 1 } BOOL; |
| 54 | |
| 55 | typedef png_color PALETTE; |
| 56 | typedef struct tagIMAGE { |
| 57 | LONG width; |
| 58 | LONG height; |
| 59 | UINT pixdepth; |
| 60 | UINT palnum; |
| 61 | BOOL topdown; |
| 62 | BOOL alpha; |
| 63 | /* ----------- */ |
| 64 | DWORD rowbytes; |
| 65 | DWORD imgbytes; |
| 66 | PALETTE *palette; |
| 67 | BYTE **rowptr; |
| 68 | BYTE *bmpbits; |
| 69 | /* ----------- */ |
| 70 | png_color_8 sigbit; |
| 71 | } IMAGE; |
| 72 | |
| 73 | extern int quietmode; |
| 74 | extern int errorlog; |
| 75 | extern const char errlogfile[]; |
| 76 | |
| 77 | void xxprintf(const char *, ...); |
| 78 | void set_status(const char *, ...); |
| 79 | void feed_line(void); |
| 80 | void init_progress_meter(png_structp, png_uint_32, png_uint_32); |
| 81 | void row_callback(png_structp, png_uint_32, int); |
| 82 | |
| 83 | FILE *binary_stdio(int); |
| 84 | char *suffix(const char *); |
| 85 | char *basname(const char *); |
| 86 | char *addslash(char *); |
| 87 | char *delslash(char *); |
| 88 | char *path_skiproot(const char *); |
| 89 | char *path_nextslash(const char *); |
| 90 | |
| 91 | void png_my_error(png_structp, png_const_charp); |
| 92 | void png_my_warning(png_structp, png_const_charp); |
| 93 | BOOL imgbuf_alloc(IMAGE *); |
| 94 | void imgbuf_free(IMAGE *); |
| 95 | void imgbuf_init(IMAGE *); |
| 96 | int parsearg(int *, char **, int, char **, char *); |
| 97 | char **envargv(int *, char ***, const char *); |
| 98 | int tokenize(char *, const char *); |
| 99 | int makedir(const char *); |
| 100 | int renbak(const char *); |
| 101 | int cpyftime(const char *, const char *); |
| 102 | |
| 103 | |
| 104 | #endif /* COMMON_H */ |