blob: b6b081beaafa9373bca57d162e8eb12da65c1284 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#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
45typedef char CHAR;
46typedef unsigned char BYTE;
47typedef short SHORT;
48typedef unsigned short WORD;
49typedef int INT;
50typedef unsigned int UINT;
51typedef long LONG;
52typedef unsigned long DWORD;
53typedef enum { FALSE = 0, TRUE = 1 } BOOL;
54
55typedef png_color PALETTE;
56typedef 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
73extern int quietmode;
74extern int errorlog;
75extern const char errlogfile[];
76
77void xxprintf(const char *, ...);
78void set_status(const char *, ...);
79void feed_line(void);
80void init_progress_meter(png_structp, png_uint_32, png_uint_32);
81void row_callback(png_structp, png_uint_32, int);
82
83FILE *binary_stdio(int);
84char *suffix(const char *);
85char *basname(const char *);
86char *addslash(char *);
87char *delslash(char *);
88char *path_skiproot(const char *);
89char *path_nextslash(const char *);
90
91void png_my_error(png_structp, png_const_charp);
92void png_my_warning(png_structp, png_const_charp);
93BOOL imgbuf_alloc(IMAGE *);
94void imgbuf_free(IMAGE *);
95void imgbuf_init(IMAGE *);
96int parsearg(int *, char **, int, char **, char *);
97char **envargv(int *, char ***, const char *);
98int tokenize(char *, const char *);
99int makedir(const char *);
100int renbak(const char *);
101int cpyftime(const char *, const char *);
102
103
104#endif /* COMMON_H */