ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uustring.c
Revision: 1.8
Committed: Sat Sep 24 06:22:47 2022 UTC (19 months, 3 weeks ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +1 -9 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 /*
2 * This file is part of uudeview, the simple and friendly multi-part multi-
3 * file uudecoder program (c) 1994-2001 by Frank Pilhofer. The author may
4 * be contacted at fp@fpx.de
5 *
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 #include <stdlib.h>
35 #include <string.h>
36
37 #ifdef HAVE_UNISTD_H
38 #include <unistd.h>
39 #endif
40
41 #include <uudeview.h>
42 #include <uuint.h>
43 #include <uustring.h>
44
45 typedef struct {
46 int code;
47 char * msg;
48 } stringmap;
49
50 /*
51 * Map of messages. This table is not exported, the messages must
52 * be retrieved via the below uustring() function.
53 */
54
55 static stringmap messages[] = {
56 /* I/O related errors/messages. Last parameter is strerror() */
57 { S_NOT_OPEN_SOURCE, "Could not open source file %s: %s" },
58 { S_NOT_OPEN_TARGET, "Could not open target file %s for writing: %s" },
59 { S_NOT_OPEN_FILE, "Could not open file %s: %s" },
60 { S_NOT_STAT_FILE, "Could not stat file %s: %s" },
61 { S_SOURCE_READ_ERR, "Read error on source file: %s" },
62 { S_READ_ERROR, "Error reading from %s: %s" },
63 { S_IO_ERR_TARGET, "I/O error on target file %s: %s" },
64 { S_WR_ERR_TARGET, "Write error on target file %s: %s" },
65 { S_WR_ERR_TEMP, "Write error on temp file: %s" },
66 { S_TMP_NOT_REMOVED, "Could not remove temp file %s: %s (ignored)" },
67
68 /* some other problems */
69 { S_OUT_OF_MEMORY, "Out of memory allocating %d bytes" },
70 { S_TARGET_EXISTS, "Target file %s exists and overwriting is not allowed" },
71 { S_NOT_RENAME, "Could not change name of %s to %s" },
72 { S_ERR_ENCODING, "Error while encoding %s: %s" },
73 { S_STAT_ONE_PART, "Could not stat input, encoding to one part only" },
74 { S_PARM_CHECK, "Parameter check failed in %s" },
75 { S_SHORT_BINHEX, "BinHex encoded file %s ended prematurely (%ld bytes left)" },
76 { S_DECODE_CANCEL, "Decode operation canceled" },
77 { S_ENCODE_CANCEL, "Encode operation canceled" },
78 { S_SCAN_CANCEL, "Scanning canceled" },
79 { S_SIZE_MISMATCH, "%s: Decoded size (%ld) does not match expected size (%ld)" },
80 { S_PSIZE_MISMATCH, "%s part %d: Decoded size (%ld) does not match expected size (%ld)" },
81 { S_CRC_MISMATCH, "CRC32 mismatch in %s. Decoded file probably corrupt." },
82 { S_PCRC_MISMATCH, "PCRC32 mismatch in %s part %d. Decoded file probably corrupt." },
83
84 /* informational messages */
85 { S_LOADED_PART, "Loaded from %s: '%s' (%s): %s part %d %s %s %s" },
86 { S_NO_DATA_FOUND, "No encoded data found in %s" },
87 { S_NO_BIN_FILE, "Oops, could not find decoded file?" },
88 { S_STRIPPED_SETUID, "Stripped setuid/setgid bits from target file %s mode %d" },
89 { S_DATA_SUSPICIOUS, "Data looks suspicious. Decoded file might be corrupt." },
90 { S_NO_TEMP_NAME, "Could not get name for temporary file" },
91 { S_BINHEX_SIZES, "BinHex file: data/resource fork sizes %ld/%ld" },
92 { S_BINHEX_BOTH, "BinHex file: both forks non-empty, decoding data fork" },
93 { S_SMERGE_MERGED, "Parts of '%s' merged with parts of '%s' (%d)" },
94
95 /* MIME-related messages */
96 { S_MIME_NO_BOUNDARY, "Multipart message without boundary ignored" },
97 { S_MIME_B_NOT_FOUND, "Boundary expected on Multipart message but found EOF" },
98 { S_MIME_MULTI_DEPTH, "Multipart message nested too deep" },
99 { S_MIME_PART_MULTI, "Handling partial multipart message as plain text" },
100
101 { 0, "" }
102 };
103
104 /*
105 * description of the return values UURET_*
106 */
107
108 char *uuretcodes[] = {
109 "OK",
110 "File I/O Error",
111 "Not Enough Memory",
112 "Illegal Value",
113 "No Data found",
114 "Unexpected End of File",
115 "Unsupported function",
116 "File exists",
117 "Continue -- no error", /* only to be seen internally */
118 "Operation Canceled"
119 };
120
121 /*
122 * Names of encoding types
123 */
124
125 char *codenames[8] = {
126 "", "UUdata", "Base64", "XXdata", "Binhex", "Text", "Text", "yEnc"
127 };
128
129 /*
130 * Message types
131 */
132
133 char *msgnames[6] = {
134 "", "Note: ", "Warning: ", "ERROR: ", "FATAL ERROR: ", "PANIC: "
135 };
136
137 /*
138 * Retrieve one of the messages. We never return NULL
139 * but instead escape to "oops".
140 */
141
142 char *
143 uustring (int codeno)
144 {
145 static char * faileddef = "oops";
146 stringmap *ptr = messages;
147
148 while (ptr->code) {
149 if (ptr->code == codeno)
150 return ptr->msg;
151 ptr++;
152 }
153
154 UUMessage (UUMSG_ERROR, "Could not retrieve string no %d", codeno);
155
156 return faileddef;
157 }