Index: script_trigger.cpp =================================================================== RCS file: /cvstools-root/cvsNT/cvsnt-2.5.03.2382/triggers/script_trigger.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- script_trigger.cpp 14 Mar 2008 12:43:28 -0000 1.1.1.1 +++ script_trigger.cpp 21 Apr 2008 14:53:51 -0000 1.3 @@ -111,6 +111,19 @@ else cvs::swprintf(strText,128,L"Script error: %08x",excep.scode); CServerIo::error("%S\n",strText.c_str()); +LONG lColumn = 0; +ULONG uLine = 0; +DWORD dwDummyContext = 0; + +pase->GetSourcePosition(&dwDummyContext, &uLine, &lColumn); +CServerIo::error("Line %u, Column %d.\n", uLine, lColumn); + +BSTR bstrLine=0; +pase->GetSourceLineText(&bstrLine); +if (NULL != bstrLine) + CServerIo::error("%S\n", bstrLine); + return S_OK; } STDMETHOD(OnEnterScript)() { return S_OK; } @@ -161,8 +174,40 @@ return -1; } - cvs::sprintf(str,80,"%s/CVSROOT/script",physical_repository); - if(CFileAccess::exists((str+".vbs").c_str())) + // In order to maintain a large installation with dozens or hundreds of repositories, we need the + // ability to store a single script and have all repositories access, like pretty much all the other + // scripts in loginfo for example. So look for "script.name" file and use it to extract the script + // name, which can be a central location. + cvs::sprintf(str,80,"%s/CVSROOT/script",physical_repository); + if(CFileAccess::exists((str+".name").c_str())) + { + CFileAccess ac; + if(!ac.open((str+".name").c_str(),"r")) + { + CServerIo::error("Couldn't open script name file: %s\n",strerror(errno)); + return -1; + } + + size_t length = (size_t)ac.length(); + char *buf = new char[length]; + + length = ac.read(buf,length); + ac.close(); + // First line is file name; clip it there. + char *c = strchr (buf, '\n'); + if (NULL != c) + *c = '\0'; + + c = strchr (buf, '\r'); + if (NULL != c) + *c = '\0'; + + str = buf; + delete[] buf; + CServerIo::trace (2, "Found script name: %s\n",str.c_str()); + } + + if(CFileAccess::exists((str+".vbs").c_str())) { szLang=L"VBScript"; str+=".vbs"; } else if(CFileAccess::exists((str+".js").c_str())) { szLang=L"JScript"; str+=".js"; } @@ -178,6 +223,8 @@ return 0; } + CServerIo::trace (2, "Opening script file: %s\n",str.c_str()); + // On Win32 there are really only two options.. UTF8 or ANSI if(!strcmp(character_set,"UTF-8")) server_codepage=CP_UTF8; @@ -534,9 +581,14 @@ return -1; _bstr_t str(ret); - *template_ptr = (const char *)malloc(wcslen(str)*3); - template_ptr[WideCharToMultiByte(server_codepage,0,str,wcslen(str),(char*)*template_ptr,wcslen(str)*3,NULL,NULL)]='\0'; - return 0; + + char * const p = (char * const) malloc(wcslen(str)*3); + p[WideCharToMultiByte(server_codepage,0,str,wcslen(str),p,wcslen(str)*3,NULL,NULL)]='\0'; + *template_ptr = p; + + return 0; } int parse_keyword(const struct trigger_interface_t *cb, const char *keyword,const char *directory,const char *file,const char *branch,const char *author,const char *printable_date,const char *rcs_date,const char *locker,const char *state,const char *version,const char *name,const char *bugid, const char *commitid, const property_info *props, size_t numprops, const char **value) @@ -604,8 +656,11 @@ return 0; _bstr_t str(ret); - *value = (const char *)malloc(wcslen(str)*3); - value[WideCharToMultiByte(server_codepage,0,str,wcslen(str),(char*)*value,wcslen(str)*3,NULL,NULL)]='\0'; + char * const p = ( char * const)malloc(wcslen(str)*3); + p[WideCharToMultiByte(server_codepage,0,str,wcslen(str),p,wcslen(str)*3,NULL,NULL)]='\0'; + *value = p; return 0; } @@ -635,7 +690,8 @@ if(!g_pEngine) return 0; - variant_t args[9]; + variant_t args[11]; args[0]=_ubstr_t(file).Detach(); args[1]=_ubstr_t(directory).Detach(); Index: server.h =================================================================== RCS file: /cvstools-root/cvsNT/cvsnt-2.5.03.2382/triggers/server.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- server.h 14 Mar 2008 12:43:29 -0000 1.1.1.1 +++ server.h 9 Apr 2008 21:05:25 -0000 1.2 @@ -47,12 +47,12 @@ COM_INTERFACE_ENTRY(IChangeInfoStruct) END_COM_MAP() public: - virtual BSTR STDMETHODCALLTYPE get_filename() { return filename; } - virtual BSTR STDMETHODCALLTYPE get_rev_new() { return rev_new; } - virtual BSTR STDMETHODCALLTYPE get_rev_old() { return rev_old; } - virtual BSTR STDMETHODCALLTYPE get_type() { return type; } - virtual BSTR STDMETHODCALLTYPE get_tag() { return tag; } - virtual BSTR STDMETHODCALLTYPE get_bugid() { return bugid; } + virtual BSTR STDMETHODCALLTYPE get_filename() { return SysAllocString(filename); } + virtual BSTR STDMETHODCALLTYPE get_rev_new() { return SysAllocString(rev_new); } + virtual BSTR STDMETHODCALLTYPE get_rev_old() { return SysAllocString(rev_old); } + virtual BSTR STDMETHODCALLTYPE get_type() { return SysAllocString(type); } + virtual BSTR STDMETHODCALLTYPE get_tag() { return SysAllocString(tag); } + virtual BSTR STDMETHODCALLTYPE get_bugid() { return SysAllocString(bugid); } BSTR filename; BSTR rev_new; @@ -73,8 +73,8 @@ END_COM_MAP() public: - virtual BSTR STDMETHODCALLTYPE get_name() { return name; } - virtual BSTR STDMETHODCALLTYPE get_value() { return value; } + virtual BSTR STDMETHODCALLTYPE get_name() { return name.copy(); } + virtual BSTR STDMETHODCALLTYPE get_value() { return value.copy(); } _bstr_t name; _bstr_t value; @@ -125,7 +125,14 @@ virtual ~CChangeInfoCollection() { } STDMETHOD(get__NewEnum)(IUnknown** ppUnk) { return CreateSTLEnumerator(ppUnk, this, m_vec); } - STDMETHOD(get_Item)(long Index, IDispatch **ppVal) { if(Index<0 || Index>(long)m_vec.size()) return E_INVALIDARG; *ppVal=m_vec[Index].pdispVal; return S_OK; } + STDMETHOD(get_Item)(long Index, IDispatch **ppVal) + { + if(Index<0 || Index>(long)m_vec.size()) + return E_INVALIDARG; + *ppVal=m_vec[Index].pdispVal; + (*ppVal)->AddRef (); + return S_OK; + } STDMETHOD(get_Count)(long *pVal) { *pVal=m_vec.size(); return S_OK; } }; @@ -146,7 +153,7 @@ virtual ~CItemListCollection() { } STDMETHOD(get__NewEnum)(IUnknown** ppUnk) { return CreateSTLEnumerator(ppUnk, this, m_vec); } - STDMETHOD(get_Item)(long Index, IDispatch **ppVal) { if(Index<0 || Index>(long)m_vec.size()) return E_INVALIDARG; *ppVal=m_vec[Index].pdispVal; return S_OK; } + STDMETHOD(get_Item)(long Index, IDispatch **ppVal) { if(Index<0 || Index>(long)m_vec.size()) return E_INVALIDARG; *ppVal=m_vec[Index].pdispVal; (*ppVal)->AddRef (); return S_OK; } STDMETHOD(get_Count)(long *pVal) { *pVal=m_vec.size(); return S_OK; } };