-
Notifications
You must be signed in to change notification settings - Fork 2
/
util.h
40 lines (32 loc) · 939 Bytes
/
util.h
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
#ifndef UTIL_H
#define UTIL_H
#include <stdio.h>
#include "trie.h"
void die(const char *fmt, ...);
FILE *util_open(const char *fn, const char *mode);
const char *util_line(FILE *in);
void util_trie_read(struct trie *t, FILE *in);
void util_trie_insert(struct trie *t, const char *s);
struct util_limit {
int dynamic;
int limit;
int max;
};
#define UTIL_LIMIT_INIT { 1, 5, 3 };
#define UTIL_LIMIT_OPTS "l:d:m:"
int util_limit_opt(struct util_limit *, char opt, const char *arg);
int util_limit(struct util_limit *, const char *s);
struct util_array {
const char **d;
unsigned len;
unsigned alloc;
};
#define UTIL_ARRAY_INIT { NULL, 0, 0 }
void util_array_push(struct util_array *, const char *);
struct util_atomicfile {
FILE *fh;
char fn[4096];
};
void util_atomicfile_open(struct util_atomicfile *af, const char *base);
void util_atomicfile_close(struct util_atomicfile *af, const char *dest);
#endif /* UTIL_H */