Check-in [717062426a]
Overview
Comment:Added an "--static-init" option to creation to make the Xvfs_fsName_Init function static, if needed to be included into a .c file
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 717062426a638dec8cecc855fc63f304f7589539718971bfaa76afa6fe30e5e2
User & Date: rkeene on 2020-04-13 15:47:03
Other Links: manifest | tags
Context
2020-04-13
15:50
Fixed typo in last commit check-in: d17d8bb449 user: rkeene tags: trunk
15:47
Added an "--static-init" option to creation to make the Xvfs_fsName_Init function static, if needed to be included into a .c file check-in: 717062426a user: rkeene tags: trunk
2020-04-03
19:03
Renamed options struct, to not be confused get getopt long options check-in: 160dcdcda4 user: rkeene tags: trunk
Changes

Modified lib/xvfs/xvfs.c.rvt from [e6f5c7aae7] to [2be0a65534].

234
235
236
237
238
239
240



241
242
243
244
245
246
247
	.protocolVersion = XVFS_PROTOCOL_VERSION,
	.name            = "<?= $::xvfs::fsName ?>",
	.getChildrenProc = xvfs_<?= $::xvfs::fsName ?>_getChildren,
	.getDataProc     = xvfs_<?= $::xvfs::fsName ?>_getData,
	.getStatProc     = xvfs_<?= $::xvfs::fsName ?>_getStat
};




int Xvfs_<?= $::xvfs::fsName ?>_Init(Tcl_Interp *interp) {
	int register_ret;

#ifdef USE_TCL_STUBS
	const char *tclInitStubs_ret;
	/* Initialize Stubs */
	tclInitStubs_ret = Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0);







>
>
>







234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
	.protocolVersion = XVFS_PROTOCOL_VERSION,
	.name            = "<?= $::xvfs::fsName ?>",
	.getChildrenProc = xvfs_<?= $::xvfs::fsName ?>_getChildren,
	.getDataProc     = xvfs_<?= $::xvfs::fsName ?>_getData,
	.getStatProc     = xvfs_<?= $::xvfs::fsName ?>_getStat
};

#ifdef XVFS_<?= $::xvfs::fsName ?>_INIT_STATIC
static
#endif
int Xvfs_<?= $::xvfs::fsName ?>_Init(Tcl_Interp *interp) {
	int register_ret;

#ifdef USE_TCL_STUBS
	const char *tclInitStubs_ret;
	/* Initialize Stubs */
	tclInitStubs_ret = Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0);
255
256
257
258
259
260
261

		return(register_ret);
	}
	
	return(TCL_OK);
}
#undef XVFS_NAME_LOOKUP_ERROR
#undef XVFS_FILE_BLOCKSIZE








>
258
259
260
261
262
263
264
265
		return(register_ret);
	}
	
	return(TCL_OK);
}
#undef XVFS_NAME_LOOKUP_ERROR
#undef XVFS_FILE_BLOCKSIZE
#undef XVFS_<?= $::xvfs::fsName ?>_INIT_STATIC

Modified lib/xvfs/xvfs.tcl from [40098de8e1] to [1e48610645].

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
proc ::xvfs::printHelp {channel {errors ""}} {
	if {[llength $errors] != 0} {
		foreach error $errors {
			puts $channel "error: $error"
		}
		puts $channel ""
	}
	puts $channel "Usage: dir2c \[--help\] \[--set-mode {flexible|standalone|client}\] \[--output <filename>\] --directory <rootDirectory> --name <fsName>"
	flush $channel
}

proc ::xvfs::sanitizeCString {string} {
	set output [join [lmap char [split $string ""] {
		if {![regexp {[A-Za-z0-9./-]} $char]} {
			binary scan $char H* char







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
proc ::xvfs::printHelp {channel {errors ""}} {
	if {[llength $errors] != 0} {
		foreach error $errors {
			puts $channel "error: $error"
		}
		puts $channel ""
	}
	puts $channel "Usage: xvfs-create \[--help\] \[--static-init {true|false}\] \[--set-mode {flexible|standalone|client}\] \[--output <filename>\] --directory <rootDirectory> --name <fsName>"
	flush $channel
}

proc ::xvfs::sanitizeCString {string} {
	set output [join [lmap char [split $string ""] {
		if {![regexp {[A-Za-z0-9./-]} $char]} {
			binary scan $char H* char
233
234
235
236
237
238
239

240
241
242
243
244
245
246
247
248
249
250
251



252
253
254
255
256
257
258
proc ::xvfs::main {argv} {
	# Main entry point
	## 1. Parse arguments
	if {[llength $argv] % 2 != 0} {
		lappend argv ""
	}


	foreach {arg val} $argv {
		switch -exact -- $arg {
			"--help" {
				printHelp stdout
				exit 0
			}
			"--directory" {
				set rootDirectory $val
			}
			"--name" {
				set fsName $val
			}



			"--output" - "--header" - "--set-mode" {
				# Ignored, handled as part of some other process
			}
			default {
				printHelp stderr [list "Invalid option: $arg $val"]
				exit 1
			}







>












>
>
>







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
proc ::xvfs::main {argv} {
	# Main entry point
	## 1. Parse arguments
	if {[llength $argv] % 2 != 0} {
		lappend argv ""
	}

	set staticInit false
	foreach {arg val} $argv {
		switch -exact -- $arg {
			"--help" {
				printHelp stdout
				exit 0
			}
			"--directory" {
				set rootDirectory $val
			}
			"--name" {
				set fsName $val
			}
			"--static-init" {
				set staticInit $val
			}
			"--output" - "--header" - "--set-mode" {
				# Ignored, handled as part of some other process
			}
			default {
				printHelp stderr [list "Invalid option: $arg $val"]
				exit 1
			}
269
270
271
272
273
274
275





276
277
278
279
280
281
282
283
	}

	if {[llength $errors] != 0} {
		printHelp stderr $errors
		exit 1
	}






	## 3. Start processing directory and producing initial output
	set ::xvfs::outputFiles [processDirectory $fsName $rootDirectory]

	set ::xvfs::fsName $fsName
	set ::xvfs::rootDirectory $rootDirectory

	# Return the output
	return [join $::xvfs::_emitLine "\n"]







>
>
>
>
>
|







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
	}

	if {[llength $errors] != 0} {
		printHelp stderr $errors
		exit 1
	}

	## 3. Initialization
	if {$staticInit} {
		::xvfs::_emitLine "#define XVFS_${fsName}_INIT_STATIC 1"
	}

	## 4. Start processing directory and producing initial output
	set ::xvfs::outputFiles [processDirectory $fsName $rootDirectory]

	set ::xvfs::fsName $fsName
	set ::xvfs::rootDirectory $rootDirectory

	# Return the output
	return [join $::xvfs::_emitLine "\n"]

Modified xvfs-core.c from [92265e645e] to [045108db01].

1


2
3
4
5
6
7
8
#include <xvfs-core.h>


#include <string.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <tcl.h>

#ifdef XVFS_DEBUG

>
>







1
2
3
4
5
6
7
8
9
10
#include <xvfs-core.h>
#ifndef XVFS_CORE_H_1B4B28D60EBAA11D5FF85642FA7CA22C29E8E817
#define XVFS_CORE_C_1B4B28D60EBAA11D5FF85642FA7CA22C29E8E817 1
#include <string.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <tcl.h>

#ifdef XVFS_DEBUG
1256
1257
1258
1259
1260
1261
1262

#undef XVFS_DEBUG_PRINTF
#undef XVFS_DEBUG_PUTS
#undef XVFS_DEBUG_ENTER
#undef XVFS_DEBUG_LEAVE
#undef XVFS_INTERNAL_SERVER_MAGIC
#undef XVFS_INTERNAL_SERVER_MAGIC_LEN
#undef XVFS_ROOT_MOUNTPOINT








>
1258
1259
1260
1261
1262
1263
1264
1265
#undef XVFS_DEBUG_PRINTF
#undef XVFS_DEBUG_PUTS
#undef XVFS_DEBUG_ENTER
#undef XVFS_DEBUG_LEAVE
#undef XVFS_INTERNAL_SERVER_MAGIC
#undef XVFS_INTERNAL_SERVER_MAGIC_LEN
#undef XVFS_ROOT_MOUNTPOINT
#endif /* XVFS_CORE_C_1B4B28D60EBAA11D5FF85642FA7CA22C29E8E817 */

Modified xvfs-create from [6fae2b3ce8] to [a457e756d3].

1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
#! /usr/bin/env tclsh

set sourceDirectory [file dirname [file normalize [info script]]]

lappend auto_path [file join $sourceDirectory lib]

set template [file join $sourceDirectory lib xvfs xvfs.c.rvt]

package require minirivet

set mode "run"

if {[lindex $argv 0] == "--dump-tcl"} {
	set mode "dump-tcl"
}

foreach {arg val} $argv {
	switch -exact -- $arg {
		"--output" {











>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /usr/bin/env tclsh

set sourceDirectory [file dirname [file normalize [info script]]]

lappend auto_path [file join $sourceDirectory lib]

set template [file join $sourceDirectory lib xvfs xvfs.c.rvt]

package require minirivet

set mode "run"
set staticInit false
if {[lindex $argv 0] == "--dump-tcl"} {
	set mode "dump-tcl"
}

foreach {arg val} $argv {
	switch -exact -- $arg {
		"--output" {