src/context.h

1
#ifndef __CONTEXT_H__
2
#define __CONTEXT_H__
3
 
4
/*--------------------------------------------------------------------------
5
 * LuaSec 0.4
6
 * Copyright (C) 2006-2009 Bruno Silvestre
7
 *
8
 *--------------------------------------------------------------------------*/
9
 
10
#include <lua.h>
11
#include <openssl/ssl.h>
12
 
13
#if defined(_WIN32)
14
#define LUASEC_API __declspec(dllexport) 
15
#else
16
#define LUASEC_API extern
17
#endif
18
 
19
#define MD_CTX_INVALID 0
20
#define MD_CTX_SERVER 1
21
#define MD_CTX_CLIENT 2
22
 
23
#define LUASEC_VERIFY_FLAGS_NONE            0x0000
24
#define LUASEC_VERIFY_FLAGS_ALWAYS_CONTINUE 0x0001
25
#define LUASEC_VERIFY_FLAGS_IGNORE_PURPOSE  0x0002
26
 
27
typedef struct t_context_ {
28
  SSL_CTX *context;
29
  lua_State *L;
30
  unsigned int verify_flags;
31
  char mode;
32
} t_context;
33
typedef t_context* p_context;
34
 
35
p_context checkctx(lua_State *L, int idx);
36
/* Retrieve the SSL context from the Lua stack */
37
SSL_CTX *ctx_getcontext(lua_State *L, int idx);
38
/* Retrieve the mode from the context in the Lua stack */
39
char ctx_getmode(lua_State *L, int idx);
40
 
41
/* Registre the module. */
42
LUASEC_API int luaopen_ssl_context(lua_State *L);
43
 
44
#endif