void 
UpdateTrafficCostRequestPacket::init()
{
   writeLong(m_allcostspos, 0);
   writeLong(m_nbrcostspos, 0);
   setLength(m_firstcostpos);
}
Beispiel #2
0
void chunkArchive::newStream(unsigned long magic)
{
	VALIDF;
	F->seek(0);
	writeLong(CHNK_MAGIC);	// CHNK
	writeLong(magic);
}
//-----------------------------------------------------------------------------
void Tes4SubRecordXCLCCELL::writeFile(FILE* pFile)
{
	writeString4(_name, pFile);
	writeUShort4(_size, pFile);
	writeLong   (_x,    pFile);
	writeLong   (_y,    pFile);
}
auto R65816::op_write_longr_w(Reg16& idx) {
  aa.l = readPC();
  aa.h = readPC();
  aa.b = readPC();
  writeLong(aa.d + idx + 0, r.a.l);
L writeLong(aa.d + idx + 1, r.a.h);
}
Beispiel #5
0
//---------------------------------------------------------------------------
void PacketFile::reserve(int32_t count, bool useCheckSum)
{
	//---------------------------------------------------
	// If we already have packets, reserve does nothing.
	// Otherwise, reserve sets up the file.  Must be
	// called before any writing to a newly created file.
	if(numPackets)
	{
		return;
	}
	usesCheckSum = useCheckSum;
	numPackets = count;
	int32_t firstPacketOffset = TABLE_ENTRY(numPackets);
	writeLong(PACKET_FILE_VERSION);
	writeLong(firstPacketOffset);
	//----------------------------
	// initialize the seek table
	while(count-- > 0)
		writeLong(SetPacketType(firstPacketOffset, STORAGE_TYPE_NUL));
	//-------------------------------------------------------------
	// If we called this, chances are we are writing a packet file
	// from start to finish.  It is MUCH faster if this table is
	// updated in memory and flushed when the file is closed.
	if(!seekTable)
	{
		seekTable = (int32_t*)systemHeap->Malloc(numPackets * sizeof(int32_t));
		if(seekTable != nullptr)
		{
			seek(sizeof(int32_t) * 2);							//File Version & File Length
			read(puint8_t(seekTable), (numPackets * sizeof(int32_t)));
		}
	}
}
Beispiel #6
0
void writeTypedListElement( TAThread thread, const TypedListElement * value ) {
    const int * start;
    switch ( value->type ) {
        case IntTObjCode    : writeString( thread, "IntTObj"     ); writeInt   ( thread, value->data.IntTObj     ); break;
        case CharTObjCode   : writeString( thread, "CharTObj"    ); writeChar  ( thread, value->data.CharTObj    ); break;
        case ShortTObjCode  : writeString( thread, "ShortTObj"   ); writeShort ( thread, value->data.ShortTObj   ); break;
        case LongTObjCode   : writeString( thread, "LongTObj"    ); writeLong  ( thread, value->data.LongTObj    ); break;
        case LLongTObjCode  : writeString( thread, "LLongTObj"   ); writeLLong ( thread, value->data.LLongTObj   ); break;
        case IntMaxTObjCode : writeString( thread, "IntMaxTObj"  ); writeIntMax( thread, value->data.IntMaxTObj  ); break;
        case SizeTObjCode   : writeString( thread, "SizeTObj"    ); writeSize  ( thread, value->data.SizeTObj    ); break;
        case PtrDiffTObjCode: writeString( thread, "PtrDiffTObj" ); writeLong  ( thread, value->data.PtrDiffTObj ); break;
        case WIntTObjCode   : writeString( thread, "WIntTObj"    ); writeWChar ( thread, value->data.WIntTObj    ); break;
        case FloatTObjCode:
            start = (int *)& value->data.FloatTObj;
            writeString( thread, "FloatTObj" );
            writeIntArray( thread, start, sizeof( float ) / sizeof( int ) );
            break;
        case DoubleTObjCode:
            start = (int *)& value->data.DoubleTObj;
            writeString( thread, "DoubleTObj" );
            writeIntArray( thread, start, sizeof( double ) / sizeof( int ) );
            break;
        case LongDoubleTObjCode:
            start = (int *)& value->data.LongDoubleTObj;
            writeString( thread, "LongDoubleTObj" );
            writeIntArray( thread, start, sizeof( long double ) / sizeof( int ) );
            break;
        case CStringCode    : writeString( thread, "CString"     ); writeString ( thread, value->data.CString     ); break;
        case WStringCode    : writeString( thread, "WString"     ); writeWString( thread, value->data.WString     ); break;
        case VoidTPtrObjCode: writeString( thread, "VoidTPtrObj" ); writePointer( thread, value->data.VoidTPtrObj ); break;
        default: assertion( 0, "writeTypedListElement : unsupported type" ); break;
    }
} // writeTypedListElement
Beispiel #7
0
//---------------------------------------------------------------------------
void PacketFile::atClose(void)
{
	if(isOpen() && fileMode != READ)								// update filesize
	{
		int32_t endPtr = getLength();
		//seek(sizeof(int32_t));								//Move Past Version Marker
		//writeLong(endPtr);								//Write File length
		int32_t tableEntry;
		currentPacket = numPackets;
		if(!seekTable)
		{
			while(--currentPacket >= 0)
			{
				seek(TABLE_ENTRY(currentPacket));
				tableEntry = readLong();
				if(GetPacketType(tableEntry) == STORAGE_TYPE_NUL)
				{
					seek(TABLE_ENTRY(currentPacket));
					writeLong(SetPacketType(endPtr, STORAGE_TYPE_NUL));
				}
				else
				{
					endPtr = GetPacketOffset(tableEntry);
				}
			}
		}
		else
		{
			while(--currentPacket >= 0)
			{
				tableEntry = seekTable[currentPacket];
				if(GetPacketType(tableEntry) == STORAGE_TYPE_NUL)
				{
					seekTable[currentPacket] = SetPacketType(endPtr, STORAGE_TYPE_NUL);
				}
				else
				{
					endPtr = GetPacketOffset(tableEntry);
				}
			}
		}
		//-----------------------------------------------------
		// If seekTable was being used, write it back to file
		if(seekTable)
		{
			seek(sizeof(int32_t) * 2);							//File Version & File Length
			write(puint8_t(seekTable), (numPackets * sizeof(int32_t)));
		}
		//------------------------------------------------------
		// Is we were using a checkSum, calc it and write it to
		// the beginning of the file.
		if(usesCheckSum)
		{
			int32_t checkSum = checkSumFile();
			seek(0);
			writeLong(checkSum);
		}
	}
	clear();
}
Beispiel #8
0
void Mega8Config::saveConfig(const wxString &profile)
{
    if (profile == wxEmptyString) {
        _currentProfile = wxT("General");
    } else {
        _currentProfile = profile;
    }

    saveKeyboard(_currentProfile);
    writeString(wxT("LastFolder"), _LastFolder);

    writeBool(wxT("FullScreen"), _FullScreen);
    writeBool(wxT("SpeedAuto"), _SpeedAuto);
    writeBool(wxT("DisplayHUD"), _DisplayHUD);
    writeBool(wxT("Filtered"), _Filtered);
    writeBool(wxT("SyncClock"), _SyncClock);
    writeLong(wxT("ColorTheme"), (int)_ColorTheme);
    writeBool(wxT("InverseColor"), _InverseColor);
    writeBool(wxT("Sound"), _Sound);
    writeBool(wxT("UseSleep"), _UseSleep);

    for (int i = 0; i <= sizeof(Chip8Types); i++) {
        writeLong(wxT("FrequencyRatio/") + getMachineTypeStr((Chip8Types)i), _FrequencyRatio[i]);
    }

    // Really save config
    if (_config != NULL) {
		writeConfig();
    }
}
Beispiel #9
0
bool MidiFile::writeTrack(const MidiTrack &t)
      {
      write("MTrk", 4);
      qint64 lenpos = fp->pos();
      writeLong(0);                 // dummy len

      status   = -1;
      int tick = 0;
      for (auto i : t.events()) {
            int ntick = i.first;
            putvl(ntick - tick);    // write tick delta
            //
            // if track channel != -1, then use this
            //    channel for all events in this track
            //
            if (t.outChannel() != -1)
                  writeEvent(i.second);
            tick = ntick;
            }

      //---------------------------------------------------
      //    write "End Of Track" Meta
      //    write Track Len
      //

      putvl(1);
      put(0xff);        // Meta
      put(0x2f);        // EOT
      putvl(0);         // len 0
      qint64 endpos = fp->pos();
      fp->seek(lenpos);
      writeLong(endpos-lenpos-4);   // tracklen
      fp->seek(endpos);
      return false;
      }
int SarReader::writeHeaderSub( ArchiveInfo *ai, FILE *fp, int archive_type, int nsa_offset )
{
    unsigned int i, j;

    fseek( fp, 0L, SEEK_SET );
    for (int k=0 ; k<nsa_offset ; k++)
        fputc( 0, fp );
    writeShort( fp, ai->num_of_files  );
    writeLong( fp, ai->base_offset-nsa_offset );
    
    for ( i=0 ; i<ai->num_of_files ; i++ ){

        for ( j=0 ; ai->fi_list[i].name[j] ; j++ )
            fputc( ai->fi_list[i].name[j], fp );
        fputc( ai->fi_list[i].name[j], fp );
        
        if ( archive_type >= ARCHIVE_TYPE_NSA )
            writeChar( fp, ai->fi_list[i].compression_type );

        writeLong( fp, ai->fi_list[i].offset  - ai->base_offset );
        writeLong( fp, ai->fi_list[i].length );

        if ( archive_type >= ARCHIVE_TYPE_NSA ){
            writeLong( fp, ai->fi_list[i].original_length );
        }
    }

    return 0;
}
ItemNamesReplyPacket::ItemNamesReplyPacket(const ItemNamesRequestPacket* p)
   : ReplyPacket(MAX_PACKET_SIZE, Packet::PACKETTYPE_ITEM_NAMES_REPLY, 
                 p, StringTable::OK)
{
   writeLong(ITEM_NAMES_REPLY_MAPID_POS, p->getMapID()); // MapID
   writeLong(ITEM_NAMES_REPLY_NBR_NAMES_POS, 0); // Nbr items
   setLength(ITEM_NAMES_REPLY_FIRST_NAME_POS);
}
auto R65816::op_sta_ildp_w() {
  dp = readPC();
  idle2();
  aa.l = readDPn(dp + 0);
  aa.h = readDPn(dp + 1);
  aa.b = readDPn(dp + 2);
  writeLong(aa.d + 0, r.a.l);
L writeLong(aa.d + 1, r.a.h);
}
void FileAllocator::write_node(FileOffset offset, const list_node *node)
{
    if (! (fseek(f, offset, SEEK_SET) == 0  &&
           writeLong(f, node->bytes) &&
           writeLong(f, node->prev) &&
           writeLong(f, node->next)))
        throw GenericException(__FILE__, __LINE__,
                               "FileAllocator node write at 0x%08lX failed",
                               (unsigned long)offset);
}
Beispiel #14
0
void FSStorageUnit::writeString( char *str, long maxLength )
{
	if( maxLength == 0 )
		writeLong( strlen( str ) );
	else
		writeLong( maxLength );

	file->write( (const char *)str, strlen( str ) );

	if( maxLength > 0 )
		for( int o = strlen( str ); o < maxLength; o++ )
			file->put( (char)0 );
}
GetUserTrackRequestPacket::GetUserTrackRequestPacket(uint16 packetID, 
                                                   uint16 reqID, 
                                                   uint32 UIN)
   : UserRequestPacket(MAX_PACKET_SIZE,
                       Packet::PACKETTYPE_GETUSERTRACK_REQUEST,
                       packetID,
                       reqID,
                       UIN)
{
   writeLong(GETUSERTRACK_REQUEST_LOWER_INTERVAL, 0);
   writeLong(GETUSERTRACK_REQUEST_HIGHER_INTERVAL, 0);
   writeLong(GETUSERTRACK_REQUEST_MAXNBRHITS, 0);
   setLength(GETUSERTRACK_REQUEST_MAXNBRHITS + 4);
}
RouteStorageGetRouteRequestPacket::RouteStorageGetRouteRequestPacket(
   uint32 routeID,
   uint32 createTime )
      : RequestPacket( REQUEST_HEADER_SIZE + endStatic_POS,
                       ROUTE_STORAGE_REQUEST_PRIO,
                       Packet::PACKETTYPE_ROUTESTORAGE_GET_ROUTE_REQUEST,
                       0,             // packetId
                       0,            //  requestID
                       MAX_UINT32 ) //   mapID
{
   writeLong( routeID_POS, routeID );
   writeLong( createTime_POS, createTime );
   setLength( endStatic_POS );
}
ItemNamesRequestPacket::ItemNamesRequestPacket(uint32 mapID, 
                                               uint16 requestID, 
                                               uint16 packetID)
   : RequestPacket(MAX_PACKET_SIZE,
                   ITEMNAMESREQUESTPACKET_PRIO,
                   Packet::PACKETTYPE_ITEM_NAMES_REQUEST,
                   packetID,
                   requestID,
                   mapID)
{
   writeLong(ITEM_NAMES_REQUEST_PREFERED_LANGUAGES_POS, 0);
   writeLong(ITEM_NAMES_REQUEST_NBR_ITEMS_POS, 0);
   setLength(ITEM_NAMES_REQUEST_FIRST_ITEM_POS);
}
Beispiel #18
0
void deleteByOffset(DeletionHandler *dh, long offset) {
	long head = readLong(dh->bfr, 0L); // read head

	seekBinaryFile(dh->bfr->bf, offset); // point to offset
	int size = readInt(dh->bfr, getStreamOffset(dh->bfr->bf));
	size *= -1; // delete

	seekBinaryFile(dh->bfw->bf, offset);
	writeInt(dh->bfw, size, getStreamOffset(dh->bfw->bf)); // write deleted

	seekBinaryFile(dh->bfw->bf, (offset + sizeof(int)));
	writeLong(dh->bfw, head, getStreamOffset(dh->bfw->bf)); // write head

	writeLong(dh->bfw, offset, 0L); // updated head with new offset
}
Beispiel #19
0
static TACommandVerdict __sysconf_cmd(TAThread thread,TAInputStream stream)
{
    int name;
    long res;

    /* Prepare */
    name = readInt(&stream);

    /* [ Set errno ] */
    errno = readInt(&stream);

    START_TARGET_OPERATION(thread);

    /* Execute */
    res = __sysconf(name);

    END_TARGET_OPERATION(thread);

    /* Response */
    writeLong(thread, res);
    writeInt(thread, errno);

    sendResponse(thread);

    return taDefaultVerdict;
}
Beispiel #20
0
void chunkArchive::writeString(const char *s)
{
	do_tagging(CHUNK_STRING);
	unsigned long size = strlen(s) + 1;
	writeLong(size);
	writeBlock((const char *) s, size);
}
Beispiel #21
0
void MessageEncoder::writeProperties(const Properties& msg)
{
    size_t fields(optimise ? optimisable(msg) : 13);
    if (fields) {
        void* token = startList32(&qpid::amqp::message::PROPERTIES);
        if (msg.hasMessageId()) writeString(msg.getMessageId());
        else writeNull();

        if (msg.hasUserId()) writeBinary(msg.getUserId());
        else if (fields > 1) writeNull();

        if (msg.hasTo()) writeString(msg.getTo());
        else if (fields > 2) writeNull();

        if (msg.hasSubject()) writeString(msg.getSubject());
        else if (fields > 3) writeNull();

        if (msg.hasReplyTo()) writeString(msg.getReplyTo());
        else if (fields > 4) writeNull();

        if (msg.hasCorrelationId()) writeString(msg.getCorrelationId());
        else if (fields > 5) writeNull();

        if (msg.hasContentType()) writeSymbol(msg.getContentType());
        else if (fields > 6) writeNull();

        if (msg.hasContentEncoding()) writeSymbol(msg.getContentEncoding());
        else if (fields > 7) writeNull();

        if (msg.hasAbsoluteExpiryTime()) writeLong(msg.getAbsoluteExpiryTime());
        else if (fields > 8) writeNull();

        if (msg.hasCreationTime()) writeLong(msg.getCreationTime());
        else if (fields > 9) writeNull();

        if (msg.hasGroupId()) writeString(msg.getGroupId());
        else if (fields > 10) writeNull();

        if (msg.hasGroupSequence()) writeUInt(msg.getGroupSequence());
        else if (fields > 11) writeNull();

        if (msg.hasReplyToGroupId()) writeString(msg.getReplyToGroupId());
        else if (fields > 12) writeNull();

        endList32(fields, token);
    }
}
Beispiel #22
0
int main(int argc, char **argv) {
    int magic;
    FILE *f;
    char tag;
    char c;
    int i;
    long l;
    void *p;
    char *s;

    if (argc != 2) {
	fprintf(stderr, "Incorrect number of arguments\n");
	exit(1);
    }
    f = fopen(argv[1], "wb");
    if (f == NULL) {
 	fprintf(stderr, "Can't open file \"%s\"\n", argv[1]);
	exit(1);
    }

    writeInt(f, 0x01020304);
    writeChar(f, 2);
    writeInt(f, 0);
    writeChar(f, 2);
    writeInt(f, 1);
    writeString(f, "abcdefghijklmnopqrstuvwxyz");
    writeChar(f, 3);
    writeInt(f, 4);
    writeInt(f, 2);
    writeInt(f, 4);
    writeInt(f, 6);
    writeInt(f, 8);
    writeChar(f, 4);
    writeInt(f, 2);
    writeLong(f, 4);
    writeLong(f, -4);
    writeChar(f, 5);
    writeInt(f, 3);
    writePtr(f, (void *)0xfffe0024540);
    writePtr(f, (void *)0);
    writePtr(f, (void *)0x0fffffffffffff00);
    writeChar(f, 2);
    writeInt(f, 1);
    writeString(f, "zyxwvutsrqponmlkjihgfedcba");
    fclose(f);
    return 0;
}
GetUserTrackReplyPacket::GetUserTrackReplyPacket(const GetUserTrackRequestPacket* req)
   : UserReplyPacket(MAX_PACKET_SIZE,
                     Packet::PACKETTYPE_GETUSERTRACK_REPLY, 
                     req)
{
   writeLong(GETUSERTRACK_REPLY_NBRELM_POS, 0);
   setLength(GETUSERTRACK_REPLY_NBRELM_POS + 4);
}
Beispiel #24
0
void prime()
{
	for (long i = 2; i < 999999; i++) {
		if (is_prime(i)) {
			writeLong(i);
		}
	}
}
auto R65816::op_sta_ildpy_b() {
  dp = readPC();
  idle2();
  aa.l = readDPn(dp + 0);
  aa.h = readDPn(dp + 1);
  aa.b = readDPn(dp + 2);
L writeLong(aa.d + r.y.w, r.a.l);
}
Beispiel #26
0
void PacketWriter::reset()
{
  m_readCursor = m_buffStart;
  m_writeCursor = m_buffStart;

  // Reserve space for header
  writeLong(0);
}
Beispiel #27
0
void writeTree(FILE *file, Tree *t) {
    if(t == NULL) return;

    writeLong(file, (long)t); // first write the id of this node
    writeTreeNode(file, t); // write the node
    writeTree(file, t->left); // recursively write the left subtree
    writeTree(file, t->right); // recursively write the right subtree
}
Beispiel #28
0
void chunkArchive::newChunk(unsigned short id)
{
	if (TEST_BIT(status_bits, bCHUNK))
		closeChunk();
	current_chunk_id = id;
	writeShort(id);
	writeLong(0);
	current_chunk_start = F->pos();
	SET_BIT(status_bits, bCHUNK);
}
Beispiel #29
0
void
cgicc::CgiEnvironment::save(const std::string& filename) 	const
{
    std::ofstream file( filename.c_str(), std::ios::binary |std::ios::out );

    if( ! file )
        throw std::runtime_error("I/O error");

    writeLong(file, fContentLength);
    writeLong(file, fServerPort);
    writeLong(file, (unsigned long) usingHTTPS());

    writeString(file, fServerSoftware);
    writeString(file, fServerName);
    writeString(file, fGatewayInterface);
    writeString(file, fServerProtocol);
    writeString(file, fRequestMethod);
    writeString(file, fPathInfo);
    writeString(file, fPathTranslated);
    writeString(file, fScriptName);
    writeString(file, fQueryString);
    writeString(file, fRemoteHost);
    writeString(file, fRemoteAddr);
    writeString(file, fAuthType);
    writeString(file, fRemoteUser);
    writeString(file, fRemoteIdent);
    writeString(file, fContentType);
    writeString(file, fAccept);
    writeString(file, fUserAgent);
    writeString(file, fRedirectRequest);
    writeString(file, fRedirectURL);
    writeString(file, fRedirectStatus);
    writeString(file, fReferrer);
    writeString(file, fCookie);

    if(stringsAreEqual(fRequestMethod, "post"))
        writeString(file, fPostData);

    if(file.bad() || file.fail())
        throw std::runtime_error("I/O error");

    file.close();
}
Beispiel #30
0
void chunkArchive::closeChunk()
{
	VALIDF;
	current_chunk_end = F->pos();
	F->seek(current_chunk_start - sizeof(unsigned long));
	writeLong(current_chunk_end - current_chunk_start);
	F->seek(current_chunk_end);
	CLEAR_BIT(status_bits, bCHUNK);
	current_chunk_id = 0;
}