File libidmef-1.0.2_parser_fatal_error_handling.diff of Package libidmef

--- libidmef-1.0.2/src/parser.c.bak	2009-08-12 07:49:07.000000000 +0200
+++ libidmef-1.0.2/src/parser.c	2009-08-12 08:26:11.000000000 +0200
@@ -25,6 +25,9 @@
 #  define dgettext(Domain, String) (String)
 #endif
 
+#include <errno.h>
+extern int errno;
+
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -501,7 +504,7 @@
 static void idmef_parser_characters (SAXParserState *state, const xmlChar *chars, int len);
 static void idmef_parser_warning (SAXParserState *state, const char *msg, ...);
 static void idmef_parser_error (SAXParserState *state, const char *msg, ...);
-static void idmef_parser_fatal_error (SAXParserState *state, const char *msg, ...);
+static  int idmef_parser_fatal_error (SAXParserState *state, int errn, const char *msg, ...);
 
 
 static xmlSAXHandler IDMEFHandler =
@@ -696,7 +699,10 @@
   state->analyzer_count = 0;
 
   if (!(state->content = (char*)calloc(sizeof(char), 128)))
-    idmef_parser_fatal_error (NULL, "Memory exhausted! Exiting ...");
+  {
+    idmef_parser_fatal_error (NULL, errno, "Memory exhausted! Exiting ...");
+    return;
+  }
   
 //  state->idmefp    = NULL;
 
@@ -741,13 +747,13 @@
           state->msg = i_new0 (IDMEFmessage, 1);
           
           if (!state->msg)
-            idmef_parser_fatal_error (NULL,
+            return idmef_parser_fatal_error (NULL, ENOMEM,
                     "idmef-parser: Cannot allocate memory (msg)! Exiting ...");
           
           state->msg->attlist = i_new0 (IDMEFattlist_global, 1);
           
           if (!state->msg->attlist)
-            idmef_parser_fatal_error (NULL,
+            return idmef_parser_fatal_error (NULL, ENOMEM,
                      "idmef-parser: Cannot allocate memory (attlist)! Exiting ...");
           
 	  for (i = 0; attrs && attrs[i] != NULL; i += 2)
@@ -913,13 +919,13 @@
           ptr = i_renew (IDMEFalert*, msg->alerts,
           			 msg->nalerts);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           msg->alerts = ptr;
           msg->alerts[msg->nalerts-1] = i_new0 (IDMEFalert, 1);
 	  
           if (!msg->alerts[msg->nalerts-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -988,13 +994,13 @@
           ptr = i_renew (IDMEFheartbeat*, msg->heartbeats,
           			     msg->nheartbeats);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           msg->heartbeats = ptr;
           msg->heartbeats[msg->nheartbeats-1] = i_new0 (IDMEFheartbeat, 1);
 
           if (!msg->heartbeats[msg->nheartbeats-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1063,13 +1069,13 @@
           ptr = i_renew (IDMEFasset*, msg->assets,
           			 msg->nassets);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           msg->assets = ptr;
           msg->assets[msg->nassets-1] = i_new0 (IDMEFasset, 1);
 	  
           if (!msg->assets[msg->nassets-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1156,7 +1162,7 @@
           alert->analyzer = i_new0 (IDMEFanalyzer, 1);
 
           if (!alert->analyzer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1403,7 +1409,7 @@
           alert->createtime = i_new0 (IDMEFtime, 1);
 
           if (!alert->createtime)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1459,7 +1465,7 @@
           alert->classification = i_new0 (IDMEFclassification, 1);
 
           if (!alert->classification)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1541,7 +1547,7 @@
           alert->detecttime = i_new0 (IDMEFtime, 1);
 
           if (!alert->detecttime)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1598,7 +1604,7 @@
           alert->analyzertime = i_new0 (IDMEFtime, 1);
 
           if (!alert->analyzertime)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1656,13 +1662,13 @@
           ptr = i_renew (IDMEFsource*, alert->sources,
           			    alert->nsources);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           alert->sources = ptr;
           alert->sources[alert->nsources-1] = i_new0 (IDMEFsource, 1);
 
           if (!alert->sources[alert->nsources-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1771,13 +1777,13 @@
           ptr = i_renew (IDMEFtarget*, alert->targets,
           			    alert->ntargets);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           alert->targets = ptr;
 	  alert->targets[alert->ntargets-1] = i_new0 (IDMEFtarget, 1);
 
           if (!alert->targets[alert->ntargets-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -1886,7 +1892,7 @@
           alert->assessment = i_new0 (IDMEFassessment, 1);
 
           if (!alert->assessment)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -1917,14 +1923,14 @@
                                      alert->additionaldatas,
           			     alert->nadditionaldatas);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           alert->additionaldatas = ptr;
           alert->additionaldatas[alert->nadditionaldatas-1] =
             i_new0 (IDMEFadditionaldata, 1);
           
           if (!alert->additionaldatas[alert->nadditionaldatas-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
           if (state->gen_idmefp)
@@ -2011,7 +2017,7 @@
           alert->toolalert = i_new0 (IDMEFtoolalert, 1);
 
           if (!alert->toolalert)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -2039,7 +2045,7 @@
           alert->overflowalert = i_new0 (IDMEFoverflowalert, 1);
 
           if (!alert->overflowalert)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -2068,7 +2074,7 @@
           alert->correlationalert = i_new0 (IDMEFcorrelationalert, 1);
 
           if (!alert->correlationalert)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -2115,7 +2121,7 @@
           additionaldata->boolean = i_new0 (IDMEFboolean, 1);
 
           if (!additionaldata->boolean)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2144,7 +2150,7 @@
           additionaldata->byte = i_new0 (IDMEFbyte, 1);
 
           if (!additionaldata->byte)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2173,7 +2179,7 @@
           additionaldata->character = i_new0 (IDMEFcharacter, 1);
 
           if (!additionaldata->character)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2202,7 +2208,7 @@
           additionaldata->date_time = i_new0 (IDMEFdate_time, 1);
 
           if (!additionaldata->date_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2231,7 +2237,7 @@
           additionaldata->integer = i_new0 (IDMEFinteger, 1);
 
           if (!additionaldata->integer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2260,7 +2266,7 @@
           additionaldata->ntpstamp = i_new0 (IDMEFntpstamp, 1);
 
           if (!additionaldata->ntpstamp)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2289,7 +2295,7 @@
           additionaldata->portlist = i_new0 (IDMEFportlist, 1);
 
           if (!additionaldata->portlist)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2318,7 +2324,7 @@
           additionaldata->real = i_new0 (IDMEFreal, 1);
 
           if (!additionaldata->real)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2347,7 +2353,7 @@
           additionaldata->string = i_new0 (IDMEFstring, 1);
 
           if (!additionaldata->string)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2376,7 +2382,7 @@
           additionaldata->byte_string = i_new0 (IDMEFbyte_string, 1);
 
           if (!additionaldata->byte_string)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2405,7 +2411,7 @@
           additionaldata->xmltext = i_new0 (IDMEFxmltext, 1);
 
           if (!additionaldata->xmltext)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2442,7 +2448,7 @@
           analyzer->node = i_new0 (IDMEFnode, 1);
 
           if (!analyzer->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2525,7 +2531,7 @@
           analyzer->process = i_new0 (IDMEFprocess, 1);
 
           if (!analyzer->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2584,7 +2590,7 @@
           analyzer->analyzer = i_new0 (IDMEFanalyzer, 1);
 
           if (!analyzer->analyzer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -2838,7 +2844,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -2867,7 +2873,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -2896,13 +2902,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
           
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -3055,7 +3061,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3084,7 +3090,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3127,7 +3133,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3156,7 +3162,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3185,7 +3191,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3215,13 +3221,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
           
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3251,13 +3257,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3301,7 +3307,7 @@
           analyzer->node = i_new0 (IDMEFnode, 1);
 
           if (!analyzer->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -3385,7 +3391,7 @@
           analyzer->process = i_new0 (IDMEFprocess, 1);
 
           if (!analyzer->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -3457,7 +3463,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3486,7 +3492,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3516,13 +3522,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
           
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -3675,7 +3681,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3704,7 +3710,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3747,7 +3753,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3776,7 +3782,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3805,7 +3811,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3835,13 +3841,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3871,13 +3877,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -3921,7 +3927,7 @@
           source->node = i_new0 (IDMEFnode, 1);
 
           if (!source->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -4005,7 +4011,7 @@
           source->user = i_new0 (IDMEFuser, 1);
 
           if (!source->user)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -4089,7 +4095,7 @@
           source->process = i_new0 (IDMEFprocess, 1);
 
           if (!source->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -4147,7 +4153,7 @@
           source->service = i_new0 (IDMEFservice, 1);
 
           if (!source->service)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4298,7 +4304,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4327,7 +4333,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4357,13 +4363,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
 
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -4516,7 +4522,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4545,7 +4551,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4590,7 +4596,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4619,7 +4625,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4648,7 +4654,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4678,13 +4684,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4714,13 +4720,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4765,13 +4771,13 @@
           ptr = i_renew (IDMEFuserid*, user->userids,
                                    user->nuserids);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           user->userids = ptr;
           user->userids[user->nuserids-1] = i_new0 (IDMEFuserid, 1);
 
           if (!user->userids[user->nuserids-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4897,7 +4903,7 @@
           userid->name = i_new0 (IDMEFname, 1);
 
           if (!userid->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4925,7 +4931,7 @@
           userid->number = i_new0 (IDMEFnumber, 1);
 
           if (!userid->number)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4967,7 +4973,7 @@
           service->snmpservice = i_new0 (IDMEFsnmpservice, 1);
 
           if (!service->snmpservice)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -4996,7 +5002,7 @@
           service->webservice = i_new0 (IDMEFwebservice, 1);
 
           if (!service->webservice)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5025,7 +5031,7 @@
           service->name = i_new0 (IDMEFname, 1);
 
           if (!service->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5054,7 +5060,7 @@
           service->port = i_new0 (IDMEFport, 1);
 
           if (!service->port)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5083,7 +5089,7 @@
           service->portlist = i_new0 (IDMEFportlist, 1);
 
           if (!service->portlist)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5112,7 +5118,7 @@
           service->protocol = i_new0 (IDMEFprotocol, 1);
 
           if (!service->protocol)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5157,7 +5163,7 @@
           snmpservice->oid = i_new0 (IDMEFoid, 1);
 
           if (!snmpservice->oid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5186,7 +5192,7 @@
           snmpservice->community = i_new0 (IDMEFcommunity, 1);
 
           if (!snmpservice->community)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5214,7 +5220,7 @@
           snmpservice->securityName = i_new0 (IDMEFsecurityName, 1);
 
           if (!snmpservice->securityName)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5242,7 +5248,7 @@
           snmpservice->contextName = i_new0 (IDMEFcontextName, 1);
 
           if (!snmpservice->contextName)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5270,7 +5276,7 @@
           snmpservice->contextEngineID = i_new0 (IDMEFcontextEngineID, 1);
 
           if (!snmpservice->contextEngineID)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5298,7 +5304,7 @@
           snmpservice->command = i_new0 (IDMEFcommand, 1);
 
           if (!snmpservice->command)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5342,7 +5348,7 @@
           webservice->url = i_new0 (IDMEFurl, 1);
 
           if (!webservice->url)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5370,7 +5376,7 @@
           webservice->cgi = i_new0 (IDMEFcgi, 1);
 
           if (!webservice->cgi)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5398,7 +5404,7 @@
           webservice->http_method = i_new0 (IDMEFhttp_method, 1);
 
           if (!webservice->http_method)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5427,13 +5433,13 @@
           ptr = i_renew (IDMEFarg*, webservice->args, webservice->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           webservice->args = ptr;
           webservice->args[webservice->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!webservice->args[webservice->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5476,7 +5482,7 @@
           target->node = i_new0 (IDMEFnode, 1);
 
           if (!target->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -5560,7 +5566,7 @@
           target->user = i_new0 (IDMEFuser, 1);
 
           if (!target->user)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -5644,7 +5650,7 @@
           target->process = i_new0 (IDMEFprocess, 1);
 
           if (!target->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -5702,7 +5708,7 @@
           target->service = i_new0 (IDMEFservice, 1);
 
           if (!target->service)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -5840,13 +5846,13 @@
           ptr = i_renew (IDMEFfile*,target->files,
                                      target->nfiles);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           target->files = ptr;
 	  target->files[target->nfiles-1] = i_new0 (IDMEFfile, 1);
 
           if (!target->files[target->nfiles-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -5994,7 +6000,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6023,7 +6029,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6053,13 +6059,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
 
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -6211,7 +6217,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6240,7 +6246,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6284,7 +6290,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6313,7 +6319,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6342,7 +6348,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6372,13 +6378,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6408,13 +6414,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6459,13 +6465,13 @@
           ptr = i_renew (IDMEFuserid*, user->userids, user->nuserids);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           user->userids = ptr;
           user->userids[user->nuserids-1] = i_new0 (IDMEFuserid, 1);
 
           if (!user->userids[user->nuserids-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6590,7 +6596,7 @@
           userid->name = i_new0 (IDMEFname, 1);
 
           if (!userid->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6618,7 +6624,7 @@
           userid->number = i_new0 (IDMEFnumber, 1);
 
           if (!userid->number)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6660,7 +6666,7 @@
           service->snmpservice = i_new0 (IDMEFsnmpservice, 1);
 
           if (!service->snmpservice)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6689,7 +6695,7 @@
           service->webservice = i_new0 (IDMEFwebservice, 1);
 
           if (!service->webservice)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6718,7 +6724,7 @@
           service->name = i_new0 (IDMEFname, 1);
 
           if (!service->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6747,7 +6753,7 @@
           service->port = i_new0 (IDMEFport, 1);
 
           if (!service->port)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6776,7 +6782,7 @@
           service->portlist = i_new0 (IDMEFportlist, 1);
 
           if (!service->portlist)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6805,7 +6811,7 @@
           service->protocol = i_new0 (IDMEFprotocol, 1);
 
           if (!service->protocol)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6850,7 +6856,7 @@
           snmpservice->oid = i_new0 (IDMEFoid, 1);
 
           if (!snmpservice->oid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6879,7 +6885,7 @@
           snmpservice->community = i_new0 (IDMEFcommunity, 1);
 
           if (!snmpservice->community)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6907,7 +6913,7 @@
           snmpservice->securityName = i_new0 (IDMEFsecurityName, 1);
 
           if (!snmpservice->securityName)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6935,7 +6941,7 @@
           snmpservice->contextName = i_new0 (IDMEFcontextName, 1);
 
           if (!snmpservice->contextName)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6963,7 +6969,7 @@
           snmpservice->contextEngineID = i_new0 (IDMEFcontextEngineID, 1);
 
           if (!snmpservice->contextEngineID)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -6991,7 +6997,7 @@
           snmpservice->command = i_new0 (IDMEFcommand, 1);
 
           if (!snmpservice->command)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7035,7 +7041,7 @@
           webservice->url = i_new0 (IDMEFurl, 1);
 
           if (!webservice->url)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7063,7 +7069,7 @@
           webservice->cgi = i_new0 (IDMEFcgi, 1);
 
           if (!webservice->cgi)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7091,7 +7097,7 @@
           webservice->http_method = i_new0 (IDMEFhttp_method, 1);
 
           if (!webservice->http_method)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7120,13 +7126,13 @@
           ptr = i_renew (IDMEFarg*, webservice->args, webservice->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           webservice->args = ptr;
           webservice->args[webservice->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!webservice->args[webservice->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7170,7 +7176,7 @@
           file->name = i_new0 (IDMEFname, 1);
 
           if (!file->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7197,7 +7203,7 @@
           file->path = i_new0 (IDMEFpath, 1);
 
           if (!file->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7224,7 +7230,7 @@
           file->create_time = i_new0 (IDMEFcreate_time, 1);
 
           if (!file->create_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7251,7 +7257,7 @@
           file->modify_time = i_new0 (IDMEFmodify_time, 1);
 
           if (!file->modify_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7278,7 +7284,7 @@
           file->access_time = i_new0 (IDMEFaccess_time, 1);
 
           if (!file->access_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7305,7 +7311,7 @@
           file->data_size = i_new0 (IDMEFdata_size, 1);
 
           if (!file->data_size)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7332,7 +7338,7 @@
           file->disk_size = i_new0 (IDMEFdisk_size, 1);
 
           if (!file->disk_size)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7361,14 +7367,14 @@
                                         file->fileaccesses,
                                         file->nfileaccesses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           file->fileaccesses = ptr;
 	  file->fileaccesses[file->nfileaccesses-1] =
             i_new0 (IDMEFfileaccess, 1);
 
           if (!file->fileaccesses[file->nfileaccesses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7398,13 +7404,13 @@
           ptr = i_renew (IDMEFlinkage*,
                                     file->linkages, file->nlinkages);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           file->linkages = ptr;
 	  file->linkages[file->nlinkages-1] = i_new0 (IDMEFlinkage, 1);
 
           if (!file->linkages[file->nlinkages-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
           if (state->gen_idmefp)
@@ -7464,7 +7470,7 @@
           file->inode = i_new0 (IDMEFinode, 1);
 
           if (!file->inode)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7492,13 +7498,13 @@
           ptr = i_renew (IDMEFchecksum*,
                                      file->checksums, file->nchecksums);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           file->checksums = ptr;
 	  file->checksums[file->nchecksums-1] = i_new0 (IDMEFchecksum, 1);
 
           if (!file->checksums[file->nchecksums-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -7574,7 +7580,7 @@
           fileaccess->userid = i_new0 (IDMEFuserid, 1);
 
           if (!fileaccess->userid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7684,14 +7690,14 @@
           ptr = i_renew (IDMEFpermission*, fileaccess->permissions,
                                              fileaccess->npermissions);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           fileaccess->permissions = ptr;
           fileaccess->permissions[fileaccess->npermissions-1] =
             i_new0 (IDMEFpermission, 1);
           
           if (!fileaccess->permissions[fileaccess->npermissions-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7736,7 +7742,7 @@
           userid->name = i_new0 (IDMEFname, 1);
 
           if (!userid->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7764,7 +7770,7 @@
           userid->number = i_new0 (IDMEFnumber, 1);
 
           if (!userid->number)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7808,7 +7814,7 @@
           linkage->name = i_new0 (IDMEFname, 1);
 
           if (!linkage->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7836,7 +7842,7 @@
           linkage->path = i_new0 (IDMEFpath, 1);
 
           if (!linkage->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7879,7 +7885,7 @@
           inode->change_time = i_new0 (IDMEFchange_time, 1);
 
           if (!inode->change_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7907,7 +7913,7 @@
           inode->number = i_new0 (IDMEFnumber, 1);
 
           if (!inode->number)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7935,7 +7941,7 @@
           inode->major_device = i_new0 (IDMEFmajor_device, 1);
 
           if (!inode->major_device)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7963,7 +7969,7 @@
           inode->minor_device = i_new0 (IDMEFminor_device, 1);
 
           if (!inode->minor_device)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -7991,7 +7997,7 @@
           inode->c_major_device = i_new0 (IDMEFc_major_device, 1);
 
           if (!inode->c_major_device)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8019,7 +8025,7 @@
           inode->c_minor_device = i_new0 (IDMEFc_minor_device, 1);
 
           if (!inode->c_minor_device)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8064,7 +8070,7 @@
           checksum->value = i_new0 (IDMEFvalue, 1);
 
           if (!checksum->value)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8092,7 +8098,7 @@
           checksum->key = i_new0 (IDMEFkey, 1);
 
           if (!checksum->key)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8136,14 +8142,14 @@
                                classification->references,
                                classification->nreferences);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           classification->references = ptr;
 	  classification->references[classification->nreferences-1] =
             i_new0 (IDMEFreference, 1);
 
           if (!classification->references[classification->nreferences-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -8243,7 +8249,7 @@
           reference->name = i_new0 (IDMEFname, 1);
 
           if (!reference->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8271,7 +8277,7 @@
           reference->url = i_new0 (IDMEFurl, 1);
 
           if (!reference->url)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8313,7 +8319,7 @@
           assessment->impact = i_new0 (IDMEFimpact, 1);
 
           if (!assessment->impact)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -8420,13 +8426,13 @@
           ptr = i_renew (IDMEFaction*, assessment->actions,
           				 assessment->nactions);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           assessment->actions = ptr;
 	  assessment->actions[assessment->nactions-1] = i_new0 (IDMEFaction, 1);
 
           if (!assessment->actions[assessment->nactions-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -8483,7 +8489,7 @@
           assessment->confidence = i_new0 (IDMEFconfidence, 1);
 
           if (!assessment->confidence)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -8554,7 +8560,7 @@
           toolalert->name = i_new0 (IDMEFname, 1);
 
           if (!toolalert->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8582,7 +8588,7 @@
           toolalert->command = i_new0 (IDMEFcommand, 1);
 
           if (!toolalert->command)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8611,14 +8617,14 @@
           ptr = i_renew (IDMEFalertident*,
           		toolalert->alertidents, toolalert->nalertidents);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           toolalert->alertidents = ptr;
           toolalert->alertidents[toolalert->nalertidents-1] =
             i_new0 (IDMEFalertident, 1);
 
           if (!toolalert->alertidents[toolalert->nalertidents-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -8690,7 +8696,7 @@
           overflowalert->program = i_new0 (IDMEFprogram, 1);
 
           if (!overflowalert->program)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8717,7 +8723,7 @@
           overflowalert->size = i_new0 (IDMEFsize, 1);
 
           if (!overflowalert->size)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8744,7 +8750,7 @@
           overflowalert->buffer = i_new0 (IDMEFbuffer, 1);
 
           if (!overflowalert->buffer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8785,7 +8791,7 @@
           correlationalert->name = i_new0 (IDMEFname, 1);
 
           if (!correlationalert->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -8814,14 +8820,14 @@
           ptr = i_renew (IDMEFalertident*,
           		correlationalert->alertidents, correlationalert->nalertidents);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           correlationalert->alertidents = ptr;
           correlationalert->alertidents[correlationalert->nalertidents-1] =
             i_new0 (IDMEFalertident, 1);
 
           if (!correlationalert->alertidents[correlationalert->nalertidents-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -8895,7 +8901,7 @@
           heartbeat->analyzer = i_new0 (IDMEFanalyzer, 1);
 
           if (!heartbeat->analyzer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -9135,7 +9141,7 @@
           heartbeat->createtime = i_new0 (IDMEFtime, 1);
 
           if (!heartbeat->createtime)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -9192,7 +9198,7 @@
           heartbeat->analyzertime = i_new0 (IDMEFtime, 1);
 
           if (!heartbeat->analyzertime)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -9251,14 +9257,14 @@
                                      heartbeat->additionaldatas,
           			     heartbeat->nadditionaldatas);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           heartbeat->additionaldatas = ptr;
           heartbeat->additionaldatas[heartbeat->nadditionaldatas-1] =
             i_new0 (IDMEFadditionaldata, 1);
             
           if (!heartbeat->additionaldatas[heartbeat->nadditionaldatas-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
           if (state->gen_idmefp)
@@ -9346,7 +9352,7 @@
           heartbeat->heartbeatinterval = i_new0 (IDMEFheartbeatinterval, 1);
 
           if (!heartbeat->heartbeatinterval)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -9390,7 +9396,7 @@
           analyzer->node = i_new0 (IDMEFnode, 1);
 
           if (!analyzer->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -9473,7 +9479,7 @@
           analyzer->process = i_new0 (IDMEFprocess, 1);
 
           if (!analyzer->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -9532,7 +9538,7 @@
           analyzer->analyzer = i_new0 (IDMEFanalyzer, 1);
 
           if (!analyzer->analyzer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -9787,7 +9793,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -9816,7 +9822,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -9845,13 +9851,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
           
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -10005,7 +10011,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10034,7 +10040,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10078,7 +10084,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10107,7 +10113,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10136,7 +10142,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10166,13 +10172,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10202,13 +10208,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10251,7 +10257,7 @@
           analyzer->node = i_new0 (IDMEFnode, 1);
 
           if (!analyzer->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -10335,7 +10341,7 @@
           analyzer->process = i_new0 (IDMEFprocess, 1);
 
           if (!analyzer->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -10407,7 +10413,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10436,7 +10442,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10466,13 +10472,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
           
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -10625,7 +10631,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10654,7 +10660,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10697,7 +10703,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10726,7 +10732,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10755,7 +10761,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10785,13 +10791,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10821,13 +10827,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -10873,7 +10879,7 @@
           additionaldata->boolean = i_new0 (IDMEFboolean, 1);
 
           if (!additionaldata->boolean)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -10902,7 +10908,7 @@
           additionaldata->byte = i_new0 (IDMEFbyte, 1);
 
           if (!additionaldata->byte)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -10931,7 +10937,7 @@
           additionaldata->character = i_new0 (IDMEFcharacter, 1);
 
           if (!additionaldata->character)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -10960,7 +10966,7 @@
           additionaldata->date_time = i_new0 (IDMEFdate_time, 1);
 
           if (!additionaldata->date_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -10989,7 +10995,7 @@
           additionaldata->integer = i_new0 (IDMEFinteger, 1);
 
           if (!additionaldata->integer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -11018,7 +11024,7 @@
           additionaldata->ntpstamp = i_new0 (IDMEFntpstamp, 1);
 
           if (!additionaldata->ntpstamp)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -11047,7 +11053,7 @@
           additionaldata->portlist = i_new0 (IDMEFportlist, 1);
 
           if (!additionaldata->portlist)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -11076,7 +11082,7 @@
           additionaldata->real = i_new0 (IDMEFreal, 1);
 
           if (!additionaldata->real)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -11105,7 +11111,7 @@
           additionaldata->string = i_new0 (IDMEFstring, 1);
 
           if (!additionaldata->string)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -11134,7 +11140,7 @@
           additionaldata->byte_string = i_new0 (IDMEFbyte_string, 1);
 
           if (!additionaldata->byte_string)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -11163,7 +11169,7 @@
           additionaldata->xmltext = i_new0 (IDMEFxmltext, 1);
 
           if (!additionaldata->xmltext)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -11889,7 +11895,7 @@
           asset->analyzer = i_new0 (IDMEFanalyzer, 1);
 
           if (!asset->analyzer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -12136,7 +12142,7 @@
 	  asset->target = i_new0 (IDMEFtarget, 1);
 
           if (!asset->target)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -12247,13 +12253,13 @@
           ptr = i_renew (IDMEFtool, asset->tools, asset->ntools);
           
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           asset->tools = ptr;
           asset->tools[asset->ntools-1] = i_new0 (IDMEFtool, 1);
 
           if (!asset->tools[asset->ntools-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -12488,7 +12494,7 @@
           analyzer->node = i_new0 (IDMEFnode, 1);
 
           if (!analyzer->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -12571,7 +12577,7 @@
           analyzer->process = i_new0 (IDMEFprocess, 1);
 
           if (!analyzer->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -12631,7 +12637,7 @@
           analyzer->analyzer = i_new0 (IDMEFanalyzer, 1);
 
           if (!analyzer->analyzer)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -12885,7 +12891,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -12914,7 +12920,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -12943,13 +12949,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
           
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -13101,7 +13107,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13130,7 +13136,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13173,7 +13179,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13202,7 +13208,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13231,7 +13237,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13261,13 +13267,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
           
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13297,13 +13303,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13347,7 +13353,7 @@
           analyzer->node = i_new0 (IDMEFnode, 1);
 
           if (!analyzer->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -13431,7 +13437,7 @@
           analyzer->process = i_new0 (IDMEFprocess, 1);
 
           if (!analyzer->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -13503,7 +13509,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13532,7 +13538,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13562,13 +13568,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
           
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -13721,7 +13727,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13750,7 +13756,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13793,7 +13799,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13822,7 +13828,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13851,7 +13857,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13881,13 +13887,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13917,13 +13923,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -13967,7 +13973,7 @@
           target->node = i_new0 (IDMEFnode, 1);
 
           if (!target->node)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -14051,7 +14057,7 @@
           target->user = i_new0 (IDMEFuser, 1);
 
           if (!target->user)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -14135,7 +14141,7 @@
           target->process = i_new0 (IDMEFprocess, 1);
 
           if (!target->process)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -14193,7 +14199,7 @@
           target->service = i_new0 (IDMEFservice, 1);
 
           if (!target->service)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14331,13 +14337,13 @@
           ptr = i_renew (IDMEFfile*,target->files,
                                      target->nfiles);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           target->files = ptr;
 	  target->files[target->nfiles-1] = i_new0 (IDMEFfile, 1);
 
           if (!target->files[target->nfiles-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -14485,7 +14491,7 @@
           node->location = i_new0 (IDMEFlocation, 1);
 
           if (!node->location)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14514,7 +14520,7 @@
           node->name = i_new0 (IDMEFname, 1);
 
           if (!node->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14544,13 +14550,13 @@
           ptr = i_renew (IDMEFaddress*, node->addresses,
           			node->naddresses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           node->addresses = ptr;
 	  node->addresses[node->naddresses-1] = i_new0 (IDMEFaddress, 1);
 
           if (!node->addresses[node->naddresses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -14702,7 +14708,7 @@
           address->netmask = i_new0 (IDMEFnetmask, 1);
 
           if (!address->netmask)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14731,7 +14737,7 @@
           address->address = i_new0 (IDMEFaddressaddress, 1);
 
           if (!address->address)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14775,7 +14781,7 @@
           process->name = i_new0 (IDMEFname, 1);
 
           if (!process->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14804,7 +14810,7 @@
           process->pid = i_new0 (IDMEFpid, 1);
 
           if (!process->pid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14833,7 +14839,7 @@
           process->path = i_new0 (IDMEFpath, 1);
 
           if (!process->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14863,13 +14869,13 @@
           ptr = i_renew (IDMEFarg*, process->args, process->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->args = ptr;
           process->args[process->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!process->args[process->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14899,13 +14905,13 @@
           ptr = i_renew (IDMEFenv*, process->envs, process->nenvs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           process->envs = ptr;
           process->envs[process->nenvs-1] = i_new0 (IDMEFenv, 1);
 
           if (!process->envs[process->nenvs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -14950,13 +14956,13 @@
           ptr = i_renew (IDMEFuserid*, user->userids, user->nuserids);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           user->userids = ptr;
           user->userids[user->nuserids-1] = i_new0 (IDMEFuserid, 1);
 
           if (!user->userids[user->nuserids-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15081,7 +15087,7 @@
           userid->name = i_new0 (IDMEFname, 1);
 
           if (!userid->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15109,7 +15115,7 @@
           userid->number = i_new0 (IDMEFnumber, 1);
 
           if (!userid->number)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15151,7 +15157,7 @@
           service->snmpservice = i_new0 (IDMEFsnmpservice, 1);
 
           if (!service->snmpservice)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15180,7 +15186,7 @@
           service->webservice = i_new0 (IDMEFwebservice, 1);
 
           if (!service->webservice)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15209,7 +15215,7 @@
           service->name = i_new0 (IDMEFname, 1);
 
           if (!service->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15238,7 +15244,7 @@
           service->port = i_new0 (IDMEFport, 1);
 
           if (!service->port)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15267,7 +15273,7 @@
           service->portlist = i_new0 (IDMEFportlist, 1);
 
           if (!service->portlist)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15296,7 +15302,7 @@
           service->protocol = i_new0 (IDMEFprotocol, 1);
 
           if (!service->protocol)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15341,7 +15347,7 @@
           snmpservice->oid = i_new0 (IDMEFoid, 1);
 
           if (!snmpservice->oid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15370,7 +15376,7 @@
           snmpservice->community = i_new0 (IDMEFcommunity, 1);
 
           if (!snmpservice->community)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15398,7 +15404,7 @@
           snmpservice->securityName = i_new0 (IDMEFsecurityName, 1);
 
           if (!snmpservice->securityName)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15426,7 +15432,7 @@
           snmpservice->contextName = i_new0 (IDMEFcontextName, 1);
 
           if (!snmpservice->contextName)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15454,7 +15460,7 @@
           snmpservice->contextEngineID = i_new0 (IDMEFcontextEngineID, 1);
 
           if (!snmpservice->contextEngineID)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15482,7 +15488,7 @@
           snmpservice->command = i_new0 (IDMEFcommand, 1);
 
           if (!snmpservice->command)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15526,7 +15532,7 @@
           webservice->url = i_new0 (IDMEFurl, 1);
 
           if (!webservice->url)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15554,7 +15560,7 @@
           webservice->cgi = i_new0 (IDMEFcgi, 1);
 
           if (!webservice->cgi)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15582,7 +15588,7 @@
           webservice->http_method = i_new0 (IDMEFhttp_method, 1);
 
           if (!webservice->http_method)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15611,13 +15617,13 @@
           ptr = i_renew (IDMEFarg*, webservice->args, webservice->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           webservice->args = ptr;
           webservice->args[webservice->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!webservice->args[webservice->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15661,7 +15667,7 @@
           file->name = i_new0 (IDMEFname, 1);
 
           if (!file->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15688,7 +15694,7 @@
           file->path = i_new0 (IDMEFpath, 1);
 
           if (!file->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15715,7 +15721,7 @@
           file->create_time = i_new0 (IDMEFcreate_time, 1);
 
           if (!file->create_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15742,7 +15748,7 @@
           file->modify_time = i_new0 (IDMEFmodify_time, 1);
 
           if (!file->modify_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15769,7 +15775,7 @@
           file->access_time = i_new0 (IDMEFaccess_time, 1);
 
           if (!file->access_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15796,7 +15802,7 @@
           file->data_size = i_new0 (IDMEFdata_size, 1);
 
           if (!file->data_size)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15823,7 +15829,7 @@
           file->disk_size = i_new0 (IDMEFdisk_size, 1);
 
           if (!file->disk_size)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15852,14 +15858,14 @@
                                         file->fileaccesses,
                                         file->nfileaccesses);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           file->fileaccesses = ptr;
 	  file->fileaccesses[file->nfileaccesses-1] =
             i_new0 (IDMEFfileaccess, 1);
 
           if (!file->fileaccesses[file->nfileaccesses-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15889,13 +15895,13 @@
           ptr = i_renew (IDMEFlinkage*,
                                     file->linkages, file->nlinkages);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           file->linkages = ptr;
 	  file->linkages[file->nlinkages-1] = i_new0 (IDMEFlinkage, 1);
 
           if (!file->linkages[file->nlinkages-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
           if (state->gen_idmefp)
@@ -15955,7 +15961,7 @@
           file->inode = i_new0 (IDMEFinode, 1);
 
           if (!file->inode)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -15983,13 +15989,13 @@
           ptr = i_renew (IDMEFchecksum*,
                                      file->checksums, file->nchecksums);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           file->checksums = ptr;
 	  file->checksums[file->nchecksums-1] = i_new0 (IDMEFchecksum, 1);
 
           if (!file->checksums[file->nchecksums-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -16065,7 +16071,7 @@
           fileaccess->userid = i_new0 (IDMEFuserid, 1);
 
           if (!fileaccess->userid)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16175,14 +16181,14 @@
           ptr = i_renew (IDMEFpermission*, fileaccess->permissions,
                                              fileaccess->npermissions);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           fileaccess->permissions = ptr;
           fileaccess->permissions[fileaccess->npermissions-1] =
             i_new0 (IDMEFpermission, 1);
           
           if (!fileaccess->permissions[fileaccess->npermissions-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16227,7 +16233,7 @@
           userid->name = i_new0 (IDMEFname, 1);
 
           if (!userid->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16255,7 +16261,7 @@
           userid->number = i_new0 (IDMEFnumber, 1);
 
           if (!userid->number)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16299,7 +16305,7 @@
           linkage->name = i_new0 (IDMEFname, 1);
 
           if (!linkage->name)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16327,7 +16333,7 @@
           linkage->path = i_new0 (IDMEFpath, 1);
 
           if (!linkage->path)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16370,7 +16376,7 @@
           inode->change_time = i_new0 (IDMEFchange_time, 1);
 
           if (!inode->change_time)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16398,7 +16404,7 @@
           inode->number = i_new0 (IDMEFnumber, 1);
 
           if (!inode->number)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16426,7 +16432,7 @@
           inode->major_device = i_new0 (IDMEFmajor_device, 1);
 
           if (!inode->major_device)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16454,7 +16460,7 @@
           inode->minor_device = i_new0 (IDMEFminor_device, 1);
 
           if (!inode->minor_device)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16482,7 +16488,7 @@
           inode->c_major_device = i_new0 (IDMEFc_major_device, 1);
 
           if (!inode->c_major_device)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16510,7 +16516,7 @@
           inode->c_minor_device = i_new0 (IDMEFc_minor_device, 1);
 
           if (!inode->c_minor_device)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16555,7 +16561,7 @@
           checksum->value = i_new0 (IDMEFvalue, 1);
 
           if (!checksum->value)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16583,7 +16589,7 @@
           checksum->key = i_new0 (IDMEFkey, 1);
 
           if (!checksum->key)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16627,7 +16633,7 @@
           tool->url = i_new0 (IDMEFurl, 1);
 
           if (!tool->url)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16653,13 +16659,13 @@
           ptr = i_renew (IDMEFarg*, tool->args, tool->nargs);
 
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           tool->args = ptr;
           tool->args[tool->nargs-1] = i_new0 (IDMEFarg, 1);
 
           if (!tool->args[tool->nargs-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -16690,13 +16696,13 @@
           ptr = i_renew (IDMEFtool, tool->results, tool->nresults);
           
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           tool->results = ptr;
           tool->results[tool->nresults-1] = i_new0 (IDMEFresult, 1);
 
           if (!tool->results[asset->ntools-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -16867,14 +16873,14 @@
                                      tool->additionaldatas,
           			     tool->nadditionaldatas);
           if (!ptr)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           tool->additionaldatas = ptr;
           tool->additionaldatas[tool->nadditionaldatas-1] =
             i_new0 (IDMEFadditionaldata, 1);
           
           if (!tool->additionaldatas[tool->nadditionaldatas-1])
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
           if (state->gen_idmefp)
@@ -16979,7 +16985,7 @@
           result->confidence = i_new0 (IDMEFconfidence, 1);
 
           if (!result->confidence)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -17036,7 +17042,7 @@
           result->service = i_new0 (IDMEFservice, 1);
 
           if (!result->service)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
           if (state->gen_idmefp)
            {
@@ -17173,7 +17179,7 @@
           result->vulnerability = i_new0 (IDMEFvulnerability, 1);
 
           if (!result->vulnerability)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
           if (state->gen_idmefp)
@@ -17398,7 +17404,7 @@
           result->os = i_new0 (IDMEFos, 1);
 
           if (!result->os)
-            idmef_parser_fatal_error (state, "Not enough memory!");
+            return idmef_parser_fatal_error (state, ENOMEM, "Not enough memory!");
 
 	  /* create an idmefp element */
 	  if (state->gen_idmefp)
@@ -22141,8 +22147,11 @@
       state->content = i_renew (char, state->content, l);
       
       if (!state->content)
-        idmef_parser_fatal_error (state, 
+      {
+        idmef_parser_fatal_error (state, ENOMEM,
                                   "Cannot allocate memory! Exiting ...");
+        return;
+      }
       snprintf (state->content, l, "%s%s", str, chars);
       free (str);
       break;
@@ -22175,17 +22184,19 @@
   va_end (args);
  }
 
-static void idmef_parser_fatal_error (SAXParserState *state, const char *format, ...)
+static int idmef_parser_fatal_error (SAXParserState *state, int errn, const char *format, ...)
  {
-  va_list args;
+  /*va_list args;
   char str[1025];
-  
+
   va_start (args, format);
   vsnprintf (str, 1024, format, args);
-  fprintf (stdout, "FATAl ERROR: %s\n", str);
-  va_end (args);
+  fprintf (stdout, "FATAL ERROR: %s\n", str);
+  va_end (args);*/
   
-  exit (1);
+  //exit (1); XXX why should we exit in a lib?
+  errno = errn;
+  return errn;
  }