+
+/**************************************************************************
+** (c) Copyright 2003, Andromeda Technology & Automation
+** This is free software; you can redistribute it and/or modify it under the
+** terms of the GNU General Public License, see the file COPYING.
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+** FILE NAME : string_utils.cpp
+** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
+** VERSION NUMBER : $Revision: 1.1 $
+**
+** DESCRIPTION : Utility functions for Strings
+**
+** EXPORTED OBJECTS :
+** LOCAL OBJECTS :
+** MODULES USED :
+***************************************************************************
+** ADMINISTRATIVE INFORMATION *
+********************************
+** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
+** CREATION DATE : Jul 31, 2003
+** LAST UPDATE : Jul 31, 2003
+** MODIFICATIONS :
+**************************************************************************/
+
+/*****************************
+ $Log: string_utils.cpp,v $
+ Revision 1.1 2003-08-05 08:15:01 arjen
+ Debug output to the log stream instead of cerr.
+ Fixed namespace problems in XPath searches of the DOM.
+ Moved string utility functions to a separate file.
+
+*****************************/
+
+static const char *RCSID = "$Id: string_utils.cpp,v 1.1 2003-08-05 08:15:01 arjen Exp $";
+
+#include <AXE/String.h>
+
+/*=========================================================================
+** NAME : SQL_Escape
+** SYNOPSIS : String SQL_Escape(String)
+** PARAMETERS :
+** RETURN VALUE :
+**
+** DESCRIPTION : Insert backslashes before single quotes.
+**
+** VARS USED :
+** VARS CHANGED :
+** FUNCTIONS USED :
+** SEE ALSO :
+** LAST MODIFIED :
+**=========================================================================
+*/
+
+String SQL_Escape(String s)
+{
+ int i;
+
+ for (i = 0; i < ~s; i++)
+ {
+ if (s[i] == '\'')
+ {
+ s(i,0) = "\\";
+ i++;
+ }
+ }
+
+ return s;
+}
+
+/*=========================================================================
+** NAME : XML_Entities
+** SYNOPSIS : String XML_Entities(String)
+** PARAMETERS :
+** RETURN VALUE :
+**
+** DESCRIPTION : Replace special characters for XML with their entity codes:
+** "<" => "<"
+** ">" => ">"
+** "&" => "&"
+**
+** VARS USED :
+** VARS CHANGED :
+** FUNCTIONS USED :
+** SEE ALSO :
+** LAST MODIFIED :
+**=========================================================================
+*/
+
+String XML_Entities(String s)
+{
+ int i;
+
+ for (i = 0; i < ~s; i++)
+ {
+ switch (s[i])
+ {
+ case '&':
+ s(i,1) = "&";
+ i++;
+ break;
+ case '<':
+ s(i,1) = "<";
+ i++;
+ break;
+ case '>':
+ s(i,1) = ">";
+ i++;
+ break;
+ }
+ }
+
+ return s;
+}