fixed error handling for missing zlib.
[swftools.git] / pdf2swf / ttf2pt1 / win_missing.h
1 /*
2  * Implementation of things missing in Windows
3  */
4
5 #ifndef M_PI
6 #define M_PI  3.14159265358979323846
7 #endif
8
9 #undef ntohs
10 #undef ntohl
11 #undef htonl
12
13 #ifdef WINDOWS_FUNCTIONS
14 /* byte order */
15
16 char *optarg;
17 int optind=1;
18
19 char getopt(int argc, char **argv, char *args) {
20         int n,nlen=strlen(args),nLen=0;
21         char nCmd;
22         
23         if (argv[optind] && *argv[optind]=='-') {
24                 nCmd=*((argv[optind]+1));
25
26                 for (n=0;n<nlen;n++) {
27                         if (args[n] == ':') continue;
28                         if (args[n] == nCmd) {
29                                 if (args[n+1]==':') {
30                                         char retVal;
31                                         retVal=*(argv[optind]+1);
32                                         optarg=argv[optind+1];
33                                         if (!optarg) optarg="";
34                                         optind+=2;
35                                         return retVal;
36                                 } else {
37                                         char retVal;
38                                         retVal=*(argv[optind]+1);
39                                         optarg=NULL;
40                                         optind+=1;
41                                         return retVal;
42                                 }
43                         }
44                 }       
45         }
46         return -1;
47 }
48
49 #else
50
51 unsigned short ntohs(unsigned short inv);
52 unsigned long ntohl(unsigned long inv);
53 unsigned long htonl(unsigned long inv);
54
55 extern char *optarg;
56 extern int optind;
57
58 char getopt(int argc, char **argv, char *args);
59 #endif