From e772e1bde20eb3866ecb7c63d2276b3ae4ea95d5 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Mon, 25 Jun 2007 14:12:57 +0200 Subject: [PATCH] replaced several "byte *" -> "char *", mostly in the configuration system --- images/config.c | 2 +- lib/conf-alloc.c | 10 ++--- lib/conf-dump.c | 4 +- lib/conf-input.c | 64 ++++++++++++++++---------------- lib/conf-internal.h | 8 ++-- lib/conf-intr.c | 90 ++++++++++++++++++++++----------------------- lib/conf-parse.c | 26 ++++++------- lib/conf-section.c | 12 +++--- lib/conf.h | 36 +++++++++--------- lib/fb-temp.c | 4 +- lib/getopt.h | 12 +++--- lib/ipaccess.c | 12 +++--- lib/simple-lists.h | 6 +-- lib/url.c | 2 +- 14 files changed, 144 insertions(+), 144 deletions(-) diff --git a/images/config.c b/images/config.c index 8c07f2d8..4494348b 100644 --- a/images/config.c +++ b/images/config.c @@ -58,7 +58,7 @@ static struct cf_section image_sig_config = { CF_INT("BorderBonus", &image_sig_border_bonus), CF_DOUBLE_ARY("InertiaScale", image_sig_inertia_scale, 3), CF_DOUBLE("TexturedThreshold", &image_sig_textured_threshold), - CF_LOOKUP("CompareMethod", &image_sig_compare_method, ((byte *[]){"integrated", "fuzzy", "average", NULL})), + CF_LOOKUP("CompareMethod", &image_sig_compare_method, ((char *[]){"integrated", "fuzzy", "average", NULL})), CF_UNS_ARY("CompareFeaturesWeights", image_sig_cmp_features_weights, IMAGE_REG_F + IMAGE_REG_H), CF_END } diff --git a/lib/conf-alloc.c b/lib/conf-alloc.c index 8553e7f9..9f02fd56 100644 --- a/lib/conf-alloc.c +++ b/lib/conf-alloc.c @@ -26,18 +26,18 @@ cf_malloc_zero(uns size) return mp_alloc_zero(cf_pool, size); } -byte * -cf_strdup(byte *s) +char * +cf_strdup(const char *s) { return mp_strdup(cf_pool, s); } -byte * -cf_printf(char *fmt, ...) +char * +cf_printf(const char *fmt, ...) { va_list args; va_start(args, fmt); - byte *res = mp_vprintf(cf_pool, fmt, args); + char *res = mp_vprintf(cf_pool, fmt, args); va_end(args); return res; } diff --git a/lib/conf-dump.c b/lib/conf-dump.c index f4af30ac..940c7ca7 100644 --- a/lib/conf-dump.c +++ b/lib/conf-dump.c @@ -36,7 +36,7 @@ dump_basic(struct fastbuf *fb, void *ptr, enum cf_type type, union cf_union *u) else bprintf(fb, "NULL "); break; - case CT_LOOKUP: bprintf(fb, "%s ", *(int*)ptr >= 0 ? u->lookup[ *(int*)ptr ] : (byte*) "???"); break; + case CT_LOOKUP: bprintf(fb, "%s ", *(int*)ptr >= 0 ? u->lookup[ *(int*)ptr ] : "???"); break; case CT_USER: if (u->utype->dumper) u->utype->dumper(fb, ptr); @@ -48,7 +48,7 @@ dump_basic(struct fastbuf *fb, void *ptr, enum cf_type type, union cf_union *u) static void dump_section(struct fastbuf *fb, struct cf_section *sec, int level, void *ptr); -static byte *class_names[] = { "end", "static", "dynamic", "parser", "section", "list", "bitmap" }; +static char *class_names[] = { "end", "static", "dynamic", "parser", "section", "list", "bitmap" }; static void dump_item(struct fastbuf *fb, struct cf_item *item, int level, void *ptr) diff --git a/lib/conf-input.c b/lib/conf-input.c index 260d9f2a..d445a198 100644 --- a/lib/conf-input.c +++ b/lib/conf-input.c @@ -23,13 +23,13 @@ /* Text file parser */ -static const byte *name_parse_fb; +static const char *name_parse_fb; static struct fastbuf *parse_fb; static uns line_num; #define MAX_LINE 4096 -static byte line_buf[MAX_LINE]; -static byte *line = line_buf; +static char line_buf[MAX_LINE]; +static char *line = line_buf; #include "lib/bbuf.h" static bb_t copy_buf; @@ -43,7 +43,7 @@ static uns words; static uns ends_by_brace; // the line is ended by "{" static int -get_line(byte **msg) +get_line(char **msg) { int err = bgets_nodie(parse_fb, line_buf, MAX_LINE); line_num++; @@ -58,7 +58,7 @@ get_line(byte **msg) } static void -append(byte *start, byte *end) +append(char *start, char *end) { uns len = end - start; bb_grow(©_buf, copied + len + 1); @@ -67,14 +67,14 @@ append(byte *start, byte *end) copy_buf.ptr[copied-1] = 0; } -static byte * +static char * get_word(uns is_command_name) { - byte *msg; + char *msg; if (*line == '\'') { line++; while (1) { - byte *start = line; + char *start = line; while (*line && *line != '\'') line++; append(start, line); @@ -82,7 +82,7 @@ get_word(uns is_command_name) break; copy_buf.ptr[copied-1] = '\n'; if (!get_line(&msg)) - return msg ? : (byte*) "Unterminated apostrophe word at the end"; + return msg ? : "Unterminated apostrophe word at the end"; } line++; @@ -90,7 +90,7 @@ get_word(uns is_command_name) line++; uns start_copy = copied; while (1) { - byte *start = line; + char *start = line; uns escape = 0; while (*line) { if (*line == '"' && !escape) @@ -109,11 +109,11 @@ get_word(uns is_command_name) else // merge two lines copied -= 2; if (!get_line(&msg)) - return msg ? : (byte*) "Unterminated quoted word at the end"; + return msg ? : "Unterminated quoted word at the end"; } line++; - byte *tmp = stk_str_unesc(copy_buf.ptr + start_copy); + char *tmp = stk_str_unesc(copy_buf.ptr + start_copy); uns l = strlen(tmp); bb_grow(©_buf, start_copy + l + 1); strcpy(copy_buf.ptr + start_copy, tmp); @@ -121,7 +121,7 @@ get_word(uns is_command_name) } else { // promised that *line is non-null and non-blank - byte *start = line; + char *start = line; while (*line && !Cblank(*line) && *line != '{' && *line != '}' && *line != ';' && (*line != '=' || !is_command_name)) @@ -140,8 +140,8 @@ get_word(uns is_command_name) return NULL; } -static byte * -get_token(uns is_command_name, byte **err) +static char * +get_token(uns is_command_name, char **err) { *err = NULL; while (1) { @@ -159,7 +159,7 @@ get_token(uns is_command_name, byte **err) return NULL; } if (!*line || *line == '#') - msg(L_WARN, "The line %s:%d following a backslash is empty", name_parse_fb ? : (byte*) "", line_num); + msg(L_WARN, "The line %s:%d following a backslash is empty", name_parse_fb ? : "", line_num); } else { split_grow(&word_buf, words+1); uns start = copied; @@ -170,11 +170,11 @@ get_token(uns is_command_name, byte **err) } } -static byte * +static char * split_command(void) { words = copied = ends_by_brace = 0; - byte *msg, *start_word; + char *msg, *start_word; if (!(start_word = get_token(1, &msg))) return msg; if (*start_word == '{') // only one opening brace @@ -194,10 +194,10 @@ split_command(void) /* Parsing multiple files */ -static byte * -parse_fastbuf(const byte *name_fb, struct fastbuf *fb, uns depth) +static char * +parse_fastbuf(const char *name_fb, struct fastbuf *fb, uns depth) { - byte *err; + char *err; name_parse_fb = name_fb; parse_fb = fb; line_num = 0; @@ -210,8 +210,8 @@ parse_fastbuf(const byte *name_fb, struct fastbuf *fb, uns depth) goto error; if (!words) return NULL; - byte *name = copy_buf.ptr + word_buf.ptr[0]; - byte *pars[words-1]; + char *name = copy_buf.ptr + word_buf.ptr[0]; + char *pars[words-1]; for (uns i=1; i #include -#define TRY(f) do { byte *_msg = f; if (_msg) return _msg; } while (0) +#define TRY(f) do { char *_msg = f; if (_msg) return _msg; } while (0) /* Register size of and parser for each basic type */ -static byte * -cf_parse_string(byte *str, byte **ptr) +static char * +cf_parse_string(char *str, char **ptr) { *ptr = cf_strdup(str); return NULL; } -typedef byte *cf_basic_parser(byte *str, void *ptr); +typedef char *cf_basic_parser(char *str, void *ptr); static struct { uns size; void *parser; @@ -37,7 +37,7 @@ static struct { { sizeof(u64), cf_parse_u64 }, { sizeof(double), cf_parse_double }, { sizeof(u32), cf_parse_ip }, - { sizeof(byte*), cf_parse_string }, + { sizeof(char*), cf_parse_string }, { sizeof(int), NULL }, // lookups are parsed extra { 0, NULL }, // user-defined types are parsed extra }; @@ -51,10 +51,10 @@ cf_type_size(enum cf_type type, struct cf_user_type *utype) return utype->size; } -static byte * -cf_parse_lookup(byte *str, int *ptr, byte **t) +static char * +cf_parse_lookup(char *str, int *ptr, char **t) { - byte **n = t; + char **n = t; uns total_len = 0; while (*n && strcasecmp(*n, str)) { total_len += strlen(*n) + 2; @@ -64,7 +64,7 @@ cf_parse_lookup(byte *str, int *ptr, byte **t) *ptr = n - t; return NULL; } - byte *err = cf_malloc(total_len + strlen(str) + 60), *c = err; + char *err = cf_malloc(total_len + strlen(str) + 60), *c = err; c += sprintf(err, "Invalid value %s, possible values are: ", str); for (n=t; *n; n++) c+= sprintf(c, "%s, ", *n); @@ -74,12 +74,12 @@ cf_parse_lookup(byte *str, int *ptr, byte **t) return err; } -static byte * -cf_parse_ary(uns number, byte **pars, void *ptr, enum cf_type type, union cf_union *u) +static char * +cf_parse_ary(uns number, char **pars, void *ptr, enum cf_type type, union cf_union *u) { for (uns i=0; iutype); if (type < CT_LOOKUP) msg = ((cf_basic_parser*) parsers[type].parser) (pars[i], ptr + i * size); @@ -98,14 +98,14 @@ cf_parse_ary(uns number, byte **pars, void *ptr, enum cf_type type, union cf_uni /* Interpreter */ #define T(x) #x, -byte *cf_op_names[] = { CF_OPERATIONS }; +char *cf_op_names[] = { CF_OPERATIONS }; #undef T -byte *cf_type_names[] = { "int", "u64", "double", "ip", "string", "lookup", "user" }; +char *cf_type_names[] = { "int", "u64", "double", "ip", "string", "lookup", "user" }; #define DARY_HDR_SIZE ALIGN_TO(sizeof(uns), CPU_STRUCT_ALIGN) -static byte * -interpret_set_dynamic(struct cf_item *item, int number, byte **pars, void **ptr) +static char * +interpret_set_dynamic(struct cf_item *item, int number, char **pars, void **ptr) { enum cf_type type = item->type; cf_journal_block(ptr, sizeof(void*)); @@ -116,8 +116,8 @@ interpret_set_dynamic(struct cf_item *item, int number, byte **pars, void **ptr) return cf_parse_ary(number, pars, *ptr, type, &item->u); } -static byte * -interpret_add_dynamic(struct cf_item *item, int number, byte **pars, int *processed, void **ptr, enum cf_operation op) +static char * +interpret_add_dynamic(struct cf_item *item, int number, char **pars, int *processed, void **ptr, enum cf_operation op) { enum cf_type type = item->type; void *old_p = *ptr; @@ -141,17 +141,17 @@ interpret_add_dynamic(struct cf_item *item, int number, byte **pars, int *proces return cf_printf("Dynamic arrays do not support operation %s", cf_op_names[op]); } -static byte *interpret_set_item(struct cf_item *item, int number, byte **pars, int *processed, void *ptr, uns allow_dynamic); +static char *interpret_set_item(struct cf_item *item, int number, char **pars, int *processed, void *ptr, uns allow_dynamic); -static byte * -interpret_section(struct cf_section *sec, int number, byte **pars, int *processed, void *ptr, uns allow_dynamic) +static char * +interpret_section(struct cf_section *sec, int number, char **pars, int *processed, void *ptr, uns allow_dynamic) { cf_add_dirty(sec, ptr); *processed = 0; for (struct cf_item *ci=sec->cfg; ci->cls; ci++) { int taken; - byte *msg = interpret_set_item(ci, number, pars, &taken, ptr + (uintptr_t) ci->ptr, allow_dynamic && !ci[1].cls); + char *msg = interpret_set_item(ci, number, pars, &taken, ptr + (uintptr_t) ci->ptr, allow_dynamic && !ci[1].cls); if (msg) return cf_printf("Item %s: %s", ci->name, msg); *processed += taken; @@ -194,8 +194,8 @@ add_to_list(cnode *where, cnode *new_node, enum cf_operation op) } } -static byte * -interpret_add_list(struct cf_item *item, int number, byte **pars, int *processed, void *ptr, enum cf_operation op) +static char * +interpret_add_list(struct cf_item *item, int number, char **pars, int *processed, void *ptr, enum cf_operation op) { if (op >= OP_REMOVE) return cf_printf("You have to open a block for operation %s", cf_op_names[op]); @@ -213,7 +213,7 @@ interpret_add_list(struct cf_item *item, int number, byte **pars, int *processed /* If the node contains any dynamic attribute at the end, we suppress * auto-repetition here and pass the flag inside instead. */ index++; - byte *msg = interpret_section(sec, number, pars, &taken, node, sec->flags & SEC_FLAG_DYNAMIC); + char *msg = interpret_section(sec, number, pars, &taken, node, sec->flags & SEC_FLAG_DYNAMIC); if (msg) return sec->flags & SEC_FLAG_DYNAMIC ? msg : cf_printf("Node %d of list %s: %s", index, item->name, msg); *processed += taken; @@ -225,8 +225,8 @@ interpret_add_list(struct cf_item *item, int number, byte **pars, int *processed return NULL; } -static byte * -interpret_add_bitmap(struct cf_item *item, int number, byte **pars, int *processed, u32 *ptr, enum cf_operation op) +static char * +interpret_add_bitmap(struct cf_item *item, int number, char **pars, int *processed, u32 *ptr, enum cf_operation op) { if (op != OP_SET && op != OP_REMOVE) return cf_printf("Cannot apply operation %s on a bitmap", cf_op_names[op]); @@ -250,8 +250,8 @@ interpret_add_bitmap(struct cf_item *item, int number, byte **pars, int *process return NULL; } -static byte * -interpret_set_item(struct cf_item *item, int number, byte **pars, int *processed, void *ptr, uns allow_dynamic) +static char * +interpret_set_item(struct cf_item *item, int number, char **pars, int *processed, void *ptr, uns allow_dynamic) { int taken; switch (item->cls) @@ -295,7 +295,7 @@ interpret_set_item(struct cf_item *item, int number, byte **pars, int *processed } } -static byte * +static char * interpret_set_all(struct cf_item *item, void *ptr, enum cf_operation op) { if (item->cls == CC_BITMAP) { @@ -360,7 +360,7 @@ find_list_node(clist *list, void *query, struct cf_section *sec, u32 mask) return NULL; } -static byte * +static char * record_selector(struct cf_item *item, struct cf_section *sec, u32 *mask) { uns nr = sec->flags & SEC_FLAG_NUMBER; @@ -387,7 +387,7 @@ static struct item_stack { } stack[MAX_STACK_SIZE]; static uns level; -static byte * +static char * opening_brace(struct cf_item *item, void *ptr, enum cf_operation op) { if (level >= MAX_STACK_SIZE-1) @@ -430,8 +430,8 @@ opening_brace(struct cf_item *item, void *ptr, enum cf_operation op) return NULL; } -static byte * -closing_brace(struct item_stack *st, enum cf_operation op, int number, byte **pars) +static char * +closing_brace(struct item_stack *st, enum cf_operation op, int number, char **pars) { if (st->op == OP_CLOSE) // top-level return "Unmatched } parenthesis"; @@ -483,7 +483,7 @@ closing_brace(struct item_stack *st, enum cf_operation op, int number, byte **pa } static struct cf_item * -find_item(struct cf_section *curr_sec, const byte *name, byte **msg, void **ptr) +find_item(struct cf_section *curr_sec, const char *name, char **msg, void **ptr) { *msg = NULL; if (name[0] == '^') // absolute name instead of relative @@ -494,7 +494,7 @@ find_item(struct cf_section *curr_sec, const byte *name, byte **msg, void **ptr) { if (curr_sec != &cf_sections) cf_add_dirty(curr_sec, *ptr); - byte *c = strchr(name, '.'); + char *c = strchr(name, '.'); if (c) *c++ = 0; struct cf_item *ci = cf_find_subitem(curr_sec, name); @@ -517,10 +517,10 @@ find_item(struct cf_section *curr_sec, const byte *name, byte **msg, void **ptr) } } -byte * -cf_interpret_line(byte *name, enum cf_operation op, int number, byte **pars) +char * +cf_interpret_line(char *name, enum cf_operation op, int number, char **pars) { - byte *msg; + char *msg; if ((op & OP_MASK) == OP_CLOSE) return closing_brace(stack+level, op, number, pars); void *ptr = stack[level].base_ptr; @@ -559,10 +559,10 @@ cf_interpret_line(byte *name, enum cf_operation op, int number, byte **pars) return NULL; } -byte * -cf_find_item(const byte *name, struct cf_item *item) +char * +cf_find_item(const char *name, struct cf_item *item) { - byte *msg; + char *msg; void *ptr = NULL; struct cf_item *ci = find_item(&cf_sections, name, &msg, &ptr); if (msg) @@ -575,10 +575,10 @@ cf_find_item(const byte *name, struct cf_item *item) return NULL; } -byte * -cf_write_item(struct cf_item *item, enum cf_operation op, int number, byte **pars) +char * +cf_write_item(struct cf_item *item, enum cf_operation op, int number, char **pars) { - byte *msg; + char *msg; int taken = 0; switch (op) { case OP_SET: diff --git a/lib/conf-parse.c b/lib/conf-parse.c index 2d93cc4c..c828462b 100644 --- a/lib/conf-parse.c +++ b/lib/conf-parse.c @@ -35,14 +35,14 @@ static const struct unit units[] = { }; static const struct unit * -lookup_unit(const byte *value, const byte *end, byte **msg) +lookup_unit(const char *value, const char *end, char **msg) { if (end && *end) { if (end == value || end[1] || *end >= '0' && *end <= '9') *msg = "Invalid number"; else { for (const struct unit *u=units; u->name; u++) - if (u->name == *end) + if ((char)u->name == *end) return u; *msg = "Invalid unit"; } @@ -52,10 +52,10 @@ lookup_unit(const byte *value, const byte *end, byte **msg) static char cf_rngerr[] = "Number out of range"; -byte * -cf_parse_int(const byte *str, int *ptr) +char * +cf_parse_int(const char *str, int *ptr) { - byte *msg = NULL; + char *msg = NULL; if (!*str) msg = "Missing number"; else { @@ -81,10 +81,10 @@ cf_parse_int(const byte *str, int *ptr) return msg; } -byte * -cf_parse_u64(const byte *str, u64 *ptr) +char * +cf_parse_u64(const char *str, u64 *ptr) { - byte *msg = NULL; + char *msg = NULL; if (!*str) msg = "Missing number"; else { @@ -110,10 +110,10 @@ cf_parse_u64(const byte *str, u64 *ptr) return msg; } -byte * -cf_parse_double(const byte *str, double *ptr) +char * +cf_parse_double(const char *str, double *ptr) { - byte *msg = NULL; + char *msg = NULL; if (!*str) msg = "Missing number"; else { @@ -130,8 +130,8 @@ cf_parse_double(const byte *str, double *ptr) return msg; } -byte * -cf_parse_ip(const byte *p, u32 *varp) +char * +cf_parse_ip(const char *p, u32 *varp) { if (!*p) return "Missing IP address"; diff --git a/lib/conf-section.c b/lib/conf-section.c index 2851d26d..1a9ae171 100644 --- a/lib/conf-section.c +++ b/lib/conf-section.c @@ -70,7 +70,7 @@ sort_dirty(void) struct cf_section cf_sections; // root section struct cf_item * -cf_find_subitem(struct cf_section *sec, const byte *name) +cf_find_subitem(struct cf_section *sec, const char *name) { struct cf_item *ci = sec->cfg; for (; ci->cls; ci++) @@ -104,7 +104,7 @@ inspect_section(struct cf_section *sec) } void -cf_declare_section(byte *name, struct cf_section *sec, uns allow_unknown) +cf_declare_section(const char *name, struct cf_section *sec, uns allow_unknown) { if (!cf_sections.cfg) { @@ -132,7 +132,7 @@ cf_declare_section(byte *name, struct cf_section *sec, uns allow_unknown) } void -cf_init_section(byte *name, struct cf_section *sec, void *ptr, uns do_bzero) +cf_init_section(const char *name, struct cf_section *sec, void *ptr, uns do_bzero) { if (do_bzero) { ASSERT(sec->size); @@ -151,16 +151,16 @@ cf_init_section(byte *name, struct cf_section *sec, void *ptr, uns do_bzero) } } if (sec->init) { - byte *msg = sec->init(ptr); + char *msg = sec->init(ptr); if (msg) die("Cannot initialize section %s: %s", name, msg); } } -static byte * +static char * commit_section(struct cf_section *sec, void *ptr, uns commit_all) { - byte *err; + char *err; for (struct cf_item *ci=sec->cfg; ci->cls; ci++) if (ci->cls == CC_SECTION) { if ((err = commit_section(ci->u.sec, ptr + (uintptr_t) ci->ptr, commit_all))) { diff --git a/lib/conf.h b/lib/conf.h index 7f176103..80857449 100644 --- a/lib/conf.h +++ b/lib/conf.h @@ -30,17 +30,17 @@ enum cf_type { }; struct fastbuf; -typedef byte *cf_parser(uns number, byte **pars, void *ptr); +typedef char *cf_parser(uns number, char **pars, void *ptr); /* A parser function gets an array of (strdup'ed) strings and a pointer with * the customized information (most likely the target address). It can store * the parsed value anywhere in any way it likes, however it must first call * cf_journal_block() on the overwritten memory block. It returns an error * message or NULL if everything is all right. */ -typedef byte *cf_parser1(byte *string, void *ptr); +typedef char *cf_parser1(char *string, void *ptr); /* A parser function for user-defined types gets a string and a pointer to * the destination variable. It must store the value within [ptr,ptr+size), * where size is fixed for each type. It should not call cf_journal_block(). */ -typedef byte *cf_hook(void *ptr); +typedef char *cf_hook(void *ptr); /* An init- or commit-hook gets a pointer to the section or NULL if this * is the global section. It returns an error message or NULL if everything * is all right. The init-hook should fill in default values (needed for @@ -51,27 +51,27 @@ typedef byte *cf_hook(void *ptr); * use cf_malloc() but normal xmalloc(). */ typedef void cf_dumper1(struct fastbuf *fb, void *ptr); /* Dumps the contents of a variable of a user-defined type. */ -typedef byte *cf_copier(void *dest, void *src); +typedef char *cf_copier(void *dest, void *src); /* Similar to init-hook, but it copies attributes from another list node * instead of setting the attributes to default values. You have to provide * it if your node contains parsed values and/or sub-lists. */ struct cf_user_type { uns size; // of the parsed attribute - byte *name; // name of the type (for dumping) + char *name; // name of the type (for dumping) cf_parser1 *parser; // how to parse it cf_dumper1 *dumper; // how to dump the type }; struct cf_section; struct cf_item { - byte *name; // case insensitive + const char *name; // case insensitive int number; // length of an array or #parameters of a parser (negative means at most) void *ptr; // pointer to a global variable or an offset in a section union cf_union { struct cf_section *sec; // declaration of a section or a list cf_parser *par; // parser function - byte **lookup; // NULL-terminated sequence of allowed strings for lookups + char **lookup; // NULL-terminated sequence of allowed strings for lookups struct cf_user_type *utype; // specification of the user-defined type } u; enum cf_class cls:16; // attribute class @@ -118,9 +118,9 @@ struct cf_section { #define CF_IP(n,p) CF_STATIC(n,p,IP,u32,1) #define CF_IP_ARY(n,p,c) CF_STATIC(n,p,IP,u32,c) #define CF_IP_DYN(n,p,c) CF_DYNAMIC(n,p,IP,u32,c) -#define CF_STRING(n,p) CF_STATIC(n,p,STRING,byte*,1) -#define CF_STRING_ARY(n,p,c) CF_STATIC(n,p,STRING,byte*,c) -#define CF_STRING_DYN(n,p,c) CF_DYNAMIC(n,p,STRING,byte*,c) +#define CF_STRING(n,p) CF_STATIC(n,p,STRING,char*,1) +#define CF_STRING_ARY(n,p,c) CF_STATIC(n,p,STRING,char*,c) +#define CF_STRING_DYN(n,p,c) CF_DYNAMIC(n,p,STRING,char*,c) #define CF_LOOKUP(n,p,t) { .cls = CC_STATIC, .type = CT_LOOKUP, .name = n, .number = 1, .ptr = CHECK_PTR_TYPE(p,int*), .u.lookup = t } #define CF_LOOKUP_ARY(n,p,t,c) { .cls = CC_STATIC, .type = CT_LOOKUP, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,int*), .u.lookup = t } #define CF_LOOKUP_DYN(n,p,t,c) { .cls = CC_DYNAMIC, .type = CT_LOOKUP, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,int**), .u.lookup = t } @@ -141,8 +141,8 @@ struct mempool; extern struct mempool *cf_pool; void *cf_malloc(uns size); void *cf_malloc_zero(uns size); -byte *cf_strdup(byte *s); -byte *cf_printf(char *fmt, ...) FORMAT_CHECK(printf,1,2); +char *cf_strdup(const char *s); +char *cf_printf(const char *fmt, ...) FORMAT_CHECK(printf,1,2); /* Undo journal for error recovery: conf-journal.c */ extern uns cf_need_journal; @@ -150,14 +150,14 @@ void cf_journal_block(void *ptr, uns len); #define CF_JOURNAL_VAR(var) cf_journal_block(&(var), sizeof(var)) /* Declaration: conf-section.c */ -void cf_declare_section(byte *name, struct cf_section *sec, uns allow_unknown); -void cf_init_section(byte *name, struct cf_section *sec, void *ptr, uns do_bzero); +void cf_declare_section(const char *name, struct cf_section *sec, uns allow_unknown); +void cf_init_section(const char *name, struct cf_section *sec, void *ptr, uns do_bzero); /* Parsers for basic types: conf-parse.c */ -byte *cf_parse_int(const byte *str, int *ptr); -byte *cf_parse_u64(const byte *str, u64 *ptr); -byte *cf_parse_double(const byte *str, double *ptr); -byte *cf_parse_ip(const byte *p, u32 *varp); +char *cf_parse_int(const char *str, int *ptr); +char *cf_parse_u64(const char *str, u64 *ptr); +char *cf_parse_double(const char *str, double *ptr); +char *cf_parse_ip(const char *p, u32 *varp); #endif diff --git a/lib/fb-temp.c b/lib/fb-temp.c index 2c359e8a..65398c15 100644 --- a/lib/fb-temp.c +++ b/lib/fb-temp.c @@ -16,7 +16,7 @@ #include #include -static byte *temp_prefix = "/tmp/temp"; +static char *temp_prefix = "/tmp/temp"; static struct cf_section temp_config = { CF_ITEMS { @@ -45,7 +45,7 @@ temp_file_name(char *buf) struct fastbuf * bopen_tmp(uns buflen) { - byte buf[TEMP_FILE_NAME_LEN]; + char buf[TEMP_FILE_NAME_LEN]; struct fastbuf *f; temp_file_name(buf); diff --git a/lib/getopt.h b/lib/getopt.h index 85321ee9..c6383ea7 100644 --- a/lib/getopt.h +++ b/lib/getopt.h @@ -21,10 +21,10 @@ void reset_getopt(void); /* Safe loading and reloading of configuration files: conf-input.c */ -extern byte *cf_def_file; /* DEFAULT_CONFIG; NULL if already loaded */ -int cf_reload(const byte *file); -int cf_load(const byte *file); -int cf_set(const byte *string); +extern char *cf_def_file; /* DEFAULT_CONFIG; NULL if already loaded */ +int cf_reload(const char *file); +int cf_load(const char *file); +int cf_set(const char *string); /* Direct access to configuration items: conf-intr.c */ @@ -40,8 +40,8 @@ enum cf_operation { CF_OPERATIONS }; #undef T struct cf_item; -byte *cf_find_item(const byte *name, struct cf_item *item); -byte *cf_write_item(struct cf_item *item, enum cf_operation op, int number, byte **pars); +char *cf_find_item(const char *name, struct cf_item *item); +char *cf_write_item(struct cf_item *item, enum cf_operation op, int number, char **pars); /* Debug dumping: conf-dump.c */ diff --git a/lib/ipaccess.c b/lib/ipaccess.c index 215fb534..5dd388cc 100644 --- a/lib/ipaccess.c +++ b/lib/ipaccess.c @@ -22,8 +22,8 @@ struct ipaccess_entry { struct ip_addrmask addr; }; -static byte * -addrmask_parser(byte *c, void *ptr) +static char * +addrmask_parser(char *c, void *ptr) { /* * This is tricky: addrmasks will be compared by memcmp(), so we must ensure @@ -32,10 +32,10 @@ addrmask_parser(byte *c, void *ptr) struct ip_addrmask *am = ptr; bzero(am, sizeof(*am)); - byte *p = strchr(c, '/'); + char *p = strchr(c, '/'); if (p) *p++ = 0; - byte *err = cf_parse_ip(c, &am->addr); + char *err = cf_parse_ip(c, &am->addr); if (err) return err; if (p) @@ -68,7 +68,7 @@ struct cf_user_type ip_addrmask_type = { struct cf_section ipaccess_cf = { CF_TYPE(struct ipaccess_entry), CF_ITEMS { - CF_LOOKUP("Mode", PTR_TO(struct ipaccess_entry, allow), ((byte*[]) { "deny", "allow", NULL })), + CF_LOOKUP("Mode", PTR_TO(struct ipaccess_entry, allow), ((char*[]) { "deny", "allow", NULL })), CF_USER("IP", PTR_TO(struct ipaccess_entry, addr), &ip_addrmask_type), CF_END } @@ -110,7 +110,7 @@ int main(int argc, char **argv) byte buf[256]; while (fgets(buf, sizeof(buf), stdin)) { - byte *c = strchr(buf, '\n'); + char *c = strchr(buf, '\n'); if (c) *c = 0; u32 ip; diff --git a/lib/simple-lists.h b/lib/simple-lists.h index d4dd081e..f553a6bf 100644 --- a/lib/simple-lists.h +++ b/lib/simple-lists.h @@ -15,7 +15,7 @@ typedef struct simp_node { cnode n; union { - byte *s; + char *s; void *p; int i; uns u; @@ -25,13 +25,13 @@ typedef struct simp_node { typedef struct simp2_node { cnode n; union { - byte *s1; + char *s1; void *p1; int i1; uns u1; }; union { - byte *s2; + char *s2; void *p2; int i2; uns u2; diff --git a/lib/url.c b/lib/url.c index da3074bf..8f1a435b 100644 --- a/lib/url.c +++ b/lib/url.c @@ -29,7 +29,7 @@ static uns url_ignore_spaces; static uns url_ignore_underflow; -static byte *url_component_separators = ""; +static char *url_component_separators = ""; static uns url_min_repeat_count = 0x7fffffff; static uns url_max_repeat_length = 0; -- 2.39.5