static void dump_ne_resources( const IMAGE_OS2_HEADER *ne ) { const NE_NAMEINFO *name; const void *res_ptr = (const char *)ne + ne->ne_rsrctab; WORD size_shift = get_word(res_ptr); const NE_TYPEINFO *info = (const NE_TYPEINFO *)((const WORD *)res_ptr + 1); int count; printf( "\nResources:\n" ); while (info->type_id != 0 && (const char *)info < (const char *)ne + ne->ne_restab) { name = (const NE_NAMEINFO *)(info + 1); for (count = info->count; count > 0; count--, name++) { if (name->id & 0x8000) printf( " %d", (name->id & ~0x8000) ); else printf( " %.*s", *((const unsigned char *)res_ptr + name->id), (const char *)res_ptr + name->id + 1 ); if (info->type_id & 0x8000) printf( " %s", get_resource_type(info->type_id) ); else printf( " %.*s", *((const unsigned char *)res_ptr + info->type_id), (const char *)res_ptr + info->type_id + 1 ); printf(" flags %04x length %04x\n", name->flags, name->length << size_shift); dump_data( PRD(name->offset << size_shift, name->length << size_shift), name->length << size_shift, " " ); } info = (const NE_TYPEINFO *)name; } }
String ResourceLoader::find_complete_path(const String& p_path,const String& p_type) { //this is an old vestige when the engine saved files without extension. //remains here for compatibility with old projects and only because it //can be sometimes nice to open files using .* from a script and have it guess //the right extension. String local_path = p_path; if (local_path.ends_with("*")) { //find the extension for resource that ends with * local_path = local_path.substr(0,local_path.length()-1); List<String> extensions; get_recognized_extensions_for_type(p_type,&extensions); List<String> candidates; for(List<String>::Element *E=extensions.front();E;E=E->next()) { String path = local_path+E->get(); if (PathRemap::get_singleton()->has_remap(path) || FileAccess::exists(path)) { candidates.push_back(path); } } if (candidates.size()==0) { return ""; } else if (candidates.size()==1 || p_type=="") { return candidates.front()->get(); } else { for(List<String>::Element *E=candidates.front();E;E=E->next()) { String rt = get_resource_type(E->get()); if (ObjectTypeDB::is_type(rt,p_type)) { return E->get(); } } return ""; } } return local_path; }
static multicart_open_error load_all_resources(emu_options &options, multicart_load_state *state) { multicart_open_error err; xml_data_node *resource_node; multicart_resource_type resource_type; for (resource_node = state->resources_node->child; resource_node != NULL; resource_node = resource_node->next) { resource_type = get_resource_type(resource_node->name); if (resource_type != MULTICART_RESOURCE_TYPE_INVALID) { err = load_resource(options, state, resource_node, resource_type); if (err != MCERR_NONE) return err; } } state->multicart->resources = state->resources; return MCERR_NONE; }
static int get_bladehpi_hostlist(struct pluginDevice *dev) { struct blade_info * bi; SaErrorT ohrc; SaHpiEntryIdT ohnextid; SaHpiRptEntryT ohRPT; SaHpiDomainInfoT ohdi; SaHpiUint32T ohupdate; if (Debug) { LOG(PIL_DEBUG, "%s: called, dev->device=%s" , __FUNCTION__, dev->device); } if (dev->device == NULL || *dev->device == 0) { LOG(PIL_CRIT, "Unconfigured stonith object in %s" , __FUNCTION__); return S_BADCONFIG; } ohrc = saHpiDomainInfoGet(dev->ohsession, &ohdi); if (ohrc != SA_OK) { LOG(PIL_CRIT, "Unable to get domain info in %s (%d)" , __FUNCTION__, ohrc); return S_BADCONFIG; } try_again: ohupdate = ohdi.RptUpdateCount; dev->ohdevid = dev->ohsensid = dev->ohsensnum = 0; ohnextid = SAHPI_FIRST_ENTRY; do { char blname[SAHPI_MAX_TEXT_BUFFER_LENGTH]; int blnum; ohrc = saHpiRptEntryGet(dev->ohsession, ohnextid , &ohnextid, &ohRPT); if (ohrc != SA_OK) { LOG(PIL_CRIT, "Unable to get RPT entry in %s (%d)" , __FUNCTION__, ohrc); free_bladehpi_hostlist(dev); return S_BADCONFIG; } switch (get_resource_type(dev->device, &ohRPT)) { case OHRES_BLADECENT: dev->ohdevid = ohRPT.ResourceId; if (Debug) { LOG(PIL_DEBUG, "BladeCenter '%s' has id %d" , (char*)ohRPT.ResourceTag.Data , dev->ohdevid); } break; case OHRES_MGMTMOD: if (ohRPT.ResourceCapabilities&SAHPI_CAPABILITY_SENSOR){ dev->ohsensnum = get_sensor_num(dev->ohsession , ohRPT.ResourceId); if (dev->ohsensnum) { dev->ohsensid = ohRPT.ResourceId; if (Debug) { LOG(PIL_DEBUG , "MgmtModule '%s' has id %d " "with sensor #%d" , (char*)ohRPT.ResourceTag.Data , dev->ohsensid , dev->ohsensnum); } } } break; case OHRES_BLADE: if ((bi = (struct blade_info *) MALLOC(sizeof(struct blade_info))) == NULL) { LOG(PIL_CRIT, "Out of memory in %s" , __FUNCTION__); free_bladehpi_hostlist(dev); return S_OOPS; } /* * New format consists of "Blade N - name" while older * format consists only of "name"; we only need to * stash name because ResourceID is the important info */ if (sscanf((char*)ohRPT.ResourceTag.Data, "Blade %d - %s" , &blnum, blname) == 2) { bi->name = STRDUP(blname); } else { bi->name = STRDUP((char*)ohRPT.ResourceTag.Data); } if (bi->name == NULL) { LOG(PIL_CRIT, "Out of memory for strdup in %s" , __FUNCTION__); free_bladehpi_hostlist(dev); return S_OOPS; } bi->resourceId = ohRPT.ResourceId; bi->resourceCaps = ohRPT.ResourceCapabilities; dev->hostlist = g_list_append(dev->hostlist, bi); if (Debug) { LOG(PIL_DEBUG, "Blade '%s' has id %d, caps %x" , bi->name, bi->resourceId, bi->resourceCaps); } break; } } while (ohrc == SA_OK && ohnextid != SAHPI_LAST_ENTRY); ohrc = saHpiDomainInfoGet(dev->ohsession, &ohdi); if (ohrc != SA_OK) { LOG(PIL_CRIT, "Unable to get domain info in %s (%d)" , __FUNCTION__, ohrc); free_bladehpi_hostlist(dev); return S_BADCONFIG; } if (ohupdate != ohdi.RptUpdateCount) { free_bladehpi_hostlist(dev); if(Debug){ LOG(PIL_DEBUG, "Looping through entries again," " count changed from %d to %d" , ohupdate, ohdi.RptUpdateCount); } goto try_again; } dev->ohrptcnt = ohupdate; return S_OK; }