Extra help info, fixed logging for dispense failures, possible fix for logging errors
authorJohn Hodge <[email protected]>
Wed, 4 May 2011 06:49:49 +0000 (14:49 +0800)
committerJohn Hodge <[email protected]>
Wed, 4 May 2011 06:49:49 +0000 (14:49 +0800)
src/client/main.c
src/server/dispense.c
src/server/server.c

index b16c495..0f7d525 100644 (file)
@@ -161,6 +161,8 @@ void ShowUsage(void)
                printf(
                        "    dispense refund <user> <itemid> [<price>]\n"
                        "        Refund an item to a user (with optional price override)\n"
+                       "        Item IDs can be seen in the cokelog (in the brackets after the item name)\n"
+                       "        e.g. coke:6 for a coke, snack:33 for slot 33 of the snack machine\n"
                        );
        if( giTextArgc == 0 || strcmp(gsTextArgs[0], "slot") == 0 )
                printf(
index 8375ab6..c3426fd 100644 (file)
@@ -50,7 +50,7 @@ int DispenseItem(int ActualUser, int User, tItem *Item)
                ret = handler->DoDispense( User, Item->ID );
                if(ret) {
                        Log_Error("Dispense failed (%s dispensing %s:%i '%s')",
-                               username, Item->Name, Item->Handler->Name, Item->ID);
+                               username, Item->Handler->Name, Item->ID, Item->Name);
                        free( username );
                        return -1;      // 1: Unknown Error again
                }
index 99ea10e..483806a 100644 (file)
@@ -152,7 +152,6 @@ void Server_Start(void)
        // Fork into background
        if( gbServer_RunInBackground )
        {
-               int newin, newout, newerr;
                int pid = fork();
                if( pid == -1 ) {
                        fprintf(stderr, "ERROR: Unable to fork\n");
@@ -165,12 +164,9 @@ void Server_Start(void)
                }
                // In child
                // - Sort out stdin/stdout
-               newin  = open("/dev/null", O_RDONLY);
-               newout = open(gsServer_LogFile, O_CREAT|O_APPEND, 0644);
-               newerr = open(gsServer_ErrorLog, O_CREAT|O_APPEND, 0644);
-               dup2(newin, 0);
-               dup2(newout, 1);
-               dup2(newerr, 2);
+               dup2( open("/dev/null", O_RDONLY, 0644), STDIN_FILENO );
+               dup2( open(gsServer_LogFile, O_CREAT|O_APPEND, 0644), STDOUT_FILENO );
+               dup2( open(gsServer_ErrorLog, O_CREAT|O_APPEND, 0644), STDERR_FILENO );
        }
 
        // Start the helper thread

UCC git Repository :: git.ucc.asn.au