Changeset 549 for branches/PublicaMundi_David-devel/zoo-project
- Timestamp:
- Feb 2, 2015, 10:04:56 AM (10 years ago)
- 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 12 12 JAVA_FILE=@JAVA_FILE@ 13 13 14 CFLAGS=@DEB_DEF@ -fpic ${GLIB_CPPFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF15 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}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} 16 16 17 17 PHPCFLAGS=@PHP_CPPFLAGS@ … … 59 59 gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c ulinet.c 60 60 61 service_zcfg.o: service_zcfg.c 62 g cc -fPIC${GLIB_CPPFLAGS} ${XML2CFLAGS} -c service_zcfg.c61 service_zcfg.o: service_zcfg.c service.h 62 g++ ${GLIB_CPPFLAGS} ${XML2CFLAGS} -c service_zcfg.c 63 63 64 64 service_internal.o: service_internal.c service.h -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/configure.ac
r512 r549 340 340 LIBS="$PYTHON_LDFLAGS" 341 341 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])], []) 343 343 AC_SUBST([PYTHON_CPPFLAGS]) 344 344 AC_SUBST([PYTHON_LDFLAGS]) -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal.c
r531 r549 58 58 59 59 void 60 printHeaders (maps * m )60 printHeaders (maps * m,FCGX_Stream *out) 61 61 { 62 62 maps *_tmp = getMaps (m, "headers"); … … 66 66 while (_tmp1 != NULL) 67 67 { 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); 69 70 _tmp1 = _tmp1->next; 70 71 } … … 100 101 101 102 #include <windows.h> 102 #include <fcgi_stdio.h>103 //#include <fcgi_stdio.h> 103 104 #include <stdio.h> 104 105 #include <conio.h> … … 1689 1690 printProcessResponse (maps * m, map * request, int pid, service * serv, 1690 1691 const char *service, int status, maps * inputs, 1691 maps * outputs )1692 maps * outputs, FCGX_Stream* out) 1692 1693 { 1693 1694 xmlNsPtr ns, ns_ows, ns_xlink, ns_xsi; … … 1990 1991 map *errormap = createMap ("text", tmpMsg); 1991 1992 addToMap (errormap, "code", "InternalError"); 1992 printExceptionReportResponse (m, errormap );1993 printExceptionReportResponse (m, errormap,out); 1993 1994 freeMap (&errormap); 1994 1995 free (errormap); … … 2005 2006 fclose (output); 2006 2007 } 2007 printDocument (m, doc, pid );2008 printDocument (m, doc, pid,out); 2008 2009 2009 2010 xmlCleanupParser (); … … 2013 2014 2014 2015 void 2015 printDocument (maps * m, xmlDocPtr doc, int pid )2016 printDocument (maps * m, xmlDocPtr doc, int pid,FCGX_Stream * out) 2016 2017 { 2017 2018 char *encoding = getEncoding (m); 2018 2019 if (pid == getpid ()) 2019 2020 { 2020 printHeaders (m );2021 printf ("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",2022 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); 2025 2026 xmlChar *xmlbuff; 2026 2027 int buffersize; … … 2030 2031 */ 2031 2032 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); 2034 2037 /* 2035 2038 * Free associated memory. … … 2462 2465 2463 2466 void 2464 printExceptionReportResponse (maps * m, map * s )2467 printExceptionReportResponse (maps * m, map * s,FCGX_Stream * out) 2465 2468 { 2466 2469 if (getMapFromMaps (m, "lenv", "hasPrinted") != NULL) … … 2504 2507 if (getpid () == atoi (tmpSid->value)) 2505 2508 { 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); 2510 2512 } 2511 2513 } 2512 2514 else 2513 2515 { 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); 2517 2520 } 2518 2521 } 2519 2522 else 2520 { 2521 printf ("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",2522 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); 2523 2526 } 2524 2527 n = createExceptionReportNode (m, s, 1); 2525 2528 xmlDocSetRootElement (doc, n); 2526 2529 xmlDocDumpFormatMemoryEnc (doc, &xmlbuff, &buffersize, encoding, 1); 2527 printf ("%s", xmlbuff); 2528 fflush (stdout); 2530 //printf ("%s", xmlbuff); 2531 FCGX_FPrintF(out,"%s",xmlbuff); 2532 FCGX_FFlush(out); 2533 //fflush (stdout); 2529 2534 xmlFreeDoc (doc); 2530 2535 xmlFree (xmlbuff); … … 2595 2600 void 2596 2601 outputResponse (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 2599 2606 #ifdef DEBUG 2600 2607 dumpMaps (request_inputs); … … 2655 2662 addToMap (errormap, "code", "InternalError"); 2656 2663 2657 printExceptionReportResponse (m, errormap );2664 printExceptionReportResponse (m, errormap,out); 2658 2665 freeMap (&errormap); 2659 2666 free (errormap); … … 2670 2677 if (asRaw == 0) 2671 2678 { 2679 2680 2672 2681 #ifdef DEBUG 2673 2682 fprintf (stderr, "REQUEST_OUTPUTS FINAL\n"); … … 2760 2769 map *errormap = createMap ("text", tmpMsg); 2761 2770 addToMap (errormap, "code", "InternalError"); 2762 printExceptionReportResponse (m, errormap); 2771 2772 printExceptionReportResponse (m, errormap,out); 2763 2773 freeMap (&errormap); 2764 2774 free (errormap); … … 2833 2843 printProcessResponse (m, request_inputs1, cpid, 2834 2844 s, r_inputs->value, res, 2835 request_inputs, request_outputs );2845 request_inputs, request_outputs,out); 2836 2846 } 2837 2847 else 2838 2848 { 2849 2839 2850 if (res == SERVICE_FAILED) 2840 2851 { 2852 2841 2853 map *errormap; 2842 2854 map *lenv; … … 2871 2883 free (tmp0); 2872 2884 addToMap (errormap, "code", "InternalError"); 2873 printExceptionReportResponse (m, errormap );2885 printExceptionReportResponse (m, errormap,out); 2874 2886 freeMap (&errormap); 2875 2887 free (errormap); … … 2880 2892 * requested one is not present in the resulting outputs maps. 2881 2893 */ 2894 2895 2882 2896 maps *tmpI = NULL; 2883 2897 map *tmpIV = getMap (request_inputs1, "RawDataOutput"); … … 2905 2919 map *errormap = createMap ("text", tmpMsg); 2906 2920 addToMap (errormap, "code", "InvalidParameterValue"); 2907 printExceptionReportResponse (m, errormap );2921 printExceptionReportResponse (m, errormap,out); 2908 2922 freeMap (&errormap); 2909 2923 free (errormap); … … 2912 2926 map *fname = getMapFromMaps (tmpI, tmpI->name, "filename"); 2913 2927 if (fname != NULL) 2914 printf ("Content-Disposition: attachment; filename=\"%s\"\r\n",2915 2928 FCGX_FPrintF(out,"Content-Disposition: attachment; filename=\"%s\"\r\n",fname->value); 2929 //printf ("Content-Disposition: attachment; filename=\"%s\"\r\n",fname->value); 2916 2930 map *rs = getMapFromMaps (tmpI, tmpI->name, "size"); 2917 2931 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); 2920 2935 char mime[1024]; 2921 2936 map *mi = getMap (tmpI->content, "mimeType"); … … 2937 2952 sprintf (mime, 2938 2953 "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); 2940 2957 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); 2942 2960 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); 2944 2965 #ifdef DEBUG 2945 2966 dumpMap (toto); … … 3400 3421 printBoundingBoxDocument (maps * m, maps * boundingbox, FILE * file) 3401 3422 { 3402 if (file == NULL)3403 rewind (stdout);3423 //if (file == NULL) 3424 // rewind (stdout); 3404 3425 xmlNodePtr n; 3405 3426 xmlDocPtr doc; … … 3421 3442 encoding); 3422 3443 } 3423 fflush (stdout);3444 //fflush (stdout); 3424 3445 } 3425 3446 … … 3583 3604 return errorException (*m, 3584 3605 _("Unable to allocate memory."), 3585 "InternalError", NULL );3606 "InternalError", NULL,NULL); 3586 3607 } 3587 3608 size_t dwRead; … … 3603 3624 return errorException (*m, 3604 3625 _("Unable to allocate memory."), 3605 "InternalError", NULL );3626 "InternalError", NULL,NULL); 3606 3627 } 3607 3628 memcpy (tmpMap->value, fcontent, … … 3667 3688 { 3668 3689 return errorException (*m, _("Unable to download the file."), 3669 "InternalError", NULL );3690 "InternalError", NULL,NULL); 3670 3691 } 3671 3692 if (mimeType != NULL) … … 3680 3701 if (tmpMap->value == NULL) 3681 3702 return errorException (*m, _("Unable to allocate memory."), 3682 "InternalError", NULL );3703 "InternalError", NULL,NULL); 3683 3704 memcpy (tmpMap->value, fcontent, (fsize + 1) * sizeof (char)); 3684 3705 … … 3698 3719 int 3699 3720 errorException (maps * m, const char *message, const char *errorcode, 3700 const char *locator )3721 const char *locator,FCGX_Stream * out) 3701 3722 { 3702 3723 map *errormap = createMap ("text", message); … … 3706 3727 else 3707 3728 addToMap (errormap, "locator", "NULL"); 3708 printExceptionReportResponse (m, errormap );3729 printExceptionReportResponse (m, errormap,out); 3709 3730 freeMap (&errormap); 3710 3731 free (errormap); -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal.h
r512 r549 39 39 #include <sys/types.h> 40 40 //#include "cgic.h" 41 #include <fcgiapp.h> 41 42 #ifndef WIN32 42 43 #include <sys/ipc.h> … … 119 120 void zooXmlCleanupDocs (); 120 121 void addPrefix (maps * conf, map * level, service * serv); 121 void printExceptionReportResponse (maps *, map * );122 void printExceptionReportResponse (maps *, map *,FCGX_Stream * out); 122 123 xmlNodePtr createExceptionReportNode (maps *, map *, int); 123 124 void printProcessResponse (maps *, map *, int, service *, const char *, int, 124 maps *, maps * );125 maps *, maps *,FCGX_Stream *); 125 126 xmlNodePtr printGetCapabilitiesHeader (xmlDocPtr, const char *, maps *); 126 127 void printGetCapabilitiesForProcess (maps *, xmlNodePtr, service *); … … 129 130 void printFullDescription (int, elements *, const char *, xmlNsPtr, 130 131 xmlNodePtr); 131 void printDocument (maps *, xmlDocPtr, int );132 void printDocument (maps *, xmlDocPtr, int, FCGX_Stream *); 132 133 void printDescription (xmlNodePtr, xmlNsPtr, const char *, map *); 133 134 void printIOType (xmlDocPtr, xmlNodePtr, xmlNsPtr, xmlNsPtr, xmlNsPtr, … … 139 140 elements *, maps *, const char *); 140 141 141 void outputResponse (service *, maps *, maps *, map *, int, maps *, int );142 void outputResponse (service *, maps *, maps *, map *, int, maps *, int,FCGX_Stream *,FCGX_Stream *); 142 143 143 144 char *base64 (const char *, int); … … 147 148 char *addDefaultValues (maps **, elements *, maps *, int); 148 149 149 int errorException (maps *, const char *, const char *, const char * );150 int errorException (maps *, const char *, const char *, const char *,FCGX_Stream *); 150 151 151 152 int checkForSoapEnvelope (xmlDocPtr); -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal_js.c
r531 r549 216 216 map *err = createMap ("text", tmp1); 217 217 addToMap (err, "code", "NoApplicableCode"); 218 printExceptionReportResponse (mc, err);218 //printExceptionReportResponse (mc, err); 219 219 freeMap (&err); 220 220 free (err); … … 268 268 map *err = createMap ("text", tmp1); 269 269 addToMap (err, "code", "NoApplicableCode"); 270 printExceptionReportResponse (*main_conf, err);270 //printExceptionReportResponse (*main_conf, err); 271 271 freeMap (&err); 272 272 free (err); -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal_python.c
r531 r549 127 127 int 128 128 zoo_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) 130 130 { 131 131 char *pythonpath; … … 222 222 "Unable to parse serviceProvider please check your zcfg file."); 223 223 addToMap (err, "code", "NoApplicableCode"); 224 printExceptionReportResponse (m, err);224 //printExceptionReportResponse (m, err); 225 225 exit (-1); 226 226 } … … 299 299 map *err = createMap ("text", pbt); 300 300 addToMap (err, "code", "NoApplicableCode"); 301 printExceptionReportResponse (m, err);301 //printExceptionReportResponse (m, err); 302 302 res = -1; 303 303 } … … 309 309 s->name, tmp->value); 310 310 map *tmps = createMap ("text", tmpS); 311 printExceptionReportResponse (m, tmps);311 //printExceptionReportResponse (m, tmps); 312 312 res = -1; 313 313 } … … 318 318 sprintf (tmpS, "Python module %s cannot be loaded.\n", tmp->value); 319 319 map *tmps = createMap ("text", tmpS); 320 printExceptionReportResponse (m, tmps);320 //printExceptionReportResponse (m, tmps); 321 321 if (PyErr_Occurred ()) 322 322 PyErr_Print (); -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal_python.h
r469 r549 43 43 map* mapFromPyDict(PyDictObject* t); 44 44 45 int zoo_python_support(maps**,map*,service*,maps**,maps** );45 int zoo_python_support(maps**,map*,service*,maps**,maps**,FCGX_Stream *); 46 46 47 47 PyObject* PythonTranslate(PyObject*, PyObject*); -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_loader.c
r348 r549 158 158 else{ 159 159 map* tmps=createMap("text","ERROR you provided more inputs than requested."); 160 printExceptionReportResponse(m,tmps );160 printExceptionReportResponse(m,tmps,out); 161 161 //printf("ERROR you provided more inputs than requested."); 162 162 return -1; -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_zcfg.c
r533 r549 6 6 #include "service.h" 7 7 #include "service_internal.h" 8 extern "C" { 8 9 #include <libxml/tree.h> 9 10 #include <libxml/xmlmemory.h> … … 11 12 #include <libxml/xpath.h> 12 13 #include <libxml/xpathInternals.h> 13 14 #include "service.h" 15 #include "service_internal.h" 16 } 14 17 15 18 … … 18 21 19 22 static GList *serviceCfgList; 23 24 //static maps * main_conf = NULL; 25 26 27 /*int 28 load_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 35 maps * get_main_conf(){ 36 return dupMaps(&main_conf); 37 } 38 39 */ 20 40 21 41 static int … … 118 138 serviceCfgList = g_list_append (serviceCfgList, s1); 119 139 } 120 freeMap (&m);140 freeMaps(&m); 121 141 } 122 142 -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_zcfg.h
r512 r549 4 4 5 5 #include "service.h" 6 #include "service_internal.h" 6 7 7 8 maps * get_main_conf(); 9 int load_main_conf(char *path); 8 10 void init_services_conf (char *rootDir); 9 11 service *search_service (char *identifier); -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/ulinet.h
r492 r549 26 26 #define _ULINET_H 27 27 28 #include "fcgi_stdio.h"28 //#include "fcgi_stdio.h" 29 29 #include "service.h" 30 30 #include <stdlib.h> -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_loader.c
r512 r549 30 30 */ 31 31 #ifndef WIN32 32 /* 32 33 #include "fcgio.h" 33 34 #include "fcgi_config.h" 34 35 #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> 36 42 #include <sys/types.h> 37 43 #include <unistd.h> … … 56 62 #include <glib.h> 57 63 #include <sys/stat.h> 64 } 65 58 66 #include "service_zcfg.h" 59 } 60 61 #include "service_internal.h" 67 //#include "service_internal.h" 62 68 63 69 xmlXPathObjectPtr extractFromDoc (xmlDocPtr, const char *); 64 int runRequest (map ** );70 int runRequest (map **,struct cgi_env **,FCGX_Request *); 65 71 66 72 using namespace std; … … 74 80 75 81 76 int 77 main (int argc, char *argv[]) 82 static void PrintEnv(FCGX_Stream *out, char *label, char **envp) 78 83 { 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 93 static int counts[THREAD_COUNT]; 94 95 96 int 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); 118 103 char *strQuery = NULL; 119 if (cgi QueryString != NULL)120 strQuery = zStrdup (cgi QueryString);104 if (cgi->cgiQueryString != NULL) 105 strQuery = zStrdup (cgi->cgiQueryString); 121 106 map *tmpMap = NULL; 122 107 123 if (strncmp (cgi ContentType, "text/xml", 8) == 0 ||124 strncasecmp (cgi RequestMethod, "post", 4) == 0)108 if (strncmp (cgi->cgiContentType, "text/xml", 8) == 0 || 109 strncasecmp (cgi->cgiRequestMethod, "post", 4) == 0) 125 110 { 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; 139 123 } 140 124 else 141 125 { 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)) 152 137 { 153 138 return errorException (NULL, 154 139 "ZOO-Kernel failed to process your request cause the request was emtpty.", 155 "InternalError", NULL );140 "InternalError", NULL,request->out); 156 141 } 157 142 else 158 143 { 159 144 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 } 164 150 } 165 151 else 166 152 { 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); 172 160 } 173 161 else 174 162 { 175 buffer[0] = 0;163 post_data[0] = '\0'; 176 164 char **array, **arrayStep; 177 if (cgiFormEntries (&array ) != cgiFormSuccess)165 if (cgiFormEntries (&array,&cgi) != cgiFormSuccess) 178 166 { 179 167 return 1; … … 182 170 while (*arrayStep) 183 171 { 184 char *ivalue = new char[cgi ContentLength];172 char *ivalue = new char[cgi->cgiContentLength]; 185 173 cgiFormStringNoNewlines (*arrayStep, ivalue, 186 cgi ContentLength);174 cgi->cgiContentLength,&cgi); 187 175 char *tmpValueFinal = 188 176 (char *) … … 190 178 1) * sizeof (char)); 191 179 sprintf (tmpValueFinal, "%s=%s", *arrayStep, ivalue); 192 if (strlen ( buffer) == 0)180 if (strlen (post_data) == 0) 193 181 { 194 sprintf ( buffer, "%s", tmpValueFinal);182 sprintf (post_data, "%s", tmpValueFinal); 195 183 } 196 184 else 197 185 { 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); 200 188 free (tmp); 201 189 } … … 209 197 } 210 198 if (tmpMap != NULL) 211 addToMap (tmpMap, "request", buffer);199 addToMap (tmpMap, "request", post_data); 212 200 else 213 tmpMap = createMap ("request", buffer);214 } 215 delete[] buffer;201 tmpMap = createMap ("request", post_data); 202 } 203 delete[]post_data; 216 204 } 217 205 } … … 221 209 dumpMap (tmpMap); 222 210 #endif 223 char **array, **arrayStep; 224 if (cgiFormEntries (&array) != cgiFormSuccess) 211 212 char **array, **arrayStep; 213 if (cgiFormEntries (&array,&cgi) != cgiFormSuccess) 225 214 { 226 215 return 1; … … 229 218 while (*arrayStep) 230 219 { 231 char *value = new char[cgi ContentLength];232 cgiFormStringNoNewlines (*arrayStep, value, cgi ContentLength);220 char *value = new char[cgi->cgiContentLength]; 221 cgiFormStringNoNewlines (*arrayStep, value, cgi->cgiContentLength,&cgi); 233 222 #ifdef DEBUG 234 223 fprintf (stderr, "(( \n %s \n %s \n ))", *arrayStep, value); … … 265 254 * one. 266 255 */ 267 if (strncasecmp (cgi RequestMethod, "post", 4) == 0 ||256 if (strncasecmp (cgi->cgiRequestMethod, "post", 4) == 0 || 268 257 (count (tmpMap) == 1 && strncmp (tmpMap->value, "<", 1) == 0) 269 258 #ifdef WIN32 … … 280 269 addToMap (tmpMap, "xrequest", t1->value); 281 270 xmlInitParser (); 282 xmlDocPtr doc = xmlParseMemory (t1->value, cgi ContentLength);271 xmlDocPtr doc = xmlParseMemory (t1->value, cgi->cgiContentLength); 283 272 { 284 273 xmlXPathObjectPtr reqptr = extractFromDoc (doc, … … 384 373 char *identifiers = NULL; 385 374 identifiers = 386 (char *) calloc (cgi ContentLength, sizeof (char));375 (char *) calloc (cgi->cgiContentLength, sizeof (char)); 387 376 identifiers[0] = 0; 388 377 for (int k = 0; k < id->nodeNr; k++) … … 427 416 428 417 char *token, *saveptr; 429 token = strtok_r (cgi QueryString, "&", &saveptr);418 token = strtok_r (cgi->cgiQueryString, "&", &saveptr); 430 419 while (token != NULL) 431 420 { … … 452 441 } 453 442 454 if (strncasecmp (cgi ContentType, "multipart/form-data", 19) == 0)443 if (strncasecmp (cgi->cgiContentType, "multipart/form-data", 19) == 0) 455 444 { 456 445 map *tmp = getMap (tmpMap, "dataInputs"); … … 465 454 free (strQuery); 466 455 467 runRequest (&tmpMap );456 runRequest (&tmpMap,&cgi,request); 468 457 469 458 /** … … 475 464 free (tmpMap); 476 465 } 477 cgiFreeResources (); 466 // a verifier fait planter 467 cgiFreeResources (&cgi); 468 469 FCGX_Finish_r(request); 470 return 0; 471 } 472 473 474 475 int 476 main (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 } 478 509 } 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 480 538 return 0; 481 482 539 } 540 -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c
r532 r549 37 37 #include <libxml/xpath.h> 38 38 #include <libxml/xpathInternals.h> 39 #include "service_zcfg.h"40 39 #include <libgen.h> 41 40 } 42 41 #include "ulinet.h" 42 #include "service_zcfg.h" 43 43 #include <libintl.h> 44 44 #include <locale.h> 45 45 #include <string.h> 46 #include "service.h"47 #include "service_internal.h"46 //#include "service.h" 47 //#include "service_internal.h" 48 48 #ifdef USE_PYTHON 49 49 #include "service_internal_python.h" … … 172 172 ("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."), 173 173 mi->name, atoi (testMap->value)); 174 errorException (m, emsg, "InternalError", NULL);174 //errorException (m, emsg, "InternalError", NULL,stderr); 175 175 return -1; 176 176 } … … 193 193 ("ZOO-Kernel was unable to load your data for %s position %s."), 194 194 mi->name, tmpMap->value); 195 errorException (m, emsg, "InternalError", NULL);195 //errorException (m, emsg, "InternalError", NULL,stderr); 196 196 return -1; 197 197 } … … 204 204 ("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."), 205 205 mi->name); 206 errorException (m, emsg, "InternalError", NULL);206 //errorException (m, emsg, "InternalError", NULL,request->out); 207 207 return -1; 208 208 } … … 390 390 ("ZOO Kernel failed to process your request receiving signal %d = %s"), 391 391 sig, ssig); 392 errorException (NULL, tmp, "InternalError", NULL);392 //errorException (NULL, tmp, "InternalError", NULL,request->out); 393 393 #ifdef DEBUG 394 394 fprintf (stderr, "Not this time!\n"); … … 399 399 void 400 400 loadServiceAndRun (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) 402 402 { 403 char tmps1[1024]; 403 404 405 char tmps1[1024]; 404 406 char ntmp[1024]; 405 407 maps *m = *myMap; … … 523 525 (execute_t) GetProcAddress (so, s1->name); 524 526 #else 527 525 528 execute_t execute = (execute_t) dlsym (so, s1->name); 526 529 #endif … … 539 542 ("Error occured while running the %s function: %s"), 540 543 s1->name, errstr); 541 errorException (m, tmpMsg, "InternalError", NULL );544 errorException (m, tmpMsg, "InternalError", NULL,out); 542 545 free (tmpMsg); 543 546 #ifdef DEBUG 544 547 fprintf (stderr, "Function %s error %s\n", 545 548 s1->name, errstr); 546 #endif 549 #endif 550 547 551 *eres = -1; 548 552 return; 549 553 } 554 550 555 #ifdef DEBUG 551 556 #ifdef WIN32 … … 568 573 fflush (stderr); 569 574 #endif 575 576 577 570 578 } 571 579 #ifdef WIN32 … … 589 597 sprintf (tmps, _("C Library can't be loaded %s"), errstr); 590 598 map *tmps1 = createMap ("text", tmps); 591 printExceptionReportResponse (m, tmps1 );599 printExceptionReportResponse (m, tmps1,out); 592 600 *eres = -1; 593 601 freeMap (&tmps1); … … 602 610 zoo_python_support (&m, request_inputs, s1, 603 611 &request_input_real_format, 604 &request_output_real_format); 612 &request_output_real_format,err); 613 605 614 } 606 615 else … … 670 679 r_inputs->value); 671 680 map *tmps = createMap ("text", tmpv); 672 printExceptionReportResponse (m, tmps );681 printExceptionReportResponse (m, tmps,out); 673 682 *eres = -1; 674 683 } … … 794 803 795 804 int 796 runRequest (map ** inputs )805 runRequest (map ** inputs,struct cgi_env ** c,FCGX_Request *request) 797 806 { 798 807 808 809 struct cgi_env *cgi = *c; 799 810 #ifndef USE_GDB 800 811 (void) signal (SIGSEGV, sig_handler); … … 813 824 * Parsing service specfic configuration file 814 825 */ 826 815 827 m = (maps *) malloc (MAPS_SIZE); 816 828 if (m == NULL) 817 829 { 818 830 return errorException (m, _("Unable to allocate memory."), 819 "InternalError", NULL); 820 } 831 "InternalError", NULL,request->out); 832 } 833 821 834 char ntmp[1024]; 822 835 #ifndef WIN32 … … 827 840 r_inputs = getMapOrFill (&request_inputs, "metapath", ""); 828 841 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 832 847 if (conf_read (conf_file, m) == 2) 833 848 { 834 849 errorException (NULL, _("Unable to load the main.cfg file."), 835 "InternalError", NULL );850 "InternalError", NULL,request->out); 836 851 free (m); 837 852 return 1; 838 853 } 854 855 839 856 #ifdef DEBUG 840 857 fprintf (stderr, "***** BEGIN MAPS\n"); … … 844 861 845 862 map *getPath = getMapFromMaps (m, "main", "gettextPath"); 863 864 865 866 846 867 if (getPath != NULL) 847 868 { … … 854 875 bindtextdomain ("zoo-services", "/usr/share/locale/"); 855 876 } 856 857 877 858 878 /** … … 878 898 ("The value %s is not supported for the <language> parameter"), 879 899 r_inputs->value); 880 errorException (m, tmp, "InvalidParameterValue", "language" );900 errorException (m, tmp, "InvalidParameterValue", "language",request->out); 881 901 freeMaps (&m); 882 902 free (m); … … 929 949 setMapInMaps (m, "main", "isSoap", "false"); 930 950 931 if (strlen (cgi ServerName) > 0)951 if (strlen (cgi->cgiServerName) > 0) 932 952 { 933 953 char tmpUrl[1024]; 934 if (strncmp (cgi ServerPort, "80", 2) == 0)935 { 936 sprintf (tmpUrl, "http://%s%s", cgi ServerName,cgiScriptName);954 if (strncmp (cgi->cgiServerPort, "80", 2) == 0) 955 { 956 sprintf (tmpUrl, "http://%s%s", cgi->cgiServerName, cgi->cgiScriptName); 937 957 } 938 958 else 939 959 { 940 sprintf (tmpUrl, "http://%s:%s%s", cgi ServerName,941 cgi ServerPort,cgiScriptName);960 sprintf (tmpUrl, "http://%s:%s%s", cgi->cgiServerName, 961 cgi->cgiServerPort, cgi->cgiScriptName); 942 962 } 943 963 #ifdef DEBUG … … 954 974 { 955 975 errorException (m, _("Parameter <request> was not specified"), 956 "MissingParameterValue", "request" );976 "MissingParameterValue", "request",request->out); 957 977 if (count (request_inputs) == 1) 958 978 { … … 974 994 _ 975 995 ("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); 977 997 freeMaps (&m); 978 998 free (m); … … 986 1006 { 987 1007 errorException (m, _("Parameter <service> was not specified"), 988 "MissingParameterValue", "service" );1008 "MissingParameterValue", "service",request->out); 989 1009 freeMaps (&m); 990 1010 free (m); … … 999 1019 _ 1000 1020 ("Unenderstood <service> value, WPS is the only acceptable value."), 1001 "InvalidParameterValue", "service" );1021 "InvalidParameterValue", "service",request->out); 1002 1022 freeMaps (&m); 1003 1023 free (m); … … 1012 1032 { 1013 1033 errorException (m, _("Parameter <version> was not specified"), 1014 "MissingParameterValue", "version" );1034 "MissingParameterValue", "version",request->out); 1015 1035 freeMaps (&m); 1016 1036 free (m); … … 1025 1045 _ 1026 1046 ("Unenderstood <version> value, 1.0.0 is the only acceptable value."), 1027 "InvalidParameterValue", "service" );1047 "InvalidParameterValue", "service",request->out); 1028 1048 freeMaps (&m); 1029 1049 free (m); … … 1043 1063 _ 1044 1064 ("Unenderstood <AcceptVersions> value, 1.0.0 is the only acceptable value."), 1045 "VersionNegotiationFailed", NULL );1065 "VersionNegotiationFailed", NULL,request->out); 1046 1066 freeMaps (&m); 1047 1067 free (m); … … 1080 1100 else 1081 1101 snprintf (conf_dir, 1024, "%s", ntmp); 1102 1103 1104 1082 1105 1083 1106 if (strncasecmp (REQUEST, "GetCapabilities", 15) == 0) … … 1098 1121 * has been found in the zcfg and then printed on stdout 1099 1122 */ 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 **/1116 1123 XML_CapabilitiesAllProcess (m, n); 1117 dup2 (saved_stdout, fileno (stdout)); 1118 printDocument (m, doc, getpid ()); 1124 printDocument (m, doc, getpid (),request->out); 1119 1125 freeMaps (&m); 1120 1126 free (m); 1121 1127 free (REQUEST); 1122 1128 free (SERVICE_URL); 1123 fflush (stdout);1124 1129 return 0; 1125 1130 } … … 1132 1137 errorException (m, 1133 1138 _("Mandatory <identifier> was not specified"), 1134 "MissingParameterValue", "identifier" );1139 "MissingParameterValue", "identifier",request->out); 1135 1140 freeMaps (&m); 1136 1141 free (m); … … 1146 1151 errorException (m, 1147 1152 _("The specified path path doesn't exist."), 1148 "InvalidParameterValue", conf_dir );1153 "InvalidParameterValue", conf_dir,request->out); 1149 1154 freeMaps (&m); 1150 1155 free (m); … … 1173 1178 1174 1179 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)); 1177 1182 XML_Describe_Process (m, n, orig); 1178 1183 closedir (dirp); 1179 fflush (stdout);1180 dup2 (saved_stdout, fileno (stdout));1184 //fflush (stdout); 1185 //dup2 (saved_stdout, fileno (stdout)); 1181 1186 free (orig); 1182 printDocument (m, doc, getpid () );1187 printDocument (m, doc, getpid (),request->out); 1183 1188 freeMaps (&m); 1184 1189 free (m); 1185 1190 free (REQUEST); 1186 1191 free (SERVICE_URL); 1187 fflush (stdout);1192 //fflush (stdout); 1188 1193 return 0; 1189 1194 … … 1191 1196 else if (strncasecmp (REQUEST, "Execute", strlen (REQUEST)) != 0) 1192 1197 { 1198 1193 1199 errorException (m, 1194 1200 _ 1195 1201 ("Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute."), 1196 "InvalidParameterValue", "request" );1202 "InvalidParameterValue", "request",request->out); 1197 1203 #ifdef DEBUG 1198 1204 fprintf (stderr, "No request found %s", REQUEST); … … 1203 1209 free (REQUEST); 1204 1210 free (SERVICE_URL); 1205 fflush (stdout);1211 //fflush (stdout); 1206 1212 return 0; 1207 1213 } … … 1250 1256 fflush (stdout); 1251 1257 **/ 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)); 1254 1260 s1 = search_service (r_inputs->value); 1255 1261 if (s1 == NULL) … … 1260 1266 ("The value for <identifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."), 1261 1267 r_inputs->value); 1262 errorException (m, tmpMsg, "InvalidParameterValue", "identifier" );1268 errorException (m, tmpMsg, "InvalidParameterValue", "identifier",request->out); 1263 1269 free (tmpMsg); 1264 1270 //free (s1); … … 1269 1275 return 0; 1270 1276 } 1271 close (saved_stdout);1277 //close (saved_stdout); 1272 1278 1273 1279 #ifdef DEBUG … … 1339 1345 return errorException (m, 1340 1346 _("Unable to allocate memory"), 1341 "InternalError", NULL );1347 "InternalError", NULL,request->out); 1342 1348 } 1343 1349 i = 0; … … 1356 1362 _ 1357 1363 ("Unable to allocate memory"), 1358 "InternalError", NULL );1364 "InternalError", NULL,request->out); 1359 1365 } 1360 1366 snprintf (outputs_as_text[i], strlen (pToken) + 1, "%s", … … 1382 1388 _ 1383 1389 ("Unable to allocate memory."), 1384 "InternalError", NULL );1390 "InternalError", NULL,request->out); 1385 1391 } 1386 1392 tmp_output->name = zStrdup (tmpc); … … 1447 1453 errorException (m, 1448 1454 _("Parameter <DataInputs> was not specified"), 1449 "MissingParameterValue", "DataInputs" );1455 "MissingParameterValue", "DataInputs",request->out); 1450 1456 freeMaps (&m); 1451 1457 free (m); … … 1479 1485 { 1480 1486 return errorException (m, _("Unable to allocate memory."), 1481 "InternalError", NULL );1487 "InternalError", NULL,request->out); 1482 1488 } 1483 1489 i = 0; … … 1498 1504 return errorException (m, 1499 1505 _("Unable to allocate memory."), 1500 "InternalError", NULL );1506 "InternalError", NULL,request->out); 1501 1507 } 1502 1508 pToken = strtok (NULL, ";"); … … 1540 1546 _ 1541 1547 ("Unable to allocate memory."), 1542 "InternalError", NULL );1548 "InternalError", NULL,request->out); 1543 1549 } 1544 1550 tmpmaps->name = zStrdup (tmpn); … … 1611 1617 ("Unable to find a valid protocol to download the remote file %s"), 1612 1618 tmpv1 + 1); 1613 errorException (m, emsg, "InternalError", NULL );1619 errorException (m, emsg, "InternalError", NULL,request->out); 1614 1620 freeMaps (&m); 1615 1621 free (m); … … 1702 1708 fflush (stderr); 1703 1709 #endif 1704 xmlDocPtr doc = xmlParseMemory (postRequest->value, cgi ContentLength);1710 xmlDocPtr doc = xmlParseMemory (postRequest->value, cgi->cgiContentLength); 1705 1711 #ifdef DEBUG 1706 1712 fprintf (stderr, "AFTER\n"); … … 1753 1759 _ 1754 1760 ("Unable to allocate memory."), 1755 "InternalError", NULL );1761 "InternalError", NULL,request->out); 1756 1762 } 1757 1763 tmpmaps->name = zStrdup ((char *) val); … … 1782 1788 _ 1783 1789 ("Unable to allocate memory."), 1784 "InternalError", NULL );1790 "InternalError", NULL,request->out); 1785 1791 } 1786 1792 tmpmaps->name = zStrdup ("missingIndentifier"); … … 1926 1932 _ 1927 1933 ("Unable to allocate memory."), 1928 "InternalError", NULL );1934 "InternalError", NULL,request->out); 1929 1935 } 1930 1936 snprintf (has, … … 1965 1971 (char *) 1966 1972 malloc 1967 (cgi ContentLength + 1 * sizeof (char));1968 memset (tmp, 0, cgi ContentLength);1973 (cgi->cgiContentLength + 1 * sizeof (char)); 1974 memset (tmp, 0, cgi->cgiContentLength); 1969 1975 xmlNodePtr cur4 = cur3->children; 1970 1976 while (cur4 != NULL) … … 2058 2064 _ 2059 2065 ("Unable to allocate memory."), 2060 "InternalError", NULL );2066 "InternalError", NULL,request->out); 2061 2067 } 2062 2068 size_t bRead; … … 2380 2386 _ 2381 2387 ("Unable to allocate memory."), 2382 "InternalError", NULL );2388 "InternalError", NULL,request->out); 2383 2389 } 2384 2390 tmpmaps->name = zStrdup ("unknownIdentifier"); … … 2464 2470 _ 2465 2471 ("Unable to allocate memory."), 2466 "InternalError", NULL );2472 "InternalError", NULL,request->out); 2467 2473 } 2468 2474 tmpmaps->name = zStrdup ("unknownIdentifier"); … … 2520 2526 _ 2521 2527 ("Unable to allocate memory."), 2522 "InternalError", NULL );2528 "InternalError", NULL,request->out); 2523 2529 } 2524 2530 tmpmaps->name = zStrdup ((char *) val); … … 2580 2586 _ 2581 2587 ("Unable to allocate memory."), 2582 "InternalError", NULL );2588 "InternalError", NULL,request->out); 2583 2589 } 2584 2590 tmpmaps->name = zStrdup ("missingIndetifier"); … … 2659 2665 _ 2660 2666 ("Unable to allocate memory."), 2661 "InternalError", NULL );2667 "InternalError", NULL,request->out); 2662 2668 } 2663 2669 tmpmaps->name = zStrdup ((char *) val); … … 2700 2706 _ 2701 2707 ("Unable to allocate memory."), 2702 "InternalError", NULL );2708 "InternalError", NULL,request->out); 2703 2709 } 2704 2710 tmpmaps->name = … … 2788 2794 addToMap (tmpe, "locator", ptr->name); 2789 2795 addToMap (tmpe, "text", tmps); 2790 printExceptionReportResponse (m, tmpe );2796 printExceptionReportResponse (m, tmpe,request->out); 2791 2797 //freeService (&s1); 2792 2798 //free (s1); … … 2832 2838 } 2833 2839 addToMap (tmpe, "text", tmps); 2834 printExceptionReportResponse (m, tmpe );2840 printExceptionReportResponse (m, tmpe,request->out); 2835 2841 //freeService (&s1); 2836 2842 free (s1); … … 2855 2861 if (getMap (tmpReqI->content, "isFile") != NULL) 2856 2862 { 2857 if (cgiFormFileName (tmpReqI->name, name, sizeof (name) ) ==2863 if (cgiFormFileName (tmpReqI->name, name, sizeof (name),&cgi) == 2858 2864 cgiFormSuccess) 2859 2865 { … … 2869 2875 int got, t; 2870 2876 map *path = getMapFromMaps (m, "main", "tmpPath"); 2871 cgiFormFileSize (tmpReqI->name, &size );2877 cgiFormFileSize (tmpReqI->name, &size,&cgi); 2872 2878 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) 2875 2881 { 2876 2882 t = -1; … … 3018 3024 _ 3019 3025 ("Status cannot be set to true with storeExecuteResponse to false. Please, modify your request parameters."), 3020 "InvalidParameterValue", "storeExecuteResponse" );3026 "InvalidParameterValue", "storeExecuteResponse",request->out); 3021 3027 //freeService (&s1); 3022 3028 //free (s1); … … 3069 3075 else 3070 3076 addToMap (_tmpMaps->content, "soap", "false"); 3071 if (cgi Cookie != NULL && strlen (cgiCookie) > 0)3077 if (cgi->cgiCookie != NULL && strlen (cgi->cgiCookie) > 0) 3072 3078 { 3073 3079 int hasValidCookie = -1; 3074 char *tcook = zStrdup (cgi Cookie);3080 char *tcook = zStrdup (cgi->cgiCookie); 3075 3081 char *tmp = NULL; 3076 3082 map *testing = getMapFromMaps (m, "main", "cookiePrefix"); … … 3085 3091 sprintf (tmp, "%s=", testing->value); 3086 3092 } 3087 if (strstr (cgi Cookie, ";") != NULL)3093 if (strstr (cgi->cgiCookie, ";") != NULL) 3088 3094 { 3089 3095 char *token, *saveptr; 3090 token = strtok_r (cgi Cookie, ";", &saveptr);3096 token = strtok_r (cgi->cgiCookie, ";", &saveptr); 3091 3097 while (token != NULL) 3092 3098 { … … 3104 3110 { 3105 3111 if (strstr 3106 (cgi Cookie, "=") != NULL && strcasestr (cgiCookie, tmp) != NULL)3112 (cgi->cgiCookie, "=") != NULL && strcasestr (cgi->cgiCookie, tmp) != NULL) 3107 3113 { 3108 tcook = zStrdup (cgi Cookie);3114 tcook = zStrdup (cgi->cgiCookie); 3109 3115 hasValidCookie = 1; 3110 3116 } … … 3131 3137 sprintf 3132 3138 (session_file_path, 3133 "%s/sess_%s.cfg", tmpPath->value, strstr (cgi Cookie, "=") + 1);3139 "%s/sess_%s.cfg", tmpPath->value, strstr (cgi->cgiCookie, "=") + 1); 3134 3140 free (tcook); 3135 3141 maps *tmpSess = (maps *) malloc (MAPS_SIZE); … … 3137 3143 int istat = stat (session_file_path, 3138 3144 &file_status); 3145 3139 3146 if (istat == 0 && file_status.st_size > 0) 3140 3147 { … … 3144 3151 free (tmpSess); 3145 3152 } 3153 3146 3154 } 3147 3155 } … … 3166 3174 } 3167 3175 #endif 3168 char *fbkp, *fbkp1; 3176 3177 3178 char *fbkp, *fbkp1; 3169 3179 FILE *f0, *f1; 3170 3180 if (status != NULL) … … 3176 3186 (&m, s1, 3177 3187 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); 3179 3189 } 3180 3190 else … … 3261 3271 r_inputs1->value, 3262 3272 SERVICE_STARTED, 3263 request_input_real_format, request_output_real_format );3273 request_input_real_format, request_output_real_format,request->out); 3264 3274 #ifndef WIN32 3265 3275 fflush (stdout); … … 3277 3287 (&m, s1, 3278 3288 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); 3280 3290 } 3281 3291 else … … 3289 3299 _ 3290 3300 ("Unable to run the child process properly"), 3291 "InternalError", NULL );3301 "InternalError", NULL,request->out); 3292 3302 } 3293 3303 } … … 3296 3306 dumpMaps (request_output_real_format); 3297 3307 #endif 3308 3298 3309 if (eres != -1) 3299 3310 outputResponse (s1, 3300 3311 request_input_real_format, 3301 3312 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); 3304 3315 /** 3305 3316 * Ensure that if error occurs when freeing memory, no signal will return … … 3315 3326 (void) signal (SIGABRT, donothing); 3316 3327 #endif 3317 if (((int) getpid ()) != cpid || cgi Sid != NULL)3328 if (((int) getpid ()) != cpid || cgi->cgiSid != NULL) 3318 3329 { 3319 3330 fclose (stdout);
Note: See TracChangeset
for help on using the changeset viewer.