|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Various utility functions for makekeys |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 #ifndef __UTILS_H_ |
|
26 #define __UTILS_H_ |
|
27 |
|
28 // =========================================================================== |
|
29 // INCLUDES |
|
30 // =========================================================================== |
|
31 |
|
32 #include <windows.h> |
|
33 #include <tchar.h> |
|
34 #include <string.h> |
|
35 #include "openssl/err.h" |
|
36 #include "openssl/objects.h" |
|
37 |
|
38 #define SUCCESS 1 |
|
39 #define FAIL 0 |
|
40 |
|
41 #define ENTRY_COUNT 8 |
|
42 #define MAXBUF 512 |
|
43 |
|
44 struct entry |
|
45 { |
|
46 char key[MAXBUF]; |
|
47 _TCHAR value[MAXBUF]; |
|
48 }; |
|
49 |
|
50 struct entry_pack |
|
51 { |
|
52 struct entry entries[ENTRY_COUNT]; |
|
53 int num; |
|
54 }; |
|
55 |
|
56 |
|
57 _TCHAR* RemoveSpaces (_TCHAR* aStr); |
|
58 char* IsValid (_TCHAR* aTk); |
|
59 int SplitString (_TCHAR* aToken, _TCHAR** aStrFirst, _TCHAR** aStrSecond); |
|
60 void InitEntryPack(struct entry_pack** aEntPack); |
|
61 |
|
62 enum TUtilsException |
|
63 {ErrNotEnoughMemory =-1}; |
|
64 |
|
65 enum TErrType |
|
66 {EGeneric, |
|
67 EOPENSSL, |
|
68 EMSCrypto}; |
|
69 |
|
70 // =========================================================================== |
|
71 // GLOBAL FUNCTIONS |
|
72 // =========================================================================== |
|
73 |
|
74 // convert a UNICODE string to MBCS |
|
75 LPSTR MakeMBCSString(LPCWSTR uniStr, UINT codePage, DWORD& length); |
|
76 int MakeMBCSString(LPCWSTR uniStr, UINT codePage, LPSTR* mbStr, int& length); |
|
77 // convert a MBCS string to UNICODE |
|
78 LPWSTR MakeUnicodeString(LPSTR mbcsStr, UINT codePage); |
|
79 |
|
80 // print error information |
|
81 void PrintError(char* aMsg, TErrType aErrType, bool aVerbose, const char* aFileName, int aLineNum); |
|
82 |
|
83 //Format a DN String |
|
84 void DoFormatted(_TCHAR* aDN, struct entry_pack** aEntPack); |
|
85 |
|
86 |
|
87 #endif |