+ return Bank_int_AddUser(Name);
+}
+
+tAcctIterator *Bank_Iterator(int FlagMask, int FlagValues, int Flags, int MinMaxBalance, time_t LastSeen)
+{
+ tAcctIterator *ret;
+
+ ret = calloc( 1, sizeof(tAcctIterator) );
+ if( !ret )
+ return NULL;
+ ret->MinBalance = INT_MIN;
+ ret->MaxBalance = INT_MAX;
+
+ ret->FlagMask = FlagMask;
+ ret->FlagValue = FlagValues & FlagMask;
+
+ if(Flags & BANK_ITFLAG_MINBALANCE)
+ ret->MinBalance = MinMaxBalance;
+ if(Flags & BANK_ITFLAG_MAXBALANCE)
+ ret->MaxBalance = MinMaxBalance;
+
+ ret->Sort = Flags & (BANK_ITFLAG_SORTMASK|BANK_ITFLAG_REVSORT);
+
+ // Shut up GCC
+ LastSeen = 0;
+
+ //if(Flags & BANK_ITFLAG_SEENBEFORE)
+ // ret->MinBalance = MinMaxBalance;
+ //if(Flags & BANK_ITFLAG_SEENAFTER)
+ // ret->MinBalance = MinMaxBalance;
+
+ return ret;
+}
+
+int Bank_IteratorNext(tAcctIterator *It)
+{
+ int ret;
+
+ while(It->CurUser < giBank_NumUsers)
+ {
+ switch(It->Sort)
+ {
+ case BANK_ITFLAG_SORT_NONE:
+ case BANK_ITFLAG_SORT_NONE | BANK_ITFLAG_REVSORT:
+ ret = It->CurUser;
+ break;
+ case BANK_ITFLAG_SORT_NAME:
+ ret = indexof(gaBank_Users, gaBank_UsersByName[It->CurUser]);
+ break;
+ case BANK_ITFLAG_SORT_NAME | BANK_ITFLAG_REVSORT:
+ ret = indexof(gaBank_Users, gaBank_UsersByName[giBank_NumUsers-It->CurUser]);
+ break;
+ case BANK_ITFLAG_SORT_BAL:
+ ret = indexof(gaBank_Users, gaBank_UsersByBalance[It->CurUser]);
+ printf("Sort by balance (ret = %i)\n", ret);
+ break;
+ case BANK_ITFLAG_SORT_BAL | BANK_ITFLAG_REVSORT:
+ ret = indexof(gaBank_Users, gaBank_UsersByBalance[giBank_NumUsers-It->CurUser]);
+ break;
+ default:
+ fprintf(stderr, "BUG: Unsupported sort in Bank_IteratorNext\n");
+ return -1;
+ }
+ It->CurUser ++;
+
+ if( gaBank_Users[ret].Balance < It->MinBalance )
+ continue;
+ if( gaBank_Users[ret].Balance > It->MaxBalance )
+ continue;
+ if( (gaBank_Users[ret].Flags & It->FlagMask) != It->FlagValue )
+ continue;
+
+ return ret;
+ }
+ return -1;