9b9d2a12d3cbe569e025e0ed3248304a6865533a
[tpg/opendispense2.git] / src / cokebank.h
1 /*
2  * OpenDispense 2 
3  * UCC (University [of WA] Computer Club) Electronic Accounting System
4  *
5  * cokebank.h - Coke-Bank common definitions
6  *
7  * This file is licenced under the 3-clause BSD Licence. See the file COPYING
8  * for full details.
9  */
10 #ifndef _COKEBANK_H_
11 #define _COKEBANK_H_
12
13 #define COKEBANK_SALES_ACCT     ">sales"        //!< Sales made into
14 #define COKEBANK_DEBT_ACCT      ">liability"    //!< Credit taken out of
15
16 enum eCokebank_Flags {
17         USER_FLAG_TYPEMASK = 0x03,
18         USER_TYPE_NORMAL = 0x00,
19         USER_TYPE_COKE   = 0x01,
20         USER_TYPE_WHEEL  = 0x02,
21         USER_TYPE_GOD    = 0x03,
22         
23         USER_FLAG_DOORGROUP = 0x40,
24         USER_FLAG_DISABLED  = 0x80
25 };
26
27 // --- Cokebank Functions ---
28 /**
29  * \brief Transfer money from one account to another
30  * \param SourceUser    UID (from \a GetUserID) to take the money from
31  * \param DestUser      UID (from \a GetUserID) give money to
32  * \param Ammount       Amount of money (in cents) to transfer
33  * \param Reason        Reason for the transfer
34  */
35 extern int      Transfer(int SourceUser, int DestUser, int Ammount, const char *Reason);
36 /**
37  * \brief Get flags on an account
38  * \param User  UID to get flags from
39  * \see eCokebank_Flags
40  */
41 extern int      GetFlags(int User);
42 /**
43  * \brief Set an account's flags
44  * \param User  UID to set flags on
45  * \param Mask  Mask of flags changed
46  * \param Value Final value of changed flags
47  */
48 extern int      SetFlags(int User, int Mask, int Value);
49 /**
50  * \brief Get an account's balance
51  * \param User  UID to query
52  */
53 extern int      GetBalance(int User);
54 /**
55  * \brief Get the name associated with an account
56  * \return Heap string
57  */
58 extern char     *GetUserName(int User);
59 /**
60  * \brief Get a UID from a passed name
61  */
62 extern int      GetUserID(const char *Username);
63 /**
64  * \brief Create a new account
65  */
66 extern int      CreateUser(const char *Username);
67 /**
68  * \brief Get the maximum UID
69  * \note Used for iterating accounts
70  */
71 extern int      GetMaxID(void);
72 /**
73  * \brief Validates a user's authentication
74  * \param Salt  Salt given to the client for hashing the password
75  * \param Username      Username used
76  * \param Password      Password sent by the client
77  */
78 extern int      GetUserAuth(const char *Salt, const char *Username, const char *Password);
79
80 #endif

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