blob: 7b215a93dd36a1a99fe7d4ddea43f855fe5bc05d (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
typedef struct
{
int is_letter;
int number;
char letter;
} Character;
static void Chomp(char *p)
{
size_t l = strlen(p);
while (l && p[l-1] == '\n')
{
p[--l] = 0;
}
}
static void Error(const char *p)
{
perror(p);
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[])
{
int no_chars;
Character *chars;
int f;
FILE *fp;
char buff[1024];
if (argc < 3)
{
fprintf(stderr, "usage: %s wordlist <letter or number> ...\n", argv[0]);
exit(EXIT_FAILURE);
}
no_chars = argc - 2;
chars = malloc(sizeof *chars * no_chars);
if (!chars)
{
Error("malloc");
}
for(f = 0; f < no_chars; f++)
{
int i;
i = atoi(argv[f+2]);
if (i == 0)
{
chars[f].is_letter = 1;
chars[f].letter = argv[f+2][0];
chars[f].number = 0;
}
else
{
chars[f].is_letter = 0;
chars[f].number = i;
chars[f].letter = 0;
}
}
fp = fopen(argv[1], "r");
if (!fp)
{
Error(argv[1]);
}
while(fgets(buff, sizeof buff, fp))
{
}
return EXIT_SUCCESS;
}
|