Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes847downloads
WebLogScramble.txt71 linesDownload Raw Back to WebLogDemo
1 2U8 key[4][256];3 4U0 InitKey()5{6  I64 i,j;7  for (i=0;i<4;i++) {8    for (j=0;j<256;j++)9      key[i][j]=j;10    for (j=0;j<255;j++)11      SwapU8(&key[i][j],&key[i][j+RandU32%(256-j)]);12  }13}14 15U0 LogScrambleFile(U8 *name)16{17  CDoc *doc=DocRead(name,DOCF_PLAIN_TEXT|DOCF_NO_CURSOR);18  CDocEntry *doc_e=doc->head.next;19  I64 i;20  U32 num;21  U8 *st,*st2;22  "Scrambling: %s\n",name;23  while (doc_e!=doc) {24    if (doc_e->type_u8==DOCT_TEXT) {25      st=MAlloc(StrLen(doc_e->tag)+1);26      st2=MAlloc(StrLen(doc_e->tag)+1);27      StrFirstRem(doc_e->tag," ",st);28 29      for (i=3;i>=0;i--) {30        StrFirstRem(st,".",st2);31        num.u8[i]=key[i][Str2I64(st2)&255];32      }33 34      Free(st);35      Free(st2);36 37      st=MStrPrint("%d.%d.%d.%d %s",num.u8[3],num.u8[2],38            num.u8[1],num.u8[0],doc_e->tag);39      Free(doc_e->tag);40      doc_e->tag=st;41    }42    doc_e=doc_e->next;43  }44  DocWrite(doc);45  DocDel(doc);46}47U0 WebLogScramble(U8 *files_find_mask)48{49  CDirEntry *tmpde=FilesFind(files_find_mask,FUF_RECURSE|FUF_JUST_FILES),50        *tmpde1=tmpde;51  InitKey;52  while (tmpde) {53    LogScrambleFile(tmpde->full_name);54    tmpde=tmpde->next;55  }56  DirTreeDel(tmpde1);57}58 59U0 LogScrambleDemo()60{61  U8 *dirname;62  Cd(__DIR__);63  dirname=DirCur;64  ST_WARN_ST "This will scramble all .LOG files in '%s'.\n\n",dirname;65  Free(dirname);66  if (AreYouSure)67    WebLogScramble("*.LOG*");68}69 70LogScrambleDemo;71