4 * This code is published under the terms of the Acess licence.
5 * See the file COPYING for details.
7 * common.h - Core Header
15 #define DEFAULT_CONFIG_FILE "/etc/opendispense/main.cfg"
16 #define DEFAULT_ITEM_FILE "/etc/opendispense/items.cfg"
18 // === HELPER MACROS ===
20 #define EXPSTR(x) _EXPSTR(x)
23 typedef struct sItem tItem;
24 typedef struct sUser tUser;
25 typedef struct sConfigItem tConfigItem;
26 typedef struct sHandler tHandler;
30 char *Name; //!< Display Name
33 tHandler *Handler; //!< Handler for the item
34 short ID; //!< Item ID
39 int ID; //!< User ID (LDAP ID)
40 int Balance; //!< Balance in cents
41 int Bytes; //!< Traffic Usage
42 char Name[]; //!< Username
54 int (*Init)(int NConfig, tConfigItem *Config);
56 * \brief Check if an item can be dispensed
57 * \return Boolean Failure
59 int (*CanDispense)(int User, int ID);
60 int (*DoDispense)(int User, int ID);
64 extern tItem *gaItems;
65 extern int giNumItems;
66 extern tHandler *gaHandlers[];
67 extern int giNumHandlers;
68 extern int giDebugLevel;
72 extern void CompileRegex(regex_t *Regex, const char *Pattern, int Flags);
73 extern int RunRegex(regex_t *regex, const char *string, int nMatches, regmatch_t *matches, const char *errorMessage);
74 extern int InitSerial(const char *Path, int BaudRate);
75 extern char *mkstr(const char *Format, ...);
78 extern int DispenseItem(int User, tItem *Item);
79 extern int DispenseGive(int SrcUser, int DestUser, int Ammount, const char *ReasonGiven);
80 extern int DispenseAdd(int User, int ByUser, int Ammount, const char *ReasonGiven);
83 extern void Log_Error(const char *Format, ...);
84 extern void Log_Info(const char *Format, ...);
86 // --- Cokebank Functions ---
87 extern int Transfer(int SourceUser, int DestUser, int Ammount, const char *Reason);
88 extern int GetBalance(int User);
89 extern char *GetUserName(int User);
90 extern int GetUserID(const char *Username);