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

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

#941 pass og_dbi to og_dbi_get_computer_info()

Reuse the existing dbi handler, instead of opening a new one.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#ifndef __OG_DBI
2#define __OG_DBI
3
4#include <dbi/dbi.h>
5
6struct og_dbi_config {
7        const char      *user;
8        const char      *passwd;
9        const char      *host;
10        const char      *port;
11        const char      *database;
12};
13
14struct og_dbi {
15        dbi_conn        conn;
16        dbi_inst        inst;
17};
18
19struct og_dbi *og_dbi_open(struct og_dbi_config *config);
20void og_dbi_close(struct og_dbi *db);
21
22#define OG_DB_COMPUTER_NAME_MAXLEN      100
23#define OG_DB_CENTER_NAME_MAXLEN        100
24#define OG_DB_ROOM_NAME_MAXLEN          100
25#define OG_DB_IMAGE_NAME_MAXLEN 50
26#define OG_DB_FILESYSTEM_MAXLEN 16
27#define OG_DB_INT8_MAXLEN       8
28#define OG_DB_INT_MAXLEN        11
29#define OG_DB_IP_MAXLEN         15
30#define OG_DB_SMALLINT_MAXLEN   6
31
32struct og_image_legacy {
33        char software_id[OG_DB_INT_MAXLEN + 1];
34        char image_id[OG_DB_INT_MAXLEN + 1];
35        char name[OG_DB_IMAGE_NAME_MAXLEN + 1];
36        char repo[OG_DB_IP_MAXLEN + 1];
37        char part[OG_DB_SMALLINT_MAXLEN + 1];
38        char disk[OG_DB_SMALLINT_MAXLEN + 1];
39        char code[OG_DB_INT8_MAXLEN + 1];
40};
41
42struct og_legacy_partition {
43        char partition[OG_DB_SMALLINT_MAXLEN + 1];
44        char code[OG_DB_INT8_MAXLEN + 1];
45        char size[OG_DB_INT_MAXLEN + 1];
46        char filesystem[OG_DB_FILESYSTEM_MAXLEN + 1];
47        char format[2]; /* Format is a boolean 0 or 1 => length is 2 */
48};
49
50extern struct og_dbi_config dbi_config;
51
52struct og_computer {
53        unsigned int    id;
54        unsigned int    center;
55        unsigned int    room;
56        char            name[OG_DB_COMPUTER_NAME_MAXLEN + 1];
57        unsigned int    procedure_id;
58};
59
60struct in_addr;
61int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer,
62                             struct in_addr addr);
63
64#endif
Note: See TracBrowser for help on using the repository browser.