Ejemplo n.º 1
0
/**
 *  \brief
 */
bool Settings::Save() const
{
    CPath cfgFile;
    INpp::Get().GetPluginsConfDir(cfgFile);
    cfgFile += cPluginCfgFileName;

    FILE* fp;
    _tfopen_s(&fp, cfgFile.C_str(), _T("wt"));
    if (fp == NULL)
        return false;

    bool success = false;
    if (_ftprintf_s(fp, _T("%s\n"), cInfo) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cUseDefDbKey, (_useDefDb ? _T("yes") : _T("no"))) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cDefDbPathKey, _defDbPath.C_str()) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cREOptionKey, (_re ? _T("yes") : _T("no"))) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n\n"), cICOptionKey, (_ic ? _T("yes") : _T("no"))) > 0)
    if (_genericDbCfg.Write(fp))
        success = true;

    fclose(fp);

    if (success)
        _dirty = false;

    return success;
}
Ejemplo n.º 2
0
void clsTranslator::pasteCam(LPCAMERA3D obj, FILE* file) {
    pasteName(obj, file);
    pastePosition(obj, file);
    pasteRotation(obj, file);
    errno_t bErrorFlag;
    bErrorFlag = _ftprintf_s(file, _T("hFOV:           %.3f\n"), obj->getHFov() );
    bErrorFlag = _ftprintf_s(file, _T("vFOV:           %.3f\n"), obj->getVFov() );
    bErrorFlag = _ftprintf_s(file, _T("Near clip:      %.3f\n"), obj->getNearCP() );
    bErrorFlag = _ftprintf_s(file, _T("Far clip:       %.3f\n"), obj->getFarCP() );
}
Ejemplo n.º 3
0
void clsTranslator::pasteCone(LPCONE3D obj, FILE* file) {
    errno_t bErrorFlag = _ftprintf_s(file, _T("------------------------------------- CONE --------------------------------------\n") );

    pasteName(obj, file);
    pastePosition(obj, file);
    pasteRotation(obj, file);

    bErrorFlag = _ftprintf_s(file, _T("Height:         %.3f\n"), obj->getHeight() );
    bErrorFlag = _ftprintf_s(file, _T("Base radius:    %.3f\n"), obj->getBRadius() );
    bErrorFlag = _ftprintf_s(file, _T("Top radius:     %.3f\n"), obj->getTRadius() );
    bErrorFlag = _ftprintf_s(file, _T("Precision:      %.3f\n"), obj->getPrecision() );
    pasteColor(obj->getColor(), file);
}
Ejemplo n.º 4
0
void clsTranslator::pasteLight(LPDIFLIGHT3D obj, FILE* file) {
    pasteName(obj, file);
    pasteRotation(obj, file);
    errno_t bErrorFlag;
    bErrorFlag = _ftprintf_s(file, _T("Power:          %.3f\n"), obj->getPower() );
    pasteColor(obj->getColor(), file);
}
Ejemplo n.º 5
0
	// Populates Sample Input for validating this program
	//
	void PopulateSampleInput ()
	{
		FILE* fout = 0;
		errno_t err = _tfopen_s( &fout,  _TEXT("C:\\SampleInput.txt"), _TEXT("w+") );
		if ( !fout || err != 0 )
		{
			cout << "C:\\SampleInput.txt cannot be created!" << endl;
			return;
		}
		_ftprintf_s( fout,	_T( "new Sunglasses01 0.50 3.79\n") \
							_T(	"new Towel01 1.47 6.98\n") \
							_T(	"new Sunglasses02 0.63 4.29\n") \
							_T(	"new Sunblock 1.00 4.98\n") \
							_T(	"buy Sunblock 100\n") \
							_T(	"sell Sunblock 2\n") \
							_T(	"buy Towel01 500\n") \
							_T(	"buy Sunglasses01 100\n") \
							_T(	"buy Sunglasses02 100\n") \
							_T(	"sell Towel01 1\n") \
							_T(	"sell Towel01 1\n") \
							_T(	"sell Sunblock 2\n") \
							_T(	"report\n") \
							_T(	"delete Sunglasses01\n") \
							_T(	"sell Sunblock 5\n") \
							_T(	"new Sunglasses03 .51 1.98\n") \
							_T(	"buy Sunglasses03 250\n") \
							_T(	"sell Towel01 5\n") \
							_T(	"sell Sunglasses03 4\n") \
							_T(	"sell Sunglasses02 10\n") \
							_T(	"report\n") \
							_T(	"*\n" ));
		fclose(fout);

	}
Ejemplo n.º 6
0
	void CLogDeviceFile::Write( LPCTSTR strLog )
	{
		if (strLog && m_fp)
		{
			_ftprintf_s(m_fp,_T("%s"),strLog);
		}
	}
Ejemplo n.º 7
0
/**
 * Write data to file.
 * <br>write strings
 *
 * @param	szData write strings data
 * @param	... vargs
 *
 * @return	AT_OK : write success
 */
int ATFile::write(const TString &szData, ...)
{
	if (ATStringUtl::isEmpty(szData)) {
		return AT_ERR_ARGUMENTS;
	}

	if (!isOpen()) {
		return AT_ERR_IOEXCEPTION;
	}

	/* variable args */
	va_list vaList;
	TCHAR szBuff[_MAX_PATH] = {0};

	const TCHAR *pSrc = szData.c_str();
	va_start(vaList, pSrc);
#ifdef PLATFORM_WINDOWS
	_vstprintf_s(szBuff, _MAX_PATH, pSrc, vaList);
#else
	vsprintf(szBuff, pSrc, vaList);
#endif
	va_end(vaList);

	/* Lock file */
	if (ml_oLock.lock() != AT_OK) {
		return AT_ERR_IOEXCEPTION;
	}

	_ftprintf_s(ml_pFile, _T("%s"), szBuff);

	ml_oLock.unlock();
	return AT_OK;
}
Ejemplo n.º 8
0
void CConsole::SetFileLevel(int nFileLevel, const TCHAR* lpszFilePath /*= NULL*/)
{
	if(nFileLevel > 0)
	{
		if(lpszFilePath == NULL)
		{
			TCHAR buf[512];         
			GetModuleFileName(NULL, buf, 512);
#ifdef _UNICODE
			std::wstring strFilePath = buf;
#else
			std::string strFilePath = buf;
#endif
			int pos = (int)strFilePath.rfind('\\');
			strFilePath = strFilePath.substr(pos+1);
			strFilePath = strFilePath.substr(0, strFilePath.size()-4);

			SYSTEMTIME tm;
			GetLocalTime(&tm);
			_stprintf_s(buf, _countof(buf), _T("[%4d-%02d-%02d %02d.%02d] %s.log"), tm.wYear, tm.wMonth, tm.wDay, tm.wHour, tm.wMinute, strFilePath.c_str());
			lpszFilePath = buf;
		}

		errno_t err = _tfopen_s(&m_file, lpszFilePath, _T("w+"));
		if (err != 0)
		{
			_ftprintf_s(stderr, _T("%s: Error opening '%s': %s\n"), __FUNCTION__, lpszFilePath, strerror(errno));
		}
	}

	m_nLogFileLevel = nFileLevel;
}
Ejemplo n.º 9
0
bool MoBody::write(FILE* moFile) const
{
	std::wstring nameStr = name();
	std::wstring defStr = definitionName();

	// --- begin definition of body

	_ftprintf_s(moFile, L"  model %s\n", defStr.c_str());

	_ftprintf_s(moFile, L"    Modelica.Mechanics.MultiBody.Parts.Body body1 (m = %.8g, I_11 = %.8g, I_22 = %.8g, I_33 = %.8g, I_21 = %.8g, I_31 = %.8g, I_32 = %.8g, r_CM = {%.8g, %.8g, %.8g}) "
						L"annotation(Placement(visible = true, transformation(origin = {0, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));\n",
				m_mass,
				m_inertia.moments()[0],  m_inertia.moments()[1],  m_inertia.moments()[2],
				m_inertia.products()[0], m_inertia.products()[1], m_inertia.products()[2],
				m_cg.x(), m_cg.y(), m_cg.z());

	// frame interface
	_ftprintf_s(moFile, L"    Modelica.Mechanics.MultiBody.Interfaces.Frame_a frame annotation(Placement(visible = true, transformation(origin = {0, -100}, extent = {{-10, -10}, {10, 10}}, rotation = 90), iconTransformation(origin = {0, -100}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));\n");

	_ftprintf_s(moFile, L"  equation\n");

	// connect frame interface to body frame
	_ftprintf_s(moFile, L"    connect(body1.frame_a, frame) annotation(Line(points = {{0, 0}, {0, -100}}, color = {95, 95, 95}));\n");

	// --- diagram and icon annotations for definition

	_ftprintf_s(moFile, L"    annotation("
						L"Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}))"
						L", Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})");
//						L", Text(origin = {-12, 121}, extent = {{-128, 19}, {152, -21}}, textString = \"%%name%%\")");

	// icon thumbnail if present
	if (m_thumbnail.empty())
		_ftprintf_s(moFile, L"));\n"); // close Icon and annotation
	else
		_ftprintf_s(moFile, L", graphics = {Bitmap(origin = {0, 0}, extent = {{-100, -100}, {100, 100}}, imageSource = \"%S\"), Text(extent = {{-150, 145}, {150, 105}}, textString = \"%%name\", lineColor = {0, 0, 255})}));\n",
			m_thumbnail.c_str());

	_ftprintf_s(moFile, L"  end %s;\n\n", defStr.c_str());

	// --- end definition

	// occurrence
	_ftprintf_s(moFile, L"  %s %s annotation(%s);\n\n", defStr.c_str(), nameStr.c_str(), placement().c_str());

	return true;
}
Ejemplo n.º 10
0
void clsTranslator::pasteRotation(LPOBJECT3D obj, FILE* file) {
    VECTOR3D fWd = obj->getForwardLookDirection();
    VECTOR3D uWd = obj->getUpLookDirection();
    VECTOR3D rWd = obj->getRightLookDirection();

    errno_t bErrorFlag = _ftprintf_s(file, _T("View vectors:\nForward:       %.3f %.3f %.3f\nUpward:        %.3f %.3f %.3f\nRightward:     %.3f %.3f %.3f\n"),
                                     fWd.x, fWd.y, fWd.z, uWd.x, uWd.y, uWd.z, rWd.x, rWd.y, rWd.z );
}
Ejemplo n.º 11
0
// ============================================================================
// Implementation of clsTranslator class:
// write to file
void clsTranslator::pasteName(LPOBJECT3D obj, FILE* file) {
    TCHAR *dataBuffer = new TCHAR[MAX_OBJECT_NAME_LEN];
    obj->getName(dataBuffer, 256);

    errno_t bErrorFlag = _ftprintf_s(file, _T("Name:          %s\n"), dataBuffer );

    dataBuffer[MAX_OBJECT_NAME_LEN - 1] = '\0';
    delete [] dataBuffer;
}
Ejemplo n.º 12
0
void MeshDump::DumpAdjacencyBuffer(ID3DXBaseMesh* mesh) {
    _fputts(_T("Adjacency Buffer:\n-----------------\n"), m_DumpStream);
    // three enttries per face
    std::vector<DWORD> adjBuf(mesh->GetNumFaces() * 3);
    mesh->GenerateAdjacency(0.0f, &adjBuf[0]);
    for (DWORD i = 0; i < mesh->GetNumFaces(); i++)
        _ftprintf_s(m_DumpStream, _T("Triangle's adjacent to triangle %d: %d, %d, %d\n"), i, adjBuf[i * 3], adjBuf[i * 3 + 1], adjBuf[i * 3 + 2]);
    _fputts(_T("\n"), m_DumpStream);
}
Ejemplo n.º 13
0
// 基类 ID3DXBaseMesh 没有 LockAttributeBuffer/UnlockAttributeBuffer 方法
void MeshDump::DumpAttributeBuffer(ID3DXMesh* mesh) {
    _fputts(_T("Attribute Buffer:\n-----------------\n"), m_DumpStream);
    DWORD* attrBuf = NULL;
    mesh->LockAttributeBuffer(0, &attrBuf);
    // an attribute for each face
    for (DWORD i = 0; i < mesh->GetNumFaces(); i++)
        _ftprintf_s(m_DumpStream, _T("Triangle lives in subset %d: %d\n"), i, attrBuf[i]);
    mesh->UnlockAttributeBuffer();
    _fputts(_T("\n"), m_DumpStream);
}
Ejemplo n.º 14
0
void MeshDump::DumpIndex(ID3DXBaseMesh* mesh) {
    _fputts(_T("Index:\n--------\n"), m_DumpStream);
    WORD* idx = NULL;
    mesh->LockIndexBuffer(0, (void**) &idx);
    if (idx == NULL)
        return;
    for (DWORD i = 0; i < mesh->GetNumFaces(); i++)
        _ftprintf_s(m_DumpStream, _T("Triangle %d: %d, %d, %d\n"), i, idx[i * 3], idx[i * 3 + 1], idx[i * 3 + 2]);
    mesh->UnlockIndexBuffer();
    _fputts(_T("\n"), m_DumpStream);
}
Ejemplo n.º 15
0
//------------------------------------------------------------------------------
// Main application entry point. Simply return the first Application UART
// COM port that was found to STDOUT.
//------------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
    TCHAR szDeviceName[MAX_PATH];
    DWORD dwReturnValue;

    dwReturnValue = EnumComPorts(0, szDeviceName, _countof(szDeviceName));

    if (dwReturnValue == ERROR_SUCCESS) {
        _ftprintf_s(stdout, _T("%s\r\n"), szDeviceName);
        return 0;
    }

	return 1;
}
Ejemplo n.º 16
0
void MeshDump::DumpVertex(ID3DXBaseMesh* mesh) {
    _fputts(_T("Vertex:\n---------\n"), m_DumpStream);
    Vertex* v = NULL;
    DWORD FVF = mesh->GetFVF();
    mesh->LockVertexBuffer(0, (void**) &v);
    size_t sz = Vertex::Size(FVF);
    v->DumpFVF(m_DumpStream, FVF);
    for (DWORD i = 0; i < mesh->GetNumVertices(); i++) {
        _ftprintf_s(m_DumpStream, _T("Vertex %d:"), i);
        Vertex::Data(v, i, sz)->Dump(m_DumpStream, FVF);
    }

    mesh->UnlockVertexBuffer();
    _fputts(_T("\n"), m_DumpStream);
}
Ejemplo n.º 17
0
	BOOL CLogDeviceFile::Open(LPCTSTR param)
	{
		m_fp = NULL;
		CString logFile;
		if (param)
		{
			logFile = param;
			errno_t err = _tfopen_s(&m_fp,logFile,_T("at+"));
			if (m_fp)
			{
				CTime currTime = CTime::GetCurrentTime();
				_ftprintf_s(m_fp,_T("-----------------------------------\nLog Generated At %s\n"),currTime.Format(TIME_FORMAT_STRING));
			}
		}
		return m_fp!=NULL;
	}
Ejemplo n.º 18
0
void clsTranslator::pastePyramid(LPPYRAMID3D obj, FILE* file) {
    errno_t bErrorFlag = _ftprintf_s(file, _T("------------------------------------- PYRAMID --------------------------------------\n") );

    pasteName(obj, file);
    pastePosition(obj, file);
    pasteRotation(obj, file);

    bErrorFlag = _ftprintf_s(file, _T("Height:         %.3f\n"), obj->getHeight() );
    bErrorFlag = _ftprintf_s(file, _T("Base length:    %.3f\n"), obj->getBLength() );
    bErrorFlag = _ftprintf_s(file, _T("Base width:     %.3f\n"), obj->getBWidth() );
    bErrorFlag = _ftprintf_s(file, _T("Top length:     %.3f\n"), obj->getTLength() );
    bErrorFlag = _ftprintf_s(file, _T("Top width:      %.3f\n"), obj->getTWidth() );
    pasteColor(obj->getColor(), file);
}
Ejemplo n.º 19
0
void MeshDump::DumpAttributeTable(ID3DXBaseMesh* mesh) {
    _fputts(_T("Attribute Table:\n----------------\n"), m_DumpStream);
    // number of entries in the attribute table
    DWORD numEntries = 0;
    mesh->GetAttributeTable(0, &numEntries);
    if (numEntries == 0)
        return;
    std::vector<D3DXATTRIBUTERANGE> table(numEntries);
    mesh->GetAttributeTable(&table[0], &numEntries);
    for (DWORD i = 0; i < numEntries; i++)
        _ftprintf_s(m_DumpStream,
                    _T("Entry %d\n-----------\n")
                    _T("Subset ID:    %d\n")
                    _T("Face Start:   %d\n")
                    _T("Face Count:   %d\n")
                    _T("Vertex Start: %d\n")
                    _T("Vertex Count: %d\n\n"),
                    i, table[i].AttribId, table[i].FaceStart, table[i].FaceCount, table[i].VertexStart, table[i].VertexCount);

    _fputts(_T("\n"), m_DumpStream);
}
Ejemplo n.º 20
0
static void usage(int argc)
{
    static const TCHAR *help[] = {
        _T("Usage:  Caption2Ass_PCR.exe [Options] source.ts [target filename]"),
        _T(""),
        _T("Options:"),
        _T("    -format <string>            Specify output format. {srt|ass|taw|dual}"),
        _T("                                    Default: ass"),
        _T("    -delay <integer>            Sepcify delay time. [mili-sec]"),
        _T("    -PMT_PID <hex>              Specify PID value."),
        _T("    -detect_length <integer>    Specify upper limit value of packet counting"),
        _T("                                 for detecting caption data. [10k]"),
        _T("                                    Default: 300"),
        _T("    -log                        Make log-file."),
        _T("    -keepinterval               Keep the interval of the output timestamp"),
        _T("                                 upon detection of packet loss."),
        _T("  [srt]"),
        _T("    -srtornament                Set ornament to srt-file."),
        _T("  [ass]"),
        _T("    -asstype <string>           Sepcify type name of ass setting."),
        _T("    -hlc <string>               Sepcify HLC control type. {kigou|box|draw}"),
        _T("                                    Default: kigou"),
        _T("    -norubi                     Does not output the Rubi to ass-file."),
        _T(""),
        _T("Example:"),
        _T("    Caption2Ass_PCR.exe -format dual \"source.ts\""),
        _T("    Caption2Ass_PCR.exe -format ass -asstype Default43 -hlc kigou \"source.ts\""),
        _T("    Caption2Ass_PCR.exe -delay 500 -PMT_PID 1f2 -detect_length 400 \"source.ts\""),
        NULL
    };

    if (argc < 2) {
        for (int i = 0; help[i]; i++)
            _ftprintf_s(stdout, _T("%s\n"), help[i]);
    }
    else {
        for (int i = 0; help[i]; i++)
            _tMyPrintf(_T("%s\r\n"), help[i]);
    }
}
Ejemplo n.º 21
0
/**
 *  \brief
 */
bool DbConfig::Write(FILE* fp) const
{
    bool success = false;

    CText libDbPaths;
    DbPathsToBuf(libDbPaths, _T(';'));

    CText pathFilters;
    FiltersToBuf(pathFilters, _T(';'));

    if (_ftprintf_s(fp, _T("%s\n"), cInfo) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cParserKey, Parser()) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cAutoUpdateKey, (_autoUpdate ? _T("yes") : _T("no"))) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cUseLibDbKey, (_useLibDb ? _T("yes") : _T("no"))) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cLibDbPathsKey, libDbPaths.C_str()) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cUsePathFilterKey, (_usePathFilter ? _T("yes") : _T("no"))) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cPathFiltersKey, pathFilters.C_str()) > 0)
        success = true;

    return success;
}
STDMETHODIMP CShooterContextMenuExt::InvokeCommand ( LPCMINVOKECOMMANDINFO pCmdInfo )
{
	// If lpVerb really points to a string, ignore this function call and bail out.
	if ( 0 != HIWORD( pCmdInfo->lpVerb ) )
		return E_INVALIDARG;

	// Get the command index - the only valid one is 0.
	switch ( LOWORD( pCmdInfo->lpVerb) )
	{
	case 0:
	case 1:
		{
			TCHAR szShooterDir[MAX_PATH];
			TCHAR szShooterDldrPath[MAX_PATH];

			//Build the ShooterDownloader's file path from this module's path.
			//Limitation: ShooterDownloader must locate in the same dir as this module.
			HINSTANCE hModule = _AtlBaseModule.GetModuleInstance();
			GetModuleFileName((HMODULE) hModule, szShooterDir, sizeof(szShooterDir));
			TCHAR* pLastSlash = _tcsrchr(szShooterDir, _T('\\'));
			*(pLastSlash + 1) = _T('\0');
			_tcscpy_s(szShooterDldrPath, szShooterDir);
			_tcscat_s(szShooterDldrPath, SHOOTER_DLDR_FILE_NAME);

			TCHAR szTempDir[MAX_PATH], szTempFilePath[MAX_PATH];
			// Get the temp path.
			DWORD dwRetVal = GetTempPath(MAX_PATH,     // length of the buffer
				szTempDir); // buffer for path 
			if (dwRetVal > MAX_PATH || (dwRetVal == 0))
			{
				return E_FAIL;
			}

			// Create a temporary file. 
			UINT uRetVal = GetTempFileName(szTempDir, // directory for tmp files
				TEXT("SDL"),  // temp file name prefix 
				0,            // create unique name 
				szTempFilePath);  // buffer for name 
			if (uRetVal == 0)
			{
				return E_FAIL;
			}

			//Write file list to a temp file.
			FILE* fp; 
			errno_t ret = _tfopen_s(&fp, szTempFilePath, _T("w, ccs=UTF-8"));
			if(ret != 0)
			{
				return E_FAIL;
			}
			
			StringList::const_iterator itor;
			for(itor = m_fileList.begin(); itor != m_fileList.end(); itor++)
			{
				_ftprintf_s(fp, _T("%s\n"), itor->c_str());
			}
			fclose(fp);

			//Call ShooterDownloader and pass it the file list.
			const static int PARAM_SIZE = 512;
			TCHAR param[PARAM_SIZE];
			if(LOWORD( pCmdInfo->lpVerb) == 0)
			{
				//download subtitle
				_stprintf_s(param, PARAM_SIZE, _T("-lst=\"%s\" /r"), szTempFilePath);
			}
			else
			{
				//convert subtitle
				_stprintf_s(param, PARAM_SIZE, _T("-lst=\"%s\" /r /c"), szTempFilePath);
			}

			ShellExecute(NULL, _T("Open"), szShooterDldrPath, param, NULL, SW_SHOWNORMAL);

			return S_OK;
		}
		break;

	default:
		return E_INVALIDARG;
		break;
	}
}
Ejemplo n.º 23
0
bool clsTranslator::saveSceneScript(LPSCENE3D Scene, TCHAR *fileName) {
    FILE* file;
    errno_t bErrorFlag = _tfopen_s(&file, fileName, _T("w"));
    if (bErrorFlag)
        return false;

    bErrorFlag = _ftprintf_s(file, _T("3DEditor scene file\n"), NULL );
    bErrorFlag = _ftprintf_s(file, _T("===================================== Cameras =======================================\n"), NULL );
    bErrorFlag = _ftprintf_s(file, _T("Total: "), NULL );
    UINT sceneObjCount = Scene->getObjectClassCount(CLS_CAMERA);
    bErrorFlag = _ftprintf_s(file, _T("%d\n\n"), sceneObjCount );

    for ( UINT i = 0; i < sceneObjCount; i++ ) {
        pasteCam((LPCAMERA3D)Scene->getObject(CLS_CAMERA, i), file);
        bErrorFlag = _ftprintf_s(file, _T("----------------------------------------------------------------------------\n"), NULL );
    }

    bErrorFlag = _ftprintf_s(file, _T("===================================== Lighters ======================================\n"), NULL );
    bErrorFlag = _ftprintf_s(file, _T("Total: "), NULL );
    sceneObjCount = Scene->getObjectClassCount(CLS_LIGHT);
    bErrorFlag = _ftprintf_s(file, _T("%d\n\n"), sceneObjCount );

    for ( UINT i = 0; i < sceneObjCount; i++ ) {
        pasteLight((LPDIFLIGHT3D)Scene->getObject(CLS_LIGHT, i), file);
        bErrorFlag = _ftprintf_s(file, _T("----------------------------------------------------------------------------\n"), NULL );
    }

    bErrorFlag = _ftprintf_s(file, _T("===================================== Meshes ========================================\n"), NULL );
    bErrorFlag = _ftprintf_s(file, _T("Total: "), NULL );
    sceneObjCount = Scene->getObjectClassCount(CLS_MESH);
    bErrorFlag = _ftprintf_s(file, _T("%d\n\n"), sceneObjCount );

    for ( UINT i = 0; i < sceneObjCount; i++ ) {
        LPMESH3D meshToSave = (LPMESH3D)Scene->getObject(CLS_MESH, i);
        switch ( meshToSave->MeshID() ) {
        case MSH_PYRAMID:
            pastePyramid((LPPYRAMID3D)meshToSave, file);
            break;
        case MSH_CONE:
            pasteCone((LPCONE3D)meshToSave, file);
            break;
        case MSH_EXCONE:
            pasteExCone((LPEXCONE3D)meshToSave, file);
            break;
        case MSH_HOLE:
            pasteHole((LPHOLE3D)meshToSave, file);
            break;
        case MSH_MIC:
            pasteMic((LPMICROPHONE3D)meshToSave, file);
            break;
        case MSH_TANK:
            pasteTank((LPJAGDPANTHER3D)meshToSave, file);
            break;

        }
    }
    bErrorFlag = _ftprintf_s(file, _T("----------------------------------------------------------------------------\n"), NULL );

    fclose(file);
    return ( bErrorFlag != 0 );
}
Ejemplo n.º 24
0
void clsTranslator::pasteColor(COLORREF in, FILE* file) {
    errno_t bErrorFlag = _ftprintf_s(file, _T("Color:         %d %d %d\n"), RED(in), GREEN(in), BLUE(in) );
}
Ejemplo n.º 25
0
void clsTranslator::pasteMic(LPMICROPHONE3D obj, FILE* file) {
    errno_t bErrorFlag = _ftprintf_s(file, _T("------------------------------------- MICROPHONE --------------------------------------\n") );

    pasteName(obj, file);
    pastePosition(obj, file);
    pasteRotation(obj, file);

    bErrorFlag = _ftprintf_s(file, _T("Total height:   %.3f\n"), obj->getTotalHeight() );
    bErrorFlag = _ftprintf_s(file, _T("Base radius:    %.3f\n"), obj->getBaseRadius() );
    bErrorFlag = _ftprintf_s(file, _T("Base height:    %.3f\n"), obj->getBaseHeight() );
    bErrorFlag = _ftprintf_s(file, _T("Button width:   %.3f\n"), obj->getButtonWidth() );
    bErrorFlag = _ftprintf_s(file, _T("Upright radius: %.3f\n"), obj->getUprightRadius() );
    bErrorFlag = _ftprintf_s(file, _T("Upright height: %.3f\n"), obj->getUprightHeight() );
    bErrorFlag = _ftprintf_s(file, _T("Upright gap:    %.3f\n"), obj->getUprightGap() );
    bErrorFlag = _ftprintf_s(file, _T("Handle indent:  %.3f\n"), obj->getHandleIndent() );
    bErrorFlag = _ftprintf_s(file, _T("Head radius:    %.3f\n"), obj->getHeadRadius() );
    bErrorFlag = _ftprintf_s(file, _T("Head deapth:    %.3f\n"), obj->getHeadDepth() );
    bErrorFlag = _ftprintf_s(file, _T("Core radius:    %.3f\n"), obj->getCoreRadius() );
    bErrorFlag = _ftprintf_s(file, _T("Precision:      %.3f\n"), obj->getPrecision() );
    pasteColor(obj->getColor(), file);
}
Ejemplo n.º 26
0
int _tmain( int argc, _TCHAR* argv[] )
{
	int retval = 0;
	e_opmode opmode = E_OPMODE_NONE;
	_TCHAR * pFilename = NULL;

	/*	sanity checks	*/
	if ( 1 >= argc || NULL == argv || NULL == argv[1] )
	{
		_ftprintf_s( stdout, _T( "%s" ), _T( "error:  parameter not found!\n" ) );
		retval = usage();
		exit( retval > 1 ? retval : 1 );
	}

	/*	argument check, collect operating parameters	*/
	if ( 0 == _tcsicmp( _T( "--help" ), argv[1] ) ||
			0 == _tcsicmp( _T( "-h" ), argv[1] ) )
	{
		retval = usage();
		exit( retval );
	}
	if ( 0 == _tcsicmp( _T( "-d" ), argv[1] ) ||
			0 == _tcsicmp( _T( "--decode" ), argv[1] ) )
	{
		opmode = E_OPMODE_DECODE;
	}
	else if ( 0 == _tcsicmp( _T( "-e" ), argv[1] ) ||
				0 == _tcsicmp( _T( "--encode" ), argv[1] ) )
	{
		opmode = E_OPMODE_ENCODE;
	}
	else if ( 0 == _tcsncmp( _T( "-" ), argv[1], 1 ) )
	{
		_ftprintf_s( stdout, _T( "%s" ), _T( "error:  parameter not recognized!\n" ) );
		retval = usage();
		exit( retval > 1 ? retval : 1 );
	}

	/*	some operating modes require a filename;	**
	**	for such modes, retrieve it					*/
	if ( E_OPMODE_NONE != opmode )
	{
		if ( 2 >= argc || NULL == argv[2] )
		{
			_ftprintf_s( stdout, _T( "%s" ), _T( "error:  filename parameter not found!\n" ) );
			retval = usage();
			exit( retval > 1 ? retval : 1 );
		}
		pFilename = argv[2];
	}

	/*	a program with more complex parameter sets would	**
	**	further validate its retrieved parameters here;		**
	**	this program is content with existing processing	*/

	/*	do useful work	*/
	switch ( opmode )
	{
		case E_OPMODE_DECODE:
			retval = decode( pFilename );
			break;
		case E_OPMODE_ENCODE:
			retval = encode( pFilename );
			break;
		default:
			/*	this is redundant only until	**
			**	a new operating mode is added	**
			**	to the parameter parsing.		*/
			_ftprintf_s( stdout, _T( "%s" ), _T( "error:  unrecognized operating mode!\n" ) );
			retval = usage();
			exit( retval > 1 ? retval : 1 );
			break;
	}

	/*	done	*/
	exit( retval );
	return retval;
}
Ejemplo n.º 27
0
void clsTranslator::pasteTank(LPJAGDPANTHER3D obj, FILE* file) {
    errno_t bErrorFlag = _ftprintf_s(file, _T("------------------------------------- JAGDPANTHER --------------------------------------\n") );

    pasteName(obj, file);
    pastePosition(obj, file);
    pasteRotation(obj, file);

    bErrorFlag = _ftprintf_s(file, _T("Body length:    %.3f\n"), obj->getBodyLength() );
    bErrorFlag = _ftprintf_s(file, _T("Body width:     %.3f\n"), obj->getBodyWidth() );
    bErrorFlag = _ftprintf_s(file, _T("Body height:    %.3f\n"), obj->getBodyHeight() );
    bErrorFlag = _ftprintf_s(file, _T("F-top slope:    %.3f\n"), obj->getFTArmSlope() );
    bErrorFlag = _ftprintf_s(file, _T("F-bottom slope: %.3f\n"), obj->getFBArmSlope() );
    bErrorFlag = _ftprintf_s(file, _T("B-top slope:    %.3f\n"), obj->getBTArmSlope() );
    bErrorFlag = _ftprintf_s(file, _T("B-b slope:      %.3f\n"), obj->getBBArmSlope() );
    bErrorFlag = _ftprintf_s(file, _T("Top slope:      %.3f\n"), obj->getTopArmSlope() );
    bErrorFlag = _ftprintf_s(file, _T("Side slope:     %.3f\n"), obj->getSideArmSlope() );
    bErrorFlag = _ftprintf_s(file, _T("Cannon length:  %.3f\n"), obj->getCannonLength() );
    pasteColor(obj->getColor(), file);
}
Ejemplo n.º 28
0
	// Report publishes bottomline
	//
	void Inventory::Report ( )
	{
		FILE* fout = 0;
		errno_t err = _tfopen_s ( &fout, _TEXT("C:\\InventoryReport.txt"), _TEXT("a+") );

		if ( !fout || err != 0 ) 	
		{
			cout << "C:\\InventoryReport.txt could not be opened" << endl;
			return;
		}

		_ftprintf_s( fout, _T("                        INVENTORY REPORT\n"));
		_ftprintf_s( fout, _T("Item Name           Buy At\t\tSell At\t\tOn Hand\t\t  Value\n"));
		_ftprintf_s( fout, _T("---------           ------\t\t-------\t\t-------\t\t  -----\n"));

		float totalValue = 0;
		float totalSales = 0;
		float totalCostOfItemsSold = 0;

		typedef map<basic_string<_TCHAR>, int>::const_iterator CI;
		for ( CI e = m.begin(); e != m.end(); ++e )
		{
			int i = e->second;
			if ( catalog[i].buyAt != 0 && catalog[i].sellAt != 0 )
			{
				_ftprintf_s( fout, _T("%s"), catalog[i].name );
				int numSpace = MAX_NAME_LENGTH - _tcslen(catalog[i].name);
				if ( numSpace > 0 )
					for ( int j = 0; j < numSpace ; j++ )
						_ftprintf_s( fout, _T(" ") );

				_ftprintf_s( fout, _T("%5.2f\t\t"), catalog[i].buyAt );
				_ftprintf_s( fout, _T("%5.2f\t\t"), catalog[i].sellAt );
				int numOnHand = catalog[i].numBought - catalog[i].numSold;
				_ftprintf_s( fout, _T("%5d\t\t"), numOnHand );
				float value = numOnHand*catalog[i].buyAt;
				_ftprintf_s( fout, _T("%7.2f\t\t\n"), value );
				
				totalValue += value;
				totalSales += catalog[i].numSold*catalog[i].sellAt;
				totalCostOfItemsSold += catalog[i].numSold*catalog[i].buyAt;
			}
		}
		_ftprintf_s( fout, _T("------------------------------\n"));
		_ftprintf_s( fout, _T("Total Value of inventory  \t\t       \t\t       \t\t%7.2f\n"), totalValue);
		float profit = totalSales - totalCostOfItemsSold - writeOff;
		float diff = profit - lastProfit;
		lastProfit = profit;
		_ftprintf_s( fout, _T("Profit since last report  \t\t       \t\t       \t\t%7.2f\n"),  diff);

		fclose(fout);
	}
Ejemplo n.º 29
0
void CCDecoder::DecodeCC(const BYTE* buff, int len, __int64 time)
{
    if (!m_rawfn.IsEmpty()) {
        FILE* f = nullptr;
        if (!_tfopen_s(&f, m_rawfn, _T("at"))) {
            _ftprintf_s(f, _T("%02d:%02d:%02d.%03d\n"),
                        (int)(time / 1000 / 60 / 60),
                        (int)((time / 1000 / 60) % 60),
                        (int)((time / 1000) % 60),
                        (int)(time % 1000));

            for (ptrdiff_t i = 0; i < len; i++) {
                _ftprintf_s(f, _T("%02x"), buff[i]);
                if (i < len - 1) {
                    _ftprintf_s(f, _T(" "));
                }
                if (i > 0 && (i & 15) == 15) {
                    _ftprintf_s(f, _T("\n"));
                }
            }
            if (len > 0) {
                _ftprintf_s(f, _T("\n\n"));
            }
            fclose(f);
        }
    }

    for (ptrdiff_t i = 0; i < len; i++) {
        BYTE c = buff[i] & 0x7f;
        if (c >= 0x20) {
            static WCHAR charmap[0x60] = {
                ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', 0xE1, '+', ',', '-', '.', '/',
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', 0x3F,
                '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
                'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', 0xE9, ']', 0xED, 0xF3,
                0xFA, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
                'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0xE7, 0xF7, 'N', 'n', 0x3F
            };

            PutChar(charmap[c - 0x20]);
        } else if (i < len - 1 && buff[i] != 0x80) {
            // codes and special characters are supposed to be doubled
            if (i < len - 3 && buff[i] == buff[i + 2] && buff[i + 1] == buff[i + 3]) {
                i += 2;
            }

            c = buff[i + 1] & 0x7f;
            if (buff[i] == 0x91 && c >= 0x20 && c < 0x30) { // formating
                // TODO
            } else if (buff[i] == 0x91 && c == 0x39) { // transparent space
                OffsetCursor(1, 0);
            } else if (buff[i] == 0x91 && c >= 0x30 && c < 0x40) { // special characters
                static WCHAR charmap[0x10] = {
                    0x00ae, // (r)egistered
                    0x00b0, // degree
                    0x00bd, // 1/2
                    0x00bf, // inverted question mark
                    0x2122, // trade mark
                    0x00a2, // cent
                    0x00a3, // pound
                    0x266a, // music
                    0x00e0, // a`
                    0x00ff, // transparent space, handled above
                    0x00e8, // e`
                    0x00e2, // a^
                    0x00ea, // e^
                    0x00ee, // i^
                    0x00f4, // o^
                    0x00fb, // u^
                };

                PutChar(charmap[c - 0x30]);
            } else if (buff[i] == 0x92 && c >= 0x20 && c < 0x40) { // extended characters
                static WCHAR charmap[0x20] = {
                    0x00c0, // A'
                    0x00c9, // E'
                    0x00d3, // O'
                    0x00da, // U'
                    0x00dc, // U:
                    0x00fc, // u:
                    0x2018, // `
                    0x00a1, // inverted !
                    0x002a, // *
                    0x2019, // '
                    0x002d, // -
                    0x00a9, // (c)opyright
                    0x2120, // SM
                    0x00b7, // . (dot in the middle)
                    0x201c, // inverted "
                    0x201d, // "

                    0x00c1, // A`
                    0x00c2, // A^
                    0x00c7, // C,
                    0x00c8, // E`
                    0x00ca, // E^
                    0x00cb, // E:
                    0x00eb, // e:
                    0x00ce, // I^
                    0x00cf, // I:
                    0x00ef, // i:
                    0x00d4, // O^
                    0x00d9, // U`
                    0x00f9, // u`
                    0x00db, // U^
                    0x00ab, // <<
                    0x00bb, // >>
                };

                PutChar(charmap[c - 0x20]);
            } else if (buff[i] == 0x13 && c >= 0x20 && c < 0x40) { // more extended characters
                static WCHAR charmap[0x20] = {
                    0x00c3, // A~
                    0x00e3, // a~
                    0x00cd, // I'
                    0x00cc, // I`
                    0x00ec, // i`
                    0x00d2, // O`
                    0x00f2, // o`
                    0x00d5, // O~
                    0x00f5, // o~
                    0x007b, // {
                    0x007d, // }
                    0x005c, // /* \ */
                    0x005e, // ^
                    0x005f, // _
                    0x00a6, // |
                    0x007e, // ~

                    0x00c4, // A:
                    0x00e4, // a:
                    0x00d6, // O:
                    0x00f6, // o:
                    0x00df, // B (ss in german)
                    0x00a5, // Y=
                    0x00a4, // ox
                    0x007c, // |
                    0x00c5, // Ao
                    0x00e5, // ao
                    0x00d8, // O/
                    0x00f8, // o/
                    0x250c, // |-
                    0x2510, // -|
                    0x2514, // |_
                    0x2518, // _|
                };

                PutChar(charmap[c - 0x20]);
            } else if (buff[i] == 0x94 && buff[i + 1] == 0xae) { // Erase Non-displayed [buffer] Memory
                ZeroMemory(m_buff, sizeof(m_buff));
            } else if (buff[i] == 0x94 && buff[i + 1] == 0x20) { // Resume Caption Loading
                ZeroMemory(m_buff, sizeof(m_buff));
            } else if (buff[i] == 0x94 && buff[i + 1] == 0x2f) { // End Of Caption
                if (memcmp(m_disp, m_buff, sizeof(m_disp)) != 0) {
                    if (m_fEndOfCaption) {
                        SaveDisp(time + (i / 2) * 1000 / 30);
                    }

                    m_fEndOfCaption = true;
                    memcpy(m_disp, m_buff, sizeof(m_disp));
                    m_time = time + (i / 2) * 1000 / 30;
                }
            } else if (buff[i] == 0x94 && buff[i + 1] == 0x2c) { // Erase Displayed Memory
                if (m_fEndOfCaption) {
                    m_fEndOfCaption = false;
                    SaveDisp(time + (i / 2) * 1000 / 30);
                }

                ZeroMemory(m_disp, sizeof(m_disp));
            } else if (buff[i] == 0x97 && (buff[i + 1] == 0xa1 || buff[i + 1] == 0xa2 || buff[i + 1] == 0x23)) { // Tab Over
                OffsetCursor(buff[i + 1] & 3, 0);
            } else if (buff[i] == 0x91 || buff[i] == 0x92 || buff[i] == 0x15 || buff[i] == 0x16
                       || buff[i] == 0x97 || buff[i] == 0x10 || buff[i] == 0x13 || buff[i] == 0x94) { // curpos, color, underline
                int row = 0;
                switch (buff[i]) {
                    default:
                    case 0x91:
                        row = 0;
                        break;
                    case 0x92:
                        row = 2;
                        break;
                    case 0x15:
                        row = 4;
                        break;
                    case 0x16:
                        row = 6;
                        break;
                    case 0x97:
                        row = 8;
                        break;
                    case 0x10:
                        row = 10;
                        break;
                    case 0x13:
                        row = 12;
                        break;
                    case 0x94:
                        row = 14;
                        break;
                }
                if (buff[i + 1] & 0x20) {
                    row++;
                }

                int col = buff[i + 1] & 0xe;
                if (col == 0 || (col > 0 && !(buff[i + 1] & 0x10))) {
                    col = 0;
                } else {
                    col <<= 1;
                }

                MoveCursor(col, row);
            }

            i++;
        }
    }
}
Ejemplo n.º 30
0
void clsTranslator::pastePosition(LPOBJECT3D obj, FILE* file) {
    VECTOR3D pos = obj->getPosition();
    errno_t bErrorFlag = _ftprintf_s(file, _T("Position:      %.3f %.3f %.3f\n"), pos.x, pos.y, pos.z );
}