aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-06 22:33:05 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-03-06 22:45:10 +0200
commit826bb71c57d903f760c89406f93d19fe0c131de0 (patch)
treef2fc240d52d9be2d668a6ea8a813ab5de5732647 /src
parent5b29f3ecc4e2edb172d50b23732a588b7a71ce62 (diff)
downloadwydawca-826bb71c57d903f760c89406f93d19fe0c131de0.tar.gz
wydawca-826bb71c57d903f760c89406f93d19fe0c131de0.tar.bz2
Replace mu_url_t with a custom URL.
Diffstat (limited to 'src')
-rw-r--r--src/config.c89
-rw-r--r--src/directive.c2
-rw-r--r--src/diskio.c11
-rw-r--r--src/process.c4
-rw-r--r--src/tcpwrap.c8
-rw-r--r--src/triplet.c2
-rw-r--r--src/vtab.c71
-rw-r--r--src/wydawca.c4
-rw-r--r--src/wydawca.h22
9 files changed, 180 insertions, 33 deletions
diff --git a/src/config.c b/src/config.c
index b381834..05d76de 100644
--- a/src/config.c
+++ b/src/config.c
@@ -45,6 +45,72 @@ tok_to_keyword(int tok, struct keyword *kw, const char **pres)
45 return 1; 45 return 1;
46} 46}
47 47
48static struct keyword kwfac[] = {
49 { "USER", LOG_USER },
50 { "DAEMON", LOG_DAEMON },
51 { "AUTH", LOG_AUTH },
52 { "AUTHPRIV",LOG_AUTHPRIV },
53 { "MAIL", LOG_MAIL },
54 { "CRON", LOG_CRON },
55 { "LOCAL0", LOG_LOCAL0 },
56 { "LOCAL1", LOG_LOCAL1 },
57 { "LOCAL2", LOG_LOCAL2 },
58 { "LOCAL3", LOG_LOCAL3 },
59 { "LOCAL4", LOG_LOCAL4 },
60 { "LOCAL5", LOG_LOCAL5 },
61 { "LOCAL6", LOG_LOCAL6 },
62 { "LOCAL7", LOG_LOCAL7 },
63 { NULL }
64};
65
66static struct keyword kwpri[] = {
67 { "EMERG", LOG_EMERG },
68 { "ALERT", LOG_ALERT },
69 { "CRIT", LOG_CRIT },
70 { "ERR", LOG_ERR },
71 { "WARNING", LOG_WARNING },
72 { "NOTICE", LOG_NOTICE },
73 { "INFO", LOG_INFO },
74 { "DEBUG", LOG_DEBUG },
75 { NULL }
76};
77
78int
79wy_strtofac(const char *str)
80{
81 int res;
82 if (keyword_to_tok(str, kwfac, &res))
83 return -1;
84 return res;
85}
86
87int
88wy_strtopri(const char *str)
89{
90 int res;
91 if (keyword_to_tok(str, kwpri, &res))
92 return -1;
93 return res;
94}
95
96const char *
97wy_pritostr(int pri)
98{
99 const char *res;
100 if (tok_to_keyword(pri, kwpri, &res))
101 return NULL;
102 return res;
103}
104
105const char *
106wy_factostr(int fac)
107{
108 const char *res;
109 if (tok_to_keyword(fac, kwfac, &res))
110 return NULL;
111 return res;
112}
113
48static struct archive_descr default_archive_descr = { 114static struct archive_descr default_archive_descr = {
49 archive_none, 115 archive_none,
50 NULL, 116 NULL,
@@ -599,14 +665,18 @@ cb_syslog_facility(enum grecs_callback_command cmd, grecs_node_t *node,
599{ 665{
600 grecs_locus_t *locus = &node->locus; 666 grecs_locus_t *locus = &node->locus;
601 grecs_value_t *value = node->v.value; 667 grecs_value_t *value = node->v.value;
602 668 int fac;
669
603 if (assert_string_arg(locus, cmd, value)) 670 if (assert_string_arg(locus, cmd, value))
604 return 1; 671 return 1;
605 672
606 if (mu_string_to_syslog_facility(value->v.string, varptr)) 673 fac = wy_strtofac(value->v.string);
674 if (fac == -1)
607 grecs_error(&value->locus, 0, 675 grecs_error(&value->locus, 0,
608 _("Unknown syslog facility `%s'"), 676 _("Unknown syslog facility `%s'"),
609 value->v.string); 677 value->v.string);
678 else
679 *(int*)varptr = fac;
610 return 0; 680 return 0;
611} 681}
612 682
@@ -1052,18 +1122,17 @@ static int
1052cb_url(enum grecs_callback_command cmd, grecs_node_t *node, 1122cb_url(enum grecs_callback_command cmd, grecs_node_t *node,
1053 void *varptr, void *cb_data) 1123 void *varptr, void *cb_data)
1054{ 1124{
1055 mu_url_t *purl = varptr, url; 1125 wy_url_t *purl = varptr, url;
1056 int rc;
1057 grecs_locus_t *locus = &node->locus; 1126 grecs_locus_t *locus = &node->locus;
1058 grecs_value_t *value = node->v.value; 1127 grecs_value_t *value = node->v.value;
1059 1128
1060 if (assert_string_arg(locus, cmd, value)) 1129 if (assert_string_arg(locus, cmd, value))
1061 return 1; 1130 return 1;
1062 rc = mu_url_create(&url, value->v.string); 1131 url = wy_url_create(value->v.string);
1063 if (rc) { 1132 if (!url) {
1064 grecs_error(&value->locus, 0, _("cannot create URL `%s': %s"), 1133 grecs_error(&value->locus, 0, _("cannot create URL `%s': %s"),
1065 value->v.string, mu_strerror(rc)); 1134 value->v.string, strerror(errno));
1066 return rc; 1135 return 1;
1067 } 1136 }
1068 *purl = url; 1137 *purl = url;
1069 return 0; 1138 return 0;
@@ -1158,7 +1227,7 @@ cb_spool(enum grecs_callback_command cmd, grecs_node_t *node,
1158 rc = 1; 1227 rc = 1;
1159 } else if (url_to_vtab(spool->dest_url, &spool->vtab)) { 1228 } else if (url_to_vtab(spool->dest_url, &spool->vtab)) {
1160 grecs_error(locus, 0, _("unsupported url: %s"), 1229 grecs_error(locus, 0, _("unsupported url: %s"),
1161 mu_url_to_string(spool->dest_url)); 1230 wy_url_printable(spool->dest_url));
1162 rc = 1; 1231 rc = 1;
1163 } else if (spool->vtab.test_url 1232 } else if (spool->vtab.test_url
1164 && spool->vtab.test_url(spool->dest_url, locus)) 1233 && spool->vtab.test_url(spool->dest_url, locus))
@@ -1179,7 +1248,7 @@ cb_spool(enum grecs_callback_command cmd, grecs_node_t *node,
1179 1248
1180 if (!spool->notification) 1249 if (!spool->notification)
1181 spool->notification = default_notification; 1250 spool->notification = default_notification;
1182 mu_url_sget_path(spool->dest_url, &spool->dest_dir); 1251 spool->dest_dir = wy_url_printable(spool->dest_url);
1183 register_spool(spool); 1252 register_spool(spool);
1184 free(spool); 1253 free(spool);
1185 *pdata = NULL; 1254 *pdata = NULL;
diff --git a/src/directive.c b/src/directive.c
index ac7c4cc..b370855 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -461,7 +461,7 @@ run_check_script(const char *script, struct file_triplet *trp,
461 461
462 setenv("WYDAWCA_SPOOL", spool->tag, 1); 462 setenv("WYDAWCA_SPOOL", spool->tag, 1);
463 setenv("WYDAWCA_SOURCE", spool->source_dir, 1); 463 setenv("WYDAWCA_SOURCE", spool->source_dir, 1);
464 setenv("WYDAWCA_DEST", spool->dest_dir, 1); 464 setenv("WYDAWCA_DEST", wy_url_path(spool->dest_url), 1);
465 setenv("WYDAWCA_URL", spool->url, 1); 465 setenv("WYDAWCA_URL", spool->url, 1);
466 setenv("WYDAWCA_TRIPLET_BASE", trp->name, 1); 466 setenv("WYDAWCA_TRIPLET_BASE", trp->name, 1);
467 setenv("WYDAWCA_DIST_FILE", trp->file[file_dist].name, 1); 467 setenv("WYDAWCA_DIST_FILE", trp->file[file_dist].name, 1);
diff --git a/src/diskio.c b/src/diskio.c
index 209d387..c369f85 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -696,17 +696,16 @@ dir_rmsymlink_file(struct file_triplet *trp, const char *file_name)
696} 696}
697 697
698int 698int
699dir_test_url(mu_url_t url, grecs_locus_t * locus) 699dir_test_url(wy_url_t url, grecs_locus_t * locus)
700{ 700{
701 int rc; 701 int rc;
702 const char *dest_dir; 702 const char *dest_dir;
703 703
704 rc = mu_url_sget_path(url, &dest_dir); 704 dest_dir = wy_url_path(url);
705 if (rc) { 705 if (!dest_dir) {
706 grecs_error(locus, 0, 706 grecs_error(locus, 0,
707 _("cannot extract directory part from URL: %s"), 707 _("cannot extract directory part from URL"));
708 mu_strerror(rc)); 708 return -1;
709 return rc;
710 } 709 }
711 if (test_dir(dest_dir, &rc)) { 710 if (test_dir(dest_dir, &rc)) {
712 if (rc) 711 if (rc)
diff --git a/src/process.c b/src/process.c
index 0b4fd1b..e111e6b 100644
--- a/src/process.c
+++ b/src/process.c
@@ -190,7 +190,7 @@ spool_add_new_file(const struct spool *spool, const char *name,
190{ 190{
191 if (debug_level) 191 if (debug_level)
192 logmsg(LOG_DEBUG, "%s -> %s, adding %s", spool->source_dir, 192 logmsg(LOG_DEBUG, "%s -> %s, adding %s", spool->source_dir,
193 mu_url_to_string(spool->dest_url), name); 193 wy_url_printable(spool->dest_url), name);
194 194
195 if (chdir(spool->source_dir)) { 195 if (chdir(spool->source_dir)) {
196 logmsg(LOG_ERR, _("cannot chdir to %s: %s"), spool->source_dir, 196 logmsg(LOG_ERR, _("cannot chdir to %s: %s"), spool->source_dir,
@@ -210,7 +210,7 @@ scan_spool_unlocked(struct spool *spool, int uc, uid_t *uv)
210 210
211 if (debug_level) 211 if (debug_level)
212 logmsg(LOG_DEBUG, "%s -> %s", spool->source_dir, 212 logmsg(LOG_DEBUG, "%s -> %s", spool->source_dir,
213 mu_url_to_string(spool->dest_url)); 213 wy_url_printable(spool->dest_url));
214 214
215 if (chdir(spool->source_dir)) { 215 if (chdir(spool->source_dir)) {
216 logmsg(LOG_ERR, _("cannot chdir to %s: %s"), spool->source_dir, 216 logmsg(LOG_ERR, _("cannot chdir to %s: %s"), spool->source_dir,
diff --git a/src/tcpwrap.c b/src/tcpwrap.c
index 4a3e59b..9d7e7d0 100644
--- a/src/tcpwrap.c
+++ b/