wined3d: Fix NULL dereference in generator function.
[wine] / dlls / secur32 / secur32_priv.h
1 /*
2  * secur32 private definitions.
3  *
4  * Copyright (C) 2004 Juan Lang
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __SECUR32_PRIV_H__
22 #define __SECUR32_PRIV_H__
23
24 #include <sys/types.h>
25 #include "wine/list.h"
26
27 /* Memory allocation functions for memory accessible by callers of secur32.
28  * The details are implementation specific.
29  */
30 #define SECUR32_ALLOC(bytes) HeapAlloc(GetProcessHeap(), 0, (bytes))
31 #define SECUR32_FREE(p)      HeapFree(GetProcessHeap(), 0, (p))
32
33 typedef struct _SecureProvider
34 {
35     struct list             entry;
36     BOOL                    loaded;
37     PWSTR                   moduleName;
38     HMODULE                 lib;
39     SecurityFunctionTableA  fnTableA;
40     SecurityFunctionTableW  fnTableW;
41 } SecureProvider;
42
43 typedef struct _SecurePackage
44 {
45     struct list     entry;
46     SecPkgInfoW     infoW;
47     SecureProvider *provider;
48 } SecurePackage;
49
50 typedef enum _helper_mode {
51     NTLM_SERVER,
52     NTLM_CLIENT,
53     NEGO_SERVER,
54     NEGO_CLIENT,
55     NUM_HELPER_MODES
56 } HelperMode;
57
58 typedef struct _NegoHelper {
59     pid_t helper_pid;
60     HelperMode mode;
61     SEC_CHAR *password;
62     int pwlen;
63     int pipe_in;
64     int pipe_out;
65     int version;
66     char *com_buf;
67     int com_buf_size;
68     int com_buf_offset;
69 } NegoHelper, *PNegoHelper;
70
71 /* Allocates space for and initializes a new provider.  If fnTableA or fnTableW
72  * is non-NULL, assumes the provider is built-in (and is thus already loaded.)
73  * Otherwise moduleName must not be NULL.
74  * Returns a pointer to the stored provider entry, for use adding packages.
75  */
76 SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
77  const SecurityFunctionTableW *fnTableW, const PWSTR moduleName);
78
79 /* Allocates space for and adds toAdd packages with the given provider.
80  * provider must not be NULL, and either infoA or infoW may be NULL, but not
81  * both.
82  */
83 void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
84  const SecPkgInfoA *infoA, const SecPkgInfoW *infoW);
85
86 /* Tries to find the package named packageName.  If it finds it, implicitly
87  * loads the package if it isn't already loaded.
88  */
89 SecurePackage *SECUR32_findPackageW(PWSTR packageName);
90
91 /* Tries to find the package named packageName.  (Thunks to _findPackageW)
92  */
93 SecurePackage *SECUR32_findPackageA(PSTR packageName);
94
95 /* A few string helpers; will return NULL if str is NULL.  Free return with
96  * SECUR32_FREE */
97 PWSTR SECUR32_strdupW(PCWSTR str);
98 PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str);
99 PSTR  SECUR32_AllocMultiByteFromWide(PCWSTR str);
100
101 /* Initialization functions for built-in providers */
102 void SECUR32_initSchannelSP(void);
103 void SECUR32_initNegotiateSP(void);
104 void SECUR32_initNTLMSP(void);
105
106 /* Functions from dispatcher.c used elsewhere in the code */
107 SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
108         char * const argv[]);
109
110 SECURITY_STATUS run_helper(PNegoHelper helper, char *buffer,
111         unsigned int max_buflen, int *buflen);
112
113 void cleanup_helper(PNegoHelper helper);
114
115 void check_version(PNegoHelper helper);
116
117 /* Functions from base64_codec.c used elsewhere */
118 SECURITY_STATUS encodeBase64(PBYTE in_buf, int in_len, char* out_buf, 
119         int max_len, int *out_len);
120
121 SECURITY_STATUS decodeBase64(char *in_buf, int in_len, BYTE *out_buf, 
122         int max_len, int *out_len);
123
124 #endif /* ndef __SECUR32_PRIV_H__ */