+ // Parse arguments
+ if( Server_int_ParseArgs(1, Args, &recipient, &ammount, &reason, NULL) ) {
+ sendf(Client->Socket, "407 GIVE takes only 3 arguments\n");
+ return ;
+ }
+ // Check for authed
+ if( !Client->bIsAuthed ) {
+ sendf(Client->Socket, "401 Not Authenticated\n");
+ return ;
+ }
+
+ // Get recipient
+ uid = Bank_GetAcctByName(recipient);
+ if( uid == -1 ) {
+ sendf(Client->Socket, "404 Invalid target user\n");
+ return ;
+ }
+
+ // You can't alter an internal account
+ if( Bank_GetFlags(uid) & USER_FLAG_INTERNAL ) {
+ sendf(Client->Socket, "404 Invalid target user\n");
+ return ;
+ }
+
+ // Parse ammount
+ iAmmount = atoi(ammount);
+ if( iAmmount <= 0 ) {
+ sendf(Client->Socket, "407 Invalid Argument, ammount must be > zero\n");
+ return ;
+ }
+
+ if( Client->EffectiveUID != -1 ) {
+ thisUid = Client->EffectiveUID;
+ }
+ else {
+ thisUid = Client->UID;
+ }
+
+ // Do give
+ switch( DispenseGive(Client->UID, thisUid, uid, iAmmount, reason) )
+ {
+ case 0:
+ sendf(Client->Socket, "200 Give OK\n");
+ return ;
+ case 2:
+ sendf(Client->Socket, "402 Poor You\n");
+ return ;
+ default:
+ sendf(Client->Socket, "500 Unknown error\n");
+ return ;
+ }
+}
+
+void Server_Cmd_DONATE(tClient *Client, char *Args)
+{
+ char *ammount, *reason;
+ int iAmmount;
+ int thisUid;
+
+ // Parse arguments
+ if( Server_int_ParseArgs(1, Args, &ammount, &reason, NULL) ) {
+ sendf(Client->Socket, "407 DONATE takes 2 arguments\n");
+ return ;
+ }
+
+ if( !Client->bIsAuthed ) {
+ sendf(Client->Socket, "401 Not Authenticated\n");
+ return ;
+ }
+
+ // Parse ammount
+ iAmmount = atoi(ammount);
+ if( iAmmount <= 0 ) {
+ sendf(Client->Socket, "407 Invalid Argument, ammount must be > zero\n");
+ return ;
+ }
+
+ // Handle effective users
+ if( Client->EffectiveUID != -1 ) {
+ thisUid = Client->EffectiveUID;
+ }
+ else {
+ thisUid = Client->UID;
+ }
+
+ // Do give
+ switch( DispenseDonate(Client->UID, thisUid, iAmmount, reason) )
+ {
+ case 0:
+ sendf(Client->Socket, "200 Give OK\n");
+ return ;
+ case 2:
+ sendf(Client->Socket, "402 Poor You\n");
+ return ;
+ default:
+ sendf(Client->Socket, "500 Unknown error\n");
+ return ;
+ }
+}
+
+void Server_Cmd_ADD(tClient *Client, char *Args)
+{
+ char *user, *ammount, *reason;
+ int uid, iAmmount;
+
+ // Parse arguments
+ if( Server_int_ParseArgs(1, Args, &user, &ammount, &reason, NULL) ) {
+ sendf(Client->Socket, "407 ADD takes 3 arguments\n");
+ return ;
+ }
+
+ if( !Client->bIsAuthed ) {
+ sendf(Client->Socket, "401 Not Authenticated\n");
+ return ;
+ }
+
+ // Check user permissions
+ if( !(Bank_GetFlags(Client->UID) & (USER_FLAG_COKE|USER_FLAG_ADMIN)) ) {
+ sendf(Client->Socket, "403 Not in coke\n");
+ return ;
+ }
+
+ // Get recipient
+ uid = Bank_GetAcctByName(user);
+ if( uid == -1 ) {
+ sendf(Client->Socket, "404 Invalid user\n");
+ return ;
+ }
+
+ // You can't alter an internal account
+ if( Bank_GetFlags(uid) & USER_FLAG_INTERNAL ) {
+ sendf(Client->Socket, "404 Invalid user\n");
+ return ;
+ }