source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/celib.h@ 1175

Last change on this file since 1175 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 7.7 KB
RevLine 
[1166]1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef __CELIB_H__
7#define __CELIB_H__
8
9#include <stdio.h>
10
11#define CENCODEMAX (64 *1024)
12
13#define GETBIT(pb,i) ((pb)[(i) / 8] & (1 << ((i) % 8)))
14#define SETBIT(pb,i) ((pb)[(i) / 8] |= (1 << ((i) % 8)))
15#define CLEARBIT(pb,i) ((pb)[(i) / 8] &= ~(1 << ((i) % 8)))
16#define BITSTOBYTES(b) ((int)(((b) + 7) / 8))
17
18#define ceCASIGN_KEY_USAGE (CERT_KEY_CERT_SIGN_KEY_USAGE | CERT_DIGITAL_SIGNATURE_KEY_USAGE | CERT_CRL_SIGN_KEY_USAGE)
19
20#define ARRAYSIZE(a) (sizeof(a)/sizeof((a)[0]))
21#define WSZARRAYSIZE(a) ((sizeof(a)/sizeof((a)[0])) - 1)
22
23#define wszCERTENROLLSHAREPATH L"CertSrv\\CertEnroll"
24
25#define cwcHRESULTSTRING 40
26#define cwcDWORDSPRINTF (1 + 10 + 1)
27
28#define SAFE_SUBTRACT_POINTERS(p1,p2) (assert(sizeof((*p1))==sizeof(*(p2))),(DWORD)((p1) - (p2)))
29#define printf Use_wprintf_Instead_Of_printf
30#define _LeaveError(hr,pszMessage) _LeaveErrorStr2((hr),(pszMessage),NULL,S_OK)
31#define _LeaveError2(hr,pszMessage,hr2) _LeaveErrorStr2((hr),(pszMessage),NULL,(hr2))
32#define _LeaveErrorStr(hr,pszMessage,pwszData) _LeaveErrorStr2((hr),(pszMessage),(pwszData),S_OK)
33#define _LeaveErrorStr2(hr,pszMessage,pwszData,hr2) { ceERRORPRINTLINESTR((pszMessage),(pwszData),(hr)); __leave; }
34#define _LeaveIfError(hr,pszMessage) _LeaveIfErrorStr2((hr),(pszMessage),NULL,S_OK)
35#define _LeaveIfError2(hr,pszMessage,hr2) _LeaveIfErrorStr2((hr),(pszMessage),NULL,(hr2))
36#define _LeaveIfErrorStr(hr,pszMessage,pwszData) _LeaveIfErrorStr2((hr),(pszMessage),(pwszData),S_OK)
37#define _LeaveIfErrorStr2(hr,pszMessage,pwszData,hr2) { if (S_OK!=(hr)) { ceERRORPRINTLINESTR((pszMessage),(pwszData),(hr)); __leave; } }
38#define _PrintErrorStr(hr,pszMessage,pwsz) ceERRORPRINTLINESTR((pszMessage),(pwsz),(hr))
39#define _PrintErrorStr2(hr,pszMessage,pwsz,hr2) _PrintErrorStr((hr),(pszMessage),(pwsz))
40#define _PrintError2(hr,pszMessage,hr2) _PrintErrorStr((hr),(pszMessage),NULL)
41#define _PrintError(hr,pszMessage) _PrintErrorStr((hr),(pszMessage),NULL)
42#define _PrintIfErrorStr(hr,pszMessage,pwsz) { if (S_OK!=(hr)) { ceERRORPRINTLINESTR((pszMessage),(pwsz),(hr)); } }
43#define _PrintIfErrorStr2(hr,pszMessage,pwsz,hr2) _PrintIfErrorStr((hr),(pszMessage),(pwsz))
44#define _PrintIfError2(hr,pszMessage,hr2) _PrintIfErrorStr((hr),(pszMessage),NULL)
45#define _PrintIfError(hr,pszMessage) _PrintIfErrorStr((hr),(pszMessage),NULL)
46#define _JumpErrorStr(hr,label,pszMessage,pwsz) _JumpError((hr),label,(pszMessage))
47#define _JumpError(hr,label,pszMessage) { ceERRORPRINTLINESTR((pszMessage),NULL,(hr)); goto label; }
48#define _JumpIfErrorStr(hr,label,pszMessage,pwsz) { if (S_OK!=(hr)) { ceERRORPRINTLINESTR((pszMessage),(pwsz),(hr)); goto label; } }
49#define _JumpIfErrorStr2(hr,label,pszMessage,pwsz,hr2) _JumpIfErrorStr((hr),label,(pszMessage),NULL)
50#define _JumpIfError2(hr,label,pszMessage,hr2) _JumpIfErrorStr((hr),label,(pszMessage),NULL)
51#define _JumpIfError(hr,label,pszMessage) _JumpIfErrorStr((hr),label,(pszMessage),NULL)
52#define ceERRORPRINTLINE(pszMessage,hr) ceErrorPrintLine(__FILE__,__LINE__,(pszMessage),NULL,(hr))
53#define ceERRORPRINTLINESTR(pszMessage,pwszData,hr) ceErrorPrintLine(__FILE__,__LINE__,(pszMessage),(pwszData),(hr))
54#define DBGPRINT(a) ceDbgPrintf a
55
56int WINAPIV ceDbgPrintf(WINBOOL fDebug,char const *pszfmt,...);
57VOID ceErrorPrintLine(char const *pszFile,DWORD line,char const *pszMessage,WCHAR const *pwszData,HRESULT hr);
58HRESULT ceHLastError(VOID);
59HRESULT ceHError(HRESULT hr);
60
61#define chLBRACE '{'
62#define chRBRACE '}'
63#define szLBRACE "{"
64#define szRBRACE "}"
65#define wcLBRACE L'{'
66#define wcRBRACE L'}'
67#define wszLBRACE L"{"
68#define wszRBRACE L"}"
69
70#define chLPAREN '('
71#define chRPAREN ')'
72#define szLPAREN "("
73#define szRPAREN ")"
74#define wcLPAREN L'('
75#define wcRPAREN L')'
76#define wszLPAREN L"("
77#define wszRPAREN L")"
78
79#define CVT_WEEKS (7 *CVT_DAYS)
80#define CVT_DAYS (24 *CVT_HOURS)
81#define CVT_HOURS (60 *CVT_MINUTES)
82#define CVT_MINUTES (60 *CVT_SECONDS)
83#define CVT_SECONDS (1)
84#define CVT_BASE (1000 *1000 *10)
85
86enum ENUM_PERIOD {
87 ENUM_PERIOD_INVALID = -1,ENUM_PERIOD_SECONDS = 0,ENUM_PERIOD_MINUTES,ENUM_PERIOD_HOURS,ENUM_PERIOD_DAYS,ENUM_PERIOD_WEEKS,
88 ENUM_PERIOD_MONTHS,ENUM_PERIOD_YEARS
89};
90
91typedef struct _LLFILETIME {
92 __C89_NAMELESS union {
93 LONGLONG ll;
94 FILETIME ft;
95 };
96} LLFILETIME;
97
98static __inline VOID ceAddToFileTime(FILETIME *pft,LONGLONG ll) {
99 LLFILETIME llft;
100 llft.ft = *pft;
101 llft.ll += ll;
102 *pft = llft.ft;
103}
104
105static __inline LONGLONG ceSubtractFileTimes(FILETIME const *pft1,FILETIME const *pft2) {
106 LLFILETIME llft1;
107 LLFILETIME llft2;
108 llft1.ft = *pft1;
109 llft2.ft = *pft2;
110 return(llft1.ll - llft2.ll);
111}
112
113HRESULT ceMakeExprDate(DATE *pDate,LONG lDelta,enum ENUM_PERIOD enumPeriod);
114HRESULT ceTranslatePeriodUnits(WCHAR const *pwszPeriod,LONG lCount,enum ENUM_PERIOD *penumPeriod,LONG *plCount);
115WCHAR const *ceGetOIDNameA(char const *pszObjId);
116WCHAR const *ceGetOIDName(WCHAR const *pwszObjId);
117WINBOOL ceDecodeObject(DWORD dwEncodingType,LPCSTR lpszStructType,BYTE const *pbEncoded,DWORD cbEncoded,WINBOOL fCoTaskMemAlloc,VOID **ppvStructInfo,DWORD *pcbStructInfo);
118WINBOOL ceEncodeObject(DWORD dwEncodingType,LPCSTR lpszStructType,VOID const *pvStructInfo,DWORD dwFlags,WINBOOL fCoTaskMemAlloc,BYTE **ppbEncoded,DWORD *pcbEncoded);
119WCHAR *ceDuplicateString(WCHAR const *pwsz);
120HRESULT ceDupString(WCHAR const *pwszIn,WCHAR **ppwszOut);
121WINBOOL ceConvertWszToSz(char **ppsz,WCHAR const *pwc,LONG cb);
122WINBOOL ceConvertWszToBstr(BSTR *pbstr,WCHAR const *pwc,LONG cb);
123WINBOOL ceConvertSzToWsz(WCHAR **ppwsz,char const *pch,LONG cch);
124WINBOOL ceConvertSzToBstr(BSTR *pbstr,CHAR const *pch,LONG cch);
125VOID ceFreeBstr(BSTR *pstr);
126HRESULT ceDateToFileTime(DATE const *pDate,FILETIME *pft);
127HRESULT ceFileTimeToDate(FILETIME const *pft,DATE *pDate);
128HRESULT ceVerifyObjIdA(char const *pszObjId);
129HRESULT ceVerifyObjId(WCHAR const *pwszObjId);
130HRESULT ceVerifyAltNameString(LONG NameChoice,BSTR strName);
131HRESULT ceDispatchSetErrorInfo(HRESULT hrError,WCHAR const *pwszDescription,WCHAR const *pwszProgId,IID const *piid);
132VOID ceInitErrorMessageText(HMODULE hMod,DWORD idsUnexpected,DWORD idsUnknownErrorCode);
133WCHAR const *ceGetErrorMessageText(HRESULT hr,WINBOOL fHResultString);
134WCHAR const *ceGetErrorMessageTextEx(HRESULT hr,WINBOOL fHResultString,WCHAR const *const *papwszInsertionText);
135WCHAR const *ceHResultToString(WCHAR *awchr,HRESULT hr);
136
137#define cwcFILENAMESUFFIXMAX 20
138#define cwcSUFFIXMAX (1 + 5 + 1)
139
140#define wszFCSAPARM_SERVERDNSNAME L"%1"
141#define wszFCSAPARM_SERVERSHORTNAME L"%2"
142#define wszFCSAPARM_SANITIZEDCANAME L"%3"
143#define wszFCSAPARM_CERTFILENAMESUFFIX L"%4"
144#define wszFCSAPARM_DOMAINDN L"%5"
145#define wszFCSAPARM_CONFIGDN L"%6"
146#define wszFCSAPARM_SANITIZEDCANAMEHASH L"%7"
147#define wszFCSAPARM_CRLFILENAMESUFFIX L"%8"
148#define wszFCSAPARM_CRLDELTAFILENAMESUFFIX L"%9"
149#define wszFCSAPARM_DSCRLATTRIBUTE L"%10"
150#define wszFCSAPARM_DSCACERTATTRIBUTE L"%11"
151#define wszFCSAPARM_DSUSERCERTATTRIBUTE L"%12"
152#define wszFCSAPARM_DSKRACERTATTRIBUTE L"%13"
153#define wszFCSAPARM_DSCROSSCERTPAIRATTRIBUTE L"%14"
154
155HRESULT ceFormatCertsrvStringArray(WINBOOL fURL,LPCWSTR pwszServerName_p1_2,LPCWSTR pwszSanitizedName_p3_7,DWORD iCert_p4,DWORD iCertTarget_p4,LPCWSTR pwszDomainDN_p5,LPCWSTR pwszConfigDN_p6,DWORD iCRL_p8,WINBOOL fDeltaCRL_p9,WINBOOL fDSAttrib_p10_11,DWORD cStrings,LPCWSTR *apwszStringsIn,LPWSTR *apwszStringsOut);
156HRESULT ceBuildPathAndExt(WCHAR const *pwszDir,WCHAR const *pwszFile,WCHAR const *pwszExt,WCHAR **ppwszPath);
157HRESULT ceInternetCanonicalizeUrl(WCHAR const *pwszIn,WCHAR **ppwszOut);
158int ceWtoI(WCHAR const *pwszDigitString,WINBOOL *pfValid);
159int celstrcmpiL(WCHAR const *pwsz1,WCHAR const *pwsz2);
160HRESULT ceIsConfigLocal(WCHAR const *pwszConfig,WCHAR **ppwszMachine,WINBOOL *pfLocal);
161#endif
Note: See TracBrowser for help on using the repository browser.