00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef HAVE_CONFIG_H
00022 #ifdef _MSC_VER
00023 #include "config.h.win32"
00024 #else
00025 #include "config.h"
00026 #endif
00027 #endif
00028
00029 #ifdef SYSTEM_WINDLL
00030 #include
00031 #endif
00032 #ifdef SYSTEM_OS2
00033 #include
00034 #endif
00035
00036 #include
00037 #include
00038
00039 #ifdef STDC_HEADERS
00040 #include
00041 #include
00042 #endif
00043 #ifdef HAVE_MALLOC_H
00044 #include
00045 #endif
00046 #ifdef HAVE_UNISTD_H
00047 #include
00048 #endif
00049 #ifdef HAVE_MEMORY_H
00050 #include
00051 #endif
00052
00053 #include uudeview.h>
00054 #include uuint.h>
00055 #include uustring.h>
00056
00057 char * uustring_id = "$Id: uustring.c 251 2007-04-28 17:58:33Z csk $";
00058
00059 typedef struct {
00060 int code;
00061 char * msg;
00062 } stringmap;
00063
00064
00065
00066
00067
00068
00069 static stringmap messages[] = {
00070
00071 { S_NOT_OPEN_SOURCE, "Could not open source file %s: %s" },
00072 { S_NOT_OPEN_TARGET, "Could not open target file %s for writing: %s" },
00073 { S_NOT_OPEN_FILE, "Could not open file %s: %s" },
00074 { S_NOT_STAT_FILE, "Could not stat file %s: %s" },
00075 { S_SOURCE_READ_ERR, "Read error on source file: %s" },
00076 { S_READ_ERROR, "Error reading from %s: %s" },
00077 { S_IO_ERR_TARGET, "I/O error on target file %s: %s" },
00078 { S_WR_ERR_TARGET, "Write error on target file %s: %s" },
00079 { S_WR_ERR_TEMP, "Write error on temp file: %s" },
00080 { S_TMP_NOT_REMOVED, "Could not remove temp file %s: %s (ignored)" },
00081
00082
00083 { S_OUT_OF_MEMORY, "Out of memory allocating %d bytes" },
00084 { S_TARGET_EXISTS, "Target file %s exists and overwriting is not allowed" },
00085 { S_NOT_RENAME, "Could not change name of %s to %s" },
00086 { S_ERR_ENCODING, "Error while encoding %s: %s" },
00087 { S_STAT_ONE_PART, "Could not stat input, encoding to one part only" },
00088 { S_PARM_CHECK, "Parameter check failed in %s" },
00089 { S_SHORT_BINHEX, "BinHex encoded file %s ended prematurely (%ld bytes left)" },
00090 { S_DECODE_CANCEL, "Decode operation canceled" },
00091 { S_ENCODE_CANCEL, "Encode operation canceled" },
00092 { S_SCAN_CANCEL, "Scanning canceled" },
00093 { S_SIZE_MISMATCH, "%s: Decoded size (%ld) does not match expected size (%ld)" },
00094 { S_PSIZE_MISMATCH, "%s part %d: Decoded size (%ld) does not match expected size (%ld)" },
00095 { S_PART_MISSING, "%Part %d missing. Decoded file probably corrupt." },
00096 { S_CRC_MISMATCH, "CRC32 mismatch in %s. Decoded file probably corrupt." },
00097 { S_PCRC_MISMATCH, "PCRC32 mismatch in %s part %d. Decoded file probably corrupt." },
00098
00099
00100 { S_LOADED_PART, "Loaded from %s: '%s' (%s): %s part %d %s %s %s" },
00101 { S_NO_DATA_FOUND, "No encoded data found in %s" },
00102 { S_NO_BIN_FILE, "Oops, could not find decoded file?" },
00103 { S_STRIPPED_SETUID, "Stripped setuid/setgid bits from target file %s mode %d" },
00104 { S_DATA_SUSPICIOUS, "Data looks suspicious. Decoded file might be corrupt." },
00105 { S_NO_TEMP_NAME, "Could not get name for temporary file" },
00106 { S_BINHEX_SIZES, "BinHex file: data/resource fork sizes %ld/%ld" },
00107 { S_BINHEX_BOTH, "BinHex file: both forks non-empty, decoding data fork" },
00108 { S_SMERGE_MERGED, "Parts of '%s' merged with parts of '%s' (%d)" },
00109
00110
00111 { S_MIME_NO_BOUNDARY, "Multipart message without boundary ignored" },
00112 { S_MIME_B_NOT_FOUND, "Boundary expected on Multipart message but found EOF" },
00113 { S_MIME_MULTI_DEPTH, "Multipart message nested too deep" },
00114 { S_MIME_PART_MULTI, "Handling partial multipart message as plain text" },
00115 { S_OPEN_FILE, "Opened file %s" },
00116
00117 { 0, "" }
00118 };
00119
00120
00121
00122
00123
00124 char *uuretcodes[] = {
00125 "OK",
00126 "File I/O Error",
00127 "Not Enough Memory",
00128 "Illegal Value",
00129 "No Data found",
00130 "Unexpected End of File",
00131 "Unsupported function",
00132 "File exists",
00133 "Continue -- no error",
00134 "Operation Canceled"
00135 };
00136
00137
00138
00139
00140
00141 char *codenames[8] = {
00142 "", "UUdata", "Base64", "XXdata", "Binhex", "Text", "Text", "yEnc"
00143 };
00144
00145
00146
00147
00148
00149 char *msgnames[6] = {
00150 "", "Note: ", "Warning: ", "ERROR: ", "FATAL ERROR: ", "PANIC: "
00151 };
00152
00153
00154
00155
00156
00157
00158 char *
00159 uustring (int codeno)
00160 {
00161 static char * faileddef = "oops";
00162 stringmap *ptr = messages;
00163
00164 while (ptr->code) {
00165 if (ptr->code == codeno)
00166 return ptr->msg;
00167 ptr++;
00168 }
00169
00170 UUMessage (uustring_id, __LINE__, UUMSG_ERROR,
00171 "Could not retrieve string no %d",
00172 codeno);
00173
00174 return faileddef;
00175 }