svn commit: samba r16037 - in branches/SOC/bnh: . include

brad at samba.org brad at samba.org
Sun Jun 4 20:01:49 GMT 2006


Author: brad
Date: 2006-06-04 20:01:49 +0000 (Sun, 04 Jun 2006)
New Revision: 16037

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16037

Log:
Created an include directory for library files, and moved common.vbs there.
It would be nice to be able to include more than one library file, and 
since we can only include one in the <script src> tag, add an include function to common.vbs.


Added:
   branches/SOC/bnh/include/
   branches/SOC/bnh/include/common.vbs
Removed:
   branches/SOC/bnh/common.vbs


Changeset:
Deleted: branches/SOC/bnh/common.vbs
===================================================================
--- branches/SOC/bnh/common.vbs	2006-06-04 05:28:13 UTC (rev 16036)
+++ branches/SOC/bnh/common.vbs	2006-06-04 20:01:49 UTC (rev 16037)
@@ -1,66 +0,0 @@
-' A VBScript providing some common library functions for handling
-' passed-in parameters and reporting run-time errors.
-' Copyright Brad Henry <brad at samba.org> 2006
-' Released under the GNU GPL v2 or later.
-
-' Don't halt on runtime errors, we will catch them.
-on error resume next
-
-const RTN_OK = 0
-const RTN_ERR = 1
-
-' We don't have WMI or ADSI extended errors in VBScript.
-' To figure them out, take the last 4 digits of the hex error code,
-' and convert them to an integer. Then search for that integer
-' in the PlatformSDK headers.
-' hextodec.vbs performs the needed conversion.
-const ADSI_ERROR_DS_NO_SUCH_OBJECT	= "80072030" ' PlatformSDK WinError.h
-const LM_NERR_PasswordTooShort		= "800708C5" ' PlatformSDK LMErr.h
-
-set stdout = wscript.stdout
-set stdin = wscript.stdin
-
-class setup_object
-	dim error_code, missing_options
-
-	public function check_options(provided, required)
-		dim opt, index
-		index = 0
-
-		' Make sure all required options are available in
-		' the provided list. The redim call resizes the array.
-		for each opt in required
-			if not provided.exists(opt) then
-				error_code = RTN_ERR
-				redim preserve missing_options(index)
-				missing_options(index) = opt
-				index = index + 1
-			end if
-		next
-	end function
-
-	public function list_missing_options
-		dim opt
-		stdout.writeline "The following required options are missing:"
-		for each opt in missing_options
-			stdout.writeline "/" & opt & ":"
-		next
-	end function
-
-	' A subroutine named class_initialize is used to set default values
-	' on object instantiation.
-	private sub class_initialize
-		error_code = RTN_OK
-		missing_options = array(25)
-	end sub
-end class
-
-public function report_error
-	if err.description = "" then
-		error_text = "No description provided."
-	else
-		error_text = err.description
-	end if
-	stdout.writeline "Error " & err.number & "(0x" & Hex(err.number) _
-	& "): " & error_text
-end function

Copied: branches/SOC/bnh/include/common.vbs (from rev 16030, branches/SOC/bnh/common.vbs)
===================================================================
--- branches/SOC/bnh/common.vbs	2006-06-03 18:58:35 UTC (rev 16030)
+++ branches/SOC/bnh/include/common.vbs	2006-06-04 20:01:49 UTC (rev 16037)
@@ -0,0 +1,83 @@
+' A VBScript providing some common library functions for handling
+' passed-in parameters and reporting run-time errors.
+' Copyright Brad Henry <brad at samba.org> 2006
+' Released under the GNU GPL v2 or later.
+
+' Don't halt on runtime errors, we will catch them.
+on error resume next
+
+const RTN_OK = 0
+const RTN_ERR = 1
+
+' We don't have WMI or ADSI extended errors in VBScript.
+' To figure them out, take the last 4 digits of the hex error code,
+' and convert them to an integer. Then search for that integer
+' in the PlatformSDK headers.
+' hextodec.vbs performs the needed conversion.
+const ADSI_ERROR_DS_NO_SUCH_OBJECT	= "80072030" ' PlatformSDK WinError.h
+const LM_NERR_PasswordTooShort		= "800708C5" ' PlatformSDK LMErr.h
+
+set stdout = wscript.stdout
+set stdin = wscript.stdin
+
+class setup_object
+	dim error_code, missing_options
+
+	public function check_options(provided, required)
+		dim opt, index
+		index = 0
+
+		' Make sure all required options are available in
+		' the provided list. The redim call resizes the array.
+		for each opt in required
+			if not provided.exists(opt) then
+				error_code = RTN_ERR
+				redim preserve missing_options(index)
+				missing_options(index) = opt
+				index = index + 1
+			end if
+		next
+	end function
+
+	public function list_missing_options
+		dim opt
+		stdout.writeline "The following required options are missing:"
+		for each opt in missing_options
+			stdout.writeline "/" & opt & ":"
+		next
+	end function
+
+	' A subroutine named class_initialize is used to set default values
+	' on object instantiation.
+	private sub class_initialize
+		error_code = RTN_OK
+		missing_options = array(25)
+	end sub
+end class
+
+public function report_error
+	if err.description = "" then
+		error_text = "No description provided."
+	else
+		error_text = err.description
+	end if
+	stdout.writeline "Error " & err.number & "(0x" & Hex(err.number) _
+	& "): " & error_text
+end function
+
+' We will need this function if we want to include more than one library file
+' at a time. The <script src=""> tag should be used to include common.vbs, and
+' other files can be included by adding 
+' 	execute include("include\fs_common.vbs")
+' within the body of the script.
+
+public function include(library_filename)
+        dim fileSystemObject, file
+        set fileSystemObject = createObject("scripting.fileSystemObject")
+        set file = fileSystemObject.openTextFile(library_filename, READ_ONLY)
+
+        include = file.readall
+        set file = nothing
+        set fileSystemObject = nothing
+end function
+



More information about the samba-cvs mailing list