/////////////////////////////////////////////////////////////////////////////// // C callable function. Note, name is not mangled for easy access from Visual // Basic, et al. extern "C" void EXP_LVL1 CS_csTest (char *srcSystem,char *trgSystem,double srcXYZ [3]) { CcsTest csTest; CS_recvr (); csTest.SetSourceSystem (srcSystem); csTest.SetTargetSystem (trgSystem); csTest.SetSourceCoordinate (srcXYZ); csTest.DoModal (); // Must capture the final settings, for persistence, before the // class goes out of scope. CS_stncp (srcSystem,csTest.GetSourceSystem (),cs_KEYNM_DEF); CS_stncp (trgSystem,csTest.GetTargetSystem (),cs_KEYNM_DEF); csTest.GetSourceCoordinate (srcXYZ); // The Test object uses the high level caches. The following // releases the memory consumed by such, and eliminates what // appears to be a memory leak. CS_recvr (); return; }
/////////////////////////////////////////////////////////////////////////////// // 'C' callable DataDir function. Name is not mangled for ease of access from // Visual Basic, et. al. extern "C" int EXP_LVL1 CS_csDataDir (int flags) { int rtnVal; CS_recvr (); CcsDataDir csDataDir; if (flags & 1) csDataDir.EnableINIBox (); if (flags & 2) csDataDir.EnableRegBox (); csDataDir.DoModal (); rtnVal = 0; if (csDataDir.GetIniSave ()) rtnVal |= 1; if (csDataDir.GetRegSave ()) rtnVal |= 2; return rtnVal; }
void CS_reset () { CS_recvr (); csReleaseNameMapper (); }
void CcsDataDir::OnOK () { char *cp; CWnd *wp; char ctemp [MAXPATH]; if (!UpdateData (TRUE)) return; // Check the provided data. cp = CS_stncp (ctemp,m_DataDirectory,sizeof(ctemp)); if (strlen (ctemp) < 3 || ctemp [1] != ':') { AfxMessageBox ("Full path to a directory must be provided."); wp = GetDlgItem (IDC_MPDR_DIRECTORY); if (wp != NULL) GotoDlgCtrl (wp); return; } if (*(cp - 1) == '\\') { cp -= 1; *cp = '\0'; } if (CS_access (ctemp,0) != 0) { AfxMessageBox ("Directory provided does not exist."); wp = GetDlgItem (IDC_MPDR_DIRECTORY); if (wp != NULL) GotoDlgCtrl (wp); return; } *cp++ = '\\'; strcpy (cp,(LPCTSTR)m_CSName); if (CS_access (ctemp,4) != 0) { AfxMessageBox ("Coordinate System dictionary file with name provided\ndoes not exist in directory provided."); wp = GetDlgItem (IDC_MPDR_CSNAME); if (wp != NULL) GotoDlgCtrl (wp); return; } strcpy (cp,(LPCTSTR)m_DtName); if (CS_access (ctemp,4) != 0) { AfxMessageBox ("Datum dictionary file with name provided\ndoes not exist in directory provided."); wp = GetDlgItem (IDC_MPDR_DTNAME); if (wp != NULL) GotoDlgCtrl (wp); return; } strcpy (cp,(LPCTSTR)m_ElName); if (CS_access (ctemp,4) != 0) { AfxMessageBox ("Ellipsoid dictionary file with name provided\ndoes not exist in directory provided."); wp = GetDlgItem (IDC_MPDR_ELNAME); if (wp != NULL) GotoDlgCtrl (wp); return; } // If we are still here, it all checks out. We save the stuff in the proper // locations. CS_csfnm (m_CSName); CS_dtfnm (m_DtName); CS_elfnm (m_ElName); CS_altdr (m_DataDirectory); #ifdef __SKIP__ if (m_SaveInRegistry) { long reg_st; HKEY strtKey = HKEY_LOCAL_MACHINE; HKEY softKey = 0; HKEY mntrKey = 0; HKEY trlnKey = 0; HKEY vrsnKey = 0; reg_st = RegOpenKeyEx (strtKey,cs_RKeySoftware,0,KEY_SET_VALUE,&softKey); if (reg_st == ERROR_SUCCESS) { reg_st = RegOpenKeyEx (softKey,cs_RKeyCompany,0,KEY_SET_VALUE,&mntrKey); RegCloseKey (softKey); } if (reg_st == ERROR_SUCCESS) { reg_st = RegOpenKeyEx (mntrKey,cs_RKeyProduct,0,KEY_SET_VALUE,&trlnKey); RegCloseKey (mntrKey); } if (reg_st == ERROR_SUCCESS) { reg_st = RegOpenKeyEx (trlnKey,cs_RKeyVersion,0,KEY_SET_VALUE,&vrsnKey); RegCloseKey (trlnKey); } if (reg_st == ERROR_SUCCESS) { char uctemp [MAXPATH]; strcpy (uctemp,(LPCTSTR)m_DataDirectory); reg_st = RegSetValueEx (vrsnKey,"DataDir",0,REG_SZ,(unsigned char*)uctemp,strlen (uctemp)); if (reg_st == ERROR_SUCCESS) { strcpy (uctemp,(LPCTSTR)m_CSName); reg_st = RegSetValueEx (vrsnKey,"CSName",0,REG_SZ,(unsigned char*)uctemp,strlen (uctemp)); } if (reg_st == ERROR_SUCCESS) { strcpy (uctemp,(LPCTSTR)m_DtName); reg_st = RegSetValueEx (vrsnKey,"DtName",0,REG_SZ,(unsigned char *)uctemp,strlen (uctemp)); } if (reg_st == ERROR_SUCCESS) { strcpy (uctemp,(LPCTSTR)m_ElName); reg_st = RegSetValueEx (vrsnKey,"ElName",0,REG_SZ,(unsigned char *)uctemp,strlen (uctemp)); } RegCloseKey (vrsnKey); } } if (m_SaveInINI) { BOOL ok; char ctemp [MAXPATH]; CS_stncp (ctemp,theApp.m_FullPath,sizeof (ctemp)); cp = strrchr (ctemp,'.'); if (cp == NULL) return; strcpy (cp,".INI"); if (CS_access (ctemp,0) != 0) { FILE* fstr = fopen (ctemp,"w"); fclose (fstr); } if (CS_access (ctemp,2) != 0) { AfxMessageBox ("Write permission to .INI file has been denied."); return; } ok = WritePrivateProfileString ("Directories","DataDir",(LPCTSTR)m_DataDirectory,ctemp); if (ok) ok = WritePrivateProfileString ("Directories","CSName",(LPCTSTR)m_CSName,ctemp); if (ok) ok = WritePrivateProfileString ("Directories","DtName",(LPCTSTR)m_DtName,ctemp); if (ok) ok = WritePrivateProfileString ("Directories","ElName",(LPCTSTR)m_ElName,ctemp); } #endif CS_recvr (); CDialog::OnOK (); return; }