Example #1
0
// find marker - search backwards for our marker,
// return it's off_t if found or 0 for none
off_t find_marker ( unsigned int fd, off_t call_offset /* start searching here backwards */ )
{
  unsigned char zzz [ AES_BLOCK_SIZE ];
  unsigned char buf [ AES_BLOCK_SIZE ];
  off_t offset = call_offset - AES_BLOCK_SIZE;

  memset(zzz,0,AES_BLOCK_SIZE);

  // a really stupid algorithm
  while ( offset > 0 ) {
    rw(mf_lseek,fd,offset,SEEK_SET);
    rw(mf_read,fd,buf,AES_BLOCK_SIZE);
    if ( 0 == memcmp(zzz,buf,AES_BLOCK_SIZE) ) {
      // found
      break;
    }
    offset -= 1;
  }

  if ( trace_flag ) {
    printf("%s: marker found at offset = %d\n",
	   __FUNCTION__,
	   (int)offset);
  }

  // done
  return offset;
}
Example #2
0
int			send_no_param(t_client *c, char *cmd, char *param)
{
  (void)param;
  if (rw(c->socket, cmd, strlen(cmd), W) == FAILURE)
    return (FAILURE);
  return (rw(c->socket, "\n", 1, W));
}
Example #3
0
	bool DeserializeScriptTo(ScriptObject& obj, const StringRef& data, const ISirenType& type, SirenCoderType coder /*= SirenCoderType::Compact*/)
	{
#ifdef MEDUSA_LUA
		SirenLuaWriter writer(obj);
#endif

		switch (coder)
		{
		case SirenCoderType::Compact:
		{
			StringStream stream(data);
			SirenCompactBinaryReader reader(stream);
			SirenReaderWriter rw(reader, writer);
			return rw.Run(type);
		}
		case SirenCoderType::Fast:
		{
			StringStream stream(data);
			SirenFastBinaryReader reader(stream);
			SirenReaderWriter rw(reader, writer);
			return rw.Run(type);

		}
		case SirenCoderType::Json:
		{
			StringStream stream(data);
			SirenJsonReader reader(stream);
			SirenReaderWriter rw(reader, writer);
			return rw.Run(type);
		}
		}
		return false;
	}
Example #4
0
 void add_ineq() {
     pb_util pb(m);
     expr_ref fml(m), tmp(m);
     th_rewriter rw(m);
     vector<rational> coeffs(vars.size());
     expr_ref_vector args(vars);
     while (true) {
         rational k(rand(6));
         for (unsigned i = 0; i < coeffs.size(); ++i) {
             int v = 3 - rand(5);
             coeffs[i] = rational(v);
             if (coeffs[i].is_neg()) {
                 args[i] = m.mk_not(args[i].get());
                 coeffs[i].neg();
                 k += coeffs[i];
             }
         }       
         fml = pb.mk_ge(args.size(), coeffs.c_ptr(), args.c_ptr(), k);
         rw(fml, tmp);
         rw(tmp, tmp);
         if (pb.is_ge(tmp)) {
             fml = tmp;
             break;
         }
     }
     std::cout << "(assert " << fml << ")\n";
     ctx.assert_expr(fml);
 }
Example #5
0
 expr_ref scaler::undo_k(expr* e, expr* k) {
     expr_safe_replace sub(m);
     th_rewriter rw(m);
     expr_ref result(e, m);
     sub.insert(k, a.mk_numeral(rational(1), false));
     sub(result);
     rw(result);
     return result;
 }
Example #6
0
 void operator()(goal_ref const & g,
                 goal_ref_buffer & result,
                 model_converter_ref & mc,
                 proof_converter_ref & pc,
                 expr_dependency_ref & core) override {
     mc = nullptr; pc = nullptr; core = nullptr;
     bool produce_proofs = g->proofs_enabled();
     tactic_report report("dt2bv", *g);
     unsigned   size = g->size();
     expr_fast_mark1 visited;
     check_fd proc(*this);
     for (unsigned i = 0; i < size; ++i) {
         quick_for_each_expr(proc, visited, g->form(i));
     }
     obj_hashtable<sort>::iterator it = m_non_fd_sorts.begin(), end = m_non_fd_sorts.end();
     for (; it != end; ++it) {
         m_fd_sorts.remove(*it);
     }
     if (!m_fd_sorts.empty()) {
         ref<extension_model_converter> ext = alloc(extension_model_converter, m);
         ref<filter_model_converter> filter = alloc(filter_model_converter, m);
         enum2bv_rewriter rw(m, m_params);
         rw.set_is_fd(&m_is_fd);            
         expr_ref   new_curr(m);
         proof_ref  new_pr(m);
         for (unsigned idx = 0; idx < size; idx++) {
             rw(g->form(idx), new_curr, new_pr);
             if (produce_proofs) {
                 proof * pr = g->pr(idx);
                 new_pr = m.mk_modus_ponens(pr, new_pr);
             }
             g->update(idx, new_curr, new_pr, g->dep(idx));
         }
         expr_ref_vector bounds(m);
         rw.flush_side_constraints(bounds);
         for (unsigned i = 0; i < bounds.size(); ++i) {
             g->assert_expr(bounds[i].get());
         }
         {
             obj_map<func_decl, func_decl*>::iterator it = rw.enum2bv().begin(), end = rw.enum2bv().end();
             for (; it != end; ++it) {
                 filter->insert(it->m_value);
             }
         }
         {
             obj_map<func_decl, expr*>::iterator it = rw.enum2def().begin(), end = rw.enum2def().end();
             for (; it != end; ++it) {
                 ext->insert(it->m_key, it->m_value);
             }
         }
         
         mc = concat(filter.get(), ext.get());
         report_tactic_progress(":fd-num-translated", rw.num_translated());
     }
     g->inc_depth();
     result.push_back(g.get());
     TRACE("dt2bv", g->display(tout););
Example #7
0
static Pos2 random_robot_pos2(const FieldGeometry *f) {
  std::uniform_real_distribution<Float> rx(
      -f->field_length / 2 + ROBOT_DIAM / 2,
      f->field_length / 2 + ROBOT_DIAM / 2);
  std::uniform_real_distribution<Float> ry(-f->field_width / 2 + ROBOT_DIAM / 2,
                                           f->field_width / 2 + ROBOT_DIAM / 2);
  std::uniform_real_distribution<Float> rw(-RAD(180), RAD(180));
  // return std::forward(rx(gen), ry(gen), rw(gen));
  return {rx(gen), ry(gen), rw(gen)};
}
Example #8
0
	HeapString SerializeScript(const ScriptObject& obj, const ISirenType& type, SirenCoderType coder/* = SirenCoderType::Compact*/)
	{

#ifdef MEDUSA_LUA
		SirenLuaReader reader(obj.State());
#endif

		switch (coder)
		{
		case SirenCoderType::Compact:
		{
			StringStream stream;
			SirenCompactBinaryWriter writer(stream);
			SirenReaderWriter rw(reader, writer);
			if (rw.Run(type))
			{
				return stream.CurrentBuffer();
			}
			return HeapString::Empty;
		}
		case SirenCoderType::Fast:
		{
			StringStream stream;
			SirenFastBinaryWriter writer(stream);
			SirenReaderWriter rw(reader, writer);
			if (rw.Run(type))
			{
				return stream.CurrentBuffer();
			}

			return HeapString::Empty;
		}
		case SirenCoderType::Json:
		{
			StringStream stream;
			SirenJsonWriter writer(stream);
			SirenReaderWriter rw(reader, writer);
			if (rw.Run(type))
			{
				return stream.CurrentBuffer();
			}

			return HeapString::Empty;
		}
		}

		return HeapString::Empty;
	}
Example #9
0
// http://www.nongnu.org/chmspec/latest/Internal.html#WINDOWS
void ChmDoc::ParseWindowsData() {
    size_t windowsLen, stringsLen;
    ScopedMem<unsigned char> windowsData(GetData("/#WINDOWS", &windowsLen));
    ScopedMem<unsigned char> stringsData(GetData("/#STRINGS", &stringsLen));
    if (!windowsData || !stringsData)
        return;
    if (windowsLen <= 8)
        return;

    ByteReader rw(windowsData, windowsLen);
    DWORD entries = rw.DWordLE(0);
    DWORD entrySize = rw.DWordLE(4);
    if (entrySize < 188)
        return;

    for (DWORD i = 0; i < entries && (i + 1) * entrySize <= windowsLen; i++) {
        DWORD off = 8 + i * entrySize;
        if (!title) {
            DWORD strOff = rw.DWordLE(off + 0x14);
            title.Set(GetCharZ(stringsData, stringsLen, strOff));
        }
        if (!tocPath) {
            DWORD strOff = rw.DWordLE(off + 0x60);
            tocPath.Set(GetCharZ(stringsData, stringsLen, strOff));
        }
        if (!indexPath) {
            DWORD strOff = rw.DWordLE(off + 0x64);
            indexPath.Set(GetCharZ(stringsData, stringsLen, strOff));
        }
        if (!homePath) {
            DWORD strOff = rw.DWordLE(off + 0x68);
            homePath.Set(GetCharZ(stringsData, stringsLen, strOff));
        }
    }
}
Example #10
0
void LoginWidget::on_toolButtonApplyForRegistration_clicked(){

    if(!checkServerAddress()){
        return;
    }


    QDialog dlg(this);
    QVBoxLayout vbl(&dlg);
    
    ApplyForRegistrationWidget rw(&dlg);
    connect(this, SIGNAL(signalRegistrationServerInfoReceived(quint8, bool, const QString &, quint8, const QString &, bool)), &rw, SLOT(slotProcessRegistrationServerInfo(quint8, bool, const QString &, quint8, const QString &, bool))/*, Qt::QueuedConnection*/);
    connect(this, SIGNAL(signalRegistrationResultReceived(quint8, quint32, const QString&)), &rw, SLOT(slotProcessRegistrationResult(quint8, quint32, const QString&))/*, Qt::QueuedConnection*/);
    //connect(&rw, SIGNAL(requestRegistrationServerInfo()), this, SIGNAL(requestRegistrationServerInfo())/*, Qt::QueuedConnection*/);
    connect(&rw, SIGNAL(registration()), this, SIGNAL(registration()));
    connect(&rw, SIGNAL(canceled()), &dlg, SLOT(accept()));

    vbl.addWidget(&rw);
    dlg.setLayout(&vbl);
    dlg.updateGeometry();
    dlg.setWindowTitle(tr("Registration"));

    emit requestRegistrationServerInfo();
    //QTimer::singleShot(5000, &rw, SLOT(requestRegistrationServerInfoTimeout()));


    dlg.exec();
    
}
void ElfSectionManager::AddSection(ElfSection & aSection){
	EnsureSectionStringTableSectionAdded();
	if (aSection.GetName().size() > 0){
		// rename sections for GDB (yuk!)
		String sectionName(aSection.GetName());
		String ro("ER_RO");
		String text(".text");
		if (sectionName == ro){
			sectionName = text;
		} else {
			String rw("ER_RW");
			String data(".data");
			if (sectionName == rw){
				sectionName = data;
			} else {
				String zi("ER_ZI");
				String bss(".bss");
				if (sectionName == zi)
					sectionName = bss;
			}
		}
		size_t nameOffset = iStringTable.AddName(sectionName);
		aSection.SetNameOffset(nameOffset);
	} else {
		// use the initial Null String.
		size_t nameOffset = iStringTable.AllocateInitialNullString();
		aSection.SetNameOffset(nameOffset);
	}
	aSection.SetIndex(iSections.size());
	iSections.push_back(aSection);
	iElf32Header.AddSectionHdr();
}
Example #12
0
	ScriptObject DeserializeScript(ScriptState& state, const StringRef& data, const ISirenType& type, SirenCoderType coder/* = SirenCoderType::Compact*/)
	{
#ifdef MEDUSA_LUA
		SirenLuaWriter writer(state.GetState());
#endif

		switch (coder)
		{
		case SirenCoderType::Compact:
		{
			StringStream stream(data);
			SirenCompactBinaryReader reader(stream);
			SirenReaderWriter rw(reader, writer);
			if (rw.Run(type))
			{
				return writer.ToObject();
			}

			return nullptr;
		}
		case SirenCoderType::Fast:
		{
			StringStream stream(data);
			SirenFastBinaryReader reader(stream);
			SirenReaderWriter rw(reader, writer);
			if (rw.Run(type))
			{
				return writer.ToObject();
			}
			return nullptr;

		}
		case SirenCoderType::Json:
		{
			StringStream stream(data);
			SirenJsonReader reader(stream);
			SirenReaderWriter rw(reader, writer);
			if (rw.Run(type))
			{
				return writer.ToObject();
			}
			return nullptr;
		}
		}
		return nullptr;
	}
static solver* mk_solver_for_logic(ast_manager & m, params_ref const & p, symbol const& logic) {
    bv_rewriter rw(m);
    if (logic == "QF_BV" && rw.hi_div0()) 
        return mk_inc_sat_solver(m, p);
    if (logic == "QF_FD") 
        return mk_fd_solver(m, p);
    return mk_smt_solver(m, p, logic);
}
Example #14
0
static solver* mk_solver_for_logic(ast_manager & m, params_ref const & p, symbol const& logic) {
    bv_rewriter rw(m);
    solver* s = mk_special_solver_for_logic(m, p, logic);
    if (!s && logic == "QF_BV" && rw.hi_div0()) 
        s = mk_inc_sat_solver(m, p);
    if (!s) 
        s = mk_smt_solver(m, p, logic);
    return s;
}
SimpleResource SimpleResourceSystem::alloc() {
    SimpleResource rw(RS_NULL_RESOURCE_CODE, &rs);
    rs_resource_code_t code;
    code = rs_alloc(&rs);
    if (code != RS_NULL_RESOURCE_CODE) {
        rw.setCode(code);
    }
    return rw;
}
Example #16
0
static ssize_t
kdi_prw(void *buf, size_t nbytes, physaddr_t addr, int (*rw)(caddr_t, size_t,
    physaddr_t, size_t *))
{
	size_t sz;
	int rc;

	kmdb_dpi_flush_slave_caches();
	if ((rc = rw(buf, nbytes, addr, &sz)) != 0)
		return (set_errno(rc));

	return (sz);
}
Example #17
0
void tst_expr_substitution() {
    memory::initialize(0);
    ast_manager m;
    reg_decl_plugins(m);
    bv_util bv(m);

    expr_ref a(m), b(m), c(m), d(m);
    expr_ref x(m);
    expr_ref   new_a(m);
    proof_ref  pr(m);
    x = m.mk_const(symbol("x"), bv.mk_sort(8));
    a = mk_bv_and(bv, mk_bv_xor(bv, x,bv.mk_numeral(8,8)), mk_bv_xor(bv,x,x));
    b = x;
    c = bv.mk_bv_sub(x, bv.mk_numeral(4, 8));

    expr_substitution subst(m);
    th_rewriter   rw(m);

    std::cout << mk_pp(c, m) << "\n";

    // normalizing c does not help.
    rw(c, d, pr);

    std::cout << mk_pp(d, m) << "\n";


// This portion diverges. It attempts to replace x by (bvadd #xfc x), which contains x.
//    subst.insert(b, d);

//    std::cout << mk_pp(a, m) << "\n";
//    rw.set_substitution(&subst);
   
//    enable_trace("th_rewriter_step");
//    rw(a, new_a, pr);

//    std::cout << mk_pp(new_a, m) << "\n";
    
}
Example #18
0
void tst_arith_rewriter() {
    ast_manager m;
    reg_decl_plugins(m);
    arith_rewriter ar(m);
    arith_util au(m);
    expr_ref t1(m), t2(m), result(m);
    t1 = au.mk_numeral(rational(0),false);
    t2 = au.mk_numeral(rational(-3),false);
    expr* args[2] = { t1, t2 };
    ar.mk_mul(2, args, result);
    std::cout << mk_pp(result, m) << "\n";

    
    th_rewriter rw(m);
    expr_ref fml = parse_fml(m, example1);
    rw(fml);
    std::cout << mk_pp(fml, m) << "\n";


    fml = parse_fml(m, example2);
    rw(fml);
    std::cout << mk_pp(fml, m) << "\n";
}
Example #19
0
File: main.cpp Project: Aroltd/rts
int main() {
	//sf::RenderWindow rw(sf::VideoMode::getDesktopMode(), "test", sf::Style::Fullscreen);
	sf::RenderWindow rw(sf::VideoMode(800, 800), "test");
	rw.setFramerateLimit(60);

	rts::Map gameMap(32);

	long mclk = 0;
	sf::Clock uclk;

	while(rw.isOpen()) {
        sf::Event event;
        while (rw.pollEvent(event)) {
            if (event.type == sf::Event::Closed)
                rw.close();
			if (event.type == sf::Event::Resized)
				rw.setSize(sf::Vector2u(event.size.width,event.size.height));
        }
		
		rw.clear();
		
		if(true) {
			if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W))
				gameMap.changeView(0,-4);

			if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S))
				gameMap.changeView(0,4);

			if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))
				gameMap.changeView(-4,0);

			if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D))
				gameMap.changeView(4,0);
		}

		sf::RectangleShape test(sf::Vector2f(400,400));
		test.setFillColor(sf::Color(0,0,0,0));
		test.setOutlineColor(sf::Color(255,255,255));
		test.setOutlineThickness(4);
		test.setPosition(200,200);

		gameMap.Render(&rw,200);
		rw.draw(test);

		rw.display();
	}
}
Example #20
0
vector<Chunk> processChunks(DataSource* ds,const char *path)
{
    const u_int64_t POLY = FINGERPRINT_PT;
    window rw(POLY);
    rabinpoly rp(POLY);

    BitwiseChunkBoundaryChecker chunkBoundaryChecker;
    PrintChunkProcessor chunkProcessor;
    vector<Chunk> chunk;

    int next;
    u_int64_t val = 0;
    //add a leading 1 to avoid the issue with rabin codes & leading 0s
    u_int64_t hash = 1;
    rw.slide8(1);

    unsigned int offset=0;
    while((next = ds->getByte()) != -1)
    {
        chunkProcessor.processByte(next);

        hash = rp.append8(hash, (char)next);
        val = rw.slide8((char)next);

        if( chunkBoundaryChecker.isBoundary(val, chunkProcessor.getSize()) )
        {

           // chunk.push_back(new Chunk(hash,offset,chunkProcessor.getSize(),path));
            Chunk chnk(hash,offset,chunkProcessor.getSize(),path);
            chunk.push_back(chnk);
            offset+=chunkProcessor.getSize();
            chunkProcessor.completeChunk(hash, val);

            hash = 1;
            rw.reset();
            rw.slide8(1);
        }

    }
   // chunk.push_back(new Chunk(hash,offset,chunkProcessor.getSize(),path));
    Chunk chnk(hash,offset,chunkProcessor.getSize(),path);
    chunk.push_back(chnk);
    chunkProcessor.completeChunk(hash, val);

    return chunk;
}
Example #21
0
    inline
    int gesvd (MatrA& a, VecS& s) {

#ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK 
      BOOST_STATIC_ASSERT((boost::is_same<
        typename traits::matrix_traits<MatrA>::matrix_structure, 
        traits::general_t
      >::value)); 
#endif 

      int const m = traits::matrix_size1 (a);
      int const n = traits::matrix_size2 (a);
      int const minmn = m < n ? m : n; 

      assert (minmn == traits::vector_size (s)); 

#ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
      typedef typename traits::matrix_traits<MatrA>::value_type val_t; 
#else 
      typedef typename MatrA::value_type val_t; 
#endif 
      typedef typename traits::type_traits<val_t>::real_type real_t;

      int const lw = gesvd_work ('O', 'N', 'N', a); 
      traits::detail::array<val_t> w (lw); 
      if (!w.valid()) return -101; 

      int const lrw = gesvd_rwork (a); 
      traits::detail::array<real_t> rw (lrw); 
      if (!rw.valid()) return -102; 

      int info; 
      detail::gesvd ('N', 'N', m, n, 
                     traits::matrix_storage (a), 
                     traits::leading_dimension (a),
                     traits::vector_storage (s),  
                     0, // traits::matrix_storage (u),
                     1, // traits::leading_dimension (u),
                     0, // traits::matrix_storage (vt),
                     1, // traits::leading_dimension (vt),
                     traits::vector_storage (w),  
                     traits::vector_size (w),  
                     traits::vector_storage (rw),  
                     &info);
      return info; 
    }
Example #22
0
methodOop oopFactory::new_method(int byte_code_size, AccessFlags access_flags,
                                 int compressed_line_number_size,
                                 int localvariable_table_length,
                                 int checked_exceptions_length,
                                 bool is_conc_safe,
                                 TRAPS) {
  methodKlass* mk = methodKlass::cast(Universe::methodKlassObj());
  assert(!access_flags.is_native() || byte_code_size == 0,
         "native methods should not contain byte codes");
  constMethodOop cm = new_constMethod(byte_code_size,
                                      compressed_line_number_size,
                                      localvariable_table_length,
                                      checked_exceptions_length,
                                      is_conc_safe, CHECK_NULL);
  constMethodHandle rw(THREAD, cm);
  return mk->allocate(rw, access_flags, CHECK_NULL);
}
Example #23
0
void K_Exp(uint8_t* pk) //The key expansion routine: Takes the 256-bit private key and expands it into 60 32-bit words that are stored in the array ek[]
{                       //The logic of this function is defined in the AES spec
    int i = 0;
    union {
        uint8_t bytes[4];
        uint32_t word;
    } temp __attribute__ ((aligned)); //Temp union will hold the word that is being processed
    union {
        uint8_t bytes[4];
        uint32_t word;
    } univar[60] __attribute__ ((aligned)); //Univar is the buffer that will hold the expanded key, it is loaded in 8-bit parts which is why the union is necessary

    for (i = 0; i < Nk; i++)
    {
        univar[i].bytes[3] = pk[i*4];
        univar[i].bytes[2] = pk[i*4+1];
        univar[i].bytes[1] = pk[i*4+2];
        univar[i].bytes[0] = pk[i*4+3];
    }

    for (i = Nk; i < Nb*(Nr+1); i++)
    {
        temp.word = univar[i-1].word;
        if (i % Nk == 0)
        {
            temp.word = (sw(rw(temp.word)));
            temp.bytes[3] = temp.bytes[3] ^ (Rcon[i/Nk]);
        }
        else if (Nk > 6 && i % Nk == 4)
        {
            temp.word = sw(temp.word);
        }
        if (i-4 % Nk == 0)
        {
            temp.word = sw(temp.word);
        }
        univar[i].word = univar[i-Nk].word ^ temp.word;
    }
    for (i = 0; i < 60; i++)
    {
        expanded_key[i] = univar[i].word; //Copy from the buffer into the global variable
    }
}
Example #24
0
void Sketch_Files::readXml(QString FileName)//Opens the sketch file
{
    if(FileName.contains(".xml")||FileName.contains(".skh"))
    {
         QFile fd(FileName);
         fd.open(QFile::ReadWrite);
         QXmlStreamReader rw(&fd);

         while(!rw.atEnd())
         {
            object = new Scene_Objects;
            if(rw.name()=="Type")//what type of object ex:line,rect...
            {
                QTextStream readline;
                QString str,subText;
                str=rw.readElementText();
                readline.setString(&str,QIODevice::ReadWrite);

                while(!readline.atEnd())
                {
                    readline>>subText;
                    if(subText.contains("Line"))
                        object->ObjectId=1;
                    if(subText.contains("Rectangle"))
                        object->ObjectId=2;
                    if(subText.contains("Ellipse"))
                        object->ObjectId=3;
                    if(subText.contains("RoundRect"))
                        object->ObjectId=5;
                }


            }

            if(rw.name()=="Dim")
            {
              parseText(rw.readElementText());
              object->print();
            }

            rw.readNext();
         }
Example #25
0
int			send_with_param(t_client *c, char *cmd, char *param)
{
  char			*msg;

  if (param == NULL)
    return (2);
  if ((msg = malloc(strlen(cmd) + strlen(param) + 3)) == NULL)
    return (my_perror(SYSCALL("malloc"), FAILURE));
  memset(msg, '\0', strlen(cmd) + strlen(param) + 3);
  strcpy(msg, cmd);
  msg[strlen(cmd)] = ' ';
  strcpy(&(msg[strlen(cmd) + 1]), param);
  msg[strlen(msg)] = '\n';
  if (rw(c->socket, msg, strlen(msg), W) == FAILURE)
    {
      free(msg);
      return (FAILURE);
    }
  free(msg);
  return (SUCCESS);
}
Example #26
0
rwops_ptr make_write_RWops(const std::string &path) {
	rwops_ptr rw(SDL_AllocRW(), &SDL_FreeRW);

	rw->size = &ofs_size;
	rw->seek = &ofs_seek;
	rw->read = &ofs_read;
	rw->write = &ofs_write;
	rw->close = &ofs_close;

	rw->type = write_type;

	scoped_ostream ofs = ostream_file(path);
	if(!ofs) {
		ERR_FS << "make_write_RWops: ostream_file returned NULL on " << path << '\n';
		rw.reset();
		return rw;
	}

	rw->hidden.unknown.data1 = ofs.release();

	return rw;
}
Example #27
0
LRESULT
CDeviceHostStatPage::OnWorkDone(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	// Stop the animation
	m_findHostsAnimate.Stop();
	m_findHostsAnimate.ShowWindow(SW_HIDE);

	// Fill the list view

	CString strBuffer;
	int size = m_hostInfoDataArray.GetSize();
	for (int i = 0; i < size; ++i)
	{
		HostInfoData& data = m_hostInfoDataArray[i];
		const NDAS_HOST_INFO* pHostInfo = &data.HostInfo;
		ACCESS_MASK access = data.Access;

		(void) pAddressString(
			strBuffer,
			&pHostInfo->LPXAddrs,
			&pHostInfo->IPV4Addrs);

		CString rw(MAKEINTRESOURCE(IDS_HOST_RW));
		CString ro(MAKEINTRESOURCE(IDS_HOST_RO));
		m_wndListView.AddItem(i, 0, (access & GENERIC_WRITE) ? rw : ro);
		m_wndListView.SetItemText(i, 1, pHostInfo->szHostname);
		m_wndListView.SetItemText(i, 2, strBuffer);
	}

	AdjustHeaderWidth(m_wndListView);

	m_wndRefreshLink.EnableWindow(TRUE);

	m_hCursor = AtlLoadSysCursor(IDC_ARROW);
	SetCursor(m_hCursor);

	return TRUE;
}
Example #28
0
/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
   interrupted.  Return the actual number of bytes read(written), zero for EOF,
   or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error.  */
size_t
safe_rw (int fd, void const *buf, size_t count)
{
  /* Work around a bug in Tru64 5.1.  Attempting to read more than
     INT_MAX bytes fails with errno == EINVAL.  See
     <http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
     When decreasing COUNT, keep it block-aligned.  */
  enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };

  for (;;)
    {
      ssize_t result = rw (fd, buf, count);

      if (0 <= result)
	return result;
      else if (IS_EINTR (errno))
	continue;
      else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
	count = BUGGY_READ_MAXIMUM;
      else
	return result;
    }
}
Example #29
0
File: rb.c Project: fdotli/libu
static int test_rw_fast_malloc (u_test_case_t *tc) { return rw(tc, 1, 1); }
Example #30
0
File: rb.c Project: fdotli/libu
static int test_rw_fast (u_test_case_t *tc) { return rw(tc, 0, 1); }