[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 |
|
---|
| 56 | int WINAPIV ceDbgPrintf(WINBOOL fDebug,char const *pszfmt,...);
|
---|
| 57 | VOID ceErrorPrintLine(char const *pszFile,DWORD line,char const *pszMessage,WCHAR const *pwszData,HRESULT hr);
|
---|
| 58 | HRESULT ceHLastError(VOID);
|
---|
| 59 | HRESULT 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 |
|
---|
| 86 | enum 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 |
|
---|
| 91 | typedef struct _LLFILETIME {
|
---|
| 92 | __C89_NAMELESS union {
|
---|
| 93 | LONGLONG ll;
|
---|
| 94 | FILETIME ft;
|
---|
| 95 | };
|
---|
| 96 | } LLFILETIME;
|
---|
| 97 |
|
---|
| 98 | static __inline VOID ceAddToFileTime(FILETIME *pft,LONGLONG ll) {
|
---|
| 99 | LLFILETIME llft;
|
---|
| 100 | llft.ft = *pft;
|
---|
| 101 | llft.ll += ll;
|
---|
| 102 | *pft = llft.ft;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | static __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 |
|
---|
| 113 | HRESULT ceMakeExprDate(DATE *pDate,LONG lDelta,enum ENUM_PERIOD enumPeriod);
|
---|
| 114 | HRESULT ceTranslatePeriodUnits(WCHAR const *pwszPeriod,LONG lCount,enum ENUM_PERIOD *penumPeriod,LONG *plCount);
|
---|
| 115 | WCHAR const *ceGetOIDNameA(char const *pszObjId);
|
---|
| 116 | WCHAR const *ceGetOIDName(WCHAR const *pwszObjId);
|
---|
| 117 | WINBOOL ceDecodeObject(DWORD dwEncodingType,LPCSTR lpszStructType,BYTE const *pbEncoded,DWORD cbEncoded,WINBOOL fCoTaskMemAlloc,VOID **ppvStructInfo,DWORD *pcbStructInfo);
|
---|
| 118 | WINBOOL ceEncodeObject(DWORD dwEncodingType,LPCSTR lpszStructType,VOID const *pvStructInfo,DWORD dwFlags,WINBOOL fCoTaskMemAlloc,BYTE **ppbEncoded,DWORD *pcbEncoded);
|
---|
| 119 | WCHAR *ceDuplicateString(WCHAR const *pwsz);
|
---|
| 120 | HRESULT ceDupString(WCHAR const *pwszIn,WCHAR **ppwszOut);
|
---|
| 121 | WINBOOL ceConvertWszToSz(char **ppsz,WCHAR const *pwc,LONG cb);
|
---|
| 122 | WINBOOL ceConvertWszToBstr(BSTR *pbstr,WCHAR const *pwc,LONG cb);
|
---|
| 123 | WINBOOL ceConvertSzToWsz(WCHAR **ppwsz,char const *pch,LONG cch);
|
---|
| 124 | WINBOOL ceConvertSzToBstr(BSTR *pbstr,CHAR const *pch,LONG cch);
|
---|
| 125 | VOID ceFreeBstr(BSTR *pstr);
|
---|
| 126 | HRESULT ceDateToFileTime(DATE const *pDate,FILETIME *pft);
|
---|
| 127 | HRESULT ceFileTimeToDate(FILETIME const *pft,DATE *pDate);
|
---|
| 128 | HRESULT ceVerifyObjIdA(char const *pszObjId);
|
---|
| 129 | HRESULT ceVerifyObjId(WCHAR const *pwszObjId);
|
---|
| 130 | HRESULT ceVerifyAltNameString(LONG NameChoice,BSTR strName);
|
---|
| 131 | HRESULT ceDispatchSetErrorInfo(HRESULT hrError,WCHAR const *pwszDescription,WCHAR const *pwszProgId,IID const *piid);
|
---|
| 132 | VOID ceInitErrorMessageText(HMODULE hMod,DWORD idsUnexpected,DWORD idsUnknownErrorCode);
|
---|
| 133 | WCHAR const *ceGetErrorMessageText(HRESULT hr,WINBOOL fHResultString);
|
---|
| 134 | WCHAR const *ceGetErrorMessageTextEx(HRESULT hr,WINBOOL fHResultString,WCHAR const *const *papwszInsertionText);
|
---|
| 135 | WCHAR 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 |
|
---|
| 155 | HRESULT 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);
|
---|
| 156 | HRESULT ceBuildPathAndExt(WCHAR const *pwszDir,WCHAR const *pwszFile,WCHAR const *pwszExt,WCHAR **ppwszPath);
|
---|
| 157 | HRESULT ceInternetCanonicalizeUrl(WCHAR const *pwszIn,WCHAR **ppwszOut);
|
---|
| 158 | int ceWtoI(WCHAR const *pwszDigitString,WINBOOL *pfValid);
|
---|
| 159 | int celstrcmpiL(WCHAR const *pwsz1,WCHAR const *pwsz2);
|
---|
| 160 | HRESULT ceIsConfigLocal(WCHAR const *pwszConfig,WCHAR **ppwszMachine,WINBOOL *pfLocal);
|
---|
| 161 | #endif
|
---|