From b7a60c5bed989a52a53b8b697203f55367f55a89 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 11 May 2026 15:24:53 -0400 Subject: Replace msg, perror, and fprintf with SYS message macros --- src/cli/stasis/stasis_main.c | 104 +++++++++++++-------------- src/cli/stasis/system_requirements.c | 6 +- src/cli/stasis_indexer/helpers.c | 8 +-- src/cli/stasis_indexer/junitxml_report.c | 6 +- src/cli/stasis_indexer/readmes.c | 2 +- src/cli/stasis_indexer/stasis_indexer_main.c | 20 +++--- src/cli/stasis_indexer/website.c | 6 +- 7 files changed, 74 insertions(+), 78 deletions(-) (limited to 'src/cli') diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c index 8a222c1..b902a8a 100644 --- a/src/cli/stasis/stasis_main.c +++ b/src/cli/stasis/stasis_main.c @@ -25,7 +25,7 @@ static void setup_sysconfdir() { globals.sysconfdir = realpath(stasis_sysconfdir_tmp, NULL); if (!globals.sysconfdir) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "Unable to resolve path to configuration directory: %s\n", stasis_sysconfdir_tmp); + SYSERROR("Unable to resolve path to configuration directory: %s", stasis_sysconfdir_tmp); exit(1); } } @@ -57,15 +57,14 @@ static void configure_stasis_ini(struct Delivery *ctx, char **config_input) { if (!access(cfgfile, F_OK | R_OK)) { *config_input = strdup(cfgfile); } else { - msg(STASIS_MSG_WARN, "STASIS global configuration is not readable, or does not exist: %s", cfgfile); + SYSWARN("STASIS global configuration is not readable, or does not exist: %s", cfgfile); } } SYSDEBUG("Reading STASIS global configuration: %s", *config_input); ctx->_stasis_ini_fp.cfg = ini_open(*config_input); if (!ctx->_stasis_ini_fp.cfg) { - msg(STASIS_MSG_ERROR, "Failed to read global config file: %s, %s\n", *config_input, strerror(errno)); - SYSERROR("Failed to read global config file: %s", *config_input); + SYSERROR("Failed to read global config file: %s, %s", *config_input, strerror(errno)); exit(1); } ctx->_stasis_ini_fp.cfg_path = strdup(*config_input); @@ -80,7 +79,7 @@ static void configure_delivery_ini(struct Delivery *ctx, char **delivery_input) msg(STASIS_MSG_L2, "Reading STASIS delivery configuration: %s\n", *delivery_input); ctx->_stasis_ini_fp.delivery = ini_open(*delivery_input); if (!ctx->_stasis_ini_fp.delivery) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to read delivery file: %s, %s\n", *delivery_input, strerror(errno)); + SYSERROR("Failed to read delivery file: %s, %s", *delivery_input, strerror(errno)); exit(1); } ctx->_stasis_ini_fp.delivery_path = strdup(*delivery_input); @@ -89,13 +88,13 @@ static void configure_delivery_ini(struct Delivery *ctx, char **delivery_input) static void configure_delivery_context(struct Delivery *ctx) { msg(STASIS_MSG_L2, "Bootstrapping delivery context\n"); if (bootstrap_build_info(ctx)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to bootstrap delivery context\n"); + SYSERROR("Failed to bootstrap delivery context"); exit(1); } msg(STASIS_MSG_L2, "Initializing delivery context\n"); if (delivery_init(ctx, INI_READ_RENDER)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to initialize delivery context\n"); + SYSERROR("Failed to initialize delivery context"); exit(1); } } @@ -103,7 +102,7 @@ static void configure_delivery_context(struct Delivery *ctx) { static void configure_jfrog_cli(struct Delivery *ctx) { msg(STASIS_MSG_L2, "Configuring JFrog CLI\n"); if (delivery_init_artifactory(ctx)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "JFrog CLI configuration failed\n"); + SYSERROR("JFrog CLI configuration failed"); exit(1); } } @@ -112,7 +111,7 @@ static void check_release_history(struct Delivery *ctx) { // Safety gate: Avoid clobbering a delivered release unless the user wants that behavior msg(STASIS_MSG_L2, "Checking release history\n"); if (!globals.enable_overwrite && delivery_exists(ctx) == DELIVERY_FOUND) { - msg(STASIS_MSG_ERROR, "Refusing to overwrite release: %s\nUse --overwrite to enable release clobbering.\n", ctx->info.release_name); + SYSERROR("Refusing to overwrite release: %s\nUse --overwrite to enable release clobbering.", ctx->info.release_name); exit(1); } @@ -123,7 +122,7 @@ static void check_conda_install_prefix(const struct Delivery *ctx) { // if path is "/" then, die // or if empty string, die if (!strcmp(ctx->storage.conda_install_prefix, DIR_SEP) || !strlen(ctx->storage.conda_install_prefix)) { - fprintf(stderr, "error: ctx.storage.conda_install_prefix is malformed!\n"); + SYSERROR("error: ctx.storage.conda_install_prefix is malformed!"); exit(1); } } @@ -135,14 +134,14 @@ static void sync_release_history(struct Delivery *ctx) { if (ctx->meta.rc > 1) { msg(STASIS_MSG_L1, "Syncing delivery artifacts for %s\n", ctx->info.build_name); if (delivery_series_sync(ctx) != 0) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Unable to sync artifacts for %s\n", ctx->info.build_name); - msg(STASIS_MSG_L3, "Case #1:\n" - "\tIf this is a new 'version', and 'rc' is greater " - "than 1, then no previous deliveries exist remotely. " - "Reset 'rc' to 1.\n"); - msg(STASIS_MSG_L3, "Case #2:\n" - "\tThe Artifactory server %s is unreachable, or the credentials used " - "are invalid.\n", globals.jfrog.url); + SYSERROR("Unable to sync artifacts for %s", ctx->info.build_name); + SYSERROR("Case #1:\n" + "\tIf this is a new 'version', and 'rc' is greater " + "than 1, then no previous deliveries exist remotely. " + "Reset 'rc' to 1."); + SYSERROR("Case #2:\n" + "\tThe Artifactory server %s is unreachable, or the credentials used " + "are invalid.", globals.jfrog.url); // No continue-on-error check. Without the previous delivery nothing can be done. exit(1); } @@ -157,13 +156,10 @@ static void check_conda_prefix_length(const struct Delivery *ctx) { const size_t prefix_len_max = 127; msg(STASIS_MSG_L2, "Checking length of conda installation prefix\n"); if (!strcmp(ctx->system.platform[DELIVERY_PLATFORM], "Linux") && prefix_len > prefix_len_max) { - msg(STASIS_MSG_L3 | STASIS_MSG_ERROR, - "The shebang, '#!%s/bin/python\\n' is too long (%zu > %zu).\n", + SYSERROR("The shebang, '#!%s/bin/python\\n' is too long (%zu > %zu).", ctx->storage.conda_install_prefix, prefix_len, prefix_len_max); - msg(STASIS_MSG_L3 | STASIS_MSG_ERROR, - "Conda's workaround to handle long path names does not work consistently within STASIS.\n"); - msg(STASIS_MSG_L3 | STASIS_MSG_ERROR, - "Please try again from a different, \"shorter\", directory.\n"); + SYSERROR("Conda's workaround to handle long path names does not work consistently within STASIS."); + SYSERROR("Please try again from a different, \"shorter\", directory."); exit(1); } } @@ -173,7 +169,7 @@ static void setup_conda(struct Delivery *ctx, char *installer_url, const size_t delivery_get_conda_installer_url(ctx, installer_url, maxlen); msg(STASIS_MSG_L2, "Downloading: %s\n", installer_url); if (delivery_get_conda_installer(ctx, installer_url)) { - msg(STASIS_MSG_ERROR, "download failed: %s\n", installer_url); + SYSERROR("download failed: %s", installer_url); exit(1); } @@ -217,7 +213,7 @@ static void configure_conda_base(struct Delivery *ctx, char *envs[]) { // Does a base.yml exist in the mission directory? // If not, do nothing. Otherwise, use the base.yml in the mission directory. if (access(mission_base_orig, F_OK) < 0) { - msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "Mission does not provide a base.yml"); + SYSWARN("Mission does not provide a base.yml"); } else { msg(STASIS_MSG_L2, "Using base environment configuration: %s\n", mission_base_orig); if (asprintf(&mission_base, "%s/%s-base.yml", ctx->storage.tmpdir, ctx->info.release_name) < 0) { @@ -239,18 +235,18 @@ static void configure_conda_base(struct Delivery *ctx, char *envs[]) { // If based_on was populated above, or defined in the configuration: install its packages. if (!isempty(ctx->meta.based_on)) { if (conda_env_exists(ctx->storage.conda_install_prefix, env) && conda_env_remove(env)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to remove %s environment: %s\n", title); + SYSERROR("failed to remove %s environment: %s", title); exit(1); } if (conda_env_create_from_uri(env, ctx->meta.based_on, ctx->meta.python)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "unable to install %s environment using configuration file\n", title); + SYSERROR("unable to install %s environment using configuration file", title); exit(1); } } else { // Otherwise, create the environments with the requested Python version and move on if (conda_env_create(env, ctx->meta.python, NULL)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to create %s environment\n", title); + SYSERROR("failed to create %s environment", title); exit(1); } } @@ -282,7 +278,7 @@ static void configure_conda_purge(struct Delivery *ctx, char *envs[]) { const int manager_flag = pkg_manager_use[i]; msg(STASIS_MSG_L2, "Purging %s packages from %s\n", manager_str, env); if (delivery_purge_packages(ctx, env, manager_flag)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "unable to purge requested %s packages from %s\n", manager_str, env); + SYSERROR("unable to purge requested %s packages from %s", manager_str, env); exit(1); } } @@ -294,7 +290,7 @@ static void setup_activate_test_env(const struct Delivery *ctx, const char *env_ // Activate test environment msg(STASIS_MSG_L1, "Activating test environment\n"); if (conda_activate(ctx->storage.conda_install_prefix, env_name_testing)) { - fprintf(stderr, "failed to activate test environment\n"); + SYSERROR("failed to activate test environment"); exit(1); } } @@ -302,11 +298,11 @@ static void setup_activate_test_env(const struct Delivery *ctx, const char *env_ static void configure_tool_versions(struct Delivery *ctx) { if (delivery_gather_tool_versions(ctx)) { if (!ctx->conda.tool_version) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda version\n"); + SYSERROR("Could not determine conda version"); exit(1); } if (!ctx->conda.tool_build_version) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda-build version\n"); + SYSERROR("Could not determine conda-build version"); exit(1); } } @@ -315,11 +311,11 @@ static void configure_tool_versions(struct Delivery *ctx) { static void install_packaging_tools() { msg(STASIS_MSG_L1, "Installing packaging tool(s)\n"); if (pip_exec("install build")) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "'build' tool installation failed\n"); + SYSERROR("'build' tool installation failed"); exit(1); } if (pip_exec("install cibuildwheel")) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "'cibuildwheel' tool installation failed\n"); + SYSERROR("'cibuildwheel' tool installation failed"); exit(1); } } @@ -331,12 +327,12 @@ static void force_conda_package_reinstallation_on_mismatch(struct Delivery *ctx, for (size_t i = 0; i < conda_package_count; i++) { const char *item = strlist_item(ctx->conda.conda_packages, i); if (!item) { - msg(STASIS_MSG_L2 | STASIS_MSG_ERROR, "NULL record in conda package list\n"); + SYSERROR("NULL record in conda package list"); exit(1); } char *pkg_name = strdup(item); if (!pkg_name) { - msg(STASIS_MSG_L2 | STASIS_MSG_ERROR, "unable to allocate memory for package name\n"); + SYSERROR("unable to allocate memory for package name"); exit(1); } const char *spec = find_version_spec(pkg_name); @@ -346,7 +342,7 @@ static void force_conda_package_reinstallation_on_mismatch(struct Delivery *ctx, msg(STASIS_MSG_L2, "%s\n", pkg_name); if (delivery_conda_enforce_package_version(ctx, env_name, pkg_name)) { - msg(STASIS_MSG_L3 | STASIS_MSG_ERROR, "Failed to determine conda package version: %s\n", pkg_name); + SYSERROR("Failed to determine conda package version: %s", pkg_name); guard_free(pkg_name); exit(1); } @@ -359,7 +355,7 @@ static void configure_package_overlay(struct Delivery *ctx, const char *env_name if (!isempty(ctx->meta.based_on)) { msg(STASIS_MSG_L1, "Generating package overlay from environment: %s\n", env_name); if (delivery_overlay_packages_from_env(ctx, env_name)) { - msg(STASIS_MSG_L2 | STASIS_MSG_ERROR, "%s", "Failed to generate package overlay. Resulting environment integrity cannot be guaranteed.\n"); + SYSERROR("Failed to generate package overlay. Resulting environment integrity cannot be guaranteed."); exit(1); } } @@ -390,7 +386,7 @@ static void run_tests(struct Delivery *ctx) { msg(STASIS_MSG_L2, "Rewriting test results\n"); delivery_fixup_test_results(ctx); } else { - msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Test execution is disabled\n"); + SYSWARN("Test execution is disabled"); } } @@ -465,7 +461,7 @@ static void build_docker(struct Delivery *ctx, const int disabled) { if (want_docker) { if (disabled) { - msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Docker image building is disabled by CLI argument\n"); + SYSWARN("Docker image building is disabled by CLI argument"); } else { char dockerfile[PATH_MAX] = {0}; snprintf(dockerfile, sizeof(dockerfile), "%s/%s", ctx->storage.build_docker_dir, "Dockerfile"); @@ -473,18 +469,18 @@ static void build_docker(struct Delivery *ctx, const int disabled) { if (!access(dockerfile, F_OK)) { msg(STASIS_MSG_L1, "Building Docker image\n"); if (delivery_docker(ctx)) { - msg(STASIS_MSG_L1 | STASIS_MSG_ERROR, "Failed to build docker image!\n"); + SYSERROR("Failed to build docker image!"); COE_CHECK_ABORT(1, "Failed to build docker image"); } } else { - msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Docker image building is disabled. No Dockerfile found in %s\n", ctx->storage.build_docker_dir); + SYSWARN("Docker image building is disabled. No Dockerfile found in %s", ctx->storage.build_docker_dir); } } else { - msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Docker image building is disabled. System configuration error\n"); + SYSWARN("Docker image building is disabled. System configuration error"); } } } else { - msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Docker image building is disabled. deploy:docker is not configured\n"); + SYSWARN("Docker image building is disabled. deploy:docker is not configured"); } } @@ -508,7 +504,7 @@ static void generate_release(struct Delivery *ctx, char *env_name, char *env_nam msg(STASIS_MSG_L1, "Dumping metadata\n"); if (delivery_dump_metadata(ctx)) { - msg(STASIS_MSG_L1 | STASIS_MSG_ERROR, "Metadata dump failed\n"); + SYSERROR("Metadata dump failed"); } } @@ -519,10 +515,10 @@ static void transfer_artifacts(struct Delivery *ctx) { msg(STASIS_MSG_L1, "Uploading artifacts\n"); delivery_artifact_upload(ctx); } else { - msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Artifactory upload is disabled by CLI argument\n"); + SYSWARN("Artifactory upload is disabled by CLI argument"); } } else { - msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Artifactory upload is disabled. deploy:artifactory is not configured\n"); + SYSWARN("Artifactory upload is disabled. deploy:artifactory is not configured"); } } @@ -625,11 +621,11 @@ int main(int argc, char *argv[]) { case OPT_TASK_TIMEOUT: globals.task_timeout = str_to_timeout(optarg); if (globals.task_timeout < 0) { - fprintf(stderr, "Invalid timeout: %s\n", optarg); + SYSERROR("Invalid timeout: %s", optarg); if (globals.task_timeout == STR_TO_TIMEOUT_INVALID_TIME_SCALE) { - fprintf(stderr, "Use format '#s' (seconds), '#m' (minutes), '#h' (hours)\n"); + SYSERROR("Use format '#s' (seconds), '#m' (minutes), '#h' (hours)"); } else if (globals.task_timeout == STR_TO_TIMEOUT_NEGATIVE) { - fprintf(stderr, "Timeout cannot be negative\n"); + SYSERROR("Timeout cannot be negative"); } exit(1); } @@ -640,8 +636,8 @@ int main(int argc, char *argv[]) { globals.pool_status_interval = 1; } else if (globals.pool_status_interval > 60 * 10) { // Possible poor choice alert - fprintf(stderr, "Caution: Excessive pausing between status updates may cause third-party CI/CD" - " jobs to fail if the stdout/stderr streams are idle for too long!\n"); + SYSWARN("Excessive pausing between status updates may cause third-party CI/CD" + " jobs to fail if the stdout/stderr streams are idle for too long!"); } break; case 'U': @@ -705,7 +701,7 @@ int main(int argc, char *argv[]) { } if (!delivery_input) { - fprintf(stderr, "error: a DELIVERY_FILE is required\n"); + SYSERROR("a DELIVERY_FILE is required"); usage(path_basename(argv[0])); exit(1); } diff --git a/src/cli/stasis/system_requirements.c b/src/cli/stasis/system_requirements.c index ebfbffc..02889da 100644 --- a/src/cli/stasis/system_requirements.c +++ b/src/cli/stasis/system_requirements.c @@ -32,7 +32,7 @@ void check_system_requirements(struct Delivery *ctx) { for (size_t i = 0; tools_required[i] != NULL; i++) { msg(STASIS_MSG_L3, "%s: ", tools_required[i]); if (!find_program(tools_required[i])) { - msg(STASIS_MSG_ERROR, "'%s' must be installed.\n", tools_required[i]); + SYSERROR("'%s' must be installed.", tools_required[i]); exit(1); } msg(STASIS_MSG_RESTRICT, "found\n"); @@ -62,7 +62,7 @@ void check_system_requirements(struct Delivery *ctx) { globals.enable_docker = false; } } else { - msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "Docker is broken\n"); + SYSWARN("Docker is broken"); // disable docker builds globals.enable_docker = false; } @@ -77,7 +77,7 @@ void check_system_path() { char *pathvar = NULL; pathvar = getenv("PATH"); if (!pathvar) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "PATH variable is not set. Cannot continue.\n"); + SYSERROR("PATH variable is not set. Cannot continue."); exit(1); } } \ No newline at end of file diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index 1bb5862..097b0ca 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -89,7 +89,7 @@ int get_pandoc_version(size_t *result) { int pandoc_exec(const char *in_file, const char *out_file, const char *css_file, const char *title) { if (!find_program("pandoc")) { - fprintf(stderr, "pandoc is not installed: unable to generate HTML indexes\n"); + SYSWARN("pandoc is not installed: unable to generate HTML indexes"); return 0; } @@ -227,7 +227,7 @@ struct Delivery **get_latest_deliveries(struct Delivery **ctx, size_t nelem, siz struct Delivery **result = calloc(nelem + 1, sizeof(*result)); if (!result) { - fprintf(stderr, "Unable to allocate %zu bytes for result delivery array: %s\n", nelem * sizeof(*result), strerror(errno)); + SYSERROR("Unable to allocate %zu bytes for result delivery array: %s", nelem * sizeof(*result), strerror(errno)); return NULL; } @@ -287,7 +287,7 @@ int get_files(struct StrList **out, const char *path, const char *pattern, ...) } } if (no_match >= strlist_count(list)) { - fprintf(stderr, "no files matching the pattern: %s\n", userpattern); + SYSERROR("no files matching the pattern: %s", userpattern); guard_strlist_free(&list); return -1; } @@ -392,7 +392,7 @@ int write_manifest(const char *path, char **exclude_path, FILE *fp) { struct dirent *rec = NULL; DIR *dp = opendir(path); if (!dp) { - perror(path); + SYSERROR("unable to open directory: %s, %s", path ? path : "NULL", strerror(errno)); return -1; } while ((rec = readdir(dp)) != NULL) { diff --git a/src/cli/stasis_indexer/junitxml_report.c b/src/cli/stasis_indexer/junitxml_report.c index b767179..073bb61 100644 --- a/src/cli/stasis_indexer/junitxml_report.c +++ b/src/cli/stasis_indexer/junitxml_report.c @@ -98,7 +98,7 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x junitxml_testsuite_free(&testsuite); fclose(resultfp); } else { - fprintf(stderr, "bad test suite: %s: %s\n", strerror(errno), xmlfilename); + SYSWARN("bad test suite: %s: %s", strerror(errno), xmlfilename); } return 0; } @@ -116,7 +116,7 @@ int indexer_junitxml_report(struct Delivery **ctx, const size_t nelem) { if (!pushd((*ctx)->storage.results_dir)) { FILE *indexfp = fopen(indexfile, "w+"); if (!indexfp) { - fprintf(stderr, "Unable to open %s for writing\n", indexfile); + SYSERROR("Unable to open %s for writing", indexfile); return -1; } printf("Index %s opened for writing\n", indexfile); @@ -157,7 +157,7 @@ int indexer_junitxml_report(struct Delivery **ctx, const size_t nelem) { fclose(indexfp); popd(); } else { - fprintf(stderr, "Unable to enter delivery directory: %s\n", (*ctx)->storage.delivery_dir); + SYSERROR("Unable to enter delivery directory: %s", (*ctx)->storage.delivery_dir); guard_strlist_free(&file_listing); return -1; } diff --git a/src/cli/stasis_indexer/readmes.c b/src/cli/stasis_indexer/readmes.c index d740367..de9e2f2 100644 --- a/src/cli/stasis_indexer/readmes.c +++ b/src/cli/stasis_indexer/readmes.c @@ -16,7 +16,7 @@ int indexer_readmes(struct Delivery **ctx, const size_t nelem) { FILE *indexfp = fopen(indexfile, "w+"); if (!indexfp) { - fprintf(stderr, "Unable to open %s for writing\n", indexfile); + SYSERROR("Unable to open %s for writing", indexfile); return -1; } struct StrList *archs = get_architectures(latest_deliveries, nelem_real); diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c index 56be257..2bf72fd 100644 --- a/src/cli/stasis_indexer/stasis_indexer_main.c +++ b/src/cli/stasis_indexer/stasis_indexer_main.c @@ -41,7 +41,7 @@ int indexer_combine_rootdirs(const char *dest, char **rootdirs, const size_t roo srcdir_with_output[sizeof(srcdir_with_output) - 1] = '\0'; if (access(srcdir_bare, F_OK)) { - fprintf(stderr, "%s does not exist\n", srcdir_bare); + SYSWARN("%s does not exist", srcdir_bare); continue; } @@ -98,12 +98,12 @@ int indexer_symlinks(struct Delivery **ctx, const size_t nelem) { if (!access(link_name_spec, F_OK)) { if (unlink(link_name_spec)) { - fprintf(stderr, "Unable to remove spec link: %s\n", link_name_spec); + SYSWARN("Unable to remove spec link: %s", link_name_spec); } } if (!access(link_name_readme, F_OK)) { if (unlink(link_name_readme)) { - fprintf(stderr, "Unable to remove readme link: %s\n", link_name_readme); + SYSWARN("Unable to remove readme link: %s", link_name_readme); } } @@ -111,19 +111,19 @@ int indexer_symlinks(struct Delivery **ctx, const size_t nelem) { printf("%s -> %s\n", file_name_spec, link_name_spec); } if (symlink(file_name_spec, link_name_spec)) { - fprintf(stderr, "Unable to link %s as %s\n", file_name_spec, link_name_spec); + SYSWARN("Unable to link %s as %s", file_name_spec, link_name_spec); } if (globals.verbose) { printf("%s -> %s\n", file_name_readme, link_name_readme); } if (symlink(file_name_readme, link_name_readme)) { - fprintf(stderr, "Unable to link %s as %s\n", file_name_readme, link_name_readme); + SYSWARN("Unable to link %s as %s", file_name_readme, link_name_readme); } } popd(); } else { - fprintf(stderr, "Unable to enter delivery directory: %s\n", (*ctx)->storage.delivery_dir); + SYSERROR("Unable to enter delivery directory: %s", (*ctx)->storage.delivery_dir); guard_free(data); return -1; } @@ -137,7 +137,7 @@ void indexer_init_dirs(struct Delivery *ctx, const char *workdir) { path_store(&ctx->storage.root, PATH_MAX, workdir, ""); path_store(&ctx->storage.tmpdir, PATH_MAX, ctx->storage.root, "tmp"); if (delivery_init_tmpdir(ctx)) { - fprintf(stderr, "Failed to configure temporary storage directory\n"); + SYSERROR("Failed to configure temporary storage directory"); exit(1); } @@ -222,7 +222,7 @@ int main(const int argc, char *argv[]) { while (optind < argc) { if (argv[optind]) { if (access(argv[optind], F_OK) < 0) { - fprintf(stderr, "%s: %s\n", argv[optind], strerror(errno)); + SYSERROR("%s: %s", argv[optind], strerror(errno)); exit(1); } } @@ -248,7 +248,7 @@ int main(const int argc, char *argv[]) { } if (!rootdirs || !rootdirs_total) { - fprintf(stderr, "You must specify at least one STASIS root directory to index\n"); + SYSERROR("You must specify at least one STASIS root directory to index"); exit(1); } @@ -274,7 +274,7 @@ int main(const int argc, char *argv[]) { globals.sysconfdir = realpath(stasis_sysconfdir_tmp, NULL); if (!globals.sysconfdir) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "Unable to resolve path to configuration directory: %s\n", stasis_sysconfdir_tmp); + SYSERROR("Unable to resolve path to configuration directory: %s", stasis_sysconfdir_tmp); exit(1); } diff --git a/src/cli/stasis_indexer/website.c b/src/cli/stasis_indexer/website.c index aa6e2a5..07ad6ad 100644 --- a/src/cli/stasis_indexer/website.c +++ b/src/cli/stasis_indexer/website.c @@ -42,12 +42,12 @@ int indexer_make_website(struct Delivery **ctx) { // Convert markdown to html if (pandoc_exec(fullpath_src, fullpath_dest, have_css ? css_filename : NULL, "STASIS")) { - msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "Unable to convert %s\n", fullpath_src); + SYSWARN("Unable to convert %s", fullpath_src); } if (file_replace_text(fullpath_dest, ".md", ".html", 0)) { // inform-only - SYSERROR("%s: failed to rewrite *.md urls with *.html extension", fullpath_dest); + SYSWARN("%s: failed to rewrite *.md urls with *.html extension", fullpath_dest); } // Link the nearest README.html to index.html @@ -58,7 +58,7 @@ int indexer_make_website(struct Delivery **ctx) { link_dest[sizeof(link_dest) - 1] = '\0'; snprintf(link_dest, sizeof(link_dest), "%s/%s", root, "index.html"); if (symlink(link_from, link_dest)) { - SYSERROR("Warning: symlink(%s, %s) failed: %s", link_from, link_dest, strerror(errno)); + SYSWARN("symlink(%s, %s) failed: %s", link_from, link_dest, strerror(errno)); } } } -- cgit