Ejemplo n.º 1
0
static int WriteGameAvb()
{
	TCHAR szRomDat[MAX_PATH];
	FILE* h;

	CreateRomDatName(szRomDat);

	if ((h = _tfopen(szRomDat, _T("wt"))) == NULL) {
		return 1;
	}

	_ftprintf(h, _T(APP_TITLE) _T(" v%.20s ROMs"), szAppBurnVer);	// identifier
	_ftprintf(h, _T(" 0x%04X "), nBurnDrvCount);					// no of games

	for (unsigned int i = 0; i < nBurnDrvCount; i++) {
		if (gameAv[i] & 2) {
			_fputtc(_T('*'), h);
		} else {
			if (gameAv[i] & 1) {
				_fputtc(_T('+'), h);
			} else {
				_fputtc(_T('-'), h);
			}
		}
	}

	_ftprintf(h, _T(" END"));									// end marker

	fclose(h);

	return 0;
}
Ejemplo n.º 2
0
int _tmain(int argc, _TCHAR* argv[])
{
    if( argc < 3 )
    {
        printf( "Incorrect number of command line arguments. Expected arguments: src file, dst file\n");
        return -1;
    }
    auto SrcFile = argv[1];
    auto DstFile = argv[2];
    FILE *pSrcFile = nullptr;
    if( _tfopen_s( &pSrcFile, SrcFile, _T( "r" ) ) != 0 )
    {
        _tprintf( _T("Failed to open source file %s\n"), SrcFile );
        return -1;
    }

    FILE *pDstFile = nullptr;
    if( _tfopen_s(&pDstFile, DstFile, _T( "w" ) ) != 0 )
    {
        _tprintf( _T("Failed to open destination file %s\n"), DstFile );
        fclose(pSrcFile);
        return -1;
    }


    _TCHAR Buff[1024];
    _TCHAR SpecialChars[] = _T( "\'\"\\" );
    while( !feof( pSrcFile ) )
    {
        auto Line = _fgetts( Buff, sizeof( Buff )/sizeof(Buff[0]) , pSrcFile );
        if( Line == nullptr )
            break;
        _fputtc( _T( '\"' ), pDstFile );
        auto CurrChar = Line;
        while( CurrChar && *CurrChar != '\n' )
        {
            if( _tcschr( SpecialChars, *CurrChar) )
                _fputtc( _T( '\\' ), pDstFile );
            _fputtc( *CurrChar, pDstFile );
            ++CurrChar;
        }
        _fputts( _T("\\n\"\n"), pDstFile );
    }

    fclose(pDstFile);
    fclose(pSrcFile);

    _tprintf( _T("File2String: sucessfully converted %s to %s\n"), SrcFile, DstFile );

	return 0;
}
Ejemplo n.º 3
0
bool
CScsiDeviceList::Populate()
{
   this->clear();

   HKEY  hScsiKey;

   _tcscpy(m_szLastKey, _T("\\Scsi"));
   m_dwLastKeyLength = 5;

   m_lLastError = RegOpenKeyEx(  HKEY_LOCAL_MACHINE, 
                                 c_ScsiPath, 
                                 0, 
                                 KEY_READ, 
                                 &hScsiKey);

   if (m_lLastError != ERROR_SUCCESS) {
      _tcscpy(m_szLastOperation, _T("Opening key "));
      _tcscpy(m_szLastKey, c_ScsiPath);
      return false;
   }

   if (!ProcessKey(hScsiKey, c_MaxKeyDepth - 1, 0)) {
      return false;
   }

#if defined(_DEBUG)
   _fputtc(_T('\n'), stderr);
#endif

   return true;
}
Ejemplo n.º 4
0
void TFile::IndentString(size_t szAmt, TCHAR cChar)
{
	DEBUG_VERIFY_ALLOCATION;

	DEBUG_VERIFY(IsOpen());

	if(!(m_flOpenFlags & FOF_WRITE) || !(m_flOpenFlags & FOF_TEXT))
		INITIATE_FAILURE;

	for( ; szAmt ; szAmt--)
		_fputtc(cChar, m_pFile);
}
Ejemplo n.º 5
0
void CPluginHelper::DumpState(FILE *fp)
{
	_ftprintf(fp, _T("  "));
	m_Engine->DumpStallInfo(fp, m_Name, m_StallInfo);
	_fputts(_T("    In: "), fp);
	int	NumInputs = GetNumInputs();
	for (int InpIdx = 0; InpIdx < NumInputs; InpIdx++) {
		PFRAME InFrame = m_InputFrame[InpIdx];
		if (InFrame != NULL)
			_ftprintf(fp, _T("[%d(%d)] "), InFrame->Idx, InFrame->RefCount);
	}
	_fputtc('\n', fp);
}
Ejemplo n.º 6
0
extern "C" void FC_CSVRecordToFILEA(
    FILE*        pFile,
    const TCHAR* pBinStr, 
    int          iChars
)
{
    int   i;
    TCHAR cc;

    //first check if there are non print " or ; chars in there:
    if(FC_CSVNeedEscape(pBinStr, iChars))
    {
        _fputtc('"', pFile);
        for(i=0; ;i++)
        {
            if(iChars>=0 && i>=iChars)
                break;

            cc = pBinStr[i];
            if(iChars<0 && cc==0)
                break;
        
            if(cc==_T('"'))
                _fputtc('"', pFile);

            _fputtc(cc, pFile);
        }
        _fputtc('"', pFile);
    }
    else if(iChars<0)
    {
        _fputts(pBinStr, pFile);
    }
    else
    {
        for(i=0; i<iChars; i++)
            _fputtc(pBinStr[i], pFile);
    }
}
Ejemplo n.º 7
0
/******************************************************************************
 * Prints string str to file
 */
void REGPROC_export_string(FILE *file, TCHAR *str)
{
    size_t len = _tcslen(str);
    size_t i;

    /* escaping characters */
    for (i = 0; i < len; i++) {
        TCHAR c = str[i];
        switch (c) {
        //case _T('\\'): _fputts(_T("\\\\"), file); break;
        case _T('\"'): _fputts(_T("\\\""), file); break;
        case _T('\n'): _fputts(_T("\\\n"), file); break;
        default:       _fputtc(c, file);          break;
        }
    }
}
Ejemplo n.º 8
0
int
write_a_wide_char(UCS ucs, FILE *fp)
{
#ifdef _WINDOWS
    int   rv = 1;
    TCHAR w;

    w = (TCHAR) ucs;
    if(_fputtc(w, fp) == _TEOF)
      rv = EOF;

    return(rv);
#else /* UNIX */
    int rv = 1;
    int i, outchars;
    unsigned char obuf[MAX(MB_LEN_MAX,32)];

     if(ucs < 0x80){
	obuf[0] = (unsigned char) ucs;
	outchars = 1;
    }
    else{
	outchars = wtomb((char *) obuf, ucs);
	if(outchars < 0){
	    outchars = 1;
	    obuf[0] = bad_char;		/* ??? */
	}
    }

    for(i = 0; i < outchars; i++)
      if(fputc(obuf[i], fp) == EOF){
	  rv = EOF;
	  break;
      }
        
    return(rv);
#endif /* UNIX */
}
Ejemplo n.º 9
0
// Called by the root thread to actually save the state and write the file.
void SaveRequest::Perform()
{
    // Check that we aren't overwriting our own parent.
    for (unsigned q = 0; q < newHierarchy-1; q++) {
        if (sameFile(hierarchyTable[q]->fileName, fileName))
        {
            errorMessage = "File being saved is used as a parent of this file";
            errCode = 0;
            return;
        }
    }

    SaveStateExport exports;
    // Open the file.  This could quite reasonably fail if the path is wrong.
    exports.exportFile = _tfopen(fileName, _T("wb"));
    if (exports.exportFile == NULL)
    {
        errorMessage = "Cannot open save file";
        errCode = errno;
        return;
    }

    // Scan over the permanent mutable area copying all reachable data that is
    // not in a lower hierarchy into new permanent segments.
    CopyScan copyScan(newHierarchy);
    copyScan.initialise(false);
    bool success = true;
    try {
        for (unsigned i = 0; i < gMem.npSpaces; i++)
        {
            PermanentMemSpace *space = gMem.pSpaces[i];
            if (space->isMutable && ! space->noOverwrite && ! space->byteOnly)
                copyScan.ScanAddressesInRegion(space->bottom, space->top);
        }
    }
    catch (MemoryException &)
    {
        success = false;
    }

    // Copy the areas into the export object.  Make sufficient space for
    // the largest possible number of entries.
    exports.memTable = new memoryTableEntry[gMem.neSpaces+gMem.npSpaces+1];
    exports.ioMemEntry = 0;
    // The IO vector.
    unsigned memTableCount = 0;
    MemSpace *ioSpace = gMem.IoSpace();
    exports.memTable[0].mtAddr = ioSpace->bottom;
    exports.memTable[0].mtLength = (char*)ioSpace->top - (char*)ioSpace->bottom;
    exports.memTable[0].mtFlags = 0;
    exports.memTable[0].mtIndex = 0;
    memTableCount++;

    // Permanent spaces at higher level.  These have to have entries although
    // only the mutable entries will be written.
    for (unsigned w = 0; w < gMem.npSpaces; w++)
    {
        PermanentMemSpace *space = gMem.pSpaces[w];
        if (space->hierarchy < newHierarchy)
        {
            memoryTableEntry *entry = &exports.memTable[memTableCount++];
            entry->mtAddr = space->bottom;
            entry->mtLength = (space->topPointer-space->bottom)*sizeof(PolyWord);
            entry->mtIndex = space->index;
            if (space->isMutable)
            {
                entry->mtFlags = MTF_WRITEABLE;
                if (space->noOverwrite) entry->mtFlags |= MTF_NO_OVERWRITE;
                if (space->byteOnly) entry->mtFlags |= MTF_BYTES;
            }
            else
                entry->mtFlags = MTF_EXECUTABLE;
        }
    }
    unsigned permanentEntries = memTableCount; // Remember where new entries start.

    // Newly created spaces.
    for (unsigned i = 0; i < gMem.neSpaces; i++)
    {
        memoryTableEntry *entry = &exports.memTable[memTableCount++];
        PermanentMemSpace *space = gMem.eSpaces[i];
        entry->mtAddr = space->bottom;
        entry->mtLength = (space->topPointer-space->bottom)*sizeof(PolyWord);
        entry->mtIndex = space->index;
        if (space->isMutable)
        {
            entry->mtFlags = MTF_WRITEABLE;
            if (space->noOverwrite) entry->mtFlags |= MTF_NO_OVERWRITE;
            if (space->byteOnly) entry->mtFlags |= MTF_BYTES;
        }
        else
            entry->mtFlags = MTF_EXECUTABLE;
    }

    exports.memTableEntries = memTableCount;
    exports.ioSpacing = IO_SPACING;

    // Update references to moved objects.
    SaveFixupAddress fixup;
    for (unsigned l = 0; l < gMem.nlSpaces; l++)
    {
        LocalMemSpace *space = gMem.lSpaces[l];
        fixup.ScanAddressesInRegion(space->bottom, space->lowerAllocPtr);
        fixup.ScanAddressesInRegion(space->upperAllocPtr, space->top);
    }
    GCModules(&fixup);

    // Update the global memory space table.  Old segments at the same level
    // or lower are removed.  The new segments become permanent.
    // Try to promote the spaces even if we've had a failure because export
    // spaces are deleted in ~CopyScan and we may have already copied
    // some objects there.
    if (! gMem.PromoteExportSpaces(newHierarchy) || ! success)
    {
        errorMessage = "Out of Memory";
        errCode = ENOMEM;
        return;
    }
    // Remove any deeper entries from the hierarchy table.
    while (hierarchyDepth > newHierarchy-1)
    {
        hierarchyDepth--;
        delete(hierarchyTable[hierarchyDepth]);
        hierarchyTable[hierarchyDepth] = 0;
    }

    // Write out the file header.
    SavedStateHeader saveHeader;
    memset(&saveHeader, 0, sizeof(saveHeader));
    saveHeader.headerLength = sizeof(saveHeader);
    strncpy(saveHeader.headerSignature,
        SAVEDSTATESIGNATURE, sizeof(saveHeader.headerSignature));
    saveHeader.headerVersion = SAVEDSTATEVERSION;
    saveHeader.segmentDescrLength = sizeof(SavedStateSegmentDescr);
    if (newHierarchy == 1)
        saveHeader.parentTimeStamp = exportTimeStamp;
    else
    {
        saveHeader.parentTimeStamp = hierarchyTable[newHierarchy-2]->timeStamp;
        saveHeader.parentNameEntry = sizeof(TCHAR); // Always the first entry.
    }
    saveHeader.timeStamp = time(NULL);
    saveHeader.segmentDescrCount = exports.memTableEntries; // One segment for each space.
    // Write out the header.
    fwrite(&saveHeader, sizeof(saveHeader), 1, exports.exportFile);

    // We need a segment header for each permanent area whether it is
    // actually in this file or not.
    SavedStateSegmentDescr *descrs = new SavedStateSegmentDescr [exports.memTableEntries];

    for (unsigned j = 0; j < exports.memTableEntries; j++)
    {
        memoryTableEntry *entry = &exports.memTable[j];
        memset(&descrs[j], 0, sizeof(SavedStateSegmentDescr));
        descrs[j].relocationSize = sizeof(RelocationEntry);
        descrs[j].segmentIndex = (unsigned)entry->mtIndex;
        descrs[j].segmentSize = entry->mtLength; // Set this even if we don't write it.
        descrs[j].originalAddress = entry->mtAddr;
        if (entry->mtFlags & MTF_WRITEABLE)
        {
            descrs[j].segmentFlags |= SSF_WRITABLE;
            if (entry->mtFlags & MTF_NO_OVERWRITE)
                descrs[j].segmentFlags |= SSF_NOOVERWRITE;
            if (j < permanentEntries && (entry->mtFlags & MTF_NO_OVERWRITE) == 0)
                descrs[j].segmentFlags |= SSF_OVERWRITE;
            if (entry->mtFlags & MTF_BYTES)
                descrs[j].segmentFlags |= SSF_BYTES;
        }
    }
    // Write out temporarily. Will be overwritten at the end.
    saveHeader.segmentDescr = ftell(exports.exportFile);
    fwrite(descrs, sizeof(SavedStateSegmentDescr), exports.memTableEntries, exports.exportFile);

    // Write out the relocations and the data.
    for (unsigned k = 1 /* Not IO area */; k < exports.memTableEntries; k++)
    {
        memoryTableEntry *entry = &exports.memTable[k];
        // Write out the contents if this is new or if it is a normal, overwritable
        // mutable area.
        if (k >= permanentEntries ||
            (entry->mtFlags & (MTF_WRITEABLE|MTF_NO_OVERWRITE)) == MTF_WRITEABLE)
        {
            descrs[k].relocations = ftell(exports.exportFile);
            // Have to write this out.
            exports.relocationCount = 0;
            // Create the relocation table.
            char *start = (char*)entry->mtAddr;
            char *end = start + entry->mtLength;
            for (PolyWord *p = (PolyWord*)start; p < (PolyWord*)end; )
            {
                p++;
                PolyObject *obj = (PolyObject*)p;
                POLYUNSIGNED length = obj->Length();
                // Most relocations can be computed when the saved state is
                // loaded so we only write out the difficult ones: those that
                // occur within compiled code.
                //  exports.relocateObject(obj);
                if (length != 0 && obj->IsCodeObject())
                    machineDependent->ScanConstantsWithinCode(obj, &exports);
                p += length;
            }
            descrs[k].relocationCount = exports.relocationCount;
            // Write out the data.
            descrs[k].segmentData = ftell(exports.exportFile);
            fwrite(entry->mtAddr, entry->mtLength, 1, exports.exportFile);
       }
    }

    // If this is a child we need to write a string table containing the parent name.
    if (newHierarchy > 1)
    {
        saveHeader.stringTable = ftell(exports.exportFile);
        _fputtc(0, exports.exportFile); // First byte of string table is zero
        _fputts(hierarchyTable[newHierarchy-2]->fileName, exports.exportFile);
        _fputtc(0, exports.exportFile); // A terminating null.
        saveHeader.stringTableSize = (_tcslen(hierarchyTable[newHierarchy-2]->fileName) + 2)*sizeof(TCHAR);
    }

    // Rewrite the header and the segment tables now they're complete.
    fseek(exports.exportFile, 0, SEEK_SET);
    fwrite(&saveHeader, sizeof(saveHeader), 1, exports.exportFile);
    fwrite(descrs, sizeof(SavedStateSegmentDescr), exports.memTableEntries, exports.exportFile);

    // Add an entry to the hierarchy table for this file.
    (void)AddHierarchyEntry(fileName, saveHeader.timeStamp);

    delete[](descrs);
}
Ejemplo n.º 10
0
Handle RenameParent(TaskData *taskData, Handle args)
// Change the name of the immediate parent stored in a child
{
    TCHAR fileNameBuff[MAXPATHLEN], parentNameBuff[MAXPATHLEN];
    // The name of the file to modify.
    POLYUNSIGNED fileLength =
        Poly_string_to_C(DEREFHANDLE(args)->Get(0), fileNameBuff, MAXPATHLEN);
    if (fileLength > MAXPATHLEN)
        raise_syscall(taskData, "File name too long", ENAMETOOLONG);
    // The new parent name to insert.
    POLYUNSIGNED parentLength =
        Poly_string_to_C(DEREFHANDLE(args)->Get(1), parentNameBuff, MAXPATHLEN);
    if (parentLength > MAXPATHLEN)
        raise_syscall(taskData, "Parent name too long", ENAMETOOLONG);

    AutoClose loadFile(_tfopen(fileNameBuff, _T("r+b"))); // Open for reading and writing
    if ((FILE*)loadFile == NULL)
    {
        char buff[MAXPATHLEN+1+23];
#if (defined(_WIN32) && defined(UNICODE))
        sprintf(buff, "Cannot open load file: %S", fileNameBuff);
#else
        sprintf(buff, "Cannot open load file: %s", fileNameBuff);
#endif
        raise_syscall(taskData, buff, errno);
    }

    SavedStateHeader header;
    // Read the header and check the signature.
    if (fread(&header, sizeof(SavedStateHeader), 1, loadFile) != 1)
        raise_fail(taskData, "Unable to load header");

    if (strncmp(header.headerSignature, SAVEDSTATESIGNATURE, sizeof(header.headerSignature)) != 0)
        raise_fail(taskData, "File is not a saved state");

    if (header.headerVersion != SAVEDSTATEVERSION ||
        header.headerLength != sizeof(SavedStateHeader) ||
        header.segmentDescrLength != sizeof(SavedStateSegmentDescr))
    {
        raise_fail(taskData, "Unsupported version of saved state file");
    }

    // Does this actually have a parent?
    if (header.parentNameEntry == 0)
        raise_fail(taskData, "File does not have a parent");

    // At the moment the only entry in the string table is the parent
    // name so we can simply write a new one on the end of the file.
    // This makes the file grow slightly each time but it shouldn't be
    // significant.
    fseek(loadFile, 0, SEEK_END);
    header.stringTable = ftell(loadFile); // Remember where this is
    _fputtc(0, loadFile); // First byte of string table is zero
    _fputts(parentNameBuff, loadFile);
    _fputtc(0, loadFile); // A terminating null.
    header.stringTableSize = (_tcslen(parentNameBuff) + 2)*sizeof(TCHAR);

    // Now rewind and write the header with the revised string table.
    fseek(loadFile, 0, SEEK_SET);
    fwrite(&header, sizeof(header), 1, loadFile);

    return SAVE(TAGGED(0));
}
Ejemplo n.º 11
0
Archivo: main.cpp Proyecto: mega-t72/vc
bool translate(_TCHAR**lpszInput,size_t ilen,int*marker,LPCTSTR lpszFormat,...){
	FILE file;
	va_list args;
	//
	file._flag	= _IOREAD|_IOSTRG|_IOMYBUF;
	file._ptr	= file._base = (char*)(*lpszInput);
	file._cnt	= (int)ilen * sizeof(**lpszInput);
	//
	*marker		= -1;
	//
	va_start(args,lpszFormat);
#if defined(_UNICODE)
	if( (_winput_s_l(&file,lpszFormat,NULL,args) >= 0) && (*marker >= 0) ){
#else
	if( (_input_s_l(&file,(const unsigned char*)lpszFormat,NULL,args) >= 0) && (*marker >= 0) ){
#endif
		*lpszInput	= ( (_TCHAR*)file._ptr ) - 1;
		va_end(args);
		return true;
	}
	va_end(args);
	return false;
}
int _tmain(int argc, _TCHAR* argv[]){
	_TCHAR szINI[MAX_PATH];
	_TCHAR mode[64];
	LARGE_INTEGER version;
	LPTSTR lpszInput,lpszOutput,lpszINI,lpszBuffer,lpCh,lpCCs;
	FILE*output,*input;
	size_t i,len,ilen,std_out,hidden;
	errno_t err;
	long bomlen;
	int line,marker;
	unsigned int x;
	_TCHAR ccs;
	//
	if( argc < 4 ){
		return usage();
	}
	//
	lpszINI		= argv[argc - 3];
	lpszInput	= argv[argc - 2];
	lpszOutput	= argv[argc - 1];
	//
	if( ::GetFileAttributes(lpszInput) == INVALID_FILE_ATTRIBUTES ){
		return usage();
	}
	//
	for(ccs	= _T('a'),i = argc - 4;i--;){
		lpCh	= argv[i + 1];
		if( !_tcschr(_T("-/"),*lpCh) )continue;
		for(len = 0; *lpCh ;++len,++lpCh);
		if( !len )continue;
		for(--lpCh; len-- && !_tcschr(_T("aUue"),*lpCh) ; --lpCh);
		if( !++len )continue;
		ccs	= *lpCh;
		break;
	}
	switch( ccs ){
		case _T('a'):{
			lpCCs	= _T("");
			break;
		}
		case _T('U'):{
			lpCCs	= _T(", ccs=UNICODE");
			break;
		}
		case _T('u'):{
			lpCCs	= _T(", ccs=UTF-8");
			break;
		}
		case _T('e'):{
			lpCCs	= _T(", ccs=UTF-16LE");
			break;
		}
	}
	_stprintf_s(mode,_T("rt%s"),lpCCs);
	if( err = _tfopen_s(&input,lpszInput,mode) ){
		lc_print(_T(".866"),_T("\r\nошибка при открытии файла-шаблона\r\n"));
		return usage();
	}
	_stprintf_s(mode,_T("wt%s"),lpCCs);
	if( err = _tfopen_s(&output,lpszOutput,mode) ){
		lc_print(_T(".866"),_T("\r\nошибка при создании выходного файла\r\n"));
		fclose(input);
		return usage();
	}
	//
	bomlen	= ftell(input);
	for(len = 0; !feof(input) ;_fgettc(input),++len);
	lpszBuffer		= (LPTSTR)malloc( (len + 1) * sizeof(_TCHAR) );
	lpszBuffer[len]	= _T('\0');
	fseek(input,bomlen,SEEK_SET);
	for(lpCh = lpszBuffer; !feof(input) ;*(lpCh++) = _fgettc(input));
	fclose(input);
	//
	::GetFullPathName(lpszINI,sizeof(szINI) / sizeof(_TCHAR),szINI,NULL);
	version.LowPart		= ::GetPrivateProfileInt(_T("general"),_T("low"),0x00000000,szINI);
	version.HighPart	= ::GetPrivateProfileInt(_T("general"),_T("high"),0x00000000,szINI);
	//
	for(line = 1,hidden = 0,std_out = 0,lpCh = lpszBuffer; *lpCh ;++lpCh){
		switch( *lpCh ){
			case _T('\n'):{
				++line;
				break;
			}
			case _T('%'):{
				if( lpCh[1] == _T('%') ){
					++lpCh;
				}else{
					ilen	= len - (lpCh - lpszBuffer);
					if( translate(&lpCh,ilen,&marker,_T("%%<*%n"),&marker) ){
						++hidden;
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%*>%n"),&marker) ){
						--hidden;
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%<<%n"),&marker) ){
						++std_out;
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%>>%n"),&marker) ){
						--std_out;
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%qw++%n"),&marker) ){
						if( !hidden ){
							_ftprintf(output,_T("%I64u"),version.QuadPart);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%I64u"),version.QuadPart);
						}
						++version.QuadPart;
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%++qw%n"),&marker) ){
						++version.QuadPart;
						if( !hidden ){
							_ftprintf(output,_T("%I64u"),version.QuadPart);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%I64u"),version.QuadPart);
						}
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%qw%n"),&marker) ){
						if( !hidden ){
							_ftprintf(output,_T("%I64u"),version.QuadPart);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%I64u"),version.QuadPart);
						}
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%dw.%u++%n"),&x,&marker) ){
						if(x > 1){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						DWORD&value	= ((LPDWORD)&version.LowPart)[x];
						if( !hidden ){
							_ftprintf(output,_T("%I32u"),value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%I32u"),value);
						}
						++value;
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%++dw.%u%n"),&x,&marker) ){
						if(x > 1){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						DWORD&value	= ((LPDWORD)&version.LowPart)[x];
						++value;
						if( !hidden ){
							_ftprintf(output,_T("%I32u"),value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%I32u"),value);
						}
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%dw.%u%n"),&x,&marker) ){
						if(x > 1){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						DWORD&value	= ((LPDWORD)&version.LowPart)[x];
						if( !hidden ){
							_ftprintf(output,_T("%I32u"),value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%I32u"),value);
						}
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%w.%u++%n"),&x,&marker) ){
						if(x > 3){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						WORD&value	= ((LPWORD)&version.LowPart)[x];
						if( !hidden ){
							_ftprintf(output,_T("%hu"),value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%hu"),value);
						}
						++value;
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%++w.%u%n"),&x,&marker) ){
						if(x > 3){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						WORD&value	= ((LPWORD)&version.LowPart)[x];
						++value;
						if( !hidden ){
							_ftprintf(output,_T("%hu"),value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%hu"),value);
						}
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%w.%u%n"),&x,&marker) ){
						if(x > 3){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						WORD&value	= ((LPWORD)&version.LowPart)[x];
						if( !hidden ){
							_ftprintf(output,_T("%hu"),value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%hu"),value);
						}
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%b.%u++%n"),&x,&marker) ){
						if(x > 7){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						BYTE&value	= ((LPBYTE)&version.LowPart)[x];
						if( !hidden ){
							_ftprintf(output,_T("%hu"),(WORD)value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%hu"),(WORD)value);
						}
						++value;
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%++b.%u%n"),&x,&marker) ){
						if(x > 7){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						BYTE&value	= ((LPBYTE)&version.LowPart)[x];
						++value;
						if( !hidden ){
							_ftprintf(output,_T("%hu"),(WORD)value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%hu"),(WORD)value);
						}
						continue;
					}
					if( translate(&lpCh,ilen,&marker,_T("%%b.%u%n"),&x,&marker) ){
						if(x > 7){
							fclose(output);
							return out_of_range(lpszInput,line);
						}
						BYTE&value	= ((LPBYTE)&version.LowPart)[x];
						if( !hidden ){
							_ftprintf(output,_T("%hu"),(WORD)value);
						}
						if( std_out ){
							_ftprintf(stdout,_T("%hu"),(WORD)value);
						}
						continue;
					}
				}
			}
		}
		if( !hidden ){
			_fputtc(*lpCh,output);
		}
		if(std_out){
			if( _tcschr(_T("Uue"),ccs) ){
				lc_print(_T(".OCP"),_T("%c"),*lpCh);
			}else{
				oem_print(_T("%c"),*lpCh);
			}
		}
	}
	free(lpszBuffer);
	fclose(output);
	//
	for(i = argc - 4;i--;){
		lpCh	= argv[i + 1];
		if( _tcschr(_T("-/"),*lpCh) ){
			if( _tcschr(lpCh + 1,_T('r')) ){
				break;
			}
		}
	}
	if( !(i + 1) ){
		_stprintf_s(mode,_T("%#.8x"),version.LowPart);
		::WritePrivateProfileString(_T("general"),_T("low"),mode,szINI);
		_stprintf_s(mode,_T("%#.8x"),version.HighPart);
		::WritePrivateProfileString(_T("general"),_T("high"),mode,szINI);
	}
	//
	return S_OK;
}
Ejemplo n.º 12
0
_TINT (_RTLENTRY _EXPFUNC _puttc)( const _TINT c, FILE *fp )
  {
  return( _fputtc( c, fp ) );
  }