-<?xml version='1.0'?>
+<?xml version="1.0"?>
+<!--
+Example OpenSRF bootstrap configuration file for Evergreen
+-->
<config>
+ <!-- Options for <loglevel>: 0 None, 1 Error, 2 Warning, 3 Info, 4 debug -->
+ <opensrf>
+ <routers>
- <!-- Options for <loglevel>: 0 None, 1 Error, 2 Warning, 3 Info, 4 debug -->
-
- <opensrf>
-
- <routers>
- <!-- define the list of routers our services will register with -->
- <router>
- <!-- This is the public router. On this router, we only register applications
- which should be accessible to everyone on the opensrf network -->
- <name>router</name>
- <domain>public.localhost</domain>
- <services>
- <service>opensrf.math</service>
- <service>open-ils.cat</service>
- <service>open-ils.supercat</service>
- <service>open-ils.search</service>
- <service>open-ils.circ</service>
- <service>open-ils.actor</service>
- <service>open-ils.auth</service>
- <service>open-ils.fielder</service>
- <service>open-ils.collections</service>
- <service>open-ils.reporter</service>
- </services>
- </router>
-
- <router>
- <!-- This is the private router. All applications must register with
- this router, so no explicit <services> section is required -->
- <name>router</name>
- <domain>private.localhost</domain>
- </router>
- </routers>
-
- <!-- Our domain should match that of the private router -->
- <domain>private.localhost</domain>
- <username>osrf</username>
- <passwd>osrf</passwd>
- <port>5222</port>
-
- <!-- name of the router used on our private domain.
- this should match one of the <name> of the private router above -->
- <router_name>router</router_name>
-
- <logfile>/openils/var/log/osrfsys.log</logfile>
- <!--
- <logfile>syslog</logfile>
- <syslog>local0</syslog>
- <actlog>local1</actlog>
+ <!-- define the list of routers our services will register with -->
+ <router>
+ <!--
+ This is the public router. On this router, we only register
+ applications which should be accessible to everyone on the OpenSRF
+ network
-->
- <loglevel>3</loglevel>
- <settings_config>/openils/conf/opensrf.xml</settings_config>
- </opensrf>
-
-
- <!-- The section between <gateway>...</gateway> is a standard OpenSRF C stack config file -->
- <gateway>
-
- <client>true</client>
- <router_name>router</router_name>
-
- <!-- The gateway connects to the public domain for security -->
+ <name>router</name>
<domain>public.localhost</domain>
- <!-- this section will be soon deprecated for multi-domain mode... -->
- <services>
- <service>opensrf.math</service>
- <service>opensrf.dbmath</service>
- <service>open-ils.cat</service>
- <service>open-ils.search</service>
- <service>open-ils.circ</service>
- <service>open-ils.actor</service>
- <service>open-ils.auth</service>
- <service>open-ils.collections</service>
- <service>open-ils.reporter</service>
- </services>
-
- <!-- jabber login info -->
- <username>osrf</username>
- <passwd>osrf</passwd>
- <port>5222</port>
- <loglevel>3</loglevel>
- <logfile>/openils/var/log/gateway.log</logfile>
+ <services>
+ <service>opensrf.math</service>
+ <service>open-ils.cat</service>
+ <service>open-ils.supercat</service>
+ <service>open-ils.search</service>
+ <service>open-ils.circ</service>
+ <service>open-ils.actor</service>
+ <service>open-ils.auth</service>
+ <service>open-ils.fielder</service>
+ <service>open-ils.collections</service>
+ <service>open-ils.reporter</service>
+ </services>
+ </router>
+
+ <router>
<!--
- <logfile>syslog</logfile>
- <syslog>local6</syslog>
- <actlog>local1</actlog>
+ This is the private router. All applications must register with
+ this router, so no explicit <services> section is required
-->
- </gateway>
-
- <!-- ======================================================================================== -->
-
- <routers>
- <router> <!-- public router -->
- <trusted_domains>
- <!-- allow private services to register with this router
- and public client to send requests to this router. -->
- <server>private.localhost</server>
- <!-- also allow private clients to send to the router so it can receive error messages -->
- <client>private.localhost</client>
- <client>public.localhost</client>
- </trusted_domains>
- <transport>
- <server>public.localhost</server>
- <port>5222</port>
- <unixpath>/openils/var/sock/unix_sock</unixpath>
- <username>router</username>
- <password>osrf</password>
- <resource>router</resource>
- <connect_timeout>10</connect_timeout>
- <max_reconnect_attempts>5</max_reconnect_attempts>
- </transport>
- <logfile>syslog</logfile>
- <syslog>local2</syslog>
- <loglevel>5</loglevel>
- </router>
- <router> <!-- private router -->
- <trusted_domains>
- <server>private.localhost</server>
- <!-- only clients on the private domain can send requests to this router -->
- <client>private.localhost</client>
- </trusted_domains>
- <transport>
- <server>private.localhost</server>
- <port>5222</port>
- <username>router</username>
- <password>osrf</password>
- <resource>router</resource>
- <connect_timeout>10</connect_timeout>
- <max_reconnect_attempts>5</max_reconnect_attempts>
- </transport>
- <logfile>syslog</logfile>
- <syslog>local2</syslog>
- <loglevel>4</loglevel>
- </router>
+ <name>router</name>
+ <domain>private.localhost</domain>
+ </router>
</routers>
- <!-- ======================================================================================== -->
-
-</config>
-
-
+ <!-- Our domain should match that of the private router -->
+ <domain>private.localhost</domain>
+ <username>osrf</username>
+ <passwd>osrf</passwd>
+ <port>5222</port>
+
+ <!--
+ Name of the router used on our private domain.
+ This should match one of the <name> of the private router above.
+ -->
+ <router_name>router</router_name>
+
+ <logfile>LOCALSTATEDIR/log/osrfsys.log</logfile>
+ <!--
+ <logfile>syslog</logfile>
+ <syslog>local0</syslog>
+ <actlog>local1</actlog>
+ -->
+ <loglevel>3</loglevel>
+ <settings_config>SYSCONFDIR/opensrf.xml</settings_config>
+ </opensrf>
+ <!--
+ The section between <gateway>...</gateway> is a standard OpenSRF C
+ stack configuration file
+ -->
+ <gateway>
+ <client>true</client>
+ <router_name>router</router_name>
+
+ <!-- The gateway connects to the public domain for security -->
+ <domain>public.localhost</domain>
+
+ <!-- This section will be soon deprecated for multi-domain mode... -->
+ <services>
+ <service>opensrf.math</service>
+ <service>opensrf.dbmath</service>
+ <service>open-ils.cat</service>
+ <service>open-ils.search</service>
+ <service>open-ils.circ</service>
+ <service>open-ils.actor</service>
+ <service>open-ils.auth</service>
+ <service>open-ils.collections</service>
+ <service>open-ils.reporter</service>
+ </services>
+
+ <!-- jabber login info -->
+ <username>osrf</username>
+ <passwd>osrf</passwd>
+ <port>5222</port>
+ <loglevel>3</loglevel>
+ <logfile>LOCALSTATEDIR/log/gateway.log</logfile>
+ <!--
+ <logfile>syslog</logfile>
+ <syslog>local6</syslog>
+ <actlog>local1</actlog>
+ -->
+ </gateway>
+ <!-- ======================================================================================== -->
+ <routers>
+ <router>
+ <!-- public router -->
+ <trusted_domains>
+ <!--
+ Allow private services to register with this router
+ and public client to send requests to this router.
+ -->
+ <server>private.localhost</server>
+ <!--
+ Also allow private clients to send to the router so it
+ can receive error messages
+ -->
+ <client>private.localhost</client>
+ <client>public.localhost</client>
+ </trusted_domains>
+ <transport>
+ <server>public.localhost</server>
+ <port>5222</port>
+ <unixpath>LOCALSTATEDIR/sock/unix_sock</unixpath>
+ <username>router</username>
+ <password>osrf</password>
+ <resource>router</resource>
+ <connect_timeout>10</connect_timeout>
+ <max_reconnect_attempts>5</max_reconnect_attempts>
+ </transport>
+ <logfile>LOCALSTATEDIR/log/router-public.log</logfile>
+ <!--
+ <logfile>syslog</logfile>
+ <syslog>local2</syslog>
+ -->
+ <loglevel>3</loglevel>
+ </router>
+ <router>
+ <!-- private router -->
+ <trusted_domains>
+ <server>private.localhost</server>
+ <!--
+ Only clients on the private domain can send requests to this router
+ -->
+ <client>private.localhost</client>
+ </trusted_domains>
+ <transport>
+ <server>private.localhost</server>
+ <port>5222</port>
+ <username>router</username>
+ <password>osrf</password>
+ <resource>router</resource>
+ <connect_timeout>10</connect_timeout>
+ <max_reconnect_attempts>5</max_reconnect_attempts>
+ </transport>
+ <logfile>LOCALSTATEDIR/log/router-private.log</logfile>
+ <!--
+ <logfile>syslog</logfile>
+ <syslog>local2</syslog>
+ -->
+ <loglevel>3</loglevel>
+ </router>
+ </routers>
+ <!-- ======================================================================================== -->
+</config>
if (idlHash) return idlHash;
- char* string_tmp = NULL;
+ char* prop_str = NULL;
idlHash = osrfNewHash();
- osrfHash* usrData = NULL;
+ osrfHash* class_def_hash = NULL;
osrfLogInfo(OSRF_LOG_MARK, "Parsing the IDL XML...");
idlDoc = xmlReadFile( idl_filename, NULL, XML_PARSE_XINCLUDE );
while (kid) {
if (!strcmp( (char*)kid->name, "class" )) {
- usrData = osrfNewHash();
- osrfHashSet( usrData, xmlGetProp(kid, BAD_CAST "id"), "classname");
- osrfHashSet( usrData, xmlGetNsProp(kid, BAD_CAST "fieldmapper", BAD_CAST OBJECT_NS), "fieldmapper");
- osrfHashSet( usrData, xmlGetNsProp(kid, BAD_CAST "readonly", BAD_CAST PERSIST_NS), "readonly");
+ class_def_hash = osrfNewHash();
+ char* current_class_name = (char*) xmlGetProp(kid, BAD_CAST "id");
+
+ osrfHashSet( class_def_hash, current_class_name, "classname" );
+ osrfHashSet( class_def_hash, xmlGetNsProp(kid, BAD_CAST "fieldmapper", BAD_CAST OBJECT_NS), "fieldmapper" );
+ osrfHashSet( class_def_hash, xmlGetNsProp(kid, BAD_CAST "readonly", BAD_CAST PERSIST_NS), "readonly" );
- osrfHashSet( idlHash, usrData, (char*)osrfHashGet(usrData, "classname") );
+ osrfHashSet( idlHash, class_def_hash, current_class_name );
- string_tmp = NULL;
- if ((string_tmp = (char*)xmlGetNsProp(kid, BAD_CAST "tablename", BAD_CAST PERSIST_NS))) {
- osrfLogDebug(OSRF_LOG_MARK, "Using table '%s' for class %s", string_tmp, osrfHashGet(usrData, "classname") );
+ if ((prop_str = (char*)xmlGetNsProp(kid, BAD_CAST "tablename", BAD_CAST PERSIST_NS))) {
+ osrfLogDebug(OSRF_LOG_MARK, "Using table '%s' for class %s", prop_str, current_class_name );
osrfHashSet(
- usrData,
- strdup( string_tmp ),
+ class_def_hash,
+ strdup( prop_str ),
"tablename"
);
}
- string_tmp = NULL;
- if ((string_tmp = (char*)xmlGetNsProp(kid, BAD_CAST "virtual", BAD_CAST PERSIST_NS))) {
+ if ((prop_str = (char*)xmlGetNsProp(kid, BAD_CAST "virtual", BAD_CAST PERSIST_NS))) {
osrfHashSet(
- usrData,
- strdup( string_tmp ),
+ class_def_hash,
+ strdup( prop_str ),
"virtual"
);
}
// Tokenize controller attribute into an osrfStringArray
- string_tmp = (char*) xmlGetProp(kid, BAD_CAST "controller");
- if( string_tmp )
- osrfLogDebug(OSRF_LOG_MARK, "Controller list is %s", string_tmp );
- osrfStringArray* controller = osrfStringArrayTokenize( string_tmp, ' ' );
- osrfHashSet( usrData, controller, "controller");
-
- osrfHash* _tmp;
- osrfHash* links = osrfNewHash();
- osrfHash* fields = osrfNewHash();
+ prop_str = (char*) xmlGetProp(kid, BAD_CAST "controller");
+ if( prop_str )
+ osrfLogDebug(OSRF_LOG_MARK, "Controller list is %s", prop_str );
+ osrfStringArray* controller = osrfStringArrayTokenize( prop_str, ' ' );
+ osrfHashSet( class_def_hash, controller, "controller");
+
+ osrfHash* current_links_hash = osrfNewHash();
+ osrfHash* current_fields_hash = osrfNewHash();
osrfHash* pcrud = osrfNewHash();
- osrfHashSet( usrData, fields, "fields" );
- osrfHashSet( usrData, links, "links" );
+ osrfHashSet( class_def_hash, current_fields_hash, "fields" );
+ osrfHashSet( class_def_hash, current_links_hash, "links" );
xmlNodePtr _cur = kid->children;
if (!strcmp( (char*)_cur->name, "fields" )) {
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetNsProp(_cur, BAD_CAST "primary", BAD_CAST PERSIST_NS)) ) {
+ if( (prop_str = (char*)xmlGetNsProp(_cur, BAD_CAST "primary", BAD_CAST PERSIST_NS)) ) {
osrfHashSet(
- usrData,
- strdup( string_tmp ),
+ class_def_hash,
+ strdup( prop_str ),
"primarykey"
);
}
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetNsProp(_cur, BAD_CAST "sequence", BAD_CAST PERSIST_NS)) ) {
+ if( (prop_str = (char*)xmlGetNsProp(_cur, BAD_CAST "sequence", BAD_CAST PERSIST_NS)) ) {
osrfHashSet(
- usrData,
- strdup( string_tmp ),
+ class_def_hash,
+ strdup( prop_str ),
"sequence"
);
}
continue;
}
- _tmp = osrfNewHash();
+ osrfHash* field_def_hash = osrfNewHash();
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetNsProp(_f, BAD_CAST "array_position", BAD_CAST OBJECT_NS)) ) {
+ if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "array_position", BAD_CAST OBJECT_NS)) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ field_def_hash,
+ strdup( prop_str ),
"array_position"
);
}
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetNsProp(_f, BAD_CAST "i18n", BAD_CAST PERSIST_NS)) ) {
+ if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "i18n", BAD_CAST PERSIST_NS)) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ field_def_hash,
+ strdup( prop_str ),
"i18n"
);
}
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetNsProp(_f, BAD_CAST "virtual", BAD_CAST PERSIST_NS)) ) {
+ if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "virtual", BAD_CAST PERSIST_NS)) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ field_def_hash,
+ strdup( prop_str ),
"virtual"
);
}
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetNsProp(_f, BAD_CAST "primitive", BAD_CAST PERSIST_NS)) ) {
+ if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "primitive", BAD_CAST PERSIST_NS)) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ field_def_hash,
+ strdup( prop_str ),
"primitive"
);
}
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetProp(_f, BAD_CAST "name")) ) {
+ if( (prop_str = (char*)xmlGetProp(_f, BAD_CAST "name")) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ field_def_hash,
+ strdup( prop_str ),
"name"
);
- }
-
- osrfLogDebug(OSRF_LOG_MARK, "Found field %s for class %s", string_tmp, osrfHashGet(usrData, "classname") );
+ osrfLogDebug(OSRF_LOG_MARK,
+ "Found field %s for class %s", prop_str, current_class_name );
+ } else
+ osrfLogDebug(OSRF_LOG_MARK,
+ "Found field with no name for class %s", current_class_name );
osrfHashSet(
- fields,
- _tmp,
- strdup( string_tmp )
+ current_fields_hash,
+ field_def_hash,
+ prop_str
);
_f = _f->next;
}
continue;
}
- _tmp = osrfNewHash();
+ osrfHash* link_def_hash = osrfNewHash();
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetProp(_l, BAD_CAST "reltype")) ) {
+ if( (prop_str = (char*)xmlGetProp(_l, BAD_CAST "reltype")) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ link_def_hash,
+ strdup( prop_str ),
"reltype"
);
- }
- osrfLogDebug(OSRF_LOG_MARK, "Adding link with reltype %s", string_tmp );
+ osrfLogDebug(OSRF_LOG_MARK, "Adding link with reltype %s", prop_str );
+ } else
+ osrfLogDebug(OSRF_LOG_MARK, "Adding link with no reltype" );
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetProp(_l, BAD_CAST "key")) ) {
+ if( (prop_str = (char*)xmlGetProp(_l, BAD_CAST "key")) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ link_def_hash,
+ strdup( prop_str ),
"key"
);
- }
- osrfLogDebug(OSRF_LOG_MARK, "Link fkey is %s", string_tmp );
+ osrfLogDebug(OSRF_LOG_MARK, "Link fkey is %s", prop_str );
+ } else
+ osrfLogDebug(OSRF_LOG_MARK, "Link with no fkey" );
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetProp(_l, BAD_CAST "class")) ) {
+ if( (prop_str = (char*)xmlGetProp(_l, BAD_CAST "class")) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ link_def_hash,
+ strdup( prop_str ),
"class"
);
- }
- osrfLogDebug(OSRF_LOG_MARK, "Link fclass is %s", string_tmp );
+ osrfLogDebug(OSRF_LOG_MARK, "Link fclass is %s", prop_str );
+ } else
+ osrfLogDebug(OSRF_LOG_MARK, "Link with no fclass" );
// Tokenize map attribute into an osrfStringArray
- string_tmp = (char*) xmlGetProp(_l, BAD_CAST "map");
- if( string_tmp )
- osrfLogDebug(OSRF_LOG_MARK, "Link mapping list is %s", string_tmp );
- osrfStringArray* map = osrfStringArrayTokenize( string_tmp, ' ' );
- osrfHashSet( _tmp, map, "map");
-
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetProp(_l, BAD_CAST "field")) ) {
+ prop_str = (char*) xmlGetProp(_l, BAD_CAST "map");
+ if( prop_str )
+ osrfLogDebug(OSRF_LOG_MARK, "Link mapping list is %s", prop_str );
+ osrfStringArray* map = osrfStringArrayTokenize( prop_str, ' ' );
+ osrfHashSet( link_def_hash, map, "map");
+
+ if( (prop_str = (char*)xmlGetProp(_l, BAD_CAST "field")) ) {
osrfHashSet(
- _tmp,
- strdup( string_tmp ),
+ link_def_hash,
+ strdup( prop_str ),
"field"
);
- }
+ osrfLogDebug(OSRF_LOG_MARK, "Link fclass is %s", prop_str );
+ } else
+ osrfLogDebug(OSRF_LOG_MARK, "Link with no fclass" );
osrfHashSet(
- links,
- _tmp,
- strdup( string_tmp )
+ current_links_hash,
+ link_def_hash,
+ prop_str
);
- osrfLogDebug(OSRF_LOG_MARK, "Found link %s for class %s", string_tmp, osrfHashGet(usrData, "classname") );
-
_l = _l->next;
}
}
**** Structure of permacrud in memory ****/
if (!strcmp( (char*)_cur->name, "permacrud" )) {
- osrfHashSet( usrData, pcrud, "permacrud" );
+ osrfHashSet( class_def_hash, pcrud, "permacrud" );
xmlNodePtr _l = _cur->children;
while(_l) {
xmlNodePtr _a = _l->children;
while(_a) {
+ const char* action_name = (const char*) _a->name;
if (
- strcmp( (char*)_a->name, "create" ) &&
- strcmp( (char*)_a->name, "retrieve" ) &&
- strcmp( (char*)_a->name, "update" ) &&
- strcmp( (char*)_a->name, "delete" )
+ strcmp( action_name, "create" ) &&
+ strcmp( action_name, "retrieve" ) &&
+ strcmp( action_name, "update" ) &&
+ strcmp( action_name, "delete" )
) {
_a = _a->next;
continue;
}
- string_tmp = (char*) _a->name;
- osrfLogDebug(OSRF_LOG_MARK, "Found Permacrud action %s for class %s", string_tmp, osrfHashGet(usrData, "classname") );
+ osrfLogDebug(OSRF_LOG_MARK, "Found Permacrud action %s for class %s",
+ action_name, current_class_name );
- _tmp = osrfNewHash();
- osrfHashSet( pcrud, _tmp, string_tmp );
+ osrfHash* action_def_hash = osrfNewHash();
+ osrfHashSet( pcrud, action_def_hash, action_name );
// Tokenize permission attribute into an osrfStringArray
- string_tmp = (char*) xmlGetProp(_a, BAD_CAST "permission");
- if( string_tmp )
+ prop_str = (char*) xmlGetProp(_a, BAD_CAST "permission");
+ if( prop_str )
osrfLogDebug(OSRF_LOG_MARK,
- "Permacrud permission list is %s", string_tmp );
- osrfStringArray* map = osrfStringArrayTokenize( string_tmp, ' ' );
- osrfHashSet( _tmp, map, "permission");
+ "Permacrud permission list is %s", prop_str );
+ osrfStringArray* map = osrfStringArrayTokenize( prop_str, ' ' );
+ osrfHashSet( action_def_hash, map, "permission");
- osrfHashSet( _tmp, (char*)xmlGetNoNsProp(_a, BAD_CAST "global_required"), "global_required");
+ osrfHashSet( action_def_hash,
+ (char*)xmlGetNoNsProp(_a, BAD_CAST "global_required"), "global_required");
// Tokenize context_field attribute into an osrfStringArray
- string_tmp = (char*) xmlGetProp(_a, BAD_CAST "context_field");
- if( string_tmp )
+ prop_str = (char*) xmlGetProp(_a, BAD_CAST "context_field");
+ if( prop_str )
osrfLogDebug(OSRF_LOG_MARK,
- "Permacrud context_field list is %s", string_tmp );
- map = osrfStringArrayTokenize( string_tmp, ' ' );
- osrfHashSet( _tmp, map, "local_context");
+ "Permacrud context_field list is %s", prop_str );
+ map = osrfStringArrayTokenize( prop_str, ' ' );
+ osrfHashSet( action_def_hash, map, "local_context");
osrfHash* foreign_context = osrfNewHash();
- osrfHashSet( _tmp, foreign_context, "foreign_context");
+ osrfHashSet( action_def_hash, foreign_context, "foreign_context");
xmlNodePtr _f = _a->children;
continue;
}
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlGetNoNsProp(_f, BAD_CAST "link")) ) {
- osrfLogDebug(OSRF_LOG_MARK, "Permacrud context link definition is %s", string_tmp );
+ if( (prop_str = (char*)xmlGetNoNsProp(_f, BAD_CAST "link")) ) {
+ osrfLogDebug(OSRF_LOG_MARK,
+ "Permacrud context link definition is %s", prop_str );
- osrfHash* _flink = oilsIDLFindPath("/%s/links/%s", osrfHashGet(usrData, "classname"), string_tmp);
-
- osrfHashSet( foreign_context, osrfNewHash(), osrfHashGet(_flink, "class") );
- osrfHash* _tmp_fcontext = osrfHashGet( foreign_context, osrfHashGet(_flink, "class") );
+ osrfHash* _tmp_fcontext = osrfNewHash();
+ // Store pointers to elements already stored
+ // from the <link> aggregate
+ osrfHash* _flink = osrfHashGet( current_links_hash, prop_str );
osrfHashSet( _tmp_fcontext, osrfHashGet(_flink, "field"), "fkey" );
osrfHashSet( _tmp_fcontext, osrfHashGet(_flink, "key"), "field" );
// Tokenize field attribute into an osrfStringArray
- string_tmp = (char*) xmlGetProp(_f, BAD_CAST "field");
- if( string_tmp )
+ const char * field_list = (char*) xmlGetProp(_f, BAD_CAST "field");
+ if( field_list )
osrfLogDebug(OSRF_LOG_MARK,
- "Permacrud foreign context field list is %s", string_tmp );
- map = osrfStringArrayTokenize( string_tmp, ' ' );
+ "Permacrud foreign context field list is %s", field_list );
+ map = osrfStringArrayTokenize( field_list, ' ' );
osrfHashSet( _tmp_fcontext, map, "context");
+ // Insert the new hash into a hash attached to the parent node
+ osrfHashSet( foreign_context, _tmp_fcontext, osrfHashGet( _flink, "class" ) );
+
} else {
- if( (string_tmp = (char*)xmlGetNoNsProp(_f, BAD_CAST "field") )) {
- char* map_list = strdup( string_tmp );
- osrfLogDebug(OSRF_LOG_MARK, "Permacrud foreign context field list is %s", string_tmp );
+ if( (prop_str = (char*)xmlGetNoNsProp(_f, BAD_CAST "field") )) {
+ char* map_list = strdup( prop_str );
+ osrfLogDebug(OSRF_LOG_MARK,
+ "Permacrud foreign context field list is %s", prop_str );
if (strlen( map_list ) > 0) {
char* st_tmp = NULL;
char* _map_class = strtok_r(map_list, " ", &st_tmp);
- osrfStringArrayAdd(osrfHashGet( _tmp, "local_context"), _map_class);
+ osrfStringArrayAdd(
+ osrfHashGet( action_def_hash, "local_context"), _map_class);
while ((_map_class = strtok_r(NULL, " ", &st_tmp))) {
- osrfStringArrayAdd(osrfHashGet( _tmp, "local_context"), _map_class);
+ osrfStringArrayAdd(
+ osrfHashGet( action_def_hash, "local_context"), _map_class);
}
}
free(map_list);
}
if (!strcmp( (char*)_cur->name, "source_definition" )) {
- string_tmp = NULL;
- if( (string_tmp = (char*)xmlNodeGetContent(_cur)) ) {
- osrfLogDebug(OSRF_LOG_MARK, "Using source definition '%s' for class %s", string_tmp, osrfHashGet(usrData, "classname") );
+ const char* content_str;
+ if( (content_str = (char*)xmlNodeGetContent(_cur)) ) {
+ osrfLogDebug(OSRF_LOG_MARK, "Using source definition '%s' for class %s",
+ content_str, current_class_name );
osrfHashSet(
- usrData,
- strdup( string_tmp ),
+ class_def_hash,
+ strdup( content_str ),
"source_definition"
);
}
return obj;
}
+static osrfHash* findClassDef( const char* classname ) {
+ if( !classname || !idlHash )
+ return NULL;
+ else
+ return osrfHashGet( idlHash, classname );
+}
+
int oilsIDL_classIsFieldmapper ( const char* classname ) {
- if (!classname) return 0;
- if(oilsIDLFindPath( "/%s", classname )) return 1;
- return 0;
+ if( findClassDef( classname ) )
+ return 1;
+ else
+ return 0;
}
int oilsIDL_ntop (const char* classname, const char* fieldname) {
- osrfHash* _pos = NULL;
+ osrfHash* class_def_hash = findClassDef( classname );
+ if( !class_def_hash )
+ return -1; // No such class
+
+ osrfHash* fields_hash = osrfHashGet( class_def_hash, "fields" );
+ if( !fields_hash )
+ return -1; // No list of fields fo the class
+
+ osrfHash* field_def_hash = osrfHashGet( fields_hash, fieldname );
+ if( !field_def_hash )
+ return -1; // No such field
- if (!oilsIDL_classIsFieldmapper(classname)) return -1;
- _pos = oilsIDLFindPath( "/%s/fields/%s", classname, fieldname );
- if (_pos) return atoi( osrfHashGet(_pos, "array_position") );
- return -1;
+ const char* pos_attr = osrfHashGet( field_def_hash, "array_position" );
+ if( !pos_attr )
+ return -1; // No array_position attribute
+
+ return atoi( pos_attr ); // Return position as int
}
char * oilsIDL_pton (const char* classname, int pos) {
- char* ret = NULL;
- osrfHash* f = NULL;
- osrfHash* fields = NULL;
- osrfHashIterator* itr = NULL;
-
- if (!oilsIDL_classIsFieldmapper(classname)) return NULL;
+ osrfHash* class_def_hash = findClassDef( classname );
+ if( !class_def_hash )
+ return NULL; // No such class
+
+ osrfHash* fields_hash = osrfHashGet( class_def_hash, "fields" );
+ if( !fields_hash )
+ return NULL; // No list of fields fo the class
- fields = oilsIDLFindPath( "/%s/fields", classname );
- itr = osrfNewHashIterator( fields );
+ char* ret = NULL;
+ osrfHash* field_def_hash = NULL;
+ osrfHashIterator* iter = osrfNewHashIterator( fields_hash );
- while ( (f = osrfHashIteratorNext( itr )) ) {
- if ( atoi(osrfHashGet(f, "array_position")) == pos ) {
- ret = strdup(osrfHashIteratorKey(itr));
+ while ( ( field_def_hash = osrfHashIteratorNext( iter ) ) ) {
+ if ( atoi( osrfHashGet( field_def_hash, "array_position" ) ) == pos ) {
+ ret = strdup( osrfHashIteratorKey( iter ) );
break;
}
}
- osrfHashIteratorFree( itr );
+ osrfHashIteratorFree( iter );
return ret;
}