From: John Hodge Date: Thu, 6 Jan 2011 03:40:22 +0000 (+0800) Subject: Updated protocol def X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=dc305dd8327bc8c6a801482f026633effc3583cd;p=tpg%2Fopendispense2.git Updated protocol def - Changed ENUM_USERS to return a list of USER_INFO responses. - Adding stub support for reading user flags from cokebank (TODO: standardise the flag values) > Also TODO: Common header for the cokebank (shared between it and the server) --- diff --git a/proto.txt b/proto.txt index b45d7a6..2565ad0 100644 --- a/proto.txt +++ b/proto.txt @@ -58,7 +58,10 @@ c ITEM_INFO \n s 202 Item \n --- Get Users' Balances --- c ENUM_USERS[ ]\n -s 201 Users :: :: ...\n +s 201 Users \n +s 202 User \n + ... +s 200 List End --- Get a User's Balance --- c USER_INFO\n s 202 User \n diff --git a/src/cokebank_basic/bank.c b/src/cokebank_basic/bank.c index 07b8271..1b356e7 100644 --- a/src/cokebank_basic/bank.c +++ b/src/cokebank_basic/bank.c @@ -56,6 +56,14 @@ int Bank_GetUserBalance(int ID) return gaBank_Users[ID].Balance; } +int Bank_GetUserFlags(int ID) +{ + if( ID < 0 || ID >= giBank_NumUsers ) + return INT_MIN; + + return gaBank_Users[ID].Flags; +} + int Bank_AlterUserBalance(int ID, int Delta) { // Sanity @@ -93,6 +101,8 @@ int Bank_GetMinAllowedBalance(int ID) if( ID < 0 || ID >= giBank_NumUsers ) return 0; +// printf("gaBank_Users[%i].Flags = 0x%x\n", ID, gaBank_Users[ID].Flags); + switch( gaBank_Users[ID].Flags & FLAG_TYPEMASK ) { case USER_TYPE_NORMAL: return 0; diff --git a/src/cokebank_basic/common.h b/src/cokebank_basic/common.h index fb1e3e9..ce6854f 100644 --- a/src/cokebank_basic/common.h +++ b/src/cokebank_basic/common.h @@ -21,6 +21,7 @@ extern int Bank_GetMinAllowedBalance(int ID); extern int Bank_GetUserBalance(int ID); extern int Bank_AlterUserBalance(int ID, int Delta); extern char *Bank_GetUserName(int ID); +extern int Bank_GetUserFlags(int ID); extern int Bank_GetUserByName(const char *Username); extern int Bank_AddUser(const char *Username); extern FILE *gBank_File; diff --git a/src/cokebank_basic/main.c b/src/cokebank_basic/main.c index 83c92be..b8aba3f 100644 --- a/src/cokebank_basic/main.c +++ b/src/cokebank_basic/main.c @@ -72,6 +72,11 @@ int Transfer(int SourceUser, int DestUser, int Ammount, const char *Reason) return 0; } +int GetFlags(int User) +{ + return Bank_GetUserFlags(User); +} + /** * \brief Get the balance of the passed user */ diff --git a/src/server/server.c b/src/server/server.c index 4549ff6..875dd04 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -559,7 +559,8 @@ char *Server_Cmd_ADD(tClient *Client, char *Args) // Parse ammount iAmmount = atoi(ammount); - if( iAmmount == 0 && ammount[0] != '0' ) return strdup("407 Invalid Argument, ammount must be > zero\n"); + if( iAmmount == 0 && ammount[0] != '0' ) + return strdup("407 Invalid Argument\n"); // Do give switch( DispenseAdd(uid, Client->UID, iAmmount, reason) )