From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/header_8cpp-source.html | 334 +++++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 docs/doxygen/nel/header_8cpp-source.html (limited to 'docs/doxygen/nel/header_8cpp-source.html') diff --git a/docs/doxygen/nel/header_8cpp-source.html b/docs/doxygen/nel/header_8cpp-source.html new file mode 100644 index 00000000..a7fd1c62 --- /dev/null +++ b/docs/doxygen/nel/header_8cpp-source.html @@ -0,0 +1,334 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

header.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "stdgeorges.h"
+00027 
+00028 #include "header.h"
+00029 #include "nel/misc/thread.h"
+00030 #include "nel/misc/i_xml.h"
+00031 #include "nel/misc/common.h"
+00032 
+00033 using namespace NLMISC;
+00034 
+00035 namespace NLGEORGES
+00036 {
+00037 
+00038 // ***************************************************************************
+00039 
+00040 void warning (bool exception, const char *format, ... );
+00041 
+00042 // ***************************************************************************
+00043 
+00044 CFileHeader::CFileHeader ()
+00045 {
+00046         MajorVersion = 0;
+00047         MinorVersion = 0;
+00048         State = Modified;
+00049         Revision = "$R";
+00050         Revision += "evision$";
+00051 }
+00052 
+00053 // ***************************************************************************
+00054 
+00055 void CFileHeader::write (xmlNodePtr node, bool georges4CVS) const
+00056 {
+00057         // Version for CVS ?
+00058         if (georges4CVS)
+00059         {
+00060                 // Georges version system
+00061                 xmlSetProp (node, (const xmlChar*)"Revision", (const xmlChar*)Revision.c_str ());
+00062         }
+00063         else
+00064         {
+00065                 // Georges version system
+00066                 char tmp[512];
+00067                 smprintf (tmp, 512, "%d.%d", MajorVersion, MinorVersion);
+00068                 xmlSetProp (node, (const xmlChar*)"Version", (const xmlChar*)tmp);
+00069         }
+00070 
+00071         // State
+00072         if (State == Modified)
+00073                 xmlSetProp (node, (const xmlChar*)"State", (const xmlChar*)"modified");
+00074         else
+00075                 xmlSetProp (node, (const xmlChar*)"State", (const xmlChar*)"checked");
+00076 
+00077         // Comments of the form
+00078         if (!Comments.empty ())
+00079         {
+00080                 // Create a new node
+00081                 xmlNodePtr child = xmlNewChild ( node, NULL, (const xmlChar*)"COMMENTS", NULL);
+00082                 xmlNodePtr textNode = xmlNewText ((const xmlChar *)Comments.c_str());
+00083                 xmlAddChild (child, textNode);
+00084         }
+00085 
+00086         // Logs
+00087         if (!Log.empty ())
+00088         {
+00089                 // Create a new node
+00090                 xmlNodePtr child = xmlNewChild ( node, NULL, (const xmlChar*)"LOG", NULL);
+00091                 xmlNodePtr textNode = xmlNewText ((const xmlChar *)Log.c_str());
+00092                 xmlAddChild (child, textNode);
+00093         }
+00094 }
+00095 
+00096 // ***************************************************************************
+00097 
+00098 void CFileHeader::addLog (const char *log)
+00099 {
+00100         time_t t;
+00101         time (&t);
+00102         if (!Log.empty())
+00103                 Log += "\n";
+00104         Log += ctime(&t);
+00105         Log.resize (Log.size()-1);
+00106         Log += " (";
+00107         Log += IThread::getCurrentThread ()->getUserName ();
+00108         Log += ") ";
+00109         Log += log;
+00110 }
+00111 
+00112 // ***************************************************************************
+00113 
+00114 void CFileHeader::setComments (const char *comments)
+00115 {
+00116         Comments = comments;
+00117 }
+00118 
+00119 // ***************************************************************************
+00120 
+00121 void CFileHeader::read (xmlNodePtr root)
+00122 {
+00123         // Get the version
+00124         const char *value = (const char*)xmlGetProp (root, (xmlChar*)"Version");
+00125         if (value)
+00126         {
+00127                 // Read the version
+00128                 if (sscanf (value, "%d.%d", &MajorVersion, &MinorVersion) != 2)
+00129                 {
+00130                         // Delete the value
+00131                         xmlFree ((void*)value);
+00132 
+00133                         // Throw exception
+00134                         warning (true, "read", "XML Syntax error in TYPE block line %d, the Version argument is invalid.", 
+00135                                 (int)root->content);
+00136                 }
+00137 
+00138                 // Delete the value
+00139                 xmlFree ((void*)value);
+00140         }
+00141         else
+00142         {
+00143                 // Set default
+00144                 MajorVersion = 0;
+00145                 MinorVersion = 0;
+00146         }
+00147 
+00148         // Get the revision
+00149         value = (const char*)xmlGetProp (root, (xmlChar*)"Revision");
+00150         if (value)
+00151         {
+00152                 // Set the value
+00153                 Revision = value;
+00154 
+00155                 // Delete the value
+00156                 xmlFree ((void*)value);
+00157         }
+00158         else
+00159         {
+00160                 // Set default
+00161                 Revision = "$R";
+00162                 Revision += "evision$";
+00163         }
+00164 
+00165         // Get the version
+00166         value = (const char*)xmlGetProp (root, (xmlChar*)"State");
+00167         if (value)
+00168         {
+00169                 // Read the version
+00170                 if (strcmp (value, "modified") == 0)
+00171                 {
+00172                         State = Modified;
+00173                 }
+00174                 else if (strcmp (value, "checked") == 0)
+00175                 {
+00176                         State = Checked;
+00177                 }
+00178                 else 
+00179                 {
+00180                         // Delete the value
+00181                         xmlFree ((void*)value);
+00182 
+00183                         // Throw exception
+00184                         warning (true, "read", "XML Syntax error in TYPE block line %d, the State argument is invalid.", 
+00185                                 (int)root->content);
+00186                 }
+00187 
+00188                 // Delete the value
+00189                 xmlFree ((void*)value);
+00190         }
+00191         else
+00192         {
+00193                 // Set default
+00194                 State = Modified;
+00195         }
+00196 
+00197         // Look for the comment node
+00198         Comments = "";
+00199         xmlNodePtr node = CIXml::getFirstChildNode (root, "COMMENTS");
+00200         if (node)
+00201         {
+00202                 // Get a text node
+00203                 if (node = CIXml::getFirstChildNode (node, XML_TEXT_NODE))
+00204                 {
+00205                         // Get content
+00206                         const char *comments = (const char*)xmlNodeGetContent (node);
+00207                         if (comments)
+00208                         {
+00209                                 Comments = comments;
+00210 
+00211                                 // Delete the value
+00212                                 xmlFree ((void*)comments);
+00213                         }
+00214                 }
+00215         }
+00216 
+00217         // Look for the log node
+00218         Log = "";
+00219         node = CIXml::getFirstChildNode (root, "LOG");
+00220         if (node)
+00221         {
+00222                 // Get a text node
+00223                 if (node = CIXml::getFirstChildNode (node, XML_TEXT_NODE))
+00224                 {
+00225                         // Get content
+00226                         const char *log = (const char*)xmlNodeGetContent (node);
+00227                         if (log)
+00228                         {
+00229                                 Log = log;
+00230 
+00231                                 // Delete the value
+00232                                 xmlFree ((void*)log);
+00233                         }
+00234                 }
+00235         }
+00236 }
+00237 
+00238 // ***************************************************************************
+00239 
+00240 const char *CFileHeader::getStateString (TState state)
+00241 {
+00242         if (state == Modified)
+00243                 return "Modified";
+00244         else
+00245                 return "Checked";
+00246 }
+00247 
+00248 // ***************************************************************************
+00249 
+00250 void CFileHeader::warning (bool exception, const char *function, const char *format, ... ) const
+00251 {
+00252         // Make a buffer string
+00253         va_list args;
+00254         va_start( args, format );
+00255         char buffer[1024];
+00256         sint ret = vsnprintf( buffer, 1024, format, args );
+00257         va_end( args );
+00258 
+00259         // Set the warning
+00260         NLGEORGES::warning (exception, "(CFileHeader::%s) : %s", function, buffer);
+00261 }
+00262 
+00263 // ***************************************************************************
+00264 
+00265 } // NLGEORGES
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1