initial checkin from subversion

This commit is contained in:
Tretter
2017-02-07 20:07:58 +00:00
commit e4f468da4b
84 changed files with 18782 additions and 0 deletions

0
0 Normal file
View File

1
1 Normal file
View File

@@ -0,0 +1 @@

1
250 Normal file
View File

@@ -0,0 +1 @@
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

1
254 Normal file
View File

@@ -0,0 +1 @@
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

1
255 Normal file
View File

@@ -0,0 +1 @@
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

1
256 Normal file
View File

@@ -0,0 +1 @@
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

BIN
a.out Normal file

Binary file not shown.

1
aas Normal file
View File

@@ -0,0 +1 @@
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

2
allchars.txt Normal file
View File

@@ -0,0 +1,2 @@


1
axa Normal file
View File

@@ -0,0 +1 @@
axaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxax

1
compile Normal file
View File

@@ -0,0 +1 @@
g++ -ox $1 -lncurses

1
dbcompile Normal file
View File

@@ -0,0 +1 @@
g++ -Wall -ox $1 -g -lncurses

BIN
dblach.txt Normal file

Binary file not shown.

31
drittes.cc Normal file
View File

@@ -0,0 +1,31 @@
#include <curses.h>
int main()
{
WINDOW *stdscr;
const char *str1 = "Eins ";
int z;
stdscr = initscr();
int sc=start_color();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
int cp=init_pair(1,(COLOR_BLUE),COLOR_BLACK);
cp=init_pair(2,COLOR_BLUE,COLOR_MAGENTA);
attrset(COLOR_PAIR(1));
attron(WA_BOLD);
box(stdscr,0,0);
for (z=1;z < 5;z++)
{
move(z,1);
attrset(COLOR_PAIR(1));
addstr(str1);
attrset(COLOR_PAIR(2));
addstr(str1);
}
refresh();
sleep(1);
endwin();
return 0;
}

68
err Normal file
View File

@@ -0,0 +1,68 @@
Im in Block0Working with line 0 - Distance is 5
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 5
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 5
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 5
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 5
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 5
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 4
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 3
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 2
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2Im in Block0Working with line 0 - Distance is 1
Im in Block1Im in Block2

30
erstes.cc Normal file
View File

@@ -0,0 +1,30 @@
#include <curses.h>
int main()
{
WINDOW *stdscr;
const char *str1 = "Eins";
int z;
stdscr = initscr();
int sc=start_color();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
int cp=init_pair(1,COLOR_MAGENTA,COLOR_BLUE);
cp=init_pair(2,COLOR_BLUE,COLOR_MAGENTA);
COLOR_PAIR(1);
for (z=1;z < 5;z++)
{
move(z,0);
attrset(COLOR_PAIR(1));
addstr(str1);
attrset(COLOR_PAIR(2));
addstr(str1);
usleep(1);
}
refresh();
sleep(1);
endwin();
return 0;
}

3
hello Normal file
View File

@@ -0,0 +1,3 @@
ao, jetzt machen air mal das file atwas größer, damat es auch was zua speichern gibt. das hier ist echat kewl.aaaadasdsaadkjkjkaas wirklach alleadrinne??a ich kaans kaum adauben aieder alasdasdasaasdasdsad-))rerrading moderide-mdae. over helfsadaasdfor testing of the
thex-hex-editor
xx

0
hellod Normal file
View File

1
hivals Normal file
View File

@@ -0,0 +1 @@
亗儎厗噲墛媽崕彁憭摂晼棙櫄洔潪煚、¥ウЖ┆<EFBFBD><EFBFBD><EFBFBD>辈炒刀犯购患骄坷谅媚牌侨墒颂臀闲岩釉罩棕仝圮蒉哙徕沅彐玷殛腱眍镳耱篝貊鼬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>

89
homepage.tiah/index.html Normal file
View File

@@ -0,0 +1,89 @@
<HTML>
<head><title>Homepage of the T.I.A.H Hex-Editor for Linux</title></head>
<body bgcolor="#004040" background="/homebuilder/wallpapers/0013.jpg" TEXT="#ffffff" LINK="#ffff00" VLINK="#ffff00" ALINK="#ffff00">
<FONT COLOR=YELLOW SIZE=4>
<B>DOWNLOAD BELOW</B><BR>
</FONT>
<BR>
<BR>
<BR>
<HR>
<FONT COLOR=RED SIZE=4>
<center>
<strong> T.I.A.H - Tiah Is A Hex-editor (EN)</strong> <BR>
</CENTER>
</FONT>
<HR>
<BR>
The tiah program is a (not yet) fully feauterd hex editor for Linux
<BR>
<BR>
The tiah-program comes with a interactive text-based user interface.
<BR>
<BR>
With tiah it is possible to insert ond delete characters.
<BR>
<BR>
Moving around, Edit in Hex/Ascii, Setting bits is possible in the moment.
<BR>
<BR>
It's planned to include functions for searching and filling in later versions.
<BR>
<BR>
<HR>
<FONT COLOR=RED SIZE=4>
<center>
<strong> T.I.A.H - Tiah Is A Hex-editor (DE)</strong> <BR>
</CENTER>
</FONT>
<HR>
<BR>
Tiah ist ein noch nicht vollstaendig implementierter Hex-Editor fuer Linux.
<BR>
<BR>
Tiah hat ein interaktives Textinterface
<BR>
<BR>
Mit Tiah ist es moeglich Zeichen einzufuegen und zu löschen
<BR>
<BR>
Momentan sind Cursorbewegungen, Setzen einzelner Bist und editieren in Hex und Ascii moeglich.
<BR>
<BR>
Es ist fuer spaetere Versionen geplant, Funktionen zum suchen und fuellen zu implementieren
<BR>
<HR>
<FONT COLOR=RED SIZE=4>
<B>DOWNLOAD: </B>
</FONT>
<BR>
<TABLE>
<TR><TD>
gzipped-version:
</TD>
<TD>
<a href="tiah05.tar.gz"> tiah05.tar.gz </A>
</TD>
</TR>
<TR>
<TD>
bzipped-version:
</TD>
<TD>
<a href="tiah05.tar.bz2"> tiah05.tar.bz2 </A>
</TD>
</TR>
</TABLE>
<HR>
<p><font size=+2>You can write eMails to me:
<a href="mailto:j.tretter@gmx.de">j.tretter@gmx.de</a>
</font>
<BR>
<BR>
<font size=+1 color="#ffffff">This Page was visited
<img src="/user-cgi/Count.cgi?df=ghex.091">
times.
</body>
</html>

Binary file not shown.

BIN
homepage.tiah/tiah05.tar.gz Normal file

Binary file not shown.

1
j Normal file
View File

@@ -0,0 +1 @@
xx

0
nix Normal file
View File

1
out Normal file
View File

@@ -0,0 +1 @@
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz

628
thx.cc Normal file
View File

@@ -0,0 +1,628 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
struct data // Eine Zeile Speicher
{
struct data* plast;
struct data* pnext;
unsigned char vals[16];
unsigned long zeile;
char len;
};
struct cpos // Cursor-Position
{
char x,y;
}pos;
int mode=1;
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII ";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pdaten,*pfirst, *phelp;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).zeile=0;
(*pfirst).len=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Tastatureingabe erlauben
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// Echo ausschalten
noecho();
// Cursor auf Groß setzen
if(curs_set(2)==ERR) retval=1 ;
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tonumsysx(int base10,int newbase)
{
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
unsigned long xto10(char *c, int oldbase)
{
unsigned long base10=0;
unsigned long rest,erg;
int pos=0;
int i;
while(c[pos++]);
pos--;
int len=pos-1;
while(pos--)
{
if(isdigit(c[len-pos]))
{
base10 = base10 + (unsigned long)( (double)(c[len-pos]-'0') * ( pow( (double)oldbase,(double)pos ) ) ) ;
}
else
{
base10 = base10 + (unsigned long)( ((double)(c[len-pos]-'A')+10) * ( pow( (double)oldbase,(double)pos ) ) );
}
}
return(base10);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
int k=0;
unsigned long zeile=0;
pdaten=pfirst;
ch=fgetc(fp);
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(feof(fp)))
{
for(x=0;x<16;x++)
{
((*pdaten).vals[x])=ch;
if (feof(fp)) //(*pdaten).vals[x]==EOF)
{
(*pdaten).vals[x]=0;
break;
}
(*pdaten).len=x+1;
ch=fgetc(fp);
}
(*pdaten).zeile=zeile++;
if(!(feof(fp)))
{
phelp=pdaten;
if (!(zeile%500)) {fprintf(stderr,"%c",'#');}
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
// BUG: Check for Memory-Full does not work.
if(!pdaten) {abort();}
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
}
/* D E B U G O N L Y
pdaten=pfirst;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
/* DEBUG ONLY
pdaten=pfirst;
int zeile=16;
int x;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
pdaten=pfirst;
for(;(*pdaten).pnext;pdaten=(*pdaten).pnext)
;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
!mode?wmove(whex,pos.y,pos.x):wmove(wascii,pos.y,pos.x);
wrefresh(woffs);
wrefresh(wtop);
wrefresh(wbot);
// die Reihenfolge wird anhand des Modus bestimmt (das letzte ist aktiv)
!mode?wrefresh(wascii):wrefresh(whex);
mode?wrefresh(wascii):wrefresh(whex);
}
void lineout(unsigned long zeile)
{
int z;
miniinit();
ptv = tonumsysx((*pdaten).zeile*16,16);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,zeile,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tonumsysx((*pdaten).vals[z],16);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,zeile,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
// BUG: Die Ober- und Untergrenze genau bestimmen.
xascii[z] = ((((*pdaten).vals[z]) > 31)&&((*pdaten).vals[z] != 127))?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,zeile,1,sascii);
}
void initout()
{
//Initiale Ausgabe (Alle)
int i;
bool schalter=false;
unsigned long zeile=1;
pdaten=pfirst;
if ((*pdaten).pnext == NULL) schalter=true;
for(i=0;i<16;i++)
{
lineout(i+1);
if (schalter) break;
pdaten=(*pdaten).pnext;
if ((*pdaten).pnext == NULL) schalter=true;
}
scrrefresh();
if(i>15) pdaten=(*pdaten).plast;
}
void scrolld()
{
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
int z;
miniinit();
lineout(16);
}
void scrollu()
{
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
lineout(1);
}
void switchmode()
{
if(mode==0)
{
mode=1; // modus:Hex->Ascii
// Umrechnen der Cursorposition
pos.x=((pos.x+1)/3);
}
else
{
mode=0; // modue:Ascii->Hex
// Umrechnen der Cursorposition
pos.x=((pos.x*3)-1);
}
}
void moveleft()
{
if(mode==0)
{
if(pos.x > 2)(pos.x%3)?pos.x-=2:pos.x--;
}
else
{
if(pos.x > 1)pos.x--;
}
}
void moveright()
{
if(mode==0)
{
if(pos.x < 48)(pos.x%3)?pos.x++:pos.x+=2;
}
else
{
if(pos.x < 16)pos.x++;
}
}
void charin(char ch)
{
int i=0;
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
// Wert schreiben
(*pdaten).vals[pos.x-1]=ch;
// Ausgabe aktualisieren
lineout(pos.y);
// wieder zurückblättern
while(i--)
{
pdaten=(*pdaten).pnext;
}
}
int main(int argc, char *argv[])
{
/* --- DEBUG ONLY
printf("DEBUG: 5-%u\n",xto10(tonumsysx(5,2),2));
printf("DEBUG: 16-%u\n",xto10(tonumsysx(16,16),16));
printf("DEBUG: 36-%u\n",xto10 (tonumsysx(36,36),36));
printf("DEBUG: 255-%u\n",xto10(tonumsysx(255,16),16));
printf("DEBUG: 255-%u\n",xto10("FF",16));
printf("DEBUG: 125-%u\n",xto10(tonumsysx(125,8),8));
printf("DEBUG: 255-%u\n",xto10(tonumsysx(255,8),8));
getchar();
--- END DEBUG */
//Variablen
unsigned int i,z; // Allgemeine Zähler
unsigned long zeile=0; // Zeilennummer
bool schalter; // Schalter für lesevorlauf
int inpch; // Eingabezeichen
//Vorbereitung
printf("GHEX Version 0.5\n");
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
// sonstige Variableninitialisierung
pos.x = pos.y = 1;
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
initout();
scrrefresh();
//Eventschleife
while(inpch!=KEY_F(10))
{
if (mode==0)
{
inpch=wgetch(whex);
}
else
{
inpch=wgetch(wascii);
}
switch(inpch)
{
case KEY_F(9): switchmode();
break;
case KEY_LEFT: moveleft();
break;
case KEY_RIGHT:moveright();
break;
case KEY_DOWN: if(pos.y>15)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
else
{
pos.y++;
}
break;
case KEY_UP: if(pos.y<2)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
else
{
pos.y--;
}
break;
case KEY_NPAGE:
for(i=0;i<16;i++)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
case KEY_PPAGE:
for(i=0;i<16;i++)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
break;
case KEY_HOME:
initout();
break;
case KEY_END:
while((*pdaten).pnext)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
default:
if(mode==0)
{
if(isdigit(inpch) || (toupper(inpch)>='A' && toupper(inpch)<='F') )
{
waddch(whex,toupper(inpch));
char hch[]="FF";
// TODO hch korrekt füllen. if(pos.x%3)
switchmode(); // um die Koordinaten umzurechnen
charin(xto10(hch,16)); // Umrechnen Hex -> Ascii+charin
switchmode(); // und wieder zurücksetzen
moveright();
}
}
else
{
//if((inpch > 31)&&(inpch < 256))
if((inpch < 256))
{
waddch(wascii,inpch);
charin(inpch);
moveright();
}
}
};
scrrefresh();
}
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

224
thxv1.cc Normal file
View File

@@ -0,0 +1,224 @@
#include <curses.h>
#include <stdio.h>
struct data
{
struct data* plast;
struct data* pnext;
char vals[16][16];
};
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pfirst;
void initvar()
{
pfirst=&daten;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tohex(int base10)
{
int newbase=16;
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
int loadcontents()
{
int retval=0;
int x,y;
for(x=0;x<16;x++)
for(y=0;y<16;y++)
{
daten.vals[y][x]=fgetc(fp);
if (daten.vals[y][x]==EOF) daten.vals[y][x]=0;
}
for(x=0;x<16;x++)
for(y=0;y<16;y++)
printf("%c",daten.vals[y][x]);
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z;
printf("%s\n",tohex(0));
printf("%s\n",tohex(10));
printf("%s\n",tohex(20));
printf("%s\n",tohex(30));
printf("%s\n",tohex(40));
printf("%s\n",tohex(50));
//Vorbereitung
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"THX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// pointer setzen
initvar();
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
for (i=1;i<17;i++)
{
ptv = tohex(i-1);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,i,1,soffs);
for (z=0;z<16;z++)
{
ptv = tohex(daten.vals[z][i-1]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,i,1,shex);
for (z=0;z<16;z++)
{
xascii[z] = ((daten.vals[z][i-1]) > 33)?(daten.vals[z][i-1]):254;
}
mvwaddstr(wascii,i,1,sascii);
}
wrefresh(woffs);
wrefresh(whex);
wrefresh(wascii);
wrefresh(wtop);
wrefresh(wbot);
sleep(1);
endscr();
return (fclose(fp));
}

286
thxv2.cc Normal file
View File

@@ -0,0 +1,286 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
struct data
{
struct data* plast;
struct data* pnext;
char vals[16][16];
};
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pdaten,*pfirst, *phelp;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tohex(int base10)
{
int newbase=16;
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
int loadcontents()
{
int retval=0;
int x,y;
char ch;
int k=0;
pdaten=pfirst;
ch=fgetc(fp);
while (!(ch==EOF))
{
k++;
for(x=0;x<16;x++)
for(y=0;y<16;y++)
{
((*pdaten).vals[y][x])=ch;
if ((*pdaten).vals[y][x]==EOF) (*pdaten).vals[y][x]=0;
ch=fgetc(fp);
}
if(!(ch==EOF))
{
phelp=pdaten;
printf("Vorher:%p\n",pdaten);
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
printf("Nachher:%p\n" ,pdaten);
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
}
/* D E B U G O N L Y
getchar();
pdaten=pfirst;
while (k--)
{
for(x=0;x<16;x++)
for(y=0;y<16;y++)
{
printf("%c-",(*pdaten).vals[y][x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
pdaten=pfirst;
for(;(*pdaten).pnext;pdaten=(*pdaten).pnext)
;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z;
unsigned long zeile=0,pos=0;
printf("%s\n",tohex(0));
printf("%s\n",tohex(10));
printf("%s\n",tohex(20));
printf("%s\n",tohex(30));
printf("%s\n",tohex(40));
printf("%s\n",tohex(50));
//Vorbereitung
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"THX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
for (i=1;i<17;i++)
{
ptv = tohex(i-1);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,i,1,soffs);
for (z=0;z<16;z++)
{
ptv = tohex(daten.vals[z][i-1]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,i,1,shex);
for (z=0;z<16;z++)
{
xascii[z] = ((daten.vals[z][i-1]) > 33)?(daten.vals[z][i-1]):254;
}
mvwaddstr(wascii,i,1,sascii);
}
wrefresh(woffs);
wrefresh(whex);
wrefresh(wascii);
wrefresh(wtop);
wrefresh(wbot);
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

463
thxv3.cc Normal file
View File

@@ -0,0 +1,463 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
struct data
{
struct data* plast;
struct data* pnext;
char vals[16];
unsigned long zeile;
char len;
};
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pdaten,*pfirst, *phelp;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).zeile=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Tastatureingabe erlauben
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tohex(int base10)
{
int newbase=16;
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
int k=0;
unsigned long zeile=0;
pdaten=pfirst;
ch=fgetc(fp);
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(ch==EOF))
{
for(x=0;x<16;x++)
{
((*pdaten).vals[x])=ch;
if ((*pdaten).vals[x]==EOF)
{
(*pdaten).vals[x]=0;
break;
}
(*pdaten).len=x+1;
ch=fgetc(fp);
}
(*pdaten).zeile=zeile++;
if(!(ch==EOF))
{
phelp=pdaten;
if (!(zeile%500)) {fprintf(stderr,"%c",'#');}
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
}
/* D E B U G O N L Y
getchar();
pdaten=pfirst;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
pdaten=pfirst;
for(;(*pdaten).pnext;pdaten=(*pdaten).pnext)
;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
wrefresh(woffs);
wrefresh(whex);
wrefresh(wascii);
wrefresh(wtop);
wrefresh(wbot);
}
void lineout(unsigned long zeile)
{
int z;
miniinit();
ptv = tohex((*pdaten).zeile);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,zeile,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tohex((*pdaten).vals[z]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,zeile,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
xascii[z] = (((*pdaten).vals[z]) > 33)?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,zeile,1,sascii);
}
void scrolld()
{
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
int z;
miniinit();
ptv = tohex((*pdaten).zeile);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,16,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tohex((*pdaten).vals[z]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,16,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
xascii[z] = (((*pdaten).vals[z]) > 33)?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,16,1,sascii);
}
void scrollu()
{
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
int z;
ptv = tohex((*pdaten).zeile);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,1,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tohex((*pdaten).vals[z]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,1,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
xascii[z] = (((*pdaten).vals[z]) > 33)?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,1,1,sascii);
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z;
unsigned long zeile=0,pos=0;
bool schalter;
int inpch;
//Vorbereitung
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"THX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
schalter=false;
zeile=1;
pdaten=pfirst;
//Initiale Ausgabe (Alle)
for(i=0;i<16;i++)
{
lineout(i+1);
if (schalter) break;
pdaten=(*pdaten).pnext;
if ((*pdaten).pnext == NULL) schalter=true;
}
scrrefresh();
if(i>15) pdaten=(*pdaten).plast;
//Eventschleife
while(inpch!=KEY_END)
{
inpch=wgetch(whex);
switch(inpch)
{
case KEY_DOWN:
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
break;
case KEY_UP:
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
break;
case KEY_NPAGE:
for(i=0;i<16;i++)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
case KEY_PPAGE:
for(i=0;i<16;i++)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
break;
};
scrrefresh();
}
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

450
thxv4.cc Normal file
View File

@@ -0,0 +1,450 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
struct data
{
struct data* plast;
struct data* pnext;
char vals[16];
unsigned long zeile;
char len;
};
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII ";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pdaten,*pfirst, *phelp;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).zeile=0;
(*pfirst).len=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Tastatureingabe erlauben
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tonumsysx(int base10,int newbase)
{
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
int k=0;
unsigned long zeile=0;
pdaten=pfirst;
ch=fgetc(fp);
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(feof(fp)))
{
for(x=0;x<16;x++)
{
((*pdaten).vals[x])=ch;
if (feof(fp)) //(*pdaten).vals[x]==EOF)
{
(*pdaten).vals[x]=0;
break;
}
(*pdaten).len=x+1;
ch=fgetc(fp);
}
(*pdaten).zeile=zeile++;
if(!(feof(fp)))
{
phelp=pdaten;
if (!(zeile%500)) {fprintf(stderr,"%c",'#');}
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
// BUG: Check for Memory-Full does not work.
if(!pdaten) {abort();}
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
}
/* D E B U G O N L Y
getchar();
pdaten=pfirst;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
pdaten=pfirst;
for(;(*pdaten).pnext;pdaten=(*pdaten).pnext)
;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
wrefresh(woffs);
wrefresh(whex);
wrefresh(wascii);
wrefresh(wtop);
wrefresh(wbot);
}
void lineout(unsigned long zeile)
{
int z;
miniinit();
ptv = tonumsysx((*pdaten).zeile*16,16);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,zeile,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tonumsysx((*pdaten).vals[z],16);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,zeile,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
xascii[z] = (((*pdaten).vals[z]) > 31)?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,zeile,1,sascii);
}
void initout()
{
//Initiale Ausgabe (Alle)
int i;
bool schalter=false;
unsigned long zeile=1;
pdaten=pfirst;
if ((*pdaten).pnext == NULL) schalter=true;
for(i=0;i<16;i++)
{
lineout(i+1);
if (schalter) break;
pdaten=(*pdaten).pnext;
if ((*pdaten).pnext == NULL) schalter=true;
}
scrrefresh();
if(i>15) pdaten=(*pdaten).plast;
}
void scrolld()
{
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
int z;
miniinit();
lineout(16);
}
void scrollu()
{
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
lineout(1);
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z;
unsigned long zeile=0,pos=0;
bool schalter;
int inpch;
printf("GHEX Version 0.5\n");
//Vorbereitung
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
initout();
//Eventschleife
while(inpch!=KEY_F(10))
{
inpch=wgetch(whex);
switch(inpch)
{
case KEY_DOWN:
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
break;
case KEY_UP:
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
break;
case KEY_NPAGE:
for(i=0;i<16;i++)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
case KEY_PPAGE:
for(i=0;i<16;i++)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
break;
case KEY_HOME:
initout();
break;
case KEY_END:
while((*pdaten).pnext)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
};
scrrefresh();
}
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

1248
tiah.cc Normal file

File diff suppressed because it is too large Load Diff

339
tiah05/COPYING Normal file
View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

40
tiah05/Makefile Normal file
View File

@@ -0,0 +1,40 @@
############################################################################
# #
# T.I.A.H - THIA IS A HEX-EDITOR #
# Copyright (C) 1999 by Joerg "Maddog" Tretter #
# #
############################################################################
PRGFILE = tiah
SRC = tiah.cc
MANFILE = tiah.1.gz
INSTPATH = /usr/local/bin
MANPATH = /usr/man/man1
DOCPATH = /usr/doc/tiah
MAKE = make
CC = c++
LIBS += -lncurses
all:
$(MAKE) $(PRGFILE)
.cc:
@echo compiling $(SRC) .
@$(CC) $(LIBS) $(SRC) -o$(PRGFILE)
install:
@install -s -g users -m 755 -o root $(PRGFILE) $(INSTPATH)
@install -d -g root -o root $(MANPATH)
@install -g root -m 644 -o root $(MANFILE) $(MANPATH)
@install -d -g root -o root $(DOCPATH)
@install -g root -m 644 -o root COPYING $(DOCPATH)
@install -g root -m 644 -o root README.PROGRAMMER $(DOCPATH)
@install -g root -m 644 -o root README.INSTALL $(DOCPATH)
@install -g root -m 644 -o root README.BUG $(DOCPATH)
clean:
@echo removing object $(PRGFILE).
@rm $(PRGFILE)

1
tiah05/README.BUG Normal file
View File

@@ -0,0 +1 @@
For known bugs see manpage.

24
tiah05/README.INSTALL Normal file
View File

@@ -0,0 +1,24 @@
TIAH (C) Joerg Tretter
What do you need:
=================
- linux on a i386+ (other systems perhaps work, too)
- g++ or compatible
- ncurses library (normally installed on every linux-system)
Steps of installation:
======================
- edit Makefile if you want an alternative install-dir
(standard is /usr/local/bin)
- make && make install
(you will get some warnings, but that doesn't matter,
if you get an error and can't solve yourself: please report via mail)
Please send me bug reports and other systems TIAH works on, too.
If you like the program, please let me know (it's interesting for me to know
how may people are using TIAH.)
Joerg Tretter
J.Tretter@gmx.de

24
tiah05/README.PROGRAMMER Normal file
View File

@@ -0,0 +1,24 @@
TIAH (C) Joerg Tretter
I know, the code abolutely cofusing, but keep in mind:
This version is only the first prototype of TIAH.
There is a complete revision of the source planned for the next release.
So if you plan to adapt new features in this program better wait for
the new versions with a cleaned, object oriented source.
Nevertheless, please send me every modification you did for fixing bugs.
Plans for next releases
1. reengineer source-code (using classes, make code readable for others)
2. search-fuction
3. replace-function
4. fill-function
5. internal calculator (source numbering-system <-> target-numbering system)
6. perhaps various goodies :-))
7. Changes suggested by others.
Joerg Tretter
J.Tretter@gmx.de

BIN
tiah05/tiah.1.gz Normal file

Binary file not shown.

1248
tiah05/tiah.cc Normal file

File diff suppressed because it is too large Load Diff

BIN
tiah05/tiah05.tar.bz2 Normal file

Binary file not shown.

BIN
tiah05/tiah05.tar.gz Normal file

Binary file not shown.

6
tiah05a/CHANGES Normal file
View File

@@ -0,0 +1,6 @@
0.5a:
bugfix, use of proper function strncpy instead of "=" for filling string constants, there was a compile-problem with newer compilers.
0.5:
first official release

339
tiah05a/COPYING Normal file
View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

40
tiah05a/Makefile Normal file
View File

@@ -0,0 +1,40 @@
############################################################################
# #
# T.I.A.H - THIA IS A HEX-EDITOR #
# Copyright (C) 1999 by Joerg "Maddog" Tretter #
# #
############################################################################
PRGFILE = tiah
SRC = tiah.cc
MANFILE = tiah.1.gz
INSTPATH = /usr/local/bin
MANPATH = /usr/man/man1
DOCPATH = /usr/doc/tiah
MAKE = make
CC = c++
LIBS += -lncurses
all:
$(MAKE) $(PRGFILE)
.cc:
@echo compiling $(SRC) .
@$(CC) $(LIBS) $(SRC) -o$(PRGFILE)
install:
@install -s -g users -m 755 -o root $(PRGFILE) $(INSTPATH)
@install -d -g root -o root $(MANPATH)
@install -g root -m 644 -o root $(MANFILE) $(MANPATH)
@install -d -g root -o root $(DOCPATH)
@install -g root -m 644 -o root COPYING $(DOCPATH)
@install -g root -m 644 -o root README.PROGRAMMER $(DOCPATH)
@install -g root -m 644 -o root README.INSTALL $(DOCPATH)
@install -g root -m 644 -o root README.BUG $(DOCPATH)
clean:
@echo removing object $(PRGFILE).
@rm $(PRGFILE)

1
tiah05a/README.BUG Normal file
View File

@@ -0,0 +1 @@
For known bugs see manpage.

24
tiah05a/README.INSTALL Normal file
View File

@@ -0,0 +1,24 @@
TIAH (C) Joerg Tretter
What do you need:
=================
- linux on a i386+ (other systems perhaps work, too)
- g++ or compatible
- ncurses library (normally installed on every linux-system)
Steps of installation:
======================
- edit Makefile if you want an alternative install-dir
(standard is /usr/local/bin)
- make && make install
(you will get some warnings, but that doesn't matter,
if you get an error and can't solve yourself: please report via mail)
Please send me bug reports and other systems TIAH works on, too.
If you like the program, please let me know (it's interesting for me to know
how may people are using TIAH.)
Joerg Tretter
J.Tretter@gmx.de

24
tiah05a/README.PROGRAMMER Normal file
View File

@@ -0,0 +1,24 @@
TIAH (C) Joerg Tretter
I know, the code abolutely cofusing, but keep in mind:
This version is only the first prototype of TIAH.
There is a complete revision of the source planned for the next release.
So if you plan to adapt new features in this program better wait for
the new versions with a cleaned, object oriented source.
Nevertheless, please send me every modification you did for fixing bugs.
Plans for next releases
1. reengineer source-code (using classes, make code readable for others)
2. search-fuction
3. replace-function
4. fill-function
5. internal calculator (source numbering-system <-> target-numbering system)
6. perhaps various goodies :-))
7. Changes suggested by others.
Joerg Tretter
J.Tretter@gmx.de

BIN
tiah05a/tiah.1.gz Normal file

Binary file not shown.

1249
tiah05a/tiah.cc Normal file

File diff suppressed because it is too large Load Diff

BIN
tiah05a/tiah05a.tar.bz2 Normal file

Binary file not shown.

10
tiah05b/CHANGES Normal file
View File

@@ -0,0 +1,10 @@
0.5b:
flush stdout after printng hashmark while loading
Handle errors during create process of the Windows properly
0.5a:
bugfix, use of proper function strncpy instead of "=" for filling string constants, there was a compile-problem with newer compilers.
0.5:
first official release

339
tiah05b/COPYING Normal file
View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

40
tiah05b/Makefile Normal file
View File

@@ -0,0 +1,40 @@
############################################################################
# #
# T.I.A.H - TIAH IS A HEX-EDITOR #
# Copyright (C) 1999 by Joerg "Maddog" Tretter #
# #
############################################################################
PRGFILE = tiah
SRC = tiah.cc
MANFILE = tiah.1.gz
INSTPATH = /usr/local/bin
MANPATH = /usr/man/man1
DOCPATH = /usr/doc/tiah
MAKE = make
CC = c++
LIBS += -lncurses
all:
$(MAKE) $(PRGFILE)
.cc:
@echo compiling $(SRC) .
@$(CC) $(LIBS) $(SRC) -o$(PRGFILE)
install:
@install -s -g users -m 755 -o root $(PRGFILE) $(INSTPATH)
@install -d -g root -o root $(MANPATH)
@install -g root -m 644 -o root $(MANFILE) $(MANPATH)
@install -d -g root -o root $(DOCPATH)
@install -g root -m 644 -o root COPYING $(DOCPATH)
@install -g root -m 644 -o root README.PROGRAMMER $(DOCPATH)
@install -g root -m 644 -o root README.INSTALL $(DOCPATH)
@install -g root -m 644 -o root README.BUG $(DOCPATH)
clean:
@echo removing object $(PRGFILE).
@rm $(PRGFILE)

1
tiah05b/README.BUG Normal file
View File

@@ -0,0 +1 @@
For known bugs see manpage.

24
tiah05b/README.INSTALL Normal file
View File

@@ -0,0 +1,24 @@
TIAH (C) Joerg Tretter
What do you need:
=================
- linux on a i386+ (other systems perhaps work, too)
- g++ or compatible
- ncurses library (normally installed on every linux-system)
Steps of installation:
======================
- edit Makefile if you want an alternative install-dir
(standard is /usr/local/bin)
- make && make install
(you will get some warnings, but that doesn't matter,
if you get an error and can't solve yourself: please report via mail)
Please send me bug reports and other systems TIAH works on, too.
If you like the program, please let me know (it's interesting for me to know
how may people are using TIAH.)
Joerg Tretter
J.Tretter@gmx.de

20
tiah05b/README.PROGRAMMER Normal file
View File

@@ -0,0 +1,20 @@
TIAH (C) Joerg Tretter
I know, the code absolutely cofusing, but keep in mind:
This version is only a first prototype of TIAH.
please send me every bugfix / feature you programmed.
Plans for next releases
1. search-fuction
2. replace-function
3. fill-function
4. internal calculator (source numbering-system <-> target-numbering system)
5. perhaps various goodies :-))
6. Changes suggested by others.
Because I have less time currently I would appreciate all patches.
Joerg Tretter
J.Tretter@gmx.de

1
tiah05b/THANKSTO Normal file
View File

@@ -0,0 +1 @@
Fabrice Haberer (for 64 Bit testing on Alpha)

BIN
tiah05b/tiah.1.gz Normal file

Binary file not shown.

1251
tiah05b/tiah.cc Normal file

File diff suppressed because it is too large Load Diff

10
tiah05c/CHANGES Normal file
View File

@@ -0,0 +1,10 @@
0.5b:
flush stdout after printng hashmark while loading
Handle errors during create process of the Windows properly
0.5a:
bugfix, use of proper function strncpy instead of "=" for filling string constants, there was a compile-problem with newer compilers.
0.5:
first official release

339
tiah05c/COPYING Normal file
View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

40
tiah05c/Makefile Normal file
View File

@@ -0,0 +1,40 @@
############################################################################
# #
# T.I.A.H - TIAH IS A HEX-EDITOR #
# Copyright (C) 1999 by Joerg "Maddog" Tretter #
# #
############################################################################
PRGFILE = tiah
SRC = tiah.cc
MANFILE = tiah.1.gz
INSTPATH = /usr/local/bin
MANPATH = /usr/man/man1
DOCPATH = /usr/doc/tiah
MAKE = make
CC = c++
LIBS += -lncurses
all:
$(MAKE) $(PRGFILE)
.cc:
@echo compiling $(SRC) .
@$(CC) $(LIBS) $(SRC) -o$(PRGFILE)
install:
@install -s -g users -m 755 -o root $(PRGFILE) $(INSTPATH)
@install -d -g root -o root $(MANPATH)
@install -g root -m 644 -o root $(MANFILE) $(MANPATH)
@install -d -g root -o root $(DOCPATH)
@install -g root -m 644 -o root COPYING $(DOCPATH)
@install -g root -m 644 -o root README.PROGRAMMER $(DOCPATH)
@install -g root -m 644 -o root README.INSTALL $(DOCPATH)
@install -g root -m 644 -o root README.BUG $(DOCPATH)
clean:
@echo removing object $(PRGFILE).
@rm $(PRGFILE)

1
tiah05c/README.BUG Normal file
View File

@@ -0,0 +1 @@
For known bugs see manpage.

24
tiah05c/README.INSTALL Normal file
View File

@@ -0,0 +1,24 @@
TIAH (C) Joerg Tretter
What do you need:
=================
- linux on a i386+ (other systems perhaps work, too)
- g++ or compatible
- ncurses library (normally installed on every linux-system)
Steps of installation:
======================
- edit Makefile if you want an alternative install-dir
(standard is /usr/local/bin)
- make && make install
(you will get some warnings, but that doesn't matter,
if you get an error and can't solve yourself: please report via mail)
Please send me bug reports and other systems TIAH works on, too.
If you like the program, please let me know (it's interesting for me to know
how may people are using TIAH.)
Joerg Tretter
J.Tretter@gmx.de

20
tiah05c/README.PROGRAMMER Normal file
View File

@@ -0,0 +1,20 @@
TIAH (C) Joerg Tretter
I know, the code absolutely cofusing, but keep in mind:
This version is only a first prototype of TIAH.
please send me every bugfix / feature you programmed.
Plans for next releases
1. search-fuction
2. replace-function
3. fill-function
4. internal calculator (source numbering-system <-> target-numbering system)
5. perhaps various goodies :-))
6. Changes suggested by others.
Because I have less time currently I would appreciate all patches.
Joerg Tretter
J.Tretter@gmx.de

1
tiah05c/THANKSTO Normal file
View File

@@ -0,0 +1 @@
Fabrice Haberer (for 64 Bit testing on Alpha)

BIN
tiah05c/tiah.1.gz Normal file

Binary file not shown.

1251
tiah05c/tiah.cc Normal file

File diff suppressed because it is too large Load Diff

BIN
tiah05c/tiah05b.tar Normal file

Binary file not shown.

224
tiahv1.cc Normal file
View File

@@ -0,0 +1,224 @@
#include <curses.h>
#include <stdio.h>
struct data
{
struct data* plast;
struct data* pnext;
char vals[16][16];
};
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pfirst;
void initvar()
{
pfirst=&daten;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tohex(int base10)
{
int newbase=16;
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
int loadcontents()
{
int retval=0;
int x,y;
for(x=0;x<16;x++)
for(y=0;y<16;y++)
{
daten.vals[y][x]=fgetc(fp);
if (daten.vals[y][x]==EOF) daten.vals[y][x]=0;
}
for(x=0;x<16;x++)
for(y=0;y<16;y++)
printf("%c",daten.vals[y][x]);
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z;
printf("%s\n",tohex(0));
printf("%s\n",tohex(10));
printf("%s\n",tohex(20));
printf("%s\n",tohex(30));
printf("%s\n",tohex(40));
printf("%s\n",tohex(50));
//Vorbereitung
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"THX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// pointer setzen
initvar();
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
for (i=1;i<17;i++)
{
ptv = tohex(i-1);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,i,1,soffs);
for (z=0;z<16;z++)
{
ptv = tohex(daten.vals[z][i-1]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,i,1,shex);
for (z=0;z<16;z++)
{
xascii[z] = ((daten.vals[z][i-1]) > 33)?(daten.vals[z][i-1]):254;
}
mvwaddstr(wascii,i,1,sascii);
}
wrefresh(woffs);
wrefresh(whex);
wrefresh(wascii);
wrefresh(wtop);
wrefresh(wbot);
sleep(1);
endscr();
return (fclose(fp));
}

1226
tiahv10.cc Normal file

File diff suppressed because it is too large Load Diff

1248
tiahv11.cc Normal file

File diff suppressed because it is too large Load Diff

286
tiahv2.cc Normal file
View File

@@ -0,0 +1,286 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
struct data
{
struct data* plast;
struct data* pnext;
char vals[16][16];
};
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pdaten,*pfirst, *phelp;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tohex(int base10)
{
int newbase=16;
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
int loadcontents()
{
int retval=0;
int x,y;
char ch;
int k=0;
pdaten=pfirst;
ch=fgetc(fp);
while (!(ch==EOF))
{
k++;
for(x=0;x<16;x++)
for(y=0;y<16;y++)
{
((*pdaten).vals[y][x])=ch;
if ((*pdaten).vals[y][x]==EOF) (*pdaten).vals[y][x]=0;
ch=fgetc(fp);
}
if(!(ch==EOF))
{
phelp=pdaten;
printf("Vorher:%p\n",pdaten);
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
printf("Nachher:%p\n" ,pdaten);
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
}
/* D E B U G O N L Y
getchar();
pdaten=pfirst;
while (k--)
{
for(x=0;x<16;x++)
for(y=0;y<16;y++)
{
printf("%c-",(*pdaten).vals[y][x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
pdaten=pfirst;
for(;(*pdaten).pnext;pdaten=(*pdaten).pnext)
;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z;
unsigned long zeile=0,pos=0;
printf("%s\n",tohex(0));
printf("%s\n",tohex(10));
printf("%s\n",tohex(20));
printf("%s\n",tohex(30));
printf("%s\n",tohex(40));
printf("%s\n",tohex(50));
//Vorbereitung
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"THX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
for (i=1;i<17;i++)
{
ptv = tohex(i-1);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,i,1,soffs);
for (z=0;z<16;z++)
{
ptv = tohex(daten.vals[z][i-1]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,i,1,shex);
for (z=0;z<16;z++)
{
xascii[z] = ((daten.vals[z][i-1]) > 33)?(daten.vals[z][i-1]):254;
}
mvwaddstr(wascii,i,1,sascii);
}
wrefresh(woffs);
wrefresh(whex);
wrefresh(wascii);
wrefresh(wtop);
wrefresh(wbot);
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

463
tiahv3.cc Normal file
View File

@@ -0,0 +1,463 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
struct data
{
struct data* plast;
struct data* pnext;
char vals[16];
unsigned long zeile;
char len;
};
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pdaten,*pfirst, *phelp;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).zeile=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Tastatureingabe erlauben
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tohex(int base10)
{
int newbase=16;
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
int k=0;
unsigned long zeile=0;
pdaten=pfirst;
ch=fgetc(fp);
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(ch==EOF))
{
for(x=0;x<16;x++)
{
((*pdaten).vals[x])=ch;
if ((*pdaten).vals[x]==EOF)
{
(*pdaten).vals[x]=0;
break;
}
(*pdaten).len=x+1;
ch=fgetc(fp);
}
(*pdaten).zeile=zeile++;
if(!(ch==EOF))
{
phelp=pdaten;
if (!(zeile%500)) {fprintf(stderr,"%c",'#');}
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
}
/* D E B U G O N L Y
getchar();
pdaten=pfirst;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
pdaten=pfirst;
for(;(*pdaten).pnext;pdaten=(*pdaten).pnext)
;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
wrefresh(woffs);
wrefresh(whex);
wrefresh(wascii);
wrefresh(wtop);
wrefresh(wbot);
}
void lineout(unsigned long zeile)
{
int z;
miniinit();
ptv = tohex((*pdaten).zeile);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,zeile,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tohex((*pdaten).vals[z]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,zeile,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
xascii[z] = (((*pdaten).vals[z]) > 33)?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,zeile,1,sascii);
}
void scrolld()
{
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
int z;
miniinit();
ptv = tohex((*pdaten).zeile);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,16,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tohex((*pdaten).vals[z]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,16,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
xascii[z] = (((*pdaten).vals[z]) > 33)?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,16,1,sascii);
}
void scrollu()
{
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
int z;
ptv = tohex((*pdaten).zeile);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,1,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tohex((*pdaten).vals[z]);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,1,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
xascii[z] = (((*pdaten).vals[z]) > 33)?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,1,1,sascii);
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z;
unsigned long zeile=0,pos=0;
bool schalter;
int inpch;
//Vorbereitung
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"THX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"THX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
schalter=false;
zeile=1;
pdaten=pfirst;
//Initiale Ausgabe (Alle)
for(i=0;i<16;i++)
{
lineout(i+1);
if (schalter) break;
pdaten=(*pdaten).pnext;
if ((*pdaten).pnext == NULL) schalter=true;
}
scrrefresh();
if(i>15) pdaten=(*pdaten).plast;
//Eventschleife
while(inpch!=KEY_END)
{
inpch=wgetch(whex);
switch(inpch)
{
case KEY_DOWN:
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
break;
case KEY_UP:
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
break;
case KEY_NPAGE:
for(i=0;i<16;i++)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
case KEY_PPAGE:
for(i=0;i<16;i++)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
break;
};
scrrefresh();
}
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

450
tiahv4.cc Normal file
View File

@@ -0,0 +1,450 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
struct data
{
struct data* plast;
struct data* pnext;
char vals[16];
unsigned long zeile;
char len;
};
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII ";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
int result;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten,*pdaten,*pfirst, *phelp;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).zeile=0;
(*pfirst).len=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Tastatureingabe erlauben
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tonumsysx(int base10,int newbase)
{
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
int k=0;
unsigned long zeile=0;
pdaten=pfirst;
ch=fgetc(fp);
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(feof(fp)))
{
for(x=0;x<16;x++)
{
((*pdaten).vals[x])=ch;
if (feof(fp)) //(*pdaten).vals[x]==EOF)
{
(*pdaten).vals[x]=0;
break;
}
(*pdaten).len=x+1;
ch=fgetc(fp);
}
(*pdaten).zeile=zeile++;
if(!(feof(fp)))
{
phelp=pdaten;
if (!(zeile%500)) {fprintf(stderr,"%c",'#');}
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
// BUG: Check for Memory-Full does not work.
if(!pdaten) {abort();}
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
}
/* D E B U G O N L Y
getchar();
pdaten=pfirst;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
pdaten=pfirst;
for(;(*pdaten).pnext;pdaten=(*pdaten).pnext)
;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(2));
wattrset(wbot,COLOR_PAIR(2));
wrefresh(woffs);
wrefresh(whex);
wrefresh(wascii);
wrefresh(wtop);
wrefresh(wbot);
}
void lineout(unsigned long zeile)
{
int z;
miniinit();
ptv = tonumsysx((*pdaten).zeile*16,16);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,zeile,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tonumsysx((*pdaten).vals[z],16);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,zeile,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
xascii[z] = (((*pdaten).vals[z]) > 31)?((*pdaten).vals[z]):254;
}
mvwaddstr(wascii,zeile,1,sascii);
}
void initout()
{
//Initiale Ausgabe (Alle)
int i;
bool schalter=false;
unsigned long zeile=1;
pdaten=pfirst;
if ((*pdaten).pnext == NULL) schalter=true;
for(i=0;i<16;i++)
{
lineout(i+1);
if (schalter) break;
pdaten=(*pdaten).pnext;
if ((*pdaten).pnext == NULL) schalter=true;
}
scrrefresh();
if(i>15) pdaten=(*pdaten).plast;
}
void scrolld()
{
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
int z;
miniinit();
lineout(16);
}
void scrollu()
{
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
lineout(1);
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z;
unsigned long zeile=0,pos=0;
bool schalter;
int inpch;
printf("GHEX Version 0.5\n");
//Vorbereitung
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
mvwaddstr(wbot,1,1,argv[1]);
//Hauptprogramm
initout();
//Eventschleife
while(inpch!=KEY_F(10))
{
inpch=wgetch(whex);
switch(inpch)
{
case KEY_DOWN:
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
break;
case KEY_UP:
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
break;
case KEY_NPAGE:
for(i=0;i<16;i++)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
case KEY_PPAGE:
for(i=0;i<16;i++)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
break;
case KEY_HOME:
initout();
break;
case KEY_END:
while((*pdaten).pnext)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
};
scrrefresh();
}
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

766
tiahv5.cc Normal file
View File

@@ -0,0 +1,766 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
struct data // Eine Zeile Speicher
{
struct data* plast;
struct data* pnext;
unsigned char vals[16];
unsigned long zeile;
char len;
};
struct cpos // Cursor-Position
{
char x,y;
}pos;
int mode=1;
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII ";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
char empty78[]=" ";
int result;
char *filename;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten, *pdaten, *pfirst, *phelp, *pmax;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).zeile=0;
(*pfirst).len=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Tastatureingabe erlauben
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// Echo ausschalten
noecho();
// Cursor auf Groß setzen
// if(curs_set(2)==ERR) retval=1 ;
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
if(init_pair(3,COLOR_MAGENTA,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(3));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tonumsysx(int base10,int newbase)
{
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
unsigned long xto10(char *c, int oldbase)
{
unsigned long base10=0;
unsigned long rest,erg;
int pos=0;
int i;
for (i=0;c[i];i++, c[i]=toupper(c[i]));
while(c[pos++]);
pos--;
int len=pos-1;
while(pos--)
{
if(isdigit(c[len-pos]))
{
base10 = base10 + (unsigned long)( (double)(c[len-pos]-'0') * ( pow( (double)oldbase,(double)pos ) ) ) ;
}
else
{
base10 = base10 + (unsigned long)( ((double)(c[len-pos]-'A')+10) * ( pow( (double)oldbase,(double)pos ) ) );
}
}
return(base10);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
int k=0;
unsigned long zeile=0;
pdaten=pfirst;
ch=fgetc(fp);
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(feof(fp)))
{
for(x=0;x<16;x++)
{
((*pdaten).vals[x])=ch;
if (feof(fp)) //(*pdaten).vals[x]==EOF)
{
(*pdaten).vals[x]=0;
break;
}
(*pdaten).len=x+1;
ch=fgetc(fp);
}
(*pdaten).zeile=zeile++;
if(!(feof(fp)))
{
phelp=pdaten;
if (!(zeile%500)) {fprintf(stderr,"%c",'#');}
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
// BUG: Check for Memory-Full does not work.
if(!pdaten) {abort();}
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
pmax=pdaten;
}
/* D E B U G O N L Y
pdaten=pfirst;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
/* DEBUG ONLY
pdaten=pfirst;
int zeile=16;
int x;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
pdaten=pmax;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(3));
wattrset(wbot,COLOR_PAIR(2));
!mode?wmove(whex,pos.y,pos.x):wmove(wascii,pos.y,pos.x);
wrefresh(woffs);
wrefresh(wtop);
wrefresh(wbot);
// die Reihenfolge wird anhand des Modus bestimmt (das letzte ist aktiv)
!mode?wrefresh(wascii):wrefresh(whex);
mode?wrefresh(wascii):wrefresh(whex);
}
void lineout(unsigned long zeile)
{
int z;
miniinit();
ptv = tonumsysx((*pdaten).zeile*16,16);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,zeile,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tonumsysx((*pdaten).vals[z],16);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,zeile,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
// BUG: Die Ober- und Untergrenze genau bestimmen.
xascii[z] = (isgraph((*pdaten).vals[z]))?((*pdaten).vals[z]):'.';
}
mvwaddstr(wascii,zeile,1,sascii);
}
void initout()
{
//Initiale Ausgabe (Alle)
int i;
bool schalter=false;
unsigned long zeile=1;
pdaten=pfirst;
if ((*pdaten).pnext == NULL) schalter=true;
for(i=0;i<16;i++)
{
lineout(i+1);
if (schalter) break;
pdaten=(*pdaten).pnext;
if ((*pdaten).pnext == NULL) schalter=true;
}
scrrefresh();
if(i>15) pdaten=(*pdaten).plast;
}
void scrolld()
{
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
int z;
miniinit();
lineout(16);
}
void scrollu()
{
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
lineout(1);
}
void switchmode()
{
if(mode==0)
{
mode=1; // modus:Hex->Ascii
// Umrechnen der Cursorposition
pos.x=((pos.x+1)/3);
}
else
{
mode=0; // modue:Ascii->Hex
// Umrechnen der Cursorposition
pos.x=((pos.x*3)-1);
}
}
void moveleft()
{
if(mode==0)
{
if(pos.x > 2)(pos.x%3)?pos.x-=2:pos.x--;
}
else
{
if(pos.x > 1)pos.x--;
}
}
void moveright()
{
if(mode==0)
{
if(pos.x < 48)(pos.x%3)?pos.x++:pos.x+=2;
}
else
{
if(pos.x < 16)pos.x++;
}
}
unsigned long getactpos()
{
int i=0;
unsigned long actpos;
int posxsave=9999;
if (!mode)
{
posxsave=pos.x;
switchmode();
}
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
// Position holen
actpos=((*pdaten).zeile*16)+pos.x-1;
// wieder zurückblättern
while(i--)
{
pdaten=(*pdaten).pnext;
}
if (posxsave!=9999)
{
switchmode();
pos.x=posxsave;
}
return(actpos);
}
void charin(char ch)
{
int i=0;
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
// Wert schreiben
(*pdaten).vals[pos.x-1]=ch;
// Ausgabe aktualisieren
lineout(pos.y);
// wieder zurückblättern
while(i--)
{
pdaten=(*pdaten).pnext;
}
}
int charout()
{
int i=0;
int ch;
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
// Wert lesen
ch=((*pdaten).vals[pos.x-1]);
// wieder zurückblättern
while(i--)
{
pdaten=(*pdaten).pnext;
}
return(ch);
}
void bottomout()
{
mvwaddstr(wbot,1,1,empty78);
mvwaddstr(wbot,2,1,empty78);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,1,"CHR:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddch(wbot,1,6,32);
mvwaddch(wbot,1,5,(isgraph(charout()))?charout():'.');
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,9,"HEX:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,13,(tonumsysx(charout(),16))+6);
mvwaddch(wbot,1,15,'h');
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,18,"DEC:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,22,(tonumsysx(charout(),10))+5);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,27,"OCT:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,31,(tonumsysx(charout(),8))+4);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,37,"BIN:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,41,tonumsysx(charout(),2));
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,52,"Offset:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,59,tonumsysx(getactpos(),16));
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,67,"h -");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,71,tonumsysx(getactpos(),10));
mvwaddstr(wbot,2,1,filename);
}
int main(int argc, char *argv[])
{
/* --- DEBUG ONLY
printf("DEBUG: 5-%u\n",xto10(tonumsysx(5,2),2));
printf("DEBUG: 16-%u\n",xto10(tonumsysx(16,16),16));
printf("DEBUG: 36-%u\n",xto10 (tonumsysx(36,36),36));
printf("DEBUG: 255-%u\n",xto10(tonumsysx(255,16),16));
printf("DEBUG: 255-%u\n",xto10("FF",16));
printf("DEBUG: 125-%u\n",xto10(tonumsysx(125,8),8));
printf("DEBUG: 255-%u\n",xto10(tonumsysx(255,8),8));
getchar();
--- END DEBUG */
//Variablen
unsigned int i,z; // Allgemeine Zähler
unsigned long zeile=0; // Zeilennummer
bool schalter; // Schalter für lesevorlauf
int inpch; // Eingabezeichen
//Vorbereitung
printf("GHEX Version 0.5\n");
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
// sonstige Variableninitialisierung
pos.x = pos.y = 1;
filename=argv[1];
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
//Hauptprogramm
initout();
bottomout();
scrrefresh();
/* --- DEBUG ONLY
fprintf(stdout,"D%d\n",charout());
pos.x++;
fprintf(stdout,"D%d\n",charout());
pos.x++;
fprintf(stdout,"D%d\n",charout());
pos.x++;
fprintf(stdout,"D%d\n",charout());
pos.x++;
fprintf(stdout,"D%d\n",charout());
getchar();
-- END DEBUG */
//Eventschleife
while(inpch!=KEY_F(10))
{
if (mode==0)
{
inpch=wgetch(whex);
}
else
{
inpch=wgetch(wascii);
}
switch(inpch)
{
case KEY_F(9): switchmode();
break;
case KEY_LEFT: moveleft();
break;
case KEY_RIGHT:moveright();
break;
case KEY_DOWN: if(pos.y>15)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
else
{
pos.y++;
}
break;
case KEY_UP: if(pos.y<2)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
else
{
pos.y--;
}
break;
case KEY_NPAGE:
for(i=0;i<16;i++)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
case KEY_PPAGE:
for(i=0;i<16;i++)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
break;
case KEY_HOME:
initout();
break;
case KEY_END: pdaten=pmax;
for(i=0;((*pdaten).plast) && (i < 16);i++)
{
pdaten=(*pdaten).plast;
}
while((*pdaten).pnext)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
default:
if(mode==0)
{
if(isdigit(inpch) || (toupper(inpch)>='A' && toupper(inpch)<='F') )
{
waddch(whex,toupper(inpch));
char hch[]="FF";
// hch korrekt füllen.
int xpos=pos.x; // Position sichern
switchmode(); // um die Koordinaten umzurechnen
ptv=tonumsysx(charout(),16); // Aktuelles Zeichen in Hex.
//* --- DEBUG ONLY
mvwaddstr(wbot,2,30,tonumsysx(charout(),16));
// --- END DEBUG
switchmode(); // Koordinaten zurückrechnen
pos.x=xpos; // position restaurieren
hch[0] = *(ptv+6);
hch[1] = *(ptv+7);
//* --- DEBUG ONLY
mvwaddstr(wbot,2,1,hch);
mvwaddstr(wbot,2,20,ptv);
// --- END DEBUG
hch[(pos.x%3)?0:1]=inpch;
switchmode(); // um die Koordinaten umzurechnen
charin(xto10(hch,16)); // Umrechnen Hex -> Ascii+charin
switchmode(); // und wieder zurücksetzen
pos.x=xpos; // position restaurieren
moveright();
}
else
{
//if((inpch > 31)&&(inpch < 256))
if((inpch < 256))
{
waddch(wascii,inpch);
charin(inpch);
moveright();
}
}
}
};
bottomout();
scrrefresh();
// fprintf(stderr,"x: %d %d",pos.x,charout());
}
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

811
tiahv6.cc Normal file
View File

@@ -0,0 +1,811 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
struct data // Eine Zeile Speicher
{
struct data* plast;
struct data* pnext;
unsigned char vals[16];
unsigned long zeile;
char len;
};
struct cpos // Cursor-Position
{
char x,y;
}pos;
char insovr='O'; // Isert/Override-Mode
int mode=1;
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII ";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
char empty78[]=" ";
int result;
char *filename;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten, *pdaten, *pfirst, *phelp, *pmax;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).zeile=0;
(*pfirst).len=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Tastatureingabe erlauben
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// Echo ausschalten
noecho();
// Cursor auf Groß setzen
// if(curs_set(2)==ERR) retval=1 ;
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
if(init_pair(3,COLOR_MAGENTA,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(3));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tonumsysx(int base10,int newbase)
{
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
unsigned long xto10(char *c, int oldbase)
{
unsigned long base10=0;
unsigned long rest,erg;
int pos=0;
int i;
for (i=0;c[i];i++, c[i]=toupper(c[i]));
while(c[pos++]);
pos--;
int len=pos-1;
while(pos--)
{
if(isdigit(c[len-pos]))
{
base10 = base10 + (unsigned long)( (double)(c[len-pos]-'0') * ( pow( (double)oldbase,(double)pos ) ) ) ;
}
else
{
base10 = base10 + (unsigned long)( ((double)(c[len-pos]-'A')+10) * ( pow( (double)oldbase,(double)pos ) ) );
}
}
return(base10);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
int k=0;
unsigned long zeile=0;
pdaten=pfirst;
ch=fgetc(fp);
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(feof(fp)))
{
for(x=0;x<16;x++)
{
((*pdaten).vals[x])=ch;
if (feof(fp)) //(*pdaten).vals[x]==EOF)
{
(*pdaten).vals[x]=0;
break;
}
(*pdaten).len=x+1;
ch=fgetc(fp);
}
(*pdaten).zeile=zeile++;
if(!(feof(fp)))
{
phelp=pdaten;
if (!(zeile%500)) {fprintf(stderr,"%c",'#');}
pdaten=((*pdaten).pnext)=(malloc(sizeof(daten)));
// BUG: Check for Memory-Full does not work.
if(!pdaten) {abort();}
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
pmax=pdaten;
}
/* D E B U G O N L Y
pdaten=pfirst;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
/* DEBUG ONLY
pdaten=pfirst;
int zeile=16;
int x;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
pdaten=pmax;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(3));
wattrset(wbot,COLOR_PAIR(2));
!mode?wmove(whex,pos.y,pos.x):wmove(wascii,pos.y,pos.x);
wrefresh(woffs);
wrefresh(wtop);
wrefresh(wbot);
// die Reihenfolge wird anhand des Modus bestimmt (das letzte ist aktiv)
!mode?wrefresh(wascii):wrefresh(whex);
mode?wrefresh(wascii):wrefresh(whex);
}
void lineout(unsigned long zeile)
{
int z;
miniinit();
ptv = tonumsysx((*pdaten).zeile*16,16);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,zeile,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tonumsysx((*pdaten).vals[z],16);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,zeile,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
// BUG: Die Ober- und Untergrenze genau bestimmen.
xascii[z] = (isgraph((*pdaten).vals[z]))?((*pdaten).vals[z]):'.';
}
mvwaddstr(wascii,zeile,1,sascii);
}
void initout()
{
//Initiale Ausgabe (Alle)
int i;
bool schalter=false;
unsigned long zeile=1;
pdaten=pfirst;
if ((*pdaten).pnext == NULL) schalter=true;
for(i=0;i<16;i++)
{
lineout(i+1);
if (schalter) break;
pdaten=(*pdaten).pnext;
if ((*pdaten).pnext == NULL) schalter=true;
}
scrrefresh();
if(i>15) pdaten=(*pdaten).plast;
}
void scrolld()
{
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
int z;
miniinit();
lineout(16);
}
void scrollu()
{
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
lineout(1);
}
void switchmode()
{
if(mode==0)
{
mode=1; // modus:Hex->Ascii
// Umrechnen der Cursorposition
pos.x=((pos.x+1)/3);
}
else
{
mode=0; // modue:Ascii->Hex
// Umrechnen der Cursorposition
pos.x=((pos.x*3)-1);
}
}
void moveleft()
{
if(mode==0)
{
if(pos.x > 2)(pos.x%3)?pos.x-=2:pos.x--;
}
else
{
if(pos.x > 1)pos.x--;
}
}
void moveright()
{
if(mode==0)
{
if(pos.x < 48)(pos.x%3)?pos.x++:pos.x+=2;
}
else
{
if(pos.x < 16)pos.x++;
}
}
unsigned long getactpos()
{
int i=0;
unsigned long actpos;
int posxsave=9999;
if (!mode)
{
posxsave=pos.x;
switchmode();
}
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
// Position holen
actpos=((*pdaten).zeile*16)+pos.x-1;
// wieder zurückblättern
while(i--)
{
pdaten=(*pdaten).pnext;
}
if (posxsave!=9999)
{
switchmode();
pos.x=posxsave;
}
return(actpos);
}
void charin(char ch)
{
int i=0;
int z=0;
int sicchar=9999;
// Das eigentliche Enfügen des Zeichens
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
if (insovr=='I') // In Override-Mode
{
phelp=pdaten;
pdaten=pmax;
if ((*pdaten).len < 16)
{
(*pdaten).len++;
}
else
{
// allocate new element
}
while(pdaten!=phelp)
{
for(z=(*pdaten).len;z>0;z--)
{
(*pdaten).vals[z]=(*pdaten).vals[z-1];
}
(*pdaten).vals[0]=(*(*pdaten).plast).vals[15];
pdaten=(*pdaten).plast;
}
for(z=(*pdaten).len;z+1>pos.x;z--)
{
(*pdaten).vals[z]=(*pdaten).vals[z-1];
}
pdaten=phelp;
}
// Wert schreiben
(*pdaten).vals[pos.x-1]=ch;
// Ausgabe aktualisieren
lineout(pos.y);
// wieder zurückblättern
while(i--)
{
pdaten=(*pdaten).pnext;
}
}
int charout()
{
int i=0;
int ch;
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
// Wert lesen
ch=((*pdaten).vals[pos.x-1]);
// wieder zurückblättern
while(i--)
{
pdaten=(*pdaten).pnext;
}
return(ch);
}
void bottomout()
{
mvwaddstr(wbot,1,1,empty78);
mvwaddstr(wbot,2,1,empty78);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,1,"CHR:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddch(wbot,1,6,32);
mvwaddch(wbot,1,5,(isgraph(charout()))?charout():'.');
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,9,"HEX:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,13,(tonumsysx(charout(),16))+6);
mvwaddch(wbot,1,15,'h');
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,18,"DEC:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,22,(tonumsysx(charout(),10))+5);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,27,"OCT:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,31,(tonumsysx(charout(),8))+4);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,37,"BIN:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,41,tonumsysx(charout(),2));
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,52,"Offset:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,59,tonumsysx(getactpos(),16));
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,67,"h -");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,71,tonumsysx(getactpos(),10));
mvwaddstr(wbot,2,1,filename);
mvwaddstr(wbot,2,76,(insovr=='O')?"OVR":"INS");
}
int main(int argc, char *argv[])
{
/* --- DEBUG ONLY
printf("DEBUG: 5-%u\n",xto10(tonumsysx(5,2),2));
printf("DEBUG: 16-%u\n",xto10(tonumsysx(16,16),16));
printf("DEBUG: 36-%u\n",xto10 (tonumsysx(36,36),36));
printf("DEBUG: 255-%u\n",xto10(tonumsysx(255,16),16));
printf("DEBUG: 255-%u\n",xto10("FF",16));
printf("DEBUG: 125-%u\n",xto10(tonumsysx(125,8),8));
printf("DEBUG: 255-%u\n",xto10(tonumsysx(255,8),8));
getchar();
--- END DEBUG */
//Variablen
unsigned int i,z; // Allgemeine Zähler
unsigned long zeile=0; // Zeilennummer
bool schalter; // Schalter für lesevorlauf
int inpch; // Eingabezeichen
//Vorbereitung
printf("GHEX Version 0.5\n");
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
// sonstige Variableninitialisierung
pos.x = pos.y = 1;
filename=argv[1];
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
//Hauptprogramm
initout();
bottomout();
scrrefresh();
/* --- DEBUG ONLY
fprintf(stdout,"D%d\n",charout());
pos.x++;
fprintf(stdout,"D%d\n",charout());
pos.x++;
fprintf(stdout,"D%d\n",charout());
pos.x++;
fprintf(stdout,"D%d\n",charout());
pos.x++;
fprintf(stdout,"D%d\n",charout());
getchar();
-- END DEBUG */
//Eventschleife
while(inpch!=KEY_F(10))
{
if (mode==0)
{
inpch=wgetch(whex);
}
else
{
inpch=wgetch(wascii);
}
switch(inpch)
{
case KEY_F(9): switchmode();
break;
case KEY_F(1): initout();
break;
case KEY_EIC:
//fallthru
case KEY_IC : if (insovr=='O')
{
insovr='I';
}
else
{
insovr='O';
}
break;
case KEY_LEFT: moveleft();
break;
case KEY_RIGHT:moveright();
break;
case KEY_DOWN: if(pos.y>15)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
else
{
pos.y++;
}
break;
case KEY_UP: if(pos.y<2)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
else
{
pos.y--;
}
break;
case KEY_NPAGE:
for(i=0;i<16;i++)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
case KEY_PPAGE:
for(i=0;i<16;i++)
{
z=0;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
if(z>15)
{
z--;
scrollu();
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
}
break;
case KEY_HOME:
initout();
break;
case KEY_END: pdaten=pmax;
for(i=0;((*pdaten).plast) && (i < 16);i++)
{
pdaten=(*pdaten).plast;
}
while((*pdaten).pnext)
{
if ((*pdaten).pnext != NULL)
{ pdaten=(*pdaten).pnext;
scrolld();
}
}
break;
default:
if(mode==0)
{
if(isdigit(inpch) || (toupper(inpch)>='A' && toupper(inpch)<='F') )
{
waddch(whex,toupper(inpch));
char hch[]="FF";
// hch korrekt füllen.
int xpos=pos.x; // Position sichern
switchmode(); // um die Koordinaten umzurechnen
ptv=tonumsysx(charout(),16); // Aktuelles Zeichen in Hex.
//* --- DEBUG ONLY
mvwaddstr(wbot,2,30,tonumsysx(charout(),16));
// --- END DEBUG
switchmode(); // Koordinaten zurückrechnen
pos.x=xpos; // position restaurieren
hch[0] = *(ptv+6);
hch[1] = *(ptv+7);
//* --- DEBUG ONLY
mvwaddstr(wbot,2,1,hch);
mvwaddstr(wbot,2,20,ptv);
// --- END DEBUG
hch[(pos.x%3)?0:1]=inpch;
switchmode(); // um die Koordinaten umzurechnen
charin(xto10(hch,16)); // Umrechnen Hex -> Ascii+charin
switchmode(); // und wieder zurücksetzen
pos.x=xpos; // position restaurieren
moveright();
}
}
else
{
if((inpch < 256))
{
waddch(wascii,inpch);
charin(inpch);
moveright();
}
}
};
bottomout();
scrrefresh();
// fprintf(stderr,"x: %d %d",pos.x,charout());
}
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

927
tiahv7.cc Normal file
View File

@@ -0,0 +1,927 @@
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
struct data // Eine Zeile Speicher
{
struct data* plast;
struct data* pnext;
unsigned char vals[16];
unsigned long zeile;
char len;
};
struct cpos // Cursor-Position
{
char x,y;
}pos;
char insovr='O'; // Isert/Override-Mode
int mode=1;
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII ";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
char empty78[]=" ";
int result;
char *filename;
char *ptv="12345678";
FILE *fp;
int ipoint;
data daten, *pdaten, *pfirst, *phelp, *pmax;
void initvar()
{
pfirst=&daten;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).zeile=0;
(*pfirst).len=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// Scrollen erlauben
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// Tastatureingabe erlauben
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// Echo ausschalten
noecho();
// Cursor auf Groß setzen
// if(curs_set(2)==ERR) retval=1 ;
// Color-Pairs anlegen (Farbkombinationen)
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
if(init_pair(3,COLOR_MAGENTA,COLOR_BLACK)) retval=1;
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(3));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tonumsysx(int base10,int newbase)
{
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
unsigned long xto10(char *c, int oldbase)
{
unsigned long base10=0;
unsigned long rest,erg;
int pos=0;
int i;
for (i=0;c[i];i++, c[i]=toupper(c[i]));
while(c[pos++]);
pos--;
int len=pos-1;
while(pos--)
{
if(isdigit(c[len-pos]))
{
base10 = base10 + (unsigned long)( (double)(c[len-pos]-'0') * ( pow( (double)oldbase,(double)pos ) ) ) ;
}
else
{
base10 = base10 + (unsigned long)( ((double)(c[len-pos]-'A')+10) * ( pow( (double)oldbase,(double)pos ) ) );
}
}
return(base10);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
int k=0;
unsigned long zeile=0;
pdaten=pfirst;
ch=fgetc(fp);
// Zero-byte-file.
if(feof(fp))
{
fprintf(stderr,"opening 0-Byte file");
pfirst=pmax=pdaten=(data*)(malloc(sizeof(daten)));
(*pdaten).pnext=NULL;
(*pdaten).plast=NULL;
(*pdaten).zeile=0;
(*pdaten).len=0;
}
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(feof(fp)))
{
for(x=0;x<16;x++)
{
((*pdaten).vals[x])=ch;
if (feof(fp)) //(*pdaten).vals[x]==EOF)
{
(*pdaten).vals[x]=0;
break;
}
(*pdaten).len=x+1;
ch=fgetc(fp);
}
(*pdaten).zeile=zeile++;
if(!(feof(fp)))
{
phelp=pdaten;
if (!(zeile%500)) {fprintf(stderr,"%c",'#');}
pdaten=((*pdaten).pnext)=(data*)(malloc(sizeof(daten)));
// BUG: Check for Memory-Full does not work.
if(!pdaten) {abort();}
(*pdaten).plast=phelp;
(*pdaten).pnext=NULL;
}
pmax=pdaten;
}
/* D E B U G O N L Y
pdaten=pfirst;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
int zv;
/* DEBUG ONLY
pdaten=pfirst;
int zeile=16;
int x;
printf("%d\n",zeile);
while (zeile--)
{
for(x=0;x<16;x++)
{
printf("%c-",(*pdaten).vals[x]);
}
pdaten=(*pdaten).pnext;
}
getchar();
--- END DEBUG ---*/
pdaten=pmax;
while((*pdaten).plast)
{
phelp=(*pdaten).plast;
free(pdaten);
pdaten=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(3));
wattrset(wbot,COLOR_PAIR(2));
!mode?wmove(whex,pos.y,pos.x):wmove(wascii,pos.y,pos.x);
wrefresh(woffs);
wrefresh(wtop);
wrefresh(wbot);
// die Reihenfolge wird anhand des Modus bestimmt (das letzte ist aktiv)
!mode?wrefresh(wascii):wrefresh(whex);
mode?wrefresh(wascii):wrefresh(whex);
}
void lineout(unsigned long zeile)
{
int z;
miniinit();
ptv = tonumsysx((*pdaten).zeile*16,16);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,zeile,1,soffs);
for (z=0;z<(*pdaten).len;z++)
{
ptv = tonumsysx((*pdaten).vals[z],16);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,zeile,1,shex);
for (z=0;z<(*pdaten).len;z++)
{
// BUG: Die Ober- und Untergrenze genau bestimmen.
xascii[z] = (isgraph((*pdaten).vals[z]))?((*pdaten).vals[z]):'.';
}
mvwaddstr(wascii,zeile,1,sascii);
}
void initout()
{
//Initiale Ausgabe (Alle)
int i;
bool schalter=false;
unsigned long zeile=1;
pdaten=pfirst;
if ((*pdaten).pnext == NULL) schalter=true;
for(i=0;i<16;i++)
{
lineout(i+1);
if (schalter) break;
pdaten=(*pdaten).pnext;
if ((*pdaten).pnext == NULL) schalter=true;
}
scrrefresh();
if(i>15) pdaten=(*pdaten).plast;
}
int scrolld()
{
int resval;
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
miniinit();
lineout(16);
resval=1;
}
else
{
resval=0;
}
return(resval);
}
int scrollu()
{
int z=0;
int result;
while(((*pdaten).plast != NULL)&&(z < 16))
{
pdaten=(*pdaten).plast;
z++;
}
result= (z!=15)?1:0;
if(z>15)
{
z--;
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
lineout(1);
}
while(z--)
{
if ((*pdaten).pnext != NULL)
{
pdaten=(*pdaten).pnext;
}
}
return(result);
}
void switchmode()
{
if(mode==0)
{
mode=1; // modus:Hex->Ascii
// Umrechnen der Cursorposition
pos.x=((pos.x+1)/3);
}
else
{
mode=0; // modus:Ascii->Hex
// Umrechnen der Cursorposition
pos.x=((pos.x*3)-1);
}
}
void moveleft()
{
if(mode==0)
{
if(pos.x > 2)
{
(pos.x%3)?pos.x-=2:pos.x--;
}
else
{
if(pos.y >1)
{
pos.y--;
pos.x=48;
}
else
{
if(scrollu())pos.x=48;
}
}
}
else
{
if(pos.x > 1)
{
pos.x--;
}
else
{
if(pos.y >1)
{
pos.y--;
pos.x=16;
}
else
{
if(scrollu())pos.x=16;
}
}
}
}
void moveright()
{
if(mode==0)
{
if(pos.x < 48)
{
(pos.x%3)?pos.x++:pos.x+=2;
}
else
{
if(pos.y < 16)
{
pos.x=2;
pos.y++;
}
else
{
if(scrolld()) pos.x=2;
}
}
}
else
{
if((pos.x < 16))
{
pos.x++;
}
else
{
if(pos.y < 16)
{
pos.x=1;
pos.y++;
}
else
{
if(scrolld()) pos.x=1;
}
}
}
}
unsigned long getactpos()
{
int i=0;
unsigned long actpos;
int posxsave=9999;
if (!mode)
{
posxsave=pos.x;
switchmode();
}
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
// Position holen
actpos=((*pdaten).zeile*16)+pos.x-1;
// wieder zurückblättern
while(i--)
{
pdaten=(*pdaten).pnext;
}
if (posxsave!=9999)
{
switchmode();
pos.x=posxsave;
}
return(actpos);
}
void charin(char ch, int realmode, int realxpos)
{
int i=0;
int z=0;
int sicchar=9999;
data *phelp2;
unsigned long zhelp;
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
fprintf(stderr,"%d Pos. zurück\n",i);
// Für den Einfügemodus
if (((insovr=='I') && (realmode==1))||((insovr=='I') && (realmode==0) && (realxpos%3==2)) && (realmode!=3))
{
phelp=pdaten;
pdaten=pmax;
if ((*pdaten).len < 16)
{
(*pdaten).len++;
}
else
{
// allocate new element
phelp2=pmax;
zhelp=(*pmax).zeile+1;
pdaten=pmax=((*pdaten).pnext)=(data*)(malloc(sizeof(daten)));
if(!pmax) {abort();}
(*pmax).plast=phelp2;
(*pmax).pnext=NULL;
(*pmax).len=1;
(*pmax).zeile=zhelp;
}
while(pdaten!=phelp)
{
for(z=(*pdaten).len-1;z>0;z--)
{
(*pdaten).vals[z]=(*pdaten).vals[z-1];
}
(*pdaten).vals[0]=(*(*pdaten).plast).vals[15];
pdaten=(*pdaten).plast;
}
for(z=(*pdaten).len-1;z+1>pos.x;z--)
{
(*pdaten).vals[z]=(*pdaten).vals[z-1];
}
pdaten=phelp;
}
// Wert schreiben
(*pdaten).vals[pos.x-1]=ch;
// Ausgabe aktualisieren
lineout(pos.y);
// wieder zurückblättern
while(i--)
{
if((*pdaten).pnext)
{
pdaten=(*pdaten).pnext;
lineout(16-i);
}
}
}
int charout()
{
int i=0;
int ch;
// im Speicher zur Cusrorposition blättern
while(i<(16-pos.y)&&((*pdaten).plast))
{
i++;
pdaten=(*pdaten).plast;
}
// Wert lesen
ch=((*pdaten).vals[pos.x-1]);
// wieder zurückblättern
while(i--)
{
//fprintf(stderr,"l");
pdaten=(*pdaten).pnext;
}
return(ch);
}
void bottomout()
{
int realmode,realposx;
realmode=mode;
if (realmode == 0)
{
realposx=pos.x;
switchmode();
}
mvwaddstr(wbot,1,1,empty78);
mvwaddstr(wbot,2,1,empty78);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,1,"CHR:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddch(wbot,1,6,32);
mvwaddch(wbot,1,5,(isgraph(charout()))?charout():'.');
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,9,"HEX:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,13,(tonumsysx(charout(),16))+6);
mvwaddch(wbot,1,15,'h');
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,18,"DEC:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,22,(tonumsysx(charout(),10))+5);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,27,"OCT:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,31,(tonumsysx(charout(),8))+4);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,37,"BIN:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,41,tonumsysx(charout(),2));
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,52,"Offset:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,59,tonumsysx(getactpos(),16));
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,67,"h -");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,71,tonumsysx(getactpos(),10));
mvwaddstr(wbot,2,1,filename);
mvwaddstr(wbot,2,76,(insovr=='O')?"OVR":"INS");
if (realmode == 0)
{
switchmode();
pos.x=realposx;
}
}
void swapbits(char bit)
{
char bin[]="12345678",*pbin; // Um Bits abzubilden
pbin=bin;
int realposx, realmode;
realmode=mode;
if (realmode==0)
{
realposx=pos.x;
switchmode();
}
pbin=tonumsysx(charout(),2);
pbin[bit]= (pbin[bit]=='0')?'1':'0';
charin(xto10(pbin,2),3,pos.x);
if (realmode==0)
{
switchmode();
pos.x=realposx;
}
}
int main(int argc, char *argv[])
{
//Variablen
unsigned int i,z; // Allgemeine Zähler
unsigned long zeile=0; // Zeilennummer
bool schalter; // Schalter für lesevorlauf
int inpch; // Eingabezeichen
//Vorbereitung
printf("GHEX Version 0.5\n");
//Parameter angegeben?
if(argc < 2)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//Datei öffnen
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// pointer setzen
initvar();
// sonstige Variableninitialisierung
pos.x = pos.y = 1;
filename=argv[1];
//Datei -> Speicher
if(loadcontents())
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// Terminal initialisieren
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
//Hauptprogramm
initout();
bottomout();
scrrefresh();
//Eventschleife
while(inpch!=KEY_F(10))
{
if (mode==0)
{
inpch=wgetch(whex);
}
else
{
inpch=wgetch(wascii);
}
switch(inpch)
{
case KEY_F(9): switchmode();
break;
case KEY_F(1): swapbits(0);
break;
case KEY_F(2): swapbits(1);
break;
case KEY_F(3): swapbits(2);
break;
case KEY_F(4): swapbits(3);
break;
case KEY_F(5): swapbits(4);
break;
case KEY_F(6): swapbits(5);
break;
case KEY_F(7): swapbits(6);
break;
case KEY_F(8): swapbits(7);
break;
case KEY_EIC: //fallthru
case KEY_IC : if (insovr=='O')
{
insovr='I';
}
else
{
insovr='O';
}
break;
case KEY_LEFT: moveleft();
break;
case KEY_RIGHT:moveright();
break;
case KEY_DOWN: if(pos.y>15)
{
scrolld();
}
else
{
pos.y++;
}
break;
case KEY_UP: if(pos.y<2)
{
scrollu();
}
else
{
pos.y--;
}
break;
case KEY_NPAGE:for(i=0;i<16;i++)
{
scrolld();
}
break;
case KEY_PPAGE:for(i=0;i<16;i++)
{
scrollu();
}
break;
case KEY_HOME: initout();
break;
case KEY_END: pdaten=pmax;
for(i=0;((*pdaten).plast) && (i < 16);i++)
{
pdaten=(*pdaten).plast;
}
while((*pdaten).pnext)
{
scrolld();
}
break;
default: if(mode==0)
{
if(isdigit(inpch) || (toupper(inpch)>='A' && toupper(inpch)<='F') )
{
waddch(whex,toupper(inpch));
char hch[]="00";
// hch korrekt füllen.
int xpos=pos.x; // Position sichern
switchmode(); // um die Koordinaten umzurechnen
ptv=tonumsysx(charout(),16); // Aktuelles Zeichen in Hex.
//* --- DEBUG ONLY
mvwaddstr(wbot,2,30,tonumsysx(charout(),16));
// --- END DEBUG
switchmode(); // Koordinaten zurückrechnen
pos.x=xpos; // position restaurieren
if (insovr=='O') // Predef. only in Override!
{
hch[0] = *(ptv+6);
hch[1] = *(ptv+7);
}
else // In Insert only first char
{
if(pos.x%3==0)
hch[0] = *(ptv+6);
}
//* --- DEBUG ONLY
mvwaddstr(wbot,2,1,hch);
mvwaddstr(wbot,2,20,ptv);
// --- END DEBUG
hch[(pos.x%3)?0:1]=inpch;
switchmode(); // um die Koordinaten umzurechnen
charin(xto10(hch,16),0,xpos); // Umrechnen Hex -> Ascii+charin
switchmode(); // und wieder zurücksetzen
pos.x=xpos; // position restaurieren
moveright();
}
}
else
{
if((inpch < 256))
{
waddch(wascii,inpch);
charin(inpch,1,pos.x);
moveright();
}
}
};
bottomout();
scrrefresh();
// fprintf(stderr,"x: %d %d",pos.x,charout());
}
sleep(1);
endscr();
unallocmem();
return (fclose(fp));
}

973
tiahv8.cc Normal file
View File

@@ -0,0 +1,973 @@
/*
* GHEX -- an advanced HEX-Editor
* Copyright (C) 1999 by Joerg Tretter
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
struct data // one line in Memory
{
struct data* plast;
struct data* pnext;
unsigned char vals[16];
unsigned long line;
char len;
};
struct cpos // Cursor-Position
{
char x,y;
}pos;
char insovr='O'; // Isert/Override-Mode
int mode=1;
WINDOW *stdscr,*woffs,*whex, *wascii, *wtop, *wbot;
const char *topline= " Offset Hex ASCII ";
char xoffs[] = "12345678",*soffs;
char xhex[] = " 14 15 16 32 32 34 20 54 61 67 65 73 61 6D 74 0D ",*shex;
char xascii[] = "1234567890123456",*sascii;
char empty78[]=" ";
int result;
char *filename;
char *ptv="12345678";
FILE *fp;
int ipoint;
data datas, *pdatas, *pfirst, *phelp, *pmax;
void initvar()
{
pfirst=&datas;
(*pfirst).plast=NULL;
(*pfirst).pnext=NULL;
(*pfirst).line=0;
(*pfirst).len=0;
soffs=xoffs;
shex=xhex;
sascii=xascii;
}
void miniinit()
{
xoffs = " ";
xhex = " ";
xascii = " ";
}
int screeninit()
{
int retval=0;
stdscr= initscr();
if(start_color()) retval=1;
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Create Curses-space for the windows
//TODO: check whether creation was fine.
woffs =newwin(18,10,3 ,0 );
whex =newwin(18,52,3 ,10);
wascii=newwin(18,18,3 ,62);
wtop =newwin(3 ,80,0 ,0 );
wbot =newwin(4 ,80,21,0 );
// enable scrolling
scrollok(woffs,1);
scrollok(whex,1);
scrollok(wascii,1);
// enable Keyboard-control
keypad(stdscr,1);
keypad(whex,1);
keypad(wascii,1);
// disable echoing of input
noecho();
// swich cursor to big size
// TODO: check why this not works in most cases
// if(curs_set(2)==ERR) retval=1 ;
// creation of curses "Color-Pairs"
if(init_pair(1,COLOR_BLUE,COLOR_BLACK)) retval=1;
if(init_pair(2,COLOR_CYAN,COLOR_BLACK)) retval=1;
if(init_pair(3,COLOR_MAGENTA,COLOR_BLACK)) retval=1;
// join the windows with the color-pairs
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
// paint the boxes around the windows (in fact it's inside)
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
// change the color-pairs of the windows again.
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(3));
wattrset(wbot,COLOR_PAIR(2));
return(retval);
}
char* tonumsysx(int base10,int newbase)
{
int erg;
int rest=0;
int pos=0;
int i;
static char swap[9];
char c[9];
swap="********";
c[pos]='0'+rest;
while (base10 > 0)
{
erg=base10/newbase;
rest=base10%newbase;
if (rest <= 9)
c[pos]='0'+rest;
else
c[pos]='A'+(rest-10);
base10=erg;
pos++;
c[pos]='\0';
}
while(pos < 8)
{
c[pos]='0';
pos++;
}
pos--;
for (i=0;i<=pos;i++)
{
swap[i]=c[pos-i];
}
return(swap);
}
unsigned long xto10(char *c, int oldbase)
{
unsigned long base10=0;
int pos=0;
int i;
for (i=0;c[i];i++, c[i]=toupper(c[i]));
while(c[pos++]);
pos--;
int len=pos-1;
while(pos--)
{
if(isdigit(c[len-pos]))
{
base10 = base10 + (unsigned long)( (double)(c[len-pos]-'0') * ( pow( (double)oldbase,(double)pos ) ) ) ;
}
else
{
base10 = base10 + (unsigned long)( ((double)(c[len-pos]-'A')+10) * ( pow( (double)oldbase,(double)pos ) ) );
}
}
return(base10);
}
int loadcontents()
{
int retval=0;
int x;
char ch;
unsigned long line=0;
pdatas=pfirst;
ch=fgetc(fp);
// Zero-byte-file.
if(feof(fp))
{
fprintf(stderr,"opening 0-Byte file");
pfirst=pmax=pdatas=(data*)(malloc(sizeof(datas)));
(*pdatas).pnext=NULL;
(*pdatas).plast=NULL;
(*pdatas).line=0;
(*pdatas).len=0;
}
printf("Printing hashmark for every 8 Kbytes.\n");
while (!(feof(fp)))
{
for(x=0;x<16;x++)
{
((*pdatas).vals[x])=ch;
if (feof(fp)) //(*pdatas).vals[x]==EOF)
{
(*pdatas).vals[x]=0;
break;
}
(*pdatas).len=x+1;
ch=fgetc(fp);
}
(*pdatas).line=line++;
if(!(feof(fp)))
{
phelp=pdatas;
if (!(line%500)) {printf("%c",'#');}
pdatas=((*pdatas).pnext)=(data*)(malloc(sizeof(datas)));
// BUG: Check for Memory-Full does not work.
if(!pdatas) {abort();}
(*pdatas).plast=phelp;
(*pdatas).pnext=NULL;
}
pmax=pdatas;
}
return (retval);
}
void endscr()
{
delwin(woffs);
delwin(whex);
delwin(wascii);
delwin(wtop);
delwin(wbot);
endwin();
}
void unallocmem()
{
pdatas=pmax;
while((*pdatas).plast)
{
phelp=(*pdatas).plast;
free(pdatas);
pdatas=phelp;
}
}
void scrrefresh()
{
wattrset(woffs,COLOR_PAIR(1));
wattrset(whex,COLOR_PAIR(1));
wattrset(wascii,COLOR_PAIR(1));
wattrset(wbot,COLOR_PAIR(1));
wattrset(wtop,COLOR_PAIR(1));
box(woffs,0,0);
box(whex,0,0);
box(wascii,0,0);
box(wtop,0,0);
box(wbot,0,0);
wattrset(woffs,COLOR_PAIR(2));
wattrset(whex,COLOR_PAIR(2));
wattrset(wascii,COLOR_PAIR(2));
wattrset(wtop,COLOR_PAIR(3));
wattrset(wbot,COLOR_PAIR(2));
// depending on the mode (ascii/hex) set the cursor-position
!mode?wmove(whex,pos.y,pos.x):wmove(wascii,pos.y,pos.x);
wrefresh(woffs);
wrefresh(wtop);
wrefresh(wbot);
// the order is given by the mode (ascii/hex). the last window refreshed
// it the one, in which the cursor appears and the input-focus is.
!mode?wrefresh(wascii):wrefresh(whex);
mode?wrefresh(wascii):wrefresh(whex);
}
void lineout(unsigned long line)
{
int z;
miniinit();
ptv = tonumsysx((*pdatas).line*16,16);
for(z=0;z<9;z++)
{
xoffs[z] = *(ptv+z);
}
mvwaddstr(woffs,line,1,soffs);
for (z=0;z<(*pdatas).len;z++)
{
ptv = tonumsysx((*pdatas).vals[z],16);
xhex[z*3+1] = *(ptv+6);
xhex[z*3+2] = *(ptv+7);
}
mvwaddstr(whex,line,1,shex);
for (z=0;z<(*pdatas).len;z++)
{
// TODO: There are many other characters that are displayable.
xascii[z] = (isgraph((*pdatas).vals[z]))?((*pdatas).vals[z]):'.';
}
mvwaddstr(wascii,line,1,sascii);
}
void initout()
{
//Initial output (All)
int i;
bool toggleswitch=false;
pdatas=pfirst;
if ((*pdatas).pnext == NULL) toggleswitch=true;
for(i=0;i<16;i++)
{
lineout(i+1);
if (toggleswitch) break;
pdatas=(*pdatas).pnext;
if ((*pdatas).pnext == NULL) toggleswitch=true;
}
scrrefresh();
if(i>15) pdatas=(*pdatas).plast;
}
int scrolld()
{
int resval;
if ((*pdatas).pnext != NULL)
{
pdatas=(*pdatas).pnext;
wscrl(woffs,1);
wscrl(whex,1);
wscrl(wascii,1);
miniinit();
lineout(16);
resval=1;
}
else
{
resval=0;
}
return(resval);
}
int scrollu()
{
int z=0;
int result;
while(((*pdatas).plast != NULL)&&(z < 16))
{
pdatas=(*pdatas).plast;
z++;
}
result= (z!=15)?1:0;
if(z>15)
{
z--;
wscrl(woffs,-1);
wscrl(whex,-1);
wscrl(wascii,-1);
miniinit();
lineout(1);
}
while(z--)
{
if ((*pdatas).pnext != NULL)
{
pdatas=(*pdatas).pnext;
}
}
return(result);
}
void switchmode()
{
if(mode==0)
{
mode=1; // mode-toggle:Hex->Ascii
// recalculate cursor-position
pos.x=((pos.x+1)/3);
}
else
{
mode=0; // mode-toggle:ascii->Hex
// recalculate cursor-position
pos.x=((pos.x*3)-1);
}
}
void moveleft()
{
if(mode==0)
{
if(pos.x > 2)
{
(pos.x%3)?pos.x-=2:pos.x--;
}
else
{
if(pos.y >1)
{
pos.y--;
pos.x=48;
}
else
{
if(scrollu())pos.x=48;
}
}
}
else
{
if(pos.x > 1)
{
pos.x--;
}
else
{
if(pos.y >1)
{
pos.y--;
pos.x=16;
}
else
{
if(scrollu())pos.x=16;
}
}
}
}
void moveright()
{
if(mode==0)
{
if(pos.x < 48)
{
(pos.x%3)?pos.x++:pos.x+=2;
}
else
{
if(pos.y < 16)
{
pos.x=2;
pos.y++;
}
else
{
if(scrolld()) pos.x=2;
}
}
}
else
{
if((pos.x < 16))
{
pos.x++;
}
else
{
if(pos.y < 16)
{
pos.x=1;
pos.y++;
}
else
{
if(scrolld()) pos.x=1;
}
}
}
}
unsigned long getactpos()
{
int i=0;
unsigned long actpos;
int distance;
int posxsave=9999;
if (!mode)
{
posxsave=pos.x;
switchmode();
}
// move in Memory to the cursor-position
if((pdatas==pmax) && ((*pdatas).line<15))
{
distance=(*pdatas).line-pos.y+1;
}
else
{
distance=16-pos.y;
}
while(i<(distance)&&((*pdatas).plast))
{
i++;
pdatas=(*pdatas).plast;
}
// get the position
actpos=((*pdatas).line*16)+pos.x-1;
// and move back
while(i--)
{
pdatas=(*pdatas).pnext;
}
if (posxsave!=9999)
{
switchmode();
pos.x=posxsave;
}
return(actpos);
}
void charin(char ch, int realmode, int realxpos)
{
int i=0;
int z=0;
int distance=0;
bool toggleswitch;
data *phelp2;
char rbmode; //rollbackmode (if file < 255 chars = 1 else 2)
unsigned long zhelp;
// im move to the cursor-position in memory
// Is the file smaller then one page, it has to be handled in another way.
if((pdatas==pmax) && ((*pdatas).line<15))
{
distance=(*pdatas).line-pos.y+1;
rbmode=1;
}
else
{
distance=16-pos.y;
rbmode=2;
}
while(i<(distance)&&((*pdatas).plast))
{
i++;
pdatas=(*pdatas).plast;
}
// For the insert-mode
if (((insovr=='I') && (realmode==1))||((insovr=='I') && (realmode==0) && (realxpos%3==2)) && (realmode!=3))
{
phelp=pdatas;
pdatas=pmax;
if ((*pdatas).len < 16)
{
(*pdatas).len++;
}
else
{
// allocate new element
phelp2=pmax;
zhelp=(*pmax).line+1;
pdatas=pmax=((*pdatas).pnext)=(data*)(malloc(sizeof(datas)));
if(!pmax) {abort();}
(*pmax).plast=phelp2;
(*pmax).pnext=NULL;
(*pmax).len=1;
(*pmax).line=zhelp;
}
while(pdatas!=phelp)
{
for(z=(*pdatas).len-1;z>=0;z--)
{
(*pdatas).vals[z]=(*pdatas).vals[z-1];
}
(*pdatas).vals[0]=(*(*pdatas).plast).vals[15];
pdatas=(*pdatas).plast;
}
for(z=(*pdatas).len-1;z+1>pos.x;z--)
{
(*pdatas).vals[z]=(*pdatas).vals[z-1];
}
pdatas=phelp;
}
// Write value
(*pdatas).vals[pos.x-1]=ch;
// refresh output of current line (not needed, I think)
lineout(pos.y);
// moving backwards again and print the lines immediate.
if (rbmode==1)
{
pdatas=pfirst;
if ((*pdatas).pnext == NULL) toggleswitch=true;
for(z=0;z<16;z++)
{
lineout(z+1);
if (toggleswitch) break;
pdatas=(*pdatas).pnext;
if ((*pdatas).pnext == NULL) toggleswitch=true;
}
}
else
{
while(i--)
{
if((*pdatas).pnext)
{
pdatas=(*pdatas).pnext;
lineout(16-i);
}
}
}
}
int charout()
{
int i=0;
int distance;
int posxsave;
int ch;
// Move in memory to cursor-position
if (!mode)
{
posxsave=pos.x;
switchmode();
}
// move in Memory to the cursor-position
if((pdatas==pmax) && ((*pdatas).line<15))
{
distance=(*pdatas).line-pos.y+1;
}
else
{
distance=16-pos.y;
}
while(i<(distance)&&((*pdatas).plast))
{
i++;
pdatas=(*pdatas).plast;
}
// get the value
ch=((*pdatas).vals[pos.x-1]);
// move back
while(i--)
{
pdatas=(*pdatas).pnext;
}
return(ch);
}
void bottomout()
{
int realmode,realposx;
realmode=mode;
if (realmode == 0)
{
realposx=pos.x;
switchmode();
}
mvwaddstr(wbot,1,1,empty78);
mvwaddstr(wbot,2,1,empty78);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,1,"CHR:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddch(wbot,1,6,32);
mvwaddch(wbot,1,5,(isgraph(charout()))?charout():'.');
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,9,"HEX:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,13,(tonumsysx(charout(),16))+6);
mvwaddch(wbot,1,15,'h');
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,18,"DEC:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,22,(tonumsysx(charout(),10))+5);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,27,"OCT:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,31,(tonumsysx(charout(),8))+4);
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,37,"BIN:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,41,tonumsysx(charout(),2));
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,52,"Offset:");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,59,tonumsysx(getactpos(),16));
wattrset(wbot,COLOR_PAIR(3));
mvwaddstr(wbot,1,67,"h -");
wattrset(wbot,COLOR_PAIR(2));
mvwaddstr(wbot,1,71,tonumsysx(getactpos(),10));
mvwaddstr(wbot,2,1,filename);
mvwaddstr(wbot,2,76,(insovr=='O')?"OVR":"INS");
if (realmode == 0)
{
switchmode();
pos.x=realposx;
}
}
void swapbits(char bit)
{
char bin[]="12345678",*pbin; // for the Bits
pbin=bin;
int realposx, realmode;
realmode=mode;
if (realmode==0)
{
realposx=pos.x;
switchmode();
}
pbin=tonumsysx(charout(),2);
pbin[bit]= (pbin[bit]=='0')?'1':'0';
charin(xto10(pbin,2),3,pos.x);
if (realmode==0)
{
switchmode();
pos.x=realposx;
}
}
void delactchar()
{
}
int main(int argc, char *argv[])
{
//Variables
unsigned int i; // Public counter
int inpch; // The char of input
//Preperation
printf("GHEX Version 0.5\n");
//Is there a param?
if(argc < 2)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nUSAGE: %s <filename> \n",argv[0]);
exit(1);
}
//open the file
fp=fopen(argv[1],"r");
if (fp == NULL)
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR opening file: %s \n",argv[1]);
exit(2);
}
// set the pointers
initvar();
// init of other useful varibles
pos.x = pos.y = 1;
filename=argv[1];
//file -> ram
if(loadcontents())
{
fprintf(stderr,"GHEX-MESSAGE:\n\nERROR reading %s (too less RAM?)\n",argv[1]);
exit(3);
}
// init of terminal
if(screeninit())
{
endscr();
fprintf(stderr,"!!!Terminal not supported!!! -> Abort \n");
exit(5);
}
mvwaddstr(wtop,1,1,topline);
//Main-procedure
initout();
bottomout();
scrrefresh();
//Event-loop
while(inpch!=KEY_F(10))
{
if (mode==0)
{
inpch=wgetch(whex);
}
else
{
inpch=wgetch(wascii);
}
switch(inpch)
{
// The Keys F1-F8 (bit-setting)
case KEY_F(9): switchmode();
break;
case KEY_F(1): swapbits(0);
break;
case KEY_F(2): swapbits(1);
break;
case KEY_F(3): swapbits(2);
break;
case KEY_F(4): swapbits(3);
break;
case KEY_F(5): swapbits(4);
break;
case KEY_F(6): swapbits(5);
break;
case KEY_F(7): swapbits(6);
break;
case KEY_F(8): swapbits(7);
break;
//the delete character-key
case KEY_DC : delactchar();
break;
//the insert-key, switch insert mode
case KEY_EIC: //fallthru
case KEY_IC : if (insovr=='O')
{
insovr='I';
}
else
{
insovr='O';
}
break;
//Cursor-movement
case KEY_LEFT: moveleft();
break;
case KEY_RIGHT:moveright();
break;
case KEY_DOWN: if(pos.y>15)
{
scrolld();
}
else
{
pos.y++;
}
break;
case KEY_UP: if(pos.y<2)
{
scrollu();
}
else
{
pos.y--;
}
break;
case KEY_NPAGE:for(i=0;i<16;i++)
{
scrolld();
}
break;
case KEY_PPAGE:for(i=0;i<16;i++)
{
scrollu();
}
break;
case KEY_HOME: initout();
break;
case KEY_END: pdatas=pmax;
for(i=0;((*pdatas).plast) && (i < 16);i++)
{
pdatas=(*pdatas).plast;
}
while((*pdatas).pnext)
{
scrolld();
}
break;
// input characters
default: if(mode==0)
{
if(isdigit(inpch) || (toupper(inpch)>='A' && toupper(inpch)<='F') )
{
waddch(whex,toupper(inpch));
char hch[]="00";
// fill hch correct (old values)
int xpos=pos.x; // save position
switchmode(); // recalc. coordinates
ptv=tonumsysx(charout(),16); // actual char in Hex.
//* --- DEBUG ONLY
mvwaddstr(wbot,2,30,tonumsysx(charout(),16));
// --- END DEBUG
switchmode(); // recalc coordinates
pos.x=xpos; // restore coorinates
if (insovr=='O') // Predef. only in Override!
{
hch[0] = *(ptv+6);
hch[1] = *(ptv+7);
}
else // In Insert only first char
{
if(pos.x%3==0)
hch[0] = *(ptv+6);
}
//* --- DEBUG ONLY
mvwaddstr(wbot,2,1,hch);
mvwaddstr(wbot,2,20,ptv);
// --- END DEBUG
hch[(pos.x%3)?0:1]=inpch;
switchmode(); // recalc coordinates
charin(xto10(hch,16),0,xpos); // calc Hex -> Ascii+charin
switchmode(); // and back
pos.x=xpos; // restore positions
moveright();
}
}
else
{
if((inpch < 256))
{
waddch(wascii,inpch);
charin(inpch,1,pos.x);
moveright();
}
}
};
bottomout();
scrrefresh();
}
endscr();
unallocmem();
return (fclose(fp));
}

1079
tiahv9.cc Normal file

File diff suppressed because it is too large Load Diff

1
uu Normal file
View File

@@ -0,0 +1 @@
亗儎厗噲墛媽崕彁憭摂晼棙櫄洔潪煚、¥ウЖ┆<EFBFBD><EFBFBD><EFBFBD>辈炒刀犯购患骄坷谅媚牌侨墒颂臀闲岩釉罩棕仝圮蒉哙徕沅彐玷殛腱眍镳耱篝貊鼬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>

5
webprefs Normal file
View File

@@ -0,0 +1,5 @@
Homepage: http://www.fortunecity.de/wolkenkratzer/messeturm/358
user: ghex
Pass: bitmaster
ftp: ftp.fortunecity.de

BIN
x Normal file

Binary file not shown.

0
y Normal file
View File

58
zweites.cc Normal file
View File

@@ -0,0 +1,58 @@
#include <curses.h>
int main()
{
WINDOW *stdscr,*w1,*w2;
char str1[] = "Zwei",*Pstr;
int z;
Pstr=str1;
stdscr = initscr();
int sc=start_color();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
// Zwei Fenster
w1=newwin(10,10,0,0);
w2=newwin(10,10,0,20);
// Scrollen erlauben
scrollok(w1,1);
scrollok(w2,1);
// Color-Pairs anlegen (Farbkombinationen)
int cp=init_pair(1,COLOR_MAGENTA,COLOR_BLUE);
cp=init_pair(2,COLOR_BLUE,COLOR_MAGENTA);
COLOR_PAIR(1);
for (z=0;z < 500;z++)
{
str1[1]='A'+(z%19);
// Color-Pair1 für window w1 benutzen
wattrset(w1,COLOR_PAIR(1));
if (z > 9) wscrl(w1,1);
wmove(w1,z < 9?(z%9):9,0);
waddstr(w1,Pstr);
wrefresh(w1);
wattrset(w2,COLOR_PAIR(2));
if (z > 9) wscrl(w2,-1);
wmove(w2,z<9?(z%9):0,0);
waddstr(w2,Pstr);
wrefresh(w2);
usleep(100);
usleep(100);
usleep(100);
usleep(100);
usleep(100);
}
sleep(1);
delwin(w1);
delwin(w2);
endwin();
return 0;
}