Version 1.3.10
[yazproxy-moved-to-github.git] / include / yazproxy / module.h
1 /* This file is part of YAZ proxy
2    Copyright (C) 1998-2011 Index Data
3
4 YAZ proxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef YAZ_PROXY_MODULE_H
20 #define YAZ_PROXY_MODULE_H_INCLUDED
21
22 struct Yaz_ProxyModule_entry {
23     int int_version;
24     const char *module_name;
25     const char *module_description;
26     void *fl;
27 };
28
29 #define  YAZPROXY_RET_NOT_ME 0 /* Did not catch it. pass to other handler */
30 #define  YAZPROXY_RET_OK     1 /* OK, grabbed */
31 #define  YAZPROXY_RET_PERM   2 /* Permissiong denied, reject etc. */
32
33 struct Yaz_ProxyModule_int0 {
34     void *(*init)(void);   // Init handler - returns module-specific handle
35
36     void (*destroy)(       // Destroy handler
37         void *handle       // module-specific handle as returned by init
38         );
39
40     int (*authenticate)(   // Authenticate handler. Returns YAZPROXY_RET_..
41         void *handle,      // module-specific handle as returned by init
42         const char *name,  // target name (or NULL if default target)
43         void *element_ptr, // xmlnodePtr thing to XML config this
44         const char *user,  // User ID (or NULL if no suppliied User ID)
45         const char *group, // Group ID (or NULL if no supplied Group ID)
46         const char *pw,    // Password (or NULL if no supplied password)
47         const char *peer_IP// IP address of client
48     );
49 };
50
51 class Yaz_ProxyModule;
52
53 class Yaz_ProxyModules {
54     friend class Proxy_Msg;
55  public:
56     Yaz_ProxyModules();
57     ~Yaz_ProxyModules();
58     int authenticate(const char *module_name,
59                      const char *target_name, void *element_ptr,
60                      const char *user,
61                      const char *group,
62                      const char *password,
63                      const char *peer_IP);
64     int add_module(const char *fname);
65     void unload_modules();
66  private:
67     Yaz_ProxyModule *m_list;
68     int m_no_open;
69 };
70
71 #endif
72 /*
73  * Local variables:
74  * c-basic-offset: 4
75  * c-file-style: "Stroustrup"
76  * indent-tabs-mode: nil
77  * End:
78  * vim: shiftwidth=4 tabstop=8 expandtab
79  */
80