home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
monitors
/
rsys
/
rsysgoodies.lha
/
Goodies
/
CheckSym
/
checksym.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-22
|
3KB
|
110 lines
/** DoRev Header ** Do not edit! **
*
* Name : checksym.c
* Creation date : 29-Jul-92
* Contents : checksym.c
* Compiler opts. : -qq -wdlp -sou -pe -hi Sys.pre
*
* Date Rev Author Comment
* --------- --- ------------------- ----------------------------------------
* 29-Jul-92 1 Rolf Boehme Erstellt
* 29-Jul-92 0 Rolf Boehme None.
*
*** DoRev End **/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
/* Vebesserte Version: Benutzt MACROs */
int atoh(char *hex)
{ int n;
register int i;
/* Stellenzähler auf 0 setzen */
n = 0;
/* Solange ein Zeichen in den angegebenen Bereichen liegt, */
/* werden die entsprechenden Werte aufaddiert */
for( i = 0; isxdigit( (int)hex[i] ); i++ ){
if((hex[i] >= '0') && (hex[i] <= '9'))
n = 16*n + hex[i] - '0';
if((hex[i] >= 'a') && (hex[i] <= 'f'))
n = 16*n + 10 + (hex[i] - 'a');
if((hex[i] >= 'A') && (hex[i] <= 'F'))
n = 16*n + 10 + (hex[i] - 'A');
}
/* Summe zurückgeben */
return(n);
}
void
main(int i,char *a[])
{
FILE *fin;
char line[200],fname[200],findsym[100],lastsym[100];
long findaddr = -1,symaddr,lastaddr = 0;
int segment,hunk;
printf("\33[3;33m%s 0.1\33[0m - von Rolf Böhme, PD!\n",a[0]);
if(i >= 2)
{
strcpy(fname,a[1]);
if( !strstr(fname,".sym") )
strcat(fname,".sym");
if( i == 3 )
findaddr = (long)atoh(a[2]);
if( fin = fopen(fname,"r") )
{
fgets( line,200,fin );
while( !feof(fin) )
{
if( strstr(line,"Segment") )
{
char *tok = strtok(line," :");
segment = atoi( strtok(NULL," :") );
strtok(NULL," :");
hunk = atoi( strtok(NULL," :") );
puts("\n-------------------------------");
printf("Segment %d, Hunk %d",segment,hunk);
puts("\n-------------------------------");
}
else
{
line[9] = '\0';
symaddr = atoh( &line[1] );
strcpy( findsym,&line[10] );
if( findaddr == -1 )
printf("Adr: 0x%08x Symbol: %s",symaddr,findsym);
else
if( (findaddr >= lastaddr) && (findaddr < symaddr) )
printf("Adr: 0x%08x Symbol: %s",lastaddr,lastsym);
strcpy(lastsym,findsym);
lastaddr = symaddr;
}
fgets( line,200,fin );
}
fclose(fin);
}
else
printf("Datei %s nicht gefunden!\n",fname);
}
else
printf("Aufruf: %s <Programmname> <adr>\n",a[0]);
exit(0);
}