virtual InlineElement<string_type, string_adaptor>* createContainer(const string_type& namespaceURI, const string_type& localName, const string_type& qName, const SAX::Attributes<string_type, string_adaptor>& atts) { std::vector<InlineAttribute<string_type, string_adaptor> > inlineAtts; for(int i = 0; i != atts.getLength(); ++i) { if(string_adaptor::find(atts.getQName(i), SC::xmlns_colon) == 0) continue; if(atts.getURI(i) == StylesheetConstant<string_type, string_adaptor>::NamespaceURI) continue; if(!baseT::context().isRemapped(atts.getURI(i))) inlineAtts.push_back(InlineAttribute<string_type, string_adaptor>(atts.getQName(i), atts.getURI(i), baseT::context().xpath_attribute_value_template(atts.getValue(i)))); else { std::pair<string_type, string_type> remap = baseT::context().remappedNamespace(atts.getURI(i)); if(string_adaptor::empty(remap.first) && !string_adaptor::empty(remap.second)) remap.first = baseT::context().autoNamespacePrefix(); string_type name = makeName(remap.first, atts.getLocalName(i)); inlineAtts.push_back(InlineAttribute<string_type, string_adaptor>(name, remap.second, baseT::context().xpath_attribute_value_template(atts.getValue(i)))); } // if ... } // for ... if(!baseT::context().isRemapped(namespaceURI)) return new InlineElement<string_type, string_adaptor>(qName, namespaceURI, inlineAtts); const std::pair<string_type, string_type>& remap = baseT::context().remappedNamespace(namespaceURI); string_type name = makeName(remap.first, localName); return new InlineElement<string_type, string_adaptor>(name, remap.second, inlineAtts); } // createContainer
AUDMEncoder_Lavcodec::AUDMEncoder_Lavcodec(AUDMAudioFilter * instream) :AUDMEncoder (instream) { _context=NULL; printf("[Lavcodec] Creating Lavcodec audio encoder (0x%x)\n",makeName(WAV)); _wavheader->encoding=makeName(WAV); };
void MapLoader::loadMap(const std::string &name, u16 area, u16 x, u16 y, Tileset &tileset, ResourceHandler &handler) { XMLFile doc("data/maps/" + name + ".tmx"); XMLElement *mapElement = doc.FirstChildElement("map").ToElement(); u16 width = mapElement->IntAttribute("width"); u16 height = mapElement->IntAttribute("height"); std::vector<u16> data; XMLElement *tileElement = mapElement->FirstChildElement("layer")->FirstChildElement("data")->FirstChildElement("tile"); while(tileElement) { s16 tileID = tileElement->IntAttribute("gid") - 1; data.push_back((tileID >= 0) ? tileID : 0); tileElement = tileElement->NextSiblingElement("tile"); } Map &map = handler.add<Map>(makeName(area, x, y), area, x, y, width, height, tileset, data); for(u16 tileY = 0 ; tileY < height ; tileY++) { for(u16 tileX = 0 ; tileX < width ; tileX++) { u16 tileID = map.getTile(tileX, tileY); if(tileset.info()[tileID] == TilesInfos::TileType::GrassTile) { map.scene().addObject(GrassFactory::create(tileX, tileY)); } else if(tileset.info()[tileID] == TilesInfos::TileType::LowGrassTile) { map.scene().addObject(GrassFactory::create(tileX, tileY, true)); } } } SceneObjectLoader::load(name, map.scene()); }
Thread::Thread(): _id(uniqueId()), _name(makeName()), _pTLS(0), _event(true) { }
void adjustTreatment(int treatmentNumber, double treatment, int simNumber) { double thisXI[INIT_NUM_STYPES][INIT_NUM_STYPES]; for(int i = 0; i < INIT_NUM_STYPES; i++) { for(int j = 0; j < INIT_NUM_STYPES; j++) { thisXI[i][j] = 0; } } for(int i = 0; i < HFLU_INDEX; i++) { thisXI[i][i] = treatment; } thisXI[HFLU_INDEX][HFLU_INDEX] = HFLU_SIGMA; std::ofstream xiStream; std::string XIFile = makeName(treatmentNumber, simNumber, "XI"); xiStream.open("../../outputs/" + XIFile, std::ios::out); for(int i = 0; i < INIT_NUM_STYPES; i++) { for(int j = 0; j < INIT_NUM_STYPES; j++) { xiStream << thisXI[i][j]; if((j + 1) % INIT_NUM_STYPES == 0) { xiStream << std::endl; } else { xiStream << "\t"; } } } xiStream.close(); }
//________________________________________________ // Init lame encoder //_______________________________________________ uint8_t AUDMEncoder_Lavcodec::initialize(void) { int ret; _context=( void *)avcodec_alloc_context(); _wavheader->byterate=(lavConfig.bitrate*1000)>>3; #ifdef ADM_LAV_MP2 if( _incoming->getInfo()->channels>2) { printf("[Lavcodec]Too many channels\n"); return 0; } #endif _wavheader->byterate=(lavConfig.bitrate*1000)>>3; #ifdef ADM_LAV_MP2 _chunk = 1152*_wavheader->channels; #else _chunk = 1536*_wavheader->channels; // AC3 #endif printf("[Lavcodec]Incoming : fq : %lu, channel : %lu bitrate: %lu \n", _wavheader->frequency,_wavheader->channels,lavConfig.bitrate); CONTEXT->channels = _wavheader->channels; CONTEXT->sample_rate = _wavheader->frequency; CONTEXT->bit_rate = (lavConfig.bitrate*1000); // bits -> kbits AVCodec *codec; CodecID codecID; codecID=makeName(CODEC_ID); codec = avcodec_find_encoder(codecID); ADM_assert(codec); ret = avcodec_open(CONTEXT, codec); if (0> ret) { printf("[Lavcodec] init failed err : %d!\n",ret); return 0; } printf("[Lavcodec]Lavcodec successfully initialized,wavTag : 0x%x\n",makeName(WAV)); return 1; }
const char *spatialRobocodeParasiteDelta::getName() { if (!participates) { if (topLevel) { switch(humanrobot) { case 0: return "jk.sheldor.nano.Yatagan"; case 1: return "mld.LittleBlackBook"; case 2: return "mld.Moebius"; case 3: return "mld.jdc.nano.LittleBlackBook"; case 4: return "nat.nano.OcnirpSNG"; case 5: return "nz.jdc.nano.AralR"; case 6: return "nz.jdc.nano.AralT"; case 7: return "nz.jdc.nano.NeophytePRAL"; case 8: return "nz.jdc.nano.NeophytePattern"; case 9: return "nz.jdc.nano.NeophyteSRAL"; case 10: return "nz.jdc.nano.PatternAdept"; case 11: return "nz.jdc.nano.PralDeGuerre"; case 12: return "oog.nano.Caligula"; case 13: return "oog.nano.Fuatisha"; case 14: return "robar.nano.BlackWidow"; case 15: return "robar.nano.Pugio"; case 16: return "sheldor.nano.Sabreur"; case 17: return "simonton.nano.WeekendObsession_S"; case 18: return "fromHell.C22H30N2O2S"; default: return "wompi.Kowari"; } } else { switch(humanrobot) { case 0: return "supersample.SuperBoxBot"; case 1: return "supersample.SuperCorners"; case 2: return "supersample.SuperCrazy"; case 3: return "supersample.SuperMercutio"; case 4: return "supersample.SuperRamFire"; case 5: return "supersample.SuperSpinBot"; case 6: return "supersample.SuperTracker"; case 7: return "supersample.SuperTrackFire"; case 8: return "supersample.SuperWalls"; case 9: return "supersample.SuperBoxBot"; case 10: return "blir.nano.Cabbage"; case 11: return "sgp.nano.FurryLeech"; case 12: return "pez.nano.LittleEvilBrother"; case 13: return "NG.LegatusLegionis"; case 14: return "projectx.ProjectNano"; case 15: /*return "bots.UberBot";*/ case 16: return "dggp.haiku.gpBot_0"; case 17: return "zyx.nano.RedBull"; case 18: return "zyx.nano.Ant"; case 19: return "stelo.MirrorNano"; default: return "supersample.SuperWalls"; } } } else { makeName(thisParasiteDeltaNumber,false); return javaPName; } }
mach_port_t Bootstrap::lookupOptional(const char *name) const { mach_port_t port; kern_return_t err = ::bootstrap_look_up(mPort, makeName(name), &port); if (err == BOOTSTRAP_UNKNOWN_SERVICE) return 0; check(err); return port; }
const String NameManager::makeCreatureName(int type) { String name; if (type == NameManagerType::STORMTROOPER || type == NameManagerType::STORMTROOPER_TAG || type == NameManagerType::SCOUTTROOPER || type == NameManagerType::SCOUTTROOPER_TAG ||type == NameManagerType::DARKTROOPER || type == NameManagerType::DARKTROOPER_TAG || type == NameManagerType::SWAMPTROOPER || type == NameManagerType::SWAMPTROOPER_TAG) { name = makeImperialTrooperName(type); } else { name = makeName(3 + System::random(6)); if (type == NameManagerType::GENERIC || type == NameManagerType::GENERIC_TAG) { name += " "; name += makeName(3 + System::random(6)); } } return name; }
/** \fn AUDMEncoder_Lavcodec */ AUDMEncoder_Lavcodec::AUDMEncoder_Lavcodec(AUDMAudioFilter * instream,bool globalHeader, CONFcouple *setup) :ADM_AudioEncoder (instream,setup) { _context=NULL; _globalHeader=globalHeader; printf("[Lavcodec] Creating Lavcodec audio encoder (0x%x)\n",makeName(WAV)); #if defined(ADM_LAV_GLOBAL_HEADER) // Only AAC ? if(globalHeader) _globalHeader=true; else #endif _globalHeader=false; wavheader.encoding=makeName(WAV); // Default config _config=defaultConfig; if(setup) // load config if possible ADM_paramLoad(setup,lav_encoder_param,&_config); };
mach_port_t Bootstrap::checkInOptional(const char *name) const { mach_port_t port; switch (kern_return_t err = ::bootstrap_check_in(mPort, makeName(name), &port)) { case BOOTSTRAP_SERVICE_ACTIVE: case BOOTSTRAP_UNKNOWN_SERVICE: case BOOTSTRAP_NOT_PRIVILEGED: return MACH_PORT_NULL; default: check(err); } return port; }
AST_expr* remapBoolOp(AST_BoolOp* node) { std::string name = nodeName(node); CFGBlock *starting_block = curblock; CFGBlock *exit_block = cfg->addDeferredBlock(); for (int i = 0; i < node->values.size() - 1; i++) { AST_expr* val = remapExpr(node->values[i]); push_back(makeAssign(name, val)); AST_Branch *br = new AST_Branch(); br->test = val; push_back(br); CFGBlock *was_block = curblock; CFGBlock *next_block = cfg->addBlock(); CFGBlock *crit_break_block = cfg->addBlock(); was_block->connectTo(next_block); was_block->connectTo(crit_break_block); if (node->op_type == AST_TYPE::Or) { br->iftrue = crit_break_block; br->iffalse = next_block; } else { br->iffalse = crit_break_block; br->iftrue = next_block; } curblock = crit_break_block; AST_Jump* j = new AST_Jump(); j->target = exit_block; push_back(j); crit_break_block->connectTo(exit_block); curblock = next_block; } AST_expr* final_val = remapExpr(node->values[node->values.size()-1]); push_back(makeAssign(name, final_val)); AST_Jump* j = new AST_Jump(); push_back(j); j->target = exit_block; curblock->connectTo(exit_block); cfg->placeBlock(exit_block); curblock = exit_block; return makeName(name, AST_TYPE::Load); }
// Constructor. SetComponentCommand::SetComponentCommand(beCore::ReflectedComponent *pReflectedComponent, uint4 componentIdx, const lean::any &component, beCore::ComponentMonitor *pComponentMonitor, QUndoCommand *pParent) : QUndoCommand( QCoreApplication::translate("SetComponentCommand", "Replaced component '%1'").arg( makeName(toQt( LEAN_ASSERT_NOT_NULL(pReflectedComponent)->GetComponentName(componentIdx) )) ), pParent ), m_pReflectedComponent( LEAN_ASSERT_NOT_NULL(pReflectedComponent) ), m_componentIdx( componentIdx ), m_previousComponent( *pReflectedComponent->GetComponent(m_componentIdx) ), m_component( component ), m_pComponentMonitor( pComponentMonitor ) { }
// Constructor. ChangePropertyCommand::ChangePropertyCommand(beCore::PropertyProvider *pPropertyProvider, uint4 propertyID, QUndoCommand *pParent) : QUndoCommand( QCoreApplication::translate("ChangePropertyCommand", "Changed property '%1'").arg( makeName(toQt( LEAN_ASSERT_NOT_NULL(pPropertyProvider)->GetPropertyName(propertyID) )) ), pParent ), m_pPropertyProvider( LEAN_ASSERT_NOT_NULL(pPropertyProvider) ), m_propertyID( propertyID ), m_previousData( createPropertyData(*m_pPropertyProvider, m_propertyID), lean::consume ), m_data( createPropertyData(*m_pPropertyProvider, m_propertyID), lean::consume ), m_bIgnoreOnce(false) { m_pPropertyProvider->GetProperty(m_propertyID, m_previousData.property_type().type_info().type, m_previousData.data(), m_previousData.count()); m_pPropertyProvider->GetProperty(m_propertyID, m_data.property_type().type_info().type, m_data.data(), m_data.count()); }
AST_expr* remapIfExp(AST_IfExp* node) { std::string rtn_name = nodeName(node); AST_expr* test = remapExpr(node->test); CFGBlock *starting_block = curblock; AST_Branch *br = new AST_Branch(); br->col_offset = node->col_offset; br->lineno = node->lineno; br->test = node->test; push_back(br); CFGBlock* iftrue = cfg->addBlock(); iftrue->info = "iftrue"; br->iftrue = iftrue; starting_block->connectTo(iftrue); curblock = iftrue; push_back(makeAssign(rtn_name, remapExpr(node->body))); AST_Jump* jtrue = new AST_Jump(); push_back(jtrue); CFGBlock* endtrue = curblock; CFGBlock* iffalse = cfg->addBlock(); iffalse->info = "iffalse"; br->iffalse = iffalse; starting_block->connectTo(iffalse); curblock = iffalse; push_back(makeAssign(rtn_name, remapExpr(node->orelse))); AST_Jump* jfalse = new AST_Jump(); push_back(jfalse); CFGBlock* endfalse = curblock; CFGBlock* exit_block = cfg->addBlock(); jtrue->target = exit_block; endtrue->connectTo(exit_block); jfalse->target = exit_block; endfalse->connectTo(exit_block); curblock = exit_block; return makeName(rtn_name, AST_TYPE::Load); }
FontPtr makeFont(void) { FontPtr font; font = malloc(sizeof(FontRec)); if(font == NULL) return NULL; font->numNames = 0; font->names = NULL; font->flags = 0; font->weight = 500; font->width = 5; font->italicAngle = 0; font->underlinePosition = - TWO_SIXTEENTH; font->underlineThickness = TWO_SIXTEENTH; font->foundry = makeName("UNKN"); font->strikes = NULL; return font; }
/** \fn initialize */ bool AUDMEncoder_Lavcodec::initialize(void) { int ret; if( _incoming->getInfo()->channels>ADM_LAV_MAX_CHANNEL) { ADM_error("[Lavcodec]Too many channels\n"); return 0; } AVCodec *codec; AVCodecID codecID; codecID=avMakeName; codec = avcodec_find_encoder(codecID); ADM_assert(codec); _context=( void *)avcodec_alloc_context3(codec); _frame=av_frame_alloc(); wavheader.byterate=(_config.bitrate*1000)>>3; _chunk = ADM_LAV_SAMPLE_PER_P*wavheader.channels; // AC3 planarBuffer=new float[_chunk]; planarBufferSize=_chunk; ADM_info("[Lavcodec]Incoming : fq : %" PRIu32", channel : %" PRIu32" bitrate: %" PRIu32" \n", wavheader.frequency,wavheader.channels,_config.bitrate); if(wavheader.channels>2) { ADM_warning("Channel remapping activated\n"); needChannelRemapping=true; } else needChannelRemapping=false; CONTEXT->channels = wavheader.channels; CONTEXT->sample_rate = wavheader.frequency; CONTEXT->bit_rate = (_config.bitrate*1000); // bits -> kbits CONTEXT->sample_fmt = AV_SAMPLE_FMT_FLT; CONTEXT->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; CONTEXT->frame_size=_chunk/wavheader.channels; CONTEXT->channel_layout=av_get_default_channel_layout(wavheader.channels); if(true==_globalHeader) { ADM_info("Configuring audio codec to use global headers\n"); CONTEXT->flags|=CODEC_FLAG_GLOBAL_HEADER; } computeChannelLayout(); CONTEXT->sample_fmt = AV_SAMPLE_FMT_FLTP; ret = avcodec_open2(CONTEXT, codec,NULL); if (ret<0) { CONTEXT->sample_fmt=AV_SAMPLE_FMT_S16; ret = avcodec_open2(CONTEXT, codec,NULL); if (ret<0) { printError("Init failed",ret); return 0; } } //ADM_info("Frame size : %d, %d\n",CONTEXT->frame_size,_chunk/wavheader.channels); _frame->format=CONTEXT->sample_fmt; outputFlavor=asFloatPlanar; ADM_info("[Lavcodec]Lavcodec successfully initialized,wavTag : 0x%x\n",makeName(WAV)); return 1; }
/** \fn initialize */ bool AUDMEncoder_Lavcodec::initialize(void) { int ret; _context=( void *)avcodec_alloc_context(); _useFloat=true; if( _incoming->getInfo()->channels>ADM_LAV_MAX_CHANNEL) { ADM_error("[Lavcodec]Too many channels\n"); return 0; } wavheader.byterate=(_config.bitrate*1000)>>3; _chunk = ADM_LAV_SAMPLE_PER_P*wavheader.channels; // AC3 ADM_info("[Lavcodec]Incoming : fq : %"PRIu32", channel : %"PRIu32" bitrate: %"PRIu32" \n", wavheader.frequency,wavheader.channels,_config.bitrate); CONTEXT->channels = wavheader.channels; CONTEXT->sample_rate = wavheader.frequency; CONTEXT->bit_rate = (_config.bitrate*1000); // bits -> kbits CONTEXT->sample_fmt = AV_SAMPLE_FMT_FLT; CONTEXT->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; if(true==_globalHeader) { ADM_info("Configuring audio codec to use global headers\n"); CONTEXT->flags|=CODEC_FLAG_GLOBAL_HEADER; } AVCodec *codec; CodecID codecID; codecID=makeName(CODEC_ID); codec = avcodec_find_encoder(codecID); ADM_assert(codec); // Try float... ret = avcodec_open(CONTEXT, codec); if (0> ret) { char er[256]={0}; av_strerror(ret, er, sizeof(er)); ADM_info("[Lavcodec] init failed err : %d %s!\n",ret,er); ADM_info("Float failed, retrying with int16\n"); CONTEXT->sample_fmt = AV_SAMPLE_FMT_S16; ret = avcodec_open(CONTEXT, codec); if (0> ret) { char er[256]={0}; av_strerror(ret, er, sizeof(er)); ADM_error("[Lavcodec] init failed err : %d %s!\n",ret,er); ADM_info("s16 failed\n"); return 0; } _useFloat=false; ADM_info("Using int16 samples\n"); }else { _useFloat=true; ADM_info("Using float samples\n"); } ADM_info("[Lavcodec]Lavcodec successfully initialized,wavTag : 0x%x\n",makeName(WAV)); return 1; }
static void getDefaultConfiguration(CONFcouple **c); /********************* Declare Plugin *****************************************************/ ADM_DECLARE_AUDIO_ENCODER_PREAMBLE(AUDMEncoder_Lavcodec); static ADM_audioEncoder encoderDesc = { ADM_AUDIO_ENCODER_API_VERSION, create, // Defined by macro automatically destroy, // Defined by macro automatically configure, //** put your own function here** ADM_LAV_NAME, ADM_LAV_MENU, ADM_LAV_DESC, ADM_LAV_MAX_CHANNEL, ADM_LAV_VERSION, makeName(WAV), 100, // Priority NULL, //** put your own function here** getDefaultConfiguration, NULL }; ADM_DECLARE_AUDIO_ENCODER_CONFIG(); /******************* / Declare plugin*******************************************************/ #define CONTEXT ((AVCodecContext *)_context) /** \fn AUDMEncoder_Lavcodec */
Thread::Thread(): _id(uniqueId()), _name(makeName()), _pTLS(0) { }
void Object::setName(string n) { name = makeName(n); }
unsigned faceFoundry(FT_Face face) { int rc; BDF_PropertyRec prop; rc = FT_Get_BDF_Property(face, "FOUNDRY", &prop); if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) { if(strcasecmp(prop.u.atom, "adobe") == 0) return makeName("ADBE"); else if(strcasecmp(prop.u.atom, "agfa") == 0) return makeName("AGFA"); else if(strcasecmp(prop.u.atom, "altsys") == 0) return makeName("ALTS"); else if(strcasecmp(prop.u.atom, "apple") == 0) return makeName("APPL"); else if(strcasecmp(prop.u.atom, "arphic") == 0) return makeName("ARPH"); else if(strcasecmp(prop.u.atom, "alltype") == 0) return makeName("ATEC"); else if(strcasecmp(prop.u.atom, "b&h") == 0) return makeName("B&H "); else if(strcasecmp(prop.u.atom, "bitstream") == 0) return makeName("BITS"); else if(strcasecmp(prop.u.atom, "dynalab") == 0) return makeName("DYNA"); else if(strcasecmp(prop.u.atom, "ibm") == 0) return makeName("IBM "); else if(strcasecmp(prop.u.atom, "itc") == 0) return makeName("ITC "); else if(strcasecmp(prop.u.atom, "interleaf") == 0) return makeName("LEAF"); else if(strcasecmp(prop.u.atom, "impress") == 0) return makeName("IMPR"); else if(strcasecmp(prop.u.atom, "larabiefonts") == 0) return makeName("LARA"); else if(strcasecmp(prop.u.atom, "linotype") == 0) return makeName("LINO"); else if(strcasecmp(prop.u.atom, "monotype") == 0) return makeName("MT "); else if(strcasecmp(prop.u.atom, "microsoft") == 0) return makeName("MS "); else if(strcasecmp(prop.u.atom, "urw") == 0) return makeName("URW "); else if(strcasecmp(prop.u.atom, "y&y") == 0) return makeName("Y&Y "); else return makeName("UNKN"); } /* For now */ return makeName("UNKN"); }
mach_port_t Bootstrap::lookup(const char *name) const { mach_port_t port; check(::bootstrap_look_up(mPort, makeName(name), &port)); return port; }
void main( int argc, char **argv ) { samp_header header; samp_code_load code_load; samp_block_prefix prefix; unsigned adjust; unsigned len; fpos_t header_position; fpos_t curr_position; fpos_t last_position; fpos_t start_position; fpos_t end_position; struct stat file_status; int st; long bias=0; int num_samps; int samp_count; samp_address sample; uint_16 thread_id; if( argc == 4 && ( argv[1][0] == '-' || argv[1][0] == '/' ) && argv[1][1] == 'b' ) { sscanf( &argv[1][2], "%lx", &bias ); /* read in bias offset */ makeName( argv[2], ".SMP", sample_file ); makeName( argv[3], ".EXE", exe_file ); } else if( argc == 3 ) { makeName( argv[1], ".SMP", sample_file ); makeName( argv[2], ".EXE", exe_file ); } else { puts( "usage: SMPSYNC { -b<offset bias> } <sample_file> <exe_file>" ); puts( "where: <offset bias> is the hexadecimal offset" ); puts( " <sample_file> and <exe_file> are absolute file names" ); puts( " (not relative)" ); exit( 1 ); } puts( "WATCOM Sample File Synchronization Utility Version 1.0" ); puts( "Copyright by WATCOM Systems Inc. 1989, 1992. All rights reserved." ); puts( "WATCOM is a trademark of WATCOM Systems Inc.\n" ); _splitpath( sample_file, drive, dir, NULL, NULL ); _makepath( new_file, drive, dir, OUTPUT_NAME, ".SMP" ); makeName( new_file, ".SMP", new_file ); sfp = fopen( sample_file, "rb" ); if( sfp == NULL ) { quit( "cannot open sample file" ); } tfp = fopen( new_file, "wb" ); if( tfp == NULL ) { quit( "cannot open output file" ); } st = fgetpos( sfp, &start_position ); check( st == 0 ); st = fseek( sfp, - (int) sizeof( header ), SEEK_END ); check( st == 0 ); st = fgetpos( sfp, &header_position ); check( st == 0 ); st = fread( &header, sizeof( header ), 1, sfp ); check( st == 1 ); if( header.signature != SAMP_SIGNATURE ) { quit( "invalid sample file" ); } printf("executable file: %s\n", exe_file ); printf("sample file: %s\n", sample_file ); printf("sample file version: %u.%u\n", header.major_ver, header.minor_ver ); printf("new sample file: " OUTPUT_NAME ".SMP\n" ); st = fseek( sfp, header.sample_start, SEEK_SET ); check( st == 0 ); st = fgetpos( sfp, &curr_position ); check( st == 0 ); transferUpTo( start_position, curr_position ); do { last_position = curr_position; st = fread( &prefix, sizeof( prefix ), 1, sfp ); if( prefix.kind == SAMP_MAIN_LOAD ) { st = fread( &code_load, sizeof( code_load ) - 1, 1, sfp ); check( st == 1 ); adjust = sizeof( prefix ) + ( sizeof( code_load ) - 1 ); st = fseek( sfp, prefix.length - adjust, SEEK_CUR ); check( st == 0 ); st = fgetpos( sfp, &curr_position ); check( st == 0 ); st = stat( exe_file, &file_status ); check( st == 0 ); code_load.time_stamp = file_status.st_mtime; len = strlen( exe_file ) + 1; prefix.length = len + sizeof( prefix ) + (sizeof( code_load ) - 1); st = fwrite( &prefix, sizeof( prefix ), 1, tfp ); check( st == 1 ); st = fwrite( &code_load, sizeof( code_load ) - 1, 1, tfp ); check( st == 1 ); st = fwrite( exe_file, len, 1, tfp ); check( st == 1 ); } else if( prefix.kind == SAMP_SAMPLES ) { /* write prefix & thread_id: they're unchanged */ st = fwrite( &prefix, sizeof( prefix ), 1, tfp ); check( st == 1 ); st = fread( &thread_id, sizeof( thread_id ), 1, sfp ); check( st == 1 ); st = fwrite( &thread_id, sizeof( thread_id ), 1, tfp ); check( st == 1 ); /* compute number of samples to modify */ num_samps = ( prefix.length - sizeof(prefix) - sizeof(uint_16) ) / sizeof( samp_address ); for( samp_count = 0; samp_count < num_samps; samp_count++ ) { /* modify sample addresses according to given bias */ st = fread( &sample, sizeof( samp_address ), 1, sfp ); check( st == 1 ); sample.offset += bias; st = fwrite( &sample, sizeof( samp_address ), 1, tfp ); check( st == 1 ); } /* reset curr_position */ st = fgetpos( sfp, &curr_position ); check( st == 0 ); } else if( prefix.kind == SAMP_MARK ) { /* write prefix: it's unchanged */ st = fwrite( &prefix, sizeof( prefix ), 1, tfp ); check( st == 1 ); /* modify mark address according to given bias */ st = fread( &sample, sizeof( samp_address ), 1, sfp ); check( st == 1 ); sample.offset += bias; st = fwrite( &sample, sizeof( samp_address ), 1, tfp ); check( st == 1 ); /* copy over remaining information & update curr_position */ st = fseek( sfp, prefix.length-sizeof(samp_block_prefix) - sizeof(samp_address), SEEK_CUR); check( st == 0 ); st = fgetpos( sfp, &curr_position ); check( st == 0 ); transferUpTo( last_position, curr_position ); } else if( prefix.kind == SAMP_ADDR_MAP ) { /* write prefix: it's unchanged */ st = fwrite( &prefix, sizeof( prefix ), 1, tfp ); check( st == 1 ); /* compute number of sample addresses to modify */ num_samps = ( prefix.length - sizeof(prefix) ) / sizeof(mapping); for( samp_count = 0; samp_count < num_samps; samp_count++ ) { /* skip over mapped address ... */ st = fread( &sample, sizeof( samp_address ), 1, sfp ); check( st == 1 ); st = fwrite( &sample, sizeof( samp_address ), 1, tfp ); check( st == 1 ); /* ... and modify actual address */ st = fread( &sample, sizeof( samp_address ), 1, sfp ); check( st == 1 ); sample.offset += bias; st = fwrite( &sample, sizeof( samp_address ), 1, tfp ); check( st == 1 ); } /* reset curr_position */ st = fgetpos( sfp, &curr_position ); check( st == 0 ); } else { st = fseek( sfp, prefix.length-sizeof(samp_block_prefix), SEEK_CUR); check( st == 0 ); st = fgetpos( sfp, &curr_position ); check( st == 0 ); transferUpTo( last_position, curr_position ); } } while( curr_position != header_position ); st = fseek( sfp, 0, SEEK_END ); check( st == 0 ); st = fgetpos( sfp, &end_position ); check( st == 0 ); transferUpTo( header_position, end_position ); st = fclose( tfp ); check( st == 0 ); st = fclose( sfp ); check( st == 0 ); exit( 0 ); }
YY_ACTION(void) yy_2_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_2_primary\n")); Node *name= makeName(findRule(yytext)); name->name.variable= pop(); push(name); ; }
YY_ACTION(void) yy_3_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_3_primary\n")); push(makeName(findRule(yytext))); ; }
YY_ACTION(void) yy_3_primary(char *yytext, int yyleng) { yyprintf((stderr, "do yy_3_primary\n")); push(makeName(findRule(yytext))); ; }
mach_port_t Bootstrap::lookup2(const char *name) const { mach_port_t port; check(::bootstrap_look_up2(mPort, makeName(name), &port, 0, BOOTSTRAP_PRIVILEGED_SERVER)); return port; }
YY_ACTION(void) yy_2_primary(char *yytext, int yyleng) { yyprintf((stderr, "do yy_2_primary\n")); Node *name= makeName(findRule(yytext)); name->name.variable= pop(); push(name); ; }
int main (int argc, char *argv[]) { #if START_DAEMON struct GNUNET_OS_Process *daemon; #endif int ok; struct GNUNET_ECRS_URI *uri; char *filename = NULL; char *keywords[] = { "fsui_foo", "fsui_bar", }; char keyword[40]; char *fn; int prog; struct GNUNET_MetaData *meta; struct GNUNET_ECRS_URI *kuri; struct GNUNET_GC_Configuration *cfg; struct GNUNET_FSUI_UploadList *upload = NULL; struct GNUNET_FSUI_SearchList *search = NULL; struct GNUNET_FSUI_UnindexList *unindex = NULL; struct GNUNET_FSUI_DownloadList *download = NULL; cfg = GNUNET_GC_create (); if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf")) { GNUNET_GC_free (cfg); return -1; } #if START_DAEMON daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO); GNUNET_GE_ASSERT (NULL, daemon != NULL); CHECK (GNUNET_OK == GNUNET_wait_for_daemon_running (NULL, cfg, 60 * GNUNET_CRON_SECONDS)); #endif GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to start */ ok = GNUNET_YES; /* ACTUAL TEST CODE */ ctx = GNUNET_FSUI_start (NULL, cfg, "basic_fsui_test", 32, /* thread pool size */ GNUNET_NO, /* no resume */ &eventCallback, NULL); CHECK (ctx != NULL); filename = makeName (42); GNUNET_disk_file_write (NULL, filename, "foo bar test!", strlen ("foo bar test!"), "600"); meta = GNUNET_meta_data_create (); kuri = GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2, (const char **) keywords); /* upload */ upload = GNUNET_FSUI_upload_start (ctx, filename, (GNUNET_FSUI_DirectoryScanCallback) & GNUNET_disk_directory_scan, NULL, 0, /* anonymity */ 0, /* priority */ GNUNET_YES, GNUNET_NO, GNUNET_NO, GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, meta, kuri, kuri); CHECK (upload != NULL); GNUNET_ECRS_uri_destroy (kuri); GNUNET_meta_data_destroy (meta); prog = 0; while (lastEvent != GNUNET_FSUI_upload_completed) { prog++; CHECK (prog < 10000) GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS); if (GNUNET_shutdown_test () == GNUNET_YES) break; } /* search */ GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0], keywords[1]); uri = GNUNET_ECRS_keyword_string_to_uri (NULL, keyword); search = GNUNET_FSUI_search_start (ctx, 0, uri); GNUNET_ECRS_uri_destroy (uri); CHECK (search != NULL); prog = 0; while (lastEvent != GNUNET_FSUI_search_result) { prog++; CHECK (prog < 10000); GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS); if (GNUNET_shutdown_test () == GNUNET_YES) break; } GNUNET_FSUI_search_abort (search); GNUNET_FSUI_search_stop (search); /* download */ fn = makeName (43); download = GNUNET_FSUI_download_start (ctx, 0, GNUNET_NO, search_uri, search_meta, fn, NULL, NULL); GNUNET_free (fn); prog = 0; while (lastEvent != GNUNET_FSUI_download_completed) { prog++; CHECK (prog < 10000); GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS); if (GNUNET_shutdown_test () == GNUNET_YES) break; } GNUNET_FSUI_download_stop (download); download = NULL; GNUNET_ECRS_uri_destroy (search_uri); GNUNET_meta_data_destroy (search_meta); /* unindex */ unindex = GNUNET_FSUI_unindex_start (ctx, filename); prog = 0; while (lastEvent != GNUNET_FSUI_unindex_completed) { prog++; CHECK (prog < 10000); GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS); if (GNUNET_shutdown_test () == GNUNET_YES) break; } if (lastEvent != GNUNET_FSUI_unindex_completed) GNUNET_FSUI_unindex_abort (unindex); GNUNET_FSUI_unindex_stop (unindex); /* END OF TEST CODE */ FAILURE: if (ctx != NULL) GNUNET_FSUI_stop (ctx); if (filename != NULL) { UNLINK (filename); GNUNET_free (filename); } if (download != NULL) { GNUNET_FSUI_download_abort (download); GNUNET_FSUI_download_stop (download); } filename = makeName (43); /* TODO: verify file 'filename(42)' == file 'filename(43)' */ UNLINK (filename); GNUNET_free (filename); #if START_DAEMON GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon)); GNUNET_OS_process_destroy (daemon); #endif GNUNET_GC_free (cfg); return (ok == GNUNET_YES) ? 0 : 1; }