1 | #!/bin/sh
|
---|
2 |
|
---|
3 | OS2EMX_H=D:/Dev/gcc452/usr/include/os2emx.h
|
---|
4 | OS2WRAP2_H=os2wrap2.h.new
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Fixed header
|
---|
8 | #
|
---|
9 |
|
---|
10 | echo \
|
---|
11 | '/*
|
---|
12 | * A full version of os2wrap.h that prefixes all OS/2 type and constant
|
---|
13 | * definitions with "os2_" which makes it possible to use the OS/2 APIs
|
---|
14 | * from the same source files that use the Windows APIs.
|
---|
15 | *
|
---|
16 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __OS2WRAP2_H__
|
---|
20 | #define __OS2WRAP2_H__
|
---|
21 |
|
---|
22 | #ifdef WINVER
|
---|
23 | #error "os2wrap2.h must be included BEFORE any Windows include file!"
|
---|
24 | #endif
|
---|
25 |
|
---|
26 | #define os2__THUNK_PASCAL_FUNCTION (FUN) os2_APIENTRY _16_##FUN
|
---|
27 | #define os2_MAKE16P (sel,off) ((_far16ptr)((sel) << 16 | (off)))
|
---|
28 | #define os2_MAKEP (sel,off) _libc_16to32 ( os2_MAKE16P (sel, off))
|
---|
29 | #define os2_SELECTOROF (farptr) ((os2_SEL)((farptr) >> 16))
|
---|
30 | #define os2_OFFSETOF (farptr) ((os2_USHORT)(farptr))
|
---|
31 | #define os2__THUNK_PTR_SIZE_OK (ptr,size) \
|
---|
32 | (((os2_ULONG)(ptr) & ~0xffff) == (((os2_ULONG)(ptr) + (size) - 1) & ~0xffff))
|
---|
33 | ' > "$OS2WRAP2_H"
|
---|
34 |
|
---|
35 | #
|
---|
36 | # Redefine all OS/2 typedefs to those having the "os2_" prefix to avoid
|
---|
37 | # conflicts with Windows typedefs. Also define "os2_" versions of all
|
---|
38 | # macros. The defines are generated with the following command on the
|
---|
39 | # respective OS/2 headers:
|
---|
40 | #
|
---|
41 |
|
---|
42 | DefinePrefixes=\
|
---|
43 | 'BM|CLR|CONTEXT|CREATE|CS|DM|DT|EH|ERROR|EXCEPTION|EXLST|FILE|FDM|FNTM|'\
|
---|
44 | 'HWND|LM|MB|MIA|MM|NP|OBJ|PAG|QS|QSV|RGN|RT|SEM|SEVERITY|SIS|SV|SWP|TA|'\
|
---|
45 | 'WC|WM|WS|XCPT|(WIN|GPI|DEV|SPL)ERR'
|
---|
46 |
|
---|
47 | Defines=\
|
---|
48 | 'ERRORID|NO_ERROR|PCMDMSG|SEL|HWND|MPARAM|MRESULT|LHANDLE|SHANDLE|BOOL|'\
|
---|
49 | '(CCH|MPFROM|MAKE)[A-Z0-9]+|'\
|
---|
50 | 'P?VOID|(API|EXP)ENTRY|P(CMD|CHR|MSE)MSG|'\
|
---|
51 | '(LO|HI|P)?U?(LONG|SHORT|CHAR|BYTE)'
|
---|
52 |
|
---|
53 | sed -nr '
|
---|
54 | {
|
---|
55 | s/^[[:space:]]*typedef[[:space:]]+struct[[:space:]]+([A-Za-z_][A-Za-z0-9_]+)([[:space:]]*[/]\*.*\*[/])?[[:space:]]*$/#define \1 os2_\1/p
|
---|
56 | td
|
---|
57 | s/^[[:space:]]*}[[:space:]]*([A-Z_][A-Z0-9_]+)[[:space:]]*;[[:space:]]*$/#define \1 os2_\1/p
|
---|
58 | td
|
---|
59 | s/^[[:space:]]*typedef[[:space:]]+.+[[:space:]]+\**([A-Z_][A-Z0-9_]+)[[:space:]]*(\[.*\])?[[:space:]]*;([[:space:]]*[/]\*.*\*[/])?[[:space:]]*$/#define \1 os2_\1/p
|
---|
60 | td
|
---|
61 | }
|
---|
62 | /^[[:space:]]*#define[[:space:]]+/ {
|
---|
63 | :a;/\\$/{N;ba}
|
---|
64 | s/([^A-Za-z0-9_])(MAKE[A-Z0-9]+)([^A-Za-z0-9_])/\1 \2 \3/g
|
---|
65 | s/([^A-Za-z0-9_])((('$DefinePrefixes')_([A-Z0-9_]+))|(('$Defines')([^A-Za-z0-9_])))/\1os2_\2/g
|
---|
66 | tb;bd
|
---|
67 | :b
|
---|
68 | s/^[[:space:]]*#define[[:space:]]+((Dos|Win|Gpi)[A-Za-z_][A-Za-z0-9_]+)([[:space:](].*)//
|
---|
69 | s/^[[:space:]]*#define[[:space:]]+(os2_)?([A-Za-z_][A-Za-z0-9_]+)[[:space:]]*(.*)/#define os2_\2 \3/p
|
---|
70 | }
|
---|
71 | :d
|
---|
72 | ' < "$OS2EMX_H" >> "$OS2WRAP2_H"
|
---|
73 |
|
---|
74 | #
|
---|
75 | # Fixed middle
|
---|
76 | #
|
---|
77 |
|
---|
78 | echo \
|
---|
79 | '
|
---|
80 | /* include the main OS/2 API wrapper */
|
---|
81 | #include <os2wrap.h>
|
---|
82 |
|
---|
83 | #undef _THUNK_PASCAL_FUNCTION
|
---|
84 | #undef MAKE16P
|
---|
85 | #undef MAKEP
|
---|
86 | #undef SELECTOROF
|
---|
87 | #undef OFFSETOF
|
---|
88 | #undef _THUNK_PTR_SIZE_OK
|
---|
89 | ' >> "$OS2WRAP2_H"
|
---|
90 |
|
---|
91 | #
|
---|
92 | # Undefine all typedefs prefixed with "os2_" at the beginning and original
|
---|
93 | # versions of macros. The command to generate this block is:
|
---|
94 | #
|
---|
95 |
|
---|
96 | sed -nr '
|
---|
97 | {
|
---|
98 | s/^[[:space:]]*typedef[[:space:]]+struct[[:space:]]+([A-Za-z_][A-Za-z0-9_]+)([[:space:]]*[/]\*.*\*[/])?[[:space:]]*$/#undef \1/p
|
---|
99 | td
|
---|
100 | s/^[[:space:]]*}[[:space:]]*([A-Z_][A-Z0-9_]+)[[:space:]]*;[[:space:]]*$/#undef \1/p
|
---|
101 | td
|
---|
102 | s/^[[:space:]]*typedef[[:space:]]+.+[[:space:]]+\**([A-Z_][A-Z0-9_]+)[[:space:]]*(\[.*\])?[[:space:]]*;([[:space:]]*[/]\*.*\*[/])?[[:space:]]*$/#undef \1/p
|
---|
103 | td
|
---|
104 | }
|
---|
105 | /^[[:space:]]*#define[[:space:]]+/ {
|
---|
106 | :a;/\\$/{N;ba}
|
---|
107 | s/([^A-Za-z0-9_])(MAKE[A-Z0-9]+)([^A-Za-z0-9_])/\1 \2 \3/g
|
---|
108 | s/([^A-Za-z0-9_])((('$DefinePrefixes')_([A-Z0-9_]+))|(('$Defines')([^A-Za-z0-9_])))/\1os2_\2/g
|
---|
109 | tb;bd
|
---|
110 | :b
|
---|
111 | s/^[[:space:]]*#define[[:space:]]+((Dos|Win|Gpi)[A-Za-z_][A-Za-z0-9_]+)([[:space:](].*)/#undef \1\
|
---|
112 | #define \1\3/p
|
---|
113 | s/^[[:space:]]*#define[[:space:]]+(os2_)?([A-Za-z_][A-Za-z0-9_]+)[[:space:]]*(.*)/#undef \2/p
|
---|
114 | }
|
---|
115 | :d
|
---|
116 | ' < "$OS2EMX_H" >> "$OS2WRAP2_H"
|
---|
117 |
|
---|
118 | #
|
---|
119 | # Fixed footer
|
---|
120 | #
|
---|
121 |
|
---|
122 | echo \
|
---|
123 | '
|
---|
124 | #endif /* __OS2WRAP2_H__ */
|
---|
125 | ' >> "$OS2WRAP2_H"
|
---|