Fixing crappy code in coke handler, debug in others
[tpg/opendispense2.git] / src / server / server.c
index a2279fd..315b129 100644 (file)
@@ -342,7 +342,7 @@ void Server_Cmd_USER(tClient *Client, char *Args)
        
        // Debug!
        if( giDebugLevel )
-               Debug("Authenticating as '%s'", Args);
+               Debug(Client, "Authenticating as '%s'", Args);
        
        // Save username
        if(Client->Username)
@@ -403,7 +403,7 @@ void Server_Cmd_AUTOAUTH(tClient *Client, char *Args)
        // Check if trusted
        if( !Client->bIsTrusted ) {
                if(giDebugLevel)
-                       Debug("Untrusted client attempting to AUTOAUTH");
+                       Debug(Client, "Untrusted client attempting to AUTOAUTH");
                sendf(Client->Socket, "401 Untrusted\n");
                return ;
        }
@@ -412,7 +412,7 @@ void Server_Cmd_AUTOAUTH(tClient *Client, char *Args)
        Client->UID = Bank_GetAcctByName( Args );       
        if( Client->UID < 0 ) {
                if(giDebugLevel)
-                       Debug("Unknown user '%s'", Args);
+                       Debug(Client, "Unknown user '%s'", Args);
                sendf(Client->Socket, "401 Auth Failure\n");
                return ;
        }
@@ -427,7 +427,7 @@ void Server_Cmd_AUTOAUTH(tClient *Client, char *Args)
        Client->bIsAuthed = 1;
        
        if(giDebugLevel)
-               Debug("Auto authenticated as '%s' (%i)", Args, Client->UID);
+               Debug(Client, "Auto authenticated as '%s' (%i)", Args, Client->UID);
        
        sendf(Client->Socket, "200 Auth OK\n");
 }
@@ -1031,13 +1031,14 @@ void Server_Cmd_USERINFO(tClient *Client, char *Args)
        space = strchr(user, ' ');
        if(space)       *space = '\0';
        
-       if( giDebugLevel )
-               Debug(Client, "User Info '%s'", user);
+       if( giDebugLevel )      Debug(Client, "User Info '%s'", user);
        
        // Get recipient
        uid = Bank_GetAcctByName(user);
+       
+       if( giDebugLevel >= 2 ) Debug(Client, "uid = %i", uid);
        if( uid == -1 ) {
-               sendf(Client->Socket, "404 Invalid user");
+               sendf(Client->Socket, "404 Invalid user\n");
                return ;
        }
        
@@ -1160,9 +1161,10 @@ void Server_Cmd_USERFLAGS(tClient *Client, char *Args)
 void Debug(tClient *Client, const char *Format, ...)
 {
        va_list args;
-       printf("%010lli [%i] ", time(NULL), Client->ID);
+       //printf("%010i [%i] ", (int)time(NULL), Client->ID);
+       printf("[%i] ", Client->ID);
        va_start(args, Format);
-       vprintf(NULL, 0, Format, args);
+       vprintf(Format, args);
        va_end(args);
        printf("\n");
 }

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