4 * This code is published under the terms of the Acess licence.
5 * See the file COPYING for details.
7 * common.h - Core Header
13 #include "../cokebank.h"
16 #define DEFAULT_CONFIG_FILE "/etc/opendispense/main.cfg"
17 #define DEFAULT_ITEM_FILE "/etc/opendispense/items.cfg"
19 // === HELPER MACROS ===
21 #define EXPSTR(x) _EXPSTR(x)
23 #define UNUSED(var) unused__##var __attribute__((__unused__))
26 typedef struct sItem tItem;
27 typedef struct sUser tUser;
28 typedef struct sConfigItem tConfigItem;
29 typedef struct sHandler tHandler;
33 char *Name; //!< Display Name
36 tHandler *Handler; //!< Handler for the item
37 short ID; //!< Item ID
42 int ID; //!< User ID (LDAP ID)
43 int Balance; //!< Balance in cents
44 int Bytes; //!< Traffic Usage
45 char Name[]; //!< Username
57 int (*Init)(int NConfig, tConfigItem *Config);
59 * \brief Check if an item can be dispensed
60 * \return Boolean Failure
62 int (*CanDispense)(int User, int ID);
63 int (*DoDispense)(int User, int ID);
67 extern tItem *gaItems;
68 extern int giNumItems;
69 extern tHandler *gaHandlers[];
70 extern int giNumHandlers;
71 extern int giDebugLevel;
75 extern void CompileRegex(regex_t *Regex, const char *Pattern, int Flags);
76 extern int RunRegex(regex_t *regex, const char *string, int nMatches, regmatch_t *matches, const char *errorMessage);
77 extern int InitSerial(const char *Path, int BaudRate);
78 extern char *mkstr(const char *Format, ...);
81 extern int DispenseItem(int ActualUser, int User, tItem *Item);
82 extern int DispenseGive(int ActualUser, int SrcUser, int DestUser, int Ammount, const char *ReasonGiven);
83 extern int DispenseAdd(int ActualUser, int User, int Ammount, const char *ReasonGiven);
84 extern int DispenseSet(int ActualUser, int User, int Balance, const char *ReasonGiven);
85 extern int DispenseDonate(int ActualUser, int User, int Ammount, const char *ReasonGiven);
88 extern void Log_Error(const char *Format, ...);
89 extern void Log_Info(const char *Format, ...);