j5

aditionnal tools for the s6 service manager
Log | Files | Refs | README

commit 88497203a33f3f7620e3b128cb7a99849fedc58a
parent 2dc59dbb440cf97b20bd52f93e3393e4e5033274
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 26 Jan 2019 23:14:48 +0100

fix difference between .c and .h declaration

Diffstat:
Mj5-envdir.c | 15+++++++--------
Mopenwriteclose.h | 2+-
2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/j5-envdir.c b/j5-envdir.c @@ -28,7 +28,7 @@ die_nomem(void) void usage(char *progname) { - log_usage(progname, ""); + log_usage(progname, "[-a] [-f file] [-p prefix] [-s suffix] [-n stripchars] envdir cmd [arg...]"); } #include <stdio.h> @@ -48,7 +48,6 @@ replace(stralloc *sa, char const *src, size_t siz, char const *pre, genalloc con if (i == siz) break; src += i + len_pre; siz -= i + len_pre; - dprintf(1, "i:%zd siz:%zd\n", i, siz); for (size_t k = 0; k < genalloc_len(ga, keyval); ++k) { keyval *a = genalloc_get(ga, keyval, k); @@ -90,11 +89,11 @@ main(int argc, char **argv) genalloc ga; ARG_BEGIN { + case 'a': flag_a = 1; break; + case 'f': flag_f = ARG; break; + case 'n': flag_n = ARG; break; case 'p': pre = ARG; break; case 's': suf = ARG; break; - case 'n': flag_n = ARG; break; - case 'f': flag_f = ARG; break; - case 'a': flag_a = 1; break; default: usage(arg_0); break; } ARG_END; if (!*argv) usage(arg_0); @@ -130,9 +129,9 @@ main(int argc, char **argv) if (flag_f) { stralloc src = STRALLOC_ZERO; stralloc dst = STRALLOC_ZERO; - openreadclose(flag_f, &src, 1024); + if (!openreadclose(flag_f, &src, 1024)) log_fatal_2(102, "open read close ", flag_f); if (!replace(&dst, src.x, src.n, pre, &ga, suf)) die_nomem(); - openwriteclose(flag_f, &dst); + if (!openwriteclose(flag_f, dst.x, dst.n)) log_fatal_2(102, "open write close ", flag_f); } for (size_t i = 0; i < genalloc_len(&ga, keyval); ++i) { @@ -141,7 +140,7 @@ main(int argc, char **argv) } genalloc_free(&ga); - if (!*argv) { usage(arg_0); } + if (!*argv) usage(arg_0); execvp(*argv, argv); log_fatal_sys_2(127, "exec ", *argv); diff --git a/openwriteclose.h b/openwriteclose.h @@ -3,6 +3,6 @@ #include "stralloc.h" -int openwriteclose(char const *, stralloc const *); +int openwriteclose(char const *, char const *, size_t); #endif