Files
harbour-core/harbour/tests/readhrb.prg
Viktor Szakats 4d4bb8e11c 2008-07-28 20:41 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* tests/ainstest.prg
   * tests/array16.prg
   * tests/arrays.prg
   * tests/atest.prg
   * tests/clasinit.prg
   * tests/classch.prg
   * tests/classes.prg
   * tests/dates.prg
   * tests/db_brows.prg
   * tests/ddate.prg
   * tests/debugtst.prg
   * tests/dynobj.prg
   * tests/files.prg
   * tests/gfx.prg
   * tests/inline.prg
   * tests/keywords.prg
   * tests/objects.prg
   * tests/onidle.prg
   * tests/readhrb.prg
   * tests/rtfclass.prg
   * tests/speed.prg
   * tests/switch.prg
   * tests/test_all.prg
   * tests/testbrw.prg
   * tests/testcgi.prg
   * tests/testcls.prg
   * tests/testget.prg
   * tests/testhtml.prg
   * tests/testidle.prg
   * tests/testinit.prg
   * tests/testntx.prg
   * tests/testpers.prg
   * tests/testrdd2.prg
   * tests/teststr.prg
   * tests/tstblock.prg
   * tests/tstmacro.prg
   * tests/videotst.prg
   * tests/vidtest.prg
   * tests/wcecon.prg
     * Cleanups. SVN header, '=' operator usage.
2008-07-28 18:43:42 +00:00

117 lines
2.8 KiB
Plaintext

//
// $Id$
//
/*
* ReadHRB
*
* This program will read the .hrb file and shows its contents
*
* ReadHRB <program file> {No .hrb extension please}
*
* Written by Eddie Runia <eddie@runia.com>
* www - http://www.harbour-project.org
*
* Placed in the public domain
*/
#include "set.ch"
function Main( cFrom )
local hFile
local cBlock := " "
local n, m
local nVal
local nSymbols
local nFuncs
local cMode := "SYMBOL"
local cScope
local nLenCount
local nIdx
local aTypes := { "NOLINK", "FUNC", "EXTERN" }
set( _SET_EXACT, .T. )
set( _SET_ALTERNATE, "readhrb.out" )
set( _SET_ALTERNATE, .T. )
if cFrom == NIL
cFrom := "hello.hrb"
else
cFrom += ".hrb"
endif
hFile := fOpen( cFrom )
if hFile == -1
QOut( "No such file:", cFrom )
else
cBlock := fReadStr( hFile, 4 )
nSymbols := asc(substr(cBlock,1,1)) +;
asc(substr(cBlock,2,1)) *256 +;
asc(substr(cBlock,3,1)) *65536 +;
asc(substr(cBlock,4,1)) *16777216
for n := 1 to nSymbols
cBlock := fReadStr( hFile, 1 )
do while asc( cBlock ) != 0
QQOut( cBlock )
cBlock := fReadStr( hFile, 1 )
enddo
cScope := fReadStr( hFile, 1 )
QQOut(" Scope ", Hex2Val(asc(cScope)))
cScope := fReadStr( hFile, 1 )
nIdx := asc( cScope ) + 1
QQOut(" Type ", aTypes[ nIdx ] )
QOut()
next n
cBlock := fReadStr( hFile, 4 )
nFuncs := asc(substr(cBlock,1,1)) +;
asc(substr(cBlock,2,1)) *256 +;
asc(substr(cBlock,3,1)) *65536 +;
asc(substr(cBlock,4,1)) *16777216
for n := 1 to nFuncs
QOut()
cBlock := fReadStr( hFile, 1 )
do while asc( cBlock ) != 0
QQOut( cBlock )
cBlock := fReadStr( hFile, 1 )
enddo
QOut( "Len = " )
cBlock := fReadStr( hFile, 4 )
nLenCount := asc(substr(cBlock,1,1)) +;
asc(substr(cBlock,2,1)) *256 +;
asc(substr(cBlock,3,1)) *65536 +;
asc(substr(cBlock,4,1)) *16777216 +1
QQOut( str(nLenCount) )
QOut()
for m:=1 to nLenCount
cBlock := fReadStr( hFile, 1 )
nVal := asc( cBlock )
QQOut( Hex2Val( nVal ) )
if nVal > 32 .and. nVal < 128
QQOut( "("+cBlock+")" )
endif
if m != nLenCount
QQOut(",")
endif
next m
next n
fClose( cFrom )
end if
set( _SET_ALTERNATE, .F. )
return nil
function Hex2Val( nVal )
return HexDigit( int(nVal / 16) ) + HexDigit( int(nVal % 16) )
function HexDigit( nDigit )
return if(nDigit>=10, chr( 55 + nDigit ), chr( 48 + nDigit ) )