]> git.neil.brown.name Git - TABS.git/blob - database/db_header.h
Terminal Alocation and Booking System - June 2006
[TABS.git] / database / db_header.h
1 /* standard include files for all modules associated with the database */
2  /* manager  */
3 #include        <rpc/rpc.h>
4 #include        <string.h>
5 #include        <gdbm.h>
6 #include        "../database/database.h"
7
8 #include        "../lib/misc.h"
9 #ifdef linux
10 #define SVC(x) x ## _svc
11 #else
12 #define SVC(x) x
13 #endif
14
15 /*  this is  the directory containing the database files */
16
17
18 /* some special keys for the database */
19 #define DOMAIN_KEY "_DOMAIN_"  /* the domain of the database.. not */
20                                /* always used */
21 #define STATUS_KEY "_STATUS_" /* the status of the database.. the */
22                               /* update time, reorg time */
23 #define ATTR_TYPE_KEY "_ATTR_TYPE_1_"
24 #define HOST_SETS "_HOSTS_SETS_" /* key of the sets in the hosts */
25                                   /* database */
26 #define LogFile "db_log"
27
28 /* some stuff for bitstrings */
29 #define BITSTRLEN 16  /* size in characters */
30 #define BITINDMAX BITSTRLEN * sizeof(char)  *8  /* size in bits */
31
32 #define MAXCHANGES 20  /* the maximum number of changes to transfer in */
33                        /* one go */
34
35 #define PRIV_REFUND_FLAG 0x8000
36
37 #ifdef _AM_MAIN_
38 #include        "db_globals.h"
39 #else
40 #include        "db_extern.h"
41 #endif
42
43 #include        <stdio.h>
44
45 typedef struct CLIENTHOST {
46     CLIENT * client;
47     char * host;
48 } CLIENTHOST;
49
50 #define Malloc(ptr,type) ptr=(type *)malloc(sizeof(type));if (ptr == NULL) {printf("no memory\n"); exit(33); }
51
52
53
54 #include        "common.h"
55
56 /* from descpairlist.c */
57 void add_to_descpairlist(descpairlist * ch, description * new, int num);
58 book_changeres del_from_descpairlist(descpairlist * ch, description *name);
59 descpairlist finddesc(descpairlist *ch, description * key);
60 void incdesc(descpairlist *ch, description * key, int diff);
61
62 /* from db_utils.c */
63 query_reply * generic_query(query_req * query);
64 int db_open(db_number db, int gdbm_mode);
65 void close_db(db_number db);
66 book_changeres read_db(item key, void * data, int data_size, xdrproc_t xdr_fn,  db_number db );
67 book_changeres update_status_key(db_number db, int update_time, int reorganise_time);
68 void get_status_key(db_number db, time_t *update_time, time_t *reorganise_time);
69 book_changeres write_db(item key, void * data, xdrproc_t xdr_fn, db_number db);
70 book_changeres delete_from_db(item key, db_number db);
71
72 /* from config_db.c */
73 book_changeres change_implication(impls * impl);
74 void init_attr_types();
75 book_changeres change_attr_type(attr_type_desc *attrs);
76 book_changeres change_configdata(configdata * configent);
77
78
79 /* from db_change.c */
80 void get_replica_header(char *host);
81 void sync_replica_header();
82 int change_init(void);
83 void close_change(void);
84 book_changeres commit(book_changeent *ch);
85 void free_changes(change_reply reply);
86 void change_del_changes(char *replica, int highest);
87
88 /* from replica_db.c */
89 int replica_grow(machine_name machine, replica_no height);
90 book_changeres replica_add(machine_name server);
91 book_changeres replica_del(machine_name server);
92 int replica_init();
93
94 /* from db_transfer */
95 void collect_xfer(void);
96 void send_database(int sock, db_number db);
97
98 /* from users_db.h */
99 book_changeres add_user_booking(book_req * booking, int clientreq);
100 book_changeres change_user_booking(book_chng * bchanges, int *refund, int *tokens, int *who_by);
101 book_changeres del_user_booking(bookuid_t user, int when, book_key *bk);
102 book_changeres del_user(bookuid_t user);
103
104 /* from bookings_db.c */
105 book_changeres add_booking_to_list(bookhead * blist, book_req *req);
106 book_changeres incuser(bookhead *bh, book_req *req);
107 book_changeres read_bookhead(bookhead *bh, book_key *key);
108 book_changeres write_bookhead(bookhead *bh, book_key *key);
109 book_changeres add_booking(book_req * booking);
110 int inc_usage_count(slotgroup *slot, int number);
111 book_changeres change_booking(book_chng *bchanges, int *refund, int *tokens, int *who_by);
112 booklist map_bookings(bookuid_t user, userbookinglist list);
113 book_changeres remove_booking(book_key * removal);
114
115 /* from classes_db.c */
116 book_changeres add_class(class_req * cl_req);
117 book_changeres set_allotment(int uid, int tok, int cnt);
118
119
120 /* from freeslots.c */
121 utilizationlist *free_slots(slotlist sl);
122
123 /* from main.c */
124 bool_t open_dbs(int gdbm_stat);
125 void close_dbs(void);
126 void init_db(void);
127 void close_all(void);
128 void start_helper(void);
129 void kill_helper(void);
130 SIGRTN die();
131 void check_update_status(void);