- Timestamp:
- Feb 2, 2015, 10:04:56 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note: See TracChangeset
for help on using the changeset viewer.