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 | |||
@@ -25,25 +25,25 @@ directive_parse (struct file_triplet *trp) | |||
25 | size_t dcount, i, j; | 25 | size_t dcount, i, j; |
26 | char *p; | 26 | char *p; |
27 | 27 | ||
28 | if (debug_level > 2) | 28 | if (debug_level > 2) |
29 | logmsg (LOG_DEBUG, _("%s: parsing directive blurb: %s"), | 29 | logmsg (LOG_DEBUG, _("%s: parsing directive blurb: %s"), |
30 | trp->file[file_directive].name, trp->blurb); | 30 | trp->file[file_directive].name, trp->blurb); |
31 | 31 | ||
32 | dcount = 0; | 32 | dcount = 0; |
33 | for (p = trp->blurb; *p; p++) | 33 | for (p = trp->blurb; *p; p++) |
34 | if (*p == '\n') | 34 | if (*p == '\n') |
35 | dcount++; | 35 | dcount++; |
36 | 36 | ||
37 | trp->directive = xcalloc (dcount + 1, sizeof trp->directive[0]); | 37 | trp->directive = grecs_calloc (dcount + 1, sizeof trp->directive[0]); |
38 | p = trp->blurb; | 38 | p = trp->blurb; |
39 | for (i = j = 0; i < dcount; i++) | 39 | for (i = j = 0; i < dcount; i++) |
40 | { | 40 | { |
41 | trp->directive[j] = p; | 41 | trp->directive[j] = p; |
42 | p = strchr (p, '\n'); | 42 | p = strchr (p, '\n'); |
43 | if (p) | 43 | if (p) |
44 | *p++ = 0; | 44 | *p++ = 0; |
45 | if (trim (trp->directive[j]) == 0) /* ignore empty lines */ | 45 | if (trim (trp->directive[j]) == 0) /* ignore empty lines */ |
46 | continue; | 46 | continue; |
47 | if (strchr (trp->directive[j], ':') == NULL) | 47 | if (strchr (trp->directive[j], ':') == NULL) |
48 | { | 48 | { |
49 | logmsg (LOG_ERR, _("%s: invalid line: %s"), | 49 | logmsg (LOG_ERR, _("%s: invalid line: %s"), |
@@ -102,25 +102,25 @@ _directive_seq_get (int n, struct file_triplet *trp, | |||
102 | { | 102 | { |
103 | char *p; | 103 | char *p; |
104 | size_t len; | 104 | size_t len; |
105 | 105 | ||
106 | if (trp->directive[n] == NULL) | 106 | if (trp->directive[n] == NULL) |
107 | return 0; | 107 | return 0; |
108 | 108 | ||
109 | p = strchr (trp->directive[n], ':'); | 109 | p = strchr (trp->directive[n], ':'); |
110 | len = p - trp->directive[n]; | 110 | len = p - trp->directive[n]; |
111 | if (len + 1 > trp->tmpsize) | 111 | if (len + 1 > trp->tmpsize) |
112 | { | 112 | { |
113 | trp->tmpsize = len + 1; | 113 | trp->tmpsize = len + 1; |
114 | trp->tmp = x2realloc (trp->tmp, &trp->tmpsize); | 114 | trp->tmp = grecs_realloc (trp->tmp, trp->tmpsize); |
115 | } | 115 | } |
116 | memcpy (trp->tmp, trp->directive[n], len); | 116 | memcpy (trp->tmp, trp->directive[n], len); |
117 | trp->tmp[len] = 0; | 117 | trp->tmp[len] = 0; |
118 | *pkey = trp->tmp; | 118 | *pkey = trp->tmp; |
119 | for (p++; *p && isspace (*p); p++) | 119 | for (p++; *p && isspace (*p); p++) |
120 | ; | 120 | ; |
121 | if (pval) | 121 | if (pval) |
122 | *pval = p; | 122 | *pval = p; |
123 | return ++n; | 123 | return ++n; |
124 | } | 124 | } |
125 | 125 | ||
126 | /* Get the first directive from TRP. Point *PKEY to its keyword and | 126 | /* Get the first directive from TRP. Point *PKEY to its keyword and |
@@ -371,25 +371,25 @@ stderr_redirector (const char *tag) | |||
371 | } | 371 | } |
372 | 372 | ||
373 | if (pid == 0) | 373 | if (pid == 0) |
374 | { | 374 | { |
375 | FILE *fp; | 375 | FILE *fp; |
376 | size_t size = 0; | 376 | size_t size = 0; |
377 | char *buf = NULL; | 377 | char *buf = NULL; |
378 | 378 | ||
379 | close (p[1]); | 379 | close (p[1]); |
380 | fp = fdopen (p[0], "r"); | 380 | fp = fdopen (p[0], "r"); |
381 | if (!fp) | 381 | if (!fp) |
382 | _exit (127); | 382 | _exit (127); |
383 | while (getline (&buf, &size, fp) >= 0) | 383 | while (grecs_getline (&buf, &size, fp) >= 0) |
384 | { | 384 | { |
385 | trim_crlf (buf); | 385 | trim_crlf (buf); |
386 | logmsg (LOG_NOTICE, "%s: %s", tag, buf); | 386 | logmsg (LOG_NOTICE, "%s: %s", tag, buf); |
387 | } | 387 | } |
388 | _exit (0); | 388 | _exit (0); |
389 | } | 389 | } |
390 | 390 | ||
391 | close (p[0]); | 391 | close (p[0]); |
392 | return p[1]; | 392 | return p[1]; |
393 | } | 393 | } |
394 | 394 | ||
395 | static int | 395 | static int |
@@ -484,25 +484,25 @@ run_check_script (const char *script, struct file_triplet *trp, | |||
484 | execv ("/bin/sh", argv); | 484 | execv ("/bin/sh", argv); |
485 | _exit (127); | 485 | _exit (127); |
486 | } | 486 | } |
487 | 487 | ||
488 | /* Master */ | 488 | /* Master */ |
489 | free (script_file); | 489 | free (script_file); |
490 | close (p[1]); | 490 | close (p[1]); |
491 | fp = fdopen (p[0], "r"); | 491 | fp = fdopen (p[0], "r"); |
492 | buf = NULL; | 492 | buf = NULL; |
493 | size = total = 0; | 493 | size = total = 0; |
494 | if (debug_level > 2) | 494 | if (debug_level > 2) |
495 | logmsg (LOG_DEBUG, _("reading script output...")); | 495 | logmsg (LOG_DEBUG, _("reading script output...")); |
496 | while (getline (&buf, &size, fp) > 0) | 496 | while (grecs_getline (&buf, &size, fp) > 0) |
497 | { | 497 | { |
498 | size_t len = strlen (buf); | 498 | size_t len = strlen (buf); |
499 | if (debug_level > 2) | 499 | if (debug_level > 2) |
500 | logmsg (LOG_DEBUG, _("read: %s"), buf); | 500 | logmsg (LOG_DEBUG, _("read: %s"), buf); |
501 | txtacc_grow (trp->acc, buf, len); | 501 | txtacc_grow (trp->acc, buf, len); |
502 | total += size; | 502 | total += size; |
503 | } | 503 | } |
504 | txtacc_1grow (trp->acc, 0); | 504 | txtacc_1grow (trp->acc, 0); |
505 | if (debug_level > 2) | 505 | if (debug_level > 2) |
506 | logmsg (LOG_DEBUG, _("bytes read: %lu"), (unsigned long)total); | 506 | logmsg (LOG_DEBUG, _("bytes read: %lu"), (unsigned long)total); |
507 | 507 | ||
508 | fclose (fp); | 508 | fclose (fp); |