Logo Search packages:      
Sourcecode: wireshark version File versions  Download package

gchar* xml_escape ( const gchar *  unescaped  ) 

Return a XML escaped representation of the unescaped string. The returned string must be freed when no longer in use.

Parameters:
unescaped The unescaped string
Returns:
An XML-escaped representation of the input string

Definition at line 766 of file strutil.c.

{
      GString *buffer = g_string_sized_new(128);
      const gchar *p;
      gchar c;

      p = unescaped;
      while ( (c = *p++) ) {
            switch (c) {
                  case '<':
                        g_string_append(buffer, "&lt;");
                        break;
                  case '>':
                        g_string_append(buffer, "&gt;");
                        break;
                  case '&':
                        g_string_append(buffer, "&amp;");
                        break;
                  case '\'':
                        g_string_append(buffer, "&apos;");
                        break;
                  case '"':
                        g_string_append(buffer, "&quot;");
                        break;
                  default:
                        g_string_append_c(buffer, c);
                        break;
            }
      }
      /* Return the string value contained within the GString
       * after getting rid of the GString structure.
       * This is the way to do this, see the GLib reference. */
      return g_string_free(buffer, FALSE);
}


Generated by  Doxygen 1.6.0   Back to index