-
Notifications
You must be signed in to change notification settings - Fork 0
/
expand.h
36 lines (33 loc) · 989 Bytes
/
expand.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
#ifndef EXPAND_H
#define EXPAND_H
/*
* dst = expand_token(src, token, value):
* Expand a given src by rewriting all occurances of token with
* a value. The dst is a newly allocated string that needs to be freed.
*
* Example:
* char *dst;
*
* dst = expand_token("<monster> does a thing", "<monster>", "orc");
* puts(dst);
* free(dst);
*/
char* expand_token(const char *, const char *, const char *);
/*
* dst = expand_tokens(src, tokens, values):
* Expand a given src by rewriting all occurances of tokens with
* a respective value. The dst is a newly allocated string that needs
* to be freed.
*
* Example:
* char *dst;
* const char *tokens[] = { "monster", "victim" };
* const char *values[] = { "orc", "elf" };
*
* dst = expand_tokens("<monster> kills <victim>", "<>", tokens, values);
* puts(dst);
* free(dst);
*/
char* expand_tokens(const char *, const char *, const char **,
const char **);
#endif