2
* PROGRAM: Firebird Message file edit program
3
* MODULE: change_msgs.epp
4
* DESCRIPTION: Allow limited change of messages in database
6
* The contents of this file are subject to the Interbase Public
7
* License Version 1.0 (the "License"); you may not use this file
8
* except in compliance with the License. You may obtain a copy
9
* of the License at http://www.Inprise.com/IPL.html
11
* Software distributed under the License is distributed on an
12
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
13
* or implied. See the License for the specific language governing
14
* rights and limitations under the License.
16
* The Original Code was created by Inprise Corporation
17
* and its predecessors. Portions created by Inprise Corporation are
18
* Copyright (C) Inprise Corporation.
20
* All Rights Reserved.
21
* Contributor(s): ______________________________________.
26
#include "../jrd/ibase.h"
27
#include "../jrd/common.h"
37
DATABASE DB = "msg.fdb";
39
//#define FAC_SQL_POSITIVE 14
40
//#define FAC_SQL_NEGATIVE 13
42
const char LOWER_A = 'a';
43
const char UPPER_A = 'A';
44
const char LOWER_Z = 'z';
45
const char UPPER_Z = 'Z';
47
static void ascii_str_upper(char*);
48
static void explicit_print(const TEXT*);
49
static bool get_sql_class(UCHAR *);
50
static bool get_sql_subclass(UCHAR *);
51
#ifdef NOT_USED_OR_REPLACED
52
static bool get_symbol(UCHAR *);
54
static bool mustget(SCHAR *);
55
static bool translate(const SCHAR*, SCHAR*, SSHORT);
58
int main( int argc, char **argv)
60
/**************************************
64
**************************************
66
* Functional description
69
**************************************/
70
char facility[20], text[256], module[32], routine[32];
71
UCHAR sql_class[32], sql_sub_class[32];
72
SCHAR input[200], yesno[100];
79
printf("\nHit Ctrl-D (or Ctrl-Z) at prompt to exit level\n");
81
("You will be prompted for facility, module, routine and message text\n");
83
("You *must* enter module and routine names for each message; be prepared\n");
84
printf("You may assign an optional symbol for the message\n");
86
("Escape sequences may be entered and will be translated to single bytes\n");
97
ascii_str_upper(facility);
98
FOR X IN FACILITIES WITH X.FACILITY = facility
101
bool sys_error = false;
103
printf("Message number (%d) ? ", msg_number + 1);
109
msg_number = atoi(input);
112
printf("Facility: %s\n", X.FACILITY);
113
FOR Y IN MESSAGES WITH
114
Y.FAC_CODE EQ X.FAC_CODE AND Y.NUMBER EQ msg_number;
116
printf(" Message: %d\n", Y.NUMBER);
117
printf(" Module: %s\n", Y.MODULE);
118
printf(" Routine: %s\n", Y.ROUTINE);
120
explicit_print(Y.TEXT);
122
printf(" Symbol: %s\n", Y.SYMBOL);
125
FOR Z IN SYSTEM_ERRORS WITH X.FAC_CODE EQ Z.FAC_CODE AND
126
Z.NUMBER EQ msg_number;
127
printf("SQLCODE: %d\n", Z.SQL_CODE);
128
printf(" SQL_CLASS: %s\n", Z.SQL_CLASS);
129
printf("SQL_SUBCLASS: %s\n", Z.SQL_SUBCLASS);
134
if (mustget(yesno) && (yesno[0] == 'y' || yesno[0] == 'Y')) {
151
if (sys_error || X.FAC_CODE == 0) {
153
if (mustget(nstring))
154
sql_number = atoi(nstring);
155
if (!get_sql_class(sql_class))
157
if (!get_sql_subclass(sql_sub_class))
161
FOR Y IN MESSAGES WITH
162
Y.FAC_CODE EQ X.FAC_CODE AND Y.NUMBER EQ msg_number;
165
strcpy(Y.MODULE, module);
167
strcpy(Y.ROUTINE, routine);
170
(text, Y.TEXT, sizeof(Y.TEXT)))
173
("Message too long: max length: %d\n",
178
strcpy(Y.SYMBOL, symbol);
182
FOR Z IN SYSTEM_ERRORS WITH
183
Z.FAC_CODE EQ X.FAC_CODE AND Z.NUMBER EQ msg_number;
186
strcpy(Z.GDS_SYMBOL, symbol);
188
Z.SQL_CODE = sql_number;
190
strcpy(Z.SQL_CLASS, (char*) sql_class);
191
if (sql_sub_class[0])
192
strcpy(Z.SQL_SUBCLASS, (char*) sql_sub_class);
199
printf("Facilty %s not found\n Known facilities are:\n",
201
FOR F IN FACILITIES SORTED BY F.FACILITY
202
printf(" %s\n", F.FACILITY);
207
printf("\n\nCommitting changes...");
216
static void ascii_str_upper( char* str)
218
/**************************************
220
* a s c i i _ s t r _ u p p e r
222
**************************************
224
* Functional description
225
* change a string to all upper case
227
**************************************/
230
/* subtract 32 if necessary */
232
if (*str >= LOWER_A && *str <= LOWER_Z)
233
*str += (UPPER_A - LOWER_A);
239
static void explicit_print( const TEXT* string)
241
/**************************************
243
* e x p l i c i t _ p r i n t
245
**************************************
247
* Functional description
248
* Let it all hang out: print line
249
* with explicit \n \b \t \f etc.
250
* to make changing messages easy
252
**************************************/
253
const TEXT* p = string;
300
static bool get_sql_class( UCHAR * sql_class)
302
/**************************************
304
* g e t _ s q l _ c l a s s
306
**************************************
308
* Functional description
309
* get a two character sql_class string
310
* return true if we get one, otherwise false
312
**************************************/
314
printf(" SQLCLASS: ");
315
gets((char*) sql_class);
316
const SSHORT length = strlen((char*) sql_class);
323
fprintf(stderr, "Sqlclass is two characters!\n");
330
static bool get_sql_subclass( UCHAR * sql_sub_class)
332
/**************************************
334
* g e t _ s q l _ s u b c l a s s
336
**************************************
338
* Functional description
339
* get a three character sql_subclass string
340
* return true if we get one, otherwise false
342
**************************************/
344
printf("SQLSUBCLASS: ");
345
gets((char*) sql_sub_class);
346
const SSHORT length = strlen((char*) sql_sub_class);
353
fprintf(stderr, "Sqlsubclass is three characters!\n");
358
#ifdef NOT_USED_OR_REPLACED
359
static bool get_symbol( UCHAR * symbol)
361
/**************************************
363
* g e t _ s y m b o l
365
**************************************
367
* Functional description
368
* insist on getting the symbol
369
* return true when we get one
371
**************************************/
373
fprintf(stderr, "Symbols are required for system errors!\n");
375
gets((char*) symbol);
376
if (strlen((char*) symbol))
382
static bool mustget( SCHAR * s)
384
/**************************************
388
**************************************
390
* Functional description
391
* gets & returns a string. Returns false
392
* if string is empty.
394
**************************************/
396
if (!gets((char*) s))
403
static bool translate( const SCHAR* source, SCHAR* target, SSHORT length)
405
/**************************************
409
**************************************
411
* Functional description
412
* make explicit escape sequences into
413
* ascii, returns length ok?
415
**************************************/
417
const SCHAR* q = source;
457
("\n\n*** Escape sequence not understood; being copied unchanged ***\n\n");