[cvsnt] Using VBScript from the loginfo file

Prochazka, Jan Jan.Prochazka at brooks.com
Tue Jan 10 17:22:53 GMT 2006


Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.


Sometime ago I did the same in MS VC++. See the code below.
The entry in CVSROOT\verifymsg looks like:

DEFAULT D:\absolute_path\verifymsg.exe 

It works fine in our 2.0.58d server (the latest CVSNT may require a
different setup (?))

Cheers,
JP


// verifymsg.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <stdlib.h>
#include <direct.h>
#include <errno.h>
#include <tchar.h>
#include <atlstr.h>


int _tmain(int argc, _TCHAR* argv[])
{
	char* buffer;
	CString msg, msgOrig="";
	FILE* msgFile; 
    long lSize;

	//something is wrong (file name should be here)
	if (argc <= 1){
		printf("\nSomething ir really wrong, file name is
missing.\n\n");
		return 2;
	}
	if (NULL==(msgFile = fopen(argv[1],"rt"))){
		printf("\nSomething ir really wrong, can not open
message file.\n\n");
		return 2;
	}

	//jump to C

    // obtain file size.
	fseek(msgFile , 0 , SEEK_END);
	lSize = ftell(msgFile);
	rewind(msgFile);

	// allocate memory to contain the whole file.
	buffer = (char*) malloc(lSize);
	if (buffer == NULL){
		printf("\nSomething ir really wrong, can not allocate
message buffer.\n\n");
		fclose(msgFile);
		return 3;
	}
	// copy the file into the buffer.
	fread(buffer,1,lSize,msgFile);

	/*** the whole file is loaded in the buffer. ***/

    fclose(msgFile);
	//add end of string
	buffer[lSize-1] = '\0';
	
	//jump back to C++
	 
	msgOrig = msg = buffer;
	free(buffer);
    
	msg.Trim();
	
	//at least 1 space in the message
	if (msg.Find(" ") == -1){
		printf("\nPlease provide a more substantial commit
message then \n\n");
		printf("'%s'\n\n",msgOrig);
		return 1;
	}

	//at least 6 chaqracters   
	msg.Remove(' ');
	msg.Remove('\t');
	msg.Remove('\n');
	if (msg.GetLength() < 6){
		printf("\nPlease provide a more substantial commit
message then \n\n");
		printf("'%s'\n\n",msgOrig);
		return 1;
	}
	
	//OK
	return 0;
}


> -----Original Message-----
> From: cvsnt-bounces at cvsnt.org 
> [mailto:cvsnt-bounces at cvsnt.org] On Behalf Of Onur Civi
> Sent: Tuesday, January 10, 2006 11:54
> To: cvsnt at cvsnt.org cvsnt downloads at march-hare.com @CVSNT on Twitter CVSNT on Facebook
> Subject: [cvsnt] Using VBScript from the loginfo file
> 
> Hi,
> 
>  
> 
> I am trying to force all CVS users enter a log message during commits.
> We are using CVSNT on Windows platform, so what I thought I 
> could do was to write a simple vbscript that examines the 
> message entry and if it is "no message", quits with a 
> non-zero exit code. The following line is what I have in my 
> loginfo file.
> 
>  
> 
> ALL cscript.exe C:\\CvsMailer\\AdminScripts\\VerifyLog.vbs
> 
>  
> 
> And the following is the script text. Needless to say, it 
> doesn't do what I want it to do. Any help would be appreciated.
> 
>  
> 
> Thanks
> 
>  
> 
> **************************************************************
> **********
> **********************************************************************
> 
> 'Define the variables & constants
> 
> Const ForAppending = 8
> 
> 'Define the file system object that we will use for logging 
> the log text passed to the script
> 
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> 
> Set objTextFile = objFSO.OpenTextFile _
> 
>     ("C:\WUTemp\Log.txt", ForAppending, True)    
> 
> 'Parse the argument and assign the log text argument to a string 
> 
> Set objArgs = WScript.Arguments
> 
> For I = 0 to objArgs.Count - 1
> 
>    objTextFile.WriteLine(objArgs(I) & vbTab)
> 
>    strLogTxt = objArgs(I)
> 
> Next
> 
> objTextFile.Close
> 
> 'If the text is empty, exit with non-zero exit code, if it is 
> not, exit with zero exit code
> 
> If StrLogTxt = "no message" Then
> 
>             Wscript.Quit (1)
> 
> Else
> 
>             Wscript.Quit (0)
> 
> End If
> 
> _______________________________________________
> cvsnt mailing list
> cvsnt at cvsnt.org cvsnt downloads at march-hare.com @CVSNT on Twitter CVSNT on Facebook
> http://www.cvsnt.org/cgi-bin/mailman/listinfo/cvsnt https://www.march-hare.com/cvspro/en.asp#downcvs
> 
> _____________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> 

_____________________________________________________________________
This email message, including any attachments, may contain confidential and proprietary information for the sole use of the intended recipient.  If you are not the intended recipient, you are hereby notified that any use, copying or dissemination of this message is strictly prohibited.  If you received this message in error, please notify Brooks Automation, Inc. immediately by reply email or by calling Brooks US Headquarters at +1 978-262-2400. Then delete this message from your system, without making any copy or distribution.  Thank you.



More information about the cvsnt mailing list
Download the latest CVSNT, TortosieCVS, WinCVS etc. for Windows 8 etc.
@CVSNT on Twitter   CVSNT on Facebook