#include <ucw/bbuf.h>
-#define GBUF_TYPE uns
+#define GBUF_TYPE uint
#define GBUF_PREFIX(x) split_##x
#include <ucw/gbuf.h>
struct cf_parser_state {
const char *name_parse_fb;
struct fastbuf *parse_fb;
- uns line_num;
+ uint line_num;
char *line;
split_t word_buf;
- uns words;
- uns ends_by_brace; // the line is ended by "{"
+ uint words;
+ uint ends_by_brace; // the line is ended by "{"
bb_t copy_buf;
- uns copied;
+ uint copied;
char line_buf[];
};
static void
append(struct cf_parser_state *p, char *start, char *end)
{
- uns len = end - start;
+ uint len = end - start;
bb_grow(&p->copy_buf, p->copied + len + 1);
memcpy(p->copy_buf.ptr + p->copied, start, len);
p->copied += len + 1;
}
static char *
-get_word(struct cf_parser_state *p, uns is_command_name)
+get_word(struct cf_parser_state *p, uint is_command_name)
{
char *msg;
char *line = p->line;
} else if (*line == '"') {
line++;
- uns start_copy = p->copied;
+ uint start_copy = p->copied;
while (1) {
char *start = line;
- uns escape = 0;
+ uint escape = 0;
while (*line) {
if (*line == '"' && !escape)
break;
line++;
char *tmp = stk_str_unesc(p->copy_buf.ptr + start_copy);
- uns l = strlen(tmp);
+ uint l = strlen(tmp);
bb_grow(&p->copy_buf, start_copy + l + 1);
strcpy(p->copy_buf.ptr + start_copy, tmp);
p->copied = start_copy + l + 1;
}
static char *
-get_token(struct cf_parser_state *p, uns is_command_name, char **err)
+get_token(struct cf_parser_state *p, uint is_command_name, char **err)
{
*err = NULL;
while (1) {
msg(L_WARN, "The line %s:%d following a backslash is empty", p->name_parse_fb ? : "", p->line_num);
} else {
split_grow(&p->word_buf, p->words+1);
- uns start = p->copied;
+ uint start = p->copied;
p->word_buf.ptr[p->words++] = p->copied;
*err = get_word(p, is_command_name);
return *err ? NULL : p->copy_buf.ptr + start;
}
static char *
-parse_fastbuf(struct cf_context *cc, const char *name_fb, struct fastbuf *fb, uns depth)
+parse_fastbuf(struct cf_context *cc, const char *name_fb, struct fastbuf *fb, uint depth)
{
struct cf_parser_state *p = cc->parser;
if (!p)
break;
char *name = p->copy_buf.ptr + p->word_buf.ptr[0];
char *pars[p->words-1];
- for (uns i=1; i<p->words; i++)
+ for (uint i=1; i<p->words; i++)
pars[i-1] = p->copy_buf.ptr + p->word_buf.ptr[i];
int optional_include = !strcasecmp(name, "optionalinclude");
if (optional_include || !strcasecmp(name, "include"))
err = cf_printf("Cannot open file %s: %m", pars[0]);
goto error;
}
- uns ll = p->line_num;
+ uint ll = p->line_num;
err = parse_fastbuf(cc, stk_strdup(pars[0]), new_fb, depth+1);
p->line_num = ll;
bclose(new_fb);
};
static void
-cf_remember_entry(struct cf_context *cc, uns type, const char *arg)
+cf_remember_entry(struct cf_context *cc, uint type, const char *arg)
{
if (!cc->enable_journal)
return;
ASSERT(cc->enable_journal);
cf_journal_swap();
struct cf_journal_item *oldj = cf_journal_new_transaction(1);
- uns ec = cc->everything_committed;
+ uint ec = cc->everything_committed;
cc->everything_committed = 0;
clist old_entries;