/* This file is in the public domain. */ #include #include #include "util.h" #include "ctype.h" #include "config.h" #include "structs.h" extern const MAP_OPS map_ops_error; typedef struct map_error_priv MAP_ERROR_PRIV; struct map_error_priv { char *name; } ; static int map_error_add(CONFIG *cfg, LISTEN *l, int pri, const char *key, int keylen, const char *rest) { MAP *map; MAP_ERROR_PRIV *p; int e; int i; if ((keylen != 5) || bcmp(key,"error",5)) return(0); if (! *rest) config_err(cfg,"missing name on `map error' listen line"); i = 0; while (rest[i] && !UCisspace(rest[i])) i ++; e = i; while (rest[i] && UCisspace(rest[i])) i ++; if (rest[i]) config_err(cfg,"trailing junk on `map error' listen line"); p = malloc(sizeof(MAP_ERROR_PRIV)); p->name = blk_to_nulterm(rest,e); map = malloc(sizeof(MAP)); map->pri = pri; map->ops = &map_ops_error; map->priv = p; map->link = l->mappings; l->mappings = map; return(1); } static void map_error_free(void *pv) { MAP_ERROR_PRIV *p; p = pv; free(p->name); free(p); } const MAP_OPS map_ops_error = MAP_OPS_INIT(error);