And here's a reworking of the idler logic.
[uccvend-vendserver.git] / sql-edition / convert.c
1 /* Prints a list of all usernames with useable coke balances
2  * delimited by newlines.
3  *
4  *  - Bernard Blackham <[email protected]>
5  */
6
7
8 #include <stdio.h>
9 #include "ucc.h"
10
11 int main(int argc, char* argv[]) {
12         char username[30];
13         int32 balance;
14
15         if (argc != 1) {
16                 fprintf(stderr, "Usage: %s\n", argv[0]);
17                 return 1;
18         }
19         
20         SetCokebankToSocks();
21
22         cokebank_open();
23         printf("DELETE from users;\n");
24         printf("COPY users (user_name, user_balance_cents, user_balance_bytes) FROM stdin;\n");
25         while (cokebank_get_next(username, &balance, 0)) {
26                 printf("%s\t%d\t%d\n", username, cokebank_get(username), cokebank_get_bytes(username));
27         }
28         printf("\\.\n");
29         cokebank_close();
30         return 0;
31 }

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