/[dgee]/dgee/smgr/execXmlRpc.c
ViewVC logotype

Diff of /dgee/smgr/execXmlRpc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by csmith, Sun Mar 30 12:59:12 2003 UTC revision 1.4 by csmith, Sun Sep 21 10:31:49 2003 UTC
# Line 34  Line 34 
34  #include "dgmxDoc.h"  #include "dgmxDoc.h"
35  #include "xmlRpcDecode.h"  #include "xmlRpcDecode.h"
36  #include "dgmxDecode.h"  #include "dgmxDecode.h"
37    #include "dgreadenv.h"
38  #include "faultXML.h"  #include "faultXML.h"
39    
40    
41    typedef struct {
42            char lang[32];
43            char service[128];
44    } LangService;
45    
46    static const char *getLanguageHandler( const char *lang );
47    
48  /* ------------------------------------------------------------------------- */  /* ------------------------------------------------------------------------- */
49  /* Input:  /* Input:
50   *    DGF_REQ_URI  - Service to call   *    DGF_REQ_URI  - Service to call
# Line 52  execXmlRpcWS( char *svc, GWMessage *reqm Line 61  execXmlRpcWS( char *svc, GWMessage *reqm
61    XMLTree  *classTree = NULL;    XMLTree  *classTree = NULL;
62    XMLTree  *methTree = NULL;    XMLTree  *methTree = NULL;
63    
64      const char  *service = NULL;
65      char  *lang    = NULL;
66    char  *errmsg  = NULL;    char  *errmsg  = NULL;
67    char  *ctype   = NULL;    char  *ctype   = NULL;
68    char  *method  = NULL;    char  *method  = NULL;
# Line 255  execXmlRpcWS( char *svc, GWMessage *reqm Line 266  execXmlRpcWS( char *svc, GWMessage *reqm
266            break;            break;
267          }          }
268        
269      /* TODO Choose VM to call based on 'language' in DGMX definition      /* Choose VM to call based on 'language' in DGMX definition
270           * These come from env entities such as LANG_C#, LANG_PYTHON in the           * These come from env entities such as LANG_C#, LANG_PYTHON in the
271           * dgeeconf.xml file           * dgeeconf.xml file
          *  
          * do gw_getenv( "LANG_C#" ) to get the service to call.  
          *  
272           */           */
273            if( (lang = dgmxGetLanguage( dgmxTree )) == NULL ) {
274          errmsg = "Failed to get language from DGMX";
275              gwusrerr = ERR_INTERNAL_FAILURE;
276              break;
277            }
278    
279        if( (service = getLanguageHandler(lang)) == NULL ) {
280              gw_logf( LOG_ERROR, "Trying to look up handler for language '%s'", lang );
281          errmsg = "Language not found";
282              gwusrerr = ERR_INTERNAL_FAILURE;
283              break;
284            }
285    
286      if( stream &&      if( stream &&
287              gw_svc_forward( "/DGEE/VM/pnetExec", stream, len, 0 ) < 0) {              gw_svc_forward( service, stream, len, 0 ) < 0) {
288            gw_logf( LOG_ERROR, "svc_forward failed with error [%s]",            gw_logf( LOG_ERROR, "svc_forward to '%s' failed with error [%s]",
289                             gw_errorstr(gwerror) );                             service, gw_errorstr(gwerror) );
290            errmsg = "Could not invoke WebService";            errmsg = "Could not invoke WebService handler";
291            gwusrerr = ERR_INTERNAL_FAILURE;            gwusrerr = ERR_INTERNAL_FAILURE;
292      }      }
293          an_error = 0;          an_error = 0;
# Line 304  execXmlRpcWS( char *svc, GWMessage *reqm Line 325  execXmlRpcWS( char *svc, GWMessage *reqm
325  }  }
326    
327  /* ------------------------------------------------------------------------- */  /* ------------------------------------------------------------------------- */
328    
329    static const char *
330    getLanguageHandler( const char *lang )
331    {
332            static LIST *LSList = NULL;
333            LangService *ls     = NULL;
334            char  *svc          = NULL;
335    
336            if( LSList == NULL ) {
337                    xl_List_init( &LSList, sizeof( LangService ) );
338            }
339    
340            if( xl_List_get_first( LSList, (uchar_t**)&ls ) == Success ) {
341              do {
342                    if( strcmp(ls->lang, lang) == 0 ) {
343                            return ls->service;
344                    }
345              } while( xl_List_get_next( LSList, (uchar_t**)&ls ) == Success );
346            }
347    
348            /* If we got here then it is not found....
349             * Do a lookup
350             */
351        svc = dgee_read_language_service( lang );
352            if( svc == NULL ) return NULL;
353    
354            if( xl_List_insert_space( LSList, ListEnd ) == Failure ) {
355              gw_logf( LOG_SYSERR, "Could not add language service to cache" );
356              return NULL;
357            }
358    
359            ls = (LangService*)xl_List_get_current_data( LSList );
360    
361            strncpy( ls->lang,    lang, sizeof(ls->lang)    - 1 );
362            strncpy( ls->service, svc,  sizeof(ls->service) - 1 );
363    
364            return ls->service;
365    }
366    
367    /* ------------------------------------------------------------------------- */
368  /* end */  /* end */

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26