void parseDimensions(mapcache_context *ctx, ezxml_t node, mapcache_tileset *tileset) { ezxml_t dimension_node; apr_array_header_t *dimensions = apr_array_make(ctx->pool,1,sizeof(mapcache_dimension*)); for(dimension_node = ezxml_child(node,"dimension"); dimension_node; dimension_node = dimension_node->next) { char *name = (char*)ezxml_attr(dimension_node,"name"); char *type = (char*)ezxml_attr(dimension_node,"type"); char *unit = (char*)ezxml_attr(dimension_node,"unit"); char *default_value = (char*)ezxml_attr(dimension_node,"default"); mapcache_dimension *dimension = NULL; if(!name || !strlen(name)) { ctx->set_error(ctx, 400, "mandatory attribute \"name\" not found in <dimension>"); return; } if(type && *type) { if(!strcmp(type,"values")) { dimension = mapcache_dimension_values_create(ctx->pool); } else if(!strcmp(type,"regex")) { dimension = mapcache_dimension_regex_create(ctx->pool); } else if(!strcmp(type,"intervals")) { dimension = mapcache_dimension_intervals_create(ctx->pool); } else if(!strcmp(type,"time")) { ctx->set_error(ctx,501,"time dimension type not implemented yet"); return; dimension = mapcache_dimension_time_create(ctx->pool); } else { ctx->set_error(ctx,400,"unknown dimension type \"%s\"",type); return; } } else { ctx->set_error(ctx,400, "mandatory attribute \"type\" not found in <dimensions>"); return; } dimension->name = apr_pstrdup(ctx->pool,name); if(unit && *unit) { dimension->unit = apr_pstrdup(ctx->pool,unit); } if(default_value && *default_value) { dimension->default_value = apr_pstrdup(ctx->pool,default_value); } else { ctx->set_error(ctx,400,"dimension \"%s\" has no \"default\" attribute",dimension->name); return; } dimension->configuration_parse_xml(ctx,dimension,dimension_node); GC_CHECK_ERROR(ctx); APR_ARRAY_PUSH(dimensions,mapcache_dimension*) = dimension; } if(apr_is_empty_array(dimensions)) { ctx->set_error(ctx, 400, "<dimensions> for tileset \"%s\" has no dimensions defined (expecting <dimension> children)",tileset->name); return; } tileset->dimensions = dimensions; }
int main() { int kanji[200][2]; int i = 0; int8_t test = 8; ezxml_t f1 = ezxml_parse_file("4e86.xml"), stroke, point; const char *teamname; for (stroke = ezxml_child(f1, "stroke"); stroke; stroke = stroke->next) { printf("new stroke\n"); for (point = ezxml_child(stroke, "point"); point; point = point->next) { kanji[i][0] = atoi(ezxml_attr(point,"x")); kanji[i][1] = atoi(ezxml_attr(point,"y")); i++; // printf("%i",i); // printf("%s \n", ezxml_attr(point,"x")); } } ezxml_free(f1); for(int j = 0;j<50;j++) { printf("j: %i, x: %i, y: %i\n", j, kanji[j][0], kanji[j][1]); } return 0; }
int is_unique_field(ezxml_t registry, ezxml_t field, const char *check_name){/*{{{*/ ezxml_t struct_xml, var_arr_xml, var_xml; const char *name; for(struct_xml = ezxml_child(registry, "var_struct"); struct_xml; struct_xml = struct_xml->next){ for(var_arr_xml = ezxml_child(struct_xml, "var_array"); var_arr_xml; var_arr_xml = var_arr_xml->next){ for(var_xml = ezxml_child(var_arr_xml, "var"); var_xml; var_xml = var_xml->next){ name = ezxml_attr(var_xml, "name"); if(strcmp(name, check_name) == 0 && var_xml != field){ return 0; } } } for(var_xml = ezxml_child(struct_xml, "var"); var_xml; var_xml = var_xml->next){ name = ezxml_attr(var_xml, "name"); if(strcmp(name, check_name) == 0 && var_xml != field){ return 0; } } } return 1; }/*}}}*/
void LCOrbits::configBase(ezxml_t xmlbloc) { ezxml_t param; for(param = ezxml_child(xmlbloc,"Param"); param; param = param->next){ if(MT->wcmp(ezxml_attr(param,"Name"),"TimeStoringPosition")) tRangeStorePos = MT->gXMLTime(param); if(MT->wcmp(ezxml_attr(param,"Name"),"TimeStoringArmlength")) tRangeStoreArm = MT->gXMLTime(param); } }
int generate_namelist(ezxml_t registry, FILE* fd, int pairs, char **keys, char **values){/*{{{*/ ezxml_t nmlrecs_xml, nmlopt_xml; const char *recname; const char *optname, *opttype; char *optval; int write_opt, write_record, record_written; int i; for (nmlrecs_xml = ezxml_child(registry, "nml_record"); nmlrecs_xml; nmlrecs_xml = nmlrecs_xml->next){ recname = ezxml_attr(nmlrecs_xml, "name"); record_written = 0; write_record = is_structure_writable(nmlrecs_xml, pairs, keys, values); /* If record doesn't have a key, record is writeable */ if ( write_record == -1 ) write_record = 1; if ( write_record == 1 ) { fprintf(fd, "&%s\n", recname); record_written = 1; } for (nmlopt_xml = ezxml_child(nmlrecs_xml, "nml_option"); nmlopt_xml; nmlopt_xml = nmlopt_xml->next){ optname = ezxml_attr(nmlopt_xml, "name"); opttype = ezxml_attr(nmlopt_xml, "type"); write_opt = is_structure_writable(nmlopt_xml, pairs, keys, values); if ( write_opt == 1 || ( write_opt == -1 && write_record == 1) ){ if ( !record_written ) { fprintf(fd, "&%s\n", recname); record_written = 1; } optval = get_option_value(nmlopt_xml, pairs, values); if ( strcmp(opttype, "character") == 0){ fprintf(fd, " %s = '%s'\n", optname, optval); } else { fprintf(fd, " %s = %s\n", optname, optval); } free(optval); } } if ( record_written ) { fprintf(fd, "/\n"); } } return 0; }/*}}}*/
void parseSource(mapcache_context *ctx, ezxml_t node, mapcache_cfg *config) { ezxml_t cur_node; char *name = NULL, *type = NULL; mapcache_source *source; name = (char*)ezxml_attr(node,"name"); type = (char*)ezxml_attr(node,"type"); if(!name || !strlen(name)) { ctx->set_error(ctx, 400, "mandatory attribute \"name\" not found in <source>"); return; } else { name = apr_pstrdup(ctx->pool, name); /* check we don't already have a source defined with this name */ if(mapcache_configuration_get_source(config, name)) { ctx->set_error(ctx, 400, "duplicate source with name \"%s\"",name); return; } } if(!type || !strlen(type)) { ctx->set_error(ctx, 400, "mandatory attribute \"type\" not found in <source>"); return; } source = NULL; if(!strcmp(type,"wms")) { source = mapcache_source_wms_create(ctx); } else if(!strcmp(type,"mapserver")) { source = mapcache_source_mapserver_create(ctx); } else if(!strcmp(type,"gdal")) { source = mapcache_source_gdal_create(ctx); } else if(!strcmp(type,"dummy")) { source = mapcache_source_dummy_create(ctx); } else { ctx->set_error(ctx, 400, "unknown source type %s for source \"%s\"", type, name); return; } if(source == NULL) { ctx->set_error(ctx, 400, "failed to parse source \"%s\"", name); return; } source->name = name; if ((cur_node = ezxml_child(node,"metadata")) != NULL) { parseMetadata(ctx, cur_node, source->metadata); GC_CHECK_ERROR(ctx); } source->configuration_parse_xml(ctx,node,source); GC_CHECK_ERROR(ctx); source->configuration_check(ctx,config,source); GC_CHECK_ERROR(ctx); mapcache_configuration_add_source(config,source,name); }
/* * parse_automaton_names * * Given a file with xml, fill in all the names that do not contain any * external references. This is the the automaton names and the transition * names. * * Note that this also allocates all the memory required for the automatons * themselves including the transition table and creating the individual * transitions. * * Parameters: xml_file - The entire xml document. * automaton_set - The automaton set to fill in. * * Returns: One of AUTOMATON_XML_FILE_RET_CODES. */ int parse_automaton_names(ezxml_t *xml_file, AUTOMATON_SET *automaton_set) { /* * Local Variables. */ int ret_code = AUTOMATON_XML_FILE_OK; ezxml_t xml_automaton; int ii; /* * Loop through all the automatons. */ ii = 0; for (xml_automaton = ezxml_child(*xml_file, "automaton"); xml_automaton; xml_automaton = xml_automaton->next) { /* * Set the name of the automaton. We refer to the automatons by name in the * transitions. */ if (NULL == ezxml_attr(xml_automaton, "name")) { DT_DEBUG_LOG("Automaton is missing name attribute in xml file.\n"); ret_code = AUTOMATON_XML_FILE_LINKS_FAIL; goto EXIT_LABEL; } strncpy(automaton_set->automaton_array[ii]->name, ezxml_attr(xml_automaton, "name"), MAX_AUTOMATON_NAME_LEN); /* * We have the automaton name so now retrieve the transition names for * the automaton. Note that this doesn't read into whether the transition * is valid yet or not. */ ret_code = parse_transition_names(&xml_automaton, automaton_set->automaton_array[ii]); if (AUTOMATON_XML_FILE_OK != ret_code) { goto EXIT_LABEL; } ii++; } EXIT_LABEL: return ret_code; }
int is_unique_struct(ezxml_t current_position, ezxml_t check_struct, const char *check_name){/*{{{*/ ezxml_t struct_xml; const char *name; int test; test = 1; for(struct_xml = ezxml_child(current_position, "var_struct"); struct_xml; struct_xml = struct_xml->next){ name = ezxml_attr(struct_xml, "name"); if(strcmp(name, check_name) == 0 && struct_xml != check_struct){ return 0; } else { test = is_unique_struct(struct_xml, check_struct, check_name); if ( !test ) { return 0; } } } return 1; }/*}}}*/
externC void cyg_start( void ) { ezxml_t f1, team, driver; const char * teamname; int i; CYG_TEST_INIT(); f1 = ezxml_parse_str(document, sizeof(document)); for (team = ezxml_child(f1, "team"); team; team = team->next) { teamname = ezxml_attr(team, "name"); for (i=0,driver = ezxml_child(team, "driver"); driver; driver = driver->next,i++) { if (strcmp(results[i].driver, ezxml_child(driver, "name")->txt) || strcmp(results[i].team, teamname) || strcmp(results[i].points, ezxml_child(driver, "points")->txt)) CYG_TEST_FAIL("Parser failed first test"); } } if (strcmp(ezxml_get(f1, "team", 0, "driver", 1, "name", -1)->txt, "David Coultard")) CYG_TEST_FAIL_FINISH("Parser failed second test"); else CYG_TEST_PASS_FINISH("Parser passed"); ezxml_free(f1); }
char * check_streams(ezxml_t registry, char * streams) { ezxml_t streams_xml, stream_xml; const char *streamname; char *string, *tofree, *token; char *failed; int missing_stream; string = strdup(streams); tofree = string; failed = NULL; while( (token = strsep(&string, ";")) != NULL) { missing_stream = 1; for (streams_xml = ezxml_child(registry, "streams"); streams_xml; streams_xml = streams_xml->next) { for (stream_xml = ezxml_child(streams_xml, "stream"); stream_xml; stream_xml = stream_xml->next) { streamname = ezxml_attr(stream_xml, "name"); if(strcasecmp(streamname, token) == 0) { /* TODO: Not portable? */ missing_stream = 0; } } } if (missing_stream) { failed = strdup(token); free(tofree); return failed; } } free(tofree); return failed; }
char * check_dimensions(ezxml_t registry, char * dims){/*{{{*/ ezxml_t dims_xml, dim_xml; const char *dimname; char *string, *tofree, *token; int missing_dim; string = strdup(dims); tofree = string; while( (token = strsep(&string, " ")) != NULL) { if (strcasecmp(token, "Time") != 0){ missing_dim = 1; for (dims_xml = ezxml_child(registry, "dims"); dims_xml; dims_xml = dims_xml->next){ for (dim_xml = ezxml_child(dims_xml, "dim"); dim_xml; dim_xml = dim_xml->next){ dimname = ezxml_attr(dim_xml, "name"); if(strcasecmp(dimname, token) == 0){ missing_dim = 0; } } } if (missing_dim) { free(tofree); return token; } } } free(tofree); return NULL; }/*}}}*/
char * check_packages(ezxml_t registry, char * packages){/*{{{*/ ezxml_t packages_xml, package_xml; const char *packagename; char *string, *tofree, *token; char *failed; int missing_package; string = strdup(packages); tofree = string; failed = NULL; while( (token = strsep(&string, ";")) != NULL) { missing_package = 1; for (packages_xml = ezxml_child(registry, "packages"); packages_xml; packages_xml = packages_xml->next){ for (package_xml = ezxml_child(packages_xml, "package"); package_xml; package_xml = package_xml->next){ packagename = ezxml_attr(package_xml, "name"); if(strcasecmp(packagename, token) == 0){ missing_package = 0; } } } if (missing_package) { failed = strdup(token); free(tofree); return failed; } } free(tofree); return failed; }/*}}}*/
int is_structure_writable(ezxml_t structure, int pairs, char **keys, char **values){/*{{{*/ const char *control_value; int i, value_found; char *string; char *tofree; char *token; value_found = -1; for (i = 0; i < pairs; i++){ control_value = ezxml_attr(structure, keys[i]); if ( control_value != NULL ){ /* Set found to false, since the key was found. */ value_found = 0; string = strdup(control_value); tofree = string; while( ( token = strsep(&string, ";") ) != NULL ){ if ( strcmp(token, values[i]) == 0 ){ value_found = 1; } } } } return value_found; }/*}}}*/
static void _mapcache_dimension_values_parse_xml(mapcache_context *ctx, mapcache_dimension *dim, ezxml_t node) { int count = 1; mapcache_dimension_values *dimension; const char *case_sensitive; char *key,*last; char *values; const char *entry = node->txt; if(!entry || !*entry) { ctx->set_error(ctx,400,"failed to parse dimension values: none supplied"); return; } dimension = (mapcache_dimension_values*)dim; case_sensitive = ezxml_attr(node,"case_sensitive"); if(case_sensitive && !strcasecmp(case_sensitive,"true")) { dimension->case_sensitive = 1; } values = apr_pstrdup(ctx->pool,entry); for(key=values; *key; key++) if(*key == ',') count++; dimension->values = (char**)apr_pcalloc(ctx->pool,count*sizeof(char*)); for (key = apr_strtok(values, ",", &last); key != NULL; key = apr_strtok(NULL, ",", &last)) { dimension->values[dimension->nvalues]=key; dimension->nvalues++; } if(!dimension->nvalues) { ctx->set_error(ctx, 400, "<dimension> \"%s\" has no values",dim->name); return; } }
static void process_import_map(ezxml_t root, struct _import_map *import_map, const char *map_name) { ezxml_t node; for(node = ezxml_child(root, map_name); node != NULL; node = ezxml_next(node)) { const char *id = ezxml_attr(node, "id"); const char *map = ezxml_attr(node, "map"); if(id == NULL) fprintf(stderr, "WARNING: <%s /> element missing required element \"id\"; ignoring\n", map_name); else if(map == NULL) fprintf(stderr, "WARNING: <%s /> element missing required element \"map\"; ignoring\n", map_name); import_map[strtoul(id, NULL, 0)].map = (unsigned char)strtoul(map, NULL, 0); } }
void LCGWSpinBBHNR1::config(ezxml_t xmlbloc) { //! *** Read sky position, polarization and name configBase(xmlbloc); //! ** Reset declination to compute quantities related to sky position setParam(0, Beta); ezxml_t param; for(param = ezxml_child(xmlbloc,"Param"); param; param = param->next){ //! *** Read ecliptic lattitude if(MT->wcmp(ezxml_attr(param,"Name"),"EclipticLatitude")) setParam(0, MT->gXMLAngle(param)); //! *** Read ecliptic colattitude if(MT->wcmp(ezxml_attr(param,"Name"),"EclipticColatitude")) setParam(0, M_PI/2. - MT->gXMLAngle(param)); //! *** Read ecliptic longitude if(MT->wcmp(ezxml_attr(param,"Name"),"EclipticLongitude")) setParam(1, MT->gXMLAngle(param)); //! *** Read polarization if(MT->wcmp(ezxml_attr(param,"Name"),"Polarization")) setParam(2, MT->gXMLAngle(param)); if(MT->wcmp(ezxml_attr(param,"Name"),"TotalMass")) setParam(3, MT->gXMLAstroMass(param) ); if(MT->wcmp(ezxml_attr(param,"Name"),"CoalescenceTime")) setParam(4, MT->gXMLTime(param) ); if(MT->wcmp(ezxml_attr(param,"Name"),"Distance")) setParam(5, MT->gXMLAstroDistance(param) ); if(MT->wcmp(ezxml_attr(param,"Name"),"PolarAngleTotalMomentuminSBB")) setParam(6, MT->gXMLAngle(param) ); if(MT->wcmp(ezxml_attr(param,"Name"),"AzimuthalAngleTotalMomentuminSBB")) setParam(7, MT->gXMLAngle(param) ); //if(MT->wcmp(ezxml_attr(param,"Name"),"FileName")) // MT->stripcopy((*param).txt,NRFileName); } }
char* MSN_GetAvatarHash(char* szContext, char** pszUrl) { if (pszUrl) *pszUrl = NULL; if (szContext == NULL) return NULL; char *res = NULL; ezxml_t xmli = ezxml_parse_str(NEWSTR_ALLOCA(szContext), strlen(szContext)); const char *szAvatarHash = ezxml_attr(xmli, "SHA1D"); if (szAvatarHash != NULL) { unsigned hashLen; mir_ptr<BYTE> hash((BYTE*)mir_base64_decode(szAvatarHash, &hashLen)); if (hash) res = arrayToHex(hash, hashLen); if (pszUrl) { const char *pszUrlAttr; for (int i=0; ; i++) { char szSetting[20]; if (i == 0) strcpy(szSetting, "Url"); else mir_snprintf(szSetting, sizeof(szSetting), "Url%d", i); pszUrlAttr = ezxml_attr(xmli, szSetting); if (pszUrlAttr == NULL) break; if (pszUrlAttr[0] != 0) { *pszUrl = mir_strdup(pszUrlAttr); break; } } } } ezxml_free(xmli); return res; }
char* get_option_value(ezxml_t nml_option, int pairs, char **values){/*{{{*/ int i; char value_name[1024]; const char *test_val; char *optvalue; for (i = 0; i < pairs; i++){ sprintf(value_name, "%s_value", values[i]); test_val = ezxml_attr(nml_option, value_name); if ( test_val != NULL ) { optvalue = strdup(test_val); return optvalue; } } test_val = ezxml_attr(nml_option, "default_value"); optvalue = strdup(test_val); return optvalue; }/*}}}*/
dom_exception dom_document_get_element_by_id(dom_node *node, dom_string *string, dom_element **outNode) { /* xmlAttrPtr attrPtr = xmlHasProp(node->node, (const xmlChar *)"id"); */ const char *id = ezxml_attr(node->node, "id"); if (id && 0 == strcasecmp(id, string->s)) { node->ref++; *outNode = node; return DOM_NO_ERR; } *outNode = NULL; /* TODO: Find id recursive! */ return DOM_NO_ERR; }
dom_exception dom_element_get_attribute(dom_node *node, dom_string *string, dom_string **outAttribute) { /* xmlAttrPtr attrPtr = xmlHasProp(node->node, (const xmlChar *)string->s); */ const char *attr = ezxml_attr(node->node, string->s); if (NULL == attr) { if (strchr(string->s, ':')) { fprintf(stderr, "TODO:dom_element_get_attribute - namespace %s\n", string->s); } } else { return dom_string_create_interned((const uint8_t *)attr, strlen(attr), outAttribute); } *outAttribute = NULL; return DOM_NO_ERR; }
/** * \private \memberof mapcache_cache_disk */ static void _mapcache_cache_disk_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache, mapcache_cfg *config) { ezxml_t cur_node; mapcache_cache_disk *dcache = (mapcache_cache_disk*)cache; char *layout = NULL; int template_layout = MAPCACHE_FALSE; layout = (char*)ezxml_attr(node,"layout"); if (!layout || !strlen(layout) || !strcmp(layout,"tilecache")) { dcache->tile_key = _mapcache_cache_disk_tilecache_tile_key; } else if(!strcmp(layout,"arcgis")) { dcache->tile_key = _mapcache_cache_disk_arcgis_tile_key; } else if (!strcmp(layout,"template")) { dcache->tile_key = _mapcache_cache_disk_template_tile_key; template_layout = MAPCACHE_TRUE; if ((cur_node = ezxml_child(node,"template")) != NULL) { dcache->filename_template = apr_pstrdup(ctx->pool,cur_node->txt); } else { ctx->set_error(ctx, 400, "no template specified for cache \"%s\"", cache->name); return; } } else { ctx->set_error(ctx, 400, "unknown layout type %s for cache \"%s\"", layout, cache->name); return; } if (!template_layout && (cur_node = ezxml_child(node,"base")) != NULL) { dcache->base_directory = apr_pstrdup(ctx->pool,cur_node->txt); } if (!template_layout && (cur_node = ezxml_child(node,"symlink_blank")) != NULL) { if(strcasecmp(cur_node->txt,"false")) { #ifdef HAVE_SYMLINK dcache->symlink_blank=1; #else ctx->set_error(ctx,400,"cache %s: host system does not support file symbolic linking",cache->name); return; #endif } } if ((cur_node = ezxml_child(node,"creation_retry")) != NULL) { dcache->creation_retry = atoi(cur_node->txt); } if ((cur_node = ezxml_child(node,"maxzoom")) != NULL) { dcache->maxzoom = atoi(cur_node->txt); } }
static void set_stats_limit (ezxml_t inner_xml, stats_limit_cfg * st) { const char *ptr = ezxml_attr (inner_xml, "name"); long value[4]; const char *val_ptr = ezxml_attr (inner_xml, "current"); if (val_ptr == NULL) { fprintf (stderr, "Error: attribute 'current' is absent\n"); exit (-1); } if( strcmp( ptr, "slow" ) == 0 ) { value[0] = parse_period( val_ptr ); value[1] = -1; value[2] = -1; value[3] = -1; } else { value[0] = atof (val_ptr); value[1] = ((val_ptr = ezxml_attr (inner_xml, "short")) == NULL) ? (-1) : atof (val_ptr); value[2] = ((val_ptr = ezxml_attr (inner_xml, "mid")) == NULL) ? (-1) : atof (val_ptr); value[3] = ((val_ptr = ezxml_attr (inner_xml, "long")) == NULL) ? (-1) : atof (val_ptr); } _set_val (&st->cpu, ptr, "cpu", value) || _set_val (&st->write, ptr, "write", value) || _set_val (&st->read, ptr, "read", value) || _set_val (&st->slow, ptr, "slow", value) || fprintf (stderr, "Unknown limit setting: %s\n", ptr); }
void LCOrbitsAnaOctahedron::config(ezxml_t xmlbloc) { configBase(xmlbloc); ezxml_t param; for(param = ezxml_child(xmlbloc,"Param"); param; param = param->next){ if(strcmp(ezxml_attr(param,"Name"),"Armlength")==0){ L0m = MT->gXMLLength(param); } if(strcmp(ezxml_attr(param,"Name"),"OrderDelay")==0){ OrderArm = atoi(ezxml_txt(param)); } if(strcmp(ezxml_attr(param,"Name"),"OrbitApproximation")==0){ char * tmpStr(NULL); MT->stripcopy((*param).txt, tmpStr); if(MT->wcmp(tmpStr,"Static")) move = 0; if(MT->wcmp(tmpStr,"Moving")) move = 1; if(tmpStr != NULL) MT->Free(tmpStr, (strlen(tmpStr)+1) * sizeof(char)); } if(strcmp(ezxml_attr(param,"Name"),"OffsetSC1")==0){ pSCOff[0] = atof(ezxml_txt(param)); } if(strcmp(ezxml_attr(param,"Name"),"OffsetSC2")==0){ pSCOff[1] = atof(ezxml_txt(param)); } if(strcmp(ezxml_attr(param,"Name"),"OffsetSC3")==0){ pSCOff[2] = atof(ezxml_txt(param)); } if(strcmp(ezxml_attr(param,"Name"),"OffsetSC4")==0){ pSCOff[3] = atof(ezxml_txt(param)); } if(strcmp(ezxml_attr(param,"Name"),"OffsetSC5")==0){ pSCOff[4] = atof(ezxml_txt(param)); } if(strcmp(ezxml_attr(param,"Name"),"OffsetSC6")==0){ pSCOff[5] = atof(ezxml_txt(param)); } } }
void LCOBPMOcta1::config(ezxml_t xmlbloc) { ezxml_t param; char * OpticalBenchType(NULL); for(param = ezxml_child(xmlbloc,"Param"); param; param = param->next){ //! **** Checking that it's the right configuration of optical bench + phasemeter if(MT->wcmp(ezxml_attr(param,"Name"),"OpticalBenchType")){ MT->stripcopy((*param).txt, OpticalBenchType); if(!MT->wcmp(OpticalBenchType, "Octa1")) throw std::invalid_argument("ERROR in LCOBPMOcta1::config : The xml bloc does not correspond to a type of the optical bench + phasemeter 'Octa1' ."); } } if(OpticalBenchType != NULL) MT->Free(OpticalBenchType, (strlen(OpticalBenchType)+1) * sizeof(char) ); //! *** Set the name and the position setNamePos(ezxml_attr(xmlbloc,"Name")); if((Name[0]=='s')&&(Name[1]=='c')&&(Name[2]=='i')){ TypeOBPM = 0; IndirectDirLink = 0; iSCLink = -1*IndirectDir; } //! *** Configuration of filter configFilter(xmlbloc); }
int check_for_unique_names(ezxml_t registry, ezxml_t current_position){/*{{{*/ ezxml_t struct_xml, var_arr_xml, var_xml; const char *name; for(struct_xml = ezxml_child(current_position, "var_struct"); struct_xml; struct_xml = struct_xml->next){ name = ezxml_attr(struct_xml, "name"); if(!is_unique_struct(registry, struct_xml, name)){ fprintf(stderr, "ERROR: Struct %s is not uniqe.\n", name); return 1; } for(var_arr_xml = ezxml_child(struct_xml, "var_array"); var_arr_xml; var_arr_xml = var_arr_xml->next){ for(var_xml = ezxml_child(var_arr_xml, "var"); var_xml; var_xml = var_xml->next){ name = ezxml_attr(var_xml, "name"); if(!is_unique_field(registry, var_xml, name)){ fprintf(stderr, "ERROR: Field %s is not unique.\n", name); return 1; } } } for(var_xml = ezxml_child(struct_xml, "var"); var_xml; var_xml = var_xml->next){ name = ezxml_attr(var_xml, "name"); if(!is_unique_field(registry, var_xml, name)){ fprintf(stderr, "ERROR: Field %s is not unique.\n", name); return 1; } } check_for_unique_names(registry, struct_xml); } return 0; }/*}}}*/
static void _mapcache_cache_sqlite_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_cache *cache, mapcache_cfg *config) { ezxml_t cur_node; mapcache_cache_sqlite *dcache; sqlite3_initialize(); sqlite3_config(SQLITE_CONFIG_MULTITHREAD); dcache = (mapcache_cache_sqlite*) cache; if ((cur_node = ezxml_child(node, "base")) != NULL) { ctx->set_error(ctx, 500, "sqlite config <base> not supported anymore, use <dbfile>"); return; } if ((cur_node = ezxml_child(node, "dbname_template")) != NULL) { ctx->set_error(ctx, 500, "sqlite config <dbname_template> not supported anymore, use <dbfile>"); return; } if ((cur_node = ezxml_child(node, "dbfile")) != NULL) { dcache->dbfile = apr_pstrdup(ctx->pool, cur_node->txt); } dcache->detect_blank = 0; if ((cur_node = ezxml_child(node, "detect_blank")) != NULL) { if(!strcasecmp(cur_node->txt,"true")) { dcache->detect_blank = 1; } } if ((cur_node = ezxml_child(node, "hitstats")) != NULL) { if (!strcasecmp(cur_node->txt, "true")) { ctx->set_error(ctx, 500, "sqlite config <hitstats> not supported anymore"); } } if ((cur_node = ezxml_child(node, "pragma")) != NULL) { dcache->pragmas = apr_table_make(ctx->pool,1); while(cur_node) { char *name = (char*)ezxml_attr(cur_node,"name"); if(!name || !cur_node->txt || !strlen(cur_node->txt)) { ctx->set_error(ctx,500,"<pragma> missing name attribute"); return; } apr_table_set(dcache->pragmas,name,cur_node->txt); cur_node = cur_node->next; } } if (!dcache->dbfile) { ctx->set_error(ctx, 500, "sqlite cache \"%s\" is missing <dbfile> entry", cache->name); return; } }
void LISACode::configTDIIntermediate(ezxml_t xmlbloc) { ezxml_t param; char * TDIIntType(NULL); for(param = ezxml_child(xmlbloc,"Param"); param; param = param->next){ if(MT->wcmp(ezxml_attr(param,"Name"),"TDIIntermediateType")){ MT->stripcopy((*param).txt, TDIIntType); if(MT->wcmp(TDIIntType, "Std2002")){ NTDII++; TDII = (LCTDIInt**) MT->ReAllocMemory(TDII, (NTDII-1)*sizeof(LCTDIInt*), NTDII*sizeof(LCTDIInt*)); TDII[NTDII-1] = new LCTDIIntStd2002(MT); TDII[NTDII-1]->config(xmlbloc); } } } if(TDIIntType != NULL) MT->Free(TDIIntType, (strlen(TDIIntType)+1) * sizeof(char)); }
const char * FindProperty(INP ezxml_t Parent, INP const char *Name, INP boolean Required) { const char *Res; Res = ezxml_attr(Parent, Name); if(Required) { if(NULL == Res) { printf(ERRTAG "[Line %d] Required property '%s' not found for element '%s'.\n", Parent->line, Name, Parent->name); exit(1); } } return Res; }
static void ___send_test_cmd(struct x_bus *sess, ezxml_t _from) { ezxml_t _s = NULL; ezxml_t __stnz = NULL; ezxml_t _stnz1 = NULL; ezxml_t _stnz2 = NULL; ENTER; __stnz = xmpp_stanza_get_root(_from); if (!__stnz) return; _stnz1 = ezxml_new("message"); _s = _stnz1; ezxml_set_attr_d(_s,"to",ezxml_attr(__stnz,"from")); ezxml_set_attr(_s, "from", sess->jid); // ezxml_set_attr(_stnz1,"xmlns","http://jabber.org/protocol/feature-neg"); // add xforms _stnz2 = ezxml_add_child(_stnz1, "x",0); ezxml_set_attr(_stnz2,"xmlns","jabber:x:data"); ezxml_set_attr(_stnz2,"type","form"); _stnz2 = ezxml_add_child(_stnz2, "field",0); ezxml_set_attr(_stnz2,"var","fname"); ezxml_set_attr(_stnz2,"type","text-single"); ezxml_set_attr(_stnz2,"label","Select filename"); // ezxml_insert(_stnz1, _s, 0); xmpp_session_send_stanza(sess, _s); ezxml_free(_s); EXIT; return; }
static int parse_tracks(ezxml_t xml, struct track* t, bool ordered, bool high_bitrate) { int track_count = 0; struct track* prev = NULL; struct track* root = t; for (ezxml_t track = ezxml_get(xml, "track",-1); track; track = track->next) { /* is this an ordered list? in that case we have to find the right track struct for every track id */ if (ordered) { char tid[33]; xmlstrncpy(tid, sizeof tid, track, "id", -1); struct track* tt; for (tt = root; tt; tt = tt->next) if (!tt->has_meta_data && !strncmp(tt->track_id, tid, sizeof tt->track_id)) break; /* if we didn't find the id, check if an old, redirected id is used */ if (!tt) { char rid[33]; for (ezxml_t re = ezxml_child(track, "redirect"); re; re = re->next) { strncpy(rid, re->txt, sizeof rid); for (tt = root; tt; tt = tt->next) { /* update to new id */ /* FIXME: This invalidates the playlist checksum */ if (!tt->has_meta_data && !strncmp(tt->track_id, rid, sizeof tt->track_id)) { memcpy (tt->track_id, tid, sizeof tt->track_id); break; } } if (tt) break; } /* we've wasted enough cpu cycles on this track now */ if (!tt) { DSFYDEBUG("!!! error: track id not found: %s\n", tid); continue; } } t = tt; } else if (!t) { t = calloc(1, sizeof(struct track)); prev->next = t; } xmlstrncpy(t->title, sizeof t->title, track, "title", -1); xmlstrncpy(t->album, sizeof t->album, track, "album", -1); xmlstrncpy(t->track_id, sizeof t->track_id, track, "id", -1); xmlstrncpy(t->cover_id, sizeof t->cover_id, track, "cover", -1); xmlstrncpy(t->album_id, sizeof t->album_id, track, "album-id", -1); /* create list of artists */ struct artist* preva = NULL; struct artist* artist = calloc(1, sizeof(struct artist)); t->artist = artist; ezxml_t xid = ezxml_get(track, "artist-id", -1); for (ezxml_t xa = ezxml_get(track, "artist", -1); xa; xa = xa->next) { if (preva) { artist = calloc(1, sizeof(struct artist)); preva->next = artist; } DSFYstrncpy(artist->name, xa->txt, sizeof artist->name); if (xid) { DSFYstrncpy(artist->id, xid->txt, sizeof artist->id); xid = xid->next; } preva = artist; } for ( ezxml_t file = ezxml_get(track, "files",0, "file",-1); file; file = file->next) { char* fmt = (char*)ezxml_attr(file, "format"); if (fmt) { unsigned int bitrate; if (sscanf(fmt,"Ogg Vorbis,%u,", &bitrate)) { if (bitrate > t->file_bitrate) { if (high_bitrate || t->file_bitrate == 0) t->file_bitrate = bitrate; else continue; } } char* id = (char*)ezxml_attr(file, "id"); if (id) { DSFYstrncpy(t->file_id, id, sizeof t->file_id); t->playable = true; } } } for ( ezxml_t restriction = ezxml_get(track, "restrictions", 0, "restriction", -1); restriction; restriction = restriction->next) { char *catalogues = (char*)ezxml_attr(restriction, "catalogues"); if(catalogues && strstr(catalogues, "premium") != NULL) { char* allowed = (char*)ezxml_attr(restriction, "allowed"); if(allowed) { t->allowed = calloc(strlen(allowed)+1, sizeof(char)); DSFYstrncpy(t->allowed, allowed, strlen(allowed)+1); } else { t->allowed = NULL; } char* forbidden = (char*)ezxml_attr(restriction, "forbidden"); if(forbidden) { t->forbidden = calloc(strlen(forbidden)+1, sizeof(char)); DSFYstrncpy(t->forbidden, forbidden, strlen(forbidden)+1); } else { t->forbidden = NULL; } } } xmlatoi(&t->year, track, "year", -1); xmlatoi(&t->length, track, "length", -1); xmlatoi(&t->tracknumber, track, "track-number", -1); xmlatof(&t->popularity, track, "popularity", -1); t->has_meta_data = true; prev = t; t = t->next; track_count++; } return track_count; }