/****************************************************************** * byte compile sources * ******************************************************************/ BOOL CompileSources( VOID ) { char szBuf[1024]; char *token; char seps[] = " \t"; char szTargetBuf[BUFLEN]; FILE *fp; int ret; /* make temp.el */ memcpy(szTargetBuf,szObjs,BUFLEN); fp = fopen(szTempFile,"w+"); if ( fp == NULL ) return ( FALSE ); fprintf(fp,"(setq load-path (cons \".\" load-path))\n(defun mew-compile () (mapcar (function (lambda (x) (byte-compile-file x))) (list "); token = strtok( szTargetBuf, seps ); while ( token ){ fprintf(fp,"\""); ReplaceString( token, ".elc", ".el"); fprintf(fp,token); fprintf(fp,"\" "); token = strtok( NULL, seps ); } fprintf(fp,")))\n"); fclose(fp); /* compile sources */ OutputDebugLog("Compiling sources..."); sprintf(szBuf, "%s -batch -q -no-site-file -l ./%s -f mew-compile", szEmacs,szTempFile); OutputDebugLog(szBuf); ret = system(szBuf); if (ret != 0){ sprintf(szBuf, "system() failed.(%d)\n", ret); OutputDebugLog(szBuf); } return ( TRUE ); }
// // Constructor // CCgShader::CCgShader( CGenum SourceType, const string& SourceStr, CGprofile Profile, CGGLenum ProfileClass, const string& Entry, const string& Arguments ): m_Program( NULL ) { if (SourceType != CG_SOURCE && SourceType != CG_OBJECT) throw Sys::CDeveloperException( "GL::CCgShader", "::CCgShader() : Invalid <SourceType> parameter." ); if (SourceStr.length() == 0) throw Sys::CDeveloperException( "GL::CCgShader", "::CCgShader() : Invalid <SourceStr> parameter." ); CCgContext::AddRef(); if (Profile == CG_PROFILE_UNKNOWN) Profile = cgGLGetLatestProfile( ProfileClass ); else { CheckDomain( Profile, ProfileClass ); if (cgGLIsProfileSupported( Profile ) == CG_FALSE) { const char *ProfileName = GetProfileName( Profile ); if (!ProfileName) throw Sys::CException( 0, "GL::CCgShader", "::CCgShader() : Unknown shader profile." ); else { throw Sys::CException( 0, "GL::CCgShader", "::CCgShader() : Profile %s unsupported.\n" "A profile may not be supported if required OpenGL extension is not available.", ProfileName ); } } } try { const char *TypeName = NULL; switch (ProfileClass) { case CG_GL_VERTEX: TypeName = "vertex"; break; case CG_GL_GEOMETRY: TypeName = "geometry"; break; case CG_GL_FRAGMENT: TypeName = "fragment"; break; } const char *Args[ 2 ] = { Arguments.c_str(), NULL }; m_Program = cgCreateProgram( CCgContext::GetContext(), SourceType, SourceStr.c_str(), Profile, (Entry.length() == 0) ? NULL : Entry.c_str(), (Arguments.length() == 0) ? NULL : Args ); if (!m_Program) { m_LastListing = CCgContext::GetLastListing(); #ifdef _DEBUG OutputDebugLog(); #endif throw CCgException( "GL::CCgShader", cgGetError(), "::CCgShader() : Failed to create Cg %s shader.\nSee program log for more details.", TypeName ); } cgCompileProgram( m_Program ); CGerror Error = cgGetError(); if (Error != CG_NO_ERROR) { m_LastListing = CCgContext::GetLastListing(); #ifdef _DEBUG OutputDebugLog(); #endif throw CCgException( "GL::CCgShader", Error, "::CCgShader() : Failed to compile Cg %s shader.\nSee program log for more details.", TypeName ); } } catch (const Sys::CException& Ex) { if (cgIsProgram( m_Program )) cgDestroyProgram( m_Program ); CCgContext::Release(); throw Ex; } }
BOOL InstallMew( VOID ) { /* szSrcs/szObjs are destroyed */ char *token; char seps[] = " \t"; char szBuf[256],szBuf2[256],szSrcFile[MAX_PATH]; BOOL fError = FALSE; char szPBuf[256], szPBuf2[32]; DWORD dwError; /* Make directories(if not exist) */ if ( ! CheckDirectory( szElispDir ) ){ sprintf(szPBuf,"[%s] is not exist. creating...",szElispDir); if ( ! CreateDirectory( szElispDir, NULL ) ){ dwError = GetLastError(); sprintf(szPBuf2, "fail.(0x%08x)", dwError); strcat(szPBuf, szPBuf2); fError = TRUE; } else { strcat(szPBuf,"ok."); } OutputLog(szPBuf); if (fError) OutputErrorMessageLog(dwError); } if ( ! CheckDirectory( szBinDir ) ){ sprintf(szPBuf,"[%s] is not exist. creating...",szBinDir); if ( ! CreateDirectory( szBinDir, NULL ) ){ dwError = GetLastError(); sprintf(szPBuf2, "fail.(0x%08x)", dwError); strcat(szPBuf, szPBuf2); fError = TRUE; } else { strcat(szPBuf,"ok."); } OutputLog(szPBuf); if (fError) OutputErrorMessageLog(dwError); } if ( fError ) return ( FALSE ); /* Sources */ token = strtok( szSrcs, seps ); while ( token ){ sprintf(szBuf,"%s\\%s",szElispDir,token); sprintf(szPBuf,"Copying [%s] to [%s] ...",token,szBuf); if ( ! CopyFile(token,szBuf,FALSE) ){ dwError = GetLastError(); sprintf(szPBuf2, "fail.(0x%08x)", dwError); strcat(szPBuf, szPBuf2); OutputLog(szPBuf); OutputErrorMessageLog(dwError); return ( FALSE ); } else { strcat(szPBuf,"ok."); OutputDebugLog(szPBuf); } token = strtok( NULL, seps ); } /* Objs */ token = strtok( szObjs, seps ); while ( token ){ sprintf(szBuf,"%s\\%s",szElispDir,token); sprintf(szPBuf,"Copying [%s] to [%s] ...",token,szBuf); if ( ! CopyFile(token,szBuf,FALSE) ){ dwError = GetLastError(); sprintf(szPBuf2, "fail.(0x%08x)", dwError); strcat(szPBuf, szPBuf2); OutputLog(szPBuf); OutputErrorMessageLog(dwError); return ( FALSE ); } else { strcat(szPBuf,"ok."); OutputDebugLog(szPBuf); } token = strtok( NULL, seps ); } /* Contribs */ if ( fFull && strcmp( szContribs, "Default" ) ){ token = strtok( szContribs, seps ); while ( token ){ sprintf(szBuf,"%s\\%s",szElispDir,token); sprintf(szBuf2,"contrib\\%s",token); sprintf(szPBuf,"Copying [%s] to [%s] ...",szBuf2,szBuf); if ( ! CopyFile(szBuf2,szBuf,FALSE) ){ dwError = GetLastError(); sprintf(szPBuf2, "fail.(0x%08x)", dwError); strcat(szPBuf, szPBuf2); OutputLog(szPBuf); OutputErrorMessageLog(dwError); return ( FALSE ); } else { strcat(szPBuf,"ok."); OutputDebugLog(szPBuf); } if ( langId == LANGID_JAPANESE ){ sprintf(szPBuf,">>非公式パッケージ [%s] がインストールされました",szBuf2); } else { sprintf(szPBuf,">>UNOFFICIAL package [%s] is installed.",szBuf2); } OutputLog(szPBuf); token = strtok( NULL, seps ); } } /* Bins */ token = strtok( szBins, seps ); while ( token ){ sprintf(szBuf,"%s\\%s",szBinDir,token); sprintf(szSrcFile,"bin\\%s",token); sprintf(szPBuf,"Copying [%s] to [%s] ...",szSrcFile,szBuf); if ( ! CopyFile(szSrcFile,szBuf,FALSE) ){ dwError = GetLastError(); sprintf(szPBuf2, "fail.(0x%08x)", dwError); strcat(szPBuf, szPBuf2); OutputLog(szPBuf); OutputErrorMessageLog(dwError); return ( FALSE ); } else { strcat(szPBuf,"ok."); OutputDebugLog(szPBuf); } token = strtok( NULL, seps ); } return ( TRUE ); }
/****************************************************************** * instaill info files * ******************************************************************/ BOOL InstallInfo( VOID ) { char seps[] = " \t"; char *token; BOOL fError; char szBuf[MAX_PATH],szBuf2[MAX_PATH]; FILE *fp; char szPBuf[256]; if ( szInfoPath[0] == 0 ){ OutputLog("info directory is not exist!"); return ( FALSE ); } if ( ! CheckDirectory( szInfoPath ) ){ sprintf(szPBuf,"[%s] is not exist!",szInfoPath); OutputLog(szPBuf); return ( FALSE ); } fError = FALSE; token = strtok( szInfos, seps ); while ( token ){ sprintf(szBuf,"%s\\%s",szInfoPath,token); sprintf(szBuf2,"info\\%s",token); sprintf(szPBuf,"Copying [%s] to [%s] ...",szBuf2,szBuf); if ( ! CopyFile(szBuf2,szBuf,FALSE) ){ strcat(szPBuf,"fail."); OutputLog(szPBuf); return ( FALSE ); } else { strcat(szPBuf,"ok."); OutputDebugLog(szPBuf); } token = strtok( NULL, seps ); } /* add Mew entry to "dir" */ sprintf(szBuf,"%s\\dir",szInfoPath); fp = fopen(szBuf,"r"); if ( fp == NULL ){ sprintf(szPBuf,"cannot open(r) [%s].",szBuf); OutputLog(szPBuf); return ( FALSE ); } fError = FALSE; while ( fgets(szBuf2,sizeof(szBuf2),fp) != NULL ){ if ( memcmp(szBuf2,"* Mew:",6) == 0 ){ fError = TRUE; break; } } if ( ! fError ){ SetEOLCode( szBuf ); fp = fopen(szBuf,"a+b"); if ( fp == NULL ){ sprintf(szPBuf,"cannot open(a+b) [%s].",szBuf); OutputLog(szPBuf); return ( FALSE ); } fprintf(fp,"* Mew: (mew.info). Messaging in the Emacs World (in English)%s", szCrCode ); fprintf(fp,"* Mewj: (mew.ja.info). Messaging in the Emacs World (in Japanese)%s", szCrCode ); fclose(fp); } return ( TRUE ); }
/****************************************************************** * read Ini file * ******************************************************************/ BOOL ReadIniFile() { BOOL fError=FALSE; char szBuf[256]; char szPBuf[4096]; sprintf(szPBuf,"INI file = [%s]",szIniFile); OutputDebugLog(szPBuf); if ( ! ReadEmacsEnvironments(szIniFile) ) return ( FALSE ); PrintEmacsEnvironments(); GetPrivateProfileString("Make","Full","no", szBuf,sizeof(szBuf), szIniFile); if ( ! strcmp(szBuf,"yes") ) fFull = TRUE; GetPrivateProfileString("Make","BINDIR","Default", szBinDir,sizeof(szBinDir), szIniFile); if ( ! strcmp(szBinDir,"Default") ) strcpy(szBinDir,szEmacsPath); sprintf(szPBuf,"BINDIR=[%s]",szBinDir); OutputDebugLog(szPBuf); GetPrivateProfileString("Make","ELISPDIR","Default", szElispDir,sizeof(szElispDir), szIniFile); if ( ! strcmp(szElispDir,"Default") ) strcpy(szElispDir,szEmacsLoadPath); sprintf(szPBuf,"ELISPDIR=[%s]",szElispDir); OutputDebugLog(szPBuf); GetPrivateProfileString("Make","INFOPATH","Default", szBuf,sizeof(szBuf), szIniFile); if ( strcmp(szBuf,"Default") ) strcpy(szInfoPath,szBuf); sprintf(szPBuf,"INFOPATH=[%s]",szInfoPath); OutputDebugLog(szPBuf); GetPrivateProfileString("Make","OBJS","Default", szObjs,sizeof(szObjs), szIniFile); GetPrivateProfileString("Make","SRCS","Default", szSrcs,sizeof(szSrcs), szIniFile); GetPrivateProfileString("Make","BINS","Default", szBins,sizeof(szBins), szIniFile); GetPrivateProfileString("Make","TEMPFILE","Default", szTempFile,sizeof(szTempFile), szIniFile); GetPrivateProfileString("Make","INFOS","Default", szInfos,sizeof(szInfos), szIniFile); GetPrivateProfileString("Make","CONTRIBS","Default", szContribs,sizeof(szContribs), szIniFile); GetLinesFromMakefile(); if ( ! strcmp(szObjs,"Default") ){ sprintf(szPBuf,"Error: OBJS is not found in [%s]",MEWINST_DEFAULT); OutputLog(szPBuf); fError = TRUE; } if ( ! strcmp(szSrcs,"Default") ){ sprintf(szPBuf,"Error: SRCS is not found in [%s]",MEWINST_DEFAULT); OutputLog(szPBuf); fError = TRUE; } if ( ! strcmp(szTempFile,"Default") ){ sprintf(szPBuf,"Error: TEMPFILE is not found in [%s]",MEWINST_DEFAULT); OutputLog(szPBuf); fError = TRUE; } if ( ! strcmp(szInfos,"Default") ){ sprintf(szPBuf,"Error: INFOS is not found in [%s]",MEWINST_DEFAULT); OutputLog(szPBuf); fError = TRUE; } if ( fError ) return ( FALSE ); sprintf(szPBuf,"Objs=[%s]",szObjs); OutputDebugLog(szPBuf); sprintf(szPBuf,"Srcs=[%s]",szSrcs); OutputDebugLog(szPBuf); sprintf(szPBuf,"Bins=[%s]",szBins); OutputDebugLog(szPBuf); sprintf(szPBuf,"TempFile=[%s]",szTempFile); OutputDebugLog(szPBuf); sprintf(szPBuf,"Infos=[%s]",szInfos); OutputDebugLog(szPBuf); sprintf(szPBuf,"Contribs=[%s]",szContribs); OutputDebugLog(szPBuf); return ( TRUE ); }