summaryrefslogtreecommitdiff
path: root/dviware/dvitops/util.h
blob: e63b605a5302e6a2d62c4ec5b2b5da6ef404a5e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* $Header: /usr/jjc/dvitops/RCS/util.h,v 1.7 90/10/16 07:53:45 jjc Exp $  */
 
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <errno.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif /* HAVE_MEMORY_H */
 
#include "config.h"

#ifndef DPI
#define DPI 300
#endif

#ifdef EBCDIC
#define XCHAR atoe
#endif

#ifdef XCHAR
#define STRXCHAR(s) { char *p_; \
for (p_ = s; *p_ != '\0'; p_++) *p_ = XCHAR(*p_); }
#else
#define STRXCHAR(s) /* as nothing */
#endif

#ifndef XCHAR
#define XCHAR(c) (c)
#endif

#ifndef FOPEN_RB
#define FOPEN_RB(file) (fopen((file), "r"))
#endif

#ifndef NORMAL_EXIT_CODE
#define NORMAL_EXIT_CODE 0
#endif

#ifndef WARNING_EXIT_CODE
#define WARNING_EXIT_CODE 1
#endif

#ifndef ERROR_EXIT_CODE
#define ERROR_EXIT_CODE 2
#endif

#ifndef FATAL_ERROR_EXIT_CODE
#define FATAL_ERROR_EXIT_CODE 3
#endif

#ifdef BROKEN_PROTO
#ifndef PROTO
#define PROTO
#endif
#define PROMOTED_UNSIGNED_CHAR unsigned char
#else
#define PROMOTED_UNSIGNED_CHAR int
#endif

#ifdef STDARG
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif
#ifdef PROTO
int abs(int);
char *getenv(char *);
int atoi(const char *);
long atol(const char *);
char *calloc(size_t, size_t);
void exit(int);
void free(char *);
char *getenv(char *);
char *malloc(size_t);
void qsort(char *, int, int, int (*)());
char *realloc(char *, size_t);
double atof(const char *);
int getopt(int argc, char **argv, char *opts);
FILE *xfopen(char *filename, int is_binary, char *area_list,
char *extension);
#ifdef NEED_MEM_FUNCTIONS
int memcmp(char *, char *, int);
char *memcpy(char *, char *, int);
char *memset(char *, int, int);
#endif /* NEED_MEM_FUNCTIONS */
time_t time(time_t *);
#ifdef NEED_STRTOK
char *strtok(char *, char *);
#endif
#ifdef CASE_INSENSITIVE_FILENAMES
int stricmp(char *, char *);
#endif
#else
int abs();
char *getenv();
double atof();
int atoi();
long atol();
char *calloc();
void exit();
void free();
char *getenv();
char *malloc();
void qsort();
char *realloc();
double atof();
long atol();
int getopt();
FILE *xfopen();
#ifdef NEED_MEM_FUNCTIONS
int memcmp();
char *memcpy();
char *memset();
#endif /* NEED_MEM_FUNCTIONS */
void qsort();
time_t time();
#ifdef NEED_STRTOK
char *strtok();
#endif
#ifdef CASE_INSENSITIVE_FILENAMES
int stricmp();
#endif
#endif

extern int opterr;
extern int optind;
extern int optopt;
extern char *optarg;
 
#define TRUE 1
#define FALSE 0

#ifdef __FILE__
#define cant_happen() message(FATAL_ERROR, "internal error: %s, line %d",\
__FILE__, __LINE__)
#else
#define cant_happen() message(FATAL_ERROR, "internal error")
#endif 

#define out_of_memory() message(FATAL_ERROR, "out of memory")

enum message_type {INFORMATION = 0, WARNING = 1, ERROR = 2, FATAL_ERROR = 3 };

extern enum message_type history;
extern char *program_name;

#ifdef STDARG
void message(enum message_type, char *,...);
#else
void message();
#endif