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_SERIAL_NUMBER_MAXLEN 25 |
---|
27 | #define OG_DB_IMAGE_NAME_MAXLEN 50 |
---|
28 | #define OG_DB_FILESYSTEM_MAXLEN 16 |
---|
29 | #define OG_DB_NETDRIVER_MAXLEN 30 |
---|
30 | #define OG_DB_NETIFACE_MAXLEN 4 |
---|
31 | #define OG_DB_LIVEDIR_MAXLEN 50 |
---|
32 | #define OG_DB_INT8_MAXLEN 8 |
---|
33 | #define OG_DB_BOOT_MAXLEN 30 |
---|
34 | #define OG_DB_INT_MAXLEN 11 |
---|
35 | #define OG_DB_MAC_MAXLEN 15 |
---|
36 | #define OG_DB_IP_MAXLEN 15 |
---|
37 | #define OG_DB_SMALLINT_MAXLEN 6 |
---|
38 | |
---|
39 | struct og_image_legacy { |
---|
40 | char software_id[OG_DB_INT_MAXLEN + 1]; |
---|
41 | char image_id[OG_DB_INT_MAXLEN + 1]; |
---|
42 | char name[OG_DB_IMAGE_NAME_MAXLEN + 1]; |
---|
43 | char repo[OG_DB_IP_MAXLEN + 1]; |
---|
44 | char part[OG_DB_SMALLINT_MAXLEN + 1]; |
---|
45 | char disk[OG_DB_SMALLINT_MAXLEN + 1]; |
---|
46 | char code[OG_DB_INT8_MAXLEN + 1]; |
---|
47 | }; |
---|
48 | |
---|
49 | struct og_legacy_partition { |
---|
50 | char partition[OG_DB_SMALLINT_MAXLEN + 1]; |
---|
51 | char code[OG_DB_INT8_MAXLEN + 1]; |
---|
52 | char size[OG_DB_INT_MAXLEN + 1]; |
---|
53 | char filesystem[OG_DB_FILESYSTEM_MAXLEN + 1]; |
---|
54 | char format[2]; /* Format is a boolean 0 or 1 => length is 2 */ |
---|
55 | }; |
---|
56 | |
---|
57 | extern struct og_dbi_config dbi_config; |
---|
58 | |
---|
59 | struct og_computer { |
---|
60 | unsigned int procedure_id; |
---|
61 | unsigned int hardware_id; |
---|
62 | unsigned int repo_id; |
---|
63 | unsigned int center; |
---|
64 | unsigned int room; |
---|
65 | unsigned int id; |
---|
66 | bool maintenance; |
---|
67 | bool remote; |
---|
68 | char serial_number[OG_DB_SERIAL_NUMBER_MAXLEN + 1]; |
---|
69 | char netdriver[OG_DB_NETDRIVER_MAXLEN + 1]; |
---|
70 | char name[OG_DB_COMPUTER_NAME_MAXLEN + 1]; |
---|
71 | char netiface[OG_DB_NETIFACE_MAXLEN + 1]; |
---|
72 | char livedir[OG_DB_LIVEDIR_MAXLEN + 1]; |
---|
73 | char netmask[OG_DB_IP_MAXLEN + 1]; |
---|
74 | char boot[OG_DB_BOOT_MAXLEN + 1]; |
---|
75 | char mac[OG_DB_MAC_MAXLEN + 1]; |
---|
76 | char ip[OG_DB_IP_MAXLEN + 1]; |
---|
77 | }; |
---|
78 | |
---|
79 | struct in_addr; |
---|
80 | int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer, |
---|
81 | struct in_addr addr); |
---|
82 | |
---|
83 | #endif |
---|