Update.
[shishi.git] / db / info.h
blob353fe9d9e8403ac049e4e2d51e0d529829892e34
1 /* info.h --- Internal header file for shisa library.
2 * Copyright (C) 2002, 2003, 2004 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 #ifndef _INFO_H
23 #define _INFO_H
25 #if HAVE_CONFIG_H
26 # include "config.h"
27 #endif
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <stdarg.h>
32 #include <ctype.h>
33 #include <string.h>
35 #include "gettext.h"
36 #define _(String) dgettext (PACKAGE, String)
37 #define gettext_noop(String) String
38 #define N_(String) gettext_noop (String)
40 /* Get xmalloc. */
41 #include "xalloc.h"
43 /* Get getline, ssize_t. */
44 #include "getline.h"
46 /* Get getsubopt. */
47 #include "getsubopt.h"
49 /* Get prototypes. */
50 #include "shisa.h"
52 typedef int (*_Shisa_db_init) (Shisa * dbh,
53 const char *location,
54 const char *options, void **state);
55 typedef void (*_Shisa_db_done) (Shisa * dbh, void *state);
57 typedef int (*_Shisa_db_enumerate_realms) (Shisa * dbh,
58 void *state,
59 char ***realms, size_t * nrealms);
60 typedef int (*_Shisa_db_enumerate_principals) (Shisa * dbh,
61 void *state,
62 const char *realm,
63 char ***principals,
64 size_t * nprincipals);
66 typedef int (*_Shisa_db_principal_find) (Shisa * dbh,
67 void *state,
68 const char *realm,
69 const char *principal,
70 Shisa_principal * ph);
71 typedef int (*_Shisa_db_principal_update) (Shisa * dbh,
72 void *state,
73 const char *realm,
74 const char *principal,
75 const Shisa_principal * ph);
76 typedef int (*_Shisa_db_principal_add) (Shisa * dbh,
77 void *state,
78 const char *realm,
79 const char *principal,
80 const Shisa_principal * ph,
81 const Shisa_key * key);
82 typedef int (*_Shisa_db_principal_remove) (Shisa * dbh,
83 void *state,
84 const char *realm,
85 const char *principal);
87 typedef int (*_Shisa_db_keys_find) (Shisa * dbh,
88 void *state,
89 const char *realm,
90 const char *principal,
91 const Shisa_key * hint,
92 Shisa_key *** keys, size_t * nkeys);
93 typedef int (*_Shisa_db_key_add) (Shisa * dbh,
94 void *state,
95 const char *realm,
96 const char *principal,
97 const Shisa_key * key);
98 typedef int (*_Shisa_db_key_update) (Shisa * dbh,
99 void *state,
100 const char *realm,
101 const char *principal,
102 const Shisa_key * oldkey,
103 const Shisa_key * newkey);
104 typedef int (*_Shisa_db_key_remove) (Shisa * dbh,
105 void *state,
106 const char *realm,
107 const char *principal,
108 const Shisa_key * key);
110 struct _Shisa_backend
112 const char *name;
113 _Shisa_db_init init;
114 _Shisa_db_done done;
115 _Shisa_db_enumerate_realms enumerate_realms;
116 _Shisa_db_enumerate_principals enumerate_principals;
117 _Shisa_db_principal_find principal_find;
118 _Shisa_db_principal_update principal_update;
119 _Shisa_db_principal_add principal_add;
120 _Shisa_db_principal_remove principal_remove;
121 _Shisa_db_keys_find keys_find;
122 _Shisa_db_key_add key_add;
123 _Shisa_db_key_update key_update;
124 _Shisa_db_key_remove key_remove;
126 typedef struct _Shisa_backend _Shisa_backend;
128 struct _Shisa_db
130 _Shisa_backend *backend;
131 void *state;
133 typedef struct _Shisa_db _Shisa_db;
135 struct Shisa
137 _Shisa_db *dbs;
138 size_t ndbs;
141 /* Return structure with function pointers implementing a Shisa
142 backend, given a name (e.g., "file"). */
143 extern _Shisa_backend *_shisa_find_backend (const char *name);
145 #endif /* _INFO_H */