Add.
[shishi.git] / db / info.h
blobed4be83b9c98e747f655eb69bbde54de157c3aff
1 /* info.h --- Internal header file for shisa library.
2 * Copyright (C) 2002, 2003, 2004, 2007 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 prototypes. */
47 #include "shisa.h"
49 typedef int (*_Shisa_db_init) (Shisa * dbh,
50 const char *location,
51 const char *options, void **state);
52 typedef void (*_Shisa_db_done) (Shisa * dbh, void *state);
54 typedef int (*_Shisa_db_enumerate_realms) (Shisa * dbh,
55 void *state,
56 char ***realms, size_t * nrealms);
57 typedef int (*_Shisa_db_enumerate_principals) (Shisa * dbh,
58 void *state,
59 const char *realm,
60 char ***principals,
61 size_t * nprincipals);
63 typedef int (*_Shisa_db_principal_find) (Shisa * dbh,
64 void *state,
65 const char *realm,
66 const char *principal,
67 Shisa_principal * ph);
68 typedef int (*_Shisa_db_principal_update) (Shisa * dbh,
69 void *state,
70 const char *realm,
71 const char *principal,
72 const Shisa_principal * ph);
73 typedef int (*_Shisa_db_principal_add) (Shisa * dbh,
74 void *state,
75 const char *realm,
76 const char *principal,
77 const Shisa_principal * ph,
78 const Shisa_key * key);
79 typedef int (*_Shisa_db_principal_remove) (Shisa * dbh,
80 void *state,
81 const char *realm,
82 const char *principal);
84 typedef int (*_Shisa_db_keys_find) (Shisa * dbh,
85 void *state,
86 const char *realm,
87 const char *principal,
88 const Shisa_key * hint,
89 Shisa_key *** keys, size_t * nkeys);
90 typedef int (*_Shisa_db_key_add) (Shisa * dbh,
91 void *state,
92 const char *realm,
93 const char *principal,
94 const Shisa_key * key);
95 typedef int (*_Shisa_db_key_update) (Shisa * dbh,
96 void *state,
97 const char *realm,
98 const char *principal,
99 const Shisa_key * oldkey,
100 const Shisa_key * newkey);
101 typedef int (*_Shisa_db_key_remove) (Shisa * dbh,
102 void *state,
103 const char *realm,
104 const char *principal,
105 const Shisa_key * key);
107 struct _Shisa_backend
109 const char *name;
110 _Shisa_db_init init;
111 _Shisa_db_done done;
112 _Shisa_db_enumerate_realms enumerate_realms;
113 _Shisa_db_enumerate_principals enumerate_principals;
114 _Shisa_db_principal_find principal_find;
115 _Shisa_db_principal_update principal_update;
116 _Shisa_db_principal_add principal_add;
117 _Shisa_db_principal_remove principal_remove;
118 _Shisa_db_keys_find keys_find;
119 _Shisa_db_key_add key_add;
120 _Shisa_db_key_update key_update;
121 _Shisa_db_key_remove key_remove;
123 typedef struct _Shisa_backend _Shisa_backend;
125 struct _Shisa_db
127 _Shisa_backend *backend;
128 void *state;
130 typedef struct _Shisa_db _Shisa_db;
132 struct Shisa
134 _Shisa_db *dbs;
135 size_t ndbs;
138 /* Return structure with function pointers implementing a Shisa
139 backend, given a name (e.g., "file"). */
140 extern _Shisa_backend *_shisa_find_backend (const char *name);
142 #endif /* _INFO_H */