-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
48 lines (39 loc) · 767 Bytes
/
Copy pathexample.c
File metadata and controls
48 lines (39 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <inttypes.h>
#include "diceroll/diceroll.h"
char *program_name;
void usage(int e)
{
fprintf(stderr, "usage: %s [<num>]d<faces> ...\n", program_name);
exit(e);
}
int main(int argc, char* argv[])
{
program_name = argv[0];
if (argc < 2)
usage(1);
diceroll_init();
int error = 0;
struct diceroll_t d;
uintmax_t roll;
//TODO: reimplement dicethrow
while(*(++argv)) {
if(diceroll_parse(&d, *argv)){
printf("%-7s| ", diceroll_str(&d));
while((roll = diceroll_rtd(&d)) != 0)
printf("%" PRIuMAX " ", roll);
printf("\n");
}else{
diceroll_perror(*argv);
error = 1;
}
}
diceroll_finish();
if(error)
usage(1);
return 0;
}