1 | #ifndef __OG_DBI |
---|
2 | #define __OG_DBI |
---|
3 | |
---|
4 | #include <dbi/dbi.h> |
---|
5 | #include <stdbool.h> |
---|
6 | |
---|
7 | struct og_dbi_config { |
---|
8 | const char *user; |
---|
9 | const char *passwd; |
---|
10 | const char *host; |
---|
11 | const char *port; |
---|
12 | const char *database; |
---|
13 | }; |
---|
14 | |
---|
15 | struct og_dbi { |
---|
16 | dbi_conn conn; |
---|
17 | dbi_inst inst; |
---|
18 | }; |
---|
19 | |
---|
20 | struct og_dbi *og_dbi_open(struct og_dbi_config *config); |
---|
21 | void og_dbi_close(struct og_dbi *db); |
---|
22 | |
---|
23 | #define OG_DB_COMPUTER_NAME_MAXLEN 100 |
---|
24 | #define OG_DB_CENTER_NAME_MAXLEN 100 |
---|
25 | #define OG_DB_ROOM_NAME_MAXLEN 100 |
---|
26 | #define OG_DB_IMAGE_NAME_MAXLEN 50 |
---|
27 | #define OG_DB_FILESYSTEM_MAXLEN 16 |
---|
28 | #define OG_DB_INT8_MAXLEN 8 |
---|
29 | #define OG_DB_INT_MAXLEN 11 |
---|
30 | #define OG_DB_IP_MAXLEN 15 |
---|
31 | #define OG_DB_SMALLINT_MAXLEN 6 |
---|
32 | |
---|
33 | struct og_image_legacy { |
---|
34 | char software_id[OG_DB_INT_MAXLEN + 1]; |
---|
35 | char image_id[OG_DB_INT_MAXLEN + 1]; |
---|
36 | char name[OG_DB_IMAGE_NAME_MAXLEN + 1]; |
---|
37 | char repo[OG_DB_IP_MAXLEN + 1]; |
---|
38 | char part[OG_DB_SMALLINT_MAXLEN + 1]; |
---|
39 | char disk[OG_DB_SMALLINT_MAXLEN + 1]; |
---|
40 | char code[OG_DB_INT8_MAXLEN + 1]; |
---|
41 | }; |
---|
42 | |
---|
43 | struct og_legacy_partition { |
---|
44 | char partition[OG_DB_SMALLINT_MAXLEN + 1]; |
---|
45 | char code[OG_DB_INT8_MAXLEN + 1]; |
---|
46 | char size[OG_DB_INT_MAXLEN + 1]; |
---|
47 | char filesystem[OG_DB_FILESYSTEM_MAXLEN + 1]; |
---|
48 | char format[2]; /* Format is a boolean 0 or 1 => length is 2 */ |
---|
49 | }; |
---|
50 | |
---|
51 | extern struct og_dbi_config dbi_config; |
---|
52 | |
---|
53 | struct og_computer { |
---|
54 | unsigned int procedure_id; |
---|
55 | unsigned int hardware_id; |
---|
56 | unsigned int repo_id; |
---|
57 | unsigned int center; |
---|
58 | unsigned int room; |
---|
59 | unsigned int id; |
---|
60 | bool maintenance; |
---|
61 | bool remote; |
---|
62 | char *serial_number; |
---|
63 | char *netdriver; |
---|
64 | char *netiface; |
---|
65 | char *netmask; |
---|
66 | char *livedir; |
---|
67 | char *name; |
---|
68 | char *boot; |
---|
69 | char *mac; |
---|
70 | char *ip; |
---|
71 | }; |
---|
72 | |
---|
73 | struct in_addr; |
---|
74 | int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer, |
---|
75 | struct in_addr addr); |
---|
76 | void og_dbi_free_computer_info(struct og_computer *computer); |
---|
77 | |
---|
78 | #endif |
---|