2001-05-23 15:26:42 +02:00
|
|
|
/*
|
2007-02-11 10:04:54 +01:00
|
|
|
* PROGRAM: Firebird Message file edit program
|
|
|
|
* MODULE: change_msgs.epp
|
2001-05-23 15:26:42 +02:00
|
|
|
* DESCRIPTION: Allow limited change of messages in database
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
2001-07-30 01:43:24 +02:00
|
|
|
#include "firebird.h"
|
2004-04-29 00:36:29 +02:00
|
|
|
#include <stdio.h>
|
2003-11-08 17:40:17 +01:00
|
|
|
#include "../jrd/ibase.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/common.h"
|
|
|
|
|
2001-07-12 08:32:05 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2001-08-01 10:11:52 +02:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
|
2002-11-25 17:14:13 +01:00
|
|
|
|
|
|
|
|
2003-03-17 13:06:48 +01:00
|
|
|
DATABASE DB = "msg.fdb";
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-18 18:32:07 +02:00
|
|
|
//#define FAC_SQL_POSITIVE 14
|
|
|
|
//#define FAC_SQL_NEGATIVE 13
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-18 18:32:07 +02:00
|
|
|
const char LOWER_A = 'a';
|
|
|
|
const char UPPER_A = 'A';
|
|
|
|
const char LOWER_Z = 'z';
|
|
|
|
const char UPPER_Z = 'Z';
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-11-10 05:26:45 +01:00
|
|
|
static void ascii_str_upper(char*);
|
|
|
|
static void explicit_print(const TEXT*);
|
2008-03-10 09:31:35 +01:00
|
|
|
static bool get_sql_class(char*);
|
|
|
|
static bool get_sql_subclass(char*);
|
2003-03-04 01:09:33 +01:00
|
|
|
#ifdef NOT_USED_OR_REPLACED
|
2008-03-10 09:31:35 +01:00
|
|
|
static bool get_symbol(char*);
|
2003-03-04 01:09:33 +01:00
|
|
|
#endif
|
2008-03-10 09:31:35 +01:00
|
|
|
static bool mustget(char*);
|
|
|
|
static bool translate(const char*, char*, SSHORT);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
2001-08-15 07:37:55 +02:00
|
|
|
int main( int argc, char **argv)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* m a i n
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
2008-12-21 00:50:22 +01:00
|
|
|
* Top level routine.
|
2001-05-23 15:26:42 +02:00
|
|
|
*
|
|
|
|
**************************************/
|
2009-07-20 14:44:11 +02:00
|
|
|
char facility[20], text[256];
|
|
|
|
BASED_ON MESSAGES.ROUTINE routine;
|
|
|
|
BASED_ON MESSAGES.MODULE module;
|
|
|
|
BASED_ON SYSTEM_ERRORS.SQL_CLASS sql_class;
|
|
|
|
BASED_ON SYSTEM_ERRORS.SQL_SUBCLASS sql_sub_class;
|
|
|
|
BASED_ON SYSTEM_ERRORS.GDS_SYMBOL symbol;
|
2008-03-10 09:31:35 +01:00
|
|
|
SCHAR input[200];
|
|
|
|
char yesno[100];
|
|
|
|
char nstring[32];
|
2001-05-23 15:26:42 +02:00
|
|
|
SSHORT count;
|
|
|
|
SSHORT sql_number;
|
|
|
|
SSHORT msg_number;
|
|
|
|
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("\nHit Ctrl-D (or Ctrl-Z) at prompt to exit level\n");
|
|
|
|
printf
|
2001-05-23 15:26:42 +02:00
|
|
|
("You will be prompted for facility, module, routine and message text\n");
|
2004-04-29 00:36:29 +02:00
|
|
|
printf
|
2001-05-23 15:26:42 +02:00
|
|
|
("You *must* enter module and routine names for each message; be prepared\n");
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("You may assign an optional symbol for the message\n");
|
|
|
|
printf
|
2001-05-23 15:26:42 +02:00
|
|
|
("Escape sequences may be entered and will be translated to single bytes\n");
|
|
|
|
|
|
|
|
READY;
|
|
|
|
START_TRANSACTION;
|
|
|
|
|
|
|
|
for (;;) {
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("Facility: ");
|
|
|
|
if (!gets(facility))
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
count = 0;
|
|
|
|
msg_number = 0;
|
2004-11-10 05:26:45 +01:00
|
|
|
ascii_str_upper(facility);
|
2001-05-23 15:26:42 +02:00
|
|
|
FOR X IN FACILITIES WITH X.FACILITY = facility
|
|
|
|
count++;
|
|
|
|
for (;;) {
|
2003-08-29 02:37:25 +02:00
|
|
|
bool sys_error = false;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("Message number (%d) ? ", msg_number + 1);
|
|
|
|
if (!gets(input))
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
if (!input[0])
|
|
|
|
msg_number++;
|
|
|
|
else
|
|
|
|
msg_number = atoi(input);
|
|
|
|
if (msg_number <= 0)
|
|
|
|
break;
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("Facility: %s\n", X.FACILITY);
|
2001-05-23 15:26:42 +02:00
|
|
|
FOR Y IN MESSAGES WITH
|
|
|
|
Y.FAC_CODE EQ X.FAC_CODE AND Y.NUMBER EQ msg_number;
|
|
|
|
|
2004-04-29 00:36:29 +02:00
|
|
|
printf(" Message: %d\n", Y.NUMBER);
|
|
|
|
printf(" Module: %s\n", Y.MODULE);
|
|
|
|
printf(" Routine: %s\n", Y.ROUTINE);
|
|
|
|
printf(" Text: ");
|
2001-05-23 15:26:42 +02:00
|
|
|
explicit_print(Y.TEXT);
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("\n");
|
|
|
|
printf(" Symbol: %s\n", Y.SYMBOL);
|
2001-05-23 15:26:42 +02:00
|
|
|
END_FOR
|
|
|
|
|
|
|
|
FOR Z IN SYSTEM_ERRORS WITH X.FAC_CODE EQ Z.FAC_CODE AND
|
|
|
|
Z.NUMBER EQ msg_number;
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("SQLCODE: %d\n", Z.SQL_CODE);
|
|
|
|
printf(" SQL_CLASS: %s\n", Z.SQL_CLASS);
|
|
|
|
printf("SQL_SUBCLASS: %s\n", Z.SQL_SUBCLASS);
|
2003-08-29 02:37:25 +02:00
|
|
|
sys_error = true;
|
2001-05-23 15:26:42 +02:00
|
|
|
END_FOR
|
|
|
|
|
2004-04-29 00:36:29 +02:00
|
|
|
printf(" Modify? ");
|
2001-05-23 15:26:42 +02:00
|
|
|
if (mustget(yesno) && (yesno[0] == 'y' || yesno[0] == 'Y')) {
|
|
|
|
module[0] = 0;
|
2004-04-29 00:36:29 +02:00
|
|
|
printf(" Module: ");
|
|
|
|
if (!gets(module))
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
routine[0] = 0;
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("Routine: ");
|
|
|
|
if (!gets(routine))
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
text[0] = 0;
|
2004-04-29 00:36:29 +02:00
|
|
|
printf(" Text: ");
|
|
|
|
if (!gets(text))
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
symbol[0] = 0;
|
2004-04-29 00:36:29 +02:00
|
|
|
printf(" Symbol: ");
|
|
|
|
if (!gets(symbol))
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
if (sys_error || X.FAC_CODE == 0) {
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("SQLCODE: ");
|
2001-05-23 15:26:42 +02:00
|
|
|
if (mustget(nstring))
|
|
|
|
sql_number = atoi(nstring);
|
|
|
|
if (!get_sql_class(sql_class))
|
|
|
|
/* continue */ ;
|
|
|
|
if (!get_sql_subclass(sql_sub_class))
|
|
|
|
/* continue */ ;
|
|
|
|
}
|
|
|
|
|
|
|
|
FOR Y IN MESSAGES WITH
|
|
|
|
Y.FAC_CODE EQ X.FAC_CODE AND Y.NUMBER EQ msg_number;
|
|
|
|
MODIFY Y USING
|
|
|
|
if (module[0])
|
2004-10-08 13:08:42 +02:00
|
|
|
strcpy(Y.MODULE, module);
|
2001-05-23 15:26:42 +02:00
|
|
|
if (routine[0])
|
2004-10-08 13:08:42 +02:00
|
|
|
strcpy(Y.ROUTINE, routine);
|
2001-05-23 15:26:42 +02:00
|
|
|
if (text[0])
|
2008-03-10 09:31:35 +01:00
|
|
|
while (!translate(text, Y.TEXT, sizeof(Y.TEXT)))
|
2004-11-10 05:26:45 +01:00
|
|
|
{
|
2004-04-29 00:36:29 +02:00
|
|
|
printf
|
2001-05-23 15:26:42 +02:00
|
|
|
("Message too long: max length: %d\n",
|
|
|
|
sizeof(Y.TEXT));
|
2003-08-28 15:07:29 +02:00
|
|
|
mustget(text);
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
if (symbol[0])
|
2004-10-08 13:08:42 +02:00
|
|
|
strcpy(Y.SYMBOL, symbol);
|
2001-05-23 15:26:42 +02:00
|
|
|
END_MODIFY;
|
|
|
|
END_FOR;
|
|
|
|
|
|
|
|
FOR Z IN SYSTEM_ERRORS WITH
|
|
|
|
Z.FAC_CODE EQ X.FAC_CODE AND Z.NUMBER EQ msg_number;
|
|
|
|
MODIFY Z USING
|
|
|
|
if (symbol[0])
|
2004-10-08 13:08:42 +02:00
|
|
|
strcpy(Z.GDS_SYMBOL, symbol);
|
2001-05-23 15:26:42 +02:00
|
|
|
if (sql_number != 0)
|
|
|
|
Z.SQL_CODE = sql_number;
|
|
|
|
if (sql_class[0])
|
2008-03-10 09:31:35 +01:00
|
|
|
strcpy(Z.SQL_CLASS, sql_class);
|
2001-05-23 15:26:42 +02:00
|
|
|
if (sql_sub_class[0])
|
2008-03-10 09:31:35 +01:00
|
|
|
strcpy(Z.SQL_SUBCLASS, sql_sub_class);
|
2001-05-23 15:26:42 +02:00
|
|
|
END_MODIFY;
|
|
|
|
END_FOR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
END_FOR;
|
|
|
|
if (!count) {
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("Facilty %s not found\n Known facilities are:\n",
|
2001-05-23 15:26:42 +02:00
|
|
|
facility);
|
|
|
|
FOR F IN FACILITIES SORTED BY F.FACILITY
|
2004-04-29 00:36:29 +02:00
|
|
|
printf(" %s\n", F.FACILITY);
|
2001-05-23 15:26:42 +02:00
|
|
|
END_FOR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("\n\nCommitting changes...");
|
2001-05-23 15:26:42 +02:00
|
|
|
COMMIT;
|
|
|
|
FINISH;
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("done.\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
exit(FINI_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-10 05:26:45 +01:00
|
|
|
static void ascii_str_upper( char* str)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* a s c i i _ s t r _ u p p e r
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* change a string to all upper case
|
|
|
|
*
|
|
|
|
**************************************/
|
|
|
|
|
|
|
|
while (*str) {
|
|
|
|
/* subtract 32 if necessary */
|
|
|
|
|
|
|
|
if (*str >= LOWER_A && *str <= LOWER_Z)
|
|
|
|
*str += (UPPER_A - LOWER_A);
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-10 05:26:45 +01:00
|
|
|
static void explicit_print( const TEXT* string)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* e x p l i c i t _ p r i n t
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* Let it all hang out: print line
|
|
|
|
* with explicit \n \b \t \f etc.
|
|
|
|
* to make changing messages easy
|
|
|
|
*
|
|
|
|
**************************************/
|
2004-11-10 05:26:45 +01:00
|
|
|
const TEXT* p = string;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2009-01-18 12:36:08 +01:00
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
switch (*p)
|
|
|
|
{
|
2001-05-23 15:26:42 +02:00
|
|
|
case '\n':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
|
|
|
putchar('n');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
case '\t':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
|
|
|
putchar('t');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
case '\f':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
|
|
|
putchar('f');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
case '\b':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
|
|
|
putchar('b');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
case '\r':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
|
|
|
putchar('r');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
case '\v':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
case '\\':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
|
|
|
putchar('\\');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
case '\"':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
|
|
|
putchar('\"');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
case '\'':
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar('\\');
|
|
|
|
putchar('\'');
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
default:
|
2004-04-29 00:36:29 +02:00
|
|
|
putchar(*p);
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
*p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-10 09:31:35 +01:00
|
|
|
static bool get_sql_class(char* sql_class)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* g e t _ s q l _ c l a s s
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* get a two character sql_class string
|
2003-08-29 02:37:25 +02:00
|
|
|
* return true if we get one, otherwise false
|
2001-05-23 15:26:42 +02:00
|
|
|
*
|
|
|
|
**************************************/
|
2004-11-10 05:26:45 +01:00
|
|
|
while (true) {
|
2004-04-29 00:36:29 +02:00
|
|
|
printf(" SQLCLASS: ");
|
2008-03-10 09:31:35 +01:00
|
|
|
gets(sql_class);
|
|
|
|
const SSHORT length = strlen(sql_class);
|
2001-05-23 15:26:42 +02:00
|
|
|
if (!length)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (length == 2)
|
2003-08-29 02:37:25 +02:00
|
|
|
return true;
|
2008-03-10 09:31:35 +01:00
|
|
|
|
|
|
|
fprintf(stderr, "Sqlclass is two characters!\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2003-08-29 02:37:25 +02:00
|
|
|
return false;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-10 09:31:35 +01:00
|
|
|
static bool get_sql_subclass(char* sql_sub_class)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* g e t _ s q l _ s u b c l a s s
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* get a three character sql_subclass string
|
2003-08-29 02:37:25 +02:00
|
|
|
* return true if we get one, otherwise false
|
2001-05-23 15:26:42 +02:00
|
|
|
*
|
|
|
|
**************************************/
|
2004-11-10 05:26:45 +01:00
|
|
|
while (true) {
|
2004-04-29 00:36:29 +02:00
|
|
|
printf("SQLSUBCLASS: ");
|
2008-03-10 09:31:35 +01:00
|
|
|
gets(sql_sub_class);
|
|
|
|
const SSHORT length = strlen(sql_sub_class);
|
2001-05-23 15:26:42 +02:00
|
|
|
if (!length)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (length == 3)
|
2003-08-29 02:37:25 +02:00
|
|
|
return true;
|
2008-03-10 09:31:35 +01:00
|
|
|
|
|
|
|
fprintf(stderr, "Sqlsubclass is three characters!\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2003-08-29 02:37:25 +02:00
|
|
|
return false;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2003-03-04 01:09:33 +01:00
|
|
|
#ifdef NOT_USED_OR_REPLACED
|
2008-03-10 09:31:35 +01:00
|
|
|
static bool get_symbol(char* symbol)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* g e t _ s y m b o l
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* insist on getting the symbol
|
2003-08-29 02:37:25 +02:00
|
|
|
* return true when we get one
|
2001-05-23 15:26:42 +02:00
|
|
|
*
|
|
|
|
**************************************/
|
2003-08-29 02:37:25 +02:00
|
|
|
while (true) {
|
2004-04-29 00:36:29 +02:00
|
|
|
fprintf(stderr, "Symbols are required for system errors!\n");
|
|
|
|
printf(" Symbol: ");
|
2008-03-10 09:31:35 +01:00
|
|
|
gets(symbol);
|
|
|
|
if (strlen(symbol))
|
2003-08-29 02:37:25 +02:00
|
|
|
return true;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
}
|
2003-03-04 01:09:33 +01:00
|
|
|
#endif
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2008-03-10 09:31:35 +01:00
|
|
|
static bool mustget(char* s)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* m u s t g e t
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
2003-08-29 02:37:25 +02:00
|
|
|
* gets & returns a string. Returns false
|
2001-05-23 15:26:42 +02:00
|
|
|
* if string is empty.
|
|
|
|
*
|
|
|
|
**************************************/
|
|
|
|
|
2008-03-10 09:31:35 +01:00
|
|
|
if (!gets(s))
|
2003-08-29 02:37:25 +02:00
|
|
|
return false;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
return (s[0] != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-10 09:31:35 +01:00
|
|
|
static bool translate(const char* source, char* target, SSHORT length)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* t r a n s l a t e
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* make explicit escape sequences into
|
|
|
|
* ascii, returns length ok?
|
|
|
|
*
|
|
|
|
**************************************/
|
2004-11-10 05:26:45 +01:00
|
|
|
SCHAR* p = target;
|
|
|
|
const SCHAR* q = source;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2009-01-18 12:36:08 +01:00
|
|
|
while (*q)
|
|
|
|
{
|
2001-05-23 15:26:42 +02:00
|
|
|
if (!--length)
|
2004-11-10 05:26:45 +01:00
|
|
|
return false;
|
2008-03-10 09:31:35 +01:00
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
if (*q == '\\') {
|
|
|
|
*q++;
|
2009-01-18 12:36:08 +01:00
|
|
|
switch (*q)
|
|
|
|
{
|
2001-05-23 15:26:42 +02:00
|
|
|
case 'n':
|
|
|
|
*p++ = '\n';
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
*p++ = '\t';
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
*p++ = '\f';
|
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
*p++ = '\a';
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
*p++ = '\b';
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
*p++ = '\r';
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
*p++ = '\v';
|
|
|
|
break;
|
|
|
|
case '\\':
|
|
|
|
*p++ = '\\';
|
|
|
|
break;
|
|
|
|
case '\"':
|
|
|
|
*p++ = '\"';
|
|
|
|
break;
|
|
|
|
case '\'':
|
|
|
|
*p++ = '\'';
|
|
|
|
break;
|
|
|
|
default:
|
2004-04-29 00:36:29 +02:00
|
|
|
printf
|
2001-05-23 15:26:42 +02:00
|
|
|
("\n\n*** Escape sequence not understood; being copied unchanged ***\n\n");
|
|
|
|
*p++ = '\\';
|
|
|
|
*p++ = *q;
|
|
|
|
}
|
|
|
|
*q++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*p++ = *q++;
|
|
|
|
}
|
|
|
|
*p = 0;
|
|
|
|
|
2004-11-10 05:26:45 +01:00
|
|
|
return true;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2004-11-10 05:26:45 +01:00
|
|
|
|