[21547] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
[21586] | 3 | OS2EMX_H=D:/Dev/gcc452/usr/include/os2emx.h
|
---|
[21547] | 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 |
|
---|
[21974] | 22 | #define OS2_WRAP_INCLUDED
|
---|
| 23 |
|
---|
[21547] | 24 | #ifdef WINVER
|
---|
| 25 | #error "os2wrap2.h must be included BEFORE any Windows include file!"
|
---|
| 26 | #endif
|
---|
| 27 |
|
---|
| 28 | #define os2__THUNK_PASCAL_FUNCTION (FUN) os2_APIENTRY _16_##FUN
|
---|
| 29 | #define os2_MAKE16P (sel,off) ((_far16ptr)((sel) << 16 | (off)))
|
---|
| 30 | #define os2_MAKEP (sel,off) _libc_16to32 ( os2_MAKE16P (sel, off))
|
---|
| 31 | #define os2_SELECTOROF (farptr) ((os2_SEL)((farptr) >> 16))
|
---|
| 32 | #define os2_OFFSETOF (farptr) ((os2_USHORT)(farptr))
|
---|
| 33 | #define os2__THUNK_PTR_SIZE_OK (ptr,size) \
|
---|
| 34 | (((os2_ULONG)(ptr) & ~0xffff) == (((os2_ULONG)(ptr) + (size) - 1) & ~0xffff))
|
---|
| 35 | ' > "$OS2WRAP2_H"
|
---|
| 36 |
|
---|
| 37 | #
|
---|
| 38 | # Redefine all OS/2 typedefs to those having the "os2_" prefix to avoid
|
---|
| 39 | # conflicts with Windows typedefs. Also define "os2_" versions of all
|
---|
| 40 | # macros. The defines are generated with the following command on the
|
---|
| 41 | # respective OS/2 headers:
|
---|
| 42 | #
|
---|
| 43 |
|
---|
[21969] | 44 | DefinePrefixes=\
|
---|
[21974] | 45 | 'BM|BN|BS|CBS|CF|CLR|CONTEXT|CREATE|CS|DDE|DLGC|DM|DT|EH|EM|EN|ERROR|ES|EXCEPTION|EXLST|FILE|FDM|FNTM|'\
|
---|
| 46 | 'HWND|LM|MB|MIA|MM|MSGF|NP|OBJ|PAG|QS|QSV|RGN|RT|SB|SBM|SBS|SC|SEM|SEVERITY|SIS|SS|STD|SV|SWP|SZDDESYS|TA|VK|'\
|
---|
[21969] | 47 | 'WC|WM|WS|XCPT|(WIN|GPI|DEV|SPL)ERR'
|
---|
| 48 |
|
---|
| 49 | Defines=\
|
---|
| 50 | 'ERRORID|NO_ERROR|PCMDMSG|SEL|HWND|MPARAM|MRESULT|LHANDLE|SHANDLE|BOOL|'\
|
---|
[21970] | 51 | 'ADDRESS|DRIVER_NAME|DRIVER_DATA|DATA_TYPE|COMMENT|PROC_NAME|'\
|
---|
| 52 | 'PROC_PARAMS|SPL_PARAMS|NETWORK_PARAMS|'\
|
---|
[21969] | 53 | '(CCH|MPFROM|MAKE)[A-Z0-9]+|'\
|
---|
| 54 | 'P?VOID|(API|EXP)ENTRY|P(CMD|CHR|MSE)MSG|'\
|
---|
| 55 | '(LO|HI|P)?U?(LONG|SHORT|CHAR|BYTE)'
|
---|
| 56 |
|
---|
[21547] | 57 | sed -nr '
|
---|
| 58 | {
|
---|
| 59 | s/^[[:space:]]*typedef[[:space:]]+struct[[:space:]]+([A-Za-z_][A-Za-z0-9_]+)([[:space:]]*[/]\*.*\*[/])?[[:space:]]*$/#define \1 os2_\1/p
|
---|
| 60 | td
|
---|
| 61 | s/^[[:space:]]*}[[:space:]]*([A-Z_][A-Z0-9_]+)[[:space:]]*;[[:space:]]*$/#define \1 os2_\1/p
|
---|
| 62 | td
|
---|
| 63 | s/^[[:space:]]*typedef[[:space:]]+.+[[:space:]]+\**([A-Z_][A-Z0-9_]+)[[:space:]]*(\[.*\])?[[:space:]]*;([[:space:]]*[/]\*.*\*[/])?[[:space:]]*$/#define \1 os2_\1/p
|
---|
| 64 | td
|
---|
| 65 | }
|
---|
| 66 | /^[[:space:]]*#define[[:space:]]+/ {
|
---|
| 67 | :a;/\\$/{N;ba}
|
---|
| 68 | s/([^A-Za-z0-9_])(MAKE[A-Z0-9]+)([^A-Za-z0-9_])/\1 \2 \3/g
|
---|
[21969] | 69 | s/([^A-Za-z0-9_])((('$DefinePrefixes')_([A-Z0-9_]+))|(('$Defines')([^A-Za-z0-9_])))/\1os2_\2/g
|
---|
[21547] | 70 | tb;bd
|
---|
| 71 | :b
|
---|
[21548] | 72 | s/^[[:space:]]*#define[[:space:]]+((Dos|Win|Gpi)[A-Za-z_][A-Za-z0-9_]+)([[:space:](].*)//
|
---|
[21547] | 73 | s/^[[:space:]]*#define[[:space:]]+(os2_)?([A-Za-z_][A-Za-z0-9_]+)[[:space:]]*(.*)/#define os2_\2 \3/p
|
---|
| 74 | }
|
---|
| 75 | :d
|
---|
| 76 | ' < "$OS2EMX_H" >> "$OS2WRAP2_H"
|
---|
| 77 |
|
---|
| 78 | #
|
---|
| 79 | # Fixed middle
|
---|
| 80 | #
|
---|
| 81 |
|
---|
| 82 | echo \
|
---|
| 83 | '
|
---|
| 84 | /* include the main OS/2 API wrapper */
|
---|
| 85 | #include <os2wrap.h>
|
---|
| 86 |
|
---|
| 87 | #undef _THUNK_PASCAL_FUNCTION
|
---|
| 88 | #undef MAKE16P
|
---|
| 89 | #undef MAKEP
|
---|
| 90 | #undef SELECTOROF
|
---|
| 91 | #undef OFFSETOF
|
---|
| 92 | #undef _THUNK_PTR_SIZE_OK
|
---|
| 93 | ' >> "$OS2WRAP2_H"
|
---|
| 94 |
|
---|
| 95 | #
|
---|
| 96 | # Undefine all typedefs prefixed with "os2_" at the beginning and original
|
---|
| 97 | # versions of macros. The command to generate this block is:
|
---|
| 98 | #
|
---|
| 99 |
|
---|
| 100 | sed -nr '
|
---|
| 101 | {
|
---|
| 102 | s/^[[:space:]]*typedef[[:space:]]+struct[[:space:]]+([A-Za-z_][A-Za-z0-9_]+)([[:space:]]*[/]\*.*\*[/])?[[:space:]]*$/#undef \1/p
|
---|
| 103 | td
|
---|
| 104 | s/^[[:space:]]*}[[:space:]]*([A-Z_][A-Z0-9_]+)[[:space:]]*;[[:space:]]*$/#undef \1/p
|
---|
| 105 | td
|
---|
| 106 | s/^[[:space:]]*typedef[[:space:]]+.+[[:space:]]+\**([A-Z_][A-Z0-9_]+)[[:space:]]*(\[.*\])?[[:space:]]*;([[:space:]]*[/]\*.*\*[/])?[[:space:]]*$/#undef \1/p
|
---|
| 107 | td
|
---|
| 108 | }
|
---|
| 109 | /^[[:space:]]*#define[[:space:]]+/ {
|
---|
| 110 | :a;/\\$/{N;ba}
|
---|
| 111 | s/([^A-Za-z0-9_])(MAKE[A-Z0-9]+)([^A-Za-z0-9_])/\1 \2 \3/g
|
---|
[21969] | 112 | s/([^A-Za-z0-9_])((('$DefinePrefixes')_([A-Z0-9_]+))|(('$Defines')([^A-Za-z0-9_])))/\1os2_\2/g
|
---|
[21547] | 113 | tb;bd
|
---|
| 114 | :b
|
---|
[21548] | 115 | s/^[[:space:]]*#define[[:space:]]+((Dos|Win|Gpi)[A-Za-z_][A-Za-z0-9_]+)([[:space:](].*)/#undef \1\
|
---|
| 116 | #define \1\3/p
|
---|
[21547] | 117 | s/^[[:space:]]*#define[[:space:]]+(os2_)?([A-Za-z_][A-Za-z0-9_]+)[[:space:]]*(.*)/#undef \2/p
|
---|
| 118 | }
|
---|
| 119 | :d
|
---|
| 120 | ' < "$OS2EMX_H" >> "$OS2WRAP2_H"
|
---|
| 121 |
|
---|
| 122 | #
|
---|
| 123 | # Fixed footer
|
---|
| 124 | #
|
---|
| 125 |
|
---|
| 126 | echo \
|
---|
| 127 | '
|
---|
| 128 | #endif /* __OS2WRAP2_H__ */
|
---|
| 129 | ' >> "$OS2WRAP2_H"
|
---|