+ space = strchr(user, ' ');
+ if(space) *space = '\0';
+
+ // Get recipient
+ uid = Bank_GetUserID(user);
+ if( uid == -1 ) {
+ sendf(Client->Socket, "404 Invalid user");
+ return ;
+ }
+
+ _SendUserInfo(Client, uid);
+}
+
+void _SendUserInfo(tClient *Client, int UserID)
+{
+ char *type, *disabled="", *door="";
+ int flags = Bank_GetFlags(UserID);
+
+ if( flags & USER_FLAG_INTERNAL ) {
+ type = "internal";
+ }
+ else if( flags & USER_FLAG_COKE ) {
+ if( flags & USER_FLAG_WHEEL )
+ type = "coke,wheel";
+ else
+ type = "coke";
+ }
+ else if( flags & USER_FLAG_WHEEL ) {
+ type = "wheel";
+ }
+ else {
+ type = "user";
+ }
+
+ if( flags & USER_FLAG_DISABLED )
+ disabled = ",disabled";
+ if( flags & USER_FLAG_DOORGROUP )
+ door = ",door";
+
+ // TODO: User flags/type
+ sendf(
+ Client->Socket, "202 User %s %i %s%s\n",
+ Bank_GetUserName(UserID), Bank_GetBalance(UserID),
+ type, disabled
+ );
+}
+
+void Server_Cmd_USERADD(tClient *Client, char *Args)
+{
+ char *username, *space;
+
+ // Check permissions
+ if( !(Bank_GetFlags(Client->UID) & USER_FLAG_WHEEL) ) {
+ sendf(Client->Socket, "403 Not Wheel\n");
+ return ;
+ }
+
+ // Read arguments
+ username = Args;
+ while( *username == ' ' ) username ++;
+ space = strchr(username, ' ');
+ if(space) *space = '\0';
+
+ // Try to create user
+ if( Bank_CreateUser(username) == -1 ) {
+ sendf(Client->Socket, "404 User exists\n");
+ return ;
+ }
+
+ sendf(Client->Socket, "200 User Added\n");
+}
+
+void Server_Cmd_USERFLAGS(tClient *Client, char *Args)
+{
+ char *username, *flags;
+ char *space;
+ int mask=0, value=0;
+ int uid;
+
+ // Check permissions
+ if( !(Bank_GetFlags(Client->UID) & USER_FLAG_WHEEL) ) {
+ sendf(Client->Socket, "403 Not Wheel\n");
+ return ;
+ }
+
+ // Read arguments
+ // - Username
+ username = Args;
+ while( *username == ' ' ) username ++;
+ space = strchr(username, ' ');
+ if(!space) {
+ sendf(Client->Socket, "407 USER_FLAGS requires 2 arguments, 1 given\n");
+ return ;
+ }
+ *space = '\0';
+ // - Flags
+ flags = space + 1;
+ while( *flags == ' ' ) flags ++;
+ space = strchr(flags, ' ');
+ if(space) *space = '\0';
+
+ // Get UID
+ uid = Bank_GetUserID(username);
+ if( uid == -1 ) {
+ sendf(Client->Socket, "404 User '%s' not found\n", username);
+ return ;
+ }
+
+ // Parse flags
+ do {
+ int bRemove = 0;
+ int i;
+ struct {
+ const char *Name;
+ int Mask;
+ int Value;
+ } cFLAGS[] = {
+ {"disabled", USER_FLAG_DISABLED, USER_FLAG_DISABLED}
+ ,{"door", USER_FLAG_DOORGROUP, USER_FLAG_DOORGROUP}
+ ,{"coke", USER_FLAG_COKE, USER_FLAG_COKE}
+ ,{"wheel", USER_FLAG_WHEEL, USER_FLAG_WHEEL}
+ // ,{"internal", USER_FLAG_INTERNAL, USER_FLAG_INTERNAL}
+ };
+ const int ciNumFlags = sizeof(cFLAGS)/sizeof(cFLAGS[0]);
+
+ while( *flags == ' ' ) flags ++; // Eat whitespace
+ space = strchr(flags, ','); // Find the end of the flag
+ if(space) *space = '\0';
+
+ // Check for inversion/removal
+ if( *flags == '!' || *flags == '-' ) {
+ bRemove = 1;
+ flags ++;
+ }
+ else if( *flags == '+' ) {
+ flags ++;
+ }
+
+ // Check flag values
+ for( i = 0; i < ciNumFlags; i ++ )
+ {
+ if( strcmp(flags, cFLAGS[i].Name) == 0 ) {
+ mask |= cFLAGS[i].Mask;
+ value &= ~cFLAGS[i].Mask;
+ if( !bRemove )
+ value |= cFLAGS[i].Value;