TempleOSCD_140715.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:09 +02:00
1 parent 7ef616a20e
commit 64f679eeb9
1095 files changed
+24814 -221011

No files matched your search

-76
View File
@@ -1,76 +0,0 @@
#help_index "Compiler"
DefineLstLoad("ST_BIN_FILE_TYPES",
"END\0 \0"
"REL_EXPORT\0"
"IMM_EXPORT\0"
"REL_I8\0"
"IMM_U8\0"
"REL_I16\0"
"IMM_U16\0"
"REL_I32\0"
"IMM_U32\0"
"REL_I64\0"
"IMM_U64\0"
" \0 \0 \0 \0"
"MAIN\0"
"MODULE_ALIGN\0MODULE_ORG\0"
" \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"
"ABS_ADDR\0"
"HEAP_GLBL\0"
);
public Bool BinRep(U8 *filename)
{//This reports imports, exports, etc
//for a .BI* file.
//See $LK,"Loader Patch Table Generation",A="FF:::/Compiler/CmpMain.CPP,EIT_MODULE_ALIGNMENT"$ and $LK,"Load",A="MN:Load"$().
U8 *fbuf,*ptr,*sptr,*absname;
I64 i,j,size,etype;
CBinFile *bfh;
CHashExport *saved_hash_ptr=NULL;
fbuf=DftExt(filename,"BIN.Z");
if (!(bfh=FileRead(fbuf,&size))) {
Free(fbuf);
return FALSE;
}
absname=FileNameAbs(fbuf);
Free(fbuf);
fbuf=StrNew(absname);
FileExtRem(fbuf);
if (fbuf[1]==':' && StrLen(fbuf)>2)
"Module Name:%s\n",fbuf+2;
else
"No Module Name\n";
Free(fbuf);
ptr=bfh(U8 *)+bfh->loader_patch_table_offset;
while (etype=*ptr++) {
i=*ptr(U32 *)++;
sptr=ptr;
ptr+=StrLen(sptr)+1;
"%16Z:$$GREEN$$%s$$FG$$:%X ",etype,"ST_BIN_FILE_TYPES",sptr,i;
switch (etype) {
case EIT_REL_I8...EIT_IMM_U64:
if (*sptr)
saved_hash_ptr=HashFind(sptr,Fs->hash_table,HTG_ALL);
if (!saved_hash_ptr)
"Unresolved Reference:%s\n",sptr;
break;
case EIT_ABS_ADDR:
NewLine;
for (j=0;j<i;j++)
"%X ",*ptr(U32 *)++;
break;
case EIT_HEAP_GLBL:
"Size:%X ",*ptr(I64 *)++;
for (j=0;j<i;j++)
"%X ",*ptr(U32 *)++;
break;
}
NewLine;
}
Free(absname);
Free(bfh);
return TRUE;
}
#help_index ""
+12 -14
View File
@@ -1,4 +1,4 @@
#help_index "Utils;Cmd Line (Typically)"
#help_index "Cmd Line (Typically)"
#define DS_USE_FILE1 0
#define DS_USE_FILE2 1
@@ -69,7 +69,7 @@ U0 DiffSelect(CDoc *doc,I64 *_df_flags,I64 j1_lo,I64 j1_hi,
"%s",doc_unsorted1[i++]->tag;
if (cur_l)
cur_l->flags= cur_l->flags&~DOCF_PLAIN_TEXT |old_flags;
NewLine;
'\n';
}
"$$CYAN$$";
if (j2_lo<=0)
@@ -84,7 +84,7 @@ U0 DiffSelect(CDoc *doc,I64 *_df_flags,I64 j1_lo,I64 j1_hi,
"%s",doc_unsorted2[i++]->tag;
if (cur_l)
cur_l->flags= cur_l->flags&~DOCF_PLAIN_TEXT |old_flags;
NewLine;
'\n';
}
"$$FG$$";
@@ -168,7 +168,7 @@ Bool DiffSub(CDoc *doc,I64 *_df_flags,I64 j1_lo,I64 j1_hi,I64 j2_lo,I64 j2_hi,
else {
i2b=i2;
while (!StrCmp(doc_sorted1[i1]->tag,doc_sorted2[i2]->tag)) {
if (j2_lo<=doc_sorted2[i2]->user_data<j2_hi) { //user_data is the new y
if (j2_lo<=doc_sorted2[i2]->user_data<j2_hi) {//user_data is the new y
score=0;
j1=doc_sorted1[i1]->user_data; //user_data is the new y
j2=doc_sorted2[i2]->user_data; //user_data is the new y
@@ -229,7 +229,8 @@ Bool DiffBins(CDoc *doc1,CDoc *doc2)
}
public Bool Diff(U8 *dst_file,U8 *src_file,I64 *_df_flags=NULL)
{ //The _df_flags arg is used when this is called by $LK,"Merge",A="MN:Merge"$().
{//Report differences between two files and merge differences
//from src_file to dst_file. Don't use _df_flags arg. (Used by $LK,"Merge",A="MN:Merge"$().)
CDoc *doc1=DocRead(dst_file,DOCF_PLAIN_TEXT_WITH_TABS|DOCF_NO_CURSOR),
*doc2=DocRead(src_file,DOCF_PLAIN_TEXT_WITH_TABS|DOCF_NO_CURSOR);
CDocEntry *doc_e,**doc_sorted1,**doc_sorted2,**doc_unsorted1,**doc_unsorted2;
@@ -305,17 +306,16 @@ public Bool Diff(U8 *dst_file,U8 *src_file,I64 *_df_flags=NULL)
return result;
}
#help_index "Utils;Cmd Line (Typically);Info"
#help_index "Cmd Line (Typically);Info"
I64 ZRepCompare(CDirEntry *e1,CDirEntry *e2)
{
return SignI64(e2->user_data(F64)-e1->user_data(F64));
}
public U0 ZipRep(U8 *files_find_mask="/*",U8 *fu_flags=NULL,
Bool just_text_not_graphics=TRUE)
{//Report of compressibility. Dft is just src files.
//(Used to spot src files with redundancy in them.)
{//Report file compressibility.
//Dft is just src files. (Used to spot
//src files with redundancy in them.)
I64 i=0,cnt,size,fuf_flags=0;
CDirEntry *tempde,*tempde1,**sort_buf;
U8 *buf;
@@ -340,10 +340,8 @@ public U0 ZipRep(U8 *files_find_mask="/*",U8 *fu_flags=NULL,
for (i=0;i<cnt;i++) {
"%4.1f%% %04X ",sort_buf[i]->user_data,sort_buf[i]->size;
PutFileLink(sort_buf[i]->full_name);
NewLine;
'\n';
}
Free(sort_buf);
DirLstDel(tempde1);
DirTreeDel(tempde1);
}
#help_index ""
+8 -15
View File
@@ -1,7 +1,5 @@
#help_index "Graphics/Windows BMP Files"
//This provides support for Window's BMP files.
class CFileBMP
{
U16 type;
@@ -27,8 +25,7 @@ class CFileBMP
};
public CFileBMP *BMPFile4To(CDC *dc)
{
//To Windows 4 bit BMP
{//To Windows 4-bit BMP.
U8 *src,*ptr;
I64 x,y,w=dc->width>>1,
size=offset(CFileBMP.end)+dc->width*dc->height>>1+16*sizeof(CBGR);
@@ -58,8 +55,7 @@ public CFileBMP *BMPFile4To(CDC *dc)
}
public CFileBMP *BMPFileRLE4To(CDC *dc)
{
//To Windows RLE4 bit BMP
{//To Windows RLE4 bit BMP.
U8 *src,*ptr;
I64 x,y,w=dc->width,cnt,pattern;
CFileBMP *r=CAlloc(offset(CFileBMP.end)+2*(dc->width+1)*dc->height+16*sizeof(CBGR));
@@ -111,8 +107,7 @@ public CFileBMP *BMPFileRLE4To(CDC *dc)
}
public CFileBMP *BMPFile24To(CDC *dc)
{
//To Windows 24 bit BMP
{//To Windows 24-bit BMP.
U8 *src;
I64 i,x,y,size=offset(CFileBMP.end)+dc->width*dc->height*sizeof(CRGB);
CBGR *bgr;
@@ -148,7 +143,7 @@ public CFileBMP *BMPFile24To(CDC *dc)
}
public I64 BMPFileWrite(U8 *filename,CDC *dc,I64 bits=4)
{ //Window's BMP Files
{//Window's BMP Files.
I64 size;
CFileBMP *r;
if (bits==4) {
@@ -199,7 +194,7 @@ U8 *BMPFilePaletteNew(CFileBMP *r)
U8 ms_paint_palette[16]={0,4,2,6,1,5,3,8,7,12,10,14,9,13,11,15};
public CDC *BMPFileRead(U8 *filename,Bool use_ms_paint_palette=FALSE)
{ //Window's BMP Files
{//Window's BMP Files.
I64 i,j,cnt;
U8 *palette_map,*ptr;
Bool rle4;
@@ -220,7 +215,7 @@ public CDC *BMPFileRead(U8 *filename,Bool use_ms_paint_palette=FALSE)
else
palette_map=BMPFilePaletteNew(r);
for (i=r->height-1;i>=0;i--)
if (rle4) { //We don't support full RLE4, just our own subset
if (rle4) {//We don't support full RLE4, just our own subset
j=0;
while (cnt=*ptr++) {
if (cnt==1) {
@@ -265,7 +260,7 @@ public CDC *BMPFileRead(U8 *filename,Bool use_ms_paint_palette=FALSE)
return result;
}
#help_index "Graphics/Sprite;Graphics/Windows BMP Files;Doc/Output"
#help_index "Graphics/Sprite;Graphics/Windows BMP Files;DolDoc/Output"
public U0 DocBMPFile(CDoc *doc=NULL,U8 *filename,Bool use_ms_paint_palette=FALSE)
{//Put a BMP file into a document as a sprite.
CDC *dc=BMPFileRead(filename,use_ms_paint_palette);
@@ -277,11 +272,9 @@ public U0 DocBMPFile(CDoc *doc=NULL,U8 *filename,Bool use_ms_paint_palette=FALSE
#help_index "Graphics/Windows BMP Files;Graphics/Screen"
public I64 BMPFileCaptureScreen(U8 *filename,I64 bits=4)
{
{//Capture screen as BMP file.
CDC *dc=DCCaptureScreen;
I64 size=BMPFileWrite(filename,dc,bits);
DCDel(dc);
return size;
}
#help_index ""
+15 -21
View File
@@ -1,4 +1,4 @@
#help_index "Utils;Cmd Line (Typically)"
#help_index "Cmd Line (Typically)"
#define GRF_REPLACE 0
#define GRF_SKIP 1
@@ -23,8 +23,6 @@ I64 PopUpGrepMenu()
return i;
}
I64 GrepFile(U8 *needle_str,U8 *haystack_filename,I64 *_fuf_flags,U8 *replace_text)
{
Bool first_on_line,write_this_file=FALSE,cont=!Bt(_fuf_flags,FUf_CANCEL);
@@ -58,7 +56,7 @@ I64 GrepFile(U8 *needle_str,U8 *haystack_filename,I64 *_fuf_flags,U8 *replace_te
if (first_on_line || Bt(_fuf_flags,FUf_REPLACE)) {
first_on_line=FALSE;
PutFileLink(haystack_filename,doc_e->y+1,TRUE);
name_buf=MPrint("%s,%d",haystack_filename,doc_e->y+1);
name_buf=MStrPrint("%s,%d",haystack_filename,doc_e->y+1);
if (cur_l=DocPut) {
old_flags=cur_l->flags&DOCF_PLAIN_TEXT;
cur_l->flags|=DOCF_PLAIN_TEXT;
@@ -143,8 +141,8 @@ I64 GrepFile(U8 *needle_str,U8 *haystack_filename,I64 *_fuf_flags,U8 *replace_te
}
public I64 Grep(U8 *needle_str,U8 *files_find_mask="*",U8 *fu_flags=NULL,U8 *replace_text=NULL)
/*
This does not do regular expressions--my bad.
{/*Find occurrences of a string in files.
This does not do regular expressions.
Anyway, it's good for searching and replacing.
Let's say it stands for global replace ;-)
@@ -159,8 +157,6 @@ Let's say it stands for global replace ;-)
"+lb"=only checks for label chars before.
"+la"=only checks for label chars after.
*/
{
I64 cnt=0,fuf_flags=0;
CDirEntry *tempde,*tempde1;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+i+f+F+T");
@@ -174,12 +170,12 @@ Let's say it stands for global replace ;-)
cnt+=GrepFile(needle_str,tempde->full_name,&fuf_flags,replace_text);
tempde=tempde->next;
}
DirLstDel(tempde1);
DirTreeDel(tempde1);
return cnt;
}
public I64 FileOcc(U8 *needle_str,U8 *files_find_mask="*",U8 *fu_flags="+r+i+l")
{/*
{/*Report occurrences of a string in files.
"+r"=recurse
"+i"=ignore case
"+l"=whole labels only.
@@ -195,13 +191,13 @@ public I64 FileOcc(U8 *needle_str,U8 *files_find_mask="*",U8 *fu_flags="+r+i+l")
class CGrep
{
U8 find_text[136] fmtstr "$$DA-P,135,A=\"FIND :%s\"$$\n";
U8 replace_text[136] fmtstr "$$DA-P,135,A=\"REPLACE :%s\"$$\n";
Bool replace fmtstr "$$CB,\"REPLACE\"$$\n";
Bool match_case fmtstr "$$CB,\"MATCH CASE\"$$\n";
Bool whole_labels fmtstr "$$CB,\"WHOLE LABELS\"$$\n";
U8 filemask[136] fmtstr "$$DA-P,135,A=\"FILE MASK :%s\"$$\n";
Bool recurse fmtstr "$$CB,\"RECURSE\"$$\n";
U8 find_text[136] fmtstr "$$DA-P,135,A=\"FIND :%s\"$$\n";
U8 replace_text[136] fmtstr "$$DA-P,135,A=\"REPLACE :%s\"$$\n";
Bool replace fmtstr "$$CB,\"REPLACE\"$$\n";
Bool match_case fmtstr "$$CB,\"MATCH CASE\"$$\n";
Bool whole_labels fmtstr "$$CB,\"WHOLE LABELS\"$$\n";
U8 filemask[136] fmtstr "$$DA-P,135,A=\"FILE MASK :%s\"$$\n";
Bool recurse fmtstr "$$CB,\"RECURSE\"$$\n";
};
I64 GrepWiz()
@@ -237,9 +233,9 @@ I64 GrepWiz()
if (g->whole_labels)
CatPrint(buf,"+l");
if (g->replace)
st=MPrint("\"$$$$WW+H,1$$$$\";Cd(\"%s\");Grep(\"%Q\",\"%Q\",\"%Q\",\"%Q\");UserTaskCont;",dir,g->find_text,g->filemask,buf,g->replace_text);
st=MStrPrint("\"$$$$WW+H,1$$$$\";Cd(\"%s\");Grep(\"%Q\",\"%Q\",\"%Q\",\"%Q\");UserTaskCont;",dir,g->find_text,g->filemask,buf,g->replace_text);
else
st=MPrint("\"$$$$WW+H,1$$$$\";Cd(\"%s\");Grep(\"%Q\",\"%Q\",\"%Q\");UserTaskCont;",dir,g->find_text,g->filemask,buf);
st=MStrPrint("\"$$$$WW+H,1$$$$\";Cd(\"%s\");Grep(\"%Q\",\"%Q\",\"%Q\");UserTaskCont;",dir,g->find_text,g->filemask,buf);
result=PopUp(st);
}
Free(dir);
@@ -247,5 +243,3 @@ I64 GrepWiz()
Free(g);
return result;
}
#help_index ""
+60 -58
View File
@@ -1,13 +1,13 @@
#help_index "Debugging/Heap"
#define HL_CALLER_DEPTH 4
#define HL_HASH_SIZE 0x1000
class CHeapLog
{
CHeapLog *next,*last;
U8 *addr;
U8 *caller1;
U8 *caller2;
U8 *caller3;
U8 *caller4;
U8 *caller[HL_CALLER_DEPTH];
};
class CHeapLogHash
@@ -15,8 +15,6 @@ class CHeapLogHash
CHeapLog *next,*last;
};
#define HEAPLOG_HASH_SIZE 0x1000
CHeapCtrl *heaplog_hc_watched,*heaplog_hc=NULL;
CHeapLogHash *heaplog_root=NULL;
@@ -27,11 +25,9 @@ U0 HeapLogMAlloc(U8 *addr)
if (MHeapCtrl(addr)==heaplog_hc_watched) {
temphl=MAlloc(sizeof(CHeapLog),heaplog_hc);
temphl->addr=addr;
temphl->caller1=Caller(2);
temphl->caller2=Caller(3);
temphl->caller3=Caller(4);
temphl->caller4=Caller(5);
i=addr>>3 &(HEAPLOG_HASH_SIZE-1);
for (i=0;i<HL_CALLER_DEPTH;i++)
temphl->caller[i]=Caller(i+2);
i=addr>>3 &(HL_HASH_SIZE-1);
PUSHFD
CLI
while (LBts(&sys_semas[SYS_SEMA_HEAPLOG_LOCK],0))
@@ -48,7 +44,7 @@ U0 HeapLogFree(U8 *addr)
CHeapLog *temphl;
if (!addr) return;
if (MHeapCtrl(addr)==heaplog_hc_watched) {
i=addr>>3 &(HEAPLOG_HASH_SIZE-1);
i=addr>>3 &(HL_HASH_SIZE-1);
PUSHFD
CLI
while (LBts(&sys_semas[SYS_SEMA_HEAPLOG_LOCK],0))
@@ -69,9 +65,51 @@ U0 HeapLogFree(U8 *addr)
}
}
public U0 HeapLogRep()
{
I64 i,total=0;
public Bool HeapLog(Bool val=ON,CTask *task=NULL)
{//Turn on. Collect data. Call $LK,"HeapLogRep",A="MN:HeapLogRep"$().
I64 i;
if (val) {
if (Bt(&sys_semas[SYS_SEMA_HEAPLOG_ACTIVE],0)) {
"HeapLog Already Active\n";
return TRUE;
} else {
if (!task) task=Fs;
if (TaskValidate(task))
heaplog_hc_watched=task->data_heap;
else
heaplog_hc_watched=task;//Actually, not a task, must be a HeapCtrl.
PUSHFD
CLI
while (LBts(&sys_semas[SYS_SEMA_HEAPLOG_LOCK],0))
PAUSE
heaplog_hc=HeapCtrlInit(,,sys_data_bp);
ext[EXT_HEAPLOG_MALLOC]=&HeapLogMAlloc;
ext[EXT_HEAPLOG_FREE]=&HeapLogFree;
heaplog_root=MAlloc(sizeof(CHeapLogHash)*HL_HASH_SIZE,heaplog_hc);
for (i=0;i<HL_HASH_SIZE;i++)
QueInit(&heaplog_root[i]);
LBtr(&sys_semas[SYS_SEMA_HEAPLOG_LOCK],0);
POPFD
LBts(&sys_semas[SYS_SEMA_HEAPLOG_ACTIVE],0);
return FALSE;
}
} else {
if (!LBtr(&sys_semas[SYS_SEMA_HEAPLOG_ACTIVE],0)) {
"HeapLog Not Active\n";
return FALSE;
} else {
HeapCtrlDel(heaplog_hc);
heaplog_root=heaplog_hc=NULL;
ext[EXT_HEAPLOG_MALLOC]=NULL;
ext[EXT_HEAPLOG_FREE]=NULL;
return TRUE;
}
}
}
public U0 HeapLogRep(Bool leave_it=OFF)
{//Call $LK,"HeapLog",A="MN:HeapLog"$() first and collect data.
I64 i,j,total=0;
CHeapLog *temphl,hl;
if (!LBtr(&sys_semas[SYS_SEMA_HEAPLOG_ACTIVE],0)) {
"HeapLog Not Active\n";
@@ -80,13 +118,15 @@ public U0 HeapLogRep()
"$$WW,0$$";
while (LBts(&sys_semas[SYS_SEMA_HEAPLOG_LOCK],0))
PAUSE
for (i=0;i<HEAPLOG_HASH_SIZE;i++) {
for (i=0;i<HL_HASH_SIZE;i++) {
temphl=heaplog_root[i].next;
while (temphl!=&heaplog_root[i]) {
//Take snapshot in case modified. (while we work)
MemCpy(&hl,temphl,sizeof(CHeapLog));
"$$PURPLE$$%08X$$FG$$ %08X %P %P %P %P\n",MSize(hl.addr),hl.addr,
hl.caller1,hl.caller2,hl.caller3,hl.caller4;
"$$PURPLE$$%08X$$FG$$ %08X",MSize(hl.addr),hl.addr;
for (j=0;j<HL_CALLER_DEPTH;j++)
" %P",hl.caller[j];
'\n';
total+=MSize(hl.addr);
temphl=hl.next;
}
@@ -94,44 +134,6 @@ public U0 HeapLogRep()
LBtr(&sys_semas[SYS_SEMA_HEAPLOG_LOCK],0);
"\n$$LTRED$$Total:%08X$$FG$$\n",total;
LBts(&sys_semas[SYS_SEMA_HEAPLOG_ACTIVE],0);
if (!leave_it)
HeapLog(OFF);
}
public U0 HeapLog(Bool val=TRUE,CTask *task=NULL)
{
I64 i;
if (val) {
if (Bt(&sys_semas[SYS_SEMA_HEAPLOG_ACTIVE],0))
"HeapLog Already Active\n";
else {
if (!task) task=Fs;
if (TaskValidate(task))
heaplog_hc_watched=task->data_heap;
else
heaplog_hc_watched=task;
PUSHFD
CLI
while (LBts(&sys_semas[SYS_SEMA_HEAPLOG_LOCK],0))
PAUSE
heaplog_hc=HeapCtrlInit(,,sys_data_bp);
ext[EXT_HEAPLOG_MALLOC]=&HeapLogMAlloc;
ext[EXT_HEAPLOG_FREE]=&HeapLogFree;
heaplog_root=MAlloc(sizeof(CHeapLogHash)*HEAPLOG_HASH_SIZE,heaplog_hc);
for (i=0;i<HEAPLOG_HASH_SIZE;i++)
QueInit(&heaplog_root[i]);
LBtr(&sys_semas[SYS_SEMA_HEAPLOG_LOCK],0);
POPFD
LBts(&sys_semas[SYS_SEMA_HEAPLOG_ACTIVE],0);
}
} else {
if (!LBtr(&sys_semas[SYS_SEMA_HEAPLOG_ACTIVE],0))
"HeapLog Not Active\n";
else {
HeapCtrlDel(heaplog_hc);
heaplog_root=heaplog_hc=NULL;
ext[EXT_HEAPLOG_MALLOC]=NULL;
ext[EXT_HEAPLOG_FREE]=NULL;
}
}
}
#help_index ""
+10 -13
View File
@@ -1,4 +1,4 @@
#help_index "Utils;Cmd Line (Typically)"
#help_index "Cmd Line (Typically)"
I64 LineRep1(CDirEntry *tempde)
{
@@ -6,7 +6,7 @@ I64 LineRep1(CDirEntry *tempde)
I64 result=0,i;
while (tempde) {
i=0;
if (tempde->attr&_ATTR_DIR)
if (tempde->attr&RS_ATTR_DIR)
i=LineRep1(tempde->sub);
else {
doc=DocRead(tempde->full_name);
@@ -23,7 +23,7 @@ I64 LineRep1(CDirEntry *tempde)
U0 LineRep2(CDoc *doc,CDirEntry *tempde)
{
while (tempde) {
if (tempde->attr&_ATTR_DIR) {
if (tempde->attr&RS_ATTR_DIR) {
DocPrint(doc,"%8,d $$TR+C,\"%s\"$$\n$$ID,2$$",tempde->user_data,tempde->name);
LineRep2(doc,tempde->sub);
DocPrint(doc,"$$ID,-2$$");
@@ -34,7 +34,7 @@ U0 LineRep2(CDoc *doc,CDirEntry *tempde)
}
}
public I64 LineRep(U8 *files_find_mask="/*",U8 *fu_flags=NULL)
{
{//Source line-of-code count report.
I64 fuf_flags=0,result=0;
CDoc *doc=DocNew;
CDirEntry *tempde1=NULL;
@@ -45,7 +45,7 @@ public I64 LineRep(U8 *files_find_mask="/*",U8 *fu_flags=NULL)
DocPrint(doc,"%8,d $$TR+C,\"%s\"$$\n$$ID,2$$",result,files_find_mask);
LineRep2(doc,tempde1);
DocPrint(doc,"$$ID,-2$$");
DirLstDel(tempde1);
DirTreeDel(tempde1);
}
DocInsDoc(DocPut,doc);
DocDel(doc);
@@ -58,10 +58,10 @@ I64 SizeRep1(CDirEntry *tempde,I64 *_fuf_flags)
U8 buf[BLK_SIZE];
CPrt *p;
while (tempde) {
if (tempde->attr&_ATTR_DIR)
if (tempde->attr&RS_ATTR_DIR)
i=SizeRep1(tempde->sub,_fuf_flags);
else if ((i=tempde->size) && Bt(_fuf_flags,FUf_EXPAND) &&
FileAttr(tempde->name)&_ATTR_COMPRESSED) {
FileAttr(tempde->name)&RS_ATTR_COMPRESSED) {
p=Drv2Prt(*tempde->full_name);
RBlks(p,buf,Cluster2Blk(p,tempde->cluster),1);
i=(&buf)(CArcCompress *)->expanded_size;
@@ -75,7 +75,7 @@ I64 SizeRep1(CDirEntry *tempde,I64 *_fuf_flags)
U0 SizeRep2(CDoc *doc,CDirEntry *tempde)
{
while (tempde) {
if (tempde->attr&_ATTR_DIR) {
if (tempde->attr&RS_ATTR_DIR) {
DocPrint(doc,"%10,d $$TR+C,\"%s\"$$\n$$ID,2$$",tempde->user_data,tempde->name);
SizeRep2(doc,tempde->sub);
DocPrint(doc,"$$ID,-2$$");
@@ -88,8 +88,7 @@ U0 SizeRep2(CDoc *doc,CDirEntry *tempde)
}
}
public I64 SizeRep(U8 *files_find_mask="/*",U8 *fu_flags=NULL)
{
//"+x" for expanded size.
{//Report file sizes. "+x" for expanded size of compressed files.
I64 fuf_flags=0,result=0;
CDoc *doc=DocNew;
CDirEntry *tempde1=NULL;
@@ -101,11 +100,9 @@ public I64 SizeRep(U8 *files_find_mask="/*",U8 *fu_flags=NULL)
DocPrint(doc,"%10,d $$TR+C,\"%s\"$$\n$$ID,2$$",result,files_find_mask);
SizeRep2(doc,tempde1);
DocPrint(doc,"$$ID,-2$$");
DirLstDel(tempde1);
DirTreeDel(tempde1);
}
DocInsDoc(DocPut,doc);
DocDel(doc);
return result;
}
#help_index ""
+3 -5
View File
@@ -1,4 +1,4 @@
#help_index "Debugging;Utils;Cmd Line (Typically)"
#help_index "Debugging;Cmd Line (Typically)"
I64 LinkChkDoc(CDoc *doc,I64 *_fuf_flags)
{
@@ -44,8 +44,7 @@ I64 LinkChkFile(U8 *filename,I64 *_fuf_flags)
return result;
}
public I64 LinkChk(U8 *files_find_mask="/*",U8 *fu_flags=NULL)
//Checks for broken file links.
{
{//Check documents for broken file links.
I64 fuf_flags=0,result=0;
CDirEntry *tempde,*tempde1;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+T+f+F+O");
@@ -55,7 +54,6 @@ public I64 LinkChk(U8 *files_find_mask="/*",U8 *fu_flags=NULL)
result+=LinkChkFile(tempde->full_name,&fuf_flags);
tempde=tempde->next;
}
DirLstDel(tempde1);
DirTreeDel(tempde1);
return result;
}
#help_index ""
+28 -31
View File
@@ -1,4 +1,4 @@
#help_index "Info;Utils;Memory/Info;Cmd Line (Typically)"
#help_index "Info;Memory/Info;Cmd Line (Typically)"
I64 TSSSize(CTSS *tss)
{
@@ -13,10 +13,10 @@ I64 PenBrushesSize()
I64 result=0,i;
for (i=0;i<GR_NUM_PEN_BRUSHES;i++)
result+=
DCSize(gr_pen_brushes[i])+
DCSize(gr_collision_pen_brushes[i])+
DCSize(gr_even_pen_brushes[i])+
DCSize(gr_odd_pen_brushes[i] );
DCSize(gr.pen_brushes[i])+
DCSize(gr.collision_pen_brushes[i])+
DCSize(gr.even_pen_brushes[i])+
DCSize(gr.odd_pen_brushes[i] );
return result;
}
@@ -24,7 +24,7 @@ I64 ScreenZoomTablesSize()
{
I64 result=0,i;
for (i=1;i<=GR_MAX_SCREEN_ZOOM;i++)
result+=MSize2(gr_screen_zoom_tables[i]);
result+=MSize2(gr.screen_zoom_tables[i]);
return result;
}
@@ -69,10 +69,10 @@ I64 TaskQueSize(CTask *task)
I64 BlkDevsSize()
{
I64 i,result=MSize2(sys_blkdevs);
I64 i,result=MSize2(dsk.blkdevs);
CBlkDev *bdev;
for (i=0;i<NUM_BLKDEVS;i++) {
bdev=&sys_blkdevs[i];
bdev=&dsk.blkdevs[i];
if (bdev->bd_signature==BD_SIGNATURE_VAL) {
if (bdev->type==BDT_RAM)
"RAMDsk %C\t:%010X Unused:%010X\n",
@@ -86,10 +86,10 @@ I64 BlkDevsSize()
I64 PrtsSize()
{
I64 i,result=MSize2(sys_prts);
I64 i,result=MSize2(dsk.prts);
for (i=0;i<NUM_PRTS;i++)
result+=MSize2(sys_prts[i].buffered_map_dirty_bits)+
MSize2(sys_prts[i].fis);
result+=MSize2(dsk.prts[i].buffered_map_dirty_bits)+
MSize2(dsk.prts[i].fis);
return result;
}
@@ -142,7 +142,7 @@ Bool MemRepTask(CTask *task,Bool override_validate=FALSE)
}
if (task==sys_winmgr_task) {
"gr_pen_brushes\t:%010X\n",PenBrushesSize;
"gr.pen_brushes\t:%010X\n",PenBrushesSize;
"gr_screen_zoom_tbles:%010X\n",ScreenZoomTablesSize;
} else if (task==adam_task) {
j=0;k=0;m=0;n=0;
@@ -173,30 +173,29 @@ Bool MemRepTask(CTask *task,Bool override_validate=FALSE)
"BlkDevs\t:%010X\n",BlkDevsSize;
"Prts\t:%010X\n",PrtsSize;
"Audio\t:%010X\n",CallExtStr("AudioSize");
if (sys_dsk_cache_base)
if (dsk.cache_base)
"DskCache\t:%010X\n",
MSize2(sys_dsk_cache_base)+MSize2(sys_dsk_cache_hash_table)+MSize2(sys_dsk_cache_ctrl);
MSize2(dsk.cache_base)+MSize2(dsk.cache_hash_table)+MSize2(dsk.cache_ctrl);
"WordStat\t:%010X\n",CallExtStr("WordStatSize");
"Clipboard\t:%010X\n",DocSize(sys_clipboard_doc);
"gr_1_to_8_bits\t:%010X\n",MSize2(gr_1_to_8_bits);
"gr_1_to_8_colors\t:%010X\n",MSize2(gr_1_to_8_colors);
"gr_text_base\t:%010X\n",MSize2(gr_text_base);
"gr_vga_text_cache\t:%010X\n",MSize2(gr_vga_text_cache);
"gr_win_z_buf\t:%010X\n",MSize2(gr_win_z_buf)+MSize2(gr_win_uncovered_bitmap);
"gr_dc\t\t:%010X\n",DCSize(gr_dc);
"gr_dc1\t\t:%010X\n",DCSize(gr_dc1);
"gr_dc2\t\t:%010X\n",DCSize(gr_dc2);
"gr_dc_cache\t\t:%010X\n",DCSize(gr_dc_cache);
"gr_screen_image\t:%010X\n",DCSize(gr_screen_image);
"gr_zoomed_dc\t:%010X\n",DCSize(gr_zoomed_dc);
"gr.to_8_bits\t:%010X\n",MSize2(gr.to_8_bits);
"gr.to_8_colors\t:%010X\n",MSize2(gr.to_8_colors);
"gr.text_base\t:%010X\n",MSize2(gr.text_base);
"gr.vga_text_cache\t:%010X\n",MSize2(gr.vga_text_cache);
"gr.win_z_buf\t:%010X\n",MSize2(gr.win_z_buf)+MSize2(gr.win_uncovered_bitmap);
"gr.dc\t\t:%010X\n",DCSize(gr.dc);
"gr.dc1\t\t:%010X\n",DCSize(gr.dc1);
"gr.dc2\t\t:%010X\n",DCSize(gr.dc2);
"gr.dc_cache\t\t:%010X\n",DCSize(gr.dc_cache);
"gr.screen_image\t:%010X\n",DCSize(gr.screen_image);
"gr.zoomed_dc\t:%010X\n",DCSize(gr.zoomed_dc);
}
"$$ID,-2$$";
return TRUE;
}
public U0 MemRep()
{
{//Memory usage report.
I64 i;
CTask *task;
CCPU *c;
@@ -237,10 +236,8 @@ public U0 MemRep()
}
"$$GREEN$$Independent Heaps$$FG$$\n$$ID,2$$";
"$$BLACK$$sys_uncached_heap:%010X Used:%010X $$RED$$Unused:%010X$$FG$$\n",
sys_uncached_heap->bp->size*PAGE_SIZE,sys_uncached_heap->used_u8s,UnusedBPMem(sys_uncached_heap->bp);
"$$BLACK$$dev.uncached_heap:%010X Used:%010X $$RED$$Unused:%010X$$FG$$\n",
dev.uncached_heap->bp->size*PAGE_SIZE,dev.uncached_heap->used_u8s,UnusedBPMem(dev.uncached_heap->bp);
"$$ID,-2$$\n";
Preempt(old_preempt);
}
#help_index ""
+15 -14
View File
@@ -1,4 +1,4 @@
#help_index "Utils;Cmd Line (Typically)"
#help_index "Cmd Line (Typically)"
CDirEntry MGFind(CDirEntry *needle_entry,CDirEntry *haystack_lst)
{
@@ -12,20 +12,18 @@ CDirEntry MGFind(CDirEntry *needle_entry,CDirEntry *haystack_lst)
U0 Merge2(CDirEntry *tempde1,CDirEntry *tempde2,I64 *_fuf_flags,I64 *_df_flags)
{
I64 i;
CDirEntry *tempde;
while (tempde1 && !(*_df_flags & DF_ABORT_ALL_FILES)) {
tempde=MGFind(tempde1,tempde2);
if (!tempde)
"$$BROWN$$Does Not Exist:%s$$FG$$\n",tempde1->full_name;
else {
if (tempde1->attr & _ATTR_DIR)
if (tempde1->attr & RS_ATTR_DIR)
Merge2(tempde1->sub,tempde->sub,_fuf_flags,_df_flags);
else {
i=tempde1->datetime-tempde->datetime;
if (AbsI64(i)>CDATE_FREQ*2) { //Filedates can shift due to conversion
if (AbsI64(tempde1->datetime-tempde->datetime)>CDATE_FREQ*2) {//Filedates can shift due to conversion
"%s",tempde1->full_name;
NewLine;
'\n';
if (Bt(_fuf_flags,FUf_DIFF)) {
if (FilesFindMatch(tempde1->full_name,FILEMASK_TXT))
Diff(tempde->full_name,tempde1->full_name,_df_flags);
@@ -38,8 +36,13 @@ U0 Merge2(CDirEntry *tempde1,CDirEntry *tempde2,I64 *_fuf_flags,I64 *_df_flags)
}
public U0 Merge(U8 *dst_files_find_mask="/*",U8 *src_files_find_mask="/*",
U8 *fu_flags=NULL)
//"+d"=Do $LK,"Diff",A="MN:Diff"$() on files
{
{/*Merge text files from one list into another.
Report files whos date/time is different.
"+d" will do $LK,"Diff",A="MN:Diff"$() on files and prompt to
merge changes from source files into
destination files.
*/
I64 df_flags=0,fuf_flags=0;
CDirEntry *tempde1=NULL,*tempde2=NULL;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
@@ -51,14 +54,14 @@ public U0 Merge(U8 *dst_files_find_mask="/*",U8 *src_files_find_mask="/*",
tempde2=FilesFind(dst_files_find_mask,fuf_flags&FUG_FILES_FIND);
fuf_flags&=FUF_DIFF;
Merge2(tempde1,tempde2,&fuf_flags,&df_flags);
DirLstDel(tempde1);
DirLstDel(tempde2);
DirTreeDel(tempde1);
DirTreeDel(tempde2);
}
#help_index "Utils;Cmd Line (Typically)"
public U0 NewFiles(U8 *files_find_mask="/*",CDate cdt=0,U8 *fu_flags=NULL)
{//List new files
{//Report files newer than a certain date.
I64 fuf_flags=0;
CDirEntry *tempde,*tempde1;
if (!cdt) cdt=sys_compile_time;
@@ -70,7 +73,5 @@ public U0 NewFiles(U8 *files_find_mask="/*",CDate cdt=0,U8 *fu_flags=NULL)
"%s\n",tempde->full_name;
tempde=tempde->next;
}
DirLstDel(tempde1);
DirTreeDel(tempde1);
}
#help_index ""
+79 -177
View File
@@ -1,200 +1,102 @@
#help_index "Debugging/Profiler;Utils/Profiler;Profiler"
#help_index "Debugging/Profiler;Profiler;Cmd Line (Typically)/Profiler"
#help_file "::/Doc/Profiler"
#define PF_ARRAY_CNT 0x100000
I64 pf_time_start,pf_time_end;
I64 pf_low=0,pf_high=SYS_KERNEL_END,pf_size=PF_ARRAY_CNT;
I64 pf_jiffy_start,pf_jiffy_end;
I64 *pf_array=NULL;
I64 pf_cpu=0;
U0 (*fp_chained_timer_routine)(CTask *task)=cpu_structs[pf_cpu].timer_irq_chain;
I64 pf_ptr,pf_depth;
#define PFM_OFF 0
#define PFM_BIN 1
#define PFM_ALL 2
I64 prof_mode=PFM_OFF;
F64 pf_t0;
I64 pf_buf_in_ptr=0,pf_depth;
I64 pf_prof_active=0;
U0 ProfTimerInt(CTask *task)
{
I64 i,j=task->rip,k;
nobound_switch (prof_mode) {
case PFM_OFF:
break;
case PFM_BIN:
i=(j-pf_low) * pf_size/(pf_high-pf_low);
if (0<=i<pf_size)
pf_array[i]++;
break;
case PFM_ALL:
for (k=0;k<=pf_depth;k++) {
if (task==Gs->idle_task)
j=SYS_IDLE_PT;
else
j=TaskCaller(task,k,TRUE);
if (pf_ptr<PF_ARRAY_CNT) {
pf_array[pf_ptr++]=j;
if (pf_ptr==PF_ARRAY_CNT)
pf_time_end=sys_jiffies;
}
{//See $LK,"profiler_timer_irq",A="FF:::/Kernel/Ints.CPP,profiler_timer_irq"$.
I64 i,k;
if (Bt(&pf_prof_active,0))
for (k=0;k<=pf_depth;k++) {
if (task==Gs->idle_task)
i=SYS_IDLE_PT;
else
i=TaskCaller(task,k,TRUE);
if (pf_buf_in_ptr<PF_ARRAY_CNT) {
pf_array[pf_buf_in_ptr++]=i;
pf_jiffy_end=cnts.jiffies;
}
break;
}
(*fp_chained_timer_routine)(task);
}
cpu_structs[pf_cpu].timer_irq_chain=&ProfTimerInt;
public U0 ProfBin(U8 *start,I64 cnt=PF_ARRAY_CNT*3)
//Start profiler in bin mode. Profilers
//report where time is spent by checking
//the instruction ptr during the
//timer interrupt. Do a $LK,"ProfRep",A="MN:ProfRep"$(), (profiler report)
//after you have collected data.
{
if (cnt<PF_ARRAY_CNT)
pf_size=cnt;
else
pf_size=PF_ARRAY_CNT;
pf_low=start;
pf_high=start+cnt;
if (!pf_array)
pf_array=AMAlloc(sizeof(I64)*PF_ARRAY_CNT);
MemSet(pf_array,0,PF_ARRAY_CNT*sizeof(I64));
pf_time_end=0;
pf_time_start=sys_jiffies;
prof_mode=PFM_BIN;
pf_t0=tS;
}
}
public U0 ProfCPUSet(I64 num)
{
if (num>=mp_cnt)
public U0 Prof(I64 depth=0,I64 cpu_num=0)
{/*Start collecting profiler statistics.
Profilers report where time is spent
by sampling RIP during the $TX,"1000 Hz",D="DD_JIFFY_HZ"$
timer interrupt.
Do a $LK,"ProfRep",A="MN:ProfRep"$(), (profiler report)
after you have collected data.
*/
if (!(0<=cpu_num<mp_cnt))
ST_ERR_ST "Invalid CPU\n";
else if (cpu_structs[pf_cpu].timer_irq_chain!=&ProfTimerInt)
ST_ERR_ST "Unchaining not implemented!\n";
else {
cpu_structs[pf_cpu].timer_irq_chain=fp_chained_timer_routine;
pf_cpu=num;
fp_chained_timer_routine=cpu_structs[pf_cpu].timer_irq_chain;
cpu_structs[pf_cpu].timer_irq_chain=&ProfTimerInt;
cpu_structs[pf_cpu].profiler_timer_irq=NULL;
pf_cpu=cpu_num;
pf_depth=depth;
pf_buf_in_ptr=0;
if (!pf_array)
pf_array=AMAlloc(sizeof(I64)*PF_ARRAY_CNT);
pf_jiffy_end=pf_jiffy_start=cnts.jiffies;
LBts(&pf_prof_active,0);
cpu_structs[pf_cpu].profiler_timer_irq=&ProfTimerInt;
}
}
public U0 ProfAll(I64 depth=0)
//Start profiler in record-all mode. Profilers
//report where time is spent by checking
//the instruction ptr during the
//timer interrupt. Do a $LK,"ProfRep",A="MN:ProfRep"$(), (profiler report)
//after you have collected data.
I64 ProfCompare(U8 *i1,U8 *i2)
{
pf_depth=depth;
pf_ptr=0;
if (!pf_array)
pf_array=AMAlloc(sizeof(I64)*PF_ARRAY_CNT);
pf_time_end=0;
pf_time_start=sys_jiffies;
prof_mode=PFM_ALL;
pf_t0=tS;
return i1-i2;
}
I64 PFACompare(U8 *i1,U8 *i2)
{
if (i1<i2)
return -1;
else if (i1>i2)
return 1;
else
return 0;
}
public U0 ProfRep(I64 filter_cnt=1,Bool leave_it=OFF)
{//Profiler report. Call $LK,"Prof",A="MN:Prof"$() first and collect data.
I64 i,hits,ip,last_ip=0,routine_total=0;
F64 total_time;
U8 buf[256],buf2[256],last_buf[256];
if (!LBtr(&pf_prof_active,0))
"Profiler Not Active\n";
if (!pf_buf_in_ptr)
"No Profiler Statistic\n";
else {
if (!(total_time=pf_jiffy_end-pf_jiffy_start))
total_time=1;
QSortI64(pf_array,pf_buf_in_ptr,&ProfCompare);
*last_buf=0;
for (i=0;i<pf_buf_in_ptr;i+=hits) {
ip=pf_array[i];
hits=0;
do hits++;
while (i+hits<pf_buf_in_ptr && pf_array[i+hits]==ip);
public U0 ProfRep(I64 filter_cnt=1)
{
F64 pf_tf=tS;
I64 i,ip,last_ip=pf_low,hits,
total_time,routine_total=0,old_mode=prof_mode;
U8 buf[128],buf2[128],buf3[128],last_buf[128];
prof_mode=PFM_OFF;
if (pf_time_end)
total_time=pf_time_end-pf_time_start;
else
total_time=sys_jiffies-pf_time_start;
if (!total_time) total_time=1;
switch (old_mode) {
case PFM_BIN:
*last_buf=0;
for (i=0;i<pf_size;i++) {
ip=pf_low+i*(pf_high-pf_low)/pf_size;
SPrint(buf,"%p",ip);
StrCpy(buf3,buf);
StrFirstRem(buf3,"+",buf2);
if (StrCmp(buf2,last_buf)) {
if (*last_buf && routine_total>=filter_cnt) {
"$$GREEN$$%3d.%02d%% %08X:",routine_total*100/total_time,
routine_total*10000/total_time%100,routine_total;
"%s\n$$FG$$",last_buf;
}
StrCpy(last_buf,buf2);
routine_total=0;
}
hits=pf_array[i];
routine_total+=hits;
if (hits>=filter_cnt) {
"%3d.%02d%% %08X:",hits*100/total_time,
hits*10000/total_time%100,hits;
if (!PutSrcLink(ip,ip-last_ip))
"%s\n",buf;
else
NewLine;
last_ip=ip;
}
StrPrint(buf,"%p",ip);
StrFirstRem(buf,"+",buf2);
if (StrCmp(buf2,last_buf)) {
if (*last_buf && routine_total>=filter_cnt)
"$$GREEN$$%6.2f %08X:%s\n$$FG$$",100*routine_total/total_time,
routine_total,last_buf;
StrCpy(last_buf,buf2);
routine_total=0;
}
if (*last_buf && routine_total>=filter_cnt) {
"$$GREEN$$%3d.%02d%% %08X:",routine_total*100/total_time,
routine_total*10000/total_time%100,routine_total;
"%s\n$$FG$$",last_buf;
routine_total+=hits;
if (hits>=filter_cnt) {
"%6.2f %08X:%P\n",100*hits/total_time,hits,ip;
last_ip=ip;
}
break;
case PFM_ALL:
QSortI64(pf_array,pf_ptr,&PFACompare);
*last_buf=0;
for (i=0;i<pf_ptr;i++) {
ip=pf_array[i];
hits=0;
while (pf_array[i]==ip) {
hits++;
i++;
if (i>=pf_ptr) break;
}
SPrint(buf,"%p",ip);
StrCpy(buf3,buf);
StrFirstRem(buf3,"+",buf2);
if (StrCmp(buf2,last_buf)) {
if (*last_buf && routine_total>=filter_cnt) {
"$$GREEN$$%3d.%02d%% %08X:",routine_total*100/total_time,
routine_total*10000/total_time%100,routine_total;
"%s\n$$FG$$",last_buf;
}
StrCpy(last_buf,buf2);
routine_total=0;
}
routine_total+=hits;
if (hits>=filter_cnt) {
"%3d.%02d%% %08X:",hits*100/total_time,
hits*10000/total_time%100,hits;
if (!PutSrcLink(ip,ip-last_ip))
"%s\n",buf;
else
NewLine;
last_ip=ip;
}
}
if (*last_buf && routine_total>=filter_cnt) {
"$$GREEN$$%3d.%02d%% %08X:",routine_total*100/total_time,
routine_total*10000/total_time%100,routine_total;
"%s\n$$FG$$",last_buf;
}
break;
}
if (*last_buf && routine_total>=filter_cnt)
"$$GREEN$$%6.2f %08X:%s\n$$FG$$",100*routine_total/total_time,
routine_total,last_buf;
"Total Time:%0.6fs\n",total_time/JIFFY_FREQ;
if (leave_it) {
cpu_structs[pf_cpu].profiler_timer_irq=&ProfTimerInt;
LBts(&pf_prof_active,0);
} else
cpu_structs[pf_cpu].profiler_timer_irq=NULL;
}
"Total Time:%12.6fs\n",pf_tf-pf_t0;
}
#help_index ""
+3 -6
View File
@@ -1,4 +1,4 @@
#help_index "Utils;Cmd Line (Typically)"
#help_index "Cmd Line (Typically)"
//$LK,"StrUtil",A="MN:StrUtil"$() operations on files
@@ -43,14 +43,11 @@ public U0 SU(U8 *files_find_mask,I64 suf_flags,U8 *fu_flags=NULL,F64 indent_scal
SUFile(tempde->full_name,suf_flags,indent_scale_factor);
tempde=tempde->next;
}
DirLstDel(tempde1);
DirTreeDel(tempde1);
}
public U0 S2T(U8 *files_find_mask,U8 *fu_flags=NULL)
{
//Spaces to tabs.
{//Spaces to tabs.
//Use "Hard Space" (SHIFT-SPACE) for spaces
//in string consts in your code.
SU(files_find_mask,SUF_S2T|SUF_REM_TRAILING,fu_flags);
}
#help_index ""
+55 -51
View File
@@ -1,17 +1,23 @@
#help_index "Doc/Cvt"
#help_index "DolDoc/Conversion"
//See $LK,"::/Doc/Acknowledgements.TXT"$.
U0 HtmlPutS(CDoc *doc,I64 c,I64 *_old_c,U8 *st,I64 *_col,U8 *style_bitmap=NULL)
U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,U8 *st,I64 *_col,U8 *style_bitmap=NULL)
{
U8 *ch,*ptr;
if (c!=*_old_c) {
if (*_old_c!=-1)
if (u32_attr&DOCET_INVERT)
u32_attr.u8[1]=(u32_attr.u8[1]&15)<<4|u32_attr.u8[1]>>4;
if (u32_attr!=*_old_u32_attr) {
if (!(u32_attr&DOCET_BLINK) && *_old_u32_attr&DOCET_BLINK)
DocPrint(doc,"</blink>");
if (*_old_u32_attr!=-1)
DocPrint(doc,"</span>");
DocPrint(doc,"<span class=c%02X>",c);
*_old_c=c;
DocPrint(doc,"<span class=c%02X>",u32_attr.u8[1]);
if (u32_attr&DOCET_BLINK && !(*_old_u32_attr&DOCET_BLINK))
DocPrint(doc,"<blink>");
*_old_u32_attr=u32_attr;
if (style_bitmap)
LBts(style_bitmap,c);
LBts(style_bitmap,u32_attr.u8[1]);
}
while (ch=*st++) {
switch (ch) {
@@ -56,13 +62,13 @@ U0 HtmlPutS(CDoc *doc,I64 c,I64 *_old_c,U8 *st,I64 *_col,U8 *style_bitmap=NULL)
}
U8 *TSLinkCvt2(U8 *filename,I64 line_num)
{ // ::/ --> http://www.templeos.org/Wb/
// Make your own LinkCvt routine
{// ::/ --> http://www.templeos.org/Wb/
//Make your own LinkCvt routine
U8 *result=NULL,*st;
if (filename) {
st=ChgExt(filename,"html");
if (st && StrLen(st)>3 && !StrNCmp(st+1,":/",2))
result=MPrint("http://www.templeos.org/Wb/%s#l%d",st+3,line_num);
result=MStrPrint("http://www.templeos.org/Wb/%s#l%d",st+3,line_num);
Free(st);
}
return result;
@@ -84,6 +90,10 @@ U8 *TSLinkCvt1(U8 *link_st)
case -1:
case LK_DEF:
case LK_HELP_INDEX:
case LK_DOC:
case LK_DOC_ANCHOR:
case LK_DOC_FIND:
case LK_DOC_LINE:
break;
case LK_BIBLE_FIND:
while (LBts(&locks,0))
@@ -108,15 +118,15 @@ public CDoc *Doc2Html(CDoc *doc_in,
U8 *html_header=NULL,
U8 *body_header=NULL,U8 *body_footer=NULL,Bool line_anchors=TRUE,
U8 (*link_cvt)(U8 *link_st)=&TSLinkCvt1)
{
{//Cvt $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ doc to HTML file.
CDocEntry *doc_e,*style,*doc_e2;
I64 i,y,old_y=MIN_I64,cur_u8_attr,col,old_c=-1,old_attr;
I64 i,y,old_y=MIN_I64,col,_old_u32_attr=-1,old_attr;
U32 *hl,*src;
U8 *st,st_2[2],*link_st,*style_bitmap=CAlloc(256/8);
CBGR p[16];
GetVGAPalette4(p);
CDoc *doc_out=DocNew;
Bool unlock_doc_in=DocLock(doc_in),no_backward;
Bool unlock_doc_in=DocLock(doc_in),no_bwd;
old_attr=doc_in->win_task->text_attr;
doc_in->win_task->text_attr=DOC_ATTR_DFT_TEXT;
@@ -150,38 +160,36 @@ public CDoc *Doc2Html(CDoc *doc_in,
doc_e=doc_in->root.next;
col=doc_e->x;
y=doc_e->y;
cur_u8_attr=doc_e->type.u8[1];
while (doc_e!=doc_in) {
if (!(doc_e->flags1&(DOCEF1_SKIP|DOCEF1_HARD_SKIP))) {
if (!(doc_e->de_flags&(DOCEF_SKIP|DOCEF_HARD_SKIP))) {
if (line_anchors && y!=old_y) {
DocPrint(doc_out,"<a name=\"l%d\"></a>",y+1);
old_y=y;
}
while (y<doc_e->y) {
HtmlPutS(doc_out,cur_u8_attr,&old_c,"\n",&col,style_bitmap);
y++;
if (line_anchors && y!=old_y) {
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&_old_u32_attr,"\n",&col,style_bitmap);
if (line_anchors && ++y!=old_y) {
DocPrint(doc_out,"<a name=\"l%d\"></a>",y+1);
old_y=y;
}
col=0;
}
no_backward=TRUE;
no_bwd=TRUE;
doc_e2=doc_e->next;
while (doc_e2!=doc_in && doc_e2->y==doc_e->y) {
if (doc_e2->x<doc_e->x) {
no_backward=FALSE;
no_bwd=FALSE;
break;
}
doc_e2=doc_e2->next;
}
if (no_backward)
if (no_bwd)
while (col<doc_e->x)
HtmlPutS(doc_out,cur_u8_attr,&old_c," ",&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&_old_u32_attr," ",&col,style_bitmap);
link_st=NULL;
if (doc_e->flags1&DOCEF1_HTML_LINK)
if (doc_e->de_flags&DOCEF_HTML_LINK)
link_st=StrNew(doc_e->html_link);
else if (st=DocEntryLink(doc_in,doc_e)) {
link_st=link_cvt(st);
@@ -189,53 +197,51 @@ public CDoc *Doc2Html(CDoc *doc_in,
}
if (link_st) {
if (old_c!=-1) {
if (_old_u32_attr!=-1) {
DocPrint(doc_out,"</span>");
old_c=-1;
_old_u32_attr=-1;
}
DocPrint(doc_out,"<a href=\"%s\">",link_st);
}
cur_u8_attr=doc_e->type.u8[1];
switch (doc_e->type_u8) {
case DOCT_TEXT:
if (doc_e->flags1&DOCEF1_HIGHLIGHT) {
if (doc_e->de_flags&DOCEF_HIGHLIGHT) {
if (doc_e->last==doc_in)
MemCpy(&doc_e->settings,&doc_in->settings_root,sizeof(CDocSettings));
else
MemCpy(&doc_e->settings,&doc_e->last->settings,sizeof(CDocSettings));
src=hl=DocHighlight(doc_e,doc_e->tag,StrLen(doc_e->tag),cur_u8_attr<<8);
src=hl=DocHighlight(doc_e,doc_e->tag,StrLen(doc_e->tag),doc_e->type&0xFF00);
while (*src) {
st_2[0]=*src&0xFF;
HtmlPutS(doc_out,*src>>8,&old_c,st_2,&col,style_bitmap);
src++;
HtmlPutS(doc_out,*src++,&_old_u32_attr,st_2,&col,style_bitmap);
}
Free(hl);
} else
HtmlPutS(doc_out,cur_u8_attr,&old_c,doc_e->tag,&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&_old_u32_attr,doc_e->tag,&col,style_bitmap);
break;
case DOCT_TAB:
HtmlPutS(doc_out,cur_u8_attr,&old_c,"\t",&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&_old_u32_attr,"\t",&col,style_bitmap);
break;
case DOCT_HTML_CODE:
if (old_c!=-1) {
if (_old_u32_attr!=-1) {
DocPrint(doc_out,"</span>");
old_c=-1;
_old_u32_attr=-1;
}
DocPrint(doc_out,"%s",doc_e->tag);
break;
case DOCT_SPRITE:
HtmlPutS(doc_out,cur_u8_attr,&old_c,doc_e->tag,&col,style_bitmap);
HtmlPutS(doc_out,DOC_COLOR_COMMENT+old_c&0xF0,&old_c,"/* Graphics Not Rendered in HTML */",&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&_old_u32_attr,doc_e->tag,&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&_old_u32_attr,"/* Graphics Not Rendered in HTML */",&col,style_bitmap);
break;
default:
if (doc_e->flags1&DOCEF1_TAG)
HtmlPutS(doc_out,cur_u8_attr,&old_c,doc_e->tag,&col,style_bitmap);
if (doc_e->de_flags&DOCEF_TAG)
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&_old_u32_attr,doc_e->tag,&col,style_bitmap);
}
if (link_st) {
if (old_c!=-1) {
if (_old_u32_attr!=-1) {
DocPrint(doc_out,"</span>");
old_c=-1;
_old_u32_attr=-1;
}
DocPrint(doc_out,"</a>");
Free(link_st);
@@ -243,14 +249,15 @@ public CDoc *Doc2Html(CDoc *doc_in,
}
doc_e=doc_e->next;
}
while (y<doc_e->y) {
HtmlPutS(doc_out,cur_u8_attr,&old_c,"\n",&col,style_bitmap);
y++;
while (y++<doc_e->y) {
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&_old_u32_attr,"\n",&col,style_bitmap);
col=0;
}
if (old_c!=-1) {
if (_old_u32_attr!=-1) {
if (_old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
DocPrint(doc_out,"</span>");
old_c=-1;
_old_u32_attr=-1;
}
DocPrint(doc_out,"%s",body_footer);
DocPrint(doc_out,"</pre></body>\n</html>\n");
@@ -269,18 +276,17 @@ public CDoc *Doc2Html(CDoc *doc_in,
return doc_out;
}
#help_index "Utils;Cmd Line (Typically);Doc/Cvt;Doc/Cmd Line (Typically)"
#help_index "Cmd Line (Typically);DolDoc/Conversion;DolDoc/Cmd Line (Typically)"
public U0 ToHtml(U8 *_in_name,U8 *_out_name=NULL,U8 *html_header=NULL,
U8 *body_header=NULL,U8 *body_footer=NULL,I64 width=80,
Bool line_anchors=TRUE,U8 (*link_cvt)(U8 *link_st)=&TSLinkCvt1)
{//Convert $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ file to HTML.
//Supply your own link_cvt routine.
{
U8 *in_name,*out_name;
CDoc *doc_in,*doc_out;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
SetWinHorz(0,width-1); //This sets doc width for word wrap
SetWinHorz(0,width-1); //Sets doc width for word wrap.
in_name=DftExt(_in_name,"CPP.Z"),
if (_out_name)
@@ -300,5 +306,3 @@ public U0 ToHtml(U8 *_in_name,U8 *_out_name=NULL,U8 *html_header=NULL,
Free(in_name);
Free(out_name);
}
#help_index ""
+11 -14
View File
@@ -1,4 +1,4 @@
#help_index "Doc/Cvt"
#help_index "DolDoc/Conversion"
U0 TXTPutS(CDoc *doc,U8 *st,I64 *_col)
{
@@ -36,11 +36,11 @@ U0 TXTPutS(CDoc *doc,U8 *st,I64 *_col)
}
public CDoc *Doc2TXT(CDoc *doc_in)
{
{//Cvt $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ doc to plain text.
CDocEntry *doc_e,*doc_e2;
I64 y,col;
CDoc *doc_out=DocNew;
Bool unlock_doc_in=DocLock(doc_in),no_backward;
Bool unlock_doc_in=DocLock(doc_in),no_bwd;
DocRecalc(doc_in);
@@ -50,23 +50,23 @@ public CDoc *Doc2TXT(CDoc *doc_in)
col=doc_e->x;
y=doc_e->y;
while (doc_e!=doc_in) {
if (!(doc_e->flags1&(DOCEF1_SKIP|DOCEF1_HARD_SKIP))) {
if (!(doc_e->de_flags&(DOCEF_SKIP|DOCEF_HARD_SKIP))) {
while (y<doc_e->y) {
TXTPutS(doc_out,"\n",&col);
y++;
col=0;
}
no_backward=TRUE;
no_bwd=TRUE;
doc_e2=doc_e->next;
while (doc_e2!=doc_in && doc_e2->y==doc_e->y) {
if (doc_e2->x<doc_e->x) {
no_backward=FALSE;
no_bwd=FALSE;
break;
}
doc_e2=doc_e2->next;
}
if (no_backward)
if (no_bwd)
while (col<doc_e->x)
TXTPutS(doc_out," ",&col);
@@ -82,7 +82,7 @@ public CDoc *Doc2TXT(CDoc *doc_in)
case DOCT_SPRITE:
break;
default:
if (doc_e->flags1&DOCEF1_TAG)
if (doc_e->de_flags&DOCEF_TAG)
TXTPutS(doc_out,doc_e->tag,&col);
}
}
@@ -101,15 +101,14 @@ public CDoc *Doc2TXT(CDoc *doc_in)
return doc_out;
}
#help_index "Utils;Cmd Line (Typically);Doc/Cvt;Doc/Cmd Line (Typically)"
#help_index "Cmd Line (Typically);DolDoc/Conversion;DolDoc/Cmd Line (Typically)"
public U0 ToTXT(U8 *_in_name,U8 *_out_name=NULL,I64 width=70)
{
{//Convert $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ file to plain text.
U8 *in_name,*out_name;
CDoc *doc_in,*doc_out;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
SetWinHorz(0,width-1); //This sets doc width for word wrap
SetWinHorz(0,width-1); //Sets doc width for word wrap.
in_name=DftExt(_in_name,"TXT.Z"),
if (_out_name)
@@ -129,5 +128,3 @@ public U0 ToTXT(U8 *_in_name,U8 *_out_name=NULL,I64 width=70)
Free(in_name);
Free(out_name);
}
#help_index ""