Ignore:
Timestamp:
Feb 2, 2015, 10:04:56 AM (9 years ago)
Author:
david
Message:
  • Adding Process Management
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
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