Beispiel #1
0
/*!
 *****************************************************************************
 * \brief
 *    Read the ImageFileHeader.
 *
 *****************************************************************************
*/
static int readImageFileHeader (Tiff * t)
{
    t->ifh.byteOrder = (uint16) getU16( t);
    t->ifh.arbitraryNumber = (uint16) getU16( t);
    t->ifh.offset = getU32( t);
    if (t->ifh.arbitraryNumber != 42)
    {
        fprintf( stderr, "ImageFileHeader.arbitrary != 42\n");
        return 1;
    }
    t->mp = t->fileInMemory + t->ifh.offset;
    return 0;
}
Beispiel #2
0
static const uint_8 *dumpSegAddr( const uint_8 *input, uint_8 addrsize, uint_8 segsize )
{
    const uint_8    *p;
    uint_32         addr;
    uint_32         seg;

    p = input;

    switch( addrsize ) {
    case 4:
        addr = getU32( (uint_32 *)p );
        p += sizeof( uint_32 );
        break;
    case 2:
        addr = getU16( (uint_16 *)p );
        p += sizeof( uint_16 );
        break;
    default:
        printf( "Unknown address size\n" );
        addr = 0;
        p += addrsize;
        break;
    }
    switch( segsize ) {
    case 4:
        seg = getU32( (uint_32 *)p );
        p += sizeof( uint_32 );
        printf( "%08lx:", seg );
        break;
    case 2:
        seg = getU16( (uint_16 *)p );
        p += sizeof( uint_16 );
        printf( "%04lx:", seg );
        break;
    case 0:
        break;
    default:
        printf( "Unknown address size\n" );
        p += addrsize;
        break;
    }
    switch( addrsize ) {
    case 4:
        printf( "%08lx", addr );
        break;
    case 2:
        printf( "%04lx", addr );
        break;
    }
    return( p );
}
Beispiel #3
0
/*!
 ************************************************************************
 * \brief
 *   Get an array of (uint16|uint32|rational).
 *
 ************************************************************************
 */
static void getIntArray (Tiff * t, uint32 offset, TiffType type, uint32 a[], int n)
{
    int    i;
    uint8  *mp = t->mp;                           // save memory pointer

    t->mp = t->fileInMemory + offset;
    switch (type)
    {
    case T_SHORT:
        for (i=0; i < n; ++i)
        {
            a[i] = getU16( t);
        }
        break;
    case T_LONG:
        for (i=0; i < n; ++i)
        {
            a[i] = getU32( t);
        }
        break;
    case T_RATIONAL:
        for (i=0; i < 2*n; ++i)
        {
            a[i] = getU32( t);
        }
        break;
    default:
        assert( type == T_SHORT || type == T_LONG || type == T_RATIONAL);
    }
    t->mp = mp;                           // restore memory pointer
}
Beispiel #4
0
std::string InputMessage::getString()
{
    uint16 stringLength = getU16();
    checkRead(stringLength);
    char* v = (char*)(m_buffer + m_readPos);
    m_readPos += stringLength;
    return std::string(v, stringLength);
}
Beispiel #5
0
bool Settings::getU16NoEx(const std::string &name, u16 &val) const
{
	try {
		val = getU16(name);
		return true;
	} catch (SettingNotFoundException &e) {
		return false;
	}
}
Beispiel #6
0
/**
 * @brief Checking whether Tag Mark (0x002A) correspond to one contained in the Jpeg file
 *          This is internal function and is not exposed to client
 *
 * @return true if tag mark equals 0x002A, false otherwise
 */
bool ExifReader::checkTagMark() const
{
    uint16_t tagMark = getU16( 2 );

    if( tagMark != tagMarkRequired )
    {
        return false;
    }
    return true;
}
Beispiel #7
0
bool NetworkMessage::getPosition(Position& p)
{
	uint16_t u16;
	if(!getU16(u16)){
		return false;
	}
	p.x = u16;

	if(!getU16(u16)){
		return false;
	}
	p.y = u16;

	uint8_t u8;
	if(!getU8(u8)){
		return false;
	}
	p.z = u8;
	return true;
}
void StandardInMessage::xteaDecrypt(const crypto::Xtea& xtea)
{
	auto size = getRemainingSize();

	if(size%8 != 0)
		throw PacketException();

	xtea.decrypt(peekRawChunckAs<uint32_t>(size), size);

	setRemainingSize(getU16());
}
boost::asio::mutable_buffers_1 StandardInMessage::parseHeaderAndGetBodyBuffer()
{
	auto bodySize = getU16();

	// 8 = adler + 1 xtea frame smallest packet
	if(bodySize < 8 || bodySize > STANDARD_IN_MESSAGE_MAX_BODY_SIZE)
		throw PacketException();

	setRemainingSize(bodySize);
	return getBodyBuffer();
}
Beispiel #10
0
std::string BinaryTree::getString(uint16 len)
{
    unserialize();
    if(len == 0)
        len = getU16();

    if(m_pos+len > m_buffer.size())
        stdext::throw_exception("BinaryTree: getString failed: string length exceeded buffer size.");

    std::string ret((char *)&m_buffer[m_pos], len);
    m_pos += len;
    return ret;
}
Beispiel #11
0
std::string NetworkMessage::getString()
{
	uint16_t stringSize = getU16();
    ECORR16(stringSize);
	if(stringSize != 0 && canRead(stringSize)){
		const char* v = (const char*)(m_buffer + m_readPos);
		m_readPos += stringSize;
		return std::string(v, stringSize);
	}
	else{
		return "";
	}
}
Beispiel #12
0
bool NetworkMessage::getString(std::string& v)
{
	uint16_t stringSize;
	getU16(stringSize);

    ECORR16(stringSize);
	if(canRead(stringSize)){
		const char* cstr = (const char*)(m_buffer + m_readPos);
		m_readPos += stringSize;
		v = std::string(cstr, stringSize);
		return true;
	}
	else{
		return false;
	}
}
Beispiel #13
0
/*!
 ************************************************************************
 * \brief
 *    Read image data into 't->img'.
 *
 ************************************************************************
 */
static int readImageData (Tiff * t)
{
    int     i, j, n;
    uint8  *mp, *s;
    uint16 *p;
    uint32  size;

    assert( t);

    size = t->ImageWidth * t->ImageLength * 3 * sizeof(uint16);
    t->img = (uint16 *) realloc( t->img, size);
    if (t->img == 0)
        return 1;

    switch (t->BitsPerSample[0])
    {
    case 8:
        p = t->img;
        for (i=0; i < t->nStrips; ++i)
        {
            n = t->StripByteCounts[i];
            s = t->fileInMemory + t->StripOffsets[i];
            for (j=0; j < n; ++j)
            {
                *p++ = *s++;
            }
        }
        break;
    case 16:
        mp = t->mp;                       // save memory pointer
        p = t->img;
        for (i=0; i < t->nStrips; ++i)
        {
            n = t->StripByteCounts[i] / 2;
            t->mp = t->fileInMemory + t->StripOffsets[i];
            for (j=0; j < n; ++j)
            {
                *p++ = (uint16) getU16( t);
            }
        }
        t->mp = mp;                       // restore memory pointer
        break;
    }
    return 0;
}
void parseBuffer(void){
	
	unsigned int parsed[6];

	rBptr = &returnBuffer[0];	//assign the start of the char buffer

	parsed[0] = getU16();		//get number of bytes transmited
	parsed[1] = getU8();		//get frame ID
	parsed[2] = getU8();		//get ID count
	parsed[3] = getU8();		//get ID
	heading = getF32();		//get compass heading
	parsed[4] = getU8();		//get ID
	pitch = getF32();		//get pitch
	parsed[5] = getU8();		//get ID
	roll = getF32();		//get pitch

	return;
}
Beispiel #15
0
std::string FileStream::getString()
{
    std::string str;
    uint16 len = getU16();
    if(len > 0 && len < 8192) {
        char buffer[8192];
        if(m_fileHandle) {
            if(PHYSFS_read(m_fileHandle, buffer, 1, len) == 0)
                throwError("read failed", true);
            else
                str = std::string(buffer, len);
        } else {
            if(m_pos+len > m_data.size()) {
                throwError("read failed");
                return 0;
            }

            str = std::string((char*)&m_data[m_pos], len);
            m_pos += len;
        }
    } else if(len != 0)
        throwError("read failed because string is too big");
    return str;
}
Beispiel #16
0
static void dumpARanges( const uint_8 *input, uint length )
{
    const uint_8    *p;
    const uint_8    *q;
    const uint_8    *cu_ar_end;
    uint_32         cu;
    uint_32         tmp;
    uint_32         tuple_size;
    uint_32         padding;
    arange_header   ar_header;

    p = input;

    if( (input == NULL) || (length == 0) )
        return;

    if( length < sizeof( ar_header ) ) {
        printf( ".debug_aranges section too small!\n" );
        return;
    }

    cu = 0;

    while( p - input < length ) {
        ++cu;
        printf( "Compilation Unit %d\n", cu );

        ar_header.len = getU32( (uint_32 *)p );
        p += sizeof( uint_32 );
        ar_header.version = getU16( (uint_16 *)p );
        p += sizeof( uint_16 );
        ar_header.dbg_pos = getU32( (uint_32 *)p );
        p += sizeof( uint_32 );
        ar_header.addr_size = *p;
        p += sizeof( uint_8 );
        ar_header.seg_size = *p;
        p += sizeof( uint_8 );

        printf( "  length:    %08lx\n", ar_header.len );
        printf( "  version:   %04x\n", ar_header.version );
        printf( "  dbg_pos:   %08lx\n", ar_header.dbg_pos );
        printf( "  addr_size: %02x\n", ar_header.addr_size );
        printf( "  seg_size:  %02x\n", ar_header.seg_size );

        /* tuples should be aligned on twice the size of a tuple; some Watcom
         * versions didn't do this right!
         */
        tuple_size = (ar_header.addr_size + ar_header.seg_size) * 2;
        q = (const uint_8 *)(((uint_32)p + tuple_size - 1) & ~(tuple_size - 1));
        padding = q - p;

        /* check if padding contains non-zero data */
        if( padding ) {
            switch( ar_header.addr_size ) {
            case 4:
                tmp = getU32( (uint_32 *)p );
                break;
            case 2:
                tmp = getU16( (uint_16 *)p );
                break;
            default:
                printf( "Unknown address size\n" );
                return;
            }
            /* padding is missing! */
            if( tmp ) {
                padding = 0;
            }
        }

        p += padding;
        cu_ar_end = p - sizeof( ar_header ) + sizeof( ar_header.len ) + ar_header.len - padding;

        while( p < cu_ar_end ) {
            /* range address */
            printf( "\t" );
            p = dumpSegAddr( p, ar_header.addr_size, ar_header.seg_size );
            /* range length */
            printf( "\t" );
            switch( ar_header.addr_size ) {
            case 4:
                tmp = getU32( (uint_32 *)p );
                p += sizeof( uint_32 );
                printf( "%08lx\n", tmp );
                break;
            case 2:
                tmp = getU16( (uint_16 *)p );
                p += sizeof( uint_16 );
                printf( "%04lx\n", tmp );
                break;
            default:
                printf( "Unknown address size\n" );
                p += ar_header.addr_size;
                return;
            }
        }
    }
}
Beispiel #17
0
/**
 * @brief Get tag number from raw exif data
 *          This is internal function and is not exposed to client
 * @param [in] offset Offset to entry in bytes inside raw exif data
 * @return tag number
 */
uint16_t ExifReader::getExifTag(const size_t offset) const
{
    return getU16( offset );
}
Beispiel #18
0
/**
 * @brief Get the number of Directory Entries in Jpeg file
 *
 * @return The number of directory entries
 */
size_t ExifReader::getNumDirEntry() const
{
    return getU16( offsetNumDir );
}
/**************************************************************** 
SeaNet General Packet Format is;
*	'@'		:	Message Header = '@' (0x40).
*	HHHH	:	Hex Length of whole binary packet (excluding LF Terminator).
*	BB		:	Binary Word of above Hex Length.
*	SID		:	Packet Source Identification (Tx Node number 0 - 255).
*	DID		:	Packet Destination Identification (Rx Node number 0 -255).
*	COUNT	:	Byte Count of attached message that follows this byte.
*	MSG		:	Command / Reply Message (i.e. 'Alive' command, 'Data Reply' message).
*	TERM	:	Message Terminator = Line Feed (0Ah).
* 
*	Returns -1 if failed, 1 if correct first time, 2 if it had to 
* 	stich packets
* 
****************************************************************/
int sortPacket(void)
{

	int packetFlag = 0,
	leFlag = 0,
	buffLen, 		//length of the recieved buffer, output from read_port()
	i,				//counter
	temp[263],
	msgLen,
	binFlag;

	//How long was the msg, according to read() ?
	buffLen = read_port();
	//printf("buffLen = %d\n", buffLen);
	rBptr = &returnBuffer[0];	//set pointer for recieved data

	//Store all packets into temp[]	

	for( i = 0; i < buffLen; i++ )
	{
		leFlag = temp[i];
		temp[i] = getU8();
		if(i >= 1 && temp[i] == 0x40 && temp[i-1] == 0x0a)
		{
			buffLen = i;
		}

	}

	//Store temp stuff into right place

	header = temp[0];
	hLength = getU32(temp[1], temp[2], temp[3], temp[4]);
	bLength = getU16(temp[6], temp[5]);
	sID = temp[7];
	dID = temp[8];
	byteCount = temp[9];
	term = temp[buffLen-1];

	//Clear msg buffer first
	for(i = 0; i < 263; i++)
		msg[i] = NULL;

	msgLen = 0;

	//Store the msg, works for varying lengths
	for( i = 10; i < (buffLen-2); i ++)
	{
		msg[(i-10)] = temp[i];
		msgLen ++;
	}

	//What is prinf?

	if(header == '@' && term == 10 && buffLen == bLength + 6)
	{

		//Prinf the packet
		//printf("<< ");
		//for(i = 0; i < buffLen; i ++)
		//	printf("%x : ", temp[i]);
		//printf("\n");

		packetFlag = 1;


		if(msg[0] == mtHeadData)
		{

//			if(byteCount == 0)
//				printf("Single Packet\n");
//			else
//				printf("Multi Packet\n");
			binFlag = 0;
			//printf("\nBearing: %f\n Bins: ", (float) getU16(temp[41], temp[40]) / 17.775 );
			for(i = 44; i < buffLen-1; i++ )
			{
				
				tempBinArray[i-44] = temp[i];
				//printf("%d, ", temp[i]);
				if(temp[i] >= THRESHOLD && binFlag == 0)
				{
					bins = i-44;
					binFlag = 1;
				}
			}
			//printf("%d\n", bins * 6);

			bearing = getU16(temp[41], temp[40]);

		}

		//printf("%d, %d\n", byteCount, msgLen+1);
	}
	else
	{
		packetFlag = -1;
	}

	return packetFlag; 
}
std::string StandardInMessage::getString()
{
	return getStrChunck(getU16());
}
Beispiel #21
0
/**
 * @brief Get orientation information from raw exif data
 *          This is internal function and is not exposed to client
 * @param [in] offset Offset to entry in bytes inside raw exif data
 * @return orientation number
 */
uint16_t ExifReader::getOrientation(const size_t offset) const
{
    return getU16( offset + 8 );
}
Beispiel #22
0
/**
 * @brief Get resolution unit from raw exif data
 *          This is internal function and is not exposed to client
 * @param [in] offset Offset to entry in bytes inside raw exif data
 * @return resolution unit value
 */
uint16_t ExifReader::getResolutionUnit(const size_t offset) const
{
    return getU16( offset + 8 );
}
Beispiel #23
0
/**
 * @brief Get YCbCr Positioning information from raw exif data
 *          This is internal function and is not exposed to client
 * @param [in] offset Offset to entry in bytes inside raw exif data
 * @return vector with YCbCr positioning value
 *
 */
uint16_t ExifReader::getYCbCrPos(const size_t offset) const
{
    return getU16( offset + 8 );
}
Beispiel #24
0
static void dumpInfo( const uint_8 *input, uint length ) {

    const uint_8 *p;
    uint_32     abbrev_code;
    uint_32     abbrev_offset;
    uint_8 *    abbrev;
    uint_32     tag;
    uint_32     attr;
    uint_32     form;
    uint_32     len;
    uint_32     tmp;
    int_32      stmp;
    uint_32     unit_length;
    int         address_size;
    const uint_8 *unit_base;

    p = input;
    while( p - input < length ) {
        unit_length = getU32( (uint_32 *)p );
        unit_base = p + sizeof( uint_32 );
        address_size = *(p + 10);
        abbrev_offset = getU32( (uint_32 *)(p + 6) );
        printf( "Length: %08lx\nVersion: %04x\nAbbrev: %08lx\nAddress Size %02x\n",
            unit_length, getU16( (uint_16 *)(p + 4) ), abbrev_offset, address_size );
        p += 11;
        while( p - unit_base < unit_length ) {
            printf( "offset %08x: ", p - input );
            p = DecodeULEB128( p, &abbrev_code );
            printf( "Code: %08lx\n", abbrev_code );
            if( abbrev_code == 0 )
                continue;
            abbrev = findAbbrev( abbrev_code, abbrev_offset );
            if( abbrev == NULL ) {
                printf( "can't find abbreviation %08lx\n", abbrev_code );
                break;
            }
            if( p >= input + length )
                break;
            abbrev = DecodeULEB128( abbrev, &tag );
            printf( "\t%s\n", getTAG( tag ) );
            abbrev++;
            for( ;; ) {
                abbrev = DecodeULEB128( abbrev, &attr );
                abbrev = DecodeULEB128( abbrev, &form );
                if( attr == 0 )
                    break;
                printf( "\t%-20s", getAT( attr ) );
    decode_form:
                switch( form ) {
                case DW_FORM_addr:
                    switch( address_size ) {
                    case 4:
                        tmp = getU32( (uint_32 *)p );
                        p += sizeof( uint_32 );
                        printf( "\t%08lx\n", tmp );
                        break;
                    case 2:
                        tmp = getU16( (uint_16 *)p );
                        p += sizeof( uint_16 );
                        printf( "\t%04lx\n", tmp );
                        break;
                    default:
                        printf( "Unknown address size\n" );
                        p += address_size;
                        break;
                    }
                    break;
                case DW_FORM_block:
                    p = DecodeULEB128( p, &len );
                    printf( "\n" );
                    dumpHex( p, len, 0 );
                    p += len;
                    break;
                case DW_FORM_block1:
                    len = *p++;
                    printf( "\n" );
                    dumpHex( p, len, 0 );
                    p += len;
                    break;
                case DW_FORM_block2:
                    len = getU16( (uint_16 *)p );
                    p += sizeof( uint_16 );
                    printf( "\n" );
                    dumpHex( p, len, 0 );
                    p += len;
                    break;
                case DW_FORM_block4:
                    len = getU32( (uint_32 *)p );
                    p += sizeof( uint_32 );
                    printf( "\n" );
                    dumpHex( p, len, 0 );
                    p += len;
                    break;
                case DW_FORM_data1:
                case DW_FORM_ref1:
                    printf( "\t%02x\n", *p++ );
                    break;
                case DW_FORM_data2:
                case DW_FORM_ref2:
                    printf( "\t%04x\n", getU16( (uint_16 *)p ) );
                    p += sizeof( uint_16 );
                    break;
                case DW_FORM_data4:
                case DW_FORM_ref4:
                    printf( "\t%08lx\n", getU32( (uint_32 *)p ) );
                    p += sizeof( uint_32 );
                    break;
                case DW_FORM_flag:
                    printf( "\t%s\n", *p++ ? "True" : "False" );
                    break;
                case DW_FORM_indirect:
                    p = DecodeULEB128( p, &form );
                    printf( "\t(%s)", getFORM( form ) );
                    goto decode_form;
                case DW_FORM_sdata:
                    p = DecodeLEB128( p, &stmp );
                    printf( "\t%08lx\n", stmp );
                    break;
                case DW_FORM_string:
                    printf( "\t\"%s\"\n", p );
                    p += strlen( (const char *)p ) + 1;
                    break;
                case DW_FORM_strp:  /* 4 byte index into .debug_str */
                    printf_debug_str( getU32( (uint_32 *)p ) );
                    p += 4;
                    break;
                case DW_FORM_udata:
                case DW_FORM_ref_udata:
                    p = DecodeULEB128( p, &tmp );
                    printf( "\t%08lx\n", tmp );
                    break;
                case DW_FORM_ref_addr:  //KLUDGE should really check addr_size
                    printf( "\t%08lx\n", getU32( (uint_32 *)p ) );
                    p += sizeof(uint_32);
                    break;
                default:
                    printf( "unknown form!\n" );
                    return;
                }
            }
        }
    }
}
Beispiel #25
0
static void dumpLines( const uint_8 *input, uint length )
{
    const uint_8    *p;
    uint            opcode_base;
    uint            *opcode_lengths;
    uint            u;
    uint            file_index;
    const uint_8    *name;
    uint_32         dir_index;
    uint_32         mod_time;
    uint_32         file_length;
    uint_32         directory;
    uint_8          op_code;
    uint_8          op_len;
    uint_32         tmp;
    uint_16         tmp_seg;
    uint            line_range;
    int             line_base;
    int_32          itmp;
    int             default_is_stmt;
    state_info      state;
    uint            min_instr;
    uint_32         unit_length;
    const uint_8    *unit_base;

    p = input;
    while( p - input < length ) {
        unit_length = getU32( (uint_32 *)p );
        p += sizeof( uint_32 );
        unit_base = p;

        printf( "total_length: 0x%08lx (%u)\n", unit_length, unit_length );

        printf( "=== unit dump start ===\n" );
        dumpHex( unit_base - sizeof( uint_32 ), unit_length + sizeof (uint_32 ), 1 );
        printf( "=== unit dump end ===\n" );

        printf( "version: 0x%04x\n", getU16( (uint_16 *)p ) );
        p += sizeof( uint_16 );

        printf( "prologue_length: 0x%08lx (%u)\n", getU32( (uint_32 *)p ), getU32( (uint_32 *)p ) );
        p += sizeof( uint_32 );

        min_instr = *p;
        printf( "minimum_instruction_length: 0x%02x (%u)\n", min_instr, min_instr );
        p += 1;

        default_is_stmt = *p;
        printf( "default_is_stmt: 0x%02x (%u)\n", default_is_stmt, default_is_stmt );
        p += 1;

        line_base = *(int_8 *)p;
        printf( "line_base: 0x%02x (%d)\n", (unsigned char)line_base, line_base );
        p += 1;

        line_range = *(uint_8 *)p;
        printf( "line_range: 0x%02x (%u)\n", line_range, line_range );
        p += 1;

        opcode_base = *p;
        printf( "opcode_base: 0x%02x (%u)\n", opcode_base, opcode_base );
        p += 1;
        opcode_lengths = alloca( sizeof( uint ) * opcode_base );
        printf( "standard_opcode_lengths:\n" );
        for( u = 0; u < opcode_base - 1; ++u ) {
            opcode_lengths[u] = *p;
            ++p;
            printf( "%4u: %u\n", u + 1, opcode_lengths[u] );
        }

        printf( "-- current_offset = %08x\n", p - input );

        if( p - input >= length )
            return;

        printf( "-- start include paths --\n");
        file_index = 0;
        while( *p != 0 ) {
            ++file_index;
            name = p;
            p += strlen( (const char *)p ) + 1;
            printf( "path %u: '%s'\n", file_index, name );
            if( p - input >= length ) {
                return;
            }
        }
        printf( "-- end include paths --\n");
        p++;
        printf( "-- start files --\n");
        file_index = 0;
        while( *p != 0 ) {
            ++file_index;
            name = p;
            p += strlen( (const char *)p ) + 1;
            p = DecodeULEB128( p, &dir_index );
            p = DecodeULEB128( p, &mod_time );
            p = DecodeULEB128( p, &file_length );
            printf( "file %u: '%s' dir_index %08lx mod_time %08lx length %08lx\n",
                file_index, name, dir_index, mod_time, file_length );
            if( p - input >= length ) {
                return;
            }
        }
        printf( "-- end files --\n");
        p++;
        initState( &state, default_is_stmt );

        while( p - unit_base < unit_length ) {
            op_code = *p;
            ++p;
            if( op_code == 0 ) {
                printf( "EXTENDED 0x%02x: ", op_code );
                /* extended op_code */
                op_len = *p;
                ++p;
                printf( "len: %03d ", op_len );
                op_code = *p;
                ++p;
                switch( op_code ) {
                case DW_LNE_end_sequence:
                    printf( "END_SEQUENCE\n" );
                    state.end_sequence = 1;
                    dumpState( &state );
                    initState( &state, default_is_stmt );
                    break;
                case DW_LNE_set_address:
                    if( op_len == 3 ) {
                        tmp = getU16( (uint_16 *)p );
                        p += sizeof( uint_16 );
                    } else {
                        tmp = getU32( (uint_32 *)p );
                        p += sizeof( uint_32 );
                    }
#if 0   /* Why did they choose 6 byte here?  */
                    tmp_seg = getU16( (uint_16 *)p );
                    p += sizeof( uint_16 );
                    printf( "SET_ADDRESS %04x:%08lx\n", tmp_seg, tmp );
#else
                    tmp_seg = 0;    /* stop warning */
                    printf( "SET_ADDRESS %08lx\n", tmp );
#endif
                    break;
                case DW_LNE_WATCOM_set_segment_OLD:
                case DW_LNE_WATCOM_set_segment:
                    tmp_seg = getU16( (uint_16 *)p );
                    p += sizeof( uint_16 );
                    printf( "SET_ADDRESS_SEG %04x\n", tmp_seg );
                    break;
                case DW_LNE_define_file:
                    ++file_index;
                    name = p;
                    p += strlen( (const char *)p ) + 1;
                    p = DecodeULEB128( p, &directory );
                    p = DecodeULEB128( p, &mod_time );
                    p = DecodeULEB128( p, &file_length );
                    printf( "DEFINE_FILE %u: '%s' directory %ld mod_time %08lx length %08lx\n",
                        file_index, name, directory, mod_time, file_length );
                    break;
                default:
                    printf( "** unknown extended opcode: %02x - %u bytes\n", op_code, op_len );
                    printf( "** losing %u bytes\n", unit_length - ( p - unit_base ));

                    dumpHex( p-3, (unit_length - ( p - unit_base )) + 3, 1 );

                    p = unit_base + unit_length;
                    goto hacky;
//                    return;
                }
            } else if( op_code < opcode_base ) {
                printf( "%s", getStandardOp( op_code ) );
                switch( op_code ) {
                case DW_LNS_copy:
                    printf( "\n" );
                    dumpState( &state );
                    state.basic_block = 0;
                    break;
                case DW_LNS_advance_pc:
                    p = DecodeLEB128( p, &itmp );
                    printf( " %ld\n", itmp );
                    state.address += itmp * min_instr;
                    break;
                case DW_LNS_advance_line:
                    p = DecodeLEB128( p, &itmp );
                    printf( " %ld\n", itmp );
                    state.line += itmp;
                    break;
                case DW_LNS_set_file:
                    p = DecodeLEB128( p, &itmp );
                    printf( " %ld\n", itmp );
                    state.file = itmp;
                    break;
                case DW_LNS_set_column:
                    p = DecodeLEB128( p, &itmp );
                    printf( " %ld\n", itmp );
                    state.column = itmp;
                    break;
                case DW_LNS_negate_stmt:
                    printf( "\n" );
                    state.is_stmt = !state.is_stmt;
                    break;
                case DW_LNS_set_basic_block:
                    printf( "\n" );
                    state.basic_block = 1;
                    break;
                case DW_LNS_const_add_pc:
                    printf( "\n" );
                    state.address += ( ( 255 - opcode_base ) / line_range ) * min_instr;
                    break;
                case DW_LNS_fixed_advance_pc:
                    tmp = getU16( (uint_16 *)p );
                    p += sizeof( uint_16 );
                    printf( " %04x\n", tmp );
                    state.address += tmp;
                    break;
                default:
                    for( u = 0; u < opcode_lengths[op_code - 1]; ++u ) {
                        p = DecodeLEB128( p, &itmp );
                        printf( " %08lx", itmp );
                    }
                    printf( "\n" );
                }
            } else {
                printf( "SPECIAL 0x%02x:", op_code );
                op_code -= opcode_base;
                printf( " addr incr: %d  line incr: %d\n",
                    op_code / line_range,
                    line_base + op_code % line_range );
                state.line += line_base + op_code % line_range;
                state.address += ( op_code / line_range ) * min_instr;
                dumpState( &state );
                state.basic_block = 0;
            }
        }
hacky:
        printf( "-- current_offset = %08x\n", p - input );
    }
}