case 'n': // Dry Run / read-only
gbDryRun = 1;
break;
- case '0': case '1':
- case '2': case '3':
- case '4': case '5':
- case '6': case '7':
- case '8': case '9':
+ default:
if( text_argc + 1 == MAX_TXT_ARGS )
{
fprintf(stderr, "ERROR: Too many arguments\n");
// Connect to server
sock = OpenConnection(gsDispenseServer, giDispensePort);
if( sock < 0 ) return -1;
- // List accounts?
+ // List accounts?
if( text_argc == 1 ) {
ret = Dispense_EnumUsers(sock);
close(sock);
// Enter curses mode
initscr();
- raw(); noecho();
+ cbreak(); noecho();
// Get max index
maxItemIndex = ShowItemAt(0, 0, 0, -1, 0);
return 0;
}
+/**
+ * \brief Move money from one user to another (Admin Only)
+ */
+int DispenseTransfer(int ActualUser, int SrcUser, int DestUser, int Ammount, const char *ReasonGiven)
+{
+ int ret;
+ char *actualUsername;
+ char *srcName, *dstName;
+
+ // Make sure the user is an admin
+ if( !(Bank_GetFlags(ActualUser) & USER_FLAG_ADMIN) )
+ return 1;
+
+ ret = _Transfer( SrcUser, DestUser, Ammount, ReasonGiven );
+ if(ret) return 2; // No Balance
+
+
+ actualUsername = Bank_GetAcctName(ActualUser);
+ srcName = Bank_GetAcctName(SrcUser);
+ dstName = Bank_GetAcctName(DestUser);
+
+ Log_Info("move %i to %s from %s by %s [balances %i, %i] - %s",
+ Ammount, dstName, srcName, actualUsername,
+ Bank_GetBalance(SrcUser), Bank_GetBalance(DestUser),
+ ReasonGiven
+ );
+
+ free(srcName);
+ free(dstName);
+ free(actualUsername);
+
+ return 0;
+}
/**
* \brief Add money to an account
*/
if( Server_int_ParseArgs(1, CommandString, &command, &args, NULL) )
{
+ if( command == NULL ) return ;
// printf("command=%s, args=%s\n", command, args);
// Is this an error? (just ignore for now)
//args = "";