86 #define STR(x) vstring_str(x)
87 #define LEN(x) VSTRING_LEN(x)
99 static const NAME_CODE data_redirect_map_types[] = {
112 static char *data_redirect_path(
VSTRING *result,
const char *path,
113 const char *log_type,
const char *log_name)
117 #define PATH_DELIMITER "/"
123 msg_warn(
"request to update %s %s in non-%s directory %s",
125 msg_warn(
"redirecting the request to %s-owned %s %s",
131 return (
STR(result));
142 if (path ==
STR(result))
143 msg_panic(
"data_redirect_file: result clobbers input");
145 return (data_redirect_path(result, path,
"file", path));
151 const char *map_type;
154 #define MAP_DELIMITER ":"
159 if (map ==
STR(result))
160 msg_panic(
"data_redirect_map: result clobbers input");
168 map_type_len = path - map;
172 map_type_len = strlen(map_type);
181 data_redirect_path(result, path,
"table", map);
191 return (
STR(result));
206 int main(
int argc,
char **argv)
225 if ((cmd =
mystrtok(&bufp,
" \t")) == 0) {
232 if (strcmp(cmd,
"file") == 0 && target && !junk) {
235 }
else if (strcmp(cmd,
"map") == 0 && target && !junk) {
int vstring_get_nonl(VSTRING *vp, VSTREAM *fp)
NORETURN msg_panic(const char *fmt,...)
char * data_redirect_map(VSTRING *result, const char *map)
int main(int argc, char **argv)
char * mystrtokq(char **src, const char *sep, const char *parens)
char * mystrtok(char **src, const char *sep)
char * sane_dirname(VSTRING *bp, const char *path)
VSTRING * vstring_strcpy(VSTRING *vp, const char *src)
void mail_conf_read(void)
VSTRING * vstring_prepend(VSTRING *vp, const char *buf, ssize_t len)
VSTREAM * vstream_printf(const char *fmt,...)
void msg_warn(const char *fmt,...)
VSTRING * vstring_alloc(ssize_t len)
#define NAME_CODE_FLAG_NONE
char * data_redirect_file(VSTRING *result, const char *path)
int name_code(const NAME_CODE *table, int flags, const char *name)
int vstream_fflush(VSTREAM *stream)
char * sane_basename(VSTRING *bp, const char *path)
VSTRING * vstring_free(VSTRING *vp)
VSTRING * vstring_strncpy(VSTRING *vp, const char *src, ssize_t len)