.
D 2020-04-20T16:03:24.642
J comment <div>Dear\sRoy,</div><div><br\s/></div><div>thank\syou\sfor\sgreat\stcl2c.tcl\sand\sits\sframework.</div><div>I\sam\slearning\seach\sday\sand\sdigging\smiself\sthrough\sthe\smechanisms.</div><div>Sorry\sto\sbe\sa\snovice.</div><div>And\ssorry\sto\suse\sMicrosoft\scompilers.</div><div><br\s/></div><div>The\scompiler\sMS-VC2015\s(VC9)\shas\sa\sstring\sconstant\ssize\slimit\sof\s65535\scharacters.</div><div>A\spossibility\sto\savoid\sthis\slimit\sis\sto\suse\san\sarray\sof\scharacters,\swhich\shave\sa\slimit\sof\ssize_z\s=\s0x7CFFFFFF.</div><div><br\s/></div><div>The\spatch\sbelow\schanges\sdir2c.tcl\sto\soutput\seach\sfile\swithin\sone\scharacter\sarray\snamed \scvfs_data_$idx\sas\sfollows:</div><div><br\s/></div><div><verbatim></div><div>/*\sData\sof\sboot.tcl\s*/<br\s/>static\sunsigned\schar\scvfs_data_2[]\s=\s{<br\s/> \s0x70,\s0x72,\s0x6f,\s0x63,\s0x20,\s0x74,\s0x63,\s0x6c,\s0x49,\s0x6e,\s0x69,\s0x74,\s0x20,\s0x7b,\s0x7d,\s0x20,\s<br\s/>...</div><div>static\sstruct\scvfs_data\scvfs_tcl_data[]\s=\s{<br\s/></div><div>...<br\s/></div><div> \s{<br\s/> \s \s/*\sname \s*/\s"boot.tcl",<br\s/> \s \s/*\sindex\s*/\s2,<br\s/> \s \s/*\stype \s*/\sCVFS_FILETYPE_FILE,<br\s/> \s \s/*\ssize \s*/\s2887,<br\s/> \s \s/*\sdata \s*/\scvfs_data_2,<br\s/> \s \s/*\sfree \s*/\s0,<br\s/> \s},<br\s/></verbatim><br\s/></div><div><br\s/></div><div>The\spatch\sallows\sto\suse\sthis\sfor\sall\sfiles\sor\sfiles\slarger\sthan\sthe\scharacter\slength\slimit.</div><div><br\s/></div><div>I\smay\smiss\sanother\sdisadvantage\sof\sthis\smethod.\sI\ssuppose,\sit\sonly\savoids\sthe\simplicite\strailing\szero\sbyte.<br\s/></div><div><br\s/></div><div>Thank\syou,</div><div>Harald</div><div><br\s/></div><div>Patch:</div><div><verbatim></div><div>---\sC:/Users/oehhar/AppData/Local/Temp/dir2c.tcl-revBASE.svn001.tmp.tcl \sFri\sApr\s17\s17:29:24\s2020<br\s/>+++\sC:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c.tcl \sMon\sApr\s20\s17:30:25\s2020<br\s/>@@\s-66,26\s+66,44\s@@<br\s/> proc\sstringify\s{data}\s{<br\s/> \sset\sret\s"\\""<br\s/> \sfor\s{set\sidx\s0}\s{$idx\s<\s[string\slength\s$data]}\s{incr\sidx}\s{<br\s/> \s \sbinary\sscan\s[string\sindex\s$data\s$idx]\sH*\schar<br\s/> <br\s/> \s \sappend\sret\s"\\\\x${char}"<br\s/> <br\s/>- \s \sif\s{($idx\s%\s20)\s==\s0\s&&\s$idx\s!=\s0}\s{<br\s/>+ \s \sif\s{(($idx+1)\s%\s20)\s==\s0}\s{<br\s/> \s \s \sappend\sret\s"\\"\\n\\""<br\s/> \s \s}<br\s/> \s}<br\s/> <br\s/> \sset\sret\s[string\strim\s$ret\s"\\n\\""]<br\s/> <br\s/> \sset\sret\s"\\"$ret\\""<br\s/> <br\s/> \sreturn\s$ret<br\s/> }<br\s/> <br\s/>+#\sConvert\sdata\sto\sa\scharacter\sarray<br\s/>+proc\scharacter_array\s{data}\s{<br\s/>+ \sset\sret\s"\\{\\n\\t"<br\s/>+ \sfor\s{set\sidx\s0}\s{$idx\s<\s[string\slength\s$data]}\s{incr\sidx}\s{<br\s/>+ \s \sbinary\sscan\s[string\sindex\s$data\s$idx]\sH*\schar<br\s/>+ \s \sappend\sret\s"0x${char},\s"<br\s/>+<br\s/>+ \s \sif\s{(($idx+1)\s%\s16)\s==\s0\s}\s{<br\s/>+ \s \s \sappend\sret\s"\\n\\t"<br\s/>+ \s \s}<br\s/>+ \s}<br\s/>+ \sset\sret\s[string\strimright\s$ret\s"\\n,\s\\t"]<br\s/>+<br\s/>+ \sappend\sret\s"\\n\\}"<br\s/>+<br\s/>+ \sreturn\s$ret<br\s/>+}<br\s/>+<br\s/> #\sEncrypt\sthe\sdata<br\s/> proc\srandom_byte\s{}\s{<br\s/> \sset\svalue\s[expr\s{int(256\s*\srand())}]<br\s/> <br\s/> \sreturn\s$value<br\s/> }<br\s/> <br\s/>@@\s-303,64\s+321,80\s@@<br\s/> <br\s/> \sreturn(0);<br\s/> }<br\s/> <br\s/> # \sendif\s/*\s!LOADED_CVFS_COMMON\s*/}<br\s/> puts\s""<br\s/> <br\s/>-puts\s"static\sstruct\scvfs_data\s${code_tag}_data\\[\\]\s=\s{"<br\s/>-puts\s"\\t{"<br\s/>-puts\s"\\t\\t/*\sIndex\s0\scannot\sbe\sused\sbecause\swe\suse\sthe\svalue\s0\sto\srepresent\sfailure\s*/"<br\s/>-puts\s"\\t\\t/*\sname \s*/\sNULL,"<br\s/>-puts\s"\\t\\t/*\sindex\s*/\s0,"<br\s/>-puts\s"\\t\\t/*\stype \s*/\s0,"<br\s/>-puts\s"\\t\\t/*\ssize \s*/\s0,"<br\s/>-puts\s"\\t\\t/*\sdata \s*/\sNULL,"<br\s/>-puts\s"\\t\\t/*\sfree \s*/\s0,"<br\s/>-puts\s"\\t},"<br\s/>+#\sC\sstruct\sdata\soutput\sbuffer\s(must\sbe\sdelayed\safter\sdefinition\sof\sfile\sdata)<br\s/>+set\sstruct_data\s""<br\s/>+<br\s/> for\s{set\sidx\s1}\s{$idx\s<\s[llength\s$files]}\s{incr\sidx}\s{<br\s/> \sset\sfile\s[lindex\s$files\s$idx]<br\s/> \sset\sshortfile\s[shorten_file\s$startdir\s$file]<br\s/> <br\s/> \sunset\s-nocomplain\sfinfo\stype<br\s/> \sfile\sstat\s$file\sfinfo<br\s/> <br\s/> \sswitch\s--\s$finfo(type)\s{<br\s/> \s \s"file"\s{<br\s/> \s \s \sset\ssize\s$finfo(size)<br\s/> <br\s/> \s \s \sset\sfd\s[open\s$file]<br\s/> \s \s \sfconfigure\s$fd\s-translation\sbinary<br\s/>- \s \s \sset\sdata\s[read\s$fd]<br\s/>+ \s \s \sset\sdata_in\s[read\s$fd]<br\s/> \s \s \sclose\s$fd<br\s/> <br\s/> \s \s \sif\s{$obsfucate}\s{<br\s/> \s \s \s \sset\stype\s"CVFS_FILETYPE_ENCRYPTED_FILE"<br\s/>- \s \s \s \sset\sdata\s"(unsigned\schar\s*)\s[stringify\s[encrypt\s$data\s$obsfucation_key]]"<br\s/>+ \s \s \s \sset\sdata_in\s[encrypt\s$data\s$obsfucation_key]<br\s/> \s \s \s}\selse\s{<br\s/> \s \s \s \sset\stype\s"CVFS_FILETYPE_FILE"<br\s/>- \s \s \s \sset\sdata\s"(unsigned\schar\s*)\s[stringify\s$data]"<br\s/> \s \s \s}<br\s/>+ \s \s \s#\sMicrosoft\sVC9\scompiler\shas\sa\sstring\slimit\sof\s65535\sbytes<br\s/>+ \s \s \s#\sso\sput\sall\slarger\sfiles\sinto\san\sarray\swhich\shas\sa\shigher<br\s/>+ \s \s \s#\sstring\slimit<br\s/>+ \s \s \s#if\s{$size\s<=\s65535}\s{<br\s/>+ \s \s \s# \sset\sdata\s"(unsigned\schar\s*)\s[stringify\s$data_in]"<br\s/>+ \s \s \s#}\selse\s{<br\s/>+ \s \s \s \sputs\s"/*\sData\sof\s$shortfile\s*/"<br\s/>+ \s \s \s \sset\svariable_name\scvfs_data_$idx<br\s/>+ \s \s \s \sset\sdata\s$variable_name<br\s/>+ \s \s \s \sputs\s"static\sunsigned\schar\s${variable_name}\\[\\]\s=\\<br\s/>+ \s \s \s \s \s \s[character_array\s$data_in];"<br\s/>+ \s \s \s#}<br\s/> \s \s}<br\s/> \s \s"directory"\s{<br\s/> \s \s \sset\stype\s"CVFS_FILETYPE_DIR"<br\s/> \s \s \sset\sdata\s"NULL"<br\s/> \s \s \sset\ssize\s0<br\s/> \s \s}<br\s/> \s}<br\s/> <br\s/>- \sputs\s"\\t{"<br\s/>- \sputs\s"\\t\\t/*\sname \s*/\s\\"$shortfile\\","<br\s/>- \sputs\s"\\t\\t/*\sindex\s*/\s$idx,"<br\s/>- \sputs\s"\\t\\t/*\stype \s*/\s$type,"<br\s/>- \sputs\s"\\t\\t/*\ssize \s*/\s$size,"<br\s/>- \sputs\s"\\t\\t/*\sdata \s*/\s$data,"<br\s/>- \sputs\s"\\t\\t/*\sfree \s*/\s0,"<br\s/>- \sputs\s"\\t},"<br\s/>+ \sappend\sstruct_data\s"\\t{\\n"\\<br\s/>+ \s \s \s"\\t\\t/*\sname \s*/\s\\"$shortfile\\",\\n"\\<br\s/>+ \s \s \s"\\t\\t/*\sindex\s*/\s$idx,\\n"\\<br\s/>+ \s \s \s"\\t\\t/*\stype \s*/\s$type,\\n"\\<br\s/>+ \s \s \s"\\t\\t/*\ssize \s*/\s$size,\\n"\\<br\s/>+ \s \s \s"\\t\\t/*\sdata \s*/\s$data,\\n"\\<br\s/>+ \s \s \s"\\t\\t/*\sfree \s*/\s0,\\n"\\<br\s/>+ \s \s \s"\\t},\\n"<br\s/> }<br\s/>+puts\s""<br\s/>+puts\s"static\sstruct\scvfs_data\s${code_tag}_data\\[\\]\s=\s{"<br\s/>+puts\s"\\t{"<br\s/>+puts\s"\\t\\t/*\sIndex\s0\scannot\sbe\sused\sbecause\swe\suse\sthe\svalue\s0\sto\srepresent\sfailure\s*/"<br\s/>+puts\s"\\t\\t/*\sname \s*/\sNULL,"<br\s/>+puts\s"\\t\\t/*\sindex\s*/\s0,"<br\s/>+puts\s"\\t\\t/*\stype \s*/\s0,"<br\s/>+puts\s"\\t\\t/*\ssize \s*/\s0,"<br\s/>+puts\s"\\t\\t/*\sdata \s*/\sNULL,"<br\s/>+puts\s"\\t\\t/*\sfree \s*/\s0,"<br\s/>+puts\s"\\t},"<br\s/>+puts\s-nonewline\s$struct_data<br\s/> puts\s"};"<br\s/> puts\s""<br\s/> <br\s/> puts\s"static\sunsigned\slong\s${code_tag}_lookup_index(const\schar\s*path)\s{"<br\s/> puts\s"\\tswitch\s(cvfs_hash((unsigned\schar\s*)\spath))\s{"<br\s/> <br\s/> for\s{set\sidx\s1}\s{$idx\s<\s[llength\s$files]}\s{incr\sidx}\s{<br\s/><br\s/></div><div></verbatim><br\s/></div>
J foundin trunk
J login anonymous
J private_contact 0f366eb3e9e2fcab52b8ebacd197db9047186a5f
J severity Minor
J status Open
J title dir2c:\sOutput\sdata\sas\scharacter\sarray\sand\snot\sas\sstring
J type Feature\sRequest
K bd6188edd4290bfdcff4a8ef9355f5280496eda5
U anonymous
Z abde5fc13982fa4229bd20c2de3c66b5