Changeset 513


Ignore:
Timestamp:
Oct 23, 2014, 3:17:32 PM (9 years ago)
Author:
david
Message:

Fix syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c

    r512 r513  
    3939#include "service_zcfg.h"
    4040}
    41 
    4241#include "ulinet.h"
    43 
    4442#include <libintl.h>
    4543#include <locale.h>
    4644#include <string.h>
    47 
    4845#include "service.h"
    49 
    50 
    5146#include "service_internal.h"
    52 
    5347#ifdef USE_PYTHON
    5448#include "service_internal_python.h"
    5549#endif
    56 
    5750#ifdef USE_JAVA
    5851#include "service_internal_java.h"
    5952#endif
    60 
    6153#ifdef USE_PHP
    6254#include "service_internal_php.h"
    6355#endif
    64 
    6556#ifdef USE_JS
    6657#include "service_internal_js.h"
    6758#endif
    68 
    6959#ifdef USE_RUBY
    7060#include "service_internal_ruby.h"
    7161#endif
    72 
    7362#ifdef USE_PERL
    7463#include "service_internal_perl.h"
    7564#endif
    76 
    7765#include <dirent.h>
    7866#include <signal.h>
     
    9280#include <time.h>
    9381#include <stdarg.h>
    94 
    9582#ifdef WIN32
    9683extern "C"
     
    115102}
    116103#endif
    117 
    118104#define _(String) dgettext ("zoo-kernel",String)
    119105#define __(String) dgettext ("zoo-service",String)
    120 
    121106extern int getServiceFromFile (maps *, const char *, service **);
    122107
     
    228213int
    229214recursReaddirF (maps * m, xmlNodePtr n, char *conf_dir, char *prefix,
    230                 int saved_stdout, int level, void (func) (maps *, xmlNodePtr,
     215                int saved_stdout, int level, void (func) (maps *,
     216                                                          xmlNodePtr,
    231217                                                          service *))
    232218{
     
    250236  setMapInMaps (m, "lenv", "level", levels);
    251237  while ((dp = readdir (dirp)) != NULL)
    252     if ((dp->d_type == DT_DIR || dp->d_type == DT_LNK) && dp->d_name[0] != '.'
    253         && strstr (dp->d_name, ".") == NULL)
     238    if ((dp->d_type == DT_DIR || dp->d_type == DT_LNK)
     239        && dp->d_name[0] != '.' && strstr (dp->d_name, ".") == NULL)
    254240      {
    255241
    256242        char *tmp =
    257           (char *) malloc ((strlen (conf_dir) + strlen (dp->d_name) + 2) *
    258                            sizeof (char));
     243          (char *)
     244          malloc ((strlen (conf_dir) + strlen (dp->d_name) +
     245                   2) * sizeof (char));
    259246        sprintf (tmp, "%s/%s", conf_dir, dp->d_name);
    260247
     
    266253        sprintf (prefix, "%s.", dp->d_name);
    267254
    268         //map* tmpMap=getMapFromMaps(m,"lenv",tmp1);
     255        // map* tmpMap=getMapFromMaps(m,"lenv",tmp1);
    269256
    270257        int res;
     
    276263            setMapInMaps (m, "lenv", "level", levels1);
    277264            res =
    278               recursReaddirF (m, n, tmp, prefix, saved_stdout, level + 1,
    279                               func);
     265              recursReaddirF (m, n, tmp, prefix, saved_stdout,
     266                              level + 1, func);
    280267            sprintf (levels1, "%d", level);
    281268            setMapInMaps (m, "lenv", "level", levels1);
     
    308295              }
    309296#ifdef DEBUG
    310             fprintf (stderr, "#################\n%s\n#################\n",
    311                      tmps1);
     297            fprintf (stderr,
     298                     "#################\n%s\n#################\n", tmps1);
    312299#endif
    313300            t = readServiceFile (m, tmps1, &s1, dp->d_name);
     
    318305                char tmp01[1024];
    319306                if (tmp00 != NULL)
    320                   sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"),
     307                  sprintf (tmp01,
     308                           _
     309                           ("Unable to parse the ZCFG file: %s (%s)"),
    321310                           dp->d_name, tmp00->value);
    322311                else
    323                   sprintf (tmp01, _("Unable to parse the ZCFG file: %s."),
     312                  sprintf (tmp01,
     313                           _
     314                           ("Unable to parse the ZCFG file: %s."),
    324315                           dp->d_name);
    325316                dup2 (saved_stdout, fileno (stdout));
     
    511502              mapsToCharXXX (request_output_real_format, (char ***) outputs);
    512503              *eres =
    513                 execute ((char ***) &main_conf[0], (char ***) &inputs[0],
    514                          (char ***) &outputs[0]);
     504                execute ((char ***) &main_conf[0],
     505                         (char ***) &inputs[0], (char ***) &outputs[0]);
    515506#ifdef DEBUG
    516507              fprintf (stderr, "Function run successfully \n");
     
    524515#ifdef WIN32
    525516              errstr = GetLastError ();
    526               fprintf (stderr, "Function %s failed to load because of %d\n",
     517              fprintf (stderr,
     518                       "Function %s failed to load because of %d\n",
    527519                       r_inputs->value, errstr);
    528520#endif
     
    556548                  free (tmpMsg);
    557549#ifdef DEBUG
    558                   fprintf (stderr, "Function %s error %s\n", r_inputs->value,
    559                            errstr);
     550                  fprintf (stderr, "Function %s error %s\n",
     551                           r_inputs->value, errstr);
    560552#endif
    561553                  *eres = -1;
    562554                  return;
    563555                }
    564 
    565556#ifdef DEBUG
    566557#ifdef WIN32
     
    626617    {
    627618      *eres =
    628         zoo_java_support (&m, request_inputs, s1, &request_input_real_format,
     619        zoo_java_support (&m, request_inputs, s1,
     620                          &request_input_real_format,
    629621                          &request_output_real_format);
    630622    }
     
    636628    {
    637629      *eres =
    638         zoo_php_support (&m, request_inputs, s1, &request_input_real_format,
     630        zoo_php_support (&m, request_inputs, s1,
     631                         &request_input_real_format,
    639632                         &request_output_real_format);
    640633    }
     
    647640    {
    648641      *eres =
    649         zoo_perl_support (&m, request_inputs, s1, &request_input_real_format,
     642        zoo_perl_support (&m, request_inputs, s1,
     643                          &request_input_real_format,
    650644                          &request_output_real_format);
    651645    }
     
    657651    {
    658652      *eres =
    659         zoo_js_support (&m, request_inputs, s1, &request_input_real_format,
     653        zoo_js_support (&m, request_inputs, s1,
     654                        &request_input_real_format,
    660655                        &request_output_real_format);
    661656    }
     
    667662    {
    668663      *eres =
    669         zoo_ruby_support (&m, request_inputs, s1, &request_input_real_format,
     664        zoo_ruby_support (&m, request_inputs, s1,
     665                          &request_input_real_format,
    670666                          &request_output_real_format);
    671667    }
     
    775771                      NULL,     // Thread handle not inheritable
    776772                      FALSE,    // Set handle inheritance to FALSE
    777                       CREATE_NO_WINDOW, // Apache won't wait until the end
     773                      CREATE_NO_WINDOW, // Apache won't wait until
     774                      // the end
    778775                      NULL,     // Use parent's environment block
    779776                      NULL,     // Use parent's starting directory
     
    947944      else
    948945        {
    949           sprintf (tmpUrl, "http://%s:%s%s", cgiServerName, cgiServerPort,
    950                    cgiScriptName);
     946          sprintf (tmpUrl, "http://%s:%s%s", cgiServerName,
     947                   cgiServerPort, cgiScriptName);
    951948        }
    952949#ifdef DEBUG
     
    11391136          || strlen (r_inputs->name) == 0 || strlen (r_inputs->value) == 0)
    11401137        {
    1141           errorException (m, _("Mandatory <identifier> was not specified"),
     1138          errorException (m,
     1139                          _("Mandatory <identifier> was not specified"),
    11421140                          "MissingParameterValue", "identifier");
    11431141          freeMaps (&m);
     
    11521150      if (dirp == NULL)
    11531151        {
    1154           errorException (m, _("The specified path path doesn't exist."),
     1152          errorException (m,
     1153                          _("The specified path path doesn't exist."),
    11551154                          "InvalidParameterValue", conf_dir);
    11561155          freeMaps (&m);
     
    13391338          if (outputs_as_text == NULL)
    13401339            {
    1341               return errorException (m, _("Unable to allocate memory"),
     1340              return errorException (m,
     1341                                     _("Unable to allocate memory"),
    13421342                                     "InternalError", NULL);
    13431343            }
     
    13541354              if (outputs_as_text[i] == NULL)
    13551355                {
    1356                   return errorException (m, _("Unable to allocate memory"),
     1356                  return errorException (m,
     1357                                         _
     1358                                         ("Unable to allocate memory"),
    13571359                                         "InternalError", NULL);
    13581360                }
     
    13981400                      tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
    13991401#ifdef DEBUG
    1400                       fprintf (stderr, "OUTPUT DEF [%s]=[%s]\n", tmpn,
    1401                                tmpv + 1);
     1402                      fprintf (stderr, "OUTPUT DEF [%s]=[%s]\n",
     1403                               tmpn, tmpv + 1);
    14021404#endif
    14031405                      if (tmp_output->content == NULL)
     
    14441446      else
    14451447        {
    1446           errorException (m, _("Parameter <DataInputs> was not specified"),
     1448          errorException (m,
     1449                          _("Parameter <DataInputs> was not specified"),
    14471450                          "MissingParameterValue", "DataInputs");
    14481451          freeMaps (&m);
     
    14661469        {
    14671470          char *tmp2 = url_decode (tmp1);
    1468           snprintf (cursor_input, (strlen (tmp2) + 1) * sizeof (char), "%s",
    1469                     tmp2);
     1471          snprintf (cursor_input, (strlen (tmp2) + 1) * sizeof (char),
     1472                    "%s", tmp2);
    14701473          free (tmp2);
    14711474          pToken = strtok (cursor_input, ";");
     
    14941497          if (inputs_as_text[i] == NULL)
    14951498            {
    1496               return errorException (m, _("Unable to allocate memory."),
     1499              return errorException (m,
     1500                                     _("Unable to allocate memory."),
    14971501                                     "InternalError", NULL);
    14981502            }
     
    15351539                    {
    15361540                      return errorException (m,
    1537                                              _("Unable to allocate memory."),
     1541                                             _
     1542                                             ("Unable to allocate memory."),
    15381543                                             "InternalError", NULL);
    15391544                    }
     
    15531558                {
    15541559#ifdef DEBUG
    1555                   fprintf (stderr, "*** KVP NON URL-ENCODED \n***%s***\n",
    1556                            tmpc);
     1560                  fprintf (stderr,
     1561                           "*** KVP NON URL-ENCODED \n***%s***\n", tmpc);
    15571562#endif
    15581563                  char *tmpv1 = strstr (tmpc, "=");
    15591564#ifdef DEBUG
    1560                   fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
     1565                  fprintf (stderr,
     1566                           "*** VALUE NON URL-ENCODED \n***%s***\n",
    15611567                           tmpv1 + 1);
    15621568#endif
     
    15751581                      map *lmap = getLastMap (tmpmaps->content);
    15761582                      char *tmpValue =
    1577                         (char *) malloc ((strlen (tmpv) + strlen (tmpc) + 1) *
    1578                                          sizeof (char));
     1583                        (char *)
     1584                        malloc ((strlen (tmpv) + strlen (tmpc) +
     1585                                 1) * sizeof (char));
    15791586                      sprintf (tmpValue, "%s@%s", tmpv + 1, tmpc);
    15801587                      free (lmap->value);
     
    15851592                    }
    15861593#ifdef DEBUG
    1587                   fprintf (stderr, "*** NAME NON URL-ENCODED \n***%s***\n",
    1588                            tmpn1);
    1589                   fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
     1594                  fprintf (stderr,
     1595                           "*** NAME NON URL-ENCODED \n***%s***\n", tmpn1);
     1596                  fprintf (stderr,
     1597                           "*** VALUE NON URL-ENCODED \n***%s***\n",
    15901598                           tmpv1 + 1);
    15911599#endif
     
    15951603                    {
    15961604                      char *tmpx2 = url_decode (tmpv1 + 1);
    1597                       if (strncasecmp (tmpx2, "http://", 7) != 0 &&
    1598                           strncasecmp (tmpx2, "ftp://", 6) != 0 &&
    1599                           strncasecmp (tmpx2, "https://", 8) != 0)
     1605                      if (strncasecmp (tmpx2, "http://", 7) != 0
     1606                          && strncasecmp (tmpx2, "ftp://", 6) != 0
     1607                          && strncasecmp (tmpx2, "https://", 8) != 0)
    16001608                        {
    16011609                          char emsg[1024];
     
    16501658              else
    16511659                {
    1652                   maps *testPresence =
    1653                     getMaps (request_input_real_format, tmpmaps->name);
     1660                  maps *testPresence = getMaps (request_input_real_format,
     1661                                                tmpmaps->name);
    16541662                  if (testPresence != NULL)
    16551663                    {
     
    16591667                        {
    16601668                          if (appendMapsToMaps
    1661                               (m, request_input_real_format, tmpmaps,
    1662                                elem) < 0)
     1669                              (m, request_input_real_format,
     1670                               tmpmaps, elem) < 0)
    16631671                            {
    16641672                              freeMaps (&m);
     
    17351743                       xmlStrlen (cur2->name)) == 0)
    17361744                    {
    1737                       xmlChar *val =
    1738                         xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
     1745                      xmlChar *val = xmlNodeListGetString (doc,
     1746                                                           cur2->xmlChildrenNode,
     1747                                                           1);
    17391748                      if (tmpmaps == NULL)
    17401749                        {
     
    17591768                      (cur2->name, BAD_CAST "Title",
    17601769                       xmlStrlen (cur2->name)) == 0
    1761                       || xmlStrncasecmp (cur2->name, BAD_CAST "Abstract",
     1770                      || xmlStrncasecmp (cur2->name,
     1771                                         BAD_CAST "Abstract",
    17621772                                         xmlStrlen (cur2->name)) == 0)
    17631773                    {
    1764                       xmlChar *val =
    1765                         xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
     1774                      xmlChar *val = xmlNodeListGetString (doc,
     1775                                                           cur2->xmlChildrenNode,
     1776                                                           1);
    17661777                      if (tmpmaps == NULL)
    17671778                        {
     
    18071818#endif
    18081819                      const char *refs[5] =
    1809                         { "mimeType", "encoding", "schema", "method",
     1820                        { "mimeType", "encoding", "schema",
     1821                        "method",
    18101822                        "href"
    18111823                      };
     
    18151827                          fprintf (stderr, "*** %s ***", refs[l]);
    18161828#endif
    1817                           xmlChar *val = xmlGetProp (cur2, BAD_CAST refs[l]);
     1829                          xmlChar *val = xmlGetProp (cur2,
     1830                                                     BAD_CAST refs[l]);
    18181831                          if (val != NULL && xmlStrlen (val) > 0)
    18191832                            {
    18201833                              if (tmpmaps->content != NULL)
    1821                                 addToMap (tmpmaps->content, refs[l],
    1822                                           (char *) val);
     1834                                addToMap (tmpmaps->content,
     1835                                          refs[l], (char *) val);
    18231836                              else
    18241837                                tmpmaps->content =
    18251838                                  createMap (refs[l], (char *) val);
    1826                               map *ltmp = getMap (tmpmaps->content, "method");
     1839                              map *ltmp = getMap (tmpmaps->content,
     1840                                                  "method");
    18271841                              if (l == 4)
    18281842                                {
    18291843                                  if (!
    18301844                                      (ltmp != NULL
    1831                                        && strncmp (ltmp->value, "POST",
     1845                                       && strncmp (ltmp->value,
     1846                                                   "POST",
    18321847                                                   4) == 0)
    18331848                                      && CHECK_INET_HANDLE (hInternet))
    18341849                                    {
    18351850                                      if (loadRemoteFile
    1836                                           (&m, &tmpmaps->content, &hInternet,
    1837                                            (char *) val) != 0)
     1851                                          (&m,
     1852                                           &tmpmaps->content,
     1853                                           &hInternet, (char *) val) != 0)
    18381854                                        {
    18391855                                          freeMaps (&m);
     
    18591875#endif
    18601876                      xmlNodePtr cur3 = cur2->children;
    1861                       /*      HINTERNET hInternetP;
    1862                          hInternetP=InternetOpen(
    1863                          #ifndef WIN32
    1864                          (LPCTSTR)
    1865                          #endif
    1866                          "ZooWPSClient\0",
    1867                          INTERNET_OPEN_TYPE_PRECONFIG,
    1868                          NULL,NULL, 0); */
    1869                       //hInternet.ihandle[hInternet.nb].header=NULL;
     1877                      /*
     1878                       * HINTERNET hInternetP; hInternetP=InternetOpen(
     1879                       * #ifndef WIN32 (LPCTSTR) #endif
     1880                       * "ZooWPSClient\0", INTERNET_OPEN_TYPE_PRECONFIG,
     1881                       * NULL,NULL, 0);
     1882                       */
     1883                      // hInternet.ihandle[hInternet.nb].header=NULL;
    18701884                      while (cur3 != NULL)
    18711885                        {
     
    18751889                          if (cur3 == NULL)
    18761890                            break;
    1877                           if (xmlStrcasecmp (cur3->name, BAD_CAST "Header") ==
    1878                               0)
     1891                          if (xmlStrcasecmp
     1892                              (cur3->name, BAD_CAST "Header") == 0)
    18791893                            {
    18801894                              const char *ha[2];
     
    18861900                              for (hai = 0; hai < 2; hai++)
    18871901                                {
    1888                                   xmlChar *val =
    1889                                     xmlGetProp (cur3, BAD_CAST ha[hai]);
     1902                                  xmlChar *val = xmlGetProp (cur3,
     1903                                                             BAD_CAST
     1904                                                             ha[hai]);
    18901905#ifdef POST_DEBUG
    1891                                   fprintf (stderr, "%s = %s\n", ha[hai],
    1892                                            (char *) val);
     1906                                  fprintf (stderr,
     1907                                           "%s = %s\n",
     1908                                           ha[hai], (char *) val);
    18931909#endif
    18941910                                  if (hai == 0)
     
    18981914                                  else
    18991915                                    {
    1900                                       has =
    1901                                         (char *)
    1902                                         malloc ((4 + xmlStrlen (val) +
    1903                                                  strlen (key)) *
    1904                                                 sizeof (char));
     1916                                      has = (char *)
     1917                                        malloc ((4 +
     1918                                                 xmlStrlen
     1919                                                 (val) +
     1920                                                 strlen
     1921                                                 (key)) * sizeof (char));
    19051922                                      if (has == NULL)
    19061923                                        {
    1907                                           return errorException (m,
    1908                                                                  _
    1909                                                                  ("Unable to allocate memory."),
    1910                                                                  "InternalError",
    1911                                                                  NULL);
     1924                                          return
     1925                                            errorException
     1926                                            (m,
     1927                                             _
     1928                                             ("Unable to allocate memory."),
     1929                                             "InternalError", NULL);
    19121930                                        }
    19131931                                      snprintf (has,
    1914                                                 (3 + xmlStrlen (val) +
    1915                                                  strlen (key)), "%s: %s", key,
    1916                                                 (char *) val);
     1932                                                (3 +
     1933                                                 xmlStrlen
     1934                                                 (val) +
     1935                                                 strlen
     1936                                                 (key)),
     1937                                                "%s: %s", key, (char *) val);
    19171938                                      free (key);
    19181939#ifdef POST_DEBUG
     
    19231944                                }
    19241945                              hInternet.ihandle[hInternet.nb].header =
    1925                                 curl_slist_append (hInternet.ihandle
    1926                                                    [hInternet.nb].header,
    1927                                                    has);
     1946                                curl_slist_append
     1947                                (hInternet.ihandle[hInternet.nb].header, has);
    19281948                              if (has != NULL)
    19291949                                free (has);
     
    19351955                                       "Try to fetch the body part of the request ...\n");
    19361956#endif
    1937                               if (xmlStrcasecmp (cur3->name, BAD_CAST "Body")
    1938                                   == 0)
     1957                              if (xmlStrcasecmp
     1958                                  (cur3->name, BAD_CAST "Body") == 0)
    19391959                                {
    19401960#ifdef POST_DEBUG
    1941                                   fprintf (stderr, "Body part found !!!\n",
     1961                                  fprintf (stderr,
     1962                                           "Body part found !!!\n",
    19421963                                           (char *) cur3->content);
    19431964#endif
    19441965                                  char *tmp =
    1945                                     (char *) malloc (cgiContentLength +
    1946                                                      1 * sizeof (char));
     1966                                    (char *)
     1967                                    malloc
     1968                                    (cgiContentLength + 1 * sizeof (char));
    19471969                                  memset (tmp, 0, cgiContentLength);
    19481970                                  xmlNodePtr cur4 = cur3->children;
     
    19701992                                      xmlFreeDoc (bdoc);
    19711993                                    }
    1972                                   map *btmp =
    1973                                     getMap (tmpmaps->content, "href");
     1994                                  map *btmp = getMap (tmpmaps->content,
     1995                                                      "href");
    19741996                                  if (btmp != NULL)
    19751997                                    {
    19761998#ifdef POST_DEBUG
    1977                                       fprintf (stderr, "%s %s\n", btmp->value,
    1978                                                tmp);
    1979                                       curl_easy_setopt (hInternet.handle,
    1980                                                         CURLOPT_VERBOSE, 1);
    1981 #endif
    1982                                       hInternet.waitingRequests[hInternet.
    1983                                                                 nb] =
    1984                                         strdup (tmp);
    1985                                       InternetOpenUrl (&hInternet,
    1986                                                        btmp->value,
    1987                                                        hInternet.
    1988                                                        waitingRequests
    1989                                                        [hInternet.nb],
    1990                                                        strlen (hInternet.
    1991                                                                waitingRequests
    1992                                                                [hInternet.
    1993                                                                 nb]),
    1994                                                        INTERNET_FLAG_NO_CACHE_WRITE,
    1995                                                        0);
     1999                                      fprintf (stderr,
     2000                                               "%s %s\n", btmp->value, tmp);
     2001                                      curl_easy_setopt
     2002                                        (hInternet.handle,
     2003                                         CURLOPT_VERBOSE, 1);
     2004#endif
     2005                                      hInternet.waitingRequests
     2006                                        [hInternet.nb] = strdup (tmp);
     2007                                      InternetOpenUrl
     2008                                        (&hInternet,
     2009                                         btmp->value,
     2010                                         hInternet.waitingRequests
     2011                                         [hInternet.nb],
     2012                                         strlen
     2013                                         (hInternet.waitingRequests
     2014                                          [hInternet.nb]),
     2015                                         INTERNET_FLAG_NO_CACHE_WRITE, 0);
    19962016                                    }
    19972017                                  free (tmp);
    19982018                                }
    1999                               else
    2000                                 if (xmlStrcasecmp
    2001                                     (cur3->name,
    2002                                      BAD_CAST "BodyReference") == 0)
     2019                              else if (xmlStrcasecmp
     2020                                       (cur3->name,
     2021                                        BAD_CAST "BodyReference") == 0)
    20032022                                {
    2004                                   xmlChar *val =
    2005                                     xmlGetProp (cur3, BAD_CAST "href");
     2023                                  xmlChar *val = xmlGetProp (cur3,
     2024                                                            BAD_CAST "href");
    20062025                                  HINTERNET bInternet, res1;
    20072026                                  bInternet = InternetOpen (
     
    20162035                                             "WARNING : hInternet handle failed to initialize");
    20172036#ifdef POST_DEBUG
    2018                                   curl_easy_setopt (bInternet.handle,
    2019                                                     CURLOPT_VERBOSE, 1);
     2037                                  curl_easy_setopt
     2038                                    (bInternet.handle, CURLOPT_VERBOSE, 1);
    20202039#endif
    20212040                                  bInternet.waitingRequests[0] =
    20222041                                    strdup ((char *) val);
    20232042                                  res1 =
    2024                                     InternetOpenUrl (&bInternet,
    2025                                                      bInternet.waitingRequests
    2026                                                      [0], NULL, 0,
    2027                                                      INTERNET_FLAG_NO_CACHE_WRITE,
    2028                                                      0);
     2043                                    InternetOpenUrl
     2044                                    (&bInternet,
     2045                                     bInternet.waitingRequests
     2046                                     [0], NULL, 0,
     2047                                     INTERNET_FLAG_NO_CACHE_WRITE, 0);
    20292048                                  processDownloads (&bInternet);
    20302049                                  char *tmp =
    20312050                                    (char *)
    2032                                     malloc ((bInternet.ihandle[0].nDataLen +
    2033                                              1) * sizeof (char));
     2051                                    malloc ((bInternet.ihandle
     2052                                             [0].nDataLen
     2053                                             + 1) * sizeof (char));
    20342054                                  if (tmp == NULL)
    20352055                                    {
    2036                                       return errorException (m,
    2037                                                              _
    2038                                                              ("Unable to allocate memory."),
    2039                                                              "InternalError",
    2040                                                              NULL);
     2056                                      return
     2057                                        errorException
     2058                                        (m,
     2059                                         _
     2060                                         ("Unable to allocate memory."),
     2061                                         "InternalError", NULL);
    20412062                                    }
    20422063                                  size_t bRead;
    2043                                   InternetReadFile (bInternet.ihandle[0],
    2044                                                     (LPVOID) tmp,
    2045                                                     bInternet.ihandle[0].
    2046                                                     nDataLen, &bRead);
     2064                                  InternetReadFile
     2065                                    (bInternet.ihandle[0],
     2066                                     (LPVOID) tmp,
     2067                                     bInternet.ihandle[0].nDataLen, &bRead);
    20472068                                  tmp[bInternet.ihandle[0].nDataLen] = 0;
    20482069                                  InternetCloseHandle (&bInternet);
    2049                                   map *btmp =
    2050                                     getMap (tmpmaps->content, "href");
     2070                                  map *btmp = getMap (tmpmaps->content,
     2071                                                      "href");
    20512072                                  if (btmp != NULL)
    20522073                                    {
    20532074#ifdef POST_DEBUG
    2054                                       fprintf (stderr, "%s %s\n", btmp->value,
    2055                                                tmp);
    2056 #endif
    2057                                       hInternet.waitingRequests[hInternet.
    2058                                                                 nb] =
    2059                                         strdup (tmp);
     2075                                      fprintf (stderr,
     2076                                               "%s %s\n", btmp->value, tmp);
     2077#endif
     2078                                      hInternet.waitingRequests
     2079                                        [hInternet.nb] = strdup (tmp);
    20602080                                      res =
    2061                                         InternetOpenUrl (&hInternet,
    2062                                                          btmp->value,
    2063                                                          hInternet.
    2064                                                          waitingRequests
    2065                                                          [hInternet.nb],
    2066                                                          strlen (hInternet.
    2067                                                                  waitingRequests
    2068                                                                  [hInternet.
    2069                                                                   nb]),
    2070                                                          INTERNET_FLAG_NO_CACHE_WRITE,
    2071                                                          0);
     2081                                        InternetOpenUrl
     2082                                        (&hInternet,
     2083                                         btmp->value,
     2084                                         hInternet.waitingRequests
     2085                                         [hInternet.nb],
     2086                                         strlen
     2087                                         (hInternet.waitingRequests
     2088                                          [hInternet.nb]),
     2089                                         INTERNET_FLAG_NO_CACHE_WRITE, 0);
    20722090                                    }
    20732091                                  free (tmp);
     
    20822100#ifdef DEBUG
    20832101                      dumpMap (tmpmaps->content);
    2084                       fprintf (stderr, "= element 2 node \"%s\" = (%s)\n",
     2102                      fprintf (stderr,
     2103                               "= element 2 node \"%s\" = (%s)\n",
    20852104                               cur2->name, cur2->content);
    20862105#endif
     
    21122131                                {
    21132132#ifdef DEBUG
    2114                                   fprintf (stderr, "*** LiteralData %s ***",
    2115                                            list[l]);
    2116 #endif
    2117                                   xmlChar *val =
    2118                                     xmlGetProp (cur4, BAD_CAST list[l]);
     2133                                  fprintf (stderr,
     2134                                           "*** LiteralData %s ***", list[l]);
     2135#endif
     2136                                  xmlChar *val = xmlGetProp (cur4,
     2137                                                             BAD_CAST
     2138                                                             list[l]);
    21192139                                  if (val != NULL
    21202140                                      && strlen ((char *) val) > 0)
    21212141                                    {
    21222142                                      if (tmpmaps->content != NULL)
    2123                                         addToMap (tmpmaps->content, list[l],
    2124                                                   (char *) val);
     2143                                        addToMap
     2144                                          (tmpmaps->content,
     2145                                           list[l], (char *) val);
    21252146                                      else
    21262147                                        tmpmaps->content =
     
    21342155                                }
    21352156                            }
    2136                           else
    2137                             if (xmlStrcasecmp
    2138                                 (cur4->name, BAD_CAST "ComplexData") == 0)
     2157                          else if (xmlStrcasecmp
     2158                                   (cur4->name, BAD_CAST "ComplexData") == 0)
    21392159                            {
    21402160                /**
     
    21422162                 * mimeType, encoding, schema
    21432163                 */
    2144                               const char *coms[3] =
    2145                                 { "mimeType", "encoding", "schema" };
     2164                              const char *coms[3] = { "mimeType", "encoding",
     2165                                "schema"
     2166                              };
    21462167                              for (int l = 0; l < 3; l++)
    21472168                                {
    21482169#ifdef DEBUG
    2149                                   fprintf (stderr, "*** ComplexData %s ***\n",
     2170                                  fprintf (stderr,
     2171                                           "*** ComplexData %s ***\n",
    21502172                                           coms[l]);
    21512173#endif
    2152                                   xmlChar *val =
    2153                                     xmlGetProp (cur4, BAD_CAST coms[l]);
     2174                                  xmlChar *val = xmlGetProp (cur4,
     2175                                                             BAD_CAST
     2176                                                             coms[l]);
    21542177                                  if (val != NULL
    21552178                                      && strlen ((char *) val) > 0)
    21562179                                    {
    21572180                                      if (tmpmaps->content != NULL)
    2158                                         addToMap (tmpmaps->content, coms[l],
    2159                                                   (char *) val);
     2181                                        addToMap
     2182                                          (tmpmaps->content,
     2183                                           coms[l], (char *) val);
    21602184                                      else
    21612185                                        tmpmaps->content =
     
    21692193                            }
    21702194
    2171                           map *test = getMap (tmpmaps->content, "encoding");
     2195                          map *test = getMap (tmpmaps->content,
     2196                                              "encoding");
    21722197                          if (test == NULL)
    21732198                            {
    21742199                              if (tmpmaps->content != NULL)
    2175                                 addToMap (tmpmaps->content, "encoding",
    2176                                           "utf-8");
     2200                                addToMap (tmpmaps->content,
     2201                                          "encoding", "utf-8");
    21772202                              else
    21782203                                tmpmaps->content =
     
    21842209                            {
    21852210                              xmlChar *mv = xmlNodeListGetString (doc,
    2186                                                                   cur4->xmlChildrenNode,
     2211                                                                  cur4->
     2212                                                                  xmlChildrenNode,
    21872213                                                                  1);
    2188                               map *ltmp =
    2189                                 getMap (tmpmaps->content, "mimeType");
     2214                              map *ltmp = getMap (tmpmaps->content,
     2215                                                  "mimeType");
    21902216                              if (mv == NULL
    21912217                                  ||
    21922218                                  (xmlStrcasecmp
    2193                                    (cur4->name, BAD_CAST "ComplexData") == 0
    2194                                    && (ltmp == NULL
    2195                                        || strncasecmp (ltmp->value,
    2196                                                        "text/xml", 8) == 0)))
     2219                                   (cur4->name,
     2220                                    BAD_CAST "ComplexData") ==
     2221                                   0 && (ltmp == NULL
     2222                                         ||
     2223                                         strncasecmp (ltmp->value,
     2224                                                      "text/xml", 8) == 0)))
    21972225                                {
    21982226                                  xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0");
     
    22002228                                  xmlNodePtr cur5 = cur4->children;
    22012229                                  while (cur5 != NULL
    2202                                          && cur5->type != XML_ELEMENT_NODE
     2230                                         && cur5->type !=
     2231                                         XML_ELEMENT_NODE
    22032232                                         && cur5->type !=
    22042233                                         XML_CDATA_SECTION_NODE)
     
    22082237                                    {
    22092238                                      xmlDocSetRootElement (doc1, cur5);
    2210                                       xmlDocDumpFormatMemoryEnc (doc1, &mv,
    2211                                                                  &buffersize,
    2212                                                                  "utf-8", 1);
     2239                                      xmlDocDumpFormatMemoryEnc
     2240                                        (doc1, &mv, &buffersize, "utf-8", 1);
    22132241                                      char size[1024];
    22142242                                      sprintf (size, "%d", buffersize);
    2215                                       addToMap (tmpmaps->content, "size",
    2216                                                 size);
     2243                                      addToMap (tmpmaps->content,
     2244                                                "size", size);
    22172245                                      xmlFreeDoc (doc1);
    22182246                                    }
     
    22202248                              if (mv != NULL)
    22212249                                {
    2222                                   addToMap (tmpmaps->content, "value",
    2223                                             (char *) mv);
     2250                                  addToMap (tmpmaps->content,
     2251                                            "value", (char *) mv);
    22242252                                  xmlFree (mv);
    22252253                                }
     
    22312259                                                                      xmlChildrenNode,
    22322260                                                                      0);
    2233                               addToMap (tmpmaps->content, "value",
    2234                                         (char *) tmp);
    2235                               map *tmpv = getMap (tmpmaps->content, "value");
     2261                              addToMap (tmpmaps->content,
     2262                                        "value", (char *) tmp);
     2263                              map *tmpv = getMap (tmpmaps->content,
     2264                                                  "value");
    22362265                              char *res = NULL;
    22372266                              char *curs = tmpv->value;
    2238                               for (int i = 0; i <= strlen (tmpv->value) / 64;
    2239                                    i++)
     2267                              for (int i = 0;
     2268                                   i <= strlen (tmpv->value) / 64; i++)
    22402269                                {
    22412270                                  if (res == NULL)
     
    22442273                                  else
    22452274                                    res =
    2246                                       (char *) realloc (res,
    2247                                                         (((i + 1) * 65) +
    2248                                                          i) * sizeof (char));
     2275                                      (char *)
     2276                                      realloc (res,
     2277                                               (((i +
     2278                                                  1) *
     2279                                                 65) + i) * sizeof (char));
    22492280                                  int csize = i * 65;
    22502281                                  strncpy (res + csize, curs, 64);
     
    22532284                                  else
    22542285                                    {
    2255                                       strncpy (res + (((i + 1) * 64) + i),
    2256                                                "\n\0", 2);
     2286                                      strncpy (res +
     2287                                               (((i +
     2288                                                  1) * 64) + i), "\n\0", 2);
    22572289                                      curs += 64;
    22582290                                    }
     
    22782310
    22792311              {
    2280                 maps *testPresence =
    2281                   getMaps (request_input_real_format, tmpmaps->name);
     2312                maps *testPresence = getMaps (request_input_real_format,
     2313                                              tmpmaps->name);
    22822314                if (testPresence != NULL)
    22832315                  {
     
    23462378              if (tmpmaps == NULL)
    23472379                {
    2348                   return errorException (m, _("Unable to allocate memory."),
     2380                  return errorException (m,
     2381                                         _
     2382                                         ("Unable to allocate memory."),
    23492383                                         "InternalError", NULL);
    23502384                }
     
    23702404                        {
    23712405                          if (tmpmaps->content != NULL)
    2372                             addToMap (tmpmaps->content, outs[l],
    2373                                       (char *) val);
     2406                            addToMap (tmpmaps->content,
     2407                                      outs[l], (char *) val);
    23742408                          else
    23752409                            tmpmaps->content =
     
    23892423                       xmlStrlen (cur2->name)) == 0)
    23902424                    {
    2391                       xmlChar *val =
    2392                         xmlNodeListGetString (NULL, cur2->xmlChildrenNode, 1);
     2425                      xmlChar *val = xmlNodeListGetString (NULL,
     2426                                                           cur2->xmlChildrenNode,
     2427                                                           1);
    23932428                      free (tmpmaps->name);
    23942429                      tmpmaps->name = zStrdup ((char *) val);
     
    24132448        for (int k = 0; k < tmps->nodeNr; k++)
    24142449          {
    2415             //else
     2450            // else
    24162451            addToMap (request_inputs, "ResponseDocument", "");
    24172452            maps *tmpmaps = NULL;
     
    24752510                         xmlStrlen (cur1->name)) == 0)
    24762511                      {
    2477                         xmlChar *val =
    2478                           xmlNodeListGetString (doc, cur1->xmlChildrenNode,
    2479                                                 1);
     2512                        xmlChar *val = xmlNodeListGetString (doc,
     2513                                                            cur1->xmlChildrenNode,
     2514                                                             1);
    24802515                        if (tmpmaps == NULL)
    24812516                          {
     
    24982533                          }
    24992534                        if (asRaw == true)
    2500                           addToMap (request_inputs, "RawDataOutput",
    2501                                     (char *) val);
     2535                          addToMap (request_inputs,
     2536                                    "RawDataOutput", (char *) val);
    25022537                        else
    25032538                          {
    25042539                            if (cur1cnt == 0)
    2505                               addToMap (request_inputs, "ResponseDocument",
    2506                                         (char *) val);
     2540                              addToMap (request_inputs,
     2541                                        "ResponseDocument", (char *) val);
    25072542                            else
    25082543                              {
    2509                                 map *tt =
    2510                                   getMap (request_inputs, "ResponseDocument");
     2544                                map *tt = getMap (request_inputs,
     2545                                                  "ResponseDocument");
    25112546                                char *tmp = zStrdup (tt->value);
    25122547                                free (tt->value);
    2513                                 tt->value =
    2514                                   (char *)
     2548                                tt->value = (char *)
    25152549                                  malloc ((strlen (tmp) +
    2516                                            strlen ((char *) val) +
    2517                                            1) * sizeof (char));
    2518                                 sprintf (tt->value, "%s;%s", tmp,
    2519                                          (char *) val);
     2550                                           strlen ((char
     2551                                                    *)
     2552                                                   val) + 1) * sizeof (char));
     2553                                sprintf (tt->value, "%s;%s",
     2554                                         tmp, (char *) val);
    25202555                                free (tmp);
    25212556                              }
     
    25272562             * Title, Asbtract
    25282563             */
    2529                     else
    2530                       if (xmlStrncasecmp
    2531                           (cur1->name, BAD_CAST "Title",
    2532                            xmlStrlen (cur1->name)) == 0
    2533                           || xmlStrncasecmp (cur1->name, BAD_CAST "Abstract",
    2534                                              xmlStrlen (cur1->name)) == 0)
     2564                    else if (xmlStrncasecmp
     2565                             (cur1->name, BAD_CAST "Title",
     2566                              xmlStrlen (cur1->name)) == 0
     2567                             || xmlStrncasecmp (cur1->name,
     2568                                                BAD_CAST
     2569                                                "Abstract",
     2570                                                xmlStrlen (cur1->name)) == 0)
    25352571                      {
    2536                         xmlChar *val =
    2537                           xmlNodeListGetString (doc, cur1->xmlChildrenNode,
    2538                                                 1);
     2572                        xmlChar *val = xmlNodeListGetString (doc,
     2573                                                            cur1->xmlChildrenNode,
     2574                                                             1);
    25392575                        if (tmpmaps == NULL)
    25402576                          {
     
    25552591                          {
    25562592                            if (tmpmaps->content != NULL)
    2557                               addToMap (tmpmaps->content, (char *) cur1->name,
    2558                                         (char *) val);
     2593                              addToMap (tmpmaps->content,
     2594                                        (char *) cur1->name, (char *) val);
    25592595                            else
    25602596                              tmpmaps->content =
     
    25632599                        xmlFree (val);
    25642600                      }
    2565                     else
    2566                       if (xmlStrncasecmp
    2567                           (cur1->name, BAD_CAST "Output",
    2568                            xmlStrlen (cur1->name)) == 0)
     2601                    else if (xmlStrncasecmp
     2602                             (cur1->name, BAD_CAST "Output",
     2603                              xmlStrlen (cur1->name)) == 0)
    25692604                      {
    25702605              /**
     
    25732608               */
    25742609                        const char *outs[5] =
    2575                           { "mimeType", "encoding", "schema", "uom",
     2610                          { "mimeType", "encoding", "schema",
     2611                          "uom",
    25762612                          "asReference"
    25772613                        };
     
    25812617                            fprintf (stderr, "*** %s ***\t", outs[l]);
    25822618#endif
    2583                             xmlChar *val =
    2584                               xmlGetProp (cur1, BAD_CAST outs[l]);
     2619                            xmlChar *val = xmlGetProp (cur1,
     2620                                                      BAD_CAST outs[l]);
    25852621                            if (val != NULL && strlen ((char *) val) > 0)
    25862622                              {
    25872623                                if (tmpmaps->content != NULL)
    2588                                   addToMap (tmpmaps->content, outs[l],
    2589                                             (char *) val);
     2624                                  addToMap (tmpmaps->content,
     2625                                            outs[l], (char *) val);
    25902626                                else
    25912627                                  tmpmaps->content =
     
    26062642                 */
    26072643                            if (xmlStrncasecmp
    2608                                 (cur2->name, BAD_CAST "Identifier",
     2644                                (cur2->name,
     2645                                 BAD_CAST "Identifier",
    26092646                                 xmlStrlen (cur2->name)) == 0)
    26102647                              {
    26112648                                xmlChar *val = xmlNodeListGetString (doc,
    2612                                                                      cur2->xmlChildrenNode,
     2649                                                                     cur2->
     2650                                                                     xmlChildrenNode,
    26132651                                                                     1);
    26142652                                if (tmpmaps == NULL)
     
    26172655                                    if (tmpmaps == NULL)
    26182656                                      {
    2619                                         return errorException (m,
    2620                                                                _
    2621                                                                ("Unable to allocate memory."),
    2622                                                                "InternalError",
    2623                                                                NULL);
     2657                                        return
     2658                                          errorException
     2659                                          (m,
     2660                                           _
     2661                                           ("Unable to allocate memory."),
     2662                                           "InternalError", NULL);
    26242663                                      }
    26252664                                    tmpmaps->name = zStrdup ((char *) val);
     
    26382677                 * Title, Asbtract
    26392678                 */
    2640                             else
    2641                               if (xmlStrncasecmp
    2642                                   (cur2->name, BAD_CAST "Title",
    2643                                    xmlStrlen (cur2->name)) == 0
    2644                                   || xmlStrncasecmp (cur2->name,
    2645                                                      BAD_CAST "Abstract",
    2646                                                      xmlStrlen (cur2->name))
    2647                                   == 0)
     2679                            else if (xmlStrncasecmp
     2680                                     (cur2->name,
     2681                                      BAD_CAST "Title",
     2682                                      xmlStrlen (cur2->name)) == 0
     2683                                     || xmlStrncasecmp (cur2->name,
     2684                                                        BAD_CAST
     2685                                                        "Abstract",
     2686                                                        xmlStrlen
     2687                                                        (cur2->name)) == 0)
    26482688                              {
    26492689                                xmlChar *val = xmlNodeListGetString (doc,
    2650                                                                      cur2->xmlChildrenNode,
     2690                                                                     cur2->
     2691                                                                     xmlChildrenNode,
    26512692                                                                     1);
    26522693                                if (tmpmaps == NULL)
     
    26552696                                    if (tmpmaps == NULL)
    26562697                                      {
    2657                                         return errorException (m,
    2658                                                                _
    2659                                                                ("Unable to allocate memory."),
    2660                                                                "InternalError",
    2661                                                                NULL);
     2698                                        return
     2699                                          errorException
     2700                                          (m,
     2701                                           _
     2702                                           ("Unable to allocate memory."),
     2703                                           "InternalError", NULL);
    26622704                                      }
    26632705                                    tmpmaps->name =
    26642706                                      zStrdup ("missingIndetifier");
    26652707                                    tmpmaps->content =
    2666                                       createMap ((char *) cur2->name,
    2667                                                  (char *) val);
     2708                                      createMap ((char
     2709                                                  *)
     2710                                                 cur2->name, (char *) val);
    26682711                                    tmpmaps->next = NULL;
    26692712                                  }
     
    26712714                                  {
    26722715                                    if (tmpmaps->content != NULL)
    2673                                       addToMap (tmpmaps->content,
    2674                                                 (char *) cur2->name,
    2675                                                (char *) val);
     2716                                      addToMap
     2717                                        (tmpmaps->content,
     2718                                         (char *) cur2->name, (char *) val);
    26762719                                    else
    26772720                                      tmpmaps->content =
     
    27102753  runHttpRequests (&m, &request_input_real_format, &hInternet);
    27112754
    2712   //  if(CHECK_INET_HANDLE(hInternet))
     2755  // if(CHECK_INET_HANDLE(hInternet))
    27132756  InternetCloseHandle (&hInternet);
    27142757
     
    28452888                  strcpy (fileNameOnServer, name + t + 1);
    28462889
    2847                   sprintf (storageNameOnServer, "%s/%s", path->value,
    2848                            fileNameOnServer);
     2890                  sprintf (storageNameOnServer, "%s/%s",
     2891                           path->value, fileNameOnServer);
    28492892#ifdef DEBUG
    28502893                  fprintf (stderr, "Name on server %s\n",
     
    28542897#endif
    28552898                  targetFile =
    2856                     open (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,
     2899                    open (storageNameOnServer,
     2900                          O_RDWR | O_CREAT | O_TRUNC,
    28572901                          S_IRWXU | S_IRGRP | S_IROTH);
    28582902                  if (targetFile < 0)
    28592903                    {
    28602904#ifdef DEBUG
    2861                       fprintf (stderr, "could not create the new file,%s\n",
     2905                      fprintf (stderr,
     2906                               "could not create the new file,%s\n",
    28622907                               fileNameOnServer);
    28632908#endif
     
    28652910                  else
    28662911                    {
    2867                       while (cgiFormFileRead (file, buffer, BufferLen, &got)
     2912                      while (cgiFormFileRead
     2913                             (file, buffer, BufferLen, &got)
    28682914                             == cgiFormSuccess)
    28692915                        {
     
    29152961            }
    29162962#ifdef DEBUG
     2963          if (SetEnvironmentVariable (mapcs->name, mapcs->value) == 0)
     2964            {
     2965              fflush (stderr);
     2966              fprintf (stderr, "setting variable... %s\n", "OK");
     2967            }
     2968          else
     2969            {
     2970              fflush (stderr);
     2971              fprintf (stderr, "setting variable... %s\n", "OK");
     2972            }
     2973#else
     2974
     2975
     2976          SetEnvironmentVariable (mapcs->name, mapcs->value);
     2977#endif
     2978          char *toto =
     2979            (char
     2980             *) malloc ((strlen
     2981                         (mapcs->name) +
     2982                         strlen (mapcs->value) + 2) * sizeof (char));
     2983          sprintf (toto, "%s=%s", mapcs->name, mapcs->value);
     2984          putenv (toto);
     2985#ifdef DEBUG
    29172986          fflush (stderr);
    2918           fprintf (stderr, "setting variable... %s\n", (
    2919 #endif
    2920                                                          SetEnvironmentVariable
    2921                                                          (mapcs->name,
    2922                                                           mapcs->value)
    2923 #ifdef DEBUG
    2924                                                          == 0) ? "OK" :
    2925                    "FAILED");
    2926 #else
    2927                                                          ;
    2928 #endif
    2929                                                          char *toto =
    2930                                                          (char
    2931                                                           *)malloc ((strlen
    2932                                                                      (mapcs->
    2933                                                                       name) +
    2934                                                                      strlen
    2935                                                                      (mapcs->
    2936                                                                       value) +
    2937                                                                      2) *
    2938                                                                     sizeof
    2939                                                                     (char));
    2940                                                          sprintf (toto,
    2941                                                                   "%s=%s",
    2942                                                                   mapcs->name,
    2943                                                                   mapcs->
    2944                                                                   value);
    2945                                                          putenv (toto);
    2946 #ifdef DEBUG
    2947                                                          fflush (stderr);
    2948 #endif
    2949 #endif
    2950 #ifdef DEBUG
    2951                                                          fprintf (stderr,
    2952                                                                   "[ZOO: setenv (%s=%s)]\n",
    2953                                                                   mapcs->name,
    2954                                                                   mapcs->
    2955                                                                   value);
    2956                                                          fflush (stderr);
    2957 #endif
    2958                                                          mapcs = mapcs->next;}
    2959                                                          }
    2960 
    2961 #ifdef DEBUG
    2962                                                          dumpMap
    2963                                                          (request_inputs);
     2987#endif
     2988#endif
     2989#ifdef DEBUG
     2990          fprintf (stderr,
     2991                   "[ZOO: setenv (%s=%s)]\n", mapcs->name, mapcs->value);
     2992          fflush (stderr);
     2993#endif
     2994          mapcs = mapcs->next;
     2995        }
     2996    }
     2997#ifdef DEBUG
     2998  dumpMap (request_inputs);
    29642999#endif
    29653000  /**
    29663001   * Need to check if we need to fork to load a status enabled
    29673002   */
    2968                                                          r_inputs = NULL;
    2969                                                          map * store =
    2970                                                          getMap
    2971                                                          (request_inputs,
    2972                                                           "storeExecuteResponse");
    2973                                                          map * status =
    2974                                                          getMap
    2975                                                          (request_inputs,
    2976                                                           "status");
     3003  r_inputs = NULL;
     3004  map *store = getMap (request_inputs,
     3005                       "storeExecuteResponse");
     3006  map *status = getMap (request_inputs, "status");
    29773007  /**
    29783008   * 05-007r7 WPS 1.0.0 page 57 :
     
    29803010   * shall raise an exception.'
    29813011   */
    2982                                                          if (status != NULL
    2983                                                              &&
    2984                                                              strcmp
    2985                                                              (status->value,
    2986                                                               "true") == 0
    2987                                                              && store != NULL
    2988                                                              &&
    2989                                                              strcmp
    2990                                                              (store->value,
    2991                                                               "false") == 0)
    2992                                                          {
    2993                                                          errorException (m,
    2994                                                                          _
    2995                                                                          ("Status cannot be set to true with storeExecuteResponse to false. Please, modify your request parameters."),
    2996                                                                          "InvalidParameterValue",
    2997                                                                          "storeExecuteResponse");
    2998                                                          freeService (&s1);
    2999                                                          free (s1);
    3000                                                          freeMaps (&m);
    3001                                                          free (m);
    3002                                                          freeMaps
    3003                                                          (&request_input_real_format);
    3004                                                          free
    3005                                                          (request_input_real_format);
    3006                                                          freeMaps
    3007                                                          (&request_output_real_format);
    3008                                                          free
    3009                                                          (request_output_real_format);
    3010                                                          free (REQUEST);
    3011                                                          free (SERVICE_URL);
    3012                                                          return 1;}
    3013                                                          r_inputs =
    3014                                                          getMap
    3015                                                          (request_inputs,
    3016                                                           "storeExecuteResponse");
    3017                                                          int eres =
    3018                                                          SERVICE_STARTED;
    3019                                                          int cpid = getpid ();
     3012  if (status != NULL
     3013      &&
     3014      strcmp
     3015      (status->value,
     3016       "true") == 0 && store != NULL && strcmp (store->value, "false") == 0)
     3017    {
     3018      errorException (m,
     3019                      _
     3020                      ("Status cannot be set to true with storeExecuteResponse to false. Please, modify your request parameters."),
     3021                      "InvalidParameterValue", "storeExecuteResponse");
     3022      freeService (&s1);
     3023      free (s1);
     3024      freeMaps (&m);
     3025      free (m);
     3026      freeMaps (&request_input_real_format);
     3027      free (request_input_real_format);
     3028      freeMaps (&request_output_real_format);
     3029      free (request_output_real_format);
     3030      free (REQUEST);
     3031      free (SERVICE_URL);
     3032      return 1;
     3033    }
     3034  r_inputs = getMap (request_inputs, "storeExecuteResponse");
     3035  int eres = SERVICE_STARTED;
     3036  int cpid = getpid ();
    30203037  /**
    30213038   * Initialize the specific [lenv] section which contains runtime variables:
     
    30363053   *
    30373054   */
    3038                                                          maps * _tmpMaps =
    3039                                                          (maps *)
    3040                                                          malloc (MAPS_SIZE);
    3041                                                          _tmpMaps->name =
    3042                                                          zStrdup ("lenv");
    3043                                                          char tmpBuff[100];
    3044                                                          sprintf (tmpBuff,
    3045                                                                   "%i",
    3046                                                                   (cpid +
    3047                                                                    (int)
    3048                                                                    time
    3049                                                                    (NULL)));
    3050                                                          _tmpMaps->content =
    3051                                                          createMap ("usid",
    3052                                                                     tmpBuff);
    3053                                                          _tmpMaps->next =
    3054                                                          NULL;
    3055                                                          sprintf (tmpBuff,
    3056                                                                   "%i", cpid);
    3057                                                          addToMap
    3058                                                          (_tmpMaps->content,
    3059                                                           "sid", tmpBuff);
    3060                                                          addToMap
    3061                                                          (_tmpMaps->content,
    3062                                                           "status", "0");
    3063                                                          addToMap
    3064                                                          (_tmpMaps->content,
    3065                                                           "cwd", ntmp);
    3066                                                          addToMap
    3067                                                          (_tmpMaps->content,
    3068                                                           "message",
    3069                                                           _
    3070                                                           ("No message provided"));
    3071                                                          map * ltmp =
    3072                                                          getMap
    3073                                                          (request_inputs,
    3074                                                           "soap");
    3075                                                          if (ltmp !=
    3076                                                              NULL)
    3077                                                          addToMap
    3078                                                          (_tmpMaps->content,
    3079                                                           "soap",
    3080                                                           ltmp->value);
    3081                                                          else
    3082                                                          addToMap
    3083                                                          (_tmpMaps->content,
    3084                                                           "soap", "false");
    3085                                                          if (cgiCookie != NULL
    3086                                                              &&
    3087                                                              strlen
    3088                                                              (cgiCookie) > 0)
    3089                                                          {
    3090                                                          int hasValidCookie =
    3091                                                          -1;
    3092                                                          char *tcook =
    3093                                                          zStrdup (cgiCookie);
    3094                                                          char *tmp = NULL;
    3095                                                          map * testing =
    3096                                                          getMapFromMaps (m,
    3097                                                                          "main",
    3098                                                                          "cookiePrefix");
    3099                                                          if (testing == NULL)
    3100                                                          {
    3101                                                          tmp =
    3102                                                          zStrdup ("ID=");}
    3103                                                          else
    3104                                                          {
    3105                                                          tmp =
    3106                                                          (char *)
    3107                                                          malloc ((strlen
    3108                                                                   (testing->
    3109                                                                    value) +
    3110                                                                   2) *
    3111                                                                  sizeof
    3112                                                                  (char));
    3113                                                          sprintf (tmp, "%s=",
    3114                                                                   testing->
    3115                                                                   value);}
    3116                                                          if (strstr
    3117                                                              (cgiCookie,
    3118                                                               ";") != NULL)
    3119                                                          {
    3120                                                          char *token,
    3121                                                          *saveptr;
    3122                                                          token =
    3123                                                          strtok_r (cgiCookie,
    3124                                                                    ";",
    3125                                                                    &saveptr);
    3126                                                          while (token != NULL)
    3127                                                          {
    3128                                                          if (strcasestr
    3129                                                              (token,
    3130                                                               tmp) != NULL)
    3131                                                          {
    3132                                                          if (tcook != NULL)
    3133                                                          free (tcook);
    3134                                                          tcook =
    3135                                                          zStrdup (token);
    3136                                                          hasValidCookie = 1;}
    3137                                                          token =
    3138                                                          strtok_r (NULL, ";",
    3139                                                                    &saveptr);}
    3140                                                          }
    3141                                                          else
    3142                                                          {
    3143                                                          if (strstr
    3144                                                              (cgiCookie,
    3145                                                               "=") != NULL
    3146                                                              &&
    3147                                                              strcasestr
    3148                                                              (cgiCookie,
    3149                                                               tmp) != NULL)
    3150                                                          {
    3151                                                          tcook =
    3152                                                          zStrdup (cgiCookie);
    3153                                                          hasValidCookie = 1;}
    3154                                                          if (tmp != NULL)
    3155                                                          {
    3156                                                          free (tmp);}
    3157                                                          }
    3158                                                          if (hasValidCookie >
    3159                                                              0)
    3160                                                          {
    3161                                                          addToMap
    3162                                                          (_tmpMaps->content,
    3163                                                           "sessid",
    3164                                                           strstr (tcook,
    3165                                                                   "=") + 1);
    3166                                                          char
    3167                                                          session_file_path
    3168                                                          [1024];
    3169                                                          map * tmpPath =
    3170                                                          getMapFromMaps (m,
    3171                                                                          "main",
    3172                                                                          "sessPath");
    3173                                                          if (tmpPath ==
    3174                                                              NULL) tmpPath =
    3175                                                          getMapFromMaps (m,
    3176                                                                          "main",
    3177                                                                          "tmpPath");
    3178                                                          char *tmp1 =
    3179                                                          strtok (tcook, ";");
    3180                                                          if (tmp1 !=
    3181                                                              NULL)
    3182                                                          sprintf
    3183                                                          (session_file_path,
    3184                                                           "%s/sess_%s.cfg",
    3185                                                           tmpPath->value,
    3186                                                           strstr (tmp1,
    3187                                                                   "=") + 1);
    3188                                                          else
    3189                                                          sprintf
    3190                                                          (session_file_path,
    3191                                                           "%s/sess_%s.cfg",
    3192                                                           tmpPath->value,
    3193                                                           strstr (cgiCookie,
    3194                                                                   "=") + 1);
    3195                                                          free (tcook);
    3196                                                          maps * tmpSess =
    3197                                                          (maps *)
    3198                                                          malloc (MAPS_SIZE);
    3199                                                          struct stat
    3200                                                          file_status;
    3201                                                          int istat =
    3202                                                          stat
    3203                                                          (session_file_path,
    3204                                                           &file_status);
    3205                                                          if (istat == 0
    3206                                                              &&
    3207                                                              file_status.
    3208                                                              st_size > 0)
    3209                                                          {
    3210                                                          conf_read
    3211                                                          (session_file_path,
    3212                                                           tmpSess);
    3213                                                          addMapsToMaps (&m,
    3214                                                                         tmpSess);
    3215                                                          freeMaps (&tmpSess);
    3216                                                          free (tmpSess);}
    3217                                                          }
    3218                                                          }
    3219                                                          addMapsToMaps (&m,
    3220                                                                         _tmpMaps);
    3221                                                          freeMaps (&_tmpMaps);
    3222                                                          free (_tmpMaps);
    3223 #ifdef DEBUG
    3224                                                          dumpMap
    3225                                                          (request_inputs);
     3055  maps *_tmpMaps = (maps *) malloc (MAPS_SIZE);
     3056  _tmpMaps->name = zStrdup ("lenv");
     3057  char tmpBuff[100];
     3058  sprintf (tmpBuff, "%i", (cpid + (int) time (NULL)));
     3059  _tmpMaps->content = createMap ("usid", tmpBuff);
     3060  _tmpMaps->next = NULL;
     3061  sprintf (tmpBuff, "%i", cpid);
     3062  addToMap (_tmpMaps->content, "sid", tmpBuff);
     3063  addToMap (_tmpMaps->content, "status", "0");
     3064  addToMap (_tmpMaps->content, "cwd", ntmp);
     3065  addToMap (_tmpMaps->content, "message", _("No message provided"));
     3066  map *ltmp = getMap (request_inputs,
     3067                      "soap");
     3068  if (ltmp != NULL)
     3069    addToMap (_tmpMaps->content, "soap", ltmp->value);
     3070  else
     3071    addToMap (_tmpMaps->content, "soap", "false");
     3072  if (cgiCookie != NULL && strlen (cgiCookie) > 0)
     3073    {
     3074      int hasValidCookie = -1;
     3075      char *tcook = zStrdup (cgiCookie);
     3076      char *tmp = NULL;
     3077      map *testing = getMapFromMaps (m, "main", "cookiePrefix");
     3078      if (testing == NULL)
     3079        {
     3080          tmp = zStrdup ("ID=");
     3081        }
     3082      else
     3083        {
     3084          tmp =
     3085            (char *) malloc ((strlen (testing->value) + 2) * sizeof (char));
     3086          sprintf (tmp, "%s=", testing->value);
     3087        }
     3088      if (strstr (cgiCookie, ";") != NULL)
     3089        {
     3090          char *token, *saveptr;
     3091          token = strtok_r (cgiCookie, ";", &saveptr);
     3092          while (token != NULL)
     3093            {
     3094              if (strcasestr (token, tmp) != NULL)
     3095                {
     3096                  if (tcook != NULL)
     3097                    free (tcook);
     3098                  tcook = zStrdup (token);
     3099                  hasValidCookie = 1;
     3100                }
     3101              token = strtok_r (NULL, ";", &saveptr);
     3102            }
     3103        }
     3104      else
     3105        {
     3106          if (strstr
     3107              (cgiCookie, "=") != NULL && strcasestr (cgiCookie, tmp) != NULL)
     3108            {
     3109              tcook = zStrdup (cgiCookie);
     3110              hasValidCookie = 1;
     3111            }
     3112          if (tmp != NULL)
     3113            {
     3114              free (tmp);
     3115            }
     3116        }
     3117      if (hasValidCookie > 0)
     3118        {
     3119          addToMap (_tmpMaps->content, "sessid", strstr (tcook, "=") + 1);
     3120          char session_file_path[1024];
     3121          map *tmpPath = getMapFromMaps (m,
     3122                                         "main",
     3123                                         "sessPath");
     3124          if (tmpPath == NULL)
     3125            tmpPath = getMapFromMaps (m, "main", "tmpPath");
     3126          char *tmp1 = strtok (tcook, ";");
     3127          if (tmp1 != NULL)
     3128            sprintf
     3129              (session_file_path,
     3130               "%s/sess_%s.cfg", tmpPath->value, strstr (tmp1, "=") + 1);
     3131          else
     3132            sprintf
     3133              (session_file_path,
     3134               "%s/sess_%s.cfg", tmpPath->value, strstr (cgiCookie, "=") + 1);
     3135          free (tcook);
     3136          maps *tmpSess = (maps *) malloc (MAPS_SIZE);
     3137          struct stat file_status;
     3138          int istat = stat (session_file_path,
     3139                            &file_status);
     3140          if (istat == 0 && file_status.st_size > 0)
     3141            {
     3142              conf_read (session_file_path, tmpSess);
     3143              addMapsToMaps (&m, tmpSess);
     3144              freeMaps (&tmpSess);
     3145              free (tmpSess);
     3146            }
     3147        }
     3148    }
     3149  addMapsToMaps (&m, _tmpMaps);
     3150  freeMaps (&_tmpMaps);
     3151  free (_tmpMaps);
     3152#ifdef DEBUG
     3153  dumpMap (request_inputs);
    32263154#endif
    32273155#ifdef WIN32
    3228                                                          char *cgiSidL = NULL;
    3229                                                          if (getenv ("CGISID")
    3230                                                              !=
    3231                                                              NULL)
    3232                                                          addToMap
    3233                                                          (request_inputs,
    3234                                                           "cgiSid",
    3235                                                           getenv ("CGISID"));
    3236                                                          map * test1 =
    3237                                                          getMap
    3238                                                          (request_inputs,
    3239                                                           "cgiSid");
    3240                                                          if (test1 != NULL)
    3241                                                          {
    3242                                                          cgiSid =
    3243                                                          test1->value;
    3244                                                          addToMap
    3245                                                          (request_inputs,
    3246                                                           "storeExecuteResponse",
    3247                                                           "true");
    3248                                                          addToMap
    3249                                                          (request_inputs,
    3250                                                           "status", "true");
    3251                                                          setMapInMaps (m,
    3252                                                                        "lenv",
    3253                                                                        "sid",
    3254                                                                        test1->
    3255                                                                        value);
    3256                                                          status =
    3257                                                          getMap
    3258                                                          (request_inputs,
    3259                                                           "status");}
    3260 #endif
    3261                                                          char *fbkp, *fbkp1;
    3262                                                          FILE * f0, *f1;
    3263                                                          if (status != NULL)
    3264                                                          if (strcasecmp
    3265                                                              (status->value,
    3266                                                               "false") ==
    3267                                                              0) status =
    3268                                                          NULLMAP;
    3269                                                          if (status ==
    3270                                                              NULLMAP)
    3271                                                          {
    3272                                                          loadServiceAndRun
    3273                                                          (&m, s1,
    3274                                                           request_inputs,
    3275                                                           &request_input_real_format,
    3276                                                           &request_output_real_format,
    3277                                                           &eres);}
    3278                                                          else
    3279                                                          {
    3280                                                          int pid;
    3281 #ifdef DEBUG
    3282                                                          fprintf (stderr,
    3283                                                                   "\nPID : %d\n",
    3284                                                                   cpid);
     3156  char *cgiSidL = NULL;
     3157  if (getenv ("CGISID") != NULL)
     3158    addToMap (request_inputs, "cgiSid", getenv ("CGISID"));
     3159  map *test1 = getMap (request_inputs, "cgiSid");
     3160  if (test1 != NULL)
     3161    {
     3162      cgiSid = test1->value;
     3163      addToMap (request_inputs, "storeExecuteResponse", "true");
     3164      addToMap (request_inputs, "status", "true");
     3165      setMapInMaps (m, "lenv", "sid", test1->value);
     3166      status = getMap (request_inputs, "status");
     3167    }
     3168#endif
     3169  char *fbkp, *fbkp1;
     3170  FILE *f0, *f1;
     3171  if (status != NULL)
     3172    if (strcasecmp (status->value, "false") == 0)
     3173      status = NULLMAP;
     3174  if (status == NULLMAP)
     3175    {
     3176      loadServiceAndRun
     3177        (&m, s1,
     3178         request_inputs,
     3179         &request_input_real_format, &request_output_real_format, &eres);
     3180    }
     3181  else
     3182    {
     3183      int pid;
     3184#ifdef DEBUG
     3185      fprintf (stderr, "\nPID : %d\n", cpid);
    32853186#endif
    32863187#ifndef WIN32
    3287                                                          pid = fork ();
     3188      pid = fork ();
    32883189#else
    3289                                                          if (cgiSid == NULL)
    3290                                                          {
    3291                                                          createProcess (m,
    3292                                                                         request_inputs,
    3293                                                                         s1,
    3294                                                                         NULL,
    3295                                                                         cpid,
    3296                                                                         request_input_real_format,
    3297                                                                         request_output_real_format);
    3298                                                          pid = cpid;}
    3299                                                          else
    3300                                                          {
    3301                                                          pid = 0;
    3302                                                          cpid =
    3303                                                          atoi (cgiSid);}
    3304 #endif
    3305                                                          if (pid > 0)
    3306                                                          {
     3190      if (cgiSid == NULL)
     3191        {
     3192          createProcess (m,
     3193                         request_inputs,
     3194                         s1,
     3195                         NULL,
     3196                         cpid,
     3197                         request_input_real_format,
     3198                         request_output_real_format);
     3199          pid = cpid;
     3200        }
     3201      else
     3202        {
     3203          pid = 0;
     3204          cpid = atoi (cgiSid);
     3205        }
     3206#endif
     3207      if (pid > 0)
     3208        {
    33073209      /**
    33083210       * dady :
     
    33103212       */
    33113213#ifdef DEBUG
    3312                                                          fprintf (stderr,
    3313                                                                   "father pid continue (origin %d) %d ...\n",
    3314                                                                   cpid,
    3315                                                                   getpid ());
    3316 #endif
    3317                                                          eres =
    3318                                                          SERVICE_ACCEPTED;}
    3319                                                          else
    3320                                                          if (pid == 0)
    3321                                                          {
     3214          fprintf (stderr,
     3215                   "father pid continue (origin %d) %d ...\n",
     3216                   cpid, getpid ());
     3217#endif
     3218          eres = SERVICE_ACCEPTED;
     3219        }
     3220      else if (pid == 0)
     3221        {
    33223222      /**
    33233223       * son : have to close the stdout, stdin and stderr to let the parent
    33243224       * process answer to http client.
    33253225       */
    3326                                                          r_inputs =
    3327                                                          getMapFromMaps (m,
    3328                                                                          "main",
    3329                                                                          "tmpPath");
    3330                                                          map * r_inputs1 =
    3331                                                          getMap (s1->content,
    3332                                                                  "ServiceProvider");
    3333                                                          fbkp =
    3334                                                          (char *)
    3335                                                          malloc ((strlen
    3336                                                                   (r_inputs->
    3337                                                                    value) +
    3338                                                                   strlen
    3339                                                                   (r_inputs1->
    3340                                                                    value) +
    3341                                                                   1024) *
    3342                                                                  sizeof
    3343                                                                  (char));
    3344                                                          sprintf (fbkp,
    3345                                                                   "%s/%s_%d.xml",
    3346                                                                   r_inputs->
    3347                                                                   value,
    3348                                                                   r_inputs1->
    3349                                                                   value,
    3350                                                                   cpid);
    3351                                                          char *flog =
    3352                                                          (char *)
    3353                                                          malloc ((strlen
    3354                                                                   (r_inputs->
    3355                                                                    value) +
    3356                                                                   strlen
    3357                                                                   (r_inputs1->
    3358                                                                    value) +
    3359                                                                   1024) *
    3360                                                                  sizeof
    3361                                                                  (char));
    3362                                                          sprintf (flog,
    3363                                                                   "%s/%s_%d_error.log",
    3364                                                                   r_inputs->
    3365                                                                   value,
    3366                                                                   r_inputs1->
    3367                                                                   value,
    3368                                                                   cpid);
    3369 #ifdef DEBUG
    3370                                                          fprintf (stderr,
    3371                                                                   "RUN IN BACKGROUND MODE \n");
    3372                                                          fprintf (stderr,
    3373                                                                   "son pid continue (origin %d) %d ...\n",
    3374                                                                   cpid,
    3375                                                                   getpid ());
    3376                                                          fprintf (stderr,
    3377                                                                   "\nFILE TO STORE DATA %s\n",
    3378                                                                   r_inputs->
    3379                                                                   value);
    3380 #endif
    3381                                                          freopen (flog, "w+",
    3382                                                                   stderr);
    3383                                                          f0 =
    3384                                                          freopen (fbkp, "w+",
    3385                                                                   stdout);
     3226          r_inputs = getMapFromMaps (m, "main", "tmpPath");
     3227          map *r_inputs1 = getMap (s1->content,
     3228                                   "ServiceProvider");
     3229          fbkp = (char *)
     3230            malloc ((strlen
     3231                     (r_inputs->value) +
     3232                     strlen (r_inputs1->value) + 1024) * sizeof (char));
     3233          sprintf (fbkp, "%s/%s_%d.xml", r_inputs->value,
     3234                   r_inputs1->value, cpid);
     3235          char *flog =
     3236            (char *)
     3237            malloc ((strlen (r_inputs->value) +
     3238                     strlen (r_inputs1->value) + 1024) * sizeof (char));
     3239          sprintf (flog, "%s/%s_%d_error.log", r_inputs->value,
     3240                   r_inputs1->value, cpid);
     3241#ifdef DEBUG
     3242          fprintf (stderr, "RUN IN BACKGROUND MODE \n");
     3243          fprintf (stderr,
     3244                   "son pid continue (origin %d) %d ...\n", cpid, getpid ());
     3245          fprintf (stderr, "\nFILE TO STORE DATA %s\n", r_inputs->value);
     3246#endif
     3247          freopen (flog, "w+", stderr);
     3248          f0 = freopen (fbkp, "w+", stdout);
    33863249#ifndef WIN32
    3387                                                          fclose (stdin);
    3388 #endif
    3389                                                          free (flog);
     3250          fclose (stdin);
     3251#endif
     3252          free (flog);
    33903253      /**
    33913254       * set status to SERVICE_STARTED and flush stdout to ensure full
     
    33943257       * this way the data will be updated at the end of the process run.
    33953258       */
    3396                                                          printProcessResponse
    3397                                                          (m, request_inputs,
    3398                                                           cpid, s1,
    3399                                                           r_inputs1->value,
    3400                                                           SERVICE_STARTED,
    3401                                                           request_input_real_format,
    3402                                                           request_output_real_format);
     3259          printProcessResponse
     3260            (m, request_inputs,
     3261             cpid, s1,
     3262             r_inputs1->value,
     3263             SERVICE_STARTED,
     3264             request_input_real_format, request_output_real_format);
    34033265#ifndef WIN32
    3404                                                          fflush (stdout);
    3405                                                          rewind (stdout);
     3266          fflush (stdout);
     3267          rewind (stdout);
    34063268#else
    34073269#endif
    3408                                                          fbkp1 =
    3409                                                          (char *)
    3410                                                          malloc ((strlen
    3411                                                                   (r_inputs->
    3412                                                                    value) +
    3413                                                                   strlen
    3414                                                                   (r_inputs1->
    3415                                                                    value) +
    3416                                                                   1024) *
    3417                                                                  sizeof
    3418                                                                  (char));
    3419                                                          sprintf (fbkp1,
    3420                                                                   "%s/%s_final_%d.xml",
    3421                                                                   r_inputs->
    3422                                                                   value,
    3423                                                                   r_inputs1->
    3424                                                                   value,
    3425                                                                   cpid);
    3426                                                          f1 =
    3427                                                          freopen (fbkp1, "w+",
    3428                                                                   stdout);
    3429                                                          loadServiceAndRun
    3430                                                          (&m, s1,
    3431                                                           request_inputs,
    3432                                                           &request_input_real_format,
    3433                                                           &request_output_real_format,
    3434                                                           &eres);}
    3435                                                          else
    3436                                                          {
     3270          fbkp1 = (char *)
     3271            malloc ((strlen
     3272                     (r_inputs->value) +
     3273                     strlen (r_inputs1->value) + 1024) * sizeof (char));
     3274          sprintf (fbkp1, "%s/%s_final_%d.xml", r_inputs->value,
     3275                   r_inputs1->value, cpid);
     3276          f1 = freopen (fbkp1, "w+", stdout);
     3277          loadServiceAndRun
     3278            (&m, s1,
     3279             request_inputs,
     3280             &request_input_real_format, &request_output_real_format, &eres);
     3281        }
     3282      else
     3283        {
    34373284      /**
    34383285       * error server don't accept the process need to output a valid
    34393286       * error response here !!!
    34403287       */
    3441                                                          eres = -1;
    3442                                                          errorException (m,
    3443                                                                          _
    3444                                                                          ("Unable to run the child process properly"),
    3445                                                                          "InternalError",
    3446                                                                          NULL);}
    3447                                                          }
    3448 
    3449 #ifdef DEBUG
    3450                                                          dumpMaps
    3451                                                          (request_output_real_format);
    3452 #endif
    3453                                                          if (eres != -1)
    3454                                                          outputResponse (s1,
    3455                                                                          request_input_real_format,
    3456                                                                          request_output_real_format,
    3457                                                                          request_inputs,
    3458                                                                          cpid,
    3459                                                                          m,
    3460                                                                          eres);
    3461                                                          fflush (stdout);
     3288          eres = -1;
     3289          errorException (m,
     3290                          _
     3291                          ("Unable to run the child process properly"),
     3292                          "InternalError", NULL);
     3293        }
     3294    }
     3295
     3296#ifdef DEBUG
     3297  dumpMaps (request_output_real_format);
     3298#endif
     3299  if (eres != -1)
     3300    outputResponse (s1,
     3301                    request_input_real_format,
     3302                    request_output_real_format,
     3303                    request_inputs, cpid, m, eres);
     3304  fflush (stdout);
    34623305  /**
    34633306   * Ensure that if error occurs when freeing memory, no signal will return
     
    34663309   */
    34673310#ifndef USE_GDB
    3468                                                          (void)
    3469                                                          signal (SIGSEGV,
    3470                                                                  donothing);
    3471                                                          (void)
    3472                                                          signal (SIGTERM,
    3473                                                                  donothing);
    3474                                                          (void)
    3475                                                          signal (SIGINT,
    3476                                                                  donothing);
    3477                                                          (void)
    3478                                                          signal (SIGILL,
    3479                                                                  donothing);
    3480                                                          (void)
    3481                                                          signal (SIGFPE,
    3482                                                                  donothing);
    3483                                                          (void)
    3484                                                          signal (SIGABRT,
    3485                                                                  donothing);
    3486 #endif
    3487                                                          if (((int) getpid ())
    3488                                                              != cpid
    3489                                                              || cgiSid !=
    3490                                                              NULL)
    3491                                                          {
    3492                                                          fclose (stdout);
    3493                                                          fclose (stderr);
    3494                                                          unhandleStatus (m);
     3311  (void) signal (SIGSEGV, donothing);
     3312  (void) signal (SIGTERM, donothing);
     3313  (void) signal (SIGINT, donothing);
     3314  (void) signal (SIGILL, donothing);
     3315  (void) signal (SIGFPE, donothing);
     3316  (void) signal (SIGABRT, donothing);
     3317#endif
     3318  if (((int) getpid ()) != cpid || cgiSid != NULL)
     3319    {
     3320      fclose (stdout);
     3321      fclose (stderr);
     3322      unhandleStatus (m);
    34953323    /**
    34963324     * Dump back the final file fbkp1 to fbkp
    34973325     */
    3498                                                          fclose (f0);
    3499                                                          fclose (f1);
    3500                                                          FILE * f2 =
    3501                                                          fopen (fbkp1, "rb");
    3502                                                          FILE * f3 =
    3503                                                          fopen (fbkp, "wb+");
    3504                                                          free (fbkp);
    3505                                                          fseek (f2, 0,
    3506                                                                 SEEK_END);
    3507                                                          long flen =
    3508                                                          ftell (f2);
    3509                                                          fseek (f2, 0,
    3510                                                                 SEEK_SET);
    3511                                                          char *tmps1 =
    3512                                                          (char
    3513                                                           *)malloc ((flen +
    3514                                                                      1) *
    3515                                                                     sizeof
    3516                                                                     (char));
    3517                                                          fread (tmps1, flen,
    3518                                                                 1, f2);
    3519                                                          fwrite (tmps1, 1,
    3520                                                                  flen, f3);
    3521                                                          fclose (f2);
    3522                                                          fclose (f3);
    3523                                                          unlink (fbkp1);
    3524                                                          free (fbkp1);
    3525                                                          free (tmps1);}
    3526 
    3527                                                          freeService (&s1);
    3528                                                          free (s1);
    3529                                                          freeMaps (&m);
    3530                                                          free (m);
    3531                                                          freeMaps
    3532                                                          (&request_input_real_format);
    3533                                                          free
    3534                                                          (request_input_real_format);
    3535                                                          freeMaps
    3536                                                          (&request_output_real_format);
    3537                                                          free
    3538                                                          (request_output_real_format);
    3539                                                          free (REQUEST);
    3540                                                          free (SERVICE_URL);
    3541 #ifdef DEBUG
    3542                                                          fprintf (stderr,
    3543                                                                   "Processed response \n");
    3544                                                          fflush (stdout);
    3545                                                          fflush (stderr);
    3546 #endif
    3547                                                          return 0;}
     3326      fclose (f0);
     3327      fclose (f1);
     3328      FILE *f2 = fopen (fbkp1, "rb");
     3329      FILE *f3 = fopen (fbkp, "wb+");
     3330      free (fbkp);
     3331      fseek (f2, 0, SEEK_END);
     3332      long flen = ftell (f2);
     3333      fseek (f2, 0, SEEK_SET);
     3334      char *tmps1 = (char *) malloc ((flen + 1) * sizeof (char));
     3335      fread (tmps1, flen, 1, f2);
     3336      fwrite (tmps1, 1, flen, f3);
     3337      fclose (f2);
     3338      fclose (f3);
     3339      unlink (fbkp1);
     3340      free (fbkp1);
     3341      free (tmps1);
     3342    }
     3343
     3344  freeService (&s1);
     3345  free (s1);
     3346  freeMaps (&m);
     3347  free (m);
     3348  freeMaps (&request_input_real_format);
     3349  free (request_input_real_format);
     3350  freeMaps (&request_output_real_format);
     3351  free (request_output_real_format);
     3352  free (REQUEST);
     3353  free (SERVICE_URL);
     3354#ifdef DEBUG
     3355  fprintf (stderr, "Processed response \n");
     3356  fflush (stdout);
     3357  fflush (stderr);
     3358#endif
     3359  return 0;
     3360}
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png