File: database.h

package info (click to toggle)
cdebconf 0.138lenny3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,184 kB
  • ctags: 1,371
  • sloc: ansic: 14,158; sh: 469; makefile: 429; sql: 51; perl: 13
file content (125 lines) | stat: -rw-r--r-- 3,756 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
 *
 * @file database.h
 * @brief Database class definition
 *
 */
#ifndef _DATABASE_H_
#define _DATABASE_H_

/* Debconf database interfaces */

struct configuration;
struct template;
struct template_db;
struct question;
struct question_db;

/**
 * @brief Methods for a template database module
 */
struct template_db_module {
    int (*initialize)(struct template_db *db, struct configuration *cfg);
    int (*shutdown)(struct template_db *db);
    int (*load)(struct template_db *db);
    int (*reload)(struct template_db *db);
    int (*save)(struct template_db *db);
    int (*set)(struct template_db *db, struct template *t);
    struct template *(*get)(struct template_db *db, const char *name);
    int (*remove)(struct template_db *, const char *name);
    int (*lock)(struct template_db *, const char *name);
    int (*unlock)(struct template_db *, const char *name);
    struct template *(*iterate)(struct template_db *db, void **iter);
    int (*accept)(struct template_db *, const char *name, const char *type);
};

/**
 * @brief Methods for a question database module
 */
struct question_db_module {
    int (*initialize)(struct question_db *db, struct configuration *cfg);
    int (*shutdown)(struct question_db *db);
    int (*load)(struct question_db *db);
    int (*save)(struct question_db *db);
    int (*set)(struct question_db *, struct question *q);
    struct question *(*get)(struct question_db *db, const char *name);
    int (*disown)(struct question_db *, const char *name, const char *owner);
    int (*disownall)(struct question_db *, const char *owner);
    int (*remove)(struct question_db *, const char *name);
    int (*lock)(struct question_db *, const char *name);
    int (*unlock)(struct question_db *, const char *name);
    int (*is_visible)(struct question_db *, const char *name, const char *priority);
    struct question *(*iterate)(struct question_db *, void **iter);
    int (*accept)(struct question_db *, const char *name, const char *type);
};

/**
 * @brief Template database object
 */
struct template_db {
    /** db module name */
    char *modname;
    /** db module handle */
    void *handle;
    /** configuration data */
    struct configuration *config;
    /** config path - base of instance configuration */
    char configpath[DEBCONF_MAX_CONFIGPATH_LEN];
    /** private data */
    void *data; 

    /** methods */
    struct template_db_module methods;
};

/**
 * @brief Question database object
 */
struct question_db {
    /** db module name */
    char *modname;
    /** db module handle */
    void *handle;
    /** configuration data */
    struct configuration *config;
    /** config path - base of instance configuration */
    char configpath[DEBCONF_MAX_CONFIGPATH_LEN];
    /** private data */
    void *data; 
    /** template database */
    struct template_db *tdb;

    /** methods */
    struct question_db_module methods;
};

/**
 * @brief Create a new template db object
 * @param cfg configuration
 * @param instance Name of instance (NULL for default)
 * @return Newly created db object
 */
struct template_db *template_db_new(struct configuration *cfg, const char *instance);

/**
 * @brief Destroy a template db oject
 * @param db Object to destroy
 */
void template_db_delete(struct template_db *db);

/**
 * @brief Create a new question db object
 * @param cfg configuration
 * @param tdb associated template database object
 * @param instance Name of instance (NULL for default)
 * @return Newly created db object
 */
struct question_db *question_db_new(struct configuration *cfg, struct template_db *tdb, const char *instance);

/**
 * @brief Destroy a question db oject
 * @param db Object to destroy
 */
void question_db_delete(struct question_db *db);

#endif