File: rolldice.h

package info (click to toggle)
rolldice 1.10-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 96 kB
  • ctags: 40
  • sloc: ansic: 237; makefile: 60
file content (64 lines) | stat: -rw-r--r-- 1,677 bytes parent folder | download | duplicates (4)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * rolldice.h - v1.10 - 25 Nov 2001
 * (c) Stevie Strickland, 1999-2001
 *
 * This program has been placed under the GPL.  Any bugfixes or enhancements
 * will be greatly appreciated :)
 *
 * Stevie Strickland - sstrickl@cc.gatech.edu
 */

/* Standard includes */
#include <stdio.h>
#include <stdlib.h>

/* For GNU getopt */
#include <getopt.h>

/* For the time() function */
#include <time.h>

/* For the rand() and srand() functions */
#include <math.h>

/* For the strstr() function */
#include <string.h>

/* For some bounds */
#include <values.h>

/* The following #defines give the position of each important dice-related
 * number inside of the dice_nums array.  The final #define gives us the
 * size of the dice_nums array, which should be the number of other 
 * #defines below.
 */
#define NUM_ROLLS 0
#define NUM_DICE 1
#define NUM_SIDES 2
#define MULTIPLIER 3
#define MODIFIER 4
#define NUM_DROP 5
#define DICE_ARRAY_SIZE 6

/* The following #defines give the tokens for each part of the format
 * string.  Perhaps eventually I'll change parse_string to use strtok()
 * instead of strstr() :)
 */
#define ROLL_IDENT "x"
#define DICE_SIDES_IDENT "d"
#define MULTI_IDENT "*"
#define MOD_PLUS_IDENT "+"
#define MOD_MINUS_IDENT "-"
#define DROP_IDENT "s"

// Defines values for true and false, just for testing stuff boolean-wise :)
#define TRUE_VAL 1
#define FALSE_VAL 0

// Defines values for the random number file to use
typedef enum {UNDEF, URANDOM, RANDOM} rand_type;

// External function declarations for using rolldice() and kin.
extern int *parse_string(char *dice_string);
extern int rolldie(int num_sides);
extern void init_random(rand_type rand_file);