ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uustring.c
Revision: 1.6
Committed: Sat Sep 24 06:02:04 2022 UTC (20 months, 1 week ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.5: +0 -2 lines
Log Message:
*** empty log message ***

File Contents

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