Exemplo n.º 1
0
	bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode ) throw( ) {
		m_nRestarting = 1;
		TCHAR szTokens[] = _T("-/");
		LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
        getRhoRootPath();
		while (lpszToken != NULL)
		{
			if (WordCmpI(lpszToken, _T("Restarting"))==0) {
				m_nRestarting = 10;
			}
#if defined(OS_WINDOWS)
			else if (wcsncmp(lpszToken, _T("approot"),7)==0) {
				char* token = wce_wctomb(lpszToken);
				//parseToken will allocate extra byte at the end of the returned token value
				char* path = parseToken( token, strlen(token) );
				if (path) {
					int len = strlen(path);
					if (!(path[len]=='\\' || path[len]=='/')) {
						path[len] = '\\';
						path[len+1]  = 0;
					}
					m_strRootPath = path;
					free(path);
				}
				free(token);
			}
#endif
			lpszToken = FindOneOf(lpszToken, szTokens);
		}

		return __super::ParseCommandLine(lpCmdLine, pnRetCode);
	}
Exemplo n.º 2
0
/** \brief Translate calendar time into readable string representation
 *
 * Possible Results:
 * - returns buf if buf != NULL
 * - returns NULL if buf == NULL
 */
os_size_t
os_ctimeW_r(
    os_timeW *t,
    char *buf,
    os_size_t bufsz)
{
    os_size_t result = 0;
    SYSTEMTIME systemTime;
    FILETIME systemTimeSince1601;
    DWORD64 dw64Time;
    DWORD64 dw64MAXDWORD = MAXDWORD;
    wchar_t format[32];
    char *fstr;

    /* Using win32 ctime here */
    if (buf)
    {
        int iSizeOfBuffer;

        dw64Time = (t->wt)/100;

        systemTimeSince1601.dwHighDateTime = (dw64Time / (dw64MAXDWORD+1));
        systemTimeSince1601.dwLowDateTime = (dw64Time % (dw64MAXDWORD+1));
        FileTimeToSystemTime(&systemTimeSince1601, &systemTime);

        /* Time is in UTC here */
        GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &systemTime, L"yyyy'-'MM'-'dd'T'HH':'mm':'ss", format, 32);
        /* convert wide str to multi byte str */
        fstr = wce_wctomb(format);
        result = snprintf(buf, bufsz, "%s", fstr);
        os_free(fstr);
    }
    return result;

}
Exemplo n.º 3
0
/* this is not Win32API. GetCommandLineA helper. */
void wce_SetCommandLine(LPCWSTR wcmd)
{
	char* acmd;

	acmd = wce_wctomb( wcmd );
	_commandLine = (char*)malloc( strlen(acmd)+5 );
	sprintf( _commandLine, "ruby %s", acmd );
	free(acmd);
}
Exemplo n.º 4
0
/* --------------------- etc, etc, etc... ----------------------- */
BOOL GetVersionExA(OSVERSIONINFOA *v)
{
	OSVERSIONINFOW wv;
	BOOL b;
	LPSTR mb;

	b = GetVersionExW(&wv);
	mb = wce_wctomb(wv.szCSDVersion);

	strcpy( v->szCSDVersion, mb );
	free(mb);
	return b;
}
Exemplo n.º 5
0
/*---------------- FindFirstFile, FindNextFile ------------------ */
static void copy_fund_data(WIN32_FIND_DATAA *data,WIN32_FIND_DATAW *wdata) {
	LPSTR mb;

  data->dwFileAttributes = wdata->dwFileAttributes;
  data->ftCreationTime = wdata->ftCreationTime;
  data->ftLastAccessTime = wdata->ftLastAccessTime;
  data->ftLastWriteTime = wdata->ftLastWriteTime;
  data->nFileSizeHigh = wdata->nFileSizeHigh;
  data->nFileSizeLow = wdata->nFileSizeLow;

  mb = wce_wctomb( wdata->cFileName );
	strcpy( data->cFileName, mb );
	free(mb);
}
Exemplo n.º 6
0
BOOL FindNextFileA(HANDLE handle,
	WIN32_FIND_DATAA *data)
{
	BOOL b;
	WIN32_FIND_DATAW wdata;
	LPSTR mb1;

	b = FindNextFileW(handle, &wdata);

	mb1 = wce_wctomb( wdata.cFileName );
	strcpy( data->cFileName, mb1 );
	free(mb1);

	return b;
}
Exemplo n.º 7
0
/* --------------- EnvironmentVariable functions. ----------------- */
DWORD GetEnvironmentVariable(
	LPCSTR name, LPSTR value, DWORD size)
{
    return 0;
#if 0
	/* use registry instead of "environment valuable". */
	HKEY	hk;
	LONG	lret;
	LPBYTE	lpData;
	DWORD	dwType=REG_SZ, cbData;
	TCHAR   buf[MAX_PATH]={0};
	LPWSTR  wname;
	LPSTR   avalue;

	lret = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
				_T("Software\\ruby_mswince"),
				0, KEY_QUERY_VALUE, &hk );

	if ( lret != ERROR_SUCCESS )
	{
		strcpy( value, "" );
		return 0;
	}

	lpData = (LPBYTE)buf;
	cbData = MAX_PATH*sizeof(*buf);
	wname  = wce_mbtowc( name );

	lret = RegQueryValueEx( hk, wname,
		NULL, &dwType, lpData, &cbData );
	RegCloseKey( hk );

	if ( lret != ERROR_SUCCESS )
	{
		strcpy( value, "" );
		free( wname );
		return 0;
	}

	avalue = wce_wctomb( (LPCTSTR)lpData );
	strcpy( value, avalue );
	free( avalue );
	free( wname );

	return strlen(value);
#endif //0
}
Exemplo n.º 8
0
/*---------------- FindFirstFile, FindNextFile ------------------ */
HANDLE FindFirstFileA(LPCSTR path,
			WIN32_FIND_DATAA *data)
{
	LPWSTR wpath;
	LPSTR  mb;
	HANDLE h;
	WIN32_FIND_DATAW wdata;

	wpath = wce_mbtowc(path);
	h = FindFirstFileW( wpath, &wdata );
	free(wpath);
	
	mb = wce_wctomb( wdata.cFileName );
	strcpy( data->cFileName, mb );
	free(mb);

	return h;
}
Exemplo n.º 9
0
DWORD GetModuleFileNameA( 
	HMODULE hModule, LPSTR lpFileName,
	DWORD size )
{
	LPWSTR lpFileNameW;
	LPSTR  mb;
	size_t ret;

	if( size==0 ) return 0;

	lpFileNameW = (LPWSTR)malloc( size*sizeof(wchar_t) );
	ret = GetModuleFileNameW( hModule, lpFileNameW, size );
	mb = wce_wctomb(lpFileNameW);
	strcpy(lpFileName, mb);
	free(mb);
	free(lpFileNameW);

	return ret;
}