/* Copyright (C) 2003 by NCR Corporation. All Rights Reserved. NCR CONFIDENTIAL AND TRADE SECRET */ #define SQL_TEXT Latin_Text #include "sqltypes_td.h" #include #include #define MAX_STRING_LENGTH 256 #define IsNull -1 #define IsNotNull 0 #define NoSqlError "00000" void oreplace1(VARCHAR_LATIN *inputStr, VARCHAR_LATIN *inputFrom, VARCHAR_LATIN *result, int *inputStrIsNull, int *inputFromIsNull, int *resultIsNull, char sqlstate[6], SQL_TEXT extname[129], SQL_TEXT specific_name[129], SQL_TEXT error_message[257]) { int linputFrom; char *pinputStr; /* Initiate return values */ strcpy(sqlstate, NoSqlError); strcpy((char *) error_message, " "); *resultIsNull = IsNotNull; *result = '\0'; if (*inputStrIsNull == IsNull) { strcpy(sqlstate, "22004") ; strcpy((char *) error_message, "First argument cannot be null.") ; *resultIsNull = IsNull; return; } if (*inputFromIsNull == IsNull || (linputFrom=strlen((const char *)inputFrom)) == 0) { strcpy((char *)result, (const char *)inputStr); return; } /* Replace */ for (pinputStr = (char *)inputStr; *pinputStr != '\0'; ) { if (strncmp((const char *)pinputStr,(const char *)inputFrom,linputFrom) == 0) { strncat((char *)result, (const char *)inputStr, (int)(pinputStr-(char *)inputStr)); pinputStr = (char *)inputStr = pinputStr + linputFrom; } else { ++pinputStr; } } strcat((char *)result,(const char *)inputStr); }