mtglist
diff src/mtglist.c @ 0:0a45dfe93e66
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 02 Nov 2014 11:07:45 +0200 |
parents | |
children | 7211fa8db425 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/mtglist.c Sun Nov 02 11:07:45 2014 +0200 1.3 @@ -0,0 +1,40 @@ 1.4 +#include <stdio.h> 1.5 +#include <stdlib.h> 1.6 +#include <string.h> 1.7 +#include "mtg.h" 1.8 + 1.9 +int main(int argc, char **argv) 1.10 +{ 1.11 + const struct mtg_card *card; 1.12 + const char *fname = "cardlist"; 1.13 + int ncards; 1.14 + 1.15 + if(argv[1]) fname = argv[1]; 1.16 + 1.17 + if(mtg_init() == -1) { 1.18 + return 1; 1.19 + } 1.20 + 1.21 + if(mtg_load_cards(fname) == -1) { 1.22 + mtg_destroy(); 1.23 + return 1; 1.24 + } 1.25 + 1.26 + ncards = 0; 1.27 + 1.28 + mtg_iter_begin(); 1.29 + while((card = mtg_iter_next())) { 1.30 + printf("%3d ", card->count); 1.31 + printf("%-11s ", mtg_color_str(card->color)); 1.32 + printf("%-32s ", card->name); 1.33 + printf("%-12s ", mtg_type_str(card->type)); 1.34 + printf("%s\n", card->edition); 1.35 + 1.36 + ncards += card->count; 1.37 + } 1.38 + 1.39 + printf("Total cards: %d\n", ncards); 1.40 + 1.41 + mtg_destroy(); 1.42 + return 0; 1.43 +}