Changeset 34 for trunk


Ignore:
Timestamp:
Oct 1, 2010, 1:41:53 AM (14 years ago)
Author:
djay
Message:

Make ZOO Kernel able to speak the natural language you teach him by using gettext tools for creating translation files. Add basic french translation .po files as current messages.po. Gettext Domains used are zoo-kernel and zoo-services.

Location:
trunk
Files:
15 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/main_conf_read.l

    r12 r34  
    6565<PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}*                   {if (affichetrace==1) printf ("\n\nNEWLINE 2\n") ; BEGIN(INITIAL); return NEWLINE;}
    6666
    67 <INITIAL>"<?"[Xx][Mm][Ll]  { if (attentionImpossibleDeTrouverXMLDeclapres == 1 || attentionImpossibleDeTrouverPIapres == 1) { printf("\nerror : a la ligne %d : il y a eut un commentaire ou un PI avant la declaration xml\n",yylineno); exit (10) ; } ; if (affichetrace==1) printf ("\n\nSTARTXMLDECL:%s\n",yytext) ;return STARTXMLDECL;}
     67<INITIAL>"<?"[Xx][Mm][Ll]  { if (attentionImpossibleDeTrouverXMLDeclapres == 1 || attentionImpossibleDeTrouverPIapres == 1) { printf("\nerror : LINE %d : comment ot PI before xml declaration\n",yylineno); exit (10) ; } ; if (affichetrace==1) printf ("\n\nSTARTXMLDECL:%s\n",yytext) ;return STARTXMLDECL;}
    6868
    6969<INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\'  {if (affichetrace==1) printf ("\n\nVERSIONDECL:%s\n",yytext) ;return VERSIONDECL;}
    70 <INITIAL>"version"{egalevolue}\"[^"]*\"|"version"{egalevolue}\'[^']*\'  {/* erreur de version encoding */       printf("\nerror : a la ligne %d : la version xml n est pas reconnue : %s\n",yylineno,yytext); exit (9) ; }
     70<INITIAL>"version"{egalevolue}\"[^"]*\"|"version"{egalevolue}\'[^']*\'  {/* erreur de version encoding */       printf("\nerror : LINE %d : XML Version not supported : %s\n",yylineno,yytext); exit (9) ; }
    7171
    7272
    7373<INITIAL>"encoding"{egalevolue}\"[Ii][Ss][Oo]"-8859-1"\"|"encoding"{egalevolue}\'[Ii][Ss][Oo]"-8859-1"\'  {if (affichetrace==1) printf ("\n\nENCODINGDECL:%s\n",yytext) ; return ENCODINGDECL;}
    74 <INITIAL>"encoding"{egalevolue}\"[^"]*\"|"encoding"{egalevolue}\'[^']*\'  {/* erreur de version encoding */     printf("\nerror : a la ligne %d : la version d encodage n est pas reconnue : %s\n",yylineno,yytext); exit (8) ; }
     74<INITIAL>"encoding"{egalevolue}\"[^"]*\"|"encoding"{egalevolue}\'[^']*\'  {/* erreur de version encoding */     printf("\nerror : LINE %d : encoding version not supported : %s\n",yylineno,yytext); exit (8) ; }
    7575
    7676
    7777<INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\'  {if (affichetrace==1) printf ("\n\nSDDECL:%s\n",yytext) ; return SDDECL;}
    7878
    79 <INITIAL>"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'|"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'  {/* erreur de version encoding */     printf("\nerror : a la ligne %d : la version standalone n est pas reconnue : %s\n",yylineno,yytext); exit (7) ; }
     79<INITIAL>"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'|"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'  {/* erreur de version encoding */     printf("\nerror : LINE %d : standalone version not supported : %s\n",yylineno,yytext); exit (7) ; }
    8080
    8181
     
    111111
    112112
    113 <INITIAL,DANSBALISE,HORSBALISE>.|\n     {if (affichetrace==1)printf("error : ligne %d : caractere non reconnu '%s'\n",yylineno,yytext); }
     113<INITIAL,DANSBALISE,HORSBALISE>.|\n     {if (affichetrace==1)printf("error : LINE %d : character not supported '%s'\n",yylineno,yytext); }
    114114
    115115%%
  • trunk/zoo-kernel/service_internal.c

    r33 r34  
    2525#include "service_internal.h"
    2626
     27void *addLangAttr(xmlNodePtr n,maps *m){
     28  map *tmpLmap=getMapFromMaps(m,"main","language");
     29  if(tmpLmap!=NULL)
     30    xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST tmpLmap->value);
     31  else
     32    xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en-US");
     33}
     34
    2735/* Converts a hex character to its integer value */
    2836char from_hex(char ch) {
     
    281289  xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsGetCapabilities_response.xsd");
    282290  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
     291  addLangAttr(n,m);
    283292 
    284293  if(toto1!=NULL){
     
    512521          xmlAddChild(nc2,nc4);
    513522          xmlAddChild(nc1,nc2);
    514           xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST buff);
    515523          dcount++;
    516524        }
     
    590598  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
    591599  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
    592   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
     600  addLangAttr(n,m);
    593601
    594602  xmlDocSetRootElement(doc, n);
     
    954962  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
    955963  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
    956   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
     964  addLangAttr(n,m);
     965
    957966  char tmp[256];
    958967  char url[1024];
     
    10461055  case SERVICE_SUCCEEDED:
    10471056    nc1 = xmlNewNode(ns, BAD_CAST "ProcessSucceeded");
    1048     sprintf(sMsg,"Service \"%s\" run successfully.",serv->name);
     1057    sprintf(sMsg,_("Service \"%s\" run successfully."),serv->name);
    10491058    nc3=xmlNewText(BAD_CAST sMsg);
    10501059    xmlAddChild(nc1,nc3);
     
    10541063    tmpStatus=getMapFromMaps(m,"lenv","status");
    10551064    xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST tmpStatus->value);
    1056     sprintf(sMsg,"ZOO Service \"%s\" is currently running. Please, reload this document to get the up-to-date status of the Service.",serv->name);
     1065    sprintf(sMsg,_("ZOO Service \"%s\" is currently running. Please, reload this document to get the up-to-date status of the Service."),serv->name);
    10571066    nc3=xmlNewText(BAD_CAST sMsg);
    10581067    xmlAddChild(nc1,nc3);
     
    10601069  case SERVICE_ACCEPTED:
    10611070    nc1 = xmlNewNode(ns, BAD_CAST "ProcessAccepted");
    1062     sprintf(sMsg,"Service \"%s\" was accepted by the ZOO Kernel and it run as a background task. Please consult the statusLocation attribtue providen in this document to get the up-to-date document.",serv->name);
     1071    sprintf(sMsg,_("Service \"%s\" was accepted by the ZOO Kernel and it run as a background task. Please consult the statusLocation attribtue providen in this document to get the up-to-date document."),serv->name);
    10631072    nc3=xmlNewText(BAD_CAST sMsg);
    10641073    xmlAddChild(nc1,nc3);
     
    10771086      addToMap(errorMap,"text",te->value);
    10781087    else
    1079       addToMap(errorMap,"text","No more information available");
     1088      addToMap(errorMap,"text",_("No more information available"));
    10801089    nc3=createExceptionReportNode(m,errorMap,0);
    10811090    xmlAddChild(nc1,nc3);
    10821091    break;
    10831092  default :
    1084     printf("error code not know : %i\n",status);
     1093    printf(_("error code not know : %i\n"),status);
    10851094    //exit(1);
    10861095    break;
     
    12501259  // Extract Title required to be first element in the ZCFG file !
    12511260  nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name);
    1252   nc3=xmlNewText(BAD_CAST tmp->value);
     1261  nc3=xmlNewText(BAD_CAST _ss(tmp->value));
    12531262  xmlAddChild(nc2,nc3); 
    12541263  xmlAddChild(nc1,nc2);
     
    12561265  tmp=tmp->next;
    12571266  nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name);
    1258   nc3=xmlNewText(BAD_CAST tmp->value);
     1267  nc3=xmlNewText(BAD_CAST _ss(tmp->value));
    12591268  xmlAddChild(nc2,nc3); 
    12601269  xmlAddChild(nc1,nc2);
     
    13521361    if(tmp1!=NULL){
    13531362      nc2 = xmlNewNode(ns_ows, BAD_CAST tmp2[j]);
    1354       xmlAddChild(nc2,xmlNewText(BAD_CAST tmp1->value));
     1363      fprintf(stderr,"[%s] \n[%s]\n",tmp1->value,_ss(tmp1->value));
     1364      xmlAddChild(nc2,xmlNewText(BAD_CAST _ss(tmp1->value)));
    13551365      xmlAddChild(root,nc2);
    13561366    }
     
    13891399  xmlDocPtr doc;
    13901400  xmlChar *xmlbuff;
    1391   xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
    1392   xmlNodePtr n,nc,nc1,nc2;
     1401  xmlNodePtr n;
    13931402
    13941403  doc = xmlNewDoc(BAD_CAST "1.0");
     
    14051414  }else
    14061415    printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
    1407 
    1408   ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
    1409   n = xmlNewNode(ns, BAD_CAST "ExceptionReport"); 
    1410   ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
    1411   ns_xlink=xmlNewNs(n,BAD_CAST "http://www.w3.org/1999/xlink",BAD_CAST "xlink");
    1412   ns_xsi=xmlNewNs(n,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
    1413   xmlNewProp(n,BAD_CAST "xsi:schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
    1414   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
    1415   xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
    1416 
    1417   nc = xmlNewNode(ns, BAD_CAST "Exception"); 
    1418 
    1419   map* tmp=getMap(s,"code");
    1420   if(tmp!=NULL)
    1421     xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST tmp->value);
    1422   else
    1423     xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode");
    1424 
    1425   tmp=getMap(s,"text");
    1426   nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
    1427   nc2=NULL;
    1428   if(tmp!=NULL){
    1429     xmlNodeSetContent(nc1, BAD_CAST tmp->value);
    1430   }
    1431   else{
    1432     xmlNodeSetContent(nc1, BAD_CAST "No debug message available");
    1433   }
    1434   xmlAddChild(nc,nc1);
    1435   xmlAddChild(n,nc);
     1416  n=createExceptionReportNode(m,s,1);
    14361417  xmlDocSetRootElement(doc, n);
    1437 
    14381418  xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1);
    14391419  printf("%s",xmlbuff);
     
    14411421  xmlFreeDoc(doc);
    14421422  xmlFree(xmlbuff);
    1443   xmlFreeNs(ns);
    14441423  xmlCleanupParser();
    14451424}
     
    14651444    xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
    14661445  }
    1467   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
     1446  addLangAttr(n,m);
    14681447  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
    14691448 
     
    14831462  }
    14841463  else{
    1485     xmlNodeSetContent(nc1, BAD_CAST "No debug message available");
     1464    xmlNodeSetContent(nc1, BAD_CAST _("No debug message available"));
    14861465  }
    14871466  xmlAddChild(nc,nc1);
     
    15441523      toto=getMap(request_outputs->content,"value");
    15451524      if(toto==NULL){
    1546         map * errormap = createMap("text","Unable to fetch any result");
     1525        map * errormap = createMap("text",_("Unable to fetch any result"));
    15471526        addToMap(errormap,"code", "InternalError");
    15481527        printExceptionReportResponse(m,errormap);
     
    15851564      lenv=getMapFromMaps(m,"lenv","message");
    15861565      if(lenv!=NULL)
    1587         sprintf(tmp,"Unable to run the Service. The message returned back by the Service was the following : %s",lenv->value);
     1566        sprintf(tmp,_("Unable to run the Service. The message returned back by the Service was the following : %s"),lenv->value);
    15881567      else
    1589         sprintf(tmp,"Unable to run the Service. No more information was returned back by the Service.");
     1568        sprintf(tmp,_("Unable to run the Service. No more information was returned back by the Service."));
    15901569      errormap = createMap("text",tmp);     
    15911570      addToMap(errormap,"code", "InternalError");
  • trunk/zoo-kernel/service_internal.h

    r26 r34  
    2828#pragma once
    2929
    30 #define DEFAULT_SERVICE_URL "http://dev.geolabs.fr/zoo-wps/"
     30#define DEFAULT_SERVICE_URL "http://www.zoo-project.org/"
    3131#define TIME_SIZE 40
     32
     33#include <libintl.h>
     34#include <locale.h>
     35#define _(String) dgettext ("zoo-kernel",String)
     36#define _ss(String) dgettext ("zoo-services",String)
    3237
    3338#include <sys/stat.h>
  • trunk/zoo-kernel/service_internal_js.c

    r26 r34  
    208208  /* Cleanup. */
    209209  JS_DestroyScript(cx, script);
    210   JS_MaybeGC(cx);
     210  //JS_MaybeGC(cx);
    211211  // If we use the DestroyContext as requested to release memory then we get
    212212  // issue getting back the main configuration maps after coming back to the
  • trunk/zoo-kernel/zoo_service_loader.c

    r33 r34  
    4040#include "ulinet.h"
    4141
     42#include <libintl.h>
     43#include <locale.h>
    4244#include <string.h>
    4345
    4446#include "service.h"
     47
    4548#include "service_internal.h"
    4649
     
    8083#include <time.h>
    8184#include <stdarg.h>
     85
     86#define _(String) dgettext ("zoo-kernel",String)
     87
     88
     89void *translateChar(char* str,char toReplace,char toReplaceBy){
     90  int i=0,len=strlen(str);
     91  for(i=0;i<len;i++){
     92    if(str[i]==toReplace)
     93      str[i]=toReplaceBy;
     94  }
     95}
    8296
    8397xmlXPathObjectPtr extractFromDoc(xmlDocPtr doc,char* search){
     
    116130    break;
    117131  }
    118   sprintf(tmp,"ZOO Kernel failed to process your request receiving signal %d = %s",sig,ssig);
     132  sprintf(tmp,_("ZOO Kernel failed to process your request receiving signal %d = %s"),sig,ssig);
    119133  errorException(NULL, tmp, "InternalError");
    120134#ifdef DEBUG
     
    122136#endif
    123137  exit(0);
     138}
     139
     140void *loadServiceAndRun(maps **myMap,service* s1,map* request_inputs,maps **inputs,maps** ioutputs,int* eres){
     141  char tmps1[1024];
     142  char ntmp[1024];
     143  maps *m=*myMap;
     144  maps *request_output_real_format=*ioutputs;
     145  maps *request_input_real_format=*inputs;
     146  /**
     147   * Extract serviceType to know what kind of service should be loaded
     148   */
     149  map* r_inputs=NULL;
     150#ifndef WIN32
     151  getcwd(ntmp,1024);
     152#else
     153  _getcwd(ntmp,1024);
     154#endif
     155  r_inputs=getMap(s1->content,"serviceType");
     156#ifdef DEBUG
     157  fprintf(stderr,"LOAD A %s SERVICE PROVIDER \n",r_inputs->value);
     158  fflush(stderr);
     159#endif
     160  if(strncasecmp(r_inputs->value,"C",1)==0){
     161    r_inputs=getMap(request_inputs,"metapath");
     162    if(r_inputs!=NULL)
     163      sprintf(tmps1,"%s/%s",ntmp,r_inputs->value);
     164    else
     165      sprintf(tmps1,"%s/",ntmp);
     166    char *altPath=strdup(tmps1);
     167    r_inputs=getMap(s1->content,"ServiceProvider");
     168    sprintf(tmps1,"%s/%s",altPath,r_inputs->value);
     169    free(altPath);
     170#ifdef DEBUG
     171    fprintf(stderr,"Trying to load %s\n",tmps1);
     172#endif
     173#ifdef WIN32
     174    HINSTANCE so = LoadLibraryEx(tmps1,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
     175#else
     176    void* so = dlopen(tmps1, RTLD_LAZY);
     177#endif
     178#ifdef DEBUG
     179#ifdef WIN32<
     180    DWORD errstr;
     181    errstr = GetLastError();
     182    fprintf(stderr,"%s loaded (%d) \n",tmps1,errstr);
     183#else
     184    char *errstr;
     185    errstr = dlerror();
     186#endif
     187#endif
     188
     189    if( so != NULL ) {
     190#ifdef DEBUG
     191      fprintf(stderr,"Library loaded %s \n",errstr);
     192      fprintf(stderr,"Service Shared Object = %s\n",r_inputs->value);
     193#endif
     194      r_inputs=getMap(s1->content,"serviceType");
     195#ifdef DEBUG
     196      dumpMap(r_inputs);
     197      fprintf(stderr,"%s\n",r_inputs->value);
     198      fflush(stderr);
     199#endif
     200      if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){
     201#ifdef WIN32
     202        //Strange return value needed here !
     203        return 1;
     204#endif
     205        r_inputs=getMap(request_inputs,"Identifier");
     206        char fname[1024];
     207        sprintf(fname,"%s_",r_inputs->value);
     208#ifdef DEBUG
     209        fprintf(stderr,"Try to load function %s\n",fname);
     210#endif
     211#ifdef WIN32
     212        typedef int (CALLBACK* execute_t)(char***,char***,char***);
     213        execute_t execute=(execute_t)GetProcAddress(so,fname);
     214#else
     215        typedef int (*execute_t)(char***,char***,char***);
     216        execute_t execute=(execute_t)dlsym(so,fname);
     217#endif
     218#ifdef DEBUG
     219#ifdef WIN32
     220        errstr = GetLastError();
     221#else
     222        errstr = dlerror();
     223#endif
     224        fprintf(stderr,"Function loaded %s\n",errstr);
     225#endif 
     226
     227        char main_conf[10][30][1024];
     228        char inputs[10][30][1024];
     229        char outputs[10][30][1024];
     230        for(int i=0;i<10;i++){
     231          for(int j=0;j<30;j++){
     232            memset(main_conf[i][j],0,1024);
     233            memset(inputs[i][j],0,1024);
     234            memset(outputs[i][j],0,1024);
     235          }
     236        }
     237        mapsToCharXXX(m,(char***)main_conf);
     238        mapsToCharXXX(request_input_real_format,(char***)inputs);
     239        mapsToCharXXX(request_output_real_format,(char***)outputs);
     240        *eres=execute((char***)&main_conf[0],(char***)&inputs[0],(char***)&outputs[0]);
     241#ifdef DEBUG
     242        fprintf(stderr,"Function run successfully \n");
     243#endif
     244        charxxxToMaps((char***)&outputs[0],&request_output_real_format);
     245      }else{
     246#ifdef DEBUG
     247#ifdef WIN32
     248        errstr = GetLastError();
     249        fprintf(stderr,"Function %s failed to load because of %d\n",r_inputs->value,errstr);
     250#endif
     251#endif
     252        r_inputs=getMap(request_inputs,"Identifier");
     253#ifdef DEBUG
     254        fprintf(stderr,"Try to load function %s\n",r_inputs->value);
     255#endif
     256        typedef int (*execute_t)(maps**,maps**,maps**);
     257#ifdef WIN32
     258        execute_t execute=(execute_t)GetProcAddress(so,r_inputs->value);
     259#else
     260        execute_t execute=(execute_t)dlsym(so,r_inputs->value);
     261#endif
     262
     263#ifdef DEBUG
     264#ifdef WIN32
     265        errstr = GetLastError();
     266#else
     267        errstr = dlerror();
     268#endif
     269        fprintf(stderr,"Function loaded %s\n",errstr);
     270#endif 
     271
     272#ifdef DEBUG
     273        fprintf(stderr,"Now run the function \n");
     274        fflush(stderr);
     275#endif
     276        *eres=execute(&m,&request_input_real_format,&request_output_real_format);
     277#ifdef DEBUG
     278        fprintf(stderr,"Function loaded and returned %d\n",eres);
     279        fflush(stderr);
     280#endif
     281      }
     282      dlclose(so);
     283    } else {
     284      /**
     285       * Unable to load the specified shared library
     286       */
     287      char tmps[1024];
     288#ifdef WIN32
     289      DWORD errstr = GetLastError();
     290#else
     291      char* errstr = dlerror();
     292#endif
     293      sprintf(tmps,_("C Library can't be loaded %s \n"),errstr);
     294      map* tmps1=createMap("text",tmps);
     295      printExceptionReportResponse(m,tmps1);
     296      *eres=-1;
     297    }
     298  }
     299  else
     300#ifdef USE_PYTHON
     301    if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
     302      *eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
     303    }
     304    else
     305#endif
     306       
     307#ifdef USE_JAVA
     308      if(strncasecmp(r_inputs->value,"JAVA",4)==0){
     309        *eres=zoo_java_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
     310      }
     311      else
     312#endif
     313
     314#ifdef USE_PHP
     315        if(strncasecmp(r_inputs->value,"PHP",3)==0){
     316          *eres=zoo_php_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
     317        }
     318        else
     319#endif
     320           
     321           
     322#ifdef USE_PERL
     323          if(strncasecmp(r_inputs->value,"PERL",4)==0){
     324            *eres=zoo_perl_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
     325          }
     326          else
     327#endif
     328
     329#ifdef USE_JS
     330            if(strncasecmp(r_inputs->value,"JS",2)==0){
     331              *eres=zoo_js_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
     332            }
     333            else
     334#endif
     335              {
     336                char tmpv[1024];
     337                sprintf(tmpv,_("Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n"),r_inputs->value);
     338                map* tmps=createMap("text",tmpv);
     339                printExceptionReportResponse(m,tmps);
     340                *eres=-1;
     341              }
     342  *ioutputs=request_output_real_format;
    124343}
    125344
     
    144363  m=(maps*)calloc(1,MAPS_SIZE);
    145364  if(m == NULL){
    146     return errorException(m, "Unable to allocate memory.", "InternalError");
     365    return errorException(m, _("Unable to allocate memory."), "InternalError");
    147366  }
    148367  char ntmp[1024];
     
    173392#endif
    174393
     394  bindtextdomain ("zoo-kernel","/usr/share/locale/");
     395  bindtextdomain ("zoo-services","/usr/share/locale/");
     396 
     397  if((r_inputs=getMap(request_inputs,"language"))!=NULL){
     398    char *tmp=strdup(r_inputs->value);
     399    translateChar(tmp,'-','_');
     400    setlocale (LC_ALL, tmp);
     401    free(tmp);
     402    setMapInMaps(m,"main","language",r_inputs->value);
     403  }
     404  else{
     405    setlocale (LC_ALL, "en_US");
     406    setMapInMaps(m,"main","language","en-US");
     407  }
     408  setlocale (LC_NUMERIC, "en_US");
     409  bind_textdomain_codeset("zoo-kernel","UTF-8");
     410  textdomain("zoo-kernel");
     411  bind_textdomain_codeset("zoo-services","UTF-8");
     412  textdomain("zoo-services");
     413
     414
    175415  /**
    176416   * Check for minimum inputs
     
    178418  r_inputs=getMap(request_inputs,"Request");
    179419  if(request_inputs==NULL || r_inputs==NULL){
    180     errorException(m, "Parameter <request> was not specified","MissingParameterValue");
     420    errorException(m, _("Parameter <request> was not specified"),"MissingParameterValue");
    181421    freeMaps(&m);
    182422    free(m);
     
    188428       && strncasecmp(r_inputs->value,"DescribeProcess",15)!=0
    189429       && strncasecmp(r_inputs->value,"Execute",7)!=0){
    190       errorException(m, "Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute.", "InvalidParameterValue");
     430      errorException(m, _("Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute."), "InvalidParameterValue");
    191431      freeMaps(&m);
    192432      free(m);
     
    198438  r_inputs=getMap(request_inputs,"Service");
    199439  if(r_inputs==NULLMAP){
    200     errorException(m, "Parameter <service> was not specified","MissingParameterValue");
     440    errorException(m, _("Parameter <service> was not specified"),"MissingParameterValue");
    201441    freeMaps(&m);
    202442    free(m);
     
    207447    r_inputs=getMap(request_inputs,"Version");
    208448    if(r_inputs==NULL){
    209       errorException(m, "Parameter <version> was not specified","MissingParameterValue");
     449      errorException(m, _("Parameter <version> was not specified"),"MissingParameterValue");
    210450      freeMaps(&m);
    211451      free(m);
     
    254494    DIR *dirp = opendir(conf_dir);
    255495    if(dirp==NULL){
    256       return errorException(m, "The specified path doesn't exist.","InvalidParameterValue");
     496      return errorException(m, _("The specified path doesn't exist."),"InvalidParameterValue");
    257497    }
    258498    xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
     
    277517        s1=(service*)calloc(1,SERVICE_SIZE);
    278518        if(s1 == NULL){
    279           return errorException(m, "Unable to allocate memory.","InternalError");
     519          return errorException(m, _("Unable to allocate memory."),"InternalError");
    280520        }
    281521#ifdef DEBUG
     
    308548    if(r_inputs==NULL
    309549       || strlen(r_inputs->name)==0 || strlen(r_inputs->value)==0){
    310       errorException(m, "Mandatory <identifier> was not specified","MissingParameterValue");
     550      errorException(m, _("Mandatory <identifier> was not specified"),"MissingParameterValue");
    311551      freeMaps(&m);
    312552      free(m);
     
    319559    DIR *dirp = opendir(conf_dir);
    320560    if(dirp==NULL){
    321       errorException(m, "The specified path path doesn't exist.","InvalidParameterValue");
     561      errorException(m, _("The specified path path doesn't exist."),"InvalidParameterValue");
    322562      freeMaps(&m);
    323563      free(m);
     
    364604            s1=(service*)calloc(1,SERVICE_SIZE);
    365605            if(s1 == NULL){
    366               return errorException(m, "Unable to allocate memory.","InternalError");
     606              return errorException(m, _("Unable to allocate memory."),"InternalError");
    367607            }
    368608#ifdef DEBUG
     
    399639    else
    400640      if(strncasecmp(REQUEST,"Execute",strlen(REQUEST))!=0){
    401         errorException(m, "Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute.", "InvalidParameterValue");
     641        errorException(m, _("Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute."), "InvalidParameterValue");
    402642#ifdef DEBUG
    403643        fprintf(stderr,"No request found %s",REQUEST);
     
    417657    free(REQUEST);
    418658    free(SERVICE_URL);
    419     return errorException(m, "Unable to allocate memory.","InternalError");
     659    return errorException(m, _("Unable to allocate memory."),"InternalError");
    420660  }
    421661  r_inputs=getMap(request_inputs,"MetaPath");
     
    438678  if(t<0){
    439679    char tmpMsg[2048+strlen(r_inputs->value)];
    440     sprintf(tmpMsg,"The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request.",r_inputs->value);
     680    sprintf(tmpMsg,_("The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),r_inputs->value);
    441681    errorException(m, tmpMsg, "InvalidParameterValue");
    442682    freeService(&s1);
     
    516756      char** outputs_as_text=(char**)calloc(128,sizeof(char*));
    517757      if(outputs_as_text == NULL) {
    518         return errorException(m, "Unable to allocate memory", "InternalError");
     758        return errorException(m, _("Unable to allocate memory"), "InternalError");
    519759      }
    520760      i=0;
     
    527767        outputs_as_text[i]=(char*)calloc(strlen(pToken)+1,sizeof(char));
    528768        if(outputs_as_text[i] == NULL) {
    529           return errorException(m, "Unable to allocate memory", "InternalError");
     769          return errorException(m, _("Unable to allocate memory"), "InternalError");
    530770        }
    531771        snprintf(outputs_as_text[i],strlen(pToken)+1,"%s",pToken);
     
    544784              tmp_output=(maps*)calloc(1,MAPS_SIZE);
    545785              if(tmp_output == NULL){
    546                 return errorException(m, "Unable to allocate memory.", "InternalError");
     786                return errorException(m, _("Unable to allocate memory."), "InternalError");
    547787              }
    548788              tmp_output->name=strdup(tmpc);
     
    603843      snprintf(cursor_input,40960,"%s",r_inputs->value);
    604844    else{
    605       errorException(m, "Parameter <DataInputs> was not specified","MissingParameterValue");
     845      errorException(m, _("Parameter <DataInputs> was not specified"),"MissingParameterValue");
    606846      freeMaps(&m);
    607847      free(m);
     
    620860    char** inputs_as_text=(char**)calloc(100,sizeof(char*));
    621861    if(inputs_as_text == NULL){
    622       return errorException(m, "Unable to allocate memory.", "InternalError");
     862      return errorException(m, _("Unable to allocate memory."), "InternalError");
    623863    }
    624864    i=0;
     
    634874      snprintf(inputs_as_text[i],strlen(pToken)+1,"%s",pToken);
    635875      if(inputs_as_text[i] == NULL){
    636         return errorException(m, "Unable to allocate memory.", "InternalError");
     876        return errorException(m, _("Unable to allocate memory."), "InternalError");
    637877      }
    638878      pToken = strtok(NULL,";");
     
    661901          tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    662902          if(tmpmaps == NULL){
    663             return errorException(m, "Unable to allocate memory.", "InternalError");
     903            return errorException(m, _("Unable to allocate memory."), "InternalError");
    664904          }
    665905          tmpmaps->name=strdup(tmpn);
     
    702942                char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
    703943                if(tmpContent == NULL){
    704                   return errorException(m, "Unable to allocate memory.", "InternalError");
     944                  return errorException(m, _("Unable to allocate memory."), "InternalError");
    705945                }
    706946                size_t dwRead;
     
    7851025              tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    7861026              if(tmpmaps == NULL){
    787                 return errorException(m, "Unable to allocate memory.", "InternalError");
     1027                return errorException(m, _("Unable to allocate memory."), "InternalError");
    7881028              }
    7891029              tmpmaps->name=strdup((char*)val);
     
    8031043              tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    8041044              if(tmpmaps == NULL){
    805                 return errorException(m, "Unable to allocate memory.", "InternalError");
     1045                return errorException(m, _("Unable to allocate memory."), "InternalError");
    8061046              }
    8071047              tmpmaps->name="missingIndetifier";
     
    8611101                      (char*)calloc((res.nDataLen+1),sizeof(char));
    8621102                    if(tmpContent == NULL){
    863                       return errorException(m, "Unable to allocate memory.", "InternalError");
     1103                      return errorException(m, _("Unable to allocate memory."), "InternalError");
    8641104                    }
    8651105                    size_t dwRead;
     
    9021142                    has=(char*)calloc((3+strlen((char*)val)+strlen(key)),sizeof(char));
    9031143                    if(has == NULL){
    904                       return errorException(m, "Unable to allocate memory.", "InternalError");
     1144                      return errorException(m, _("Unable to allocate memory."), "InternalError");
    9051145                    }
    9061146                    snprintf(has,(3+strlen((char*)val)+strlen(key)),"%s: %s",key,(char*)val);
     
    9491189                    char* tmpContent = (char*)calloc((res.nDataLen+1),sizeof(char));
    9501190                    if(tmpContent == NULL){
    951                       return errorException(m, "Unable to allocate memory.", "InternalError");
     1191                      return errorException(m, _("Unable to allocate memory."), "InternalError");
    9521192                    }
    9531193                    size_t dwRead;
     
    9841224                      (char*)calloc((res1.nDataLen+1),sizeof(char));
    9851225                    if(tmp == NULL){
    986                       return errorException(m, "Unable to allocate memory.", "InternalError");
     1226                      return errorException(m, _("Unable to allocate memory."), "InternalError");
    9871227                    }
    9881228                    size_t bRead;
     
    10021242                      char* tmpContent = (char*)calloc((res.nDataLen+1),sizeof(char));
    10031243                      if(tmpContent == NULL){
    1004                         return errorException(m, "Unable to allocate memory.", "InternalError");
     1244                        return errorException(m, _("Unable to allocate memory."), "InternalError");
    10051245                      }
    10061246                      size_t dwRead;
     
    11431383          tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    11441384          if(tmpmaps == NULL){
    1145             return errorException(m, "Unable to allocate memory.", "InternalError");
     1385            return errorException(m, _("Unable to allocate memory."), "InternalError");
    11461386          }
    11471387          tmpmaps->name="unknownIdentifier";
     
    12151455                  tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    12161456                  if(tmpmaps == NULL){
    1217                     return errorException(m, "Unable to allocate memory.", "InternalError");
     1457                    return errorException(m, _("Unable to allocate memory."), "InternalError");
    12181458                  }
    12191459                  tmpmaps->name=strdup((char*)val);
     
    12351475                  tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    12361476                  if(tmpmaps == NULL){
    1237                     return errorException(m, "Unable to allocate memory.", "InternalError");
     1477                    return errorException(m, _("Unable to allocate memory."), "InternalError");
    12381478                  }
    12391479                  tmpmaps->name="missingIndetifier";
     
    12951535            tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    12961536            if(tmpmaps == NULL){
    1297               return errorException(m, "Unable to allocate memory.", "InternalError");
     1537              return errorException(m, _("Unable to allocate memory."), "InternalError");
    12981538            }
    12991539            tmpmaps->name="unknownIdentifier";
     
    13211561            tmpmaps=(maps*)calloc(1,MAPS_SIZE);
    13221562            if(tmpmaps == NULL){
    1323               return errorException(m, "Unable to allocate memory.", "InternalError");
     1563              return errorException(m, _("Unable to allocate memory."), "InternalError");
    13241564            }
    13251565            tmpmaps->name=strdup((char*)val);
     
    13631603  if(strcmp(dfv,"")!=0){
    13641604    char tmps[1024];
    1365     snprintf(tmps,1024,"The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file.",dfv);
     1605    snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv);
    13661606    map* tmpe=createMap("text",tmps);
    13671607    addToMap(tmpe,"code","MissingParameterValue");
     
    14581698      r_inputs=NULL;
    14591699  if(r_inputs==NULLMAP){
    1460     /**
    1461      * Extract serviceType to know what kind of service shoudl be loaded
    1462      */
    1463     r_inputs=NULL;
    1464     r_inputs=getMap(s1->content,"serviceType");
    1465 #ifdef DEBUG
    1466     fprintf(stderr,"LOAD A %s SERVICE PROVIDER IN NORMAL MODE \n",r_inputs->value);
    1467     fflush(stderr);
    1468 #endif
    1469     if(strncasecmp(r_inputs->value,"C",1)==0){
    1470       r_inputs=getMap(request_inputs,"metapath");
    1471       if(r_inputs!=NULL)
    1472         sprintf(tmps1,"%s/%s",ntmp,r_inputs->value);
    1473       else
    1474         sprintf(tmps1,"%s/",ntmp);
    1475       char *altPath=strdup(tmps1);
    1476       r_inputs=getMap(s1->content,"ServiceProvider");
    1477       sprintf(tmps1,"%s/%s",altPath,r_inputs->value);
    1478       free(altPath);
    1479 #ifdef DEBUG
    1480       fprintf(stderr,"Trying to load %s\n",tmps1);
    1481 #endif
    1482 #ifdef WIN32
    1483       HINSTANCE so = LoadLibraryEx(tmps1,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
    1484 #else
    1485       void* so = dlopen(tmps1, RTLD_LAZY);
    1486 #endif
    1487 #ifdef DEBUG
    1488 #ifdef WIN32
    1489       DWORD errstr;
    1490       errstr = GetLastError();
    1491       fprintf(stderr,"%s loaded (%d) \n",tmps1,errstr);
    1492 #else
    1493       char *errstr;
    1494       errstr = dlerror();
    1495 #endif
    1496 #endif
    1497 
    1498       if( so != NULL ) {
    1499 #ifdef DEBUG
    1500         fprintf(stderr,"Library loaded %s \n",errstr);
    1501         fprintf(stderr,"Service Shared Object = %s\n",r_inputs->value);
    1502 #endif
    1503         r_inputs=getMap(s1->content,"serviceType");
    1504 #ifdef DEBUG
    1505         dumpMap(r_inputs);
    1506         fprintf(stderr,"%s\n",r_inputs->value);
    1507         fflush(stderr);
    1508 #endif
    1509         if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){
    1510 #ifdef WIN32
    1511           //Strange return value needed here !
    1512           return 1;
    1513 #endif
    1514           r_inputs=getMap(request_inputs,"Identifier");
    1515           char fname[1024];
    1516           sprintf(fname,"%s_",r_inputs->value);
    1517 #ifdef DEBUG
    1518           fprintf(stderr,"Try to load function %s\n",fname);
    1519 #endif
    1520 #ifdef WIN32
    1521           typedef int (CALLBACK* execute_t)(char***,char***,char***);
    1522           execute_t execute=(execute_t)GetProcAddress(so,fname);
    1523 #else
    1524           typedef int (*execute_t)(char***,char***,char***);
    1525           execute_t execute=(execute_t)dlsym(so,fname);
    1526 #endif
    1527 #ifdef DEBUG
    1528 #ifdef WIN32
    1529           errstr = GetLastError();
    1530 #else
    1531           errstr = dlerror();
    1532 #endif
    1533           fprintf(stderr,"Function loaded %s\n",errstr);
    1534 #endif 
    1535 
    1536           char main_conf[10][30][1024];
    1537           char inputs[10][30][1024];
    1538           char outputs[10][30][1024];
    1539           for(int i=0;i<10;i++){
    1540             for(int j=0;j<30;j++){
    1541               memset(main_conf[i][j],0,1024);
    1542               memset(inputs[i][j],0,1024);
    1543               memset(outputs[i][j],0,1024);
    1544             }
    1545           }
    1546           mapsToCharXXX(m,(char***)main_conf);
    1547           mapsToCharXXX(request_input_real_format,(char***)inputs);
    1548           mapsToCharXXX(request_output_real_format,(char***)outputs);
    1549           eres=execute((char***)&main_conf[0],(char***)&inputs[0],(char***)&outputs[0]);
    1550 #ifdef DEBUG
    1551           fprintf(stderr,"Function run successfully \n");
    1552 #endif
    1553           charxxxToMaps((char***)&outputs[0],&request_output_real_format);
    1554         }else{
    1555 #ifdef DEBUG
    1556 #ifdef WIN32
    1557           errstr = GetLastError();
    1558           fprintf(stderr,"Function %s failed to load because of %d\n",r_inputs->value,errstr);
    1559 #endif
    1560 #endif
    1561           r_inputs=getMap(request_inputs,"Identifier");
    1562 #ifdef DEBUG
    1563           fprintf(stderr,"Try to load function %s\n",r_inputs->value);
    1564 #endif
    1565           typedef int (*execute_t)(maps**,maps**,maps**);
    1566 #ifdef WIN32
    1567           execute_t execute=(execute_t)GetProcAddress(so,r_inputs->value);
    1568 #ifdef DEBUG
    1569           errstr = GetLastError();
    1570           fprintf(stderr,"Function %s failed to load because of %d\n",r_inputs->value,errstr);
    1571 #endif
    1572 #else
    1573           execute_t execute=(execute_t)dlsym(so,r_inputs->value);
    1574 #endif
    1575 
    1576 #ifdef DEBUG
    1577 #ifdef WIN32
    1578           errstr = GetLastError();
    1579 #else
    1580           errstr = dlerror();
    1581 #endif
    1582           fprintf(stderr,"Function loaded %s\n",errstr);
    1583 #endif 
    1584 
    1585 #ifdef DEBUG
    1586           fprintf(stderr,"Now run the function \n");
    1587           fflush(stderr);
    1588 #endif
    1589           eres=execute(&m,&request_input_real_format,&request_output_real_format);
    1590 #ifdef DEBUG
    1591           fprintf(stderr,"Function loaded and returned %d\n",eres);
    1592           fflush(stderr);
    1593 #endif
    1594         }
    1595         dlclose(so);
    1596       } else {
    1597         /**
    1598          * Unable to load the specified shared library
    1599          */
    1600         char tmps[1024];
    1601 #ifdef WIN32
    1602         DWORD errstr = GetLastError();
    1603 #else
    1604         char* errstr = dlerror();
    1605 #endif
    1606         sprintf(tmps,"C Library can't be loaded %s \n",errstr);
    1607         map* tmps1=createMap("text",tmps);
    1608         printExceptionReportResponse(m,tmps1);
    1609         exit(1);
    1610       }
    1611     }
    1612     else
    1613 #ifdef USE_PYTHON
    1614       if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
    1615         eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1616       }
    1617       else
    1618 #endif
    1619        
    1620 #ifdef USE_JAVA
    1621         if(strncasecmp(r_inputs->value,"JAVA",4)==0){
    1622           eres=zoo_java_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1623         }
    1624         else
    1625 #endif
    1626 
    1627 #ifdef USE_PHP
    1628           if(strncasecmp(r_inputs->value,"PHP",3)==0){
    1629             eres=zoo_php_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1630           }
    1631           else
    1632 #endif
    1633            
    1634            
    1635 #ifdef USE_PERL
    1636           if(strncasecmp(r_inputs->value,"PERL",4)==0){
    1637             eres=zoo_perl_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1638           }
    1639           else
    1640 #endif
    1641 
    1642 #ifdef USE_JS
    1643             if(strncasecmp(r_inputs->value,"JS",2)==0){
    1644               eres=zoo_js_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1645             }
    1646             else
    1647 #endif
    1648               {
    1649                 char tmpv[1024];
    1650                 sprintf(tmpv,"Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n",r_inputs->value);
    1651                 map* tmps=createMap("text",tmpv);
    1652                 printExceptionReportResponse(m,tmps);
    1653                 return(-1);
    1654               }
    1655   }
     1700    loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
     1701  }
    16561702  else{
    1657 
    16581703    pid_t   pid;
    16591704#ifdef DEBUG
     
    16961741      free(fbkp);
    16971742      free(flog);
    1698       if(setsid()<0)
    1699         return errorException(m, "Unable to run the child process properly", "InternalError");
    17001743      /**
    17011744       * set status to SERVICE_STARTED and flush stdout to ensure full
     
    17111754      fflush(stdout);
    17121755      rewind(stdout);
    1713       /**
    1714        * Extract serviceType to know what kind of service shoudl be loaded
    1715        */
    1716       r_inputs=NULL;
    1717       r_inputs=getMap(s1->content,"serviceType");
    1718 #ifdef DEBUG
    1719       fprintf(stderr,"LOAD A %s SERVICE PROVIDER IN BACKGROUND MODE \n",r_inputs->value);
    1720 #endif
    1721 
    1722       if(strncasecmp(r_inputs->value,"C",1)==0){
    1723 
    1724         r_inputs=getMap(request_inputs,"metapath");
    1725         if(r_inputs!=NULL){
    1726           sprintf(tmps1,"%s/%s",ntmp,r_inputs->value);
    1727           r_inputs=getMap(s1->content,"ServiceProvider");
    1728           if(r_inputs!=NULL)
    1729             sprintf(tmps1,"%s/%s",strdup(tmps1),r_inputs->value);
    1730         }else{
    1731           sprintf(tmps1,"%s/",ntmp);
    1732         }
    1733          
    1734  
    1735 #ifdef DEBUG
    1736         fprintf(stderr,"Trying to load %s\n",tmps1);
    1737 #endif
    1738 #ifdef WIN32
    1739         HINSTANCE so = LoadLibraryEx(tmps1,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
    1740 #else
    1741         void* so = dlopen(tmps1, RTLD_LAZY);
    1742 #endif
    1743 #ifdef WIN32
    1744         DWORD errstr;
    1745         errstr = GetLastError();
    1746 #else
    1747         char *errstr;
    1748         errstr = dlerror();
    1749 #endif
    1750         if( so != NULL ) {
    1751           r_inputs=getMap(s1->content,"serviceType");
    1752 #ifdef DEBUG
    1753           fprintf(stderr,"r_inputs->value = %s\n",r_inputs->value);
    1754 #endif
    1755           if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){
    1756             r_inputs=getMap(request_inputs,"Identifier");
    1757 #ifdef DEBUG
    1758             fprintf(stderr,"Try to load function %s\n",r_inputs->value);
    1759 #endif
    1760             typedef int (*execute_t)(char***,char***,char***);
    1761             char fname[1024];
    1762             sprintf(fname,"%s_",r_inputs->value);
    1763 #ifdef DEBUG
    1764             fprintf(stderr,"Try to load function %s\n",fname);
    1765 #endif
    1766 #ifdef WIN32
    1767             execute_t execute=(execute_t)GetProcAddress(so,fname);
    1768 #else
    1769             execute_t execute=(execute_t)dlsym(so,fname);
    1770 #endif
    1771 #ifdef DEBUG
    1772 #ifdef WIN32
    1773             errstr = GetLastError();
    1774 #else
    1775             errstr = dlerror();
    1776 #endif
    1777 #endif 
    1778             char main_conf[10][10][1024];
    1779             char inputs[10][10][1024];
    1780             char outputs[10][10][1024];
    1781             for(int i=0;i<10;i++){
    1782               for(int j=0;j<10;j++){
    1783                 memset(main_conf[i][j],0,1024);
    1784                 memset(inputs[i][j],0,1024);
    1785                 memset(outputs[i][j],0,1024);
    1786               }
    1787             }
    1788             mapsToCharXXX(m,(char***)main_conf);
    1789             mapsToCharXXX(request_input_real_format,(char***)inputs);
    1790             //mapsToCharXXX(request_output_real_format,(char***)outputs);
    1791             eres=execute((char***)&main_conf[0],(char***)&inputs[0],(char***)&outputs[0]);
    1792             charxxxToMaps((char***)&outputs[0],&request_output_real_format);
    1793 
    1794           }else{
    1795 
    1796             typedef int (*execute_t)(maps**,maps**,maps**);
    1797 #ifdef DEBUG
    1798             fprintf(stderr,"Library loaded %s \n",errstr);
    1799 #endif
    1800             r_inputs=getMap(request_inputs,"Identifier");
    1801 #ifdef DEBUG
    1802             fprintf(stderr,"Try to load function %s\n",r_inputs->value);
    1803 #endif
    1804 #ifdef WIN32
    1805             execute_t execute=(execute_t)GetProcAddress(so,r_inputs->value);
    1806 #else
    1807             execute_t execute=(execute_t)dlsym(so,r_inputs->value);
    1808 #endif
    1809 #ifdef DEBUG
    1810 #ifdef WIN32
    1811             errstr = GetLastError();
    1812 #else
    1813             errstr = dlerror();
    1814 #endif
    1815             fprintf(stderr,"Function loaded %s\n",errstr);
    1816 #endif 
    1817             /**
    1818              * set the status code value returned by the service function itself
    1819              */
    1820             eres=execute(&m,&request_input_real_format,&request_output_real_format);
    1821           }
    1822           dlclose(so);
    1823         } else {
    1824           /**
    1825            * Unable to load the requested C Library
    1826            */
    1827           char tmps2[1024];
    1828           sprintf(tmps1,"C Library can't be loaded %s \n",errstr);
    1829           map* tmps=createMap("text",tmps1);
    1830           printExceptionReportResponse(m,tmps);
    1831           freeMap(&tmps);
    1832           free(tmps);
    1833           exit(1);
    1834         }
    1835       }
    1836       else
    1837 #ifdef USE_PYTHON
    1838         if(strncasecmp(r_inputs->value,"PYTHON",6)==0)
    1839           eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1840         else
    1841 #endif
    1842 #ifdef USE_JAVA
    1843           if(strncasecmp(r_inputs->value,"JAVA",4)==0){
    1844             eres=zoo_java_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1845             }
    1846           else
    1847 #endif
    1848            
    1849 #ifdef USE_PHP
    1850             if(strncasecmp(r_inputs->value,"PHP",3)==0){
    1851               eres=zoo_php_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1852             }
    1853             else
    1854 #endif
    1855              
    1856 #ifdef USE_PERL
    1857               if(strncasecmp(r_inputs->value,"PERL",4)==0){
    1858                 eres=zoo_perl_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1859               }
    1860               else
    1861 #endif
    1862 #ifdef USE_JS
    1863                 if(strncasecmp(r_inputs->value,"JS",2)==0){
    1864                   eres=zoo_js_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    1865                 }
    1866                 else
    1867 #endif
    1868                   {
    1869                     char tmpv[1024];
    1870                     sprintf(tmpv,"Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n",r_inputs->value);
    1871                     map* tmps=createMap("text",tmpv);
    1872                     printExceptionReportResponse(m,tmps);
    1873                     return -1;
    1874                   }
    1875      
    1876  
     1756
     1757      loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
     1758
    18771759    } else {
    18781760      /**
     
    18801762       * error response here !!!
    18811763       */
     1764      eres=-1;
     1765      errorException(m, _("Unable to run the child process properly"), "InternalError");
    18821766    }
    18831767       
  • trunk/zoo-services/ogr/base-vect-ops/service.c

    r32 r34  
    2323 */
    2424
     25#include <libintl.h>
     26#include <locale.h>
     27#define _(String) dgettext ("zoo-services",String)
     28
    2529#include "cpl_conv.h"
    2630#include "ogr_api.h"
     
    2832#include "geos_c.h"
    2933#include "service.h"
     34
    3035
    3136extern "C" {
     
    479484    }
    480485    if(geometry2==NULL){
    481       setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity2.");
     486      setMapInMaps(conf,"lenv","message",_("Unable to parse input geometry for InputEntity2."));
    482487      fprintf(stderr,"SERVICE FAILED !\n");
    483488      return SERVICE_FAILED;
  • trunk/zoo-services/utils/status/service.c

    r32 r34  
    2222 * THE SOFTWARE.
    2323 */
     24
    2425#include "service.h"
    2526
     
    7576    }else{
    7677      char tmp[1024];
    77       snprintf(tmp,1024,"GetStatus was unable to use the tmpPath value set in main.cfg file as directory %s.",tmpTmap->value);
     78      snprintf(tmp,1024,_ss("GetStatus was unable to use the tmpPath value set in main.cfg file as directory %s."),tmpTmap->value);
    7879      setMapInMaps(conf,"lenv","message",tmp);
    7980      return SERVICE_FAILED;
     
    8182    if(hasFile<0){
    8283      char tmp[1024];
    83       snprintf(tmp,1024,"GetStatus was unable to find any cache file for Service ID %s.",tmpMap->value);
     84      snprintf(tmp,1024,_ss("GetStatus was unable to find any cache file for Service ID %s."),tmpMap->value);
    8485      setMapInMaps(conf,"lenv","message",tmp);
    8586      return SERVICE_FAILED;
     
    107108    else{
    108109      char tmp[1024];
    109       sprintf(tmp,"ZOO GetStatus Service was unable to parse the cache xml file available for the Service ID %s.",tmpMap->value);
     110      sprintf(tmp,_ss("ZOO GetStatus Service was unable to parse the cache xml file available for the Service ID %s."),tmpMap->value);
    110111      setMapInMaps(conf,"lenv","message",tmp);
    111112      return SERVICE_FAILED;
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