source: ogServer-Git/src/dbi.h @ af47a08

Last change on this file since af47a08 was cbd9421, checked in by OpenGnSys Support Team <soporte-og@…>, 4 years ago

#941 Extend og_dbi_get_computer_info(...)

For the strings in og_computer we do not need to know the max size in
advance but instead we need to free up memmory using
og_dbi_free_computer_info(...) function.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#ifndef __OG_DBI
2#define __OG_DBI
3
4#include <dbi/dbi.h>
5#include <stdbool.h>
6
7struct 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
15struct og_dbi {
16        dbi_conn        conn;
17        dbi_inst        inst;
18};
19
20struct og_dbi *og_dbi_open(struct og_dbi_config *config);
21void 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
33struct 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
43struct 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
51extern struct og_dbi_config dbi_config;
52
53struct 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
73struct in_addr;
74int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer,
75                             struct in_addr addr);
76void og_dbi_free_computer_info(struct og_computer *computer);
77
78#endif
Note: See TracBrowser for help on using the repository browser.