added chapter seperation.
[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 static unsigned short StoM(unsigned short inv) {
17     union iconv {
18         unsigned short    ui;
19         unsigned char   uc[2];
20     } *inp, outv;
21
22     inp = (union iconv *)&inv;
23
24     outv.uc[0] = inp->uc[1];
25     outv.uc[1] = inp->uc[0];
26  
27     return (outv.ui);
28 }
29
30 static unsigned int ItoM(unsigned int inv) {
31     union iconv {
32         unsigned int    ui;
33         unsigned char   uc[4];
34     } *inp, outv;
35
36     inp = (union iconv *)&inv;
37
38     outv.uc[0] = inp->uc[3];
39     outv.uc[1] = inp->uc[2];
40     outv.uc[2] = inp->uc[1];
41     outv.uc[3] = inp->uc[0];
42
43     return (outv.ui);
44 }
45
46 unsigned short ntohs(unsigned short inv) { return StoM(inv); }
47 unsigned long ntohl(unsigned long inv) { return ItoM(inv); }
48 unsigned long htonl(unsigned long inv) { return ItoM(inv); }
49
50 char *optarg;
51 int optind=1;
52
53 char getopt(int argc, char **argv, char *args) {
54         int n,nlen=strlen(args),nLen=0;
55         char nCmd;
56         
57         if (argv[optind] && *argv[optind]=='-') {
58                 nCmd=*((argv[optind]+1));
59
60                 for (n=0;n<nlen;n++) {
61                         if (args[n] == ':') continue;
62                         if (args[n] == nCmd) {
63                                 if (args[n+1]==':') {
64                                         char retVal;
65                                         retVal=*(argv[optind]+1);
66                                         optarg=argv[optind+1];
67                                         if (!optarg) optarg="";
68                                         optind+=2;
69                                         return retVal;
70                                 } else {
71                                         char retVal;
72                                         retVal=*(argv[optind]+1);
73                                         optarg=NULL;
74                                         optind+=1;
75                                         return retVal;
76                                 }
77                         }
78                 }       
79         }
80         return -1;
81 }
82
83 #else
84
85 unsigned short ntohs(unsigned short inv);
86 unsigned long ntohl(unsigned long inv);
87 unsigned long htonl(unsigned long inv);
88
89 extern char *optarg;
90 extern int optind;
91
92 char getopt(int argc, char **argv, char *args);
93 #endif