History Of Ticket bd6188edd4290bfd

Artifacts Associated With Ticket bd6188edd4290bfd

  1. Ticket change [4eaaa9b664] (rid 2628) by anonymous on 2020-04-20 16:03:24:

    1. comment initialized to:
      <div>Dear Roy,</div><div><br /></div><div>thank you for great tcl2c.tcl and its framework.</div><div>I am learning each day and digging miself through the mechanisms.</div><div>Sorry to be a novice.</div><div>And sorry to use Microsoft compilers.</div><div><br /></div><div>The compiler MS-VC2015 (VC9) has a string constant size limit of 65535 characters.</div><div>A possibility to avoid this limit is to use an array of characters, which have a limit of size_z = 0x7CFFFFFF.</div><div><br /></div><div>The patch below changes dir2c.tcl to output each file within one character array named&nbsp; cvfs_data_$idx as follows:</div><div><br /></div><div>&lt;verbatim&gt;</div><div>/* Data of boot.tcl */<br />static unsigned char cvfs_data_2[] = {<br />&nbsp;&nbsp;&nbsp; 0x70, 0x72, 0x6f, 0x63, 0x20, 0x74, 0x63, 0x6c, 0x49, 0x6e, 0x69, 0x74, 0x20, 0x7b, 0x7d, 0x20, <br />...</div><div>static struct cvfs_data cvfs_tcl_data[] = {<br /></div><div>...<br /></div><div>&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* name&nbsp; */ "boot.tcl",<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* index */ 2,<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* type&nbsp; */ CVFS_FILETYPE_FILE,<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* size&nbsp; */ 2887,<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* data&nbsp; */ cvfs_data_2,<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* free&nbsp; */ 0,<br />&nbsp;&nbsp;&nbsp; },<br />&lt;/verbatim&gt;<br /></div><div><br /></div><div>The patch allows to use this for all files or files larger than the character length limit.</div><div><br /></div><div>I may miss another disadvantage of this method. I suppose, it only avoids the implicite trailing zero byte.<br /></div><div><br /></div><div>Thank you,</div><div>Harald</div><div><br /></div><div>Patch:</div><div>&lt;verbatim&gt;</div><div>--- C:/Users/oehhar/AppData/Local/Temp/dir2c.tcl-revBASE.svn001.tmp.tcl&nbsp;&nbsp;&nbsp; Fri Apr 17 17:29:24 2020<br />+++ C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c.tcl&nbsp;&nbsp;&nbsp; Mon Apr 20 17:30:25 2020<br />@@ -66,26 +66,44 @@<br />&nbsp;proc stringify {data} {<br />&nbsp;&nbsp;&nbsp;&nbsp; set ret "\""<br />&nbsp;&nbsp;&nbsp;&nbsp; for {set idx 0} {$idx &lt; [string length $data]} {incr idx} {<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; binary scan [string index $data $idx] H* char<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; append ret "\\x${char}"<br />&nbsp;<br />-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if {($idx % 20) == 0 &amp;&amp; $idx != 0} {<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if {(($idx+1) % 20) == 0} {<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; append ret "\"\n\""<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; set ret [string trim $ret "\n\""]<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; set ret "\"$ret\""<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; return $ret<br />&nbsp;}<br />&nbsp;<br />+# Convert data to a character array<br />+proc character_array {data} {<br />+&nbsp;&nbsp;&nbsp; set ret "\{\n\t"<br />+&nbsp;&nbsp;&nbsp; for {set idx 0} {$idx &lt; [string length $data]} {incr idx} {<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; binary scan [string index $data $idx] H* char<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; append ret "0x${char}, "<br />+<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if {(($idx+1) % 16) == 0 } {<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; append ret "\n\t"<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />+&nbsp;&nbsp;&nbsp; }<br />+&nbsp;&nbsp;&nbsp; set ret [string trimright $ret "\n, \t"]<br />+<br />+&nbsp;&nbsp;&nbsp; append ret "\n\}"<br />+<br />+&nbsp;&nbsp;&nbsp; return $ret<br />+}<br />+<br />&nbsp;# Encrypt the data<br />&nbsp;proc random_byte {} {<br />&nbsp;&nbsp;&nbsp;&nbsp; set value [expr {int(256 * rand())}]<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; return $value<br />&nbsp;}<br />&nbsp;<br />@@ -303,64 +321,80 @@<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; return(0);<br />&nbsp;}<br />&nbsp;<br />&nbsp;#&nbsp; endif /* !LOADED_CVFS_COMMON */}<br />&nbsp;puts ""<br />&nbsp;<br />-puts "static struct cvfs_data ${code_tag}_data\[\] = {"<br />-puts "\t{"<br />-puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"<br />-puts "\t\t/* name&nbsp; */ NULL,"<br />-puts "\t\t/* index */ 0,"<br />-puts "\t\t/* type&nbsp; */ 0,"<br />-puts "\t\t/* size&nbsp; */ 0,"<br />-puts "\t\t/* data&nbsp; */ NULL,"<br />-puts "\t\t/* free&nbsp; */ 0,"<br />-puts "\t},"<br />+# C struct data output buffer (must be delayed after definition of file data)<br />+set struct_data ""<br />+<br />&nbsp;for {set idx 1} {$idx &lt; [llength $files]} {incr idx} {<br />&nbsp;&nbsp;&nbsp;&nbsp; set file [lindex $files $idx]<br />&nbsp;&nbsp;&nbsp;&nbsp; set shortfile [shorten_file $startdir $file]<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; unset -nocomplain finfo type<br />&nbsp;&nbsp;&nbsp;&nbsp; file stat $file finfo<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; switch -- $finfo(type) {<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "file" {<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set size $finfo(size)<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set fd [open $file]<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fconfigure $fd -translation binary<br />-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set data [read $fd]<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set data_in [read $fd]<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; close $fd<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if {$obsfucate} {<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set type "CVFS_FILETYPE_ENCRYPTED_FILE"<br />-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set data "(unsigned char *) [stringify [encrypt $data $obsfucation_key]]"<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set data_in [encrypt $data $obsfucation_key]<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else {<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set type "CVFS_FILETYPE_FILE"<br />-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set data "(unsigned char *) [stringify $data]"<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Microsoft VC9 compiler has a string limit of 65535 bytes<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # so put all larger files into an array which has a higher<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # string limit<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #if {$size &lt;= 65535} {<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; set data "(unsigned char *) [stringify $data_in]"<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #} else {<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; puts "/* Data of $shortfile */"<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set variable_name cvfs_data_$idx<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set data $variable_name<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; puts "static unsigned char ${variable_name}\[\] =\<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [character_array $data_in];"<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #}<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "directory" {<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set type "CVFS_FILETYPE_DIR"<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set data "NULL"<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set size 0<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;<br />-&nbsp;&nbsp;&nbsp; puts "\t{"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t/* name&nbsp; */ \"$shortfile\","<br />-&nbsp;&nbsp;&nbsp; puts "\t\t/* index */ $idx,"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t/* type&nbsp; */ $type,"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t/* size&nbsp; */ $size,"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t/* data&nbsp; */ $data,"<br />-&nbsp;&nbsp;&nbsp; puts "\t\t/* free&nbsp; */ 0,"<br />-&nbsp;&nbsp;&nbsp; puts "\t},"<br />+&nbsp;&nbsp;&nbsp; append struct_data "\t{\n"\<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "\t\t/* name&nbsp; */ \"$shortfile\",\n"\<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "\t\t/* index */ $idx,\n"\<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "\t\t/* type&nbsp; */ $type,\n"\<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "\t\t/* size&nbsp; */ $size,\n"\<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "\t\t/* data&nbsp; */ $data,\n"\<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "\t\t/* free&nbsp; */ 0,\n"\<br />+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "\t},\n"<br />&nbsp;}<br />+puts ""<br />+puts "static struct cvfs_data ${code_tag}_data\[\] = {"<br />+puts "\t{"<br />+puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"<br />+puts "\t\t/* name&nbsp; */ NULL,"<br />+puts "\t\t/* index */ 0,"<br />+puts "\t\t/* type&nbsp; */ 0,"<br />+puts "\t\t/* size&nbsp; */ 0,"<br />+puts "\t\t/* data&nbsp; */ NULL,"<br />+puts "\t\t/* free&nbsp; */ 0,"<br />+puts "\t},"<br />+puts -nonewline $struct_data<br />&nbsp;puts "};"<br />&nbsp;puts ""<br />&nbsp;<br />&nbsp;puts "static unsigned long ${code_tag}_lookup_index(const char *path) {"<br />&nbsp;puts "\tswitch (cvfs_hash((unsigned char *) path)) {"<br />&nbsp;<br />&nbsp;for {set idx 1} {$idx &lt; [llength $files]} {incr idx} {<br /><br /></div><div>&lt;/verbatim&gt;<br /></div>
      
    2. foundin initialized to: "trunk"
    3. login: "anonymous"
    4. private_contact initialized to: "0f366eb3e9e2fcab52b8ebacd197db9047186a5f"
    5. severity initialized to: "Minor"
    6. status initialized to: "Open"
    7. title initialized to:
      dir2c: Output data as character array and not as string
      
    8. type initialized to: "Feature Request"
  2. Ticket change [5f15c8b012] (rid 2634) by anonymous on 2020-05-11 16:38:04:

    1. icomment:
      Dear Roy,
      
      sorry, this patch also has an issue. The obfuscated version does not work any more (wrong variable data instead data_in).
      
      Here is a corrected total patch including ticket [127ac40147]
      
      <verbatim>
      
      --- C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c.tcl	Mon May 11 07:31:09 2020
      +++ C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c_ori.tcl	Wed Jan 22 20:53:52 2020
      @@ -70,7 +70,7 @@
       
       		append ret "\\x${char}"
       
      -		if {(($idx+1) % 20) == 0} {
      +		if {($idx % 20) == 0 && $idx != 0} {
       			append ret "\"\n\""
       		}
       	}
      @@ -82,24 +82,6 @@
       	return $ret
       }
       
      -# Convert data to a character array
      -proc character_array {data} {
      -	set ret "\{\n\t"
      -	for {set idx 0} {$idx < [string length $data]} {incr idx} {
      -		binary scan [string index $data $idx] H* char
      -		append ret "0x${char}, "
      -
      -		if {(($idx+1) % 16) == 0 } {
      -			append ret "\n\t"
      -		}
      -	}
      -	set ret [string trimright $ret "\n, \t"]
      -
      -	append ret "\n\}"
      -
      -	return $ret
      -}
      -
       # Encrypt the data
       proc random_byte {} {
       	set value [expr {int(256 * rand())}]
      @@ -325,9 +307,16 @@
       #  endif /* !LOADED_CVFS_COMMON */}
       puts ""
       
      -# C struct data output buffer (must be delayed after definition of file data)
      -set struct_data ""
      -
      +puts "static struct cvfs_data ${code_tag}_data\[\] = {"
      +puts "\t{"
      +puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"
      +puts "\t\t.name  = NULL,"
      +puts "\t\t.index = 0,"
      +puts "\t\t.type  = 0,"
      +puts "\t\t.size  = 0,"
      +puts "\t\t.data  = NULL,"
      +puts "\t\t.free  = 0,"
      +puts "\t},"
       for {set idx 1} {$idx < [llength $files]} {incr idx} {
       	set file [lindex $files $idx]
       	set shortfile [shorten_file $startdir $file]
      @@ -341,28 +330,15 @@
       
       			set fd [open $file]
       			fconfigure $fd -translation binary
      -			set data_in [read $fd]
      +			set data [read $fd]
       			close $fd
       
       			if {$obsfucate} {
       				set type "CVFS_FILETYPE_ENCRYPTED_FILE"
      -				set data_in [encrypt $data_in $obsfucation_key]
      +				set data "(unsigned char *) [stringify [encrypt $data $obsfucation_key]]"
       			} else {
       				set type "CVFS_FILETYPE_FILE"
      -			}
      -			# Microsoft VC9 compiler has a string limit of 65535 bytes
      -			# so put all larger files into an array which has a higher
      -			# string limit
      -			# For instance, the extra variable is used for all files.
      -			# this may be deactivated by removing "0 &" below
      -			if { 0 & $size <= 65535} {
      -				set data "(unsigned char *) [stringify $data_in]"
      -			} else {
      -				puts "/* Data of $shortfile */"
      -				set variable_name cvfs_data_$idx
      -				set data $variable_name
      -				puts "static unsigned char ${variable_name}\[\] =\
      -						[character_array $data_in];"
      +				set data "(unsigned char *) [stringify $data]"
       			}
       		}
       		"directory" {
      @@ -372,27 +348,15 @@
       		}
       	}
       
      -	append struct_data "\t{\n"\
      -			"\t\t/* name  */ \"$shortfile\",\n"\
      -			"\t\t/* index */ $idx,\n"\
      -			"\t\t/* size  */ $size,\n"\
      -			"\t\t/* type  */ $type,\n"\
      -			"\t\t/* data  */ $data,\n"\
      -			"\t\t/* free  */ 0,\n"\
      -			"\t},\n"
      +	puts "\t{"
      +	puts "\t\t.name  = \"$shortfile\","
      +	puts "\t\t.index = $idx,"
      +	puts "\t\t.type  = $type,"
      +	puts "\t\t.size  = $size,"
      +	puts "\t\t.data  = $data,"
      +	puts "\t\t.free  = 0,"
      +	puts "\t},"
       }
      -puts ""
      -puts "static struct cvfs_data ${code_tag}_data\[\] = {"
      -puts "\t{"
      -puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"
      -puts "\t\t/* name  */ NULL,"
      -puts "\t\t/* index */ 0,"
      -puts "\t\t/* type  */ 0,"
      -puts "\t\t/* size  */ 0,"
      -puts "\t\t/* data  */ NULL,"
      -puts "\t\t/* free  */ 0,"
      -puts "\t},"
      -puts -nonewline $struct_data
       puts "};"
       puts ""
      
      </verbatim>
      
    2. login: "anonymous"
    3. mimetype: "text/x-fossil-wiki"
    4. priority changed to: "Immediate"
    5. resolution changed to: "Open"
    6. subsystem changed to: "Tcl"
    7. username: "oehhar"
  3. Ticket change [2536b9c03b] (rid 2635) by anonymous on 2020-05-11 16:40:12:

    1. icomment:
      I would love to be able to edit my own bad stuff.
      
      The diff was in the wrong direction. Here is the corrected diff:
      
      <verbatim>
      
      --- C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c_ori.tcl	Wed Jan 22 20:53:52 2020
      +++ C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c.tcl	Mon May 11 07:31:09 2020
      @@ -70,7 +70,7 @@
       
       		append ret "\\x${char}"
       
      -		if {($idx % 20) == 0 && $idx != 0} {
      +		if {(($idx+1) % 20) == 0} {
       			append ret "\"\n\""
       		}
       	}
      @@ -82,6 +82,24 @@
       	return $ret
       }
       
      +# Convert data to a character array
      +proc character_array {data} {
      +	set ret "\{\n\t"
      +	for {set idx 0} {$idx < [string length $data]} {incr idx} {
      +		binary scan [string index $data $idx] H* char
      +		append ret "0x${char}, "
      +
      +		if {(($idx+1) % 16) == 0 } {
      +			append ret "\n\t"
      +		}
      +	}
      +	set ret [string trimright $ret "\n, \t"]
      +
      +	append ret "\n\}"
      +
      +	return $ret
      +}
      +
       # Encrypt the data
       proc random_byte {} {
       	set value [expr {int(256 * rand())}]
      @@ -307,16 +325,9 @@
       #  endif /* !LOADED_CVFS_COMMON */}
       puts ""
       
      -puts "static struct cvfs_data ${code_tag}_data\[\] = {"
      -puts "\t{"
      -puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"
      -puts "\t\t.name  = NULL,"
      -puts "\t\t.index = 0,"
      -puts "\t\t.type  = 0,"
      -puts "\t\t.size  = 0,"
      -puts "\t\t.data  = NULL,"
      -puts "\t\t.free  = 0,"
      -puts "\t},"
      +# C struct data output buffer (must be delayed after definition of file data)
      +set struct_data ""
      +
       for {set idx 1} {$idx < [llength $files]} {incr idx} {
       	set file [lindex $files $idx]
       	set shortfile [shorten_file $startdir $file]
      @@ -330,15 +341,28 @@
       
       			set fd [open $file]
       			fconfigure $fd -translation binary
      -			set data [read $fd]
      +			set data_in [read $fd]
       			close $fd
       
       			if {$obsfucate} {
       				set type "CVFS_FILETYPE_ENCRYPTED_FILE"
      -				set data "(unsigned char *) [stringify [encrypt $data $obsfucation_key]]"
      +				set data_in [encrypt $data_in $obsfucation_key]
       			} else {
       				set type "CVFS_FILETYPE_FILE"
      -				set data "(unsigned char *) [stringify $data]"
      +			}
      +			# Microsoft VC9 compiler has a string limit of 65535 bytes
      +			# so put all larger files into an array which has a higher
      +			# string limit
      +			# For instance, the extra variable is used for all files.
      +			# this may be deactivated by removing "0 &" below
      +			if { 0 & $size <= 65535} {
      +				set data "(unsigned char *) [stringify $data_in]"
      +			} else {
      +				puts "/* Data of $shortfile */"
      +				set variable_name cvfs_data_$idx
      +				set data $variable_name
      +				puts "static unsigned char ${variable_name}\[\] =\
      +						[character_array $data_in];"
       			}
       		}
       		"directory" {
      @@ -348,15 +372,27 @@
       		}
       	}
       
      -	puts "\t{"
      -	puts "\t\t.name  = \"$shortfile\","
      -	puts "\t\t.index = $idx,"
      -	puts "\t\t.type  = $type,"
      -	puts "\t\t.size  = $size,"
      -	puts "\t\t.data  = $data,"
      -	puts "\t\t.free  = 0,"
      -	puts "\t},"
      +	append struct_data "\t{\n"\
      +			"\t\t/* name  */ \"$shortfile\",\n"\
      +			"\t\t/* index */ $idx,\n"\
      +			"\t\t/* size  */ $size,\n"\
      +			"\t\t/* type  */ $type,\n"\
      +			"\t\t/* data  */ $data,\n"\
      +			"\t\t/* free  */ 0,\n"\
      +			"\t},\n"
       }
      +puts ""
      +puts "static struct cvfs_data ${code_tag}_data\[\] = {"
      +puts "\t{"
      +puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"
      +puts "\t\t/* name  */ NULL,"
      +puts "\t\t/* index */ 0,"
      +puts "\t\t/* type  */ 0,"
      +puts "\t\t/* size  */ 0,"
      +puts "\t\t/* data  */ NULL,"
      +puts "\t\t/* free  */ 0,"
      +puts "\t},"
      +puts -nonewline $struct_data
       puts "};"
       puts ""
      
      </verbatim>
      
    2. login: "anonymous"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"