author | Olivier Brunel
<jjk@jjacky.com> 2015-07-30 17:08:26 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2015-08-07 17:24:47 UTC |
parent | 5392d0623ed77ed153aefae0533b2699206fc9da |
src/anopa/aa-enable.c | +8 | -9 |
src/anopa/aa-reset.c | +2 | -3 |
src/anopa/aa-start.c | +4 | -5 |
src/anopa/aa-status.c | +6 | -7 |
src/anopa/aa-stop.c | +6 | -7 |
src/anopa/start-stop.c | +22 | -23 |
src/include/anopa/output.h | +106 | -0 |
src/libanopa/exec_longrun.c | +4 | -4 |
src/libanopa/exec_oneshot.c | +7 | -7 |
src/libanopa/output.c | +53 | -0 |
src/libanopa/service.c | +3 | -3 |
src/libanopa/service_start.c | +2 | -2 |
src/utils/aa-chroot.c | +5 | -5 |
src/utils/aa-ctty.c | +4 | -4 |
src/utils/aa-echo.c | +0 | -1 |
src/utils/aa-incmdline.c | +2 | -4 |
src/utils/aa-kill.c | +3 | -3 |
src/utils/aa-mount.c | +9 | -9 |
src/utils/aa-mvlog.c | +8 | -10 |
src/utils/aa-pivot.c | +2 | -2 |
src/utils/aa-reboot.c | +2 | -4 |
src/utils/aa-service.c | +10 | -10 |
src/utils/aa-setready.c | +5 | -7 |
src/utils/aa-terminate.c | +6 | -9 |
src/utils/aa-test.c | +3 | -3 |
src/utils/aa-tty.c | +2 | -3 |
src/utils/aa-umount.c | +2 | -2 |
diff --git a/src/anopa/aa-enable.c b/src/anopa/aa-enable.c index 838238e..c82799d 100644 --- a/src/anopa/aa-enable.c +++ b/src/anopa/aa-enable.c @@ -35,7 +35,6 @@ #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/direntry.h> -#include <skalibs/strerr2.h> #include <skalibs/error.h> #include <skalibs/uint.h> #include <skalibs/skamisc.h> @@ -205,9 +204,9 @@ main (int argc, char * const argv[]) int r; if (!stralloc_catb (&aa_sa_sources, SOURCE_ETC, sizeof (SOURCE_ETC))) - strerr_diefu1sys (1, "stralloc_catb"); + aa_strerr_diefu1sys (1, "stralloc_catb"); if (!stralloc_catb (&aa_sa_sources, SOURCE_USR, sizeof (SOURCE_USR))) - strerr_diefu1sys (1, "stralloc_catb"); + aa_strerr_diefu1sys (1, "stralloc_catb"); for (;;) { @@ -274,7 +273,7 @@ main (int argc, char * const argv[]) case 's': unslash (optarg); if (!stralloc_catb (&aa_sa_sources, optarg, strlen (optarg) + 1)) - strerr_diefu1sys (1, "stralloc_catb"); + aa_strerr_diefu1sys (1, "stralloc_catb"); break; case 'u': @@ -303,11 +302,11 @@ main (int argc, char * const argv[]) if (r < 0) { if (r == -ERR_IO_REPODIR) - strerr_diefu2sys (1, "create repository ", path_repo); + aa_strerr_diefu2sys (1, "create repository ", path_repo); else if (r == -ERR_IO_SCANDIR) - strerr_diefu3sys (1, "create scandir ", path_repo, "/" AA_SCANDIR_DIRNAME); + aa_strerr_diefu3sys (1, "create scandir ", path_repo, "/" AA_SCANDIR_DIRNAME); else - strerr_diefu2sys (1, "init repository ", path_repo); + aa_strerr_diefu2sys (1, "init repository ", path_repo); } /* process listdir (path_list) first, to ensure if the service was also @@ -320,7 +319,7 @@ main (int argc, char * const argv[]) stralloc_catb (&sa_pl, path_list, strlen (path_list) + 1); r = aa_scan_dir (&sa_pl, 0, it_list, NULL); if (r < 0) - strerr_diefu3sys (-r, "read list directory ", + aa_strerr_diefu3sys (-r, "read list directory ", (*path_list != '/' && *path_list != '.') ? LISTDIR_PREFIX : path_list, (*path_list != '/' && *path_list != '.') ? path_list : ""); } @@ -329,7 +328,7 @@ main (int argc, char * const argv[]) if (str_equal (argv[i], "-")) { if (process_names_from_stdin ((names_cb) enable_service, NULL) < 0) - strerr_diefu1sys (ERR_IO, "process names from stdin"); + aa_strerr_diefu1sys (ERR_IO, "process names from stdin"); } else enable_service (argv[i], 0); diff --git a/src/anopa/aa-reset.c b/src/anopa/aa-reset.c index f5d902e..1ec14e9 100644 --- a/src/anopa/aa-reset.c +++ b/src/anopa/aa-reset.c @@ -26,7 +26,6 @@ #include <errno.h> #include <getopt.h> -#include <skalibs/strerr2.h> #include <skalibs/tai.h> #include <skalibs/error.h> #include <anopa/common.h> @@ -210,13 +209,13 @@ main (int argc, char * const argv[]) r = aa_init_repo (path_repo, AA_REPO_READ); if (r < 0) - strerr_diefu2sys (2, "init repository ", path_repo); + aa_strerr_diefu2sys (2, "init repository ", path_repo); for (i = 0; i < argc; ++i) if (str_equal (argv[i], "-")) { if (process_names_from_stdin ((names_cb) reset_service, (void *) mode) < 0) - strerr_diefu1sys (ERR_IO, "process names from stdin"); + aa_strerr_diefu1sys (ERR_IO, "process names from stdin"); } else reset_service (argv[i], mode); diff --git a/src/anopa/aa-start.c b/src/anopa/aa-start.c index 39c159a..5d485f1 100644 --- a/src/anopa/aa-start.c +++ b/src/anopa/aa-start.c @@ -37,7 +37,6 @@ #include <skalibs/bytestr.h> #include <skalibs/direntry.h> #include <skalibs/genalloc.h> -#include <skalibs/strerr2.h> #include <skalibs/error.h> #include <skalibs/tai.h> #include <skalibs/iopause.h> @@ -285,7 +284,7 @@ main (int argc, char * const argv[]) case 't': if (!uint0_scan (optarg, &aa_secs_timeout)) - strerr_diefu2sys (ERR_IO, "set default timeout to ", optarg); + aa_strerr_diefu2sys (ERR_IO, "set default timeout to ", optarg); break; case 'V': @@ -309,7 +308,7 @@ main (int argc, char * const argv[]) dieusage (1); if (aa_init_repo (path_repo, AA_REPO_WRITE) < 0) - strerr_diefu2sys (ERR_IO, "init repository ", path_repo); + aa_strerr_diefu2sys (ERR_IO, "init repository ", path_repo); if (path_list) { @@ -322,7 +321,7 @@ main (int argc, char * const argv[]) r = aa_scan_dir (&sa, 1, it_start, NULL); stralloc_free (&sa); if (r < 0) - strerr_diefu3sys (-r, "read list directory ", + aa_strerr_diefu3sys (-r, "read list directory ", (*path_list != '/' && *path_list != '.') ? LISTDIR_PREFIX : path_list, (*path_list != '/' && *path_list != '.') ? path_list : ""); } @@ -333,7 +332,7 @@ main (int argc, char * const argv[]) if (str_equal (argv[i], "-")) { if (process_names_from_stdin ((names_cb) add_service, NULL) < 0) - strerr_diefu1sys (ERR_IO, "process names from stdin"); + aa_strerr_diefu1sys (ERR_IO, "process names from stdin"); } else add_service (argv[i], NULL); diff --git a/src/anopa/aa-status.c b/src/anopa/aa-status.c index 705b4c3..2ffcff1 100644 --- a/src/anopa/aa-status.c +++ b/src/anopa/aa-status.c @@ -35,7 +35,6 @@ #include <skalibs/djbunix.h> #include <skalibs/genalloc.h> #include <skalibs/stralloc.h> -#include <skalibs/strerr2.h> #include <skalibs/uint.h> #include <skalibs/djbtime.h> #include <skalibs/sig.h> @@ -235,7 +234,7 @@ put_list_header (struct config *cfg) len -= cols[1].len; if (len < len) { - strerr_warn1x ("Terminal too small, disabling list mode"); + aa_strerr_warn1x ("Terminal too small, disabling list mode"); cfg->mode = MODE_NORMAL; return 0; } @@ -729,7 +728,7 @@ main (int argc, char * const argv[]) case 'f': if (!set_filter (optarg)) - strerr_diefu3sys (1, "set filter '", optarg, "'"); + aa_strerr_diefu3sys (1, "set filter '", optarg, "'"); break; case 'h': @@ -768,7 +767,7 @@ main (int argc, char * const argv[]) r = aa_init_repo (path_repo, AA_REPO_READ); if (r < 0) - strerr_diefu2sys (2, "init repository ", path_repo); + aa_strerr_diefu2sys (2, "init repository ", path_repo); if (cfg.mode == MODE_LIST) { @@ -792,7 +791,7 @@ main (int argc, char * const argv[]) stralloc_catb (&sa, ".", 2); r = aa_scan_dir (&sa, 0, it_all, &cfg); if (r < 0) - strerr_diefu2sys (-r, "scan repo directory ", path_repo); + aa_strerr_diefu2sys (-r, "scan repo directory ", path_repo); } else if (path_list) { @@ -805,7 +804,7 @@ main (int argc, char * const argv[]) r = aa_scan_dir (&sa, 1, it_listdir, &cfg); stralloc_free (&sa); if (r < 0) - strerr_diefu3sys (-r, "read list directory ", + aa_strerr_diefu3sys (-r, "read list directory ", (*path_list != '/' && *path_list != '.') ? LISTDIR_PREFIX : path_list, (*path_list != '/' && *path_list != '.') ? path_list : ""); } @@ -814,7 +813,7 @@ main (int argc, char * const argv[]) if (str_equal (argv[i], "-")) { if (process_names_from_stdin ((names_cb) load_service, &cfg) < 0) - strerr_diefu1sys (ERR_IO, "process names from stdin"); + aa_strerr_diefu1sys (ERR_IO, "process names from stdin"); } else load_service (argv[i], &cfg); diff --git a/src/anopa/aa-stop.c b/src/anopa/aa-stop.c index 5a7a238..268bc6f 100644 --- a/src/anopa/aa-stop.c +++ b/src/anopa/aa-stop.c @@ -31,7 +31,6 @@ #include <skalibs/bytestr.h> #include <skalibs/direntry.h> #include <skalibs/genalloc.h> -#include <skalibs/strerr2.h> #include <skalibs/error.h> #include <skalibs/uint.h> #include <skalibs/tai.h> @@ -173,7 +172,7 @@ add_service (const char *name, void *data) if (aa_service (si)->st.code != ERR_NOT_UP) { errno = EINVAL; - strerr_diefu1sys (ERR_IO, "add service"); + aa_strerr_diefu1sys (ERR_IO, "add service"); } if (!(mode & AA_MODE_IS_DRY)) @@ -304,7 +303,7 @@ main (int argc, char * const argv[]) case 't': if (!uint0_scan (optarg, &aa_secs_timeout)) - strerr_diefu2sys (ERR_IO, "set default timeout to ", optarg); + aa_strerr_diefu2sys (ERR_IO, "set default timeout to ", optarg); break; case 'V': @@ -325,7 +324,7 @@ main (int argc, char * const argv[]) dieusage (1); if (aa_init_repo (path_repo, AA_REPO_WRITE) < 0) - strerr_diefu2sys (ERR_IO, "init repository ", path_repo); + aa_strerr_diefu2sys (ERR_IO, "init repository ", path_repo); /* let's "preload" every services from the repo. This will have everything * in tmp list, either LOAD_DONE when up, or LOAD_FAIL when not @@ -342,7 +341,7 @@ main (int argc, char * const argv[]) r = aa_scan_dir (&sa, 0, it_preload, NULL); stralloc_free (&sa); if (r < 0) - strerr_diefu1sys (-r, "read repository directory"); + aa_strerr_diefu1sys (-r, "read repository directory"); } if (mode & AA_MODE_STOP_ALL) @@ -376,7 +375,7 @@ main (int argc, char * const argv[]) r = aa_scan_dir (&sa, 1, it_stop, NULL); stralloc_free (&sa); if (r < 0) - strerr_diefu3sys (-r, "read list directory ", + aa_strerr_diefu3sys (-r, "read list directory ", (*path_list != '/' && *path_list != '.') ? LISTDIR_PREFIX : path_list, (*path_list != '/' && *path_list != '.') ? path_list : ""); } @@ -385,7 +384,7 @@ main (int argc, char * const argv[]) if (str_equal (argv[i], "-")) { if (process_names_from_stdin ((names_cb) add_service, NULL) < 0) - strerr_diefu1sys (ERR_IO, "process names from stdin"); + aa_strerr_diefu1sys (ERR_IO, "process names from stdin"); } else add_service (argv[i], NULL); diff --git a/src/anopa/start-stop.c b/src/anopa/start-stop.c index 6d01cd1..7cce2f7 100644 --- a/src/anopa/start-stop.c +++ b/src/anopa/start-stop.c @@ -36,7 +36,6 @@ #include <skalibs/sig.h> #include <skalibs/uint.h> #include <skalibs/uint16.h> -#include <skalibs/strerr2.h> #include <anopa/service.h> #include <anopa/ga_int_list.h> #include <anopa/output.h> @@ -298,7 +297,7 @@ refresh_draw () r = term_set_echo (0); if (r < 0) { - strerr_warnwu2sys ("set terminal attributes; " + aa_strerr_warnu2sys ("set terminal attributes; " "can't ask for password for service ", aa_service_name (aa_service (pg->si))); break; @@ -648,7 +647,7 @@ end_si_password (void) r = term_set_echo (1); if (r < 0) - strerr_warnwu1sys ("reset terminal attributes"); + aa_strerr_warnu1sys ("reset terminal attributes"); /* to get to the next one, if any */ draw |= DRAW_NEED_PASSWORD; @@ -675,7 +674,7 @@ handle_fdw (int fd) r = fd_write (fd, pg->aa_pg.sa.s + offset, len); if (r < 0) { - strerr_warnwu2sys ("write to fd_in of service ", aa_service_name (s)); + aa_strerr_warnu2sys ("write to fd_in of service ", aa_service_name (s)); return r; } else if (r < len) @@ -700,7 +699,7 @@ handle_oneshot (int is_start) if (r < 0) { if (errno != ECHILD) - strerr_warnwu1sys ("wait_pids_nohang"); + aa_strerr_warnu1sys ("wait_pids_nohang"); return r; } else if (r == 0) @@ -727,7 +726,7 @@ handle_oneshot (int is_start) svst->event = (is_start) ? AA_EVT_STARTED : AA_EVT_STOPPED; tain_copynow (&svst->stamp); if (aa_service_status_write (svst, aa_service_name (aa_service (si))) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (aa_service (si))); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (aa_service (si))); put_title (1, aa_service_name (aa_service (si)), (is_start) ? "Started" : "Stopped", 1); @@ -745,7 +744,7 @@ handle_oneshot (int is_start) tain_copynow (&svst->stamp); aa_service_status_set_msg (svst, ""); if (aa_service_status_write (svst, aa_service_name (aa_service (si))) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (aa_service (si))); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (aa_service (si))); put_err_service (aa_service_name (aa_service (si)), ERR_TIMEDOUT, 1); genalloc_append (int, &ga_timedout, &si); @@ -759,7 +758,7 @@ handle_oneshot (int is_start) tain_copynow (&svst->stamp); aa_service_status_set_msg (svst, ""); if (aa_service_status_write (svst, aa_service_name (aa_service (si))) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (aa_service (si))); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (aa_service (si))); if (WIFEXITED (wstat)) { @@ -805,7 +804,7 @@ handle_longrun (aa_mode mode, uint16 id, char event) { char buf[UINT16_FMT]; buf[uint16_fmt (buf, id)] = '\0'; - strerr_warnwu2x ("find longrun service for id#", buf); + aa_strerr_warnu2x ("find longrun service for id#", buf); return -1; } @@ -875,7 +874,7 @@ handle_signals (aa_mode mode) switch (c) { case -1: - strerr_diefu1sys (ERR_IO, "selfpipe_read"); + aa_strerr_diefu1sys (ERR_IO, "selfpipe_read"); case 0: return r; @@ -911,7 +910,7 @@ handle_signals (aa_mode mode) break; default: - strerr_dief1x (ERR_IO, "internal error: invalid selfpipe_read value"); + aa_strerr_dief1x (ERR_IO, "internal error: invalid selfpipe_read value"); } } } @@ -1082,7 +1081,7 @@ process_timeouts (aa_mode mode, aa_scan_cb scan_cb) tain_copynow (&svst->stamp); aa_service_status_set_msg (svst, ""); if (aa_service_status_write (svst, aa_service_name (aa_service (si))) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (aa_service (si))); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (aa_service (si))); put_err_service (aa_service_name (aa_service (si)), ERR_TIMEDOUT, 1); genalloc_append (int, &ga_timedout, &si); @@ -1145,7 +1144,7 @@ process_timeouts (aa_mode mode, aa_scan_cb scan_cb) tain_copynow (&svst->stamp); aa_service_status_set_msg (svst, ""); if (aa_service_status_write (svst, aa_service_name (aa_service (si))) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (aa_service (si))); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (aa_service (si))); put_err_service (aa_service_name (aa_service (si)), ERR_TIMEDOUT, 1); genalloc_append (int, &ga_timedout, &si); @@ -1181,11 +1180,11 @@ mainloop (aa_mode mode, aa_scan_cb scan_cb) int i; if (!genalloc_ready_tuned (iopause_fd, &ga_iop, 2, 0, 0, 1)) - strerr_diefu1sys (ERR_IO, "allocate iopause_fd"); + aa_strerr_diefu1sys (ERR_IO, "allocate iopause_fd"); iop.fd = selfpipe_init (); if (iop.fd == -1) - strerr_diefu1sys (ERR_IO, "init selfpipe"); + aa_strerr_diefu1sys (ERR_IO, "init selfpipe"); iop.events = IOPAUSE_READ; genalloc_append (iopause_fd, &ga_iop, &iop); @@ -1194,7 +1193,7 @@ mainloop (aa_mode mode, aa_scan_cb scan_cb) sig_ignore (SIGINT); iop.fd = aa_prepare_mainlist (prepare_cb, exec_cb); if (iop.fd < 0) - strerr_diefu1sys (ERR_IO, "prepare mainlist"); + aa_strerr_diefu1sys (ERR_IO, "prepare mainlist"); else if (iop.fd == 0) iop.fd = -1; genalloc_append (iopause_fd, &ga_iop, &iop); @@ -1206,7 +1205,7 @@ mainloop (aa_mode mode, aa_scan_cb scan_cb) sigaddset (&set, SIGINT); sigaddset (&set, SIGWINCH); if (selfpipe_trapset (&set) < 0) - strerr_diefu1sys (ERR_IO, "trap signals"); + aa_strerr_diefu1sys (ERR_IO, "trap signals"); /* start what we can */ for (i = 0; i < genalloc_len (int, &aa_main_list); ++i) @@ -1252,7 +1251,7 @@ mainloop (aa_mode mode, aa_scan_cb scan_cb) nb_iop = genalloc_len (iopause_fd, &ga_iop); r = iopause_g (genalloc_s (iopause_fd, &ga_iop), nb_iop, &iol_deadline); if (r < 0) - strerr_diefu1sys (ERR_IO, "iopause"); + aa_strerr_diefu1sys (ERR_IO, "iopause"); else if (r == 0) { if (ms1 < 0 || ms2 < ms1) @@ -1270,13 +1269,13 @@ mainloop (aa_mode mode, aa_scan_cb scan_cb) { r = handle_fd (iofd->fd); if (r < 0) - strerr_warnwu1sys ("handle fd"); + aa_strerr_warnu1sys ("handle fd"); } else if (iofd->revents & IOPAUSE_WRITE) { r = handle_fdw (iofd->fd); if (r < 0) - strerr_warnwu1sys ("handle fdw"); + aa_strerr_warnu1sys ("handle fdw"); } else if (iofd->revents & IOPAUSE_EXCEPT) close_fd_for (iofd->fd, -1); @@ -1286,7 +1285,7 @@ mainloop (aa_mode mode, aa_scan_cb scan_cb) if (iofd->revents & IOPAUSE_READ) scan += handle_signals (mode); else if (iofd->revents & IOPAUSE_EXCEPT) - strerr_diefu1sys (ERR_IO, "iopause: selfpipe error"); + aa_strerr_diefu1sys (ERR_IO, "iopause: selfpipe error"); iofd = &genalloc_s (iopause_fd, &ga_iop)[1]; if (iofd->fd <= 0) @@ -1301,7 +1300,7 @@ mainloop (aa_mode mode, aa_scan_cb scan_cb) r = aa_get_longrun_info (&id, &event); if (r < 0) { - strerr_warnwu1sys ("get longrun information"); + aa_strerr_warnu1sys ("get longrun information"); break; } else if (r == 0) @@ -1313,7 +1312,7 @@ mainloop (aa_mode mode, aa_scan_cb scan_cb) } } else if (iofd->revents & IOPAUSE_EXCEPT) - strerr_diefu1sys (ERR_IO, "iopause: longrun pipe error"); + aa_strerr_diefu1sys (ERR_IO, "iopause: longrun pipe error"); scan: if (scan > 0) diff --git a/src/include/anopa/output.h b/src/include/anopa/output.h index 396899c..dcbb0c5 100644 --- a/src/include/anopa/output.h +++ b/src/include/anopa/output.h @@ -24,6 +24,9 @@ #define AA_OUTPUT_H #include <string.h> /* strlen() */ +#include <skalibs/error.h> + +extern const char *PROG; #define ANSI_HIGHLIGHT_ON "\x1B[1;39m" #define ANSI_HIGHLIGHT_RED_ON "\x1B[1;31m" @@ -52,4 +55,107 @@ extern void aa_put_warn (const char *name, const char *msg, int end); #define aa_end_title() aa_bs_end (AA_OUT) extern void aa_put_title (int main, const char *name, const char *title, int end); +extern void aa_strerr_warn (const char *s1, + const char *s2, + const char *s3, + const char *s4, + const char *s5, + const char *s6, + const char *s7, + const char *s8, + const char *s9, + const char *s10); + +#define aa_strerr_warn1x(s1) \ + aa_strerr_warn ("warning: ", s1, 0, 0, 0, 0, 0, 0, 0, 0) +#define aa_strerr_warn2x(s1,s2) \ + aa_strerr_warn ("warning: ", s1, s2, 0, 0, 0, 0, 0, 0, 0) +#define aa_strerr_warn3x(s1,s2,s3) \ + aa_strerr_warn ("warning: ", s1, s2, s3, 0, 0, 0, 0, 0, 0) +#define aa_strerr_warn4x(s1,s2,s3,s4) \ + aa_strerr_warn ("warning: ", s1, s2, s3, s4, 0, 0, 0, 0, 0) +#define aa_strerr_warn5x(s1,s2,s3,s4,s5) \ + aa_strerr_warn ("warning: ", s1, s2, s3, s4, s5, 0, 0, 0, 0) +#define aa_strerr_warn6x(s1,s2,s3,s4,s5,s6) \ + aa_strerr_warn ("warning: ", s1, s2, s3, s4, s5, s6, 0, 0, 0) + +#define aa_strerr_warnu1x(s1) \ + aa_strerr_warn ("warning: ", "unable to ", s1, 0, 0, 0, 0, 0, 0, 0) +#define aa_strerr_warnu2x(s1,s2) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, 0, 0, 0, 0, 0, 0) +#define aa_strerr_warnu3x(s1,s2,s3) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, s3, 0, 0, 0, 0, 0) +#define aa_strerr_warnu4x(s1,s2,s3,s4) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, s3, s4, 0, 0, 0, 0) +#define aa_strerr_warnu5x(s1,s2,s3,s4,s5) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, s3, s4, s5, 0, 0, 0) +#define aa_strerr_warnu6x(s1,s2,s3,s4,s5,s6) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, s3, s4, s5, s6, 0, 0) + +#define aa_strerr_warnu1sys(s1) \ + aa_strerr_warn ("warning: ", "unable to ", s1, ": ", error_str (errno), 0, 0, 0, 0, 0) +#define aa_strerr_warnu2sys(s1,s2) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, ": ", error_str (errno), 0, 0, 0, 0) +#define aa_strerr_warnu3sys(s1,s2,s3) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, s3, ": ", error_str (errno), 0, 0, 0) +#define aa_strerr_warnu4sys(s1,s2,s3,s4) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, s3, s4, ": ", error_str (errno), 0, 0) +#define aa_strerr_warnu5sys(s1,s2,s3,s4,s5) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, s3, s4, s5, ": ", error_str (errno), 0) +#define aa_strerr_warnu6sys(s1,s2,s3,s4,s5,s6) \ + aa_strerr_warn ("warning: ", "unable to ", s1, s2, s3, s4, s5, s6, ": ", error_str (errno)) + +extern void aa_strerr_die (int rc, + const char *s1, + const char *s2, + const char *s3, + const char *s4, + const char *s5, + const char *s6, + const char *s7, + const char *s8, + const char *s9); + +#define aa_strerr_diefu1sys(rc,s1) \ + aa_strerr_die (rc, "unable to ", s1, ": ", error_str (errno), 0, 0, 0, 0, 0) +#define aa_strerr_diefu2sys(rc,s1,s2) \ + aa_strerr_die (rc, "unable to ", s1, s2, ": ", error_str (errno), 0, 0, 0, 0) +#define aa_strerr_diefu3sys(rc,s1,s2,s3) \ + aa_strerr_die (rc, "unable to ", s1, s2, s3, ": ", error_str (errno), 0, 0, 0) +#define aa_strerr_diefu4sys(rc,s1,s2,s3,s4) \ + aa_strerr_die (rc, "unable to ", s1, s2, s3, s4, ": ", error_str (errno), 0, 0) +#define aa_strerr_diefu5sys(rc,s1,s2,s3,s4,s5) \ + aa_strerr_die (rc, "unable to ", s1, s2, s3, s4, s5, ": ", error_str (errno), 0) +#define aa_strerr_diefu6sys(rc,s1,s2,s3,s4,s5,s6) \ + aa_strerr_die (rc, "unable to ", s1, s2, s3, s4, s5, s6, ": ", error_str (errno)) + +#define aa_strerr_dief1x(rc,s1) \ + aa_strerr_die (rc, s1, 0, 0, 0, 0, 0, 0, 0, 0) +#define aa_strerr_dief2x(rc,s1,s2) \ + aa_strerr_die (rc, s1, s2, 0, 0, 0, 0, 0, 0, 0) +#define aa_strerr_dief3x(rc,s1,s2,s3) \ + aa_strerr_die (rc, s1, s2, s3, 0, 0, 0, 0, 0, 0) +#define aa_strerr_dief4x(rc,s1,s2,s3,s4) \ + aa_strerr_die (rc, s1, s2, s3, s4, 0, 0, 0, 0, 0) +#define aa_strerr_dief5x(rc,s1,s2,s3,s4,s5) \ + aa_strerr_die (rc, s1, s2, s3, s4, s5, 0, 0, 0, 0) +#define aa_strerr_dief6x(rc,s1,s2,s3,s4,s5,s6) \ + aa_strerr_die (rc, s1, s2, s3, s4, s5, s6, 0, 0, 0) + +#define aa_strerr_diefu1x(rc,s1) \ + aa_strerr_die (rc, "unable to ", s1, 0, 0, 0, 0, 0, 0, 0) +#define aa_strerr_diefu2x(rc,s1,s2) \ + aa_strerr_die (rc, "unable to ", s1, s2, 0, 0, 0, 0, 0, 0) +#define aa_strerr_diefu3x(rc,s1,s2,s3) \ + aa_strerr_die (rc, "unable to ", s1, s2, s3, 0, 0, 0, 0, 0) +#define aa_strerr_diefu4x(rc,s1,s2,s3,s4) \ + aa_strerr_die (rc, "unable to ", s1, s2, s3, s4, 0, 0, 0, 0) +#define aa_strerr_diefu5x(rc,s1,s2,s3,s4,s5) \ + aa_strerr_die (rc, "unable to ", s1, s2, s3, s4, s5, 0, 0, 0) +#define aa_strerr_diefu6x(rc,s1,s2,s3,s4,s5,s6) \ + aa_strerr_die (rc, "unable to ", s1, s2, s3, s4, s5, s6, 0, 0) + +#define aa_strerr_dieexec(rc,s) \ + aa_strerr_diefu2sys (rc, "exec ", s) + #endif /* AA_OUTPUT_H */ diff --git a/src/libanopa/exec_longrun.c b/src/libanopa/exec_longrun.c index 94e8b77..e426f35 100644 --- a/src/libanopa/exec_longrun.c +++ b/src/libanopa/exec_longrun.c @@ -25,11 +25,11 @@ #include <skalibs/bytestr.h> #include <skalibs/tai.h> #include <skalibs/error.h> -#include <skalibs/strerr2.h> #include <s6/s6-supervise.h> #include <s6/ftrigr.h> #include <anopa/service.h> #include <anopa/err.h> +#include <anopa/output.h> #include "service_internal.h" int @@ -63,7 +63,7 @@ _exec_longrun (int si, aa_mode mode) tain_copynow (&s->st.stamp); aa_service_status_set_msg (&s->st, "Failed to subscribe to eventdir"); if (aa_service_status_write (&s->st, aa_service_name (s)) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (s)); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (s)); if (_exec_cb) _exec_cb (si, s->st.event, 0); @@ -86,7 +86,7 @@ _exec_longrun (int si, aa_mode mode) tain_addsec (&s->st.stamp, &st6.stamp, -1); aa_service_status_set_msg (&s->st, ""); if (aa_service_status_write (&s->st, aa_service_name (s)) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (s)); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (s)); /* we still process it. Because we checked the service state (from s6) * before adding it to the "treansaction" (i.e. in @@ -151,7 +151,7 @@ _exec_longrun (int si, aa_mode mode) ? "Failed to send command" : "Supervisor not listenning"); if (aa_service_status_write (&s->st, aa_service_name (s)) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (s)); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (s)); if (_exec_cb) _exec_cb (si, s->st.event, 0); diff --git a/src/libanopa/exec_oneshot.c b/src/libanopa/exec_oneshot.c index 9c30b4f..a3ba683 100644 --- a/src/libanopa/exec_oneshot.c +++ b/src/libanopa/exec_oneshot.c @@ -32,9 +32,9 @@ #include <skalibs/tai.h> #include <skalibs/uint32.h> #include <skalibs/error.h> -#include <skalibs/strerr2.h> #include <anopa/service.h> #include <anopa/err.h> +#include <anopa/output.h> #include "service_internal.h" int @@ -75,7 +75,7 @@ _exec_oneshot (int si, aa_mode mode) s->st.event = (is_start) ? AA_EVT_STARTED : AA_EVT_STOPPED; tain_copynow (&s->st.stamp); if (aa_service_status_write (&s->st, aa_service_name (s)) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (s)); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (s)); if (_exec_cb) _exec_cb (si, s->st.event, 0); @@ -200,7 +200,7 @@ _exec_oneshot (int si, aa_mode mode) fd_write (p_int[1], "p", 1); uint32_pack (buf_e, e); fd_write (p_int[1], buf_e, UINT32_FMT); - strerr_diefu1sys (ERR_IO, "set up pipes"); + aa_strerr_diefu1sys (ERR_IO, "set up pipes"); } if (chdir (PROG) < 0) @@ -209,7 +209,7 @@ _exec_oneshot (int si, aa_mode mode) fd_write (p_int[1], "c", 1); uint32_pack (buf_e, e); fd_write (p_int[1], buf_e, UINT32_FMT); - strerr_diefu1sys (ERR_IO, "get into service directory"); + aa_strerr_diefu1sys (ERR_IO, "get into service directory"); } buf[l_sn - 1] = '.'; @@ -219,7 +219,7 @@ _exec_oneshot (int si, aa_mode mode) fd_write (p_int[1], "e", 1); uint32_pack (buf_e, e); fd_write (p_int[1], buf_e, UINT32_FMT); - strerr_dieexec (ERR_IO, filename); + aa_strerr_dieexec (ERR_IO, filename); } fd_close (p_int[1]); @@ -291,7 +291,7 @@ _exec_oneshot (int si, aa_mode mode) tain_copynow (&s->st.stamp); aa_service_status_set_msg (&s->st, msg); if (aa_service_status_write (&s->st, aa_service_name (s)) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (s)); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (s)); if (_exec_cb) _exec_cb (si, s->st.event, 0); @@ -332,7 +332,7 @@ err: aa_service_status_set_msg (&s->st, msg); } if (aa_service_status_write (&s->st, aa_service_name (s)) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (s)); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (s)); if (_exec_cb) _exec_cb (si, s->st.event, 0); diff --git a/src/libanopa/output.c b/src/libanopa/output.c index c25d59b..0c91ee0 100644 --- a/src/libanopa/output.c +++ b/src/libanopa/output.c @@ -135,3 +135,56 @@ aa_put_title (int main, const char *name, const char *title, int end) if (end) aa_end_title (); } + +void +aa_strerr_warn (const char *s1, + const char *s2, + const char *s3, + const char *s4, + const char *s5, + const char *s6, + const char *s7, + const char *s8, + const char *s9, + const char *s10) +{ + aa_bs_noflush (AA_ERR, PROG); + aa_bs_noflush (AA_ERR, ": "); + if (s1) + aa_bs_noflush (AA_ERR, s1); + if (s2) + aa_bs_noflush (AA_ERR, s2); + if (s3) + aa_bs_noflush (AA_ERR, s3); + if (s4) + aa_bs_noflush (AA_ERR, s4); + if (s5) + aa_bs_noflush (AA_ERR, s5); + if (s6) + aa_bs_noflush (AA_ERR, s6); + if (s7) + aa_bs_noflush (AA_ERR, s7); + if (s8) + aa_bs_noflush (AA_ERR, s8); + if (s9) + aa_bs_noflush (AA_ERR, s9); + if (s10) + aa_bs_noflush (AA_ERR, s10); + aa_bs_flush (AA_ERR, "\n"); +} + +void +aa_strerr_die (int rc, + const char *s1, + const char *s2, + const char *s3, + const char *s4, + const char *s5, + const char *s6, + const char *s7, + const char *s8, + const char *s9) +{ + aa_strerr_warn ("fatal: ", s1, s2, s3, s4, s5, s6, s7, s8, s9); + _exit (rc); +} diff --git a/src/libanopa/service.c b/src/libanopa/service.c index 5eb87d3..ea5441b 100644 --- a/src/libanopa/service.c +++ b/src/libanopa/service.c @@ -29,13 +29,13 @@ #include <skalibs/direntry.h> #include <skalibs/uint.h> #include <skalibs/tai.h> -#include <skalibs/strerr2.h> #include <s6/s6-supervise.h> #include <s6/ftrigr.h> #include <anopa/service.h> #include <anopa/ga_int_list.h> #include <anopa/scan_dir.h> #include <anopa/err.h> +#include <anopa/output.h> #include "service_internal.h" static aa_close_fd_fn close_fd; @@ -296,7 +296,7 @@ aa_ensure_service_loaded (int si, aa_mode mode, int no_wants, aa_load_fail_cb lf r = uint_scan (sa_to.s, &aa_service (si)->secs_timeout); if (!r || (sa_to.s[r] != '\n' && sa_to.s[r] != '\0')) { - strerr_warnwu3x ("read timeout for ", aa_service_name (aa_service (si)), "; using default"); + aa_strerr_warnu3x ("read timeout for ", aa_service_name (aa_service (si)), "; using default"); aa_service (si)->secs_timeout = aa_secs_timeout; } } @@ -533,7 +533,7 @@ aa_scan_mainlist (aa_scan_cb scan_cb, aa_mode mode) tain_copynow (&svst->stamp); aa_service_status_set_msg (svst,aa_service_name (aa_service (sni))); if (aa_service_status_write (svst, aa_service_name (s)) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (s)); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (s)); remove_from_list (&aa_main_list, si); diff --git a/src/libanopa/service_start.c b/src/libanopa/service_start.c index 9dfb726..4bac929 100644 --- a/src/libanopa/service_start.c +++ b/src/libanopa/service_start.c @@ -21,10 +21,10 @@ */ #include <skalibs/direntry.h> -#include <skalibs/strerr2.h> #include <anopa/service.h> #include <anopa/ga_int_list.h> #include <anopa/err.h> +#include <anopa/output.h> #include <anopa/service_status.h> #include "service_internal.h" @@ -111,7 +111,7 @@ _it_start_needs (direntry *d, void *data) aa_service_status_set_err (&s->st, ERR_DEPEND, buf); if (aa_service_status_write (&s->st, aa_service_name (s)) < 0) - strerr_warnwu2sys ("write service status file for ", aa_service_name (s)); + aa_strerr_warnu2sys ("write service status file for ", aa_service_name (s)); } if (it_data->lf_cb) diff --git a/src/utils/aa-chroot.c b/src/utils/aa-chroot.c index 9da3993..ac84ed3 100644 --- a/src/utils/aa-chroot.c +++ b/src/utils/aa-chroot.c @@ -25,8 +25,8 @@ #include <getopt.h> #include <unistd.h> #include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> #include <anopa/common.h> +#include <anopa/output.h> static void dieusage (int rc) @@ -73,11 +73,11 @@ main (int argc, char * const argv[], char * const envp[]) dieusage (1); if (chdir (argv[0]) < 0) - strerr_diefu2sys (2, "chdir to ", argv[0]); + aa_strerr_diefu2sys (2, "chdir to ", argv[0]); if (chroot (".") < 0) - strerr_diefu1sys (3, "chroot"); + aa_strerr_diefu1sys (3, "chroot"); if (chdir ("/") < 0) - strerr_diefu1sys (3, "chdir to new root"); + aa_strerr_diefu1sys (3, "chdir to new root"); pathexec_run (argv[1], (char const * const *) argv + 1, (char const * const *) envp); - strerr_dieexec (4, argv[1]); + aa_strerr_dieexec (4, argv[1]); } diff --git a/src/utils/aa-ctty.c b/src/utils/aa-ctty.c index 3a4c607..2ef7f14 100644 --- a/src/utils/aa-ctty.c +++ b/src/utils/aa-ctty.c @@ -25,8 +25,8 @@ #include <sys/ioctl.h> #include <skalibs/uint.h> #include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> #include <anopa/common.h> +#include <anopa/output.h> static void dieusage (int rc) @@ -64,7 +64,7 @@ main (int argc, char * const argv[], char const * const *envp) { case 'f': if (!uint0_scan (optarg, &fd)) - strerr_diefu1sys (1, "set fd"); + aa_strerr_diefu1sys (1, "set fd"); break; case 'h': @@ -88,8 +88,8 @@ main (int argc, char * const argv[], char const * const *envp) dieusage (1); if (ioctl (fd, TIOCSCTTY, steal) < 0) - strerr_warnwu1sys ("set controlling terminal"); + aa_strerr_warnu1sys ("set controlling terminal"); pathexec_run (argv[0], (char const * const *) argv, envp); - strerr_dieexec (111, argv[0]); + aa_strerr_dieexec (111, argv[0]); } diff --git a/src/utils/aa-echo.c b/src/utils/aa-echo.c index 25f8529..9fbbb6f 100644 --- a/src/utils/aa-echo.c +++ b/src/utils/aa-echo.c @@ -25,7 +25,6 @@ #include <anopa/common.h> #include <anopa/output.h> -char const *PROG; typedef void (*put_fn) (const char *name, const char *msg, int end); static void diff --git a/src/utils/aa-incmdline.c b/src/utils/aa-incmdline.c index 3e07e9b..ea007f4 100644 --- a/src/utils/aa-incmdline.c +++ b/src/utils/aa-incmdline.c @@ -25,10 +25,8 @@ #include <skalibs/stralloc.h> #include <skalibs/bytestr.h> #include <skalibs/buffer.h> -#include <skalibs/strerr2.h> #include <anopa/common.h> - -const char *PROG; +#include <anopa/output.h> static void dieusage (int rc) @@ -112,7 +110,7 @@ main (int argc, char * const argv[]) dieusage (1); if (!openslurpclose (&sa, file)) - strerr_diefu2sys (2, "read ", file); + aa_strerr_diefu2sys (2, "read ", file); len_arg = strlen (argv[0]); for (start = i = 0; i < sa.len; ++i) diff --git a/src/utils/aa-kill.c b/src/utils/aa-kill.c index 2e77fea..cc631d6 100644 --- a/src/utils/aa-kill.c +++ b/src/utils/aa-kill.c @@ -28,9 +28,9 @@ #include <skalibs/sig.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> #include <skalibs/uint.h> #include <anopa/common.h> +#include <anopa/output.h> #include <anopa/scan_dir.h> static struct { @@ -190,9 +190,9 @@ main (int argc, char * const argv[]) ownpid[uint_fmt (ownpid, u)] = '\0'; if (!stralloc_catb (&sa, "/proc", sizeof ("/proc"))) - strerr_diefu1sys (1, "stralloc_catb"); + aa_strerr_diefu1sys (1, "stralloc_catb"); if (aa_scan_dir (&sa, 0, it_kill, &sa) < 0) - strerr_diefu1sys (1, "scan /proc"); + aa_strerr_diefu1sys (1, "scan /proc"); stralloc_free (&sa); } else diff --git a/src/utils/aa-mount.c b/src/utils/aa-mount.c index 509c9fc..96c70dc 100644 --- a/src/utils/aa-mount.c +++ b/src/utils/aa-mount.c @@ -25,9 +25,9 @@ #include <sys/stat.h> #include <sys/types.h> #include <sys/mount.h> -#include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <anopa/common.h> +#include <anopa/output.h> #include "mount-constants.h" struct mnt_opt @@ -168,7 +168,7 @@ main (int argc, char * const argv[]) { case 'B': if (!add_option (&sa, &flags, "bind")) - strerr_diefu1sys (2, "build user options"); + aa_strerr_diefu1sys (2, "build user options"); break; case 'd': @@ -180,17 +180,17 @@ main (int argc, char * const argv[]) case 'M': if (!add_option (&sa, &flags, "move")) - strerr_diefu1sys (2, "build user options"); + aa_strerr_diefu1sys (2, "build user options"); break; case 'o': if (!add_option (&sa, &flags, optarg)) - strerr_diefu1sys (2, "build user options"); + aa_strerr_diefu1sys (2, "build user options"); break; case 'r': if (!add_option (&sa, &flags, "ro")) - strerr_diefu1sys (2, "build user options"); + aa_strerr_diefu1sys (2, "build user options"); break; case 't': @@ -202,7 +202,7 @@ main (int argc, char * const argv[]) case 'w': if (!add_option (&sa, &flags, "rw")) - strerr_diefu1sys (2, "build user options"); + aa_strerr_diefu1sys (2, "build user options"); break; default: @@ -216,11 +216,11 @@ main (int argc, char * const argv[]) dieusage (1); if (!stralloc_0 (&sa)) - strerr_diefu1sys (2, "build user options"); + aa_strerr_diefu1sys (2, "build user options"); if (mk && mkdir (argv[1], 0755) < 0 && errno != EEXIST) - strerr_diefu4sys (2, "mkdir ", argv[1], " to mount ", argv[0]); + aa_strerr_diefu4sys (2, "mkdir ", argv[1], " to mount ", argv[0]); if (mount (argv[0], argv[1], fstype, flags, sa.s) < 0) - strerr_diefu4sys (3, "mount ", argv[0], " on ", argv[1]); + aa_strerr_diefu4sys (3, "mount ", argv[0], " on ", argv[1]); return 0; } diff --git a/src/utils/aa-mvlog.c b/src/utils/aa-mvlog.c index 66504fd..e6800fb 100644 --- a/src/utils/aa-mvlog.c +++ b/src/utils/aa-mvlog.c @@ -24,12 +24,10 @@ #include <unistd.h> #include <skalibs/djbunix.h> #include <skalibs/bytestr.h> -#include <skalibs/strerr2.h> #include <anopa/common.h> +#include <anopa/output.h> #include <anopa/copy_file.h> -const char *PROG; - static void dieusage (int rc) { @@ -56,9 +54,9 @@ main (int argc, char * const argv[]) dieusage (1); if (stat (argv[1], &st) < 0) - strerr_diefu2sys (2, "stat ", argv[1]); + aa_strerr_diefu2sys (2, "stat ", argv[1]); else if (!S_ISREG (st.st_mode)) - strerr_dief2x (2, argv[1], ": not a file"); + aa_strerr_dief2x (2, argv[1], ": not a file"); { int l = strlen (argv[2]); @@ -68,23 +66,23 @@ main (int argc, char * const argv[]) byte_copy (newname, l, argv[2]); newname[l] = '/'; if (openreadnclose (argv[1], newname + l + 1, 25) != 25) - strerr_diefu2sys (2, "read new name from ", argv[1]); + aa_strerr_diefu2sys (2, "read new name from ", argv[1]); if (newname[l + 1] != '@' || byte_chr (newname + l + 1, 25, '/') < 25 || byte_chr (newname + l + 1, 25, '\0') < 25) - strerr_dief2x (2, "invalid new name read from ", argv[1]); + aa_strerr_dief2x (2, "invalid new name read from ", argv[1]); newname[l + 26] = '\0'; if (aa_copy_file (argv[1], newname, st.st_mode, AA_CP_CREATE) < 0) - strerr_diefu4sys (2, "copy ", argv[1], " as ", newname); + aa_strerr_diefu4sys (2, "copy ", argv[1], " as ", newname); byte_copy (target, 26, newname + l + 1); byte_copy (newname + l + 1, 8, "current"); unlink (newname); if (symlink (target, newname) < 0) - strerr_warnwu2sys ("create symlink ", newname); + aa_strerr_warnu2sys ("create symlink ", newname); if (unlink (argv[1]) < 0) - strerr_warnwu2sys ("remove source file ", argv[1]); + aa_strerr_warnu2sys ("remove source file ", argv[1]); } return 0; diff --git a/src/utils/aa-pivot.c b/src/utils/aa-pivot.c index c4f983d..26b8e69 100644 --- a/src/utils/aa-pivot.c +++ b/src/utils/aa-pivot.c @@ -21,8 +21,8 @@ */ #include <getopt.h> -#include <skalibs/strerr2.h> #include <anopa/common.h> +#include <anopa/output.h> #ifndef NULL #define NULL (void *) 0 @@ -75,6 +75,6 @@ main (int argc, char * const argv[]) dieusage (1); if (pivot_root (argv[0], argv[1]) < 0) - strerr_diefu2sys (2, "pivot into ", argv[0]); + aa_strerr_diefu2sys (2, "pivot into ", argv[0]); return 0; } diff --git a/src/utils/aa-reboot.c b/src/utils/aa-reboot.c index 6c7ad8a..533882a 100644 --- a/src/utils/aa-reboot.c +++ b/src/utils/aa-reboot.c @@ -23,10 +23,8 @@ #include <getopt.h> #include <unistd.h> #include <sys/reboot.h> -#include <skalibs/strerr2.h> #include <anopa/common.h> - -const char *PROG; +#include <anopa/output.h> static void dieusage (int rc) @@ -101,7 +99,7 @@ main (int argc, char * const argv[]) dieusage (1); if (reboot (cmd[i].cmd) < 0) - strerr_diefu2sys (2, cmd[i].desc, " the machine"); + aa_strerr_diefu2sys (2, cmd[i].desc, " the machine"); /* unlikely :p */ return 0; diff --git a/src/utils/aa-service.c b/src/utils/aa-service.c index a5f370f..577aa31 100644 --- a/src/utils/aa-service.c +++ b/src/utils/aa-service.c @@ -25,11 +25,11 @@ #include <skalibs/env.h> #include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> #include <skalibs/genalloc.h> #include <skalibs/stralloc.h> #include <execline/execline.h> #include <anopa/common.h> +#include <anopa/output.h> typedef struct exlsn_s exlsn_t; struct exlsn_s @@ -197,29 +197,29 @@ main (int argc, char const **argv, char const *const *envp) switch (-r) { case ERR_NOT_LOG: - strerr_dief1x (2, "option --log used while not in a subfolder 'log'"); + aa_strerr_dief1x (2, "option --log used while not in a subfolder 'log'"); case ERR_DIRNAME: - strerr_diefu1x (3, "get current dirname"); + aa_strerr_diefu1x (3, "get current dirname"); case ERR_BAD_KEY: - strerr_dief1x (4, "bad substitution key"); + aa_strerr_dief1x (4, "bad substitution key"); case ERR_ADDVAR: - strerr_diefu1sys (5, "complete addvar function"); + aa_strerr_diefu1sys (5, "complete addvar function"); default: - strerr_diefu2x (5, "complete addvar function", ": unknown error"); + aa_strerr_diefu2x (5, "complete addvar function", ": unknown error"); } if (!env_string (&sa, argv, (unsigned int) argc)) - strerr_diefu1sys (5, "env_string"); + aa_strerr_diefu1sys (5, "env_string"); r = el_substitute (&dst, sa.s, sa.len, info.vars.s, info.values.s, genalloc_s (elsubst_t const, &info.data), genalloc_len (elsubst_t const, &info.data)); if (r < 0) - strerr_diefu1sys (5, "el_substitute"); + aa_strerr_diefu1sys (5, "el_substitute"); else if (r == 0) _exit (0); @@ -229,10 +229,10 @@ main (int argc, char const **argv, char const *const *envp) char const *v[r + 1]; if (!env_make (v, r, dst.s, dst.len)) - strerr_diefu1sys (5, "env_make"); + aa_strerr_diefu1sys (5, "env_make"); v[r] = 0; pathexec_r (v, envp, env_len (envp), info.modifs.s, info.modifs.len); } - strerr_dieexec (6, dst.s); + aa_strerr_dieexec (6, dst.s); } diff --git a/src/utils/aa-setready.c b/src/utils/aa-setready.c index ea2ab43..aa91424 100644 --- a/src/utils/aa-setready.c +++ b/src/utils/aa-setready.c @@ -23,13 +23,11 @@ #include <getopt.h> #include <errno.h> #include <unistd.h> -#include <skalibs/strerr2.h> #include <skalibs/djbunix.h> #include <s6/ftrigw.h> #include <s6/s6-supervise.h> #include <anopa/common.h> - -extern char const *PROG; +#include <anopa/output.h> static void dieusage (int rc) @@ -108,26 +106,26 @@ main (int argc, char * const argv[]) char data[TAIN_PACK]; if (!tain_now_g()) - strerr_diefu1sys (2, "tain_now"); + aa_strerr_diefu1sys (2, "tain_now"); tain_pack (data, &STAMP); if (!openwritenclose_suffix (readyfile, data, TAIN_PACK, ".new")) { r = 3; - strerr_warnwu2sys ("create ", readyfile); + aa_strerr_warnu2sys ("create ", readyfile); } } else if (unlink (readyfile) < 0 && errno != ENOENT) { r = 4; - strerr_warnwu2sys ("remove ", readyfile); + aa_strerr_warnu2sys ("remove ", readyfile); } if (ftrigw_notify (fifodir, (ready) ? 'U' : 'D') < 0) { r += 10; - strerr_warnwu4sys ("send event ", (ready) ? "U": "D" , " via ", fifodir); + aa_strerr_warnu4sys ("send event ", (ready) ? "U": "D" , " via ", fifodir); } } diff --git a/src/utils/aa-terminate.c b/src/utils/aa-terminate.c index 45bb1c8..79956ae 100644 --- a/src/utils/aa-terminate.c +++ b/src/utils/aa-terminate.c @@ -35,14 +35,11 @@ #include <linux/loop.h> #include <skalibs/djbunix.h> #include <skalibs/stralloc.h> -#include <skalibs/strerr2.h> #include <skalibs/error.h> #include <anopa/common.h> #include <anopa/scan_dir.h> #include <anopa/output.h> -const char *PROG; - typedef int (*do_fn) (const char *path); static int umnt_flags = 0; static int level = 1; @@ -200,7 +197,7 @@ it_loops_dms (direntry *d, void *data) l = sas[i]->len; if (!stralloc_cats (sas[i], "/dev/") || !stralloc_cats (sas[i], d->d_name) || !stralloc_0 (sas[i])) - strerr_diefu1sys (2, "stralloc_catb"); + aa_strerr_diefu1sys (2, "stralloc_catb"); /* /dev/loop* always exists, let's find the actual ones */ if (i == 0) @@ -346,7 +343,7 @@ again: /* read swaps */ if (!openslurpclose (&sa, "/proc/swaps")) - strerr_diefu1sys (2, "read /proc/swaps"); + aa_strerr_diefu1sys (2, "read /proc/swaps"); if (sa.len > 0) { @@ -363,7 +360,7 @@ again: { if (!stralloc_catb (&sa_swaps, sa.s + l, e) || !stralloc_0 (&sa_swaps)) - strerr_diefu1sys (2, "stralloc_catb"); + aa_strerr_diefu1sys (2, "stralloc_catb"); } l += byte_chr (sa.s + l, sa.len - l, '\n') + 1; } @@ -378,7 +375,7 @@ again: mounts = setmntent ("/proc/mounts", "r"); if (!mounts) - strerr_diefu1sys (2, "read /proc/mounts"); + aa_strerr_diefu1sys (2, "read /proc/mounts"); while ((mnt = getmntent (mounts))) { @@ -390,7 +387,7 @@ again: continue; if (!stralloc_catb (&sa_mounts, mnt->mnt_dir, strlen (mnt->mnt_dir) + 1)) - strerr_diefu1sys (2, "stralloc_catb"); + aa_strerr_diefu1sys (2, "stralloc_catb"); } endmntent (mounts); } @@ -404,7 +401,7 @@ again: stralloc_catb (&sa, "/dev", 5); r = aa_scan_dir (&sa, 2, it_loops_dms, &sas); if (r < 0) - strerr_diefu1sys (2, "scan /dev"); + aa_strerr_diefu1sys (2, "scan /dev"); sa.len = 0; } diff --git a/src/utils/aa-test.c b/src/utils/aa-test.c index 515fa15..c4ffd1b 100644 --- a/src/utils/aa-test.c +++ b/src/utils/aa-test.c @@ -25,8 +25,8 @@ #include <unistd.h> #include <sys/stat.h> #include <skalibs/uint.h> -#include <skalibs/strerr2.h> #include <anopa/common.h> +#include <anopa/output.h> static int is_group_member (gid_t gid) @@ -122,7 +122,7 @@ main (int argc, char * const argv[]) case 'R': if (optarg && !uint0_scan (optarg, &repeat)) - strerr_diefu2sys (1, "set repeat counter to ", optarg); + aa_strerr_diefu2sys (1, "set repeat counter to ", optarg); else if (!optarg) repeat = 0; break; @@ -147,7 +147,7 @@ again: if (lstat (argv[0], &st) < 0) { if (errno != ENOENT) - strerr_diefu2sys (2, "stat ", argv[0]); + aa_strerr_diefu2sys (2, "stat ", argv[0]); else if (repeat >= 0) { if (repeat > 1) diff --git a/src/utils/aa-tty.c b/src/utils/aa-tty.c index e2975b3..0d26885 100644 --- a/src/utils/aa-tty.c +++ b/src/utils/aa-tty.c @@ -23,7 +23,6 @@ #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> #include <anopa/output.h> #include <anopa/common.h> @@ -65,7 +64,7 @@ main (int argc, char * const argv[]) byte_copy (file + sizeof (PREFIX) + 6, sizeof (NAME), NAME); r = openreadnclose (file, name, max); if (r <= 0) - strerr_diefu2sys (2, "read ", file); + aa_strerr_diefu2sys (2, "read ", file); for (;;) { @@ -81,7 +80,7 @@ main (int argc, char * const argv[]) return 0; } else - strerr_diefu2sys (2, "read ", file); + aa_strerr_diefu2sys (2, "read ", file); } } } diff --git a/src/utils/aa-umount.c b/src/utils/aa-umount.c index 95deb32..a7548c6 100644 --- a/src/utils/aa-umount.c +++ b/src/utils/aa-umount.c @@ -22,8 +22,8 @@ #include <getopt.h> #include <sys/mount.h> -#include <skalibs/strerr2.h> #include <anopa/common.h> +#include <anopa/output.h> #ifndef NULL #define NULL (void *) 0 @@ -87,7 +87,7 @@ main (int argc, char * const argv[]) dieusage (1); if (umount2 (argv[0], flags) < 0) - strerr_diefu2sys (3, "unmount ", argv[0]); + aa_strerr_diefu2sys (3, "unmount ", argv[0]); return 0; }