Changeset 549 for branches


Ignore:
Timestamp:
Feb 2, 2015, 10:04:56 AM (9 years ago)
Author:
david
Message:
  • Adding Process Management
Location:
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/Makefile.in

    r512 r549  
    1212JAVA_FILE=@JAVA_FILE@
    1313
    14 CFLAGS=@DEB_DEF@ -fpic ${GLIB_CPPFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
    15 LDFLAGS=-lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${GLIB_LDFLAGS}  ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${YAML_LDFLAGS}
     14CFLAGS=@DEB_DEF@  -fpic ${GLIB_CPPFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
     15LDFLAGS=  -lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${GLIB_LDFLAGS}  ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${YAML_LDFLAGS}
    1616
    1717PHPCFLAGS=@PHP_CPPFLAGS@
     
    5959        gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c ulinet.c
    6060
    61 service_zcfg.o: service_zcfg.c
    62         gcc -fPIC ${GLIB_CPPFLAGS} ${XML2CFLAGS} -c service_zcfg.c
     61service_zcfg.o: service_zcfg.c service.h
     62        g++ ${GLIB_CPPFLAGS} ${XML2CFLAGS} -c service_zcfg.c
    6363
    6464service_internal.o: service_internal.c service.h
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/configure.ac

    r512 r549  
    340340        LIBS="$PYTHON_LDFLAGS"
    341341        PY_LIB=`$PYTHONCONFIG --libs | sed -e 's/^.*\(python2\..\)$/\1/'`
    342         AC_CHECK_LIB([$PY_LIB], [PyObject_CallObject], [], [AC_MSG_ERROR([could not find libpython])], [])
     342        #AC_CHECK_LIB([$PY_LIB], [PyObject_CallObject], [], [AC_MSG_ERROR([could not find libpython])], [])
    343343        AC_SUBST([PYTHON_CPPFLAGS])
    344344        AC_SUBST([PYTHON_LDFLAGS])
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal.c

    r531 r549  
    5858
    5959void
    60 printHeaders (maps * m)
     60printHeaders (maps * m,FCGX_Stream *out)
    6161{
    6262  maps *_tmp = getMaps (m, "headers");
     
    6666      while (_tmp1 != NULL)
    6767        {
    68           printf ("%s: %s\r\n", _tmp1->name, _tmp1->value);
     68          FCGX_FPrintF(out,"%s: %s\r\n", _tmp1->name, _tmp1->value);
     69          //printf ("%s: %s\r\n", _tmp1->name, _tmp1->value);
    6970          _tmp1 = _tmp1->next;
    7071        }
     
    100101
    101102#include <windows.h>
    102 #include <fcgi_stdio.h>
     103//#include <fcgi_stdio.h>
    103104#include <stdio.h>
    104105#include <conio.h>
     
    16891690printProcessResponse (maps * m, map * request, int pid, service * serv,
    16901691                      const char *service, int status, maps * inputs,
    1691                       maps * outputs)
     1692                      maps * outputs, FCGX_Stream* out)
    16921693{
    16931694  xmlNsPtr ns, ns_ows, ns_xlink, ns_xsi;
     
    19901991          map *errormap = createMap ("text", tmpMsg);
    19911992          addToMap (errormap, "code", "InternalError");
    1992           printExceptionReportResponse (m, errormap);
     1993          printExceptionReportResponse (m, errormap,out);
    19931994          freeMap (&errormap);
    19941995          free (errormap);
     
    20052006      fclose (output);
    20062007    }
    2007   printDocument (m, doc, pid);
     2008  printDocument (m, doc, pid,out);
    20082009
    20092010  xmlCleanupParser ();
     
    20132014
    20142015void
    2015 printDocument (maps * m, xmlDocPtr doc, int pid)
     2016printDocument (maps * m, xmlDocPtr doc, int pid,FCGX_Stream * out)
    20162017{
    20172018  char *encoding = getEncoding (m);
    20182019  if (pid == getpid ())
    20192020    {
    2020       printHeaders (m);
    2021       printf ("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",
    2022               encoding);
    2023     }
    2024   fflush (stdout);
     2021      printHeaders (m,out);
     2022      FCGX_FPrintF(out,"Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
     2023      //printf ("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
     2024    }
     2025  //fflush (stdout);
    20252026  xmlChar *xmlbuff;
    20262027  int buffersize;
     
    20302031   */
    20312032  xmlDocDumpFormatMemoryEnc (doc, &xmlbuff, &buffersize, encoding, 1);
    2032   printf ("%s", xmlbuff);
    2033   fflush (stdout);
     2033  FCGX_FPrintF(out,(char *)xmlbuff);
     2034  FCGX_FFlush(out);
     2035  //printf ("%s", xmlbuff);
     2036  //fflush (stdout);
    20342037  /*
    20352038   * Free associated memory.
     
    24622465
    24632466void
    2464 printExceptionReportResponse (maps * m, map * s)
     2467printExceptionReportResponse (maps * m, map * s,FCGX_Stream * out)
    24652468{
    24662469  if (getMapFromMaps (m, "lenv", "hasPrinted") != NULL)
     
    25042507          if (getpid () == atoi (tmpSid->value))
    25052508            {
    2506               printHeaders (m);
    2507               printf
    2508                 ("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",
    2509                  encoding, exceptionCode);
     2509              printHeaders (m,out);
     2510              FCGX_FPrintF(out,"Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",encoding, exceptionCode);
     2511              //printf("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",encoding, exceptionCode);
    25102512            }
    25112513        }
    25122514      else
    25132515        {
    2514           printHeaders (m);
    2515           printf ("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",
    2516                   encoding, exceptionCode);
     2516          printHeaders (m,out);
     2517          FCGX_FPrintF(out,"Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",
     2518                            encoding, exceptionCode);
     2519          //printf ("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",encoding, exceptionCode);
    25172520        }
    25182521    }
    25192522  else
    2520     {
    2521       printf ("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",
    2522               encoding, exceptionCode);
     2523    { 
     2524      FCGX_FPrintF(out,"Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",encoding, exceptionCode);
     2525      //printf ("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",encoding, exceptionCode);
    25232526    }
    25242527  n = createExceptionReportNode (m, s, 1);
    25252528  xmlDocSetRootElement (doc, n);
    25262529  xmlDocDumpFormatMemoryEnc (doc, &xmlbuff, &buffersize, encoding, 1);
    2527   printf ("%s", xmlbuff);
    2528   fflush (stdout);
     2530  //printf ("%s", xmlbuff);
     2531  FCGX_FPrintF(out,"%s",xmlbuff);
     2532FCGX_FFlush(out);
     2533  //fflush (stdout);
    25292534  xmlFreeDoc (doc);
    25302535  xmlFree (xmlbuff);
     
    25952600void
    25962601outputResponse (service * s, maps * request_inputs, maps * request_outputs,
    2597                 map * request_inputs1, int cpid, maps * m, int res)
    2598 {
     2602                map * request_inputs1, int cpid, maps * m, int res,FCGX_Stream *out,FCGX_Stream *err)
     2603{
     2604
     2605
    25992606#ifdef DEBUG
    26002607  dumpMaps (request_inputs);
     
    26552662          addToMap (errormap, "code", "InternalError");
    26562663
    2657           printExceptionReportResponse (m, errormap);
     2664          printExceptionReportResponse (m, errormap,out);
    26582665          freeMap (&errormap);
    26592666          free (errormap);
     
    26702677  if (asRaw == 0)
    26712678    {
     2679
     2680
    26722681#ifdef DEBUG
    26732682      fprintf (stderr, "REQUEST_OUTPUTS FINAL\n");
     
    27602769                  map *errormap = createMap ("text", tmpMsg);
    27612770                  addToMap (errormap, "code", "InternalError");
    2762                   printExceptionReportResponse (m, errormap);
     2771
     2772                  printExceptionReportResponse (m, errormap,out);
    27632773                  freeMap (&errormap);
    27642774                  free (errormap);
     
    28332843      printProcessResponse (m, request_inputs1, cpid,
    28342844                            s, r_inputs->value, res,
    2835                             request_inputs, request_outputs);
     2845                            request_inputs, request_outputs,out);
    28362846    }
    28372847  else
    28382848    {
     2849
    28392850      if (res == SERVICE_FAILED)
    28402851        {
     2852
    28412853          map *errormap;
    28422854          map *lenv;
     
    28712883          free (tmp0);
    28722884          addToMap (errormap, "code", "InternalError");
    2873           printExceptionReportResponse (m, errormap);
     2885          printExceptionReportResponse (m, errormap,out);
    28742886          freeMap (&errormap);
    28752887          free (errormap);
     
    28802892       * requested one is not present in the resulting outputs maps.
    28812893       */
     2894
     2895
    28822896      maps *tmpI = NULL;
    28832897      map *tmpIV = getMap (request_inputs1, "RawDataOutput");
     
    29052919              map *errormap = createMap ("text", tmpMsg);
    29062920              addToMap (errormap, "code", "InvalidParameterValue");
    2907               printExceptionReportResponse (m, errormap);
     2921              printExceptionReportResponse (m, errormap,out);
    29082922              freeMap (&errormap);
    29092923              free (errormap);
     
    29122926          map *fname = getMapFromMaps (tmpI, tmpI->name, "filename");
    29132927          if (fname != NULL)
    2914             printf ("Content-Disposition: attachment; filename=\"%s\"\r\n",
    2915                     fname->value);
     2928            FCGX_FPrintF(out,"Content-Disposition: attachment; filename=\"%s\"\r\n",fname->value);
     2929            //printf ("Content-Disposition: attachment; filename=\"%s\"\r\n",fname->value);
    29162930          map *rs = getMapFromMaps (tmpI, tmpI->name, "size");
    29172931          if (rs != NULL)
    2918             printf ("Content-Length: %s\r\n", rs->value);
    2919           printHeaders (m);
     2932            FCGX_FPrintF(out,"Content-Length: %s\r\n", rs->value);
     2933            //printf ("Content-Length: %s\r\n", rs->value);
     2934          printHeaders (m,out);
    29202935          char mime[1024];
    29212936          map *mi = getMap (tmpI->content, "mimeType");
     
    29372952            sprintf (mime,
    29382953                     "Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
    2939           printf ("%s", mime);
     2954          FCGX_FPrintF(out,"%s", mime);
     2955
     2956          //printf ("%s", mime);
    29402957          if (rs != NULL)
    2941             fwrite (toto->value, 1, atoi (rs->value), stdout);
     2958            FCGX_PutStr(toto->value,atoi(rs->value),out);
     2959            //fwrite (toto->value, 1, atoi (rs->value), stdout);
    29422960          else
    2943             fwrite (toto->value, 1, strlen (toto->value), stdout);
     2961             FCGX_PutStr(toto->value,strlen (toto->value),out);
     2962            //fwrite (toto->value, 1, strlen (toto->value), stdout);
     2963
     2964          FCGX_FFlush(out);
    29442965#ifdef DEBUG
    29452966          dumpMap (toto);
     
    34003421printBoundingBoxDocument (maps * m, maps * boundingbox, FILE * file)
    34013422{
    3402   if (file == NULL)
    3403     rewind (stdout);
     3423  //if (file == NULL)
     3424   // rewind (stdout);
    34043425  xmlNodePtr n;
    34053426  xmlDocPtr doc;
     
    34213442             encoding);
    34223443        }
    3423       fflush (stdout);
     3444      //fflush (stdout);
    34243445    }
    34253446
     
    35833604                      return errorException (*m,
    35843605                                             _("Unable to allocate memory."),
    3585                                              "InternalError", NULL);
     3606                                             "InternalError", NULL,NULL);
    35863607                    }
    35873608                  size_t dwRead;
     
    36033624                      return errorException (*m,
    36043625                                             _("Unable to allocate memory."),
    3605                                              "InternalError", NULL);
     3626                                             "InternalError", NULL,NULL);
    36063627                    }
    36073628                  memcpy (tmpMap->value, fcontent,
     
    36673688    {
    36683689      return errorException (*m, _("Unable to download the file."),
    3669                              "InternalError", NULL);
     3690                             "InternalError", NULL,NULL);
    36703691    }
    36713692  if (mimeType != NULL)
     
    36803701  if (tmpMap->value == NULL)
    36813702    return errorException (*m, _("Unable to allocate memory."),
    3682                            "InternalError", NULL);
     3703                           "InternalError", NULL,NULL);
    36833704  memcpy (tmpMap->value, fcontent, (fsize + 1) * sizeof (char));
    36843705
     
    36983719int
    36993720errorException (maps * m, const char *message, const char *errorcode,
    3700                 const char *locator)
     3721                const char *locator,FCGX_Stream * out)
    37013722{
    37023723  map *errormap = createMap ("text", message);
     
    37063727  else
    37073728    addToMap (errormap, "locator", "NULL");
    3708   printExceptionReportResponse (m, errormap);
     3729  printExceptionReportResponse (m, errormap,out);
    37093730  freeMap (&errormap);
    37103731  free (errormap);
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal.h

    r512 r549  
    3939#include <sys/types.h>
    4040//#include "cgic.h"
     41#include <fcgiapp.h>
    4142#ifndef WIN32
    4243#include <sys/ipc.h>
     
    119120  void zooXmlCleanupDocs ();
    120121  void addPrefix (maps * conf, map * level, service * serv);
    121   void printExceptionReportResponse (maps *, map *);
     122  void printExceptionReportResponse (maps *, map *,FCGX_Stream * out);
    122123  xmlNodePtr createExceptionReportNode (maps *, map *, int);
    123124  void printProcessResponse (maps *, map *, int, service *, const char *, int,
    124                              maps *, maps *);
     125                             maps *, maps *,FCGX_Stream *);
    125126  xmlNodePtr printGetCapabilitiesHeader (xmlDocPtr, const char *, maps *);
    126127  void printGetCapabilitiesForProcess (maps *, xmlNodePtr, service *);
     
    129130  void printFullDescription (int, elements *, const char *, xmlNsPtr,
    130131                             xmlNodePtr);
    131   void printDocument (maps *, xmlDocPtr, int);
     132  void printDocument (maps *, xmlDocPtr, int, FCGX_Stream *);
    132133  void printDescription (xmlNodePtr, xmlNsPtr, const char *, map *);
    133134  void printIOType (xmlDocPtr, xmlNodePtr, xmlNsPtr, xmlNsPtr, xmlNsPtr,
     
    139140                                elements *, maps *, const char *);
    140141
    141   void outputResponse (service *, maps *, maps *, map *, int, maps *, int);
     142  void outputResponse (service *, maps *, maps *, map *, int, maps *, int,FCGX_Stream *,FCGX_Stream *);
    142143
    143144  char *base64 (const char *, int);
     
    147148  char *addDefaultValues (maps **, elements *, maps *, int);
    148149
    149   int errorException (maps *, const char *, const char *, const char *);
     150  int errorException (maps *, const char *, const char *, const char *,FCGX_Stream *);
    150151
    151152  int checkForSoapEnvelope (xmlDocPtr);
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal_js.c

    r531 r549  
    216216      map *err = createMap ("text", tmp1);
    217217      addToMap (err, "code", "NoApplicableCode");
    218       printExceptionReportResponse (mc, err);
     218      //printExceptionReportResponse (mc, err);
    219219      freeMap (&err);
    220220      free (err);
     
    268268      map *err = createMap ("text", tmp1);
    269269      addToMap (err, "code", "NoApplicableCode");
    270       printExceptionReportResponse (*main_conf, err);
     270      //printExceptionReportResponse (*main_conf, err);
    271271      freeMap (&err);
    272272      free (err);
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal_python.c

    r531 r549  
    127127int
    128128zoo_python_support (maps ** main_conf, map * request, service * s,
    129                     maps ** real_inputs, maps ** real_outputs)
     129                    maps ** real_inputs, maps ** real_outputs,FCGX_Stream * err)
    130130{
    131131  char *pythonpath;
     
    222222                            "Unable to parse serviceProvider please check your zcfg file.");
    223223      addToMap (err, "code", "NoApplicableCode");
    224       printExceptionReportResponse (m, err);
     224      //printExceptionReportResponse (m, err);
    225225      exit (-1);
    226226    }
     
    299299              map *err = createMap ("text", pbt);
    300300              addToMap (err, "code", "NoApplicableCode");
    301               printExceptionReportResponse (m, err);
     301              //printExceptionReportResponse (m, err);
    302302              res = -1;
    303303            }
     
    309309                   s->name, tmp->value);
    310310          map *tmps = createMap ("text", tmpS);
    311           printExceptionReportResponse (m, tmps);
     311          //printExceptionReportResponse (m, tmps);
    312312          res = -1;
    313313        }
     
    318318      sprintf (tmpS, "Python module %s cannot be loaded.\n", tmp->value);
    319319      map *tmps = createMap ("text", tmpS);
    320       printExceptionReportResponse (m, tmps);
     320      //printExceptionReportResponse (m, tmps);
    321321      if (PyErr_Occurred ())
    322322        PyErr_Print ();
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal_python.h

    r469 r549  
    4343map* mapFromPyDict(PyDictObject* t);
    4444
    45 int zoo_python_support(maps**,map*,service*,maps**,maps**);
     45int zoo_python_support(maps**,map*,service*,maps**,maps**,FCGX_Stream *);
    4646
    4747PyObject* PythonTranslate(PyObject*, PyObject*);
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_loader.c

    r348 r549  
    158158    else{
    159159      map* tmps=createMap("text","ERROR you provided more inputs than requested.");
    160       printExceptionReportResponse(m,tmps);
     160      printExceptionReportResponse(m,tmps,out);
    161161      //printf("ERROR you provided more inputs than requested.");
    162162      return -1;
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_zcfg.c

    r533 r549  
    66#include "service.h"
    77#include "service_internal.h"
     8extern "C" {
    89#include <libxml/tree.h>
    910#include <libxml/xmlmemory.h>
     
    1112#include <libxml/xpath.h>
    1213#include <libxml/xpathInternals.h>
    13 
     14#include "service.h"
     15#include "service_internal.h"
     16}
    1417
    1518
     
    1821
    1922static GList *serviceCfgList;
     23
     24//static maps * main_conf = NULL;
     25
     26
     27/*int
     28load_main_conf(char * path){
     29    if (main_conf != NULL)
     30        freeMaps(&main_conf);
     31    main_conf = (maps *) malloc (MAP_SIZE);
     32    return conf_read (path, main_conf);
     33}
     34
     35maps *  get_main_conf(){
     36    return  dupMaps(&main_conf);
     37}
     38
     39*/
    2040
    2141static int
     
    118138      serviceCfgList = g_list_append (serviceCfgList, s1);
    119139    }
    120   freeMap(&m);
     140  freeMaps(&m);
    121141}
    122142
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_zcfg.h

    r512 r549  
    44
    55#include "service.h"
     6#include "service_internal.h"
    67
    7 
     8maps *  get_main_conf();
     9int load_main_conf(char *path);
    810void init_services_conf (char *rootDir);
    911service *search_service (char *identifier);
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/ulinet.h

    r492 r549  
    2626#define _ULINET_H
    2727
    28 #include "fcgi_stdio.h"
     28//#include "fcgi_stdio.h"
    2929#include "service.h"
    3030#include <stdlib.h>
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_loader.c

    r512 r549  
    3030 */
    3131#ifndef WIN32
     32/*
    3233#include "fcgio.h"
    3334#include "fcgi_config.h"
    3435#include "fcgi_stdio.h"
    35 #endif
     36*/
     37#include <unistd.h>
     38#include <fcgiapp.h>
     39#endif
     40#include <sys/wait.h>
     41#include <pthread.h>
    3642#include <sys/types.h>
    3743#include <unistd.h>
     
    5662#include <glib.h>
    5763#include <sys/stat.h>
     64}
     65
    5866#include "service_zcfg.h"
    59 }
    60 
    61 #include "service_internal.h"
     67//#include "service_internal.h"
    6268
    6369xmlXPathObjectPtr extractFromDoc (xmlDocPtr, const char *);
    64 int runRequest (map **);
     70int runRequest (map **,struct cgi_env **,FCGX_Request *);
    6571
    6672using namespace std;
     
    7480
    7581
    76 int
    77 main (int argc, char *argv[])
     82static void PrintEnv(FCGX_Stream *out, char *label, char **envp)
    7883{
    79   maps *m;
    80   m = (maps *) malloc (MAP_SIZE);
    81   conf_read ("main.cfg", m);
    82   char ntmp[1024];
    83 #ifndef WIN32
    84   getcwd (ntmp, 1024);
    85 #else
    86   _getcwd (ntmp, 1024);
    87 #endif
    88   char *rootDir = "/var/www/zoo-wps/cgi-bin";
    89   init_services_conf (rootDir);
    90 
    91 
    92   while (FCGI_Accept () >= 0)
    93     {
    94       cgiMain_init (argc, argv);
    95 /**
    96    * We'll use cgiOut as the default output (stdout) to produce plain text
    97    * response.
    98    */
    99       dup2 (fileno (cgiOut), fileno (stdout));
    100 
    101 #ifdef DEBUG
    102       fprintf (cgiOut,
    103                "Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
    104       fprintf (cgiOut, "Welcome on ZOO verbose debuging mode \r\n\r\n");
    105       fflush (cgiOut);
    106       fprintf (stderr, "Addr:%s\n", cgiRemoteAddr);
    107       fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,
    108                strncasecmp (cgiRequestMethod, "post", 4),
    109                strncmp (cgiContentType, "text/xml", 8) == 0
    110                || strncasecmp (cgiRequestMethod, "post", 4) == 0);
    111       fprintf (stderr, "Request: %s\n", cgiQueryString);
    112       fprintf (stderr, "ContentType: %s\n", cgiContentType);
    113       fprintf (stderr, "ContentLength: %d\n", cgiContentLength);
    114       fflush (stderr);
    115 #endif
    116 
    117 
     84    FCGX_FPrintF(out, "%s:<br>\n<pre>\n", label);
     85    for( ; *envp != NULL; envp++) {
     86        FCGX_FPrintF(out, "%s\n", *envp);
     87    }
     88    FCGX_FPrintF(out, "</pre><p>\n");
     89}
     90
     91#define PATH_SOCKET "/tmp/zoo.sock"
     92#define THREAD_COUNT 50
     93static int counts[THREAD_COUNT];
     94
     95
     96int process(FCGX_Request *request){
     97
     98      int pid = getpid();
     99      struct cgi_env *cgi;
     100      //PrintEnv(request.err, "Request environment", request.envp);
     101      cgi = (struct cgi_env*)malloc(sizeof(struct cgi_env));
     102      cgiMain_init (NULL, NULL,&cgi,request);
    118103      char *strQuery = NULL;
    119       if (cgiQueryString != NULL)
    120         strQuery = zStrdup (cgiQueryString);
     104      if (cgi->cgiQueryString != NULL)
     105        strQuery = zStrdup (cgi->cgiQueryString);
    121106      map *tmpMap = NULL;
    122107
    123       if (strncmp (cgiContentType, "text/xml", 8) == 0 ||
    124           strncasecmp (cgiRequestMethod, "post", 4) == 0)
     108      if (strncmp (cgi->cgiContentType, "text/xml", 8) == 0 ||
     109          strncasecmp (cgi->cgiRequestMethod, "post", 4) == 0)
    125110        {
    126           if (cgiContentLength == 0)
    127             {
    128               char *buffer = new char[2];
    129               char *res = NULL;
    130               int r = 0;
    131               while ((r = fread (buffer, sizeof (char), 1, cgiIn)))
    132                 {
    133                   buffer[1] = 0;
    134                   cgiContentLength += r;
    135                   if (res == NULL)
    136                     {
    137                       res = (char *) malloc (2 * sizeof (char));
    138                       sprintf (res, "%s", buffer);
     111          if (cgi->cgiContentLength == 0)
     112            {
     113              char *post_data = NULL;
     114              int i = 0;
     115              int ch = FCGX_GetChar(request->in);
     116              while (ch != -1){
     117                {
     118                  i++;
     119                  if (post_data == NULL)
     120                    {
     121                    post_data=(char*)malloc(sizeof(char));
     122                    post_data[i-1] = (char) ch;
    139123                    }
    140124                  else
    141125                    {
    142                       char *tmp = zStrdup (res);
    143                       res =
    144                         (char *) realloc (res,
    145                                           (strlen (tmp) + 2) * sizeof (char));
    146                       sprintf (res, "%s%s", tmp, buffer);
    147                       free (tmp);
    148                     }
    149                 }
    150               delete[]buffer;
    151               if (res == NULL && (strQuery == NULL || strlen (strQuery) == 0))
     126                    post_data=(char*)realloc(post_data,i*sizeof(char));
     127                    post_data[i-1] = (char) ch;
     128                    }
     129                  ch = FCGX_GetChar(request->in);
     130                  if (ch == -1 ){
     131                    post_data=(char*)realloc(post_data,(i + 1)*sizeof(char));
     132                    post_data[i] = '\0';
     133                    }
     134                }
     135                cgi->cgiContentLength = i;
     136              if (post_data == NULL && (strQuery == NULL || strlen (strQuery) == 0))
    152137                {
    153138                  return errorException (NULL,
    154139                                         "ZOO-Kernel failed to process your request cause the request was emtpty.",
    155                                          "InternalError", NULL);
     140                                         "InternalError", NULL,request->out);
    156141                }
    157142              else
    158143                {
    159144                  if (strQuery == NULL || strlen (strQuery) == 0)
    160                     tmpMap = createMap ("request", res);
    161                 }
    162               if (res != NULL)
    163                 free (res);
     145                    tmpMap = createMap ("request", post_data);
     146                }
     147              if (post_data != NULL)
     148                free (post_data);
     149                }
    164150            }
    165151          else
    166152            {
    167               char *buffer = new char[cgiContentLength + 1];
    168               if (fread (buffer, sizeof (char), cgiContentLength, cgiIn) > 0)
    169                 {
    170                   buffer[cgiContentLength] = 0;
    171                   tmpMap = createMap ("request", buffer);
     153              char *post_data = new char[cgi->cgiContentLength + 1];
     154              int r = FCGX_GetStr(post_data,cgi->cgiContentLength,request->in);
     155              if ( r > 0)
     156                {
     157                  post_data[r] = '\0';
     158                  cgi->cgiContentLength = r;
     159                  tmpMap = createMap ("request", post_data);
    172160                }
    173161              else
    174162                {
    175                   buffer[0] = 0;
     163                  post_data[0] = '\0';
    176164                  char **array, **arrayStep;
    177                   if (cgiFormEntries (&array) != cgiFormSuccess)
     165                  if (cgiFormEntries (&array,&cgi) != cgiFormSuccess)
    178166                    {
    179167                      return 1;
     
    182170                  while (*arrayStep)
    183171                    {
    184                       char *ivalue = new char[cgiContentLength];
     172                      char *ivalue = new char[cgi->cgiContentLength];
    185173                      cgiFormStringNoNewlines (*arrayStep, ivalue,
    186                                                cgiContentLength);
     174                                               cgi->cgiContentLength,&cgi);
    187175                      char *tmpValueFinal =
    188176                        (char *)
     
    190178                                 1) * sizeof (char));
    191179                      sprintf (tmpValueFinal, "%s=%s", *arrayStep, ivalue);
    192                       if (strlen (buffer) == 0)
     180                      if (strlen (post_data) == 0)
    193181                        {
    194                           sprintf (buffer, "%s", tmpValueFinal);
     182                          sprintf (post_data, "%s", tmpValueFinal);
    195183                        }
    196184                      else
    197185                        {
    198                           char *tmp = zStrdup (buffer);
    199                           sprintf (buffer, "%s&%s", tmp, tmpValueFinal);
     186                          char *tmp = zStrdup (post_data);
     187                          sprintf (post_data, "%s&%s", tmp, tmpValueFinal);
    200188                          free (tmp);
    201189                        }
     
    209197                    }
    210198                  if (tmpMap != NULL)
    211                     addToMap (tmpMap, "request", buffer);
     199                    addToMap (tmpMap, "request", post_data);
    212200                  else
    213                     tmpMap = createMap ("request", buffer);
    214                 }
    215               delete[]buffer;
     201                    tmpMap = createMap ("request", post_data);
     202                }
     203              delete[]post_data;
    216204            }
    217205        }
     
    221209          dumpMap (tmpMap);
    222210#endif
    223           char **array, **arrayStep;
    224           if (cgiFormEntries (&array) != cgiFormSuccess)
     211       
     212       char **array, **arrayStep;
     213          if (cgiFormEntries (&array,&cgi) != cgiFormSuccess)
    225214            {
    226215              return 1;
     
    229218          while (*arrayStep)
    230219            {
    231               char *value = new char[cgiContentLength];
    232               cgiFormStringNoNewlines (*arrayStep, value, cgiContentLength);
     220              char *value = new char[cgi->cgiContentLength];
     221              cgiFormStringNoNewlines (*arrayStep, value, cgi->cgiContentLength,&cgi);
    233222#ifdef DEBUG
    234223              fprintf (stderr, "(( \n %s \n %s \n ))", *arrayStep, value);
     
    265254   * one.
    266255   */
    267       if (strncasecmp (cgiRequestMethod, "post", 4) == 0 ||
     256      if (strncasecmp (cgi->cgiRequestMethod, "post", 4) == 0 ||
    268257          (count (tmpMap) == 1 && strncmp (tmpMap->value, "<", 1) == 0)
    269258#ifdef WIN32
     
    280269              addToMap (tmpMap, "xrequest", t1->value);
    281270              xmlInitParser ();
    282               xmlDocPtr doc = xmlParseMemory (t1->value, cgiContentLength);
     271              xmlDocPtr doc = xmlParseMemory (t1->value, cgi->cgiContentLength);
    283272              {
    284273                xmlXPathObjectPtr reqptr = extractFromDoc (doc,
     
    384373                          char *identifiers = NULL;
    385374                          identifiers =
    386                             (char *) calloc (cgiContentLength, sizeof (char));
     375                            (char *) calloc (cgi->cgiContentLength, sizeof (char));
    387376                          identifiers[0] = 0;
    388377                          for (int k = 0; k < id->nodeNr; k++)
     
    427416
    428417          char *token, *saveptr;
    429           token = strtok_r (cgiQueryString, "&", &saveptr);
     418          token = strtok_r (cgi->cgiQueryString, "&", &saveptr);
    430419          while (token != NULL)
    431420            {
     
    452441        }
    453442
    454       if (strncasecmp (cgiContentType, "multipart/form-data", 19) == 0)
     443      if (strncasecmp (cgi->cgiContentType, "multipart/form-data", 19) == 0)
    455444        {
    456445          map *tmp = getMap (tmpMap, "dataInputs");
     
    465454        free (strQuery);
    466455
    467       runRequest (&tmpMap);
     456      runRequest (&tmpMap,&cgi,request);
    468457
    469458  /**
     
    475464          free (tmpMap);
    476465        }
    477       cgiFreeResources ();
     466        // a verifier fait planter
     467      cgiFreeResources (&cgi);
     468
     469      FCGX_Finish_r(request);
     470      return 0;
     471}
     472
     473
     474
     475int
     476main (int argc, char *argv[])
     477{
     478  maps *main_config;
     479  int max_requests, start_servers;
     480  start_servers = 10;
     481  max_requests= 100;
     482  main_config = (maps *) malloc (MAP_SIZE);
     483  conf_read ("main.cfg", main_config);
     484  char ntmp[1024];
     485#ifndef WIN32
     486  getcwd (ntmp, 1024);
     487#else
     488  _getcwd (ntmp, 1024);
     489#endif
     490  char *rootDir = "/var/www/zoo-wps/cgi-bin";
     491  int fork_status = fork();
     492  if (fork_status == 0){
     493    //child
     494    int forker_pid = getpid();
     495    init_services_conf (rootDir);
     496    int sock = FCGX_OpenSocket(PATH_SOCKET, 1000);
     497    FCGX_Init();
     498    FCGX_Request request;
     499    FCGX_InitRequest(&request, sock, 0);
     500    int i;
     501    int count_request = 0;
     502    for (i = 0; i< start_servers; i++){
     503        fork_status = fork();
     504        if (fork_status == 0){
     505            fprintf(stderr,"child %d \n",i);
     506            fflush(stderr);
     507            break;
     508        }
    478509    }
    479   FCGI_Finish ();
     510    while(1){
     511        if (forker_pid != getpid()){
     512            while(FCGX_Accept_r(&request) == 0){
     513                process(&request);
     514                count_request ++;
     515                if (count_request >= max_requests){
     516                    fprintf(stderr,"Max request stop process\n");
     517                    fflush(stderr);
     518                    exit(0);
     519                }
     520            }
     521        }
     522        else {
     523            wait(0);
     524            fprintf(stderr,"new child\n");
     525            fflush(stderr);
     526            fork();
     527        }
     528    }
     529  }
     530  else {
     531 
     532  while(1);
     533
     534
     535
     536  }
     537 
    480538  return 0;
    481 
    482539}
     540 
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c

    r532 r549  
    3737#include <libxml/xpath.h>
    3838#include <libxml/xpathInternals.h>
    39 #include "service_zcfg.h"
    4039#include <libgen.h>
    4140}
    4241#include "ulinet.h"
     42#include "service_zcfg.h"
    4343#include <libintl.h>
    4444#include <locale.h>
    4545#include <string.h>
    46 #include "service.h"
    47 #include "service_internal.h"
     46//#include "service.h"
     47//#include "service_internal.h"
    4848#ifdef USE_PYTHON
    4949#include "service_internal_python.h"
     
    172172                       ("You set maximum occurences for <%s> as %i but you tried to use it more than the limit you set. Please correct your ZCFG file or your request."),
    173173                       mi->name, atoi (testMap->value));
    174               errorException (m, emsg, "InternalError", NULL);
     174              //errorException (m, emsg, "InternalError", NULL,stderr);
    175175              return -1;
    176176            }
     
    193193                           ("ZOO-Kernel was unable to load your data for %s position %s."),
    194194                           mi->name, tmpMap->value);
    195                   errorException (m, emsg, "InternalError", NULL);
     195                  //errorException (m, emsg, "InternalError", NULL,stderr);
    196196                  return -1;
    197197                }
     
    204204                       ("You set maximum occurences for <%s> to one but you tried to use it more than once. Please correct your ZCFG file or your request."),
    205205                       mi->name);
    206               errorException (m, emsg, "InternalError", NULL);
     206              //errorException (m, emsg, "InternalError", NULL,request->out);
    207207              return -1;
    208208            }
     
    390390           ("ZOO Kernel failed to process your request receiving signal %d = %s"),
    391391           sig, ssig);
    392   errorException (NULL, tmp, "InternalError", NULL);
     392  //errorException (NULL, tmp, "InternalError", NULL,request->out);
    393393#ifdef DEBUG
    394394  fprintf (stderr, "Not this time!\n");
     
    399399void
    400400loadServiceAndRun (maps ** myMap, service * s1, map * request_inputs,
    401                    maps ** inputs, maps ** ioutputs, int *eres)
     401                   maps ** inputs, maps ** ioutputs, int *eres,FCGX_Stream *out, FCGX_Stream *err)
    402402{
    403   char tmps1[1024];
     403 
     404
     405 char tmps1[1024];
    404406  char ntmp[1024];
    405407  maps *m = *myMap;
     
    523525                (execute_t) GetProcAddress (so, s1->name);
    524526#else
     527
    525528              execute_t execute = (execute_t) dlsym (so, s1->name);
    526529#endif
     
    539542                           ("Error occured while running the %s function: %s"),
    540543                           s1->name, errstr);
    541                   errorException (m, tmpMsg, "InternalError", NULL);
     544                  errorException (m, tmpMsg, "InternalError", NULL,out);
    542545                  free (tmpMsg);
    543546#ifdef DEBUG
    544547                  fprintf (stderr, "Function %s error %s\n",
    545548                           s1->name, errstr);
    546 #endif
     549#endif             
     550
    547551                  *eres = -1;
    548552                  return;
    549553                }
     554
    550555#ifdef DEBUG
    551556#ifdef WIN32
     
    568573              fflush (stderr);
    569574#endif
     575
     576
     577
    570578            }
    571579#ifdef WIN32
     
    589597          sprintf (tmps, _("C Library can't be loaded %s"), errstr);
    590598          map *tmps1 = createMap ("text", tmps);
    591           printExceptionReportResponse (m, tmps1);
     599          printExceptionReportResponse (m, tmps1,out);
    592600          *eres = -1;
    593601          freeMap (&tmps1);
     
    602610        zoo_python_support (&m, request_inputs, s1,
    603611                            &request_input_real_format,
    604                             &request_output_real_format);
     612                            &request_output_real_format,err);
     613
    605614    }
    606615  else
     
    670679               r_inputs->value);
    671680      map *tmps = createMap ("text", tmpv);
    672       printExceptionReportResponse (m, tmps);
     681      printExceptionReportResponse (m, tmps,out);
    673682      *eres = -1;
    674683    }
     
    794803
    795804int
    796 runRequest (map ** inputs)
     805runRequest (map ** inputs,struct cgi_env ** c,FCGX_Request *request)
    797806{
    798807
     808
     809struct cgi_env *cgi = *c;
    799810#ifndef USE_GDB
    800811  (void) signal (SIGSEGV, sig_handler);
     
    813824   * Parsing service specfic configuration file
    814825   */
     826 
    815827  m = (maps *) malloc (MAPS_SIZE);
    816828  if (m == NULL)
    817829    {
    818830      return errorException (m, _("Unable to allocate memory."),
    819                              "InternalError", NULL);
    820     }
     831                             "InternalError", NULL,request->out);
     832    }
     833   
    821834  char ntmp[1024];
    822835#ifndef WIN32
     
    827840  r_inputs = getMapOrFill (&request_inputs, "metapath", "");
    828841
    829 
    830   char conf_file[10240];
    831   snprintf (conf_file, 10240, "%s/%s/main.cfg", ntmp, r_inputs->value);
     842  //m = get_main_conf();
     843
     844 char conf_file[10240];
     845 snprintf (conf_file, 10240, "%s/%s/main.cfg", ntmp, r_inputs->value);
     846 
    832847  if (conf_read (conf_file, m) == 2)
    833848    {
    834849      errorException (NULL, _("Unable to load the main.cfg file."),
    835                       "InternalError", NULL);
     850                      "InternalError", NULL,request->out);
    836851      free (m);
    837852      return 1;
    838853    }
     854
     855
    839856#ifdef DEBUG
    840857  fprintf (stderr, "***** BEGIN MAPS\n");
     
    844861
    845862  map *getPath = getMapFromMaps (m, "main", "gettextPath");
     863
     864
     865
     866
    846867  if (getPath != NULL)
    847868    {
     
    854875      bindtextdomain ("zoo-services", "/usr/share/locale/");
    855876    }
    856 
    857877
    858878  /**
     
    878898                   ("The value %s is not supported for the <language> parameter"),
    879899                   r_inputs->value);
    880           errorException (m, tmp, "InvalidParameterValue", "language");
     900          errorException (m, tmp, "InvalidParameterValue", "language",request->out);
    881901          freeMaps (&m);
    882902          free (m);
     
    929949    setMapInMaps (m, "main", "isSoap", "false");
    930950
    931   if (strlen (cgiServerName) > 0)
     951  if (strlen (cgi->cgiServerName) > 0)
    932952    {
    933953      char tmpUrl[1024];
    934       if (strncmp (cgiServerPort, "80", 2) == 0)
    935         {
    936           sprintf (tmpUrl, "http://%s%s", cgiServerName, cgiScriptName);
     954      if (strncmp (cgi->cgiServerPort, "80", 2) == 0)
     955        {
     956          sprintf (tmpUrl, "http://%s%s", cgi->cgiServerName, cgi->cgiScriptName);
    937957        }
    938958      else
    939959        {
    940           sprintf (tmpUrl, "http://%s:%s%s", cgiServerName,
    941                    cgiServerPort, cgiScriptName);
     960          sprintf (tmpUrl, "http://%s:%s%s", cgi->cgiServerName,
     961                   cgi->cgiServerPort, cgi->cgiScriptName);
    942962        }
    943963#ifdef DEBUG
     
    954974    {
    955975      errorException (m, _("Parameter <request> was not specified"),
    956                       "MissingParameterValue", "request");
     976                      "MissingParameterValue", "request",request->out);
    957977      if (count (request_inputs) == 1)
    958978        {
     
    974994                          _
    975995                          ("Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute."),
    976                           "OperationNotSupported", r_inputs->value);
     996                          "OperationNotSupported", r_inputs->value,request->out);
    977997          freeMaps (&m);
    978998          free (m);
     
    9861006    {
    9871007      errorException (m, _("Parameter <service> was not specified"),
    988                       "MissingParameterValue", "service");
     1008                      "MissingParameterValue", "service",request->out);
    9891009      freeMaps (&m);
    9901010      free (m);
     
    9991019                          _
    10001020                          ("Unenderstood <service> value, WPS is the only acceptable value."),
    1001                           "InvalidParameterValue", "service");
     1021                          "InvalidParameterValue", "service",request->out);
    10021022          freeMaps (&m);
    10031023          free (m);
     
    10121032        {
    10131033          errorException (m, _("Parameter <version> was not specified"),
    1014                           "MissingParameterValue", "version");
     1034                          "MissingParameterValue", "version",request->out);
    10151035          freeMaps (&m);
    10161036          free (m);
     
    10251045                              _
    10261046                              ("Unenderstood <version> value, 1.0.0 is the only acceptable value."),
    1027                               "InvalidParameterValue", "service");
     1047                              "InvalidParameterValue", "service",request->out);
    10281048              freeMaps (&m);
    10291049              free (m);
     
    10431063                              _
    10441064                              ("Unenderstood <AcceptVersions> value, 1.0.0 is the only acceptable value."),
    1045                               "VersionNegotiationFailed", NULL);
     1065                              "VersionNegotiationFailed", NULL,request->out);
    10461066              freeMaps (&m);
    10471067              free (m);
     
    10801100  else
    10811101    snprintf (conf_dir, 1024, "%s", ntmp);
     1102
     1103
     1104
    10821105
    10831106  if (strncasecmp (REQUEST, "GetCapabilities", 15) == 0)
     
    10981121     * has been found in the zcfg and then printed on stdout
    10991122     */
    1100       int saved_stdout = dup (fileno (stdout));
    1101       dup2 (fileno (stderr), fileno (stdout));
    1102 
    1103         /**
    1104       if (int res =
    1105           recursReaddirF (m, n, conf_dir, NULL, saved_stdout, 0,
    1106                           printGetCapabilitiesForProcess) < 0)
    1107         {
    1108           freeMaps (&m);
    1109           free (m);
    1110           free (REQUEST);
    1111           free (SERVICE_URL);
    1112           fflush (stdout);
    1113           return res;
    1114         }
    1115       **/
    11161123      XML_CapabilitiesAllProcess (m, n);
    1117       dup2 (saved_stdout, fileno (stdout));
    1118       printDocument (m, doc, getpid ());
     1124      printDocument (m, doc, getpid (),request->out);
    11191125      freeMaps (&m);
    11201126      free (m);
    11211127      free (REQUEST);
    11221128      free (SERVICE_URL);
    1123       fflush (stdout);
    11241129      return 0;
    11251130    }
     
    11321137          errorException (m,
    11331138                          _("Mandatory <identifier> was not specified"),
    1134                           "MissingParameterValue", "identifier");
     1139                          "MissingParameterValue", "identifier",request->out);
    11351140          freeMaps (&m);
    11361141          free (m);
     
    11461151          errorException (m,
    11471152                          _("The specified path path doesn't exist."),
    1148                           "InvalidParameterValue", conf_dir);
     1153                          "InvalidParameterValue", conf_dir,request->out);
    11491154          freeMaps (&m);
    11501155          free (m);
     
    11731178
    11741179
    1175           int saved_stdout = dup (fileno (stdout));
    1176           dup2 (fileno (stderr), fileno (stdout));
     1180          //int saved_stdout = dup (fileno (stdout));
     1181          //dup2 (fileno (stderr), fileno (stdout));
    11771182          XML_Describe_Process (m, n, orig);
    11781183          closedir (dirp);
    1179           fflush (stdout);
    1180           dup2 (saved_stdout, fileno (stdout));
     1184          //fflush (stdout);
     1185          //dup2 (saved_stdout, fileno (stdout));
    11811186          free (orig);
    1182           printDocument (m, doc, getpid ());
     1187          printDocument (m, doc, getpid (),request->out);
    11831188          freeMaps (&m);
    11841189          free (m);
    11851190          free (REQUEST);
    11861191          free (SERVICE_URL);
    1187           fflush (stdout);
     1192          //fflush (stdout);
    11881193          return 0;
    11891194
     
    11911196      else if (strncasecmp (REQUEST, "Execute", strlen (REQUEST)) != 0)
    11921197        {
     1198         
    11931199          errorException (m,
    11941200                          _
    11951201                          ("Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute."),
    1196                           "InvalidParameterValue", "request");
     1202                          "InvalidParameterValue", "request",request->out);
    11971203#ifdef DEBUG
    11981204          fprintf (stderr, "No request found %s", REQUEST);
     
    12031209          free (REQUEST);
    12041210          free (SERVICE_URL);
    1205           fflush (stdout);
     1211          //fflush (stdout);
    12061212          return 0;
    12071213        }
     
    12501256  fflush (stdout);
    12511257  **/
    1252   int saved_stdout = dup (fileno (stdout));
    1253   dup2 (saved_stdout, fileno (stdout));
     1258  //int saved_stdout = dup (fileno (stdout));
     1259  //dup2 (saved_stdout, fileno (stdout));
    12541260  s1 = search_service (r_inputs->value);
    12551261  if (s1 == NULL)
     
    12601266               ("The value for <identifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),
    12611267               r_inputs->value);
    1262       errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
     1268      errorException (m, tmpMsg, "InvalidParameterValue", "identifier",request->out);
    12631269      free (tmpMsg);
    12641270      //free (s1);
     
    12691275      return 0;
    12701276    }
    1271   close (saved_stdout);
     1277  //close (saved_stdout);
    12721278
    12731279#ifdef DEBUG
     
    13391345              return errorException (m,
    13401346                                     _("Unable to allocate memory"),
    1341                                      "InternalError", NULL);
     1347                                     "InternalError", NULL,request->out);
    13421348            }
    13431349          i = 0;
     
    13561362                                         _
    13571363                                         ("Unable to allocate memory"),
    1358                                          "InternalError", NULL);
     1364                                         "InternalError", NULL,request->out);
    13591365                }
    13601366              snprintf (outputs_as_text[i], strlen (pToken) + 1, "%s",
     
    13821388                                                     _
    13831389                                                     ("Unable to allocate memory."),
    1384                                                      "InternalError", NULL);
     1390                                                     "InternalError", NULL,request->out);
    13851391                            }
    13861392                          tmp_output->name = zStrdup (tmpc);
     
    14471453          errorException (m,
    14481454                          _("Parameter <DataInputs> was not specified"),
    1449                           "MissingParameterValue", "DataInputs");
     1455                          "MissingParameterValue", "DataInputs",request->out);
    14501456          freeMaps (&m);
    14511457          free (m);
     
    14791485        {
    14801486          return errorException (m, _("Unable to allocate memory."),
    1481                                  "InternalError", NULL);
     1487                                 "InternalError", NULL,request->out);
    14821488        }
    14831489      i = 0;
     
    14981504              return errorException (m,
    14991505                                     _("Unable to allocate memory."),
    1500                                      "InternalError", NULL);
     1506                                     "InternalError", NULL,request->out);
    15011507            }
    15021508          pToken = strtok (NULL, ";");
     
    15401546                                             _
    15411547                                             ("Unable to allocate memory."),
    1542                                              "InternalError", NULL);
     1548                                             "InternalError", NULL,request->out);
    15431549                    }
    15441550                  tmpmaps->name = zStrdup (tmpn);
     
    16111617                                   ("Unable to find a valid protocol to download the remote file %s"),
    16121618                                   tmpv1 + 1);
    1613                           errorException (m, emsg, "InternalError", NULL);
     1619                          errorException (m, emsg, "InternalError", NULL,request->out);
    16141620                          freeMaps (&m);
    16151621                          free (m);
     
    17021708      fflush (stderr);
    17031709#endif
    1704       xmlDocPtr doc = xmlParseMemory (postRequest->value, cgiContentLength);
     1710      xmlDocPtr doc = xmlParseMemory (postRequest->value, cgi->cgiContentLength);
    17051711#ifdef DEBUG
    17061712      fprintf (stderr, "AFTER\n");
     
    17531759                                                     _
    17541760                                                     ("Unable to allocate memory."),
    1755                                                      "InternalError", NULL);
     1761                                                     "InternalError", NULL,request->out);
    17561762                            }
    17571763                          tmpmaps->name = zStrdup ((char *) val);
     
    17821788                                                     _
    17831789                                                     ("Unable to allocate memory."),
    1784                                                      "InternalError", NULL);
     1790                                                     "InternalError", NULL,request->out);
    17851791                            }
    17861792                          tmpmaps->name = zStrdup ("missingIndentifier");
     
    19261932                                             _
    19271933                                             ("Unable to allocate memory."),
    1928                                              "InternalError", NULL);
     1934                                             "InternalError", NULL,request->out);
    19291935                                        }
    19301936                                      snprintf (has,
     
    19651971                                    (char *)
    19661972                                    malloc
    1967                                     (cgiContentLength + 1 * sizeof (char));
    1968                                   memset (tmp, 0, cgiContentLength);
     1973                                    (cgi->cgiContentLength + 1 * sizeof (char));
     1974                                  memset (tmp, 0, cgi->cgiContentLength);
    19691975                                  xmlNodePtr cur4 = cur3->children;
    19701976                                  while (cur4 != NULL)
     
    20582064                                         _
    20592065                                         ("Unable to allocate memory."),
    2060                                          "InternalError", NULL);
     2066                                         "InternalError", NULL,request->out);
    20612067                                    }
    20622068                                  size_t bRead;
     
    23802386                                         _
    23812387                                         ("Unable to allocate memory."),
    2382                                          "InternalError", NULL);
     2388                                         "InternalError", NULL,request->out);
    23832389                }
    23842390              tmpmaps->name = zStrdup ("unknownIdentifier");
     
    24642470                                               _
    24652471                                               ("Unable to allocate memory."),
    2466                                                "InternalError", NULL);
     2472                                               "InternalError", NULL,request->out);
    24672473                      }
    24682474                    tmpmaps->name = zStrdup ("unknownIdentifier");
     
    25202526                                                       _
    25212527                                                       ("Unable to allocate memory."),
    2522                                                        "InternalError", NULL);
     2528                                                       "InternalError", NULL,request->out);
    25232529                              }
    25242530                            tmpmaps->name = zStrdup ((char *) val);
     
    25802586                                                       _
    25812587                                                       ("Unable to allocate memory."),
    2582                                                        "InternalError", NULL);
     2588                                                       "InternalError", NULL,request->out);
    25832589                              }
    25842590                            tmpmaps->name = zStrdup ("missingIndetifier");
     
    26592665                                           _
    26602666                                           ("Unable to allocate memory."),
    2661                                            "InternalError", NULL);
     2667                                           "InternalError", NULL,request->out);
    26622668                                      }
    26632669                                    tmpmaps->name = zStrdup ((char *) val);
     
    27002706                                           _
    27012707                                           ("Unable to allocate memory."),
    2702                                            "InternalError", NULL);
     2708                                           "InternalError", NULL,request->out);
    27032709                                      }
    27042710                                    tmpmaps->name =
     
    27882794              addToMap (tmpe, "locator", ptr->name);
    27892795              addToMap (tmpe, "text", tmps);
    2790               printExceptionReportResponse (m, tmpe);
     2796              printExceptionReportResponse (m, tmpe,request->out);
    27912797              //freeService (&s1);
    27922798              //free (s1);
     
    28322838        }
    28332839      addToMap (tmpe, "text", tmps);
    2834       printExceptionReportResponse (m, tmpe);
     2840      printExceptionReportResponse (m, tmpe,request->out);
    28352841      //freeService (&s1);
    28362842      free (s1);
     
    28552861      if (getMap (tmpReqI->content, "isFile") != NULL)
    28562862        {
    2857           if (cgiFormFileName (tmpReqI->name, name, sizeof (name)) ==
     2863          if (cgiFormFileName (tmpReqI->name, name, sizeof (name),&cgi) ==
    28582864              cgiFormSuccess)
    28592865            {
     
    28692875              int got, t;
    28702876              map *path = getMapFromMaps (m, "main", "tmpPath");
    2871               cgiFormFileSize (tmpReqI->name, &size);
     2877              cgiFormFileSize (tmpReqI->name, &size,&cgi);
    28722878              cgiFormFileContentType (tmpReqI->name, contentType,
    2873                                       sizeof (contentType));
    2874               if (cgiFormFileOpen (tmpReqI->name, &file) == cgiFormSuccess)
     2879                                      sizeof (contentType),&cgi);
     2880              if (cgiFormFileOpen (tmpReqI->name, &file,&cgi) == cgiFormSuccess)
    28752881                {
    28762882                  t = -1;
     
    30183024                      _
    30193025                      ("Status cannot be set to true with storeExecuteResponse to false. Please, modify your request parameters."),
    3020                       "InvalidParameterValue", "storeExecuteResponse");
     3026                      "InvalidParameterValue", "storeExecuteResponse",request->out);
    30213027      //freeService (&s1);
    30223028      //free (s1);
     
    30693075  else
    30703076    addToMap (_tmpMaps->content, "soap", "false");
    3071   if (cgiCookie != NULL && strlen (cgiCookie) > 0)
     3077  if (cgi->cgiCookie != NULL && strlen (cgi->cgiCookie) > 0)
    30723078    {
    30733079      int hasValidCookie = -1;
    3074       char *tcook = zStrdup (cgiCookie);
     3080      char *tcook = zStrdup (cgi->cgiCookie);
    30753081      char *tmp = NULL;
    30763082      map *testing = getMapFromMaps (m, "main", "cookiePrefix");
     
    30853091          sprintf (tmp, "%s=", testing->value);
    30863092        }
    3087       if (strstr (cgiCookie, ";") != NULL)
     3093      if (strstr (cgi->cgiCookie, ";") != NULL)
    30883094        {
    30893095          char *token, *saveptr;
    3090           token = strtok_r (cgiCookie, ";", &saveptr);
     3096          token = strtok_r (cgi->cgiCookie, ";", &saveptr);
    30913097          while (token != NULL)
    30923098            {
     
    31043110        {
    31053111          if (strstr
    3106               (cgiCookie, "=") != NULL && strcasestr (cgiCookie, tmp) != NULL)
     3112              (cgi->cgiCookie, "=") != NULL && strcasestr (cgi->cgiCookie, tmp) != NULL)
    31073113            {
    3108               tcook = zStrdup (cgiCookie);
     3114              tcook = zStrdup (cgi->cgiCookie);
    31093115              hasValidCookie = 1;
    31103116            }
     
    31313137            sprintf
    31323138              (session_file_path,
    3133                "%s/sess_%s.cfg", tmpPath->value, strstr (cgiCookie, "=") + 1);
     3139               "%s/sess_%s.cfg", tmpPath->value, strstr (cgi->cgiCookie, "=") + 1);
    31343140          free (tcook);
    31353141          maps *tmpSess = (maps *) malloc (MAPS_SIZE);
     
    31373143          int istat = stat (session_file_path,
    31383144                            &file_status);
     3145         
    31393146          if (istat == 0 && file_status.st_size > 0)
    31403147            {
     
    31443151              free (tmpSess);
    31453152            }
     3153           
    31463154        }
    31473155    }
     
    31663174    }
    31673175#endif
    3168   char *fbkp, *fbkp1;
     3176 
     3177
     3178char *fbkp, *fbkp1;
    31693179  FILE *f0, *f1;
    31703180  if (status != NULL)
     
    31763186        (&m, s1,
    31773187         request_inputs,
    3178          &request_input_real_format, &request_output_real_format, &eres);
     3188         &request_input_real_format, &request_output_real_format, &eres,request->out,request->err);
    31793189    }
    31803190  else
     
    32613271             r_inputs1->value,
    32623272             SERVICE_STARTED,
    3263              request_input_real_format, request_output_real_format);
     3273             request_input_real_format, request_output_real_format,request->out);
    32643274#ifndef WIN32
    32653275          fflush (stdout);
     
    32773287            (&m, s1,
    32783288             request_inputs,
    3279              &request_input_real_format, &request_output_real_format, &eres);
     3289             &request_input_real_format, &request_output_real_format, &eres,request->out,request->err);
    32803290        }
    32813291      else
     
    32893299                          _
    32903300                          ("Unable to run the child process properly"),
    3291                           "InternalError", NULL);
     3301                          "InternalError", NULL,request->out);
    32923302        }
    32933303    }
     
    32963306  dumpMaps (request_output_real_format);
    32973307#endif
     3308
    32983309  if (eres != -1)
    32993310    outputResponse (s1,
    33003311                    request_input_real_format,
    33013312                    request_output_real_format,
    3302                     request_inputs, cpid, m, eres);
    3303   fflush (stdout);
     3313                    request_inputs, cpid, m, eres,request->out,request->err);
     3314  //fflush (stdout);
    33043315  /**
    33053316   * Ensure that if error occurs when freeing memory, no signal will return
     
    33153326  (void) signal (SIGABRT, donothing);
    33163327#endif
    3317   if (((int) getpid ()) != cpid || cgiSid != NULL)
     3328  if (((int) getpid ()) != cpid || cgi->cgiSid != NULL)
    33183329    {
    33193330      fclose (stdout);
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