ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uustring.c
Revision: 1.2.2.3
Committed: Sun Oct 13 13:03:09 2002 UTC (21 years, 7 months ago) by root
Content type: text/plain
Branch: UUDEVIEW
CVS Tags: UUDEVIEW-0-5-18
Changes since 1.2.2.2: +5 -1 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
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 #include <uudeview.h>
50 #include <uuint.h>
51 #include <uustring.h>
52
53 char * uustring_id = "$Id: uustring.c,v 1.8 2002/03/11 09:15:47 fp Exp $";
54
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 { S_SIZE_MISMATCH, "%s: Decoded size (%ld) does not match expected size (%ld)" },
90 { S_PSIZE_MISMATCH, "%s part %d: Decoded size (%ld) does not match expected size (%ld)" },
91 { S_CRC_MISMATCH, "CRC32 mismatch in %s. Decoded file probably corrupt." },
92 { S_PCRC_MISMATCH, "PCRC32 mismatch in %s part %d. Decoded file probably corrupt." },
93
94 /* informational messages */
95 { S_LOADED_PART, "Loaded from %s: '%s' (%s): %s part %d %s %s %s" },
96 { S_NO_DATA_FOUND, "No encoded data found in %s" },
97 { S_NO_BIN_FILE, "Oops, could not find decoded file?" },
98 { S_STRIPPED_SETUID, "Stripped setuid/setgid bits from target file %s mode %d" },
99 { S_DATA_SUSPICIOUS, "Data looks suspicious. Decoded file might be corrupt." },
100 { S_NO_TEMP_NAME, "Could not get name for temporary file" },
101 { S_BINHEX_SIZES, "BinHex file: data/resource fork sizes %ld/%ld" },
102 { S_BINHEX_BOTH, "BinHex file: both forks non-empty, decoding data fork" },
103 { S_SMERGE_MERGED, "Parts of '%s' merged with parts of '%s' (%d)" },
104
105 /* MIME-related messages */
106 { S_MIME_NO_BOUNDARY, "Multipart message without boundary ignored" },
107 { S_MIME_B_NOT_FOUND, "Boundary expected on Multipart message but found EOF" },
108 { S_MIME_MULTI_DEPTH, "Multipart message nested too deep" },
109 { S_MIME_PART_MULTI, "Handling partial multipart message as plain text" },
110
111 { 0, "" }
112 };
113
114 /*
115 * description of the return values UURET_*
116 */
117
118 char *uuretcodes[] = {
119 "OK",
120 "File I/O Error",
121 "Not Enough Memory",
122 "Illegal Value",
123 "No Data found",
124 "Unexpected End of File",
125 "Unsupported function",
126 "File exists",
127 "Continue -- no error", /* only to be seen internally */
128 "Operation Canceled"
129 };
130
131 /*
132 * Names of encoding types
133 */
134
135 char *codenames[8] = {
136 "", "UUdata", "Base64", "XXdata", "Binhex", "Text", "Text", "yEnc"
137 };
138
139 /*
140 * Message types
141 */
142
143 char *msgnames[6] = {
144 "", "Note: ", "Warning: ", "ERROR: ", "FATAL ERROR: ", "PANIC: "
145 };
146
147 /*
148 * Retrieve one of the messages. We never return NULL
149 * but instead escape to "oops".
150 */
151
152 char *
153 uustring (int codeno)
154 {
155 static char * faileddef = "oops";
156 stringmap *ptr = messages;
157
158 while (ptr->code) {
159 if (ptr->code == codeno)
160 return ptr->msg;
161 ptr++;
162 }
163
164 UUMessage (uustring_id, __LINE__, UUMSG_ERROR,
165 "Could not retrieve string no %d",
166 codeno);
167
168 return faileddef;
169 }