int Dispense_ShowUser(int Socket, const char *Username);
void _PrintUserLine(const char *Line);
int Dispense_AddUser(int Socket, const char *Username);
- int Dispense_SetUserType(int Socket, const char *Username, const char *TypeString);
+ int Dispense_SetUserType(int Socket, const char *Username, const char *TypeString, const char *Reason);
int Dispense_SetItem(int Socket, const char *Type, int ID, int NewPrice, const char *NewName);
// --- Helpers ---
char *ReadLine(int Socket);
printf(
" dispense user add <user>\n"
" Create new account\n"
- " dispense user type <user> <flags>\n"
+ " dispense user type <user> <flags> <reason>\n"
" Alter a user's flags\n"
" <flags> is a comma-separated list of user, coke, admin, internal or disabled\n"
" Flags are removed by preceding the name with '-' or '!'\n"
ShowUsage();
return RV_ARGUMENTS;
}
- if( giTextArgc + 1 == MAX_TXT_ARGS )
+ if( giTextArgc == MAX_TXT_ARGS )
{
fprintf(stderr, "ERROR: Too many arguments\n");
return RV_ARGUMENTS;
continue;
}
- if( giTextArgc + 1 == MAX_TXT_ARGS )
+ if( giTextArgc == MAX_TXT_ARGS )
{
fprintf(stderr, "ERROR: Too many arguments\n");
return RV_ARGUMENTS;
// Update a user
else if( strcmp(gsTextArgs[1], "type") == 0 || strcmp(gsTextArgs[1], "flags") == 0 )
{
- if( giTextArgc != 4 ) {
+ if( giTextArgc < 4 || giTextArgc > 5 ) {
fprintf(stderr, "Error: `dispense user type` requires two arguments\n");
ShowUsage();
return RV_ARGUMENTS;
}
- ret = Dispense_SetUserType(sock, gsTextArgs[2], gsTextArgs[3]);
+ if( giTextArgc == 4 )
+ ret = Dispense_SetUserType(sock, gsTextArgs[2], gsTextArgs[3], "");
+ else
+ ret = Dispense_SetUserType(sock, gsTextArgs[2], gsTextArgs[3], gsTextArgs[4]);
}
else
{
return ret;
}
-int Dispense_SetUserType(int Socket, const char *Username, const char *TypeString)
+int Dispense_SetUserType(int Socket, const char *Username, const char *TypeString, const char *Reason)
{
char *buf;
int responseCode, ret;
// TODO: Pre-validate the string
- sendf(Socket, "USER_FLAGS %s %s\n", Username, TypeString);
+ sendf(Socket, "USER_FLAGS %s %s %s\n", Username, TypeString, Reason);
buf = ReadLine(Socket);
responseCode = atoi(buf);
break;
case 403:
- printf("Only wheel can modify users\n");
+ printf("Only dispense admins can modify users\n");
ret = RV_PERMISSIONS;
break;