Misc changes, have flu so don't remember all of them
[tpg/opendispense2.git] / src / server / server.c
index 1ebb612..dd8a294 100644 (file)
@@ -253,7 +253,7 @@ void Server_Cleanup(void)
 {
        printf("\nClose(%i)\n", giServer_Socket);
        close(giServer_Socket);
-       unlink("/var/run/dispsrv");
+       unlink("/var/run/dispsrv.pid");
 }
 
 /**
@@ -479,7 +479,7 @@ void Server_Cmd_AUTOAUTH(tClient *Client, char *Args)
        }
        
        // Get UID
-       Client->UID = Bank_GetAcctByName( username );   
+       Client->UID = Bank_GetAcctByName( username, 0 );        
        if( Client->UID < 0 ) {
                if(giDebugLevel)
                        Debug(Client, "Unknown user '%s'", username);
@@ -539,7 +539,7 @@ void Server_Cmd_SETEUSER(tClient *Client, char *Args)
        }
        
        // Set id
-       Client->EffectiveUID = Bank_GetAcctByName(username);
+       Client->EffectiveUID = Bank_GetAcctByName(username, 0);
        if( Client->EffectiveUID == -1 ) {
                sendf(Client->Socket, "404 User not found\n");
                return ;
@@ -585,6 +585,10 @@ void Server_int_SendItem(tClient *Client, tItem *Item)
                }
        }
        
+       // KNOWN HACK: Naming a slot 'dead' disables it
+       if( strcmp(Item->Name, "dead") == 0 )
+               status = "sold";        // Another status?
+       
        sendf(Client->Socket,
                "202 Item %s:%i %s %i %s\n",
                Item->Handler->Name, Item->ID, status, Item->Price, Item->Name
@@ -744,7 +748,7 @@ void Server_Cmd_REFUND(tClient *Client, char *Args)
                return ;
        }
 
-       uid = Bank_GetAcctByName(username);
+       uid = Bank_GetAcctByName(username, 0);
        if( uid == -1 ) {
                sendf(Client->Socket, "404 Unknown user\n");
                return ;
@@ -786,7 +790,7 @@ void Server_Cmd_GIVE(tClient *Client, char *Args)
        }
 
        // Get recipient
-       uid = Bank_GetAcctByName(recipient);
+       uid = Bank_GetAcctByName(recipient, 0);
        if( uid == -1 ) {
                sendf(Client->Socket, "404 Invalid target user\n");
                return ;
@@ -897,7 +901,7 @@ void Server_Cmd_ADD(tClient *Client, char *Args)
        }
 
        // Get recipient
-       uid = Bank_GetAcctByName(user);
+       uid = Bank_GetAcctByName(user, 0);
        if( uid == -1 ) {
                sendf(Client->Socket, "404 Invalid user\n");
                return ;
@@ -958,7 +962,7 @@ void Server_Cmd_SET(tClient *Client, char *Args)
        }
 
        // Get recipient
-       uid = Bank_GetAcctByName(user);
+       uid = Bank_GetAcctByName(user, 0);
        if( uid == -1 ) {
                sendf(Client->Socket, "404 Invalid user\n");
                return ;
@@ -1171,7 +1175,7 @@ void Server_Cmd_USERINFO(tClient *Client, char *Args)
        if( giDebugLevel )      Debug(Client, "User Info '%s'", user);
        
        // Get recipient
-       uid = Bank_GetAcctByName(user);
+       uid = Bank_GetAcctByName(user, 0);
        
        if( giDebugLevel >= 2 ) Debug(Client, "uid = %i", uid);
        if( uid == -1 ) {
@@ -1266,7 +1270,7 @@ void Server_Cmd_USERFLAGS(tClient *Client, char *Args)
        }
        
        // Get UID
-       uid = Bank_GetAcctByName(username);
+       uid = Bank_GetAcctByName(username, 0);
        if( uid == -1 ) {
                sendf(Client->Socket, "404 User '%s' not found\n", username);
                return ;
@@ -1318,19 +1322,18 @@ void Server_Cmd_UPDATEITEM(tClient *Client, char *Args)
        
        price = atoi(price_str);
        if( price <= 0 && price_str[0] != '0' ) {
-               sendf(CLient->Socket, "407 Invalid price set\n");
+               sendf(Client->Socket, "407 Invalid price set\n");
        }
        
-       // Update the item
-       free(item->Name);
-       item->Name = strdup(description);
-       item->Price = price;
-       
-       // Update item file
-       Items_UpdateFile();
-       
-       // Return OK
-       sendf(Client->Socket, "200 Item updated\n");
+       switch( DispenseUpdateItem( Client->UID, item, description, price ) )
+       {
+       case 0:
+               // Return OK
+               sendf(Client->Socket, "200 Item updated\n");
+               break;
+       default:
+               break;
+       }
 }
 
 // --- INTERNAL HELPERS ---

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