Exemplo n.º 1
0
/*
	输  入: lpszFileName(const wchar_t*) - [in]日志文件路径
			lpszStr(wchar_t*) - [in]错误内容
	输  出: int - TRUE:写内容成功, FALSE:写内容失败
	功  能: 写错误信息
*/
static int WriteFile(const wchar_t* lpszFileName, wchar_t* lpszStr)
{
	FILE* pFile =_wfopen(lpszFileName, L"a");
	_ASSERT(pFile != NULL);
	time_t timeNow;

	if (NULL == pFile)
	{
		return FALSE;
	}

	// 格式化时间
	time(&timeNow);
	wchar_t* pTimeNow = _wctime(&timeNow);

	fputws(lpszStr, pFile);
	fputws(L"\n", pFile);
	fputws(pTimeNow, pFile);
	fputws(L"\r\n", pFile);		

	fclose(pFile);
	pFile = NULL;

	return TRUE;
}
Exemplo n.º 2
0
void print_locals(Env *env, FILE *stream)
{
	const Binding *bnd = 0;
	static bool rec = false;

	assert(env != 0);
	assert(stream != 0);

	if (rec == true) {
		fputws(L"...", stream);
		return;
	}

	rec = true;

	for (bnd = env->bindings; bnd != UNBOUND; bnd = bnd->link) {
		fputws(bnd->name, stream);
		fputwc(L'=', stream);
		print_value(bnd->value, stream);
		if (bnd->link != 0) {
			fputwc(L',', stream);
		}
	}

	rec = false;
}
Exemplo n.º 3
0
LISPTR lisp_print(LISPTR x, FILE* out)
{
	if (consp(x)) {
		fputwc('(', out);
		while (true) {
			lisp_print(car(x), out);
			x = cdr(x);
			if (!consp(x)) {
				if (x != NIL) {
					fputws(L" . ", out);
					lisp_print(x, out);
				}
				break;
			}
			fputwc(' ', out);
		}
		fputwc(')', out);
	} else if (symbolp(x)) {
		fputws(string_text(symbol_name(x)), out);
	} else if (numberp(x)) {
		fwprintf(out, L"%g", number_value(x));
	} else if (stringp(x)) {
		fputwc('"', out);
		fputws(string_text(x), out);
		fputwc('"', out);
	} else {
		fputws(L"*UNKOBJ*", out);
	}
	return x;
}
Exemplo n.º 4
0
void print_env(Env *env, FILE *stream)
{
	const Binding *bnd = 0;
	static bool rec = 0;

	if (rec == 1) {
		fputws(L"...", stream);
		return;
	}

	rec = 1;

	fputws(L"#<Env", stream);
	for (; env != 0; env = env->link) {
		for (bnd = env->bindings; bnd != UNBOUND; bnd = bnd->link) {
			fputwc(L' ', stream);
			fputws(bnd->name, stream);
			fputwc(L'=', stream);
			print_value(bnd->value, stream);
			if (bnd->link != 0) {
				fputwc(L',', stream);
			}
		}
	}

	rec = 0;

	fputwc(L'>', stream);
}
Exemplo n.º 5
0
static void
error3()
{
	if (Cp) {
		struct call	*mptr;

		/* fix limit */
		*op = EOS;
		(Cp+1)->argp = Ap+1;

		for (mptr = callst; mptr <= Cp; ++mptr) {
			wchar_t	**aptr, **lim;

			aptr = mptr->argp;
			lim = (mptr+1)->argp-1;
			if (mptr == callst)
				(void) fputws(*aptr, stderr);
			++aptr;
			(void) fputs("(", stderr);
			if (aptr < lim)
				for (;;) {
					(void) fputws(*aptr++, stderr);
					if (aptr >= lim)
						break;
					(void) fputs(",", stderr);
				}
		}
		while (--mptr >= callst)
			(void) fputs(")", stderr);

		(void) fputs("\n", stderr);
	}
	delexit(NOT_OK, 1);
}
//
// ProcessTest
// - Load a sample set in the following format
//
//   <Movie1Id>:
//   <CustomerId>
//   <CustomerId>
//   ...
//   <Movie2Id>:
//   <CustomerId>
//
// - And write results:
//
//   <Movie1Id>:
//   <Rating>
//   <Rating>
//   ...
void Project_Engine::Qualify(wchar_t* pwzFile, MatrixXd rate_matrix, NodePtr Class_List, Sparse_Mat Movie_Matrix)
{
    FILE *streamIn, *streamOut;
    wchar_t pwzBuffer[1000];
    int custId, movieId, pos = 0, counter = 0;
    double predict_rating, err, rmse = 0;
	double sq = 0;
    bool bMovieRow;

    wsprintf(pwzBuffer, TEST_PATH, pwzFile);
    wprintf(L"\n\nProcessing test: %s\n", pwzBuffer);

    if (_wfopen_s(&streamIn, pwzBuffer, L"r") != 0) return;
    if (_wfopen_s(&streamOut, PREDICTION_DIRECTORY, L"w") != 0) return;

    fgetws(pwzBuffer, 1000, streamIn);
    while ( !feof( streamIn ) )
    {
        bMovieRow = false;
        for (int i=0; i<(int)wcslen(pwzBuffer); i++)
        {
            bMovieRow |= (pwzBuffer[i] == 58); 
        }

        pos = 0;
        if (bMovieRow)
        {
            Parse_Str_Int(pwzBuffer, (int)wcslen(pwzBuffer), pos, movieId);

            // Write same row to results
            fputws(pwzBuffer,streamOut); 
        }
        else
        {
            Parse_Str_Int(pwzBuffer, (int)wcslen(pwzBuffer), pos, custId);
            custId = mapped_custID[custId];

			// Predict rating and calc error
			predict_rating = rate_matrix(returnClass(custId-1,Class_List),movieId);//Rating Prediction Algorithm!!!!
			err = (Movie_Matrix.coeff(custId-1,movieId-1) - predict_rating);
            sq += err*err;
			counter++;

            // Write predicted value
            swprintf(pwzBuffer,1000,L"%5.3f\n",predict_rating);//Print predicted value!!!
            fputws(pwzBuffer,streamOut);
        }

        //wprintf(L"Got Line: %d %d %d \n", movieId, custId, rating);
        fgetws(pwzBuffer, 1000, streamIn);
    }

	rmse = sqrt(sq/counter);
    // Cleanup
    fclose( streamIn );
    fclose( streamOut );
}
Exemplo n.º 7
0
int
do_seek_set (FILE *fp)
{
  long save1, save2;

  if (fputws (L"ゅう\n", fp) == -1)
    {
      printf ("seek_set: fputws(1): %s\n", strerror (errno));
      return 1;
    }

  save1 = ftell (fp);

  if (fputws (L"ゅう\n", fp) == -1)
    {
      printf ("seek_set: fputws(2): %s\n", strerror (errno));
      return 1;
    }

  save2 = ftell (fp);

  if (fputws (L"ゅう\n", fp) == -1)
    {
      printf ("seek_set: fputws(3): %s\n", strerror (errno));
      return 1;
    }

  if (fseek (fp, save1, SEEK_SET) == -1)
    {
      printf ("seek_set: fseek(1): %s\n", strerror (errno));
      return 1;
    }

  if (save1 != ftell (fp))
    {
      printf ("save1 = %ld, ftell = %ld\n", save1, ftell (fp));
      return 1;
    }

  if (fseek (fp, save2, SEEK_SET) == -1)
    {
      printf ("seek_set: fseek(2): %s\n", strerror (errno));
      return 1;
    }

  if (save2 != ftell (fp))
    {
      printf ("save2 = %ld, ftell = %ld\n", save2, ftell (fp));
      return 1;
    }

  return 0;
}
Exemplo n.º 8
0
Arquivo: xml.cpp Projeto: Kaldaien/BMT
void
bmt::XML::SaveXML (void)
{
  std::wstring documents_dir = BMT_GetDocumentsDir ();

  wchar_t wszXML [1024];

  wsprintf (wszXML, L"%s\\WB Games\\Batman Arkham Knight\\GFXSettings.BatmanArkhamKnight.xml", documents_dir.c_str ());

  wchar_t* wszOut = new wchar_t [8192];
  wchar_t* wszEnd = print (wszOut, bmak_xml, 0);

  int last_brace = 0;

  // XML parser doesn't like the TM symbol, so get it the hell out of there!
  for (int i = 0; i < 8192; i++) {
    if (wszOut [i] == L'™')
      wszOut [i] = L' ';
    if (wszOut [i] == L'>')
      last_brace = i;
  }

  wszOut [last_brace + 1] = L'\0';

  FILE* fXML;
  errno_t ret = _wfopen_s (&fXML, wszXML, L"w,ccs=UTF-16LE");

  if (ret != 0 || fXML == 0) {
    delete [] wszOut;
    BMT_MessageBox (L"Could not open GFXSettings.BatmanArkhamKnight.xml for writing!\n", L"Unable to save XML settings", MB_OK | MB_ICONSTOP);
    return;
  }

  fputws (L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\n", fXML);
  fputws (wszOut, fXML);

  delete [] wszOut;

  fflush (fXML);
  fclose (fXML);

  //
  // Windows 10 File Permission Fixes
  //

  // Normalize file ownership and attributes (Win10 fix)
  BMT_SetNormalFileAttribs (wszXML);

  // Now normalize the directory as a whole
  wsprintf (wszXML, L"%s\\WB Games\\Batman Arkham Knight", documents_dir.c_str ());
  BMT_SetNormalFileAttribs (wszXML);
}
Exemplo n.º 9
0
static void create_minidump()
{
    HANDLE dumpfile = INVALID_HANDLE_VALUE;

    if (!set_dump_privileges())
    {
        fputws(L"Unable to adjust privileges to create minidump\n", stderr);
        goto cleanup;
    }

    DWORD const buf_size = MAX_PATH * 2;
    wchar_t dump_filename[buf_size];

    ::GetTempPathW(buf_size, dump_filename);
    StringCbCat(dump_filename, buf_size, *app_name_? app_name_ : L"app");
    StringCbCat(dump_filename, buf_size, L"-crash.dmp");

    dumpfile = ::CreateFile(dump_filename, GENERIC_WRITE, 0, NULL,
                            CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (dumpfile == INVALID_HANDLE_VALUE)
    {
        fputws(L"Unable to create minidump file ", stderr);
        fputws(dump_filename, stderr);
        goto cleanup;
    }

    MINIDUMP_TYPE const dump_type = MiniDumpWithFullMemory;//MiniDumpNormal;

    MINIDUMP_EXCEPTION_INFORMATION dump_exception_info;
    dump_exception_info.ThreadId = ::GetCurrentThreadId();
    dump_exception_info.ExceptionPointers = exception_pointers_;
    dump_exception_info.ClientPointers = false;

    if (!::MiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(),
                             dumpfile, dump_type, &dump_exception_info, nullptr, nullptr))
    {
        fputws(L"Unable to write minidump file ", stderr);
        fputws(dump_filename, stderr);
        goto cleanup;
    }

    fputws(L"Minidump has been written to ", stderr);
    fputws(dump_filename, stderr);
    if (*report_contact_)
    {
        fputws(L"Please send it to ", stderr);
        fputws(report_contact_, stderr);
    }

cleanup:
    if (dumpfile != INVALID_HANDLE_VALUE)
    {
        ::CloseHandle(dumpfile);
    }
}
Exemplo n.º 10
0
//------------------------------------------------------------------------
void CLogFile::LogTextWithDate(const TCHAR * pszString, ...)
{
	THREAD_PROTECT;
	if (m_fpLog == NULL)
		return;
	LogDate();
	va_list	vl;
	va_start(vl, pszString);
	wvsprintf(m_szCache, pszString, vl);
	va_end(vl);
	fputws(m_szCache, m_fpLog);
	fputws(L"\n", m_fpLog);
	fflush(m_fpLog);
}
Exemplo n.º 11
0
void print_prologue(FILE *f, struct psafe3_pro *pro)
{
	int i;
#define EOL() fputwc('\n', f)
	fputws(L"SALT   ", f); printhex(f, pro->salt, 32); EOL();
	fwprintf(f, L"ITER   %u\n", pro->iter);
	fputws(L"H(P')  ", f); printhex(f, pro->h_pprime, 32); EOL();
	for (i = 0; i < 4; i++) {
		fwprintf(f, L"B%d     ", i);
		printhex(f, pro->b[i], 16); EOL();
	}
	fputws(L"IV     ", f); printhex(f, pro->iv, 16); EOL();
#undef EOL
}
Exemplo n.º 12
0
int main()
{
    FILE *fp_in_wide;
    wchar_t buffer[4096];
    wchar_t *line = buffer;

    if ( setlocale( LC_CTYPE, "" ) == NULL)
    {
       fwprintf( stderr, L"Sorry, couldn't change to the system's native locale.\n");
       return -1;
    }
    if (( fp_in_wide = fopen( "local_in.txt", "r" )) == NULL )
    {   perror( "Opening input file");  return -1;   }

    fwide( fp_in_wide, 1);

    line = fgetws( buffer, sizeof(buffer), fp_in_wide );
    if ( line == NULL )
       perror( "Reading from input file" );
    else
       if( fputws( line, stdout) < 0)
          perror( "Writing to stdout" );

    return 0;
}
Exemplo n.º 13
0
void CPtnZler::SaveToLog(int nResult, int nRound)
{
	//打开文件
	TCHAR wcsLogFile[_MAX_PATH];
	wsprintf(wcsLogFile, L"%s\\Pattern\\Log.txt", ModulePath);
	FILE *LogFile;
	if ((LogFile = _wfopen(wcsLogFile, L"a+, ccs=UTF-8")) == NULL)
		return;

	//写入结果
	TCHAR wcsResult[128], szIdent[7];
	switch (nResult)
	{
	case BLKLOSE:
		wsprintf(szIdent, L"%s", nRound >= 30 ? L"      " : nRound >= 25 ? L"   " : L"");
		wsprintf(wcsResult, L"%6d.pgn         %s%3d\n", m_nFileNumber, szIdent, nRound);
		break;
	case TIMEOUT:
		wsprintf(wcsResult, L"%6d.pgn         超时\n", m_nFileNumber);
		break;
	}
	fputws(wcsResult, LogFile);

	//关闭文件
	fclose(LogFile);
}
Exemplo n.º 14
0
int
main (void)
{
  FILE *fp;

  mtrace ();

  setlocale (LC_ALL, "de_DE.UTF-8");

  fp = fopen (inputfile, "r,ccs=ISO-8859-1");
  if (fp == NULL)
    {
      printf ("cannot open \"%s\": %s\n", inputfile, strerror (errno));
      exit (1);
    }

  while (! feof_unlocked (fp))
    {
      wchar_t buf[200];

      if (fgetws_unlocked (buf, sizeof (buf) / sizeof (buf[0]), fp) == NULL)
	break;

      fputws (buf, stdout);
    }

  fclose (fp);

  return 0;
}
void PrintWin32Error( DWORD tErrorCode )
{
   WCHAR tBuffer[ 1024 ];
   FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, tBuffer, SIZEOF( tBuffer ), NULL );
   fputws( tBuffer, stdout );
   fputc( '\n', stdout );
}
Exemplo n.º 16
0
Arquivo: io.c Projeto: bencz/OrangeC
int main()
{
    int c,i;
    wchar_t s[100];
    FILE *fil = fopen("hi.txt","w+");
    printf("%d\n",fwide(fil,0));
    fputwc(L'c',fil);
    fputws(L"hi dave\n",fil);
    fwprintf(fil,L"%ls\n",L"geez");
    printf("%d\n",fwide(fil,0));
    printf("%d\n",fputc('z',fil));
    printf("%d\n",fwide(fil,-1));
    printf("%d\n",fputc('y',fil));
    printf("%d\n",fputc('y',fil));
    rewind(fil);
    printf("%d\n",fwide(fil,1));
    printf("%04x\n",fgetwc(fil));
    printf("%04x\n",fgetwc(fil));
    printf(":%x: ",fgetws(s,100,fil));
    for (i=0; i <wcslen(s); i++)
        printf("%04x ",s[i]);
    printf("\n");
    fwscanf(fil,L"%ls ",s);
    for (i=0; i <wcslen(s); i++)
        printf("%04x ",s[i]);
    printf("\n");
    printf("%d\n",fwide(fil,-1));
    printf("%02x\n",fgetc(fil));
    fclose(fil);
}
Exemplo n.º 17
0
void CjocLog::Append(std::wstring &strText, bool bTimestamp, bool bShowOnScreen)
{
	std::wstring strLog;
	std::wstring strTime;

	if (m_strFile.empty () == true){throw JOC_Error_(enjocErrors::err_bad_state );}

	FILE *pFile = NULL;
		
	pFile = _wfopen (m_strFile.c_str (),L"a+");
	if (pFile == NULL){throw JOC_Error_arg_(enjocErrors::err_opening_file_for_append,m_strFile.c_str ());}

	if (bTimestamp == true)
	{
		strTime = CjocUtils::GetTimeStr (L"%H:%M:%S %d/%m/%Y");
		strTime = strTime + L" - ";		
	}
	
	strLog = strTime;
	strLog.append (strText);
	strLog.append (L"\n");

	int nRc = fputws (strLog.c_str (),pFile);

	fclose(pFile);

	if (nRc < 0){throw JOC_Error_arg_(enjocErrors::err_append_file,m_strFile.c_str ());}

	if (bShowOnScreen == true)
		wprintf (strLog.c_str ());
}
Exemplo n.º 18
0
int FileStdStream::PutS(const String &sString)
{
	// Write string
	if (m_pFile && IsWritable()) {
		#ifdef WIN32
			// ASCII or Unicode?
			if (m_nStringFormat == String::ASCII) {
				const int nSize = fputs(sString.GetASCII(), m_pFile);
				if (nSize >= 0)
					return sString.GetLength();
			} else {
				const int nSize = fputws(sString.GetUnicode(), m_pFile);
				if (nSize >= 0)
					return sString.GetLength();
			}
		#else
			const int nSize = fputs((sString.GetFormat() == String::ASCII) ? sString.GetASCII() : sString.GetUTF8(), m_pFile);
			if (nSize >= 0)
				return sString.GetLength();
		#endif
	}

	// Error!
	return -1;
}
Exemplo n.º 19
0
void pflush(int ol)
{
	register int i;
	register wchar_t *cp;
	char lastomit;
	int l;

	l = ol;
	lastomit = 0;
	if (l > 266)
		l = 266;
	else
		l |= 1;
	for (i = first | 1; i < l; i++) {
		move(i, i - 1);
		move(i, i + 1);
	}
	for (i = first; i < l; i++) {
		cp = page[i];
		if (printall == 0 && lastomit == 0 && *cp == 0) {
			lastomit = 1;
			continue;
		}
		lastomit = 0;
		fputws(cp, stdout);
		putwchar('\n');
	}
	bcopy(page[ol], page, (267 - ol) * 132 * sizeof(wchar_t));
	bzero(page[267- ol], ol * 132 * sizeof(wchar_t));
	outline -= ol;
	outcol = 0;
	first = 1;
}
Exemplo n.º 20
0
void CFileSystemServiceImpl::internalWriteAllText(const wstring& path1, const wstring& text, const wstring& encoding) {
	BException ex;
	wstring ret;

	wstring path = makeValidPath(path1);
	FILE* file = NULL;

	wstringstream ssmode;
	ssmode << L"w"; 
	if (encoding.size()) ssmode << L", ccs=" << checkValidEncoding(encoding);

	errno_t err = _wfopen_s(&file, path.c_str(), ssmode.str().c_str());
	if (err) {
		wstringstream wss;
		wss << L"Failed to open file \"" << path << L"\".";
		ex = createException(wss.str(), err);
		goto leave;
	}

	err = fputws(text.c_str(), file);
	if (err) {
		wstringstream wss;
		wss << L"Failed to write file \"" << path << L"\".";
		ex = createException(wss.str(), err);
		goto leave;
	}

leave:
	if (file) fclose(file);
	
	if (ex) throw ex;
}
Exemplo n.º 21
0
void CStdioFileEx::WriteWideString(LPCWSTR lpsz)
{
   ASSERT(lpsz != NULL);
   
   if (lpsz == NULL)
   {
      AfxThrowInvalidArgException();
   }
   if(m_bIsUnicodeText)
   {
      ASSERT(m_pStream != NULL);
      // If writing Unicode and at the start of the file, need to write byte mark
      if(GetPosition() == 0)
      {
         wchar_t cBOM = (wchar_t)UNICODE_BOM;
         CFile::Write(&cBOM, sizeof(wchar_t));
      }
      if (fputws(lpsz, m_pStream) == _TEOF)
         AfxThrowFileException(CFileException::diskFull, _doserrno, m_strFileName);
   }
   else
   {
      USES_CONVERSION;
      WriteAnsiString(CW2A(lpsz));
   }
}
int
main (int argc, char *argv[])
{
  FILE *fp;

  mtrace ();

  if (argc < 2)
    exit (1);

  fp = fopen (argv[1], "w");
  if (fp == NULL)
    {
      puts ("fopen failed: %m");
      exit (1);
    }

  fputs ("Hello world (mb)\n", fp);

  fp = freopen (argv[1], "a+", fp);
  if (fp == NULL)
    {
      puts ("freopen failed: %m");
      exit (1);
    }

  fputws (L"Hello world (wc)\n", fp);

  fclose (fp);

  return 0;
}
Exemplo n.º 23
0
void Bookmark::Save( CMixiDataList& bookmark )
{
	CString fileName;
	fileName.Format( _T("%s\\favorite.dat"), theApp.GetAppDirPath());

	FILE* fp = _wfopen(fileName, _T("w"));

	INT_PTR count = bookmark.size();
	CString buf;
	CString type;

	for (int i=0; i<count; i++) {
		CMixiData& data = bookmark[i];
#ifdef BT_MZ3
		switch (data.GetAccessType()) {
		case ACCESS_BBS:
			type = _T("b");
			break;
		case ACCESS_ENQUETE:
			type = _T("e");
			break;
		case ACCESS_EVENT:
			type = _T("v");
			break;
		case ACCESS_EVENT_JOIN:
			type = _T("j");
			break;
		}
#endif
		buf.Format(_T("%s<>%d<>%s<>%s\n"), type, data.GetID(), data.GetName(), data.GetTitle());
		fputws(buf, fp);
	}

	fclose(fp);
}
Exemplo n.º 24
0
void outputVal(FILE *fp, int val)
{
	wchar_t buf[1024];

	swprintf_s(buf, 1024, _T("\"%d\""), val);
	fputws(buf, fp);
}
void CWE252_Unchecked_Return_Value__wchar_t_fputs_18_bad()
{
    goto sink;
sink:
    /* FLAW: Do not check the return value */
    fputws(L"string", stdout);
}
Exemplo n.º 26
0
static void DbgPrint(LPCWSTR format, ...) {
  if (g_DebugMode) {
    const WCHAR *outputString;
    WCHAR *buffer = NULL;
    size_t length;
    va_list argp;

    va_start(argp, format);
    length = _vscwprintf(format, argp) + 1;
    buffer = _malloca(length * sizeof(WCHAR));
    if (buffer) {
      vswprintf_s(buffer, length, format, argp);
      outputString = buffer;
    } else {
      outputString = format;
    }
    if (g_UseStdErr)
      fputws(outputString, stderr);
    else
      OutputDebugStringW(outputString);
    if (buffer)
      _freea(buffer);
    va_end(argp);
  }
}
Exemplo n.º 27
0
/**
 * Funkcja, która finalizuje wczytywanie słowa i wypisuje o nim informacje.
 * Na standardowe wyjście słowo zostaje przepisane, lub przepisane poprzedzone
 * znakiem '#', jeśli go nie znaleziono w słowniku.
 * Jeśli w 'pstate' ustawiony jest tryb "verbose", wypisywane są również
 * dodatkowe informacje o podpowiedziach na wyjście błędów.
 * @param [in,out] pstate Stan parsera. Zostanie uaktualniona jedynie pozycja
 * w buforze.
 */
void process_word(struct parser_state * pstate)
{
    // finalizing buffer iterator
    *pstate->buffer_iterator = L'\0';
    pstate->buffer_iterator = word_buffer;

    // word for dictionary
    make_lower(word_buffer, word_buffer_lowered);

    // true position of the word
    int word_column_num = pstate->last_non_word_column_num + 1;

    // getting data from dictionary and printing it
    const bool is_in_dict = dictionary_find(pstate->dict, word_buffer_lowered);
    if (!is_in_dict && pstate->verbose)
    {
        {
            struct word_list wlist;
            dictionary_hints(pstate->dict, word_buffer_lowered, &wlist);
            print_verbose_info(pstate, word_column_num, &wlist, stderr);
        }
        fputwc(L'#', stdout);
    }
    fputws(word_buffer, stdout);
}
Exemplo n.º 28
0
static int
do_seek_end (FILE *fp)
{
  long save;

  if (fputws (L"abc\n", fp) == -1)
    {
      printf ("do_seek_end: fputws: %s\n", strerror (errno));
      return 1;
    }

  save = ftell (fp);
  rewind (fp);

  if (fseek (fp, 0, SEEK_END) == -1)
    {
      printf ("do_seek_end: fseek: %s\n", strerror (errno));
      return 1;
    }

  if (save != ftell (fp))
    {
      printf ("save = %ld, ftell = %ld\n", save, ftell (fp));
      return 1;
    }

  return 0;
}
Exemplo n.º 29
0
void LogInternal(int nLevel, ULONGLONG elapsed, LPCTSTR pszMessage)
{
	// Add timestamp
	WCHAR buffer[128];
	size_t len = _snwprintf_s(buffer, _TRUNCATE, L"%02llu:%02llu:%02llu.%03llu", elapsed / (1000 * 60 * 60), (elapsed / (1000 * 60)) % 60, (elapsed / 1000) % 60, elapsed % 1000);

	Rainmeter->AddAboutLogInfo(nLevel, buffer, pszMessage);

#ifndef _DEBUG
	if (!Rainmeter->GetLogging()) return;
#endif

	std::wstring message;
	switch (nLevel)
	{
	case LOG_ERROR:
		message = L"ERRO";
		break;

	case LOG_WARNING:
		message = L"WARN";
		break;

	case LOG_NOTICE:
		message = L"NOTE";
		break;

	case LOG_DEBUG:
		message = L"DBUG";
		break;
	}
	
	message += L" (";
	message.append(buffer, len);
	message += L") ";
	message += pszMessage;
	message += L'\n';
	
#ifdef _DEBUG
	_RPT0(_CRT_WARN, ConvertToAscii(message.c_str()).c_str());
	if (!Rainmeter->GetLogging()) return;
#endif

	const WCHAR* logFile = Rainmeter->GetLogFile().c_str();
	if (_waccess(logFile, 0) == -1)
	{
		// Disable logging if the file was deleted manually
		Rainmeter->StopLogging();
	}
	else
	{
		FILE* file = _wfopen(logFile, L"a+, ccs=UTF-8");
		if (file)
		{
			fputws(message.c_str(), file);
			fclose(file);
		}
	}
}
Exemplo n.º 30
0
int
zmain (int argc, char *argv[])
{
  fputws (L"Hello world!\n", stdout);
  wprintf (L"This %s a %ls string: %d\n", "is", L"mixed", 42);
  wprintf (L"%Iu\n", 0xfeedbeef);
  return 0;
}