Q5Module* module_create (Q5Core core, Q5ModuleInstance* instance) { Q5Module* self = ENTC_NEW (Q5Module); self->instance = instance; self->core = core; self->port = 44000; self->host = ecstr_copy ("0.0.0.0"); self->entities = NULL; return self; }
AdblCredentials* adbl_credentials_new (const EcString dbtype) { AdblCredentials* self = ENTC_NEW(AdblCredentials); self->type = ecstr_copy(dbtype); //initialise the credentials self->connection = 0; //inisitalise the properties self->properties.port = 0; self->properties.host = 0; self->properties.file = 0; self->properties.schema = 0; self->properties.username = 0; self->properties.password = 0; self->pp = NULL; return self; }
void adbl_parseXMLDatabase( AdblManager self, EcXMLStream xmlstream, const char* confpath) { const EcString name = ecxmlstream_nodeAttribute( xmlstream, "name" ); if(name) { const EcString dbtype = ecxmlstream_nodeAttribute( xmlstream, "type" ); if(dbtype) { ADBLModuleProperties* pp; EcMapNode node; node = ecmap_find(self->modules, dbtype); if (node == ecmap_end(self->modules)) { eclogger_fmt (LL_WARN, MODULE, "credentials", "database '%s' not in the list", dbtype); return; } pp = ecmap_data (node); node = ecmap_find(self->credentials, name); if( node == ecmap_end(self->credentials) ) { int isfile = FALSE; EcString fileprefix = NULL; EcString filextension = NULL; //create new credential AdblCredentials* pc = adbl_credentials_new (dbtype); pc->pp = pp; //add to map ecmap_append(self->credentials, name, pc); //parse the other stuff ENTC_XMLSTREAM_BEGIN if( ecxmlstream_isBegin( xmlstream, "connection" ) ) { const char* port = ecxmlstream_nodeAttribute( xmlstream, "port" ); pc->properties.host = ecstr_copy( ecxmlstream_nodeAttribute( xmlstream, "host" ) ); if(port) pc->properties.port = atoi(port); } else if( ecxmlstream_isBegin( xmlstream, "schema" ) ) { pc->properties.schema = ecstr_copy( ecxmlstream_nodeAttribute( xmlstream, "name" ) ); pc->properties.username = ecstr_copy( ecxmlstream_nodeAttribute( xmlstream, "user" ) ); pc->properties.password = ecstr_copy( ecxmlstream_nodeAttribute( xmlstream, "password" ) ); } else if( ecxmlstream_isBegin( xmlstream, "file" ) ) { isfile = TRUE; fileprefix = ecstr_copy( ecxmlstream_nodeAttribute( xmlstream, "prefix" ) ); filextension = ecstr_copy( ecxmlstream_nodeAttribute( xmlstream, "filextension" ) ); } ENTC_XMLSTREAM_END( "database" ) //create the filename if( isfile == TRUE ) { EcStream file = ecstream_new(); if( fileprefix ) { ecstream_append( file, fileprefix ); ecstream_append( file, "_" ); ecstr_delete (&fileprefix ); } if( pc->properties.schema ) { ecstream_append( file, pc->properties.schema ); } if( filextension ) { ecstream_append( file, filextension ); ecstr_delete (&filextension); } else { ecstream_append( file, ".db" ); } pc->properties.file = ecfs_mergeToPath(confpath, ecstream_buffer( file )); /* clean up */ ecstream_delete(&file); } } else { eclogger_fmt (LL_WARN, MODULE, "credentials", "parsing the config file: db-source already exists [%s] in current register", name ); } }
EcString lrealpath = ecfs_mergeToPath(path, filename); EcFileObserver inst = ecf_observer_new (lrealpath, confdir, events, fct, ptr); ecstr_delete(&lrealpath); return inst; } /*------------------------------------------------------------------------*/ EcFileObserver ecf_observer_new (const EcString filename, const EcString confdir, EcEventFiles events, events_callback_fct fct, void* ptr) { EcFileObserver self = ENTC_NEW(struct EcFileObserver_s); /* init common part */ self->confdir = ecstr_copy(confdir); self->filename = ecstr_copy( filename ); self->fhandle = 0; self->fct = fct; self->ptr = ptr; self->events = events; #ifdef _WIN32 ece_files_register (self->events, self->filename, self->fct, self->ptr, ecf_observer_onDelete, self); #endif return self; }