src/xmlutils.cxx

00001 
00018 /***************************************************************************
00019  *            xmlutils.cxx
00020  *
00021  *  Wed Jan 30 14:13:20 2008
00022  *  Copyright  2008  Peter L. Berghold
00023  *  <Peter@Berghold.net>
00024  ****************************************************************************/
00025 
00026 /*
00027  * This program is free software; you can redistribute it and/or modify
00028  * it under the terms of the GNU General Public License as published by
00029  * the Free Software Foundation; either version 2 of the License, or
00030  * (at your option) any later version.
00031  * 
00032  * This program is distributed in the hope that it will be useful,
00033  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00034  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00035  * GNU Library General Public License for more details.
00036  * 
00037  * You should have received a copy of the GNU General Public License
00038  * along with this program; if not, write to the Free Software
00039  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
00040  */
00041 #include "xmlutils.hpp"
00042 #include <string.h>
00043 #include <malloc.h>
00044 #include <stdio.h>
00045 
00046 char* addXMLElement(char *s,char *e,char *v){
00047         char *buffer;
00048         char *start = createStartElement(e);
00049         char *end = createEndElement(e);
00050         
00051         buffer = (char*) malloc( strlen(s) + 1 + 
00052                                                          + 2 +           
00053                                                          strlen(start) + 
00054                                                          strlen(v)     + 
00055                                                          strlen(end)   + 
00056                                                          + 2             
00057                                                         );
00058         sprintf(buffer,"%s\n\t\t%s%s%s\n",s,start,v,end);
00059         return buffer;
00060 }
00061 
00062         
00063 
00064 
00065 char* createStartElement(char *e){
00066         char *buffer;
00067         
00068         buffer = (char*) malloc(strlen(e)+4);
00069         buffer[0]='\0';
00070         sprintf(buffer,"<%s>",e);
00071         
00072         return buffer;
00073 }
00074 
00075 char* createEndElement(char *e){
00076         char* buffer;
00077         
00078         buffer=(char*) malloc(strlen(e)+6);
00079         buffer[0]='\0';
00080         sprintf(buffer,"</%s>",e);
00081         
00082         return buffer;
00083 }
00084 
00085 
00086         

Generated on Fri Mar 7 16:40:53 2008 for frpuniverse by  doxygen 1.4.7