Source code of Windows XP (NT5)
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.

392 lines
16 KiB

  1. /*****************************************************************************/
  2. /* Copyright (C) 1989-1999 Open Systems Solutions, Inc. All rights reserved.*/
  3. /*****************************************************************************/
  4. /* THIS FILE IS PROPRIETARY MATERIAL OF OPEN SYSTEMS SOLUTIONS, INC.
  5. * AND MAY BE USED ONLY BY DIRECT LICENSEES OF OPEN SYSTEMS SOLUTIONS, INC.
  6. * THIS FILE MAY NOT BE DISTRIBUTED. */
  7. /*****************************************************************************/
  8. /* FILE: @(#)asn1code.h 5.36.1.16 97/10/20 */
  9. /*****************************************************************************/
  10. #ifndef ASN1CODE_H
  11. #define ASN1CODE_H
  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif
  15. #include <stddef.h>
  16. #include "asn1hdr.h"
  17. #include "ossdll.h"
  18. #define ERR_MSG_LENGTH 512 /* length of error messages to be output */
  19. /*** encoder/decoder flags ***/
  20. #define DEBUGPDU 0x02 /* produce tracing output */
  21. #define BUFFER_PROVIDED 0x04 /* use caller-provided buffer */
  22. #define RESTRAIN 0x08 /* limit output buffer to user-specified size*/
  23. #define NOTRAPPING 0x200 /* do no signal trapping */
  24. #define NOCONSTRAIN 0x800 /* ignore calling constraint checker */
  25. /*** encoder flags ***/
  26. #define DEFINITE 0x10 /* force definite-length encoding */
  27. #define INDEFINITE 0x20 /* force indefinite-length encoding */
  28. #define FRONT_ALIGN 0x80 /* align output to front of output buffer */
  29. #define BACK_ALIGN 0x100 /* align output to back of output buffer */
  30. #define DEFAULT_ALIGN 0 /* use most efficient align (back or front) */
  31. #define DETERMINE_ENC_LENGTH 0x40 /* generate only total encoding length
  32. * (for use in user memory managers) */
  33. /*** decoder flags ***/
  34. #define DEBUG_ERRORS 0x10 /* print errors to asn1out */
  35. #define RELAXBER 0x400 /* relax BER */
  36. #define OBJECT_HANDLE 0x1000 /* temporarily mark object of type with
  37. * NOCOPY directive to not free it by
  38. * ossFreePDU() (for use in user memory
  39. * managers) */
  40. /*** compatibility flags ***/
  41. #define OSS_V412_TIME_AND_WIDE_CHAR_STRINGS 0x01
  42. #define OSS_TRUNCATE_0_SECONDS_FROM_GENERALIZED_TIME 0x02
  43. #define OSS_TRUNCATE_0_SECONDS_FROM_UTC_TIME 0x04
  44. #define OSS_EXTENDED_UNRESTRICTED_CHAR_STRINGS 0x08
  45. #define OSS_ALLOW_ZERO_LENGTH_OPENTYPE_STRINGS 0x10
  46. /*** reserved flags for internal use ***/
  47. #define RESERVED_FLAG1 0x8000
  48. #define RESERVED_FLAG2 0x4000
  49. /*** common return codes ***/
  50. #define CANT_CLOSE_TRACE_FILE 46 /* error when closing a trace file */
  51. #define MUTEX_NOT_CREATED 45 /* mutex was not created */
  52. #define OPEN_TYPE_ERROR 44 /* error in automatic encoding/decoding/
  53. * copying an open type */
  54. #define PER_DLL_NOT_LINKED 43 /* PER DLL was not linked */
  55. #define BERDER_DLL_NOT_LINKED 42 /* BER/DER DLL was not linked */
  56. #define API_DLL_NOT_LINKED 41 /* API DLL was not linked */
  57. #define PDV_CODE_NOT_LINKED 40 /* EMBEDDED PDV code was not linked */
  58. #define PDV_DLL_NOT_LINKED 39 /* EMBEDDED PDV DLL was not linked */
  59. #define MEM_MGR_DLL_NOT_LINKED 38 /* memory manager DLL was not linked */
  60. #define COMPARATOR_CODE_NOT_LINKED 37 /* value comparator code was not linked */
  61. #define COMPARATOR_DLL_NOT_LINKED 36 /* value comparator DLL was not linked */
  62. #define CONSTRAINT_DLL_NOT_LINKED 35 /* constraint checker DLL was not linked */
  63. #define COPIER_DLL_NOT_LINKED 34 /* value copier DLL was not linked */
  64. #define OUT_OF_RANGE 33 /* parameter value range error */
  65. #define REAL_CODE_NOT_LINKED 32 /* REAL code was not linked */
  66. #define REAL_DLL_NOT_LINKED 31 /* REAL DLL was not linked */
  67. #define TYPE_NOT_SUPPORTED 30 /* ASN.1 type is not supported */
  68. #define TABLE_MISMATCH 29 /* C++ API: PDUcls function called with
  69. * a ossControl object which refers to
  70. * control table different from one the
  71. * PDU was defined in */
  72. #define TRACE_FILE_ALREADY_OPEN 28 /* the trace file has been opened */
  73. #define CANT_OPEN_TRACE_FILE 27 /* error when opening a trace file */
  74. #define OID_DLL_NOT_LINKED 26 /* OBJECT IDENTIFIER DLL was not linked */
  75. #define UNIMPLEMENTED 25 /* unimplemented type or feature */
  76. #define CANT_OPEN_TRACE_WINDOW 24 /* error when opening a trace window */
  77. #define UNAVAIL_ENCRULES 23 /* the encoding rules requested are
  78. * not implemented yet or were not
  79. * linked because the encoder/decoder
  80. * function pointers were not
  81. * initialized by a call to ossinit() */
  82. #define BAD_ENCRULES 22 /* unknown encoding rules set in the
  83. * ossGlobal structure */
  84. #define NULL_FCN 21 /* attempt was made to call the
  85. * encoder/decoder via a NULL pointer */
  86. #define NULL_TBL 20 /* attempt was made to pass a NULL
  87. * control table pointer */
  88. #define ACCESS_SERIALIZATION_ERROR 19 /* error occured during access to
  89. * global data in a multi-threaded
  90. * environment */
  91. #define CONSTRAINT_VIOLATED 17 /* constraint violation error occured */
  92. #define OUT_MEMORY 8 /* memory-allocation error */
  93. #define BAD_VERSION 7 /* versions of encoder/decoder and
  94. * control-table do not match */
  95. #define PDU_RANGE 3 /* pdu specified out of range */
  96. #define MORE_BUF 1 /* user-provided outbut buffer
  97. * too small */
  98. /*** encoder return codes ***/
  99. #define FATAL_ERROR 18 /* *serious* error, could not free memory, &etc */
  100. #define TOO_LONG 16 /* type was longer than shown in SIZE constraint */
  101. #define BAD_TABLE 15 /* table was bad, but not NULL */
  102. #define MEM_ERROR 14 /* memory violation signal trapped */
  103. #define INDEFINITE_NOT_SUPPORTED 13 /* BER indefinite-length encoding is
  104. * not supported for Spartan or time-optimized
  105. * encoder/decoder */
  106. #define BAD_TIME 12 /* bad value in time type */
  107. #define BAD_PTR 11 /* unexpected NULL pointer in input buffer */
  108. #define BAD_OBJID 10 /* object identifier conflicts with x.208 */
  109. #define BAD_CHOICE 9 /* unknown selector for a choice */
  110. #define BAD_ARG 6 /* something weird was passed--probably a NULL
  111. * pointer */
  112. #define PDU_ENCODED 0 /* PDU successfully encoded */
  113. /*** decoder return codes ***/
  114. /* MORE_BUF, BAD_VERSION, OUT_MEMORY, PDU_RANGE and BAD_ARG defined above */
  115. #define LIMITED 10 /* implementation limit exceeded. eg:
  116. * integer value too great */
  117. #define PDU_MISMATCH 9 /* the PDU tag that the user specified was different
  118. * from the tag found in the encoded data */
  119. #define DATA_ERROR 5 /* an error exists in the encoded data */
  120. #define MORE_INPUT 4 /* the PDU is not fully decoded, but the end
  121. * of the input buffer has been reached */
  122. #define NEGATIVE_UINTEGER 2 /* the first bit of the encoding is encountered
  123. * set to 1 while decoding an unsigned integer */
  124. #define PDU_DECODED 0 /* PDU successfully decoded */
  125. extern int asn1chop; /* 0 means don't truncate strings; non-zero
  126. * value means truncate long input strings
  127. * (OCTET STRING, BIT STRING, CharacterStrings)
  128. * to be asn1chop bytes long. Used by printPDU. */
  129. extern size_t ossblock; /* if > 0, size of largest block to allocate */
  130. extern size_t ossprefx; /* size of reserved OSAK buffer prefix */
  131. #ifdef __cplusplus
  132. extern "C"
  133. {
  134. #endif
  135. extern void *(*mallocp)(size_t p); /* function which allocates memory */
  136. extern void (*freep)(void *p); /* function which frees memory */
  137. #ifdef EOF
  138. extern FILE *asn1out;
  139. /* pointer to output function used by printPDU; default to fprintf. */
  140. extern int (*asn1prnt) (FILE *stream, const char *format, ...);
  141. #endif
  142. #ifndef storing
  143. #ifndef coding
  144. #ifndef OSS_TOED
  145. #include "ossglobl.h"
  146. #endif /* not OSS_TOED */
  147. #endif /* not coding */
  148. #endif /* not storing */
  149. #if defined(_MSC_VER) && (defined(_WIN32) || defined(WIN32))
  150. #pragma pack(push, ossPacking, 4)
  151. #elif defined(_MSC_VER) && (defined(_WINDOWS) || defined(_MSDOS))
  152. #pragma pack(1)
  153. #elif defined(__BORLANDC__) && defined(__MSDOS__)
  154. #ifdef _BC31
  155. #pragma option -a-
  156. #else
  157. #pragma option -a1
  158. #endif /* _BC31 */
  159. #elif defined(__BORLANDC__) && defined(__WIN32__)
  160. #pragma option -a4
  161. #elif defined(__IBMC__)
  162. #pragma pack(4)
  163. #elif defined(__WATCOMC__) && defined(__NT__)
  164. #pragma pack(push, 4)
  165. #elif defined(__WATCOMC__) && (defined(__WINDOWS__) || defined(__DOS__))
  166. #pragma pack(push, 1)
  167. #endif /* _MSC_VER && _WIN32 */
  168. #ifdef macintosh
  169. #pragma options align=mac68k
  170. #endif
  171. typedef struct {
  172. long length;
  173. unsigned char *value;
  174. } OssBuf;
  175. #if defined(_MSC_VER) && (defined(_WIN32) || defined(WIN32))
  176. #pragma pack(pop, ossPacking)
  177. #elif defined(_MSC_VER) && (defined(_WINDOWS) || defined(_MSDOS))
  178. #pragma pack()
  179. #elif defined(__BORLANDC__) && (defined(__WIN32__) || defined(__MSDOS__))
  180. #pragma option -a.
  181. #elif defined(__IBMC__)
  182. #pragma pack()
  183. #elif defined(__WATCOMC__)
  184. #pragma pack(pop)
  185. #endif /* _MSC_VER && _WIN32 */
  186. #ifdef macintosh
  187. #pragma options align=reset
  188. #endif
  189. PUBLIC extern int DLL_ENTRY encode(struct ossGlobal *world,
  190. int pdunum, void *inbuf, char **outbuf, long *outlen,
  191. void *ctl_tbl, unsigned flags, char errmsg[ERR_MSG_LENGTH]);
  192. PUBLIC extern int DLL_ENTRY decode(struct ossGlobal *world,
  193. int *pdunum, char **inbuf, long *inlen, void **outbuf,
  194. long *outlen, void *ctl_tbl, unsigned flags,
  195. char errmsg[ERR_MSG_LENGTH]);
  196. #define PDU_FREED 0
  197. /* returns 0 (PDU_FREED), PDU_RANGE, UNIMPLEMENTED */
  198. PUBLIC int DLL_ENTRY freePDU(struct ossGlobal *world, int pdunum, void *data, void *ctl_tbl);
  199. PUBLIC void DLL_ENTRY freeBUF(struct ossGlobal *world, void *data);
  200. #define PDU_PRINTED 0
  201. /* returns 0 (PDU_PRINTED), PDU_RANGE */
  202. PUBLIC int DLL_ENTRY printPDU(struct ossGlobal *world, int pdunum, void *data, void *ctl_tbl);
  203. #define VALUE_COPIED 0
  204. /*returns 0 (VALUE_COPIED), NULL_TBL, PDU_RANGE, BAD_ARG */
  205. PUBLIC extern int DLL_ENTRY ossCpyValue (struct ossGlobal *world,
  206. int pdunum, void *source, void **destination);
  207. #define VALUES_EQUAL 0 /* The values are the same */
  208. #define VALUES_NOT_EQUAL 1 /* The values are not the same */
  209. /*returns VALUE_EQUAL, VALUES_NOT_EQUAL, NULL_TBL, PDU_RANGE, BAD_ARG */
  210. PUBLIC extern int DLL_ENTRY ossCmpValue (struct ossGlobal *world,
  211. int pdunum, void *originalData, void *copiedData);
  212. #define INITIALIZATION_SUCCESSFUL 0
  213. /* returns 0 (INITIALIZATION_SUCCESSFUL), BAD_TABLE */
  214. PUBLIC int DLL_ENTRY ossinit(struct ossGlobal *world,
  215. void *ctl_tbl);
  216. PUBLIC void DLL_ENTRY ossterm(struct ossGlobal *world);
  217. extern int ossPrint(struct ossGlobal *, const char *, ...);
  218. PUBLIC int DLL_ENTRY ossEncode(struct ossGlobal *world,
  219. int pdunum,
  220. void *input,
  221. OssBuf *output);
  222. PUBLIC int DLL_ENTRY ossDecode(struct ossGlobal *world,
  223. int *pdunum,
  224. OssBuf *input,
  225. void **output);
  226. PUBLIC int DLL_ENTRY ossPrintPDU(struct ossGlobal *world,
  227. int pdunum,
  228. void *data);
  229. PUBLIC int DLL_ENTRY ossFreePDU(struct ossGlobal *world,
  230. int pdunum,
  231. void *data);
  232. PUBLIC void DLL_ENTRY ossFreeBuf(struct ossGlobal *world,
  233. void *data);
  234. extern int DLL_ENTRY ossTest(struct ossGlobal *world,
  235. int pdunum,
  236. void *data);
  237. PUBLIC void DLL_ENTRY ossPrintHex(struct ossGlobal *world,
  238. char *encodedData,
  239. long length);
  240. PUBLIC int DLL_ENTRY ossCheckConstraints(struct ossGlobal *world,
  241. int pdunum,
  242. void *data);
  243. PUBLIC long DLL_ENTRY ossDetermineEncodingLength(struct ossGlobal *world,
  244. int pdunum,
  245. void *data);
  246. PUBLIC int DLL_ENTRY ossOpenTraceFile(struct ossGlobal *world,
  247. char *fileName);
  248. PUBLIC int DLL_ENTRY ossCloseTraceFile(struct ossGlobal *world);
  249. /* Runtime support for encoded OBJECT IDENTIFIERs */
  250. typedef struct {
  251. unsigned short length;
  252. unsigned char *value;
  253. } OssEncodedOID;
  254. PUBLIC int DLL_ENTRY ossEncodedOidToAsnVal(struct ossGlobal *world,
  255. const OssEncodedOID *encodedOID, OssBuf *valOID);
  256. PUBLIC int DLL_ENTRY ossEncodedOidToDotVal(struct ossGlobal *world,
  257. const OssEncodedOID *encodedOID, OssBuf *dotOID);
  258. PUBLIC int DLL_ENTRY ossAsnValToEncodedOid(struct ossGlobal *world,
  259. const char *valOID, OssEncodedOID *encodedOID);
  260. PUBLIC int DLL_ENTRY ossDotValToEncodedOid(struct ossGlobal *world,
  261. const char *dotOID, OssEncodedOID *encodedOID);
  262. #if !defined(_WINDOWS) && !defined(_DLL) && \
  263. !defined(OS2_DLL) && !defined(NETWARE_DLL)
  264. extern char OSS_PLUS_INFINITY[];
  265. extern char OSS_MINUS_INFINITY[];
  266. extern char ossNaN[];
  267. #endif /* !_WINDOWS && !_DLL && !OS2_DLL && !NETWARE_DLL */
  268. typedef enum {
  269. OSS_DEFAULT_MEMMGR = 0, /* memory is malloc'ed for each pointer in
  270. * data tree */
  271. OSS_FILE_MEMMGR, /* file memory manager with memory malloc'ed
  272. * for each pointer in data tree */
  273. OSS_SOCKET_MEMMGR, /* TCP/IP socket and file memory manager with memory
  274. * malloc'ed for each pointer in data tree */
  275. OSS_FLAT_MEMMGR, /* memory is malloc'ed in large blocks */
  276. OSS_OSAK_MEMMGR, /* OSAK-buffer memory manager */
  277. OSS_USER_MEMMGR /* user memory manager */
  278. } OssMemMgrType;
  279. typedef enum {
  280. OSS_UNKNOWN_OBJECT = 0,
  281. OSS_FILE,
  282. OSS_SOCKET,
  283. OSS_OSAK_BUFFER
  284. } OssObjType;
  285. #if defined(__arm)
  286. PUBLIC OssObjType DLL_ENTRY ossTestObj(struct ossGlobal *world, void *objHndl);
  287. #else
  288. PUBLIC void *DLL_ENTRY ossTestObj(struct ossGlobal *world, void *objHndl);
  289. #endif /* __arm */
  290. PUBLIC void *DLL_ENTRY ossGetObj(struct ossGlobal *world, void *objHndl);
  291. PUBLIC void *DLL_ENTRY ossUnmarkObj(struct ossGlobal *world, void *objHndl);
  292. PUBLIC void *DLL_ENTRY ossMarkObj(struct ossGlobal *world, OssObjType objType,
  293. void *object);
  294. PUBLIC void DLL_ENTRY ossFreeObjectStack(struct ossGlobal *world);
  295. PUBLIC void DLL_ENTRY ossSetTimeout(struct ossGlobal *world, long timeout);
  296. PUBLIC int DLL_ENTRY ossSetUserStack(struct ossGlobal *world, OssBuf *stack);
  297. PUBLIC int DLL_ENTRY ossInitSync(void);
  298. PUBLIC void DLL_ENTRY ossTermSync(void);
  299. #ifdef __IBMC__
  300. extern void *getStartAddress(struct ossGlobal *, char *);
  301. extern void DLL_ENTRY ossWterm(struct ossGlobal *);
  302. extern int DLL_ENTRY ossFreeDll(struct ossGlobal *, char *);
  303. extern int DLL_ENTRY ossReadLine(struct ossGlobal *, HWND, FILE *, char *, MEMBLOCK *, LONG);
  304. extern void DLL_ENTRY ossFreeList(struct ossGlobal *);
  305. extern void DLL_ENTRY ossSaveTraceInfo(struct ossGlobal *, HWND, char *);
  306. extern int DLL_ENTRY oss_test(struct ossGlobal *);
  307. int ossGeneric(struct ossGlobal *, HWND);
  308. extern int DLL_ENTRY ossOpenTraceWindow(struct ossGlobal *);
  309. extern void *DLL_ENTRY ossGetHeader(void);
  310. extern int DLL_ENTRY ossPrintWin(struct ossGlobal *, const char *,
  311. int, int, int, int, int, int, int, int, int, int);
  312. extern HINSTANCE DLL_ENTRY ossLoadDll(struct ossGlobal *, char *);
  313. extern HINSTANCE DLL_ENTRY ossLoadMemoryManager(struct ossGlobal *,
  314. OssMemMgrType, char *);
  315. extern int DLL_ENTRY ossWinit(struct ossGlobal *, void *, char *, HWND);
  316. #endif /* __IBMC__ */
  317. /* Functions for manipulating pointers to OSAK buffers by
  318. * marking them object handles.
  319. * NOTE: only the pointer to the first OSAK buffer in a linked
  320. * list of buffers is marked a pointer to an OSAK buffer */
  321. #ifdef __hpux /* CHOOSE & CUT */
  322. /* There is a real signal "SIGBUS", even if ANSI-C is compiled */
  323. #define SIGBUS _SIGBUS
  324. #endif /* CHOOSE & CUT */
  325. #ifdef __cplusplus
  326. }
  327. #endif
  328. #endif /* ASN1CODE_H */