Initial revision
[crypto.git] / lib / silcsim / silcsim.h
1 /*
2
3   silcsim.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 2000 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 #ifndef SILCSIM_H
22 #define SILCSIM_H
23
24 /* All SIM types. New types maybe freely added. */
25 typedef enum {
26   SILC_SIM_NONE = 0,
27   SILC_SIM_CIPHER,
28   SILC_SIM_HASH,
29 } SilcSimType;
30
31 /* 
32    SILC Module (SIM) Context.
33
34    This context holds relevant information about the SIM loaded into
35    the system. Following short description of the fields.
36
37    void *handle
38
39        Pointer to the SIM. This is used to get the symbols out of
40        the SIM. This is initalized by system specific routine.
41
42    SilcSimType type
43
44        Type of the SIM.
45
46    char *libname;
47
48        Filename and path to the SIM library file.
49
50    int flags
51
52        Flags used with the SIM. These are system specific flags.
53        See below for more information.
54
55 */
56 typedef struct {
57   void *handle;
58   SilcSimType type;
59   char *libname;
60   int flags;
61 } SilcSimContext;
62
63 /* Flags used to retrieve the symbols from the library file. Default
64    is that the symbols are resolved as they are loaded. However, if
65    system doesn't support this we have no other choice but to do it lazy
66    thus experience some overhead when using the symbol first time. */
67 #define SILC_SIM_FLAGS RTLD_NOW
68 /*#define SILC_SIM_FLAGS RTLD_LAZY */
69
70 /* Prototypes */
71 SilcSimContext *silc_sim_alloc();
72 void silc_sim_free(SilcSimContext *sim);
73 int silc_sim_load(SilcSimContext *sim);
74 int silc_sim_close(SilcSimContext *sim);
75 char *silc_sim_error();
76 void *silc_sim_getsym(SilcSimContext *sim, const char *symbol);
77
78 #endif