}
// Get UID
- Client->UID = Bank_GetUserID( Args );
+ Client->UID = Bank_GetAcctByName( Args );
if( Client->UID < 0 ) {
if(giDebugLevel)
printf("Client %i: Unknown user '%s'\n", Client->ID, Args);
}
// Set id
- Client->EffectiveUID = Bank_GetUserID(Args);
+ Client->EffectiveUID = Bank_GetAcctByName(Args);
if( Client->EffectiveUID == -1 ) {
sendf(Client->Socket, "404 User not found\n");
return ;
{
int i;
- if( Args != NULL || strlen(Args) ) {
+ if( Args != NULL && strlen(Args) ) {
sendf(Client->Socket, "407 ENUM_ITEMS takes no arguments\n");
return ;
}
reason ++;
// Get recipient
- uid = Bank_GetUserID(recipient);
+ uid = Bank_GetAcctByName(recipient);
if( uid == -1 ) {
sendf(Client->Socket, "404 Invalid target user\n");
return ;
}
// Get recipient
- uid = Bank_GetUserID(user);
+ uid = Bank_GetAcctByName(user);
if( uid == -1 ) {
sendf(Client->Socket, "404 Invalid user\n");
return ;
{
int i, numRet = 0;
int maxBal = INT_MAX, minBal = INT_MIN;
- int numUsr = Bank_GetMaxID();
+ tAcctIterator *it;
+ int sort = BANK_ITFLAG_SORT_NAME;
// Parse arguments
if( Args && strlen(Args) )
maxBal = atoi(max);
}
+ // Create iterator
+ if( maxBal != INT_MAX )
+ it = Bank_Iterator(0, 0, sort|BANK_ITFLAG_MAXBALANCE, maxBal, 0);
+ else if( minBal != INT_MIN )
+ it = Bank_Iterator(0, 0, sort|BANK_ITFLAG_MINBALANCE, minBal, 0);
+ else
+ it = Bank_Iterator(0, 0, sort, 0, 0);
+
// Get return number
- for( i = 0; i < numUsr; i ++ )
+ while( (i = Bank_IteratorNext(it)) != -1 )
{
int bal = Bank_GetBalance(i);
numRet ++;
}
+ Bank_DelIterator(it);
+
// Send count
sendf(Client->Socket, "201 Users %i\n", numRet);
- for( i = 0; i < numUsr; i ++ )
+
+ // Create iterator
+ if( maxBal != INT_MAX )
+ it = Bank_Iterator(0, 0, sort|BANK_ITFLAG_MAXBALANCE, maxBal, 0);
+ else if( minBal != INT_MIN )
+ it = Bank_Iterator(0, 0, sort|BANK_ITFLAG_MINBALANCE, minBal, 0);
+ else
+ it = Bank_Iterator(0, 0, sort, 0, 0);
+
+ while( (i = Bank_IteratorNext(it)) != -1 )
{
int bal = Bank_GetBalance(i);
_SendUserInfo(Client, i);
}
+ Bank_DelIterator(it);
+
sendf(Client->Socket, "200 List End\n");
}
if(space) *space = '\0';
// Get recipient
- uid = Bank_GetUserID(user);
+ uid = Bank_GetAcctByName(user);
if( uid == -1 ) {
sendf(Client->Socket, "404 Invalid user");
return ;
// TODO: User flags/type
sendf(
Client->Socket, "202 User %s %i %s%s\n",
- Bank_GetUserName(UserID), Bank_GetBalance(UserID),
+ Bank_GetAcctName(UserID), Bank_GetBalance(UserID),
type, disabled
);
}
if(space) *space = '\0';
// Try to create user
- if( Bank_CreateUser(username) == -1 ) {
+ if( Bank_CreateAcct(username) == -1 ) {
sendf(Client->Socket, "404 User exists\n");
return ;
}
if(space) *space = '\0';
// Get UID
- uid = Bank_GetUserID(username);
+ uid = Bank_GetAcctByName(username);
if( uid == -1 ) {
sendf(Client->Socket, "404 User '%s' not found\n", username);
return ;