From 99e7c7539d932c8283941dff1a2e63a75cabce31 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 06 Jul 2023 13:02:21 -0400 Subject: opkg-opk: Use common error functions And translate a couple missing strings. --- diff --git a/TODO b/TODO index 458948d..3e41b0a 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ Ownership override Finish options handling, remove cli.txt -Reconsider error handling (enum?), prepend program name to messages (see above) +Reconsider error handling (enum?) chown and install replacements to append to override file Test helpers opkbuild helper to set PATH diff --git a/opkg-opk/local.mk b/opkg-opk/local.mk index 6653839..cbab94e 100644 --- a/opkg-opk/local.mk +++ b/opkg-opk/local.mk @@ -1,5 +1,7 @@ opkg_opk_opkg_opk_SOURCES += \ common/defs.h \ + common/error.c \ + common/error.h \ %reldir%/dirent.c \ %reldir%/dirent.h \ %reldir%/gzip.c \ diff --git a/opkg-opk/main.c b/opkg-opk/main.c index b33c268..cab68e9 100644 --- a/opkg-opk/main.c +++ b/opkg-opk/main.c @@ -34,6 +34,8 @@ #include #endif +#include "error.h" + extern const char *PACKAGE_VERSION_GIT; static const char *_OPTSTRING = "bc:d:s:f:F:lLhV"; @@ -207,15 +209,14 @@ _help_tip(const char *program_name) static void _opt_mutex(const char *program_name, char opt1, char opt2) { - fprintf(stderr, _("%s: Options -%c and -%c are mutually exclusive\n"), - program_name, opt1, opt2); + opkg_opk_error(_("Options -%c and -%c are mutually exclusive"), + opt1, opt2); _help_tip(program_name); } int main(int argc, char *argv[]) { - const char *program_name; struct opkg_opk_opk *opk; int build; int opt_f; @@ -233,7 +234,7 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); #endif - program_name = argv[0]; + opkg_opk_set_program_name(argv[0]); /* Initialize package. */ opk = opkg_opk_opk_init(); @@ -266,17 +267,16 @@ main(int argc, char *argv[]) case 's': if (opkg_opk_opk_specials_read(opk, optarg) != OPKG_OPK_OK) { - fprintf(stderr, _("%s: Failed to read " - "specials file" - "\n"), - program_name); + opkg_opk_error(_("Failed to read " + "specials file") + ); opkg_opk_opk_free(opk); return EXIT_FAILURE; } break; case 'f': if (opt_l > 0) { - _opt_mutex(program_name, 'f', 'l'); + _opt_mutex(argv[0], 'f', 'l'); opkg_opk_opk_free(opk); return EXIT_FAILURE; } @@ -289,7 +289,7 @@ main(int argc, char *argv[]) break; case 'F': if (opt_L > 0) { - _opt_mutex(program_name, 'F', 'L'); + _opt_mutex(argv[0], 'F', 'L'); opkg_opk_opk_free(opk); return EXIT_FAILURE; } @@ -302,7 +302,7 @@ main(int argc, char *argv[]) break; case 'l': if (opt_f > 0) { - _opt_mutex(program_name, 'f', 'l'); + _opt_mutex(argv[0], 'f', 'l'); opkg_opk_opk_free(opk); return EXIT_FAILURE; } @@ -311,7 +311,7 @@ main(int argc, char *argv[]) break; case 'L': if (opt_F > 0) { - _opt_mutex(program_name, 'F', 'L'); + _opt_mutex(argv[0], 'F', 'L'); opkg_opk_opk_free(opk); return EXIT_FAILURE; } @@ -319,7 +319,7 @@ main(int argc, char *argv[]) opkg_opk_opk_list_data(opk); break; case 'h': - _help(program_name); + _help(argv[0]); opkg_opk_opk_free(opk); return EXIT_SUCCESS; case 'V': @@ -327,10 +327,9 @@ main(int argc, char *argv[]) opkg_opk_opk_free(opk); return EXIT_SUCCESS; default: - fprintf(stderr, _("%s: Invalid option: " - "\"%c\"\n"), - program_name, optopt); - _help_tip(program_name); + opkg_opk_error(_("Invalid option: \"%c\""), + optopt); + _help_tip(argv[0]); opkg_opk_opk_free(opk); return EXIT_FAILURE; } @@ -339,15 +338,13 @@ main(int argc, char *argv[]) argv += optind; if (argc < 1) { - fprintf(stderr, _("%s: Missing package file operand\n"), - program_name); - _help_tip(program_name); + opkg_opk_error(_("Missing package file operand")); + _help_tip(argv[0]); opkg_opk_opk_free(opk); return EXIT_FAILURE; } else if (argc > 1) { - fprintf(stderr, _("%s: Too many package file operands\n"), - program_name); - _help_tip(program_name); + opkg_opk_error(_("Too many package file operands")); + _help_tip(argv[0]); opkg_opk_opk_free(opk); return EXIT_FAILURE; } diff --git a/opkg-opk/opk/read.c b/opkg-opk/opk/read.c index 369fcd7..e079b94 100644 --- a/opkg-opk/opk/read.c +++ b/opkg-opk/opk/read.c @@ -24,6 +24,7 @@ #include #include #include "defs.h" +#include "error.h" #include "../gzip.h" #include "../i18n.h" #include "../opk.h" @@ -55,14 +56,14 @@ _opkg_opk_opk_read_init_inner(struct opkg_opk_opk *opk) (opkg_opk_gzip_read_func *) &opkg_opk_ustar_read, opk->outer_ustar); if (opk->inner_gzip == NULL) { - fputs(_("Error: Failed to initialize\n"), stderr); + opkg_opk_error(_("Failed to initialize")); return OPKG_OPK_ERROR; } /* Initialize inner ustar unarchiver. */ opk->inner_ustar = opkg_opk_ustar_init(opk->inner_gzip); if (opk->inner_ustar == NULL) { - fputs(_("Error: Failed to initialize\n"), stderr); + opkg_opk_error(_("Failed to initialize")); opkg_opk_gzip_free(opk->inner_gzip); return OPKG_OPK_ERROR; } @@ -131,13 +132,12 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) if (opk->control_dir != NULL) { if (stat(opk->control_dir, &stat_buf) == 0) { if (!S_ISDIR(stat_buf.st_mode)) { - fputs(_("Error: Cannot create control directory" - "\n"), stderr); + opkg_opk_error(_("Cannot create control " + "directory")); return OPKG_OPK_ERROR; } } else if (mkdir(opk->control_dir, 0755) != 0) { - fputs(_("Error: Cannot create control directory" - "\n"), stderr); + opkg_opk_error(_("Cannot create control directory")); return OPKG_OPK_ERROR; } /* For below #pragmas: path initialized here @@ -177,8 +177,8 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) /* Only extract and/or print regular files. */ if (member->type != '-') { - fputs(_("Error: Non-regular control files not supported" - "\n"), stderr); + opkg_opk_error(_("Non-regular control files not " + "supported")); free(member); _opkg_opk_opk_read_free_inner(opk); if (opk->control_dir != NULL) { @@ -213,8 +213,8 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) fp = fopen(path, "wb"); # pragma GCC diagnostic pop if (fp == NULL) { - fputs(_("Error: Failed to extract control file" - "\n"), stderr); + opkg_opk_error(_("Failed to extract control " + "file")); free(member); _opkg_opk_opk_read_free_inner(opk); # pragma GCC diagnostic push @@ -252,8 +252,8 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) { if (print == 1 && fwrite(buffer, 1, size, stdout) != size) { - fputs(_("Error: Failed to print control file\n") - , stderr); + opkg_opk_error(_("Failed to print control file") + ); _opkg_opk_opk_read_free_inner(opk); if (opk->control_dir != NULL) { free(path); @@ -265,8 +265,8 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) "-Wanalyzer-use-of-uninitialized-value" if (opk->control_dir != NULL && fwrite(buffer, 1, size, fp) != size) { - fputs(_("Error: Failed to write control file\n") - , stderr); + opkg_opk_error(_("Failed to write control file") + ); _opkg_opk_opk_read_free_inner(opk); free(path); # pragma GCC diagnostic pop @@ -274,8 +274,7 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) } } if (ret_read == OPKG_OPK_ERROR) { - fputs(_("Error: Failed to read control file\n"), - stderr); + opkg_opk_error(_("Failed to read control file")); _opkg_opk_opk_read_free_inner(opk); if (opk->control_dir != NULL) { # pragma GCC diagnostic push @@ -316,7 +315,7 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) # pragma GCC diagnostic pop } if (ret_list == OPKG_OPK_ERROR) { - fputs(_("Error: Failed to list control files\n"), stderr); + opkg_opk_error(_("Failed to list control files")); _opkg_opk_opk_read_free_inner(opk); return OPKG_OPK_ERROR; } @@ -325,8 +324,8 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) if (opk->print_control_head != NULL) { for (seek_name = opk->print_control_head; seek_name != NULL; seek_name = seek_name->next) { - fprintf(stderr, _("Error: Failed to find control file " - "\"%s\"\n"), seek_name->name); + opkg_opk_error(_("Failed to find control file \"%s\""), + seek_name->name); } _opkg_opk_opk_read_free_inner(opk); return OPKG_OPK_ERROR; @@ -438,22 +437,20 @@ _opkg_opk_opk_read_data(struct opkg_opk_opk *opk) &buffer, &size)) == OPKG_OPK_OK) { if (fwrite(buffer, 1, size, stdout) != size) { - fputs(_("Error: Failed to print data file\n") - , stderr); + opkg_opk_error(_("Failed to print data file")); _opkg_opk_opk_read_free_inner(opk); return OPKG_OPK_ERROR; } } if (ret_read == OPKG_OPK_ERROR) { - fputs(_("Error: Failed to read data file\n"), - stderr); + opkg_opk_error(_("Failed to read data file")); _opkg_opk_opk_read_free_inner(opk); return OPKG_OPK_ERROR; } opk->previously_printed = 1; } if (ret == OPKG_OPK_ERROR) { - fputs(_("Error: Failed to list data files\n"), stderr); + opkg_opk_error(_("Failed to list data files")); _opkg_opk_opk_read_free_inner(opk); return OPKG_OPK_ERROR; } @@ -570,8 +567,7 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name) /* Open outer archive. */ opk->file = fopen(file_name, "rb"); if (opk->file == NULL) { - fprintf(stderr, _("Error: Failed to open file \"%s\"\n"), - file_name); + opkg_opk_error(_("Failed to open file \"%s\""), file_name); ret = OPKG_OPK_ERROR; goto out0; } @@ -580,7 +576,7 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name) opk->outer_gzip = opkg_opk_gzip_init_read(&_opkg_opk_opk_read_file, opk); if (opk->outer_gzip == NULL) { - fputs(_("Error: Failed to initialize\n"), stderr); + opkg_opk_error(_("Failed to initialize")); ret = OPKG_OPK_ERROR; goto out1; } @@ -588,22 +584,22 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name) /* Initialize outer ustar unarchiver. */ opk->outer_ustar = opkg_opk_ustar_init(opk->outer_gzip); if (opk->outer_ustar == NULL) { - fputs(_("Error: Failed to initialize\n"), stderr); + opkg_opk_error(_("Failed to initialize")); ret = OPKG_OPK_ERROR; goto out2; } /* Check package version. */ if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK) { - fputs(_("Error: Failed to find \"debian-binary\" in archive\n"), - stderr); + opkg_opk_error(_("Failed to find \"debian-binary\" in archive") + ); ret = OPKG_OPK_ERROR; goto out3; } if (strcmp(member->name, "debian-binary") != 0) { free(member); - fputs(_("Error: Failed to find \"debian-binary\" in archive\n"), - stderr); + opkg_opk_error(_("Failed to find \"debian-binary\" in archive") + ); ret = OPKG_OPK_ERROR; goto out3; } @@ -611,27 +607,27 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name) if (opkg_opk_ustar_read(opk->outer_ustar, &version_buffer, &version_size) != OPKG_OPK_OK) { - fputs(_("Error: Failed to read \"debian-binary\" in archive\n"), - stderr); + opkg_opk_error(_("Failed to read \"debian-binary\" in archive") + ); ret = OPKG_OPK_ERROR; goto out3; } if (version_size < 4 || strncmp(version_buffer, "2.", 2) != 0) { - fputs(_("Error: Unsupported package version\n"), stderr); + opkg_opk_error(_("Unsupported package version")); ret = OPKG_OPK_ERROR; goto out3; } /* Read control archive. */ if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK) { - fputs(_("Error: Failed to find \"control.tar.gz\" in archive\n") - , stderr); + opkg_opk_error(_("Failed to find \"control.tar.gz\" in archive") + ); return OPKG_OPK_ERROR; } if (strcmp(member->name, "control.tar.gz") != 0) { free(member); - fputs(_("Error: Failed to find \"control.tar.gz\" in archive\n") - , stderr); + opkg_opk_error(_("Failed to find \"control.tar.gz\" in archive") + ); return OPKG_OPK_ERROR; } free(member); @@ -642,14 +638,12 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name) /* Read data archive. */ if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK) { - fputs(_("Error: Failed to find \"data.tar.gz\" in archive\n"), - stderr); + opkg_opk_error(_("Failed to find \"data.tar.gz\" in archive")); return OPKG_OPK_ERROR; } if (strcmp(member->name, "data.tar.gz") != 0) { free(member); - fputs(_("Error: Failed to find \"data.tar.gz\" in archive\n"), - stderr); + opkg_opk_error(_("Failed to find \"data.tar.gz\" in archive")); return OPKG_OPK_ERROR; } free(member); diff --git a/opkg-opk/opk/write.c b/opkg-opk/opk/write.c index 520b5fd..996007d 100644 --- a/opkg-opk/opk/write.c +++ b/opkg-opk/opk/write.c @@ -28,6 +28,7 @@ #include #include #include "defs.h" +#include "error.h" #include "../dirent.h" #include "../gzip.h" #include "../i18n.h" @@ -120,8 +121,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, for (name_i = 0; children[children_i]->d_name[name_i] != '\0'; ++name_i) { if (path_off + name_i + 1 == OPKG_OPK_USTAR_NAME_SIZE) { - fprintf(stderr, "Error: File name \"%s\" too " - "long", + opkg_opk_error(_("File name \"%s\" too long"), children[children_i]->d_name); goto err; } @@ -130,7 +130,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, } child_path[name_i] = '\0'; if (lstat(opk->path_real, &st) != 0) { - fprintf(stderr, _("Error: Failed to stat \"%s\"\n"), + opkg_opk_error(_("Failed to stat \"%s\""), opk->path_real); goto err; } @@ -141,8 +141,8 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, gname = getgrgid(gid)->gr_name; if (S_ISDIR(st.st_mode)) { if (path_off + name_i + 2 == OPKG_OPK_USTAR_NAME_SIZE) { - fprintf(stderr, "Error: File name \"%s\" too " - "long", child_path); + opkg_opk_error(_("File name \"%s\" too long"), + child_path); goto err; } child_path[name_i] = '/'; @@ -152,8 +152,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, uid, uname, gid, gname, 0, 0, 0, opk->mtime, 'd', NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), - stderr); + opkg_opk_error(_("Failed to write header")); goto err; } if (_opkg_opk_opk_write_dir_read(opk, &child, @@ -176,8 +175,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, uid, uname, gid, gname, 0, 0, 0, opk->mtime, 'l', link) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), - stderr); + opkg_opk_error(_("Failed to write header")); goto err; } } else if (S_ISCHR(st.st_mode)) { @@ -188,8 +186,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, minor(st.st_rdev), 0, opk->mtime, 'c', NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), - stderr); + opkg_opk_error(_("Failed to write header")); goto err; } } else if (S_ISBLK(st.st_mode)) { @@ -200,8 +197,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, minor(st.st_rdev), 0, opk->mtime, 'b', NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), - stderr); + opkg_opk_error(_("Failed to write header")); goto err; } } else if (S_ISFIFO(st.st_mode)) { @@ -210,8 +206,7 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, uid, uname, gid, gname, 0, 0, 0, opk->mtime, 'p', NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), - stderr); + opkg_opk_error(_("Failed to write header")); goto err; } } else if (S_ISREG(st.st_mode)) { @@ -227,8 +222,8 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, devmajor, devminor, 0, opk->mtime, type, NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header" - "\n"), stderr); + opkg_opk_error(_("Failed to write " + "header")); goto err; } continue; @@ -238,14 +233,12 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, uid, uname, gid, gname, 0, 0, st.st_size, opk->mtime, '-', NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), - stderr); + opkg_opk_error(_("Failed to write header")); goto err; } fp = fopen(opk->path_real, "rb"); if (fp == NULL) { - fprintf(stderr, _("Error: Failed to open file " - "\"%s\"\n"), + opkg_opk_error(_("Failed to open file \"%s\""), opk->path_real); goto err; } @@ -258,25 +251,24 @@ _opkg_opk_opk_write_dir_read(struct opkg_opk_opk *opk, tot_read += num_read; } if (ferror(fp) != 0) { - fputs(_("Error: Error reading file\n"), stderr); + opkg_opk_error(_("Error reading file")); fclose(fp); goto err; } if (fclose(fp) != 0) { - fputs(_("Error: Failed to close file\n"), - stderr); + opkg_opk_error(_("Failed to close file")); goto err; } if ((uintmax_t) tot_read != (uintmax_t) st.st_size) { - fprintf(stderr, _("Error: Expected %jd bytes " - "but read %zu\n"), + opkg_opk_error(_("Expected %jd bytes " + "but read %zu"), (intmax_t) st.st_size, num_read); goto err; } } else { - fprintf(stderr, _("Error: Unknown type of file \"%s\"\n" - ), opk->path_real); + opkg_opk_error(_("Unknown type of file \"%s\""), + opk->path_real); goto err; } } @@ -318,20 +310,20 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk, } fp = fopen(opk->temp_file_name, "w+b"); if (fp == NULL) { - fprintf(stderr, _("Error: Failed to open file \"%s\"\n"), + opkg_opk_error(_("Failed to open file \"%s\""), opk->temp_file_name); goto err0; } opk->inner_gzip = opkg_opk_gzip_init_write(fp); if (opk->inner_gzip == NULL) { - fputs(_("Error: Failed to initialize compressor\n"), stderr); + opkg_opk_error(_("Failed to initialize compressor")); goto err1; } /* Initialize inner ustar archiver. */ opk->inner_ustar = opkg_opk_ustar_init(opk->inner_gzip); if (opk->inner_ustar == NULL) { - fputs(_("Error: Failed to initialize archiver\n"), stderr); + opkg_opk_error(_("Failed to initialize archiver")); goto err2; } @@ -346,8 +338,7 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk, opk->path_virt = opk->path_real + opk->data_dir_len; } if (stat(opk->path_real, &st) != 0) { - fprintf(stderr, _("Error: Failed to stat \"%s\"\n"), - opk->path_real); + opkg_opk_error(_("Failed to stat \"%s\""), opk->path_real); goto err3; } uid = st.st_uid; @@ -357,8 +348,7 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk, if (opkg_opk_ustar_write_header(opk->inner_ustar, &dirent, st.st_mode & 0777, uid, uname, gid, gname, 0, 0, 0, opk->mtime, 'd', NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), - stderr); + opkg_opk_error(_("Failed to write header")); goto err3; } if (_opkg_opk_opk_write_dir_read(opk, &dirent, 1 /* Skip '/' */) != @@ -368,7 +358,7 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk, /* Write trailer. */ if (opkg_opk_ustar_write_trailer(opk->inner_ustar) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write trailer\n"), stderr); + opkg_opk_error(_("Failed to write trailer")); goto err3; } @@ -385,13 +375,13 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk, 0, opk->outer_uname, 0, opk->outer_gname, 0, 0, written, opk->mtime, '-', NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), stderr); + opkg_opk_error(_("Failed to write header")); goto err1; } /* Read temporary file into outer archive. */ if (fseek(fp, 0L, SEEK_SET) != 0) { - fputs(_("Error: Failed to seek in file\n"), stderr); + opkg_opk_error(_("Failed to seek in file")); goto err1; } opkg_opk_ustar_get_buffer(opk->outer_ustar, &buffer, &size); @@ -401,17 +391,17 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk, tot_read += num_read; } if (ferror(fp) != 0) { - fputs(_("Error: Error reading file\n"), stderr); + opkg_opk_error(_("Error reading file")); fclose(fp); goto err1; } if (fclose(fp) != 0) { - fputs(_("Error: Failed to close file\n"), stderr); + opkg_opk_error(_("Failed to close file")); goto err1; } unlink(opk->temp_file_name); if (tot_read != written) { - fprintf(stderr, _("Error: Wrote %lu bytes but read %lu\n"), + opkg_opk_error(_("Wrote %lu bytes but read %lu"), written, num_read); goto err1; } @@ -440,8 +430,7 @@ opkg_opk_opk_write(struct opkg_opk_opk *opk, const char *file_name) ret = OPKG_OPK_OK; if (_opkg_opk_opk_source_date_epoch(&opk->mtime) == OPKG_OPK_ERROR) { - fputs(_("Error: Missing or invalid SOURCE_DATE_EPOCH\n"), - stderr); + opkg_opk_error(_("Missing or invalid SOURCE_DATE_EPOCH")); ret = OPKG_OPK_ERROR; goto out0; } @@ -451,8 +440,7 @@ opkg_opk_opk_write(struct opkg_opk_opk *opk, const char *file_name) /* Open outer archive. */ opk->file = fopen(file_name, "wb"); if (opk->file == NULL) { - fprintf(stderr, _("Error: Failed to open file \"%s\"\n"), - file_name); + opkg_opk_error(_("Failed to open file \"%s\""), file_name); ret = OPKG_OPK_ERROR; goto out0; } @@ -460,7 +448,7 @@ opkg_opk_opk_write(struct opkg_opk_opk *opk, const char *file_name) /* Initialize outer gzip compressor. */ opk->outer_gzip = opkg_opk_gzip_init_write(opk->file); if (opk->outer_gzip == NULL) { - fputs(_("Error: Failed to initialize\n"), stderr); + opkg_opk_error(_("Failed to initialize")); ret = OPKG_OPK_ERROR; goto out1; } @@ -468,7 +456,7 @@ opkg_opk_opk_write(struct opkg_opk_opk *opk, const char *file_name) /* Initialize outer ustar archiver. */ opk->outer_ustar = opkg_opk_ustar_init(opk->outer_gzip); if (opk->outer_ustar == NULL) { - fputs(_("Error: Failed to initialize\n"), stderr); + opkg_opk_error(_("Failed to initialize")); ret = OPKG_OPK_ERROR; goto out2; } @@ -482,14 +470,14 @@ opkg_opk_opk_write(struct opkg_opk_opk *opk, const char *file_name) if (opkg_opk_ustar_write_header(opk->outer_ustar, &dirent, 0644, 0, opk->outer_uname, 0, opk->outer_gname, 0, 0, 4, opk->mtime, '-', NULL) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write header\n"), stderr); + opkg_opk_error(_("Failed to write header")); ret = OPKG_OPK_ERROR; goto out3; } opkg_opk_ustar_get_buffer(opk->outer_ustar, &buffer, &size); memcpy(buffer, "2.0\n", 4); if (opkg_opk_ustar_write_data(opk->outer_ustar, 4) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write data\n"), stderr); + opkg_opk_error(_("Failed to write data")); ret = OPKG_OPK_ERROR; goto out3; } @@ -530,7 +518,7 @@ opkg_opk_opk_write(struct opkg_opk_opk *opk, const char *file_name) /* Write trailer. */ if (opkg_opk_ustar_write_trailer(opk->outer_ustar) != OPKG_OPK_OK) { - fputs(_("Error: Failed to write trailer\n"), stderr); + opkg_opk_error(_("Failed to write trailer")); ret = OPKG_OPK_ERROR; goto out5; } -- cgit v0.9.1