emacs_integration/vimclient.HIDE/src/vim_api.cpp
// Launch emacs.  Sources roverserv.el and starts server exec.
// Emacs and this server talk via a pipe.  This is required because emacs 
// Must spawn anything it wants to talk to.  We want the browser to pre-exist emacs
// so this inbetween in necessary.
Launch emacs.  Sources roverserv.el and starts server exec.
Emacs and this server talk via a pipe.  This is required because emacs
Must spawn anything it wants to talk to.  We want the browser to pre-exist emacs
so this inbetween in necessary.
Launch emacs . Sources roverserv . el and starts server exec . Emacs and this server talk via a pipe . This is required because emacs Must spawn anything it wants to talk to . We want the browser to pre - exist emacs so this inbetween in necessary .
int LaunchIntegrator(void) {
STARTUPINFO si;
PROCESS_INFORMATION pi;
char intname[1024];
#define EMACS_PATH_LEN 1024l
char some_dir[EMACS_PATH_LEN];
char vim_path[EMACS_PATH_LEN];
char some_path[EMACS_PATH_LEN];
DWORD some_dir_len = sizeof(some_dir);
DWORD paramType = REG_EXPAND_SZ;
	_DBG(fprintf(log_fd,"Starting Integrator... \n"));
	char* envPath = getenv("CODE_ROVER_HOME");
	if(envPath==NULL)
		envPath = getenv("PSETHOME");
	if(envPath)
		strcpy(some_dir,envPath);
	else
		strcpy(some_dir,"C:\\Program Files\\Code Rover");
	strcat(some_dir,"\\bin\\gvim.exe");
	GetShortPathName(some_dir,intname,sizeof(intname));
	if(envPath)
		strcpy(some_dir,envPath);
	else
		strcpy(some_dir,"C:\\Program Files\\Code Rover");
	GetShortPathName(some_dir,some_path,sizeof(some_path));
	if(some_path[strlen(some_path)-1]=='\\' || some_path[strlen(some_path)-1]=='/')
		some_path[strlen(some_path)-1]=0;
	for(int i=strlen(some_path); i; i--) if(some_path[i]=='\\') some_path[i]='/';
	_DBG(fprintf(log_fd,"CRHOME is %s\n",some_path));
	SetEnvironmentVariable("CRHOME", some_path) ;
	strcpy(vim_path, some_path);
	strcat(vim_path, "/lib/vim" );
	_DBG(fprintf(log_fd,"VIM is %s\n",vim_path));
	SetEnvironmentVariable("VIM", vim_path) ;
	_DBG(fprintf(log_fd,"DIS_VIM_DEVXPRESS is 1\n"));
	SetEnvironmentVariable("DIS_VIM_DEVXPRESS", "1") ;
	memset(&si,0,sizeof(STARTUPINFO));
	si.cb=sizeof(STARTUPINFO);
	if(::CreateProcess(NULL,intname,NULL,NULL,FALSE,DETACHED_PROCESS,NULL,NULL,&si,&pi)==FALSE) {
		_DBG(fprintf(log_fd,"Error while launching integrator server. Command is %s\n",intname));
		return 0;
	}
	_DBG(fprintf(log_fd,"Integrator started. Command is %s\n",intname));
	return 1;
}
int LaunchIntegrator ( void ) { STARTUPINFO si ; PROCESS_INFORMATION pi ; char intname [ 1024 ] ; #define EMACS_PATH_LEN  1024l char some_dir [ EMACS_PATH_LEN ] ; char vim_path [ EMACS_PATH_LEN ] ; char some_path [ EMACS_PATH_LEN ] ; DWORD some_dir_len = sizeof ( some_dir ) ; DWORD paramType = REG_EXPAND_SZ ; _DBG ( fprintf ( log_fd , " \n " ) ) ; char * envPath = getenv ( " " ) ; if ( envPath == NULL ) envPath = getenv ( " " ) ; if ( envPath ) strcpy ( some_dir , envPath ) ; else strcpy ( some_dir , " \\ \\ " ) ; strcat ( some_dir , " \\ \\ " ) ; GetShortPathName ( some_dir , intname , sizeof ( intname ) ) ; if ( envPath ) strcpy ( some_dir , envPath ) ; else strcpy ( some_dir , " \\ \\ " ) ; GetShortPathName ( some_dir , some_path , sizeof ( some_path ) ) ; if ( some_path [ strlen ( some_path ) - 1 ] == ' \\ ' || some_path [ strlen ( some_path ) - 1 ] == ' ' ) some_path [ strlen ( some_path ) - 1 ] = 0 ; for ( int i = strlen ( some_path ) ; i ; i -- ) if ( some_path [ i ] == ' \\ ' ) some_path [ i ] = ' ' ; _DBG ( fprintf ( log_fd , " \n " , some_path ) ) ; SetEnvironmentVariable ( " " , some_path ) ; strcpy ( vim_path , some_path ) ; strcat ( vim_path , " " ) ; _DBG ( fprintf ( log_fd , " \n " , vim_path ) ) ; SetEnvironmentVariable ( " " , vim_path ) ; _DBG ( fprintf ( log_fd , " \n " ) ) ; SetEnvironmentVariable ( " " , " " ) ; memset ( & si , 0 , sizeof ( STARTUPINFO ) ) ; si . cb = sizeof ( STARTUPINFO ) ; if ( :: CreateProcess ( NULL , intname , NULL , NULL , FALSE , DETACHED_PROCESS , NULL , NULL , & si , & pi ) == FALSE ) { _DBG ( fprintf ( log_fd , " \n " , intname ) ) ; return 0 ; } _DBG ( fprintf ( log_fd , " \n " , intname ) ) ; return 1 ; }
Launch emacs.
Launch emacs .
// getting Code Rover directory // adding emacs path to the launch parameter // we convert our path string to short file name because emacs doesn't understand spaces  // in file names