| 1 |
root |
1.1 |
/* |
| 2 |
|
|
* This file is part of uudeview, the simple and friendly multi-part multi- |
| 3 |
root |
1.2 |
* file uudecoder program (c) 1994-2001 by Frank Pilhofer. The author may |
| 4 |
|
|
* be contacted at fp@fpx.de |
| 5 |
root |
1.1 |
* |
| 6 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 7 |
|
|
* it under the terms of the GNU General Public License as published by |
| 8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
|
|
* (at your option) any later version. |
| 10 |
|
|
* |
| 11 |
|
|
* This program is distributed in the hope that it will be useful, |
| 12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
|
|
* GNU General Public License for more details. |
| 15 |
|
|
*/ |
| 16 |
|
|
|
| 17 |
|
|
/* |
| 18 |
|
|
* Strings used in the library for easier translation etc. |
| 19 |
|
|
*/ |
| 20 |
|
|
|
| 21 |
|
|
#ifdef HAVE_CONFIG_H |
| 22 |
|
|
#include "config.h" |
| 23 |
|
|
#endif |
| 24 |
|
|
|
| 25 |
|
|
#ifdef SYSTEM_WINDLL |
| 26 |
|
|
#include <windows.h> |
| 27 |
|
|
#endif |
| 28 |
|
|
#ifdef SYSTEM_OS2 |
| 29 |
|
|
#include <os2.h> |
| 30 |
|
|
#endif |
| 31 |
|
|
|
| 32 |
|
|
#include <stdio.h> |
| 33 |
|
|
#include <ctype.h> |
| 34 |
|
|
|
| 35 |
|
|
#ifdef STDC_HEADERS |
| 36 |
|
|
#include <stdlib.h> |
| 37 |
|
|
#include <string.h> |
| 38 |
|
|
#endif |
| 39 |
|
|
#ifdef HAVE_MALLOC_H |
| 40 |
|
|
#include <malloc.h> |
| 41 |
|
|
#endif |
| 42 |
|
|
#ifdef HAVE_UNISTD_H |
| 43 |
|
|
#include <unistd.h> |
| 44 |
|
|
#endif |
| 45 |
|
|
#ifdef HAVE_MEMORY_H |
| 46 |
|
|
#include <memory.h> |
| 47 |
|
|
#endif |
| 48 |
|
|
|
| 49 |
root |
1.2 |
#include <uudeview.h> |
| 50 |
root |
1.1 |
#include <uuint.h> |
| 51 |
|
|
#include <uustring.h> |
| 52 |
|
|
|
| 53 |
root |
1.2 |
char * uustring_id = "$Id: uustring.c,v 1.6 2001/06/06 18:21:47 fp Exp $"; |
| 54 |
root |
1.1 |
|
| 55 |
|
|
typedef struct { |
| 56 |
|
|
int code; |
| 57 |
|
|
char * msg; |
| 58 |
|
|
} stringmap; |
| 59 |
|
|
|
| 60 |
|
|
/* |
| 61 |
|
|
* Map of messages. This table is not exported, the messages must |
| 62 |
|
|
* be retrieved via the below uustring() function. |
| 63 |
|
|
*/ |
| 64 |
|
|
|
| 65 |
|
|
static stringmap messages[] = { |
| 66 |
|
|
/* I/O related errors/messages. Last parameter is strerror() */ |
| 67 |
|
|
{ S_NOT_OPEN_SOURCE, "Could not open source file %s: %s" }, |
| 68 |
|
|
{ S_NOT_OPEN_TARGET, "Could not open target file %s for writing: %s" }, |
| 69 |
|
|
{ S_NOT_OPEN_FILE, "Could not open file %s: %s" }, |
| 70 |
|
|
{ S_NOT_STAT_FILE, "Could not stat file %s: %s" }, |
| 71 |
|
|
{ S_SOURCE_READ_ERR, "Read error on source file: %s" }, |
| 72 |
|
|
{ S_READ_ERROR, "Error reading from %s: %s" }, |
| 73 |
|
|
{ S_IO_ERR_TARGET, "I/O error on target file %s: %s" }, |
| 74 |
|
|
{ S_WR_ERR_TARGET, "Write error on target file %s: %s" }, |
| 75 |
|
|
{ S_WR_ERR_TEMP, "Write error on temp file: %s" }, |
| 76 |
|
|
{ S_TMP_NOT_REMOVED, "Could not remove temp file %s: %s (ignored)" }, |
| 77 |
|
|
|
| 78 |
|
|
/* some other problems */ |
| 79 |
|
|
{ S_OUT_OF_MEMORY, "Out of memory allocating %d bytes" }, |
| 80 |
|
|
{ S_TARGET_EXISTS, "Target file %s exists and overwriting is not allowed" }, |
| 81 |
|
|
{ S_NOT_RENAME, "Could not change name of %s to %s" }, |
| 82 |
|
|
{ S_ERR_ENCODING, "Error while encoding %s: %s" }, |
| 83 |
|
|
{ S_STAT_ONE_PART, "Could not stat input, encoding to one part only" }, |
| 84 |
|
|
{ S_PARM_CHECK, "Parameter check failed in %s" }, |
| 85 |
|
|
{ S_SHORT_BINHEX, "BinHex encoded file %s ended prematurely (%ld bytes left)" }, |
| 86 |
|
|
{ S_DECODE_CANCEL, "Decode operation canceled" }, |
| 87 |
|
|
{ S_ENCODE_CANCEL, "Encode operation canceled" }, |
| 88 |
|
|
{ S_SCAN_CANCEL, "Scanning canceled" }, |
| 89 |
|
|
|
| 90 |
|
|
/* informational messages */ |
| 91 |
|
|
{ S_LOADED_PART, "Loaded from %s: '%s' (%s): %s part %d %s %s %s" }, |
| 92 |
|
|
{ S_NO_DATA_FOUND, "No encoded data found in %s" }, |
| 93 |
|
|
{ S_NO_BIN_FILE, "Oops, could not find decoded file?" }, |
| 94 |
|
|
{ S_STRIPPED_SETUID, "Stripped setuid/setgid bits from target file %s mode %d" }, |
| 95 |
|
|
{ S_DATA_SUSPICIOUS, "Data looks suspicious. Decoded file might be corrupt." }, |
| 96 |
|
|
{ S_NO_TEMP_NAME, "Could not get name for temporary file" }, |
| 97 |
|
|
{ S_BINHEX_SIZES, "BinHex file: data/resource fork sizes %ld/%ld" }, |
| 98 |
|
|
{ S_BINHEX_BOTH, "BinHex file: both forks non-empty, decoding data fork" }, |
| 99 |
|
|
{ S_SMERGE_MERGED, "Parts of '%s' merged with parts of '%s' (%d)" }, |
| 100 |
|
|
|
| 101 |
|
|
/* MIME-related messages */ |
| 102 |
|
|
{ S_MIME_NO_BOUNDARY, "Multipart message without boundary ignored" }, |
| 103 |
|
|
{ S_MIME_B_NOT_FOUND, "Boundary expected on Multipart message but found EOF" }, |
| 104 |
|
|
{ S_MIME_MULTI_DEPTH, "Multipart message nested too deep" }, |
| 105 |
|
|
{ S_MIME_PART_MULTI, "Handling partial multipart message as plain text" }, |
| 106 |
|
|
|
| 107 |
|
|
{ 0, "" } |
| 108 |
|
|
}; |
| 109 |
|
|
|
| 110 |
|
|
/* |
| 111 |
|
|
* description of the return values UURET_* |
| 112 |
|
|
*/ |
| 113 |
|
|
|
| 114 |
|
|
char *uuretcodes[] = { |
| 115 |
|
|
"OK", |
| 116 |
|
|
"File I/O Error", |
| 117 |
|
|
"Not Enough Memory", |
| 118 |
|
|
"Illegal Value", |
| 119 |
|
|
"No Data found", |
| 120 |
|
|
"Unexpected End of File", |
| 121 |
|
|
"Unsupported function", |
| 122 |
|
|
"File exists", |
| 123 |
|
|
"Continue -- no error", /* only to be seen internally */ |
| 124 |
|
|
"Operation Canceled" |
| 125 |
|
|
}; |
| 126 |
|
|
|
| 127 |
|
|
/* |
| 128 |
|
|
* Names of encoding types |
| 129 |
|
|
*/ |
| 130 |
|
|
|
| 131 |
|
|
char *codenames[7] = { |
| 132 |
|
|
"", "UUdata", "Base64", "XXdata", "Binhex", "Text", "Text" |
| 133 |
|
|
}; |
| 134 |
|
|
|
| 135 |
|
|
/* |
| 136 |
|
|
* Message types |
| 137 |
|
|
*/ |
| 138 |
|
|
|
| 139 |
|
|
char *msgnames[6] = { |
| 140 |
|
|
"", "Note: ", "Warning: ", "ERROR: ", "FATAL ERROR: ", "PANIC: " |
| 141 |
|
|
}; |
| 142 |
|
|
|
| 143 |
|
|
/* |
| 144 |
|
|
* Retrieve one of the messages. We never return NULL |
| 145 |
|
|
* but instead escape to "oops". |
| 146 |
|
|
*/ |
| 147 |
|
|
|
| 148 |
|
|
char * |
| 149 |
|
|
uustring (int codeno) |
| 150 |
|
|
{ |
| 151 |
|
|
static char * faileddef = "oops"; |
| 152 |
|
|
stringmap *ptr = messages; |
| 153 |
|
|
|
| 154 |
|
|
while (ptr->code) { |
| 155 |
|
|
if (ptr->code == codeno) |
| 156 |
|
|
return ptr->msg; |
| 157 |
|
|
ptr++; |
| 158 |
|
|
} |
| 159 |
|
|
|
| 160 |
|
|
UUMessage (uustring_id, __LINE__, UUMSG_ERROR, |
| 161 |
|
|
"Could not retrieve string no %d", |
| 162 |
|
|
codeno); |
| 163 |
|
|
|
| 164 |
|
|
return faileddef; |
| 165 |
|
|
} |