@@ -1,9 +1,9 @@ #! /usr/bin/env tclsh if {[llength $argv] != 2} { - puts stderr "Usage: kitdll " + puts stderr "Usage: dir2c.tcl " exit 1 } set hashkey [lindex $argv 0] @@ -74,11 +74,11 @@ return $ret } # This function must be kept in-sync with the generated C function below -proc kitdll_hash {path} { +proc cvfs_hash {path} { set h 0 set g 0 for {set idx 0} {$idx < [string length $path]} {incr idx} { binary scan [string index $path $idx] H* char @@ -101,12 +101,12 @@ # Insert dummy entry cooresponding to C dummy entry set files [linsert $files 0 "__DUMMY__"] # Produce C89 compatible header -set cpp_tag "KITDLL_[string toupper $hashkey]" -set code_tag "kitdll_[string tolower $hashkey]" +set cpp_tag "CVFS_[string toupper $hashkey]" +set code_tag "cvfs_[string tolower $hashkey]" set hashkey [string tolower $hashkey] puts "#ifndef $cpp_tag" puts "# define $cpp_tag 1" puts { @@ -123,27 +123,27 @@ # endif # ifdef HAVE_STRING_H # include # endif -# ifndef LOADED_KITDLL_COMMON -# define LOADED_KITDLL_COMMON 1 +# ifndef LOADED_CVFS_COMMON +# define LOADED_CVFS_COMMON 1 typedef enum { - KITDLL_FILETYPE_FILE, - KITDLL_FILETYPE_DIR -} kitdll_filetype_t; + CVFS_FILETYPE_FILE, + CVFS_FILETYPE_DIR +} cvfs_filetype_t; -struct kitdll_data { +struct cvfs_data { const char * name; unsigned long index; unsigned long size; - kitdll_filetype_t type; + cvfs_filetype_t type; const unsigned char * data; }; -static unsigned long kitdll_hash(const unsigned char *path) { +static unsigned long cvfs_hash(const unsigned char *path) { unsigned long i, h = 0, g = 0; for (i = 0; path[i]; i++) { h = (h << 4) + path[i]; g = h & 0xf0000000; @@ -154,14 +154,14 @@ } return(h); } -# endif /* !LOADED_KITDLL_COMMON */} +# endif /* !LOADED_CVFS_COMMON */} puts "" -puts "static struct kitdll_data ${code_tag}_data\[\] = {" +puts "static struct cvfs_data ${code_tag}_data\[\] = {" puts "\t{" puts "\t\t.name = NULL," puts "\t\t.index = 0," puts "\t\t.type = 0," puts "\t\t.size = 0," @@ -174,11 +174,11 @@ unset -nocomplain finfo type file stat $file finfo switch -- $finfo(type) { "file" { - set type "KITDLL_FILETYPE_FILE" + set type "CVFS_FILETYPE_FILE" set size $finfo(size) set fd [open $file] fconfigure $fd -translation binary set data [read $fd] @@ -185,11 +185,11 @@ close $fd set data "(unsigned char *) [stringify $data]" } "directory" { - set type "KITDLL_FILETYPE_DIR" + set type "CVFS_FILETYPE_DIR" set data "NULL" set size 0 } } @@ -203,16 +203,16 @@ } puts "};" puts "" puts "static unsigned long ${code_tag}_lookup_index(const char *path) {" -puts "\tswitch (kitdll_hash((unsigned char *) path)) {" +puts "\tswitch (cvfs_hash((unsigned char *) path)) {" for {set idx 1} {$idx < [llength $files]} {incr idx} { set file [lindex $files $idx] set shortfile [shorten_file $startdir $file] - set hash [kitdll_hash $shortfile] + set hash [cvfs_hash $shortfile] lappend indexes_per_hash($hash) [list $shortfile $idx] } foreach {hash idx_list} [array get indexes_per_hash] { @@ -236,11 +236,11 @@ puts "\t}" puts "\treturn(0);" puts "}" puts "" -puts "static struct kitdll_data *${code_tag}_getData(const char *path, unsigned long index) {" +puts "static struct cvfs_data *${code_tag}_getData(const char *path, unsigned long index) {" puts "\tif (path != NULL) {" puts "\t\tindex = ${code_tag}_lookup_index(path);" puts "\t}" puts "" puts "\tif (index == 0) {" @@ -264,11 +264,11 @@ puts "\tindex = ${code_tag}_lookup_index(path);" puts "\tif (index == 0) {" puts "\t\treturn(0);" puts "\t}" puts "" -puts "\tif (${code_tag}_data\[index\].type != KITDLL_FILETYPE_DIR) {" +puts "\tif (${code_tag}_data\[index\].type != CVFS_FILETYPE_DIR) {" puts "\t\treturn(0);" puts "\t}" puts "" puts "\tif (strcmp(path, ${code_tag}_data\[index\].name) != 0) {" puts "\t\treturn(0);" @@ -349,13 +349,13 @@ puts "" puts "\treturn(num_children);" puts "}" puts "" -puts "# ifdef KITDLL_MAKE_LOADABLE" +puts "# ifdef CVFS_MAKE_LOADABLE" -set fd [open "vfs_kitdll_data.c"] +set fd [open "cvfs_data.c"] puts [read $fd] close $fd puts "static cmd_getData_t *getCmdData(const char *hashkey) {" @@ -365,31 +365,31 @@ puts "static cmd_getChildren_t *getCmdChildren(const char *hashkey) {" puts "\treturn(${code_tag}_getChildren);" puts "}" puts "" -puts "int Vfs_kitdll_data_${hashkey}_Init(Tcl_Interp *interp) {" +puts "int Cvfs_data_${hashkey}_Init(Tcl_Interp *interp) {" puts "\tTcl_Command tclCreatComm_ret;" puts "\tint tclPkgProv_ret;" puts "" -puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getMetadata\", getMetadata, NULL, NULL);" +puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::cvfs::data::${hashkey}::getMetadata\", getMetadata, NULL, NULL);" +puts "\tif (!tclCreatComm_ret) {" +puts "\t\treturn(TCL_ERROR);" +puts "\t}" +puts "" +puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::cvfs::data::${hashkey}::getData\", getData, NULL, NULL);" puts "\tif (!tclCreatComm_ret) {" puts "\t\treturn(TCL_ERROR);" puts "\t}" puts "" -puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getData\", getData, NULL, NULL);" +puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::cvfs::data::${hashkey}::getChildren\", getChildren, NULL, NULL);" puts "\tif (!tclCreatComm_ret) {" puts "\t\treturn(TCL_ERROR);" puts "\t}" puts "" -puts "\ttclCreatComm_ret = Tcl_CreateObjCommand(interp, \"::vfs::kitdll::data::${hashkey}::getChildren\", getChildren, NULL, NULL);" -puts "\tif (!tclCreatComm_ret) {" -puts "\t\treturn(TCL_ERROR);" -puts "\t}" -puts "" -puts "\ttclPkgProv_ret = Tcl_PkgProvide(interp, \"vfs::kitdll::data::${hashkey}\", \"1.0\");" +puts "\ttclPkgProv_ret = Tcl_PkgProvide(interp, \"vfs::cvfs::data::${hashkey}\", \"1.0\");" puts "" puts "\treturn(tclPkgProv_ret);" puts "\t}" -puts "# endif /* KITDLL_MAKE_LOADABLE */" +puts "# endif /* CVFS_MAKE_LOADABLE */" puts "#endif /* !$cpp_tag */"