diff options
Diffstat (limited to 'src/directive.c')
-rw-r--r-- | src/directive.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/directive.c b/src/directive.c index 08a14df..fadaedf 100644 --- a/src/directive.c +++ b/src/directive.c @@ -13,49 +13,49 @@ You should have received a copy of the GNU General Public License along with wydawca. If not, see <http://www.gnu.org/licenses/>. */ #include "wydawca.h" /* Directive file support */ /* Parse directives from TRP->blurb. Fill TRP->directive */ int directive_parse (struct file_triplet *trp) { size_t dcount, i, j; char *p; if (debug_level > 2) logmsg (LOG_DEBUG, _("%s: parsing directive blurb: %s"), trp->file[file_directive].name, trp->blurb); dcount = 0; for (p = trp->blurb; *p; p++) if (*p == '\n') dcount++; - trp->directive = xcalloc (dcount + 1, sizeof trp->directive[0]); + trp->directive = grecs_calloc (dcount + 1, sizeof trp->directive[0]); p = trp->blurb; for (i = j = 0; i < dcount; i++) { trp->directive[j] = p; p = strchr (p, '\n'); if (p) *p++ = 0; if (trim (trp->directive[j]) == 0) /* ignore empty lines */ continue; if (strchr (trp->directive[j], ':') == NULL) { logmsg (LOG_ERR, _("%s: invalid line: %s"), trp->file[file_directive].name, trp->directive[j]); free (trp->directive); trp->directive = NULL; return 1; } j++; if (!p) break; } trp->directive[j] = NULL; return 0; } @@ -90,49 +90,49 @@ directive_get_value (struct file_triplet *trp, const char *key, Arguments: N - Index of the current directive, TRP - Triplet, PKEY, PVAL - Return addresses. The function points PKEY and PVAL to the keyword and value of the Nth directive, and returns N + 1. If N points past all the directive, the function returns 0. */ static int _directive_seq_get (int n, struct file_triplet *trp, const char **pkey, const char **pval) { char *p; size_t len; if (trp->directive[n] == NULL) return 0; p = strchr (trp->directive[n], ':'); len = p - trp->directive[n]; if (len + 1 > trp->tmpsize) { trp->tmpsize = len + 1; - trp->tmp = x2realloc (trp->tmp, &trp->tmpsize); + trp->tmp = grecs_realloc (trp->tmp, trp->tmpsize); } memcpy (trp->tmp, trp->directive[n], len); trp->tmp[len] = 0; *pkey = trp->tmp; for (p++; *p && isspace (*p); p++) ; if (pval) *pval = p; return ++n; } /* Get the first directive from TRP. Point *PKEY to its keyword and *PVAL to its value. Return 1 on success, 0 on failure. */ int directive_first (struct file_triplet *trp, const char **pkey, const char **pval) { int n = 0; return _directive_seq_get (n, trp, pkey, pval); } /* Get the first directive from TRP. Point *PKEY to its keyword and *PVAL to its value. Return 1 on success, 0 on failure. Return non-0 on success, 0 on failure */ @@ -359,49 +359,49 @@ stderr_redirector (const char *tag) if (pipe (p)) { logmsg (LOG_CRIT, "redirector pipe: %s", strerror (errno)); return -1; } pid = fork (); if (pid == -1) { logmsg (LOG_CRIT, "redirector fork: %s", strerror (errno)); return -1; } if (pid == 0) { FILE *fp; size_t size = 0; char *buf = NULL; close (p[1]); fp = fdopen (p[0], "r"); if (!fp) _exit (127); - while (getline (&buf, &size, fp) >= 0) + while (grecs_getline (&buf, &size, fp) >= 0) { trim_crlf (buf); logmsg (LOG_NOTICE, "%s: %s", tag, buf); } _exit (0); } close (p[0]); return p[1]; } static int run_check_script (const char *script, struct file_triplet *trp, const char *descr) { static char *script_file; pid_t pid; int status; int p[2]; RETSIGTYPE (*oldsig)(); FILE *fp; char *buf; size_t size, total; @@ -472,49 +472,49 @@ run_check_script (const char *script, struct file_triplet *trp, setenv ("WYDAWCA_SOURCE", spool->source_dir, 1); setenv ("WYDAWCA_DEST", spool->dest_dir, 1); setenv ("WYDAWCA_URL", spool->url, 1); setenv ("WYDAWCA_TRIPLET_BASE", trp->name, 1); setenv ("WYDAWCA_DIST_FILE", trp->file[file_dist].name, 1); chdir (temp_homedir); argv[0] = "sh"; argv[1] = script_file; argv[2] = NULL; execv ("/bin/sh", argv); _exit (127); } /* Master */ free (script_file); close (p[1]); fp = fdopen (p[0], "r"); buf = NULL; size = total = 0; if (debug_level > 2) logmsg (LOG_DEBUG, _("reading script output...")); - while (getline (&buf, &size, fp) > 0) + while (grecs_getline (&buf, &size, fp) > 0) { size_t len = strlen (buf); if (debug_level > 2) logmsg (LOG_DEBUG, _("read: %s"), buf); txtacc_grow (trp->acc, buf, len); total += size; } txtacc_1grow (trp->acc, 0); if (debug_level > 2) logmsg (LOG_DEBUG, _("bytes read: %lu"), (unsigned long)total); fclose (fp); waitpid (pid, &status, 0); signal (SIGCHLD, oldsig); if (total) trp->check_diag = txtacc_finish (trp->acc, 0); trp->check_result = status; if (WIFEXITED (status)) { status = WEXITSTATUS (status); if (status) |