Restructured code into src/<module>
[tpg/opendispense2.git] / server / src / common.h
1 /*
2  * OpenDispense2
3  *
4  * This code is published under the terms of the Acess licence.
5  * See the file COPYING for details.
6  *
7  * common.h - Core Header
8  */
9 #ifndef _COMMON_H_
10 #define _COMMON_H_
11
12 // === CONSTANTS ===
13 #define DEFAULT_CONFIG_FILE     "/etc/opendispense/main.cfg"
14 #define DEFAULT_ITEM_FILE       "/etc/opendispense/items.cfg"
15
16 // === HELPER MACROS ===
17 #define _EXPSTR(x)      #x
18 #define EXPSTR(x)       _EXPSTR(x)
19
20 // === STRUCTURES ===
21 typedef struct sItem    tItem;
22 struct sItem
23 {
24         char    *Name;  //!< Display Name
25          int    Price;  //!< Price
26         
27         short   Type;   //!< References an action
28         short   ID;     //!< Item ID
29 };
30
31 typedef struct sUser    tUser;
32 struct sUser
33 {
34          int    ID;             //!< User ID (LDAP ID)
35          int    Balance;        //!< Balance in cents
36          int    Bytes;  //!< Traffic Usage
37         char    Name[]; //!< Username
38 };
39
40 typedef struct sHandler tHandler;
41 struct sHandler
42 {
43         char    *Name;
44          int    (*CanDispense)(int User, int ID);
45          int    (*DoDispense)(int User, int ID);
46 };
47
48 // === GLOBALS ===
49 extern tItem    *gaItems;
50 extern int      giNumItems;
51 extern tHandler *gaHandlers;
52 extern int      giDebugLevel;
53
54 // === FUNCTIONS ===
55 // --- Logging ---
56 extern void     Log_Error(const char *Format, ...);
57 extern void     Log_Info(const char *Format, ...);
58
59 // --- Cokebank Functions ---
60 extern int      AlterBalance(int User, int Ammount);
61 extern int      GetBalance(int User);
62 extern char     *GetUserName(int User);
63 extern int      GetUserID(const char *Username);
64
65 #endif

UCC git Repository :: git.ucc.asn.au