mtglist

view 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 source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "mtg.h"
6 int main(int argc, char **argv)
7 {
8 const struct mtg_card *card;
9 const char *fname = "cardlist";
10 int ncards;
12 if(argv[1]) fname = argv[1];
14 if(mtg_init() == -1) {
15 return 1;
16 }
18 if(mtg_load_cards(fname) == -1) {
19 mtg_destroy();
20 return 1;
21 }
23 ncards = 0;
25 mtg_iter_begin();
26 while((card = mtg_iter_next())) {
27 printf("%3d ", card->count);
28 printf("%-11s ", mtg_color_str(card->color));
29 printf("%-32s ", card->name);
30 printf("%-12s ", mtg_type_str(card->type));
31 printf("%s\n", card->edition);
33 ncards += card->count;
34 }
36 printf("Total cards: %d\n", ncards);
38 mtg_destroy();
39 return 0;
40 }