[2629906] | 1 | #ifndef __OG_DBI |
---|
| 2 | #define __OG_DBI |
---|
| 3 | |
---|
| 4 | #include <dbi/dbi.h> |
---|
[cbd9421] | 5 | #include <stdbool.h> |
---|
[2629906] | 6 | |
---|
| 7 | struct og_dbi_config { |
---|
| 8 | const char *user; |
---|
| 9 | const char *passwd; |
---|
| 10 | const char *host; |
---|
[0631b0e] | 11 | const char *port; |
---|
[2629906] | 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 | |
---|
[9c8e5c7] | 23 | #define OG_DB_COMPUTER_NAME_MAXLEN 100 |
---|
[3d253e6] | 24 | #define OG_DB_CENTER_NAME_MAXLEN 100 |
---|
| 25 | #define OG_DB_ROOM_NAME_MAXLEN 100 |
---|
[04ca20e] | 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 | |
---|
[3cb98c7] | 53 | struct og_computer { |
---|
[cbd9421] | 54 | unsigned int procedure_id; |
---|
| 55 | unsigned int hardware_id; |
---|
| 56 | unsigned int repo_id; |
---|
[3cb98c7] | 57 | unsigned int center; |
---|
| 58 | unsigned int room; |
---|
[cbd9421] | 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; |
---|
[3cb98c7] | 71 | }; |
---|
| 72 | |
---|
| 73 | struct in_addr; |
---|
[d7e2022] | 74 | int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer, |
---|
| 75 | struct in_addr addr); |
---|
[cbd9421] | 76 | void og_dbi_free_computer_info(struct og_computer *computer); |
---|
[3cb98c7] | 77 | |
---|
[2629906] | 78 | #endif |
---|