From: Laurent Mazet Date: Fri, 9 Dec 2022 12:25:37 +0000 (+0100) Subject: correct output stream for error messages X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=e75046fbacdc934109c9a38a0ef35a72a5aa02b1;p=compress.git correct output stream for error messages --- diff --git a/compress.c b/compress.c index 17385d4..ea65038 100644 --- a/compress.c +++ b/compress.c @@ -58,7 +58,7 @@ int *create_table (char *filename) /* open file */ fid = open (filename, O_RDONLY|O_RAW); if (fid == -1) { - VERBOSE (ERROR, PRINTOUT ("can't open file '%s'\n", filename)); + VERBOSE (ERROR, PRINTERR ("can't open file '%s'\n", filename/); return NULL; } VERBOSE (INFO, PRINTOUT ("file '%s' opened\n", filename)); @@ -115,7 +115,7 @@ leaf_t **init_forest (int *table) if (table[i] > 0) { leafs[l] = getleaf (1); if (leafs[l] == NULL) { - VERBOSE (ERROR, PRINTOUT ("can't allocate memory\n")); + VERBOSE (ERROR, PRINTERR ("can't allocate memory\n")); return NULL; } leafs[l]->occ = table[i]; @@ -173,12 +173,12 @@ leaf_t *create_tree (leaf_t **leafs) /* create branch */ if ((last == -1) || (ante == -1)) { - VERBOSE (ERROR, PRINTOUT ("error during tree building\n")); + VERBOSE (ERROR, PRINTERR ("error during tree building\n")); return NULL; } branch = getleaf (1); if (branch == NULL) { - VERBOSE (ERROR, PRINTOUT ("can't allocate memory\n")); + VERBOSE (ERROR, PRINTERR ("can't allocate memory\n")); return NULL; } branch->left = leafs[last]; @@ -371,7 +371,7 @@ int write_compress (char *output, char *input, code_t *codes, byte_t *header) /* open input file */ fin = open (input, O_RDONLY|O_RAW); if (fin == -1) { - VERBOSE (ERROR, PRINTOUT ("can't open file '%s' for reading\n", input)); + VERBOSE (ERROR, PRINTERR ("can't open file '%s' for reading\n", input)); return 1; } VERBOSE (INFO, PRINTOUT ("file '%s' opened\n", input)); @@ -379,7 +379,7 @@ int write_compress (char *output, char *input, code_t *codes, byte_t *header) /* open output file */ fout = open (output, O_WRONLY|O_CREAT|O_RAW, 0700); if (fout == -1) { - VERBOSE (ERROR, PRINTOUT ("can't open file '%s' for writing\n", output)); + VERBOSE (ERROR, PRINTERR ("can't open file '%s' for writing\n", output)); close (fin); return 1; } @@ -457,7 +457,7 @@ code_t *read_header (char *filename) { /* open file */ fid = open (filename, O_RDONLY|O_RAW); if (fid == -1) { - VERBOSE (ERROR, PRINTOUT ("can't open file '%s'\n", filename)); + VERBOSE (ERROR, PRINTERR ("can't open file '%s'\n", filename)); return NULL; } VERBOSE (INFO, PRINTOUT ("file '%s' opened\n", filename)); @@ -481,7 +481,7 @@ code_t *read_header (char *filename) { } close (fid); if (mode == 0) { - VERBOSE (ERROR, PRINTOUT ("incorrect file\n")); + VERBOSE (ERROR, PRINTERR ("incorrect file\n")); return NULL; } @@ -510,7 +510,7 @@ code_t *read_header (char *filename) { } if (((mode == 1) && (size - 256 != (l + 7) / 8)) || ((mode == 2) && (size - 2 * nb - 1 != (l + 7) / 8))) { - VERBOSE (ERROR, PRINTOUT ("incorrect code table length: %d %d %d\n", size, nb, l)); + VERBOSE (ERROR, PRINTERR ("incorrect code table length: %d %d %d\n", size, nb, l)); return NULL; } @@ -556,7 +556,7 @@ int write_decompress (char *output, char *input, code_t *codes) /* open file for reading */ fin = open (input, O_RDONLY|O_RAW); if (fin == -1) { - VERBOSE (ERROR, PRINTOUT ("can't open file '%s' for reading\n", input)); + VERBOSE (ERROR, PRINTERR ("can't open file '%s' for reading\n", input)); return 1; } VERBOSE (INFO, PRINTOUT ("file '%s' opened\n", input)); @@ -564,7 +564,7 @@ int write_decompress (char *output, char *input, code_t *codes) /* read magic number */ nb = read (fin, bufhea, 6); if (nb != 6) { - VERBOSE (ERROR, PRINTOUT ("can't read file\n")); + VERBOSE (ERROR, PRINTERR ("can't read file\n")); close (fin); return 1; } @@ -574,7 +574,7 @@ int write_decompress (char *output, char *input, code_t *codes) VERBOSE (DEBUG, PRINTOUT ("remainder: %d\n", rem)); nb = read (fin, bufhea, size); if (nb != size) { - VERBOSE (ERROR, PRINTOUT ("can't read file\n")); + VERBOSE (ERROR, PRINTERR ("can't read file\n")); close (fin); return 1; } @@ -582,7 +582,7 @@ int write_decompress (char *output, char *input, code_t *codes) /* open file for writing */ fout = open (output, O_WRONLY|O_CREAT|O_RAW, 0700); if (fout == -1) { - VERBOSE (ERROR, PRINTOUT ("can't open file '%s' for writing\n", output)); + VERBOSE (ERROR, PRINTERR ("can't open file '%s' for writing\n", output)); close (fin); return 2; }