Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

275 lines
9.1 KiB

  1. /* -------------------------------------------------------------------------
  2. Test: OSUTIL
  3. Copyright (C) 1991, Microsoft Corporation
  4. Component: OLE Programmability
  5. Major Area: Type Information Interface
  6. Sub Area: ITypeInfo
  7. Test Area:
  8. Keyword: Win32
  9. ---------------------------------------------------------------------------
  10. Purpose: constants for programs that run under Win32
  11. Scenarios:
  12. Abstract:
  13. ---------------------------------------------------------------------------
  14. Category:
  15. Product:
  16. Related Files:
  17. Notes: There are three different settings that must be covered by
  18. the library:
  19. OS OLE Automation
  20. 1. UNICODE OAU (UNICODE)
  21. 2. ANSI OAU
  22. 3. ANSI ASNI
  23. When OAU is specified at compile-time; all strings are
  24. defined as UNICODE string regardless the OS.
  25. ---------------------------------------------------------------------------
  26. Revision History:
  27. [ 0] 09-Mar-1993 Angelach: Created Test
  28. [ 1] 10-Mar-1994 Angelach: added support to Win32s
  29. [ 2] 24-May-1994 Angelach: added support to diff
  30. machines
  31. [ 3] 06-Jul-1994 Angelach: added support for remoting
  32. typelib testing
  33. [ 4] 27-Oct-1994 Angelach: added LCMapStringX
  34. [ 5] 19-Oct-1994 Angelach: added RegEnumKeyX &
  35. RegDeleteKeyX for Win32s
  36. [ 6] 06-Mar-1995 Angelach: added support for network
  37. [ 7] 07-Mar-1995 Angelach: added Memory-leak detection
  38. --------------------------------------------------------------------------
  39. */
  40. #include <windows.h>
  41. //#define OAU // OLE Automation is Unicode
  42. #ifndef FAR
  43. #define FAR
  44. #endif
  45. #define EXPORT
  46. #define _NEWCTYPETABLE // specifies to use the wide
  47. // char type table
  48. #undef VOID // windows.h #defines these
  49. #undef LONG // but ole2.h typedef's them
  50. typedef void VOID ;
  51. typedef int BOOL ;
  52. typedef short SHORT ;
  53. typedef int INT ;
  54. typedef long LONG ;
  55. typedef unsigned char BYTE ;
  56. typedef unsigned short WORD ;
  57. typedef unsigned long DWORD ;
  58. typedef unsigned short USHORT ;
  59. typedef unsigned int UINT ;
  60. typedef unsigned long ULONG ;
  61. typedef char CHAR ;
  62. typedef CHAR FAR * LPSTR ;
  63. typedef VOID FAR * LPVOID ;
  64. #define LPSIZE LPVOID
  65. #define LPRECT LPVOID
  66. #define LPLOGPALETTE LPVOID
  67. #define Byte BYTE
  68. #define fLockType BOOL // [3]
  69. #include <malloc.h>
  70. #include <stdio.h>
  71. #include <stdlib.h>
  72. #include <ole2.h>
  73. //#include <dispatch.h>
  74. #include "apglobal.h"
  75. #ifdef DEBUG
  76. #include "cmallspy.h" // [7]
  77. #endif
  78. #ifdef OAU // UNICODE string; all strings [1]
  79. // are UNICODE string regardless
  80. #define CreateTypeLibX CreateTypeLib // what the OS uses
  81. #define LHashValOfNameX LHashValOfName // select an interface and [1]
  82. #define LHashValOfNameSysX LHashValOfNameSys // and support functions
  83. #define LoadRegTypeLibX LoadRegTypeLib
  84. #define LoadTypeLibX(path, pptlb) LoadTypeLibEx(path, REGKIND_NONE, pptlb)
  85. #define RegisterTypeLibX RegisterTypeLib
  86. #define ICreateTypeInfoX ICreateTypeInfo
  87. #define ICreateTypeLibX ICreateTypeLib
  88. #define ITypeInfoX ITypeInfo
  89. #define ITypeLibX ITypeLib
  90. #define ITypeCompX ITypeComp
  91. #define BINDPTRX BINDPTR
  92. #define VARDESCX VARDESC
  93. #define VARIANTX VARIANT
  94. #define IID_ITypeInfoX IID_ITypeInfo
  95. #define BSTRX BSTR
  96. #define CompareStringX CompareStringW
  97. #define CreateFileMonikerX CreateFileMoniker // [3]
  98. #define CLSIDFromStringX CLSIDFromString
  99. #define IIDFromStringX IIDFromString
  100. #define RegOpenKeyX RegOpenKeyW // [3]
  101. #define StgCreateDocfileX StgCreateDocfile
  102. #define SysAllocStringX SysAllocString
  103. #define SysFreeStringX SysFreeString
  104. #define VariantInitX VariantInit
  105. FILE * fopenX (XCHAR *, XCHAR *) ;
  106. int fputsX (XCHAR *, FILE *) ;
  107. #ifdef UNICODE // UNICODE
  108. #define osKillFile DeleteFile // if system is also using
  109. #define osRmDir RemoveDirectory // UNICODE strings
  110. #define LCMapStringX LCMapStringW // [4]
  111. #define RegEnumKeyX RegEnumKeyW // [3] [5]
  112. #define RegDeleteKeyX RegDeleteKeyW // [5]
  113. #else // UNICODE
  114. // if the system is using ANSI,
  115. int osKillFile (XCHAR *) ; // need to convert strings to
  116. int osRmDir (XCHAR *) ; // ANSI before making system call
  117. int LCMapStringX (LCID, DWORD, LPXSTR, int, LPXSTR, int) ; // [4]
  118. long RegEnumKeyX (HKEY, DWORD, LPXSTR, DWORD) ;// [3] [5]
  119. long RegDeleteKeyX(HKEY, LPXSTR) ; // [5]
  120. #endif // UNICODE
  121. #else // OAU
  122. // ANSI strings
  123. #include "ole2ansi.h"
  124. #include "dispansi.h"
  125. #define CreateTypeLibX CreateTypeLibA
  126. #define LHashValOfNameX LHashValOfNameA
  127. #define LHashValOfNameSysX LHashValOfNameSysA
  128. #define LoadRegTypeLibX LoadRegTypeLibA
  129. #define LoadTypeLibX(path, pptlb) LoadTypeLibA(path, pptlb)
  130. #define RegisterTypeLibX RegisterTypeLibA
  131. #define ICreateTypeInfoX ICreateTypeInfoA
  132. #define ICreateTypeLibX ICreateTypeLibA
  133. #define ITypeInfoX ITypeInfoA
  134. #define ITypeLibX ITypeLibA
  135. #define ITypeCompX ITypeCompA
  136. #define BINDPTRX BINDPTRA
  137. #define VARDESCX VARDESCA
  138. #define VARIANTX VARIANTA
  139. #define IID_ITypeInfoX IID_ITypeInfoA
  140. #define BSTRX BSTRA
  141. #define CLSIDFromStringX CLSIDFromStringA
  142. #define CompareStringX CompareStringA
  143. #define CreateFileMonikerX CreateFileMonikerA
  144. #define IIDFromStringX IIDFromStringA
  145. #define LCMapStringX LCMapStringA
  146. #define RegDeleteKeyX RegDeleteKeyA
  147. #define RegEnumKeyX RegEnumKeyA
  148. #define RegOpenKeyX RegOpenKeyA
  149. #define StgCreateDocfileX StgCreateDocfileA
  150. #define SysAllocStringX SysAllocStringA
  151. #define SysFreeStringX SysFreeStringA
  152. #define VariantInitX VariantInitA
  153. #define osKillFile DeleteFile
  154. #define osRmDir RemoveDirectory
  155. #define fopenX fopen
  156. #define fputsX fputs
  157. #endif // OAU
  158. #define MaxAlignment 4 // the largest possible alignment
  159. #define osDeAllocSpaces free
  160. #define SysKind (SYSKIND)SYS_WIN32 // default system kind
  161. #define szPathSep XSTR("\\") // separator for pathspec
  162. #define NameOfDll XSTR("tinfodll.dll")
  163. #define FARPASCAL
  164. #if defined (MIPS) || defined (ALPHA) || defined (PPC) // [2]
  165. #define DLLFUNC1 XSTR("DLLFUNC1")
  166. #define DLLFUNC2 XSTR("DLLFUNC2")
  167. #define DLLFUNC3 XSTR("DLLFUNC3")
  168. #define DLLFUNC4 XSTR("DLLFUNC4")
  169. #define DLLFUNC5 XSTR("DLLFUNC5")
  170. #define DLLFUNC6 XSTR("DLLFUNC6")
  171. #define DLLFUNC7 XSTR("DLLFUNC7")
  172. #define DLLFUNC8 XSTR("DLLFUNC8")
  173. #define DLLFUNC9 XSTR("DLLFUNC9")
  174. #define DLLFUNC10 XSTR("DLLFUNC10")
  175. #else
  176. #define DLLFUNC1 XSTR("DLLFUNC1@0")
  177. #define DLLFUNC2 XSTR("DLLFUNC2@4")
  178. #define DLLFUNC3 XSTR("DLLFUNC3@8")
  179. #define DLLFUNC4 XSTR("DLLFUNC4@16")
  180. #define DLLFUNC5 XSTR("DLLFUNC5@4")
  181. #define DLLFUNC6 XSTR("DLLFUNC6@8")
  182. #define DLLFUNC7 XSTR("DLLFUNC7@8")
  183. #define DLLFUNC8 XSTR("DLLFUNC8@8")
  184. #define DLLFUNC9 XSTR("DLLFUNC9@12")
  185. #define DLLFUNC10 XSTR("DLLFUNC10@4")
  186. #endif // MIPS
  187. // routines defined in osutil.cpp
  188. VOID FAR * osAllocSpaces (WORD) ;
  189. VOID FAR osGetRootDir (LPXSTR) ;
  190. BOOL FAR osGetCurDir (LPXSTR) ;
  191. BOOL FAR osMkDir (LPXSTR) ;
  192. VOID FAR osItoA (int, LPXSTR) ;
  193. VOID FAR osLtoA (long, LPXSTR) ;
  194. long FAR osAtoL (LPXSTR) ;
  195. BOOL FAR osGetNetDrive (LPXSTR, LPXSTR, BOOL) ; // [6]
  196. GUID FAR * osCreateGuid (LPXSTR) ;
  197. BOOL FAR osRetrieveGuid (LPXSTR, GUID) ;
  198. WORD FAR osGetSize (WORD) ;
  199. WORD FAR osGetAlignment (WORD, WORD) ;
  200. VARTYPE FAR osGetEnumType (VOID) ;
  201. HRESULT FAR osOleInit (VOID) ;
  202. VOID FAR osOleUninit (VOID) ;
  203. VOID FAR osMessage (LPXSTR, LPXSTR) ;
  204. UINT FAR osSetErrorMode (UINT) ;
  205. long FAR osDeleteRegTree (LPXSTR) ;
  206. #if !defined(OAU) // ANSI only functions [1]
  207. STDAPI CreateTypeLibA (SYSKIND, char *, ICreateTypeLibA * *) ;
  208. STDAPI LoadTypeLibA (char *, ITypeLibA * *) ;
  209. STDAPI LoadRegTypeLibA (REFGUID, unsigned short, unsigned short, LCID, ITypeLibA * *) ;
  210. STDAPI RegisterTypeLibA (ITypeLibA FAR *, char *, char *) ;
  211. STDAPI CLSIDFromStringA (char *, LPCLSID) ;
  212. STDAPI IIDFromStringA (LPSTR, LPIID) ;
  213. STDAPI StgCreateDocfileA(LPCSTR, DWORD, DWORD, IStorage * *) ;
  214. STDAPI_(unsigned long) LHashValOfNameSysA(SYSKIND, LCID, char *) ;
  215. STDAPI CreateFileMonikerA (char *, LPMONIKER FAR *) ;
  216. #endif
  217. // external routine
  218. VOID FAR mainEntry (LPXSTR lpCmd) ;
  219. VOID NEAR ProcessInput (VOID) ;
  220. #if defined(WIN32) && !defined(UNICODE) // chicago and win32s
  221. LPWSTR FAR PASCAL lstrcatWrap(LPWSTR, LPWSTR) ;
  222. LPWSTR FAR PASCAL lstrcpyWrap(LPWSTR, LPWSTR) ;
  223. #endif