File: frontend.h

package info (click to toggle)
cdebconf 0.227
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,552 kB
  • sloc: ansic: 16,568; sh: 549; makefile: 456; sql: 52; perl: 13
file content (91 lines) | stat: -rw-r--r-- 2,850 bytes parent folder | download | duplicates (5)
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
/**
 * @file frontend.h
 * @brief debconf frontend interface
 */
#ifndef _FRONTEND_H_
#define _FRONTEND_H_

#include <stdbool.h>

#include "constants.h"

#undef _
#define _(x) (x)

struct configuration;
struct template_db;
struct question_db;
struct question;
struct frontend;

#define DCF_CAPB_BACKUP		(1UL << 0)
#define DCF_CAPB_PROGRESSCANCEL	(1UL << 1)
#define DCF_CAPB_ALIGN		(1UL << 2)
#define DCF_CAPB_ESCAPE		(1UL << 3)

struct frontend_module {
    int (*initialize)(struct frontend *, struct configuration *);
    int (*shutdown)(struct frontend *);
    unsigned long (*query_capability)(struct frontend *);
    const char * (*lookup_directive)(struct frontend *, const char *);
    void (*set_title)(struct frontend *, const char *title);
    void (*info)(struct frontend *, struct question *);
    int (*add)(struct frontend *, struct question *q);
    int (*go)(struct frontend *);
    void (*clear)(struct frontend *);
    bool (*can_go_back)(struct frontend *, struct question *);
    bool (*can_go_forward)(struct frontend *, struct question *);
    bool (*can_cancel_progress)(struct frontend *);
    bool (*can_align)(struct frontend *, struct question *);

    void (*progress_start)(struct frontend *fe, int min, int max, struct question *title);
    int (*progress_set) (struct frontend *fe, int val);
    /* You do not have to implement _step, it will call _set by default */
    int (*progress_step)(struct frontend *fe, int step);
    int (*progress_info)(struct frontend *fe, struct question *info);
    void (*progress_stop)(struct frontend *fe);
   
    int (*go_noninteractive)(struct frontend *);
    int (*add_noninteractive)(struct frontend *, struct question *q);
};

struct frontend {
    /* module name */
    char *name;
    /* module handle */
    void *handle;
    /* configuration data */
    struct configuration *config;
    /* config path - base of instance configuration */
    char configpath[DEBCONF_MAX_CONFIGPATH_LEN];
    /* database handle for templates and config */
    struct template_db *tdb;
    struct question_db *qdb;
    /* frontend capabilities */
    unsigned long capability;
    /* private data */
    void *data;
    
    /* class variables */
    struct question *questions;
    int interactive;
    char *capb;
    char *title;
    struct question *info;
    struct question *progress_title;
    int progress_min, progress_max, progress_cur;
    	
    /* methods */
    struct frontend_module methods;
    /* path to plugins */
    char *plugin_path;
    	/* separate list of noninteractive questions */
	struct question *questions_noninteractive;
};

struct frontend *frontend_new(struct configuration *, struct template_db *, struct question_db *);
void frontend_delete(struct frontend *);

int frontend_qdb_set(struct question_db *qdb, struct question *q, const char *prev);

#endif