Exemple #1
0
BOOL SetEnvironmentVariable(LPCSTR name, LPCSTR value)
{
    return FALSE;
#if 0
	/* use registry instead of "environment valuable". */
	HKEY	hk;
	LONG	lret;
	LPBYTE	lpData;
	DWORD	ret, dwType=REG_SZ, cbData;
	LPWSTR  wname, wvalue;

	lret = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
			_T("Software\\ruby_mswince"),
			0, _T(""), 0,
			0, NULL, &hk, &ret );
	if( lret != ERROR_SUCCESS )
		return FALSE;

	wname  = wce_mbtowc(name);
	wvalue = wce_mbtowc(value);

	lpData = (LPBYTE)wvalue;
	cbData = (wcslen(wvalue) + 1) * sizeof(*wvalue);
	lret = RegSetValueEx( hk, wname,
		0, dwType, lpData, cbData );
	RegCloseKey( hk );
	free(wname);
	free(wvalue);
	return lret == ERROR_SUCCESS;
#endif //0
}
Exemple #2
0
/* ---------------  move and remove functions. ------------------- */
BOOL MoveFileA(LPCSTR fn1, LPCSTR fn2)
{
	LPWSTR wfn1, wfn2;
	BOOL b;

	wfn1 = wce_mbtowc(fn1);
	wfn2 = wce_mbtowc(fn2);
	b = MoveFileW(wfn1, wfn2);
	free(wfn1);
	free(wfn2);
	return 0;
}
Exemple #3
0
/* strnicmp already exists in stdlib.h? */
int strnicmp( const char *s1, const char *s2, size_t count )
{
	wchar_t *w1, *w2;
	int n;

	w1 = wce_mbtowc(s1);
	w2 = wce_mbtowc(s2);

	n = wcsnicmp(w1, w2, count);

	free(w1);
	free(w2);

	return n;
}
Exemple #4
0
int stricmp( const char *s1, const char *s2 )
{
	wchar_t *w1, *w2;
	int n;

	w1 = wce_mbtowc(s1);
	w2 = wce_mbtowc(s2);

	n = wcsicmp(w1, w2);

	free(w1);
	free(w2);

	return n;
}
Exemple #5
0
int _rename(const char *oldname, const char *newname)
{
	wchar_t *wold, *wnew;
	BOOL rc;

	wold = wce_mbtowc(oldname);
	wnew = wce_mbtowc(newname);

	/* replace with MoveFile. */
	rc = MoveFileW(wold, wnew);

	free(wold);
	free(wnew);

	return rc==TRUE ? 0 : -1;
}
Exemple #6
0
/* replace "open" with "CreateFile", etc. */
int _open(const char *file, int mode, va_list arg)
{
	wchar_t *wfile;
	DWORD access=0, share=0, create=0, lasterror = 0;
	HANDLE h;

	if( (mode&_O_RDWR) != 0 )
		access = GENERIC_READ|GENERIC_WRITE;
	else if( (mode&_O_WRONLY) != 0 )
		access = GENERIC_WRITE;
	else //if( (mode&_O_RDONLY) != 0 )
		access = GENERIC_READ;

	if( (mode&_O_CREAT) != 0 )
		create = CREATE_ALWAYS;
	else
		create = OPEN_ALWAYS;

	wfile = wce_mbtowc(file);

	h = CreateFileW(wfile, access, share, NULL,
			create, 0, NULL );
  
  lasterror = GetLastError();
	
  free(wfile);
	return (int)h;
}
Exemple #7
0
void delete_winmo_session(const char *url_string) {
  BOOL bReturn;
  // Delete the session cookie.
  LPTSTR url = wce_mbtowc(url_string);
  bReturn = InternetSetCookie(url, NULL, L"");
  free(url);
}
Exemple #8
0
HANDLE FindFirstFileA(LPCSTR path,
			WIN32_FIND_DATAA *data)
{
	LPWSTR wpath;
	HANDLE h;
    WIN32_FIND_DATAW wdata = {0};
    int i = 0;
    DWORD dwErr = 0;
	wpath = wce_mbtowc(path);
    for( i = 0; wpath[i]; i++)
    {
        if ( wpath[i] == L'/' )
            wpath[i] = L'\\';
    }

    //if ( wpath[wcslen(wpath)-1] == '*')  //wince does not support *
    //    wpath[wcslen(wpath)-1] = 0;

	h = FindFirstFileW( wpath, &wdata );
    dwErr = GetLastError();
    if ( h == INVALID_HANDLE_VALUE && dwErr == 18)
        h = 0;
	free(wpath);
	
    copy_fund_data(data,&wdata);

	return h;
}
Exemple #9
0
BOOL MoveFileEx(LPCSTR oldname, LPCSTR newname, DWORD dwFlags)
{
	LPWSTR woldname, wnewname;
	BOOL b;

	woldname = wce_mbtowc(oldname);
	wnewname = wce_mbtowc(newname);

	if( (dwFlags&MOVEFILE_REPLACE_EXISTING)!=0 )
		DeleteFileW( wnewname );

	b = MoveFileW( woldname, wnewname );

	free(woldname);
	free(wnewname);

	return b;
}
Exemple #10
0
char *strpbrk(const char *str, const char *cs)
{
	wchar_t *wstr, *wcs, *w;
	char *s = NULL;

	wstr = wce_mbtowc(str);
	wcs  = wce_mbtowc(cs);

	w = wcspbrk(wstr, wcs);

	if( w!=NULL )
		s = str + (wcs-wstr)/sizeof(wchar_t);

	free(wstr);
	free(wcs);

	return s;
}
Exemple #11
0
BOOL DeleteFileA(LPCSTR path)
{ 
	LPWSTR wpath;
	BOOL b;

	wpath = wce_mbtowc(path);
	b = DeleteFileW(wpath);
	free(wpath);
	return 0;
}
Exemple #12
0
/* --------------  file attributes functions. ------------------- */
DWORD GetFileAttributesA(LPCSTR lpFileName)
{
	LPWSTR lpwFileName;
	DWORD dw;

	lpwFileName = wce_mbtowc(lpFileName);
	dw = GetFileAttributesW(lpwFileName);
	free(lpwFileName);
	return dw;
}
Exemple #13
0
	void DoViewNavigate(char* url) {
		char* canonical_url = canonicalizeURL(url);
		if (canonical_url) {
			::PostMessage(m_appWindow.m_hWnd,WM_COMMAND,IDM_NAVIGATE,(LPARAM)wce_mbtowc(canonical_url));
			free(canonical_url);
		}
		//LPTSTR wcurl = wce_mbtowc(url);
		//m_appWindow.Navigate2(wcurl);
		//free(wcurl);
	}
Exemple #14
0
FARPROC GetProcAddressA(HMODULE hModule, LPCSTR lpProcName)
{
	FARPROC p;
	LPWSTR  lpwProcName;

	lpwProcName = wce_mbtowc( lpProcName );
	p = GetProcAddressW( hModule, lpwProcName );
	free( lpwProcName );
	return p;
}
Exemple #15
0
BOOL SetFileAttributesA(
	LPCSTR lpFileName, DWORD attributes) 
{
	LPWSTR lpwFileName;
	BOOL b;

	lpwFileName = wce_mbtowc(lpFileName);
	b = SetFileAttributesW(lpwFileName, attributes);
	free(lpwFileName);
	return b;
}
Exemple #16
0
int _unlink(const char *file)
{
	wchar_t *wfile;
	BOOL rc;

	/* replace with DeleteFile. */
	wfile = wce_mbtowc(file);
	rc = DeleteFileW(wfile);
	free(wfile);

	return rc==TRUE ? 0 : -1;
}
Exemple #17
0
void CAppManager::ReloadRhoBundle(const char* szUrl, const char* szZipPassword)
{
	if ( szUrl )
	{
		//get zip file with rhodes
		DWORD dwDataSize = 0;
		char* zipData = remote_data( L"GET", const_cast<char*>(szUrl), NULL, 0, false, true, false, &dwDataSize );

		LPWSTR rootw = wce_mbtowc(RhoGetRootPath());  

		//TODO: Add error handling
		if ( zipData && dwDataSize > 0 )
		{
			ZIPENTRY ze; 
			// Open zip file
			HZIP hz = OpenZip(zipData, dwDataSize, szZipPassword);
			
			if ( hz )
			{
				//Stop HTTP Server
				CHttpServer::Instance()->FreezeThread();

				// Set base for unziping
				SetUnzipBaseDir(hz, rootw);
				
				// Get info about the zip
				// -1 gives overall information about the zipfile
				GetZipItem(hz,-1,&ze);
				int numitems = ze.index;
				
				// Iterate through items and unzip them
				for (int zi = 0; zi<numitems; zi++)
				{ 
					// fetch individual details, e.g. the item's name.
					GetZipItem(hz,zi,&ze); 
					// unzip item
					UnzipItem(hz, zi, ze.name);         
				}
				
				CloseZip(hz);

				//Show MessageBox
				MessageBox(NULL, _T("Rhobundle has been updated successfully.\n\nPlease restart application."), _T("Information"), MB_OK | MB_ICONINFORMATION );
			}
		}

		if ( rootw )
			free(rootw);

		if ( zipData )
			delete zipData;
	}
}
Exemple #18
0
int _rmdir(const char * dir)
{
	wchar_t *wdir;
	BOOL rc;

	/* replace with RemoveDirectory. */
	wdir = wce_mbtowc(dir);
	rc = RemoveDirectoryW(wdir);
	free(wdir);

	return rc==TRUE ? 0 : -1;
}
Exemple #19
0
int _mkdir(const char * dir)
{
	wchar_t* wdir;
	BOOL rc;

	/* replace with CreateDirectory. */
	wdir = wce_mbtowc(dir);
	rc = CreateDirectoryW(wdir, NULL);
	free(wdir);

	return rc==TRUE ? 0 : -1;
}
Exemple #20
0
HANDLE CreateEventA(SECURITY_ATTRIBUTES *sa, 
	BOOL manual_reset, BOOL initial_state, LPCSTR name)
{
	HANDLE h;
	LPWSTR wname;

	wname = wce_mbtowc(name);
	h = CreateEventW(sa, manual_reset,
		initial_state, wname);
	free(wname);

	return h;
}
Exemple #21
0
BOOL CreateProcessA(LPCSTR appname, LPCSTR commandline,
	LPSECURITY_ATTRIBUTES att, LPSECURITY_ATTRIBUTES threadatt,
	BOOL bOpt, DWORD dwFlag, LPVOID lpEnv, LPSTR dir,
	LPSTARTUPINFO lpsi, LPPROCESS_INFORMATION lppi)
{
	LPWSTR wappname, wcommandline, wdir;
	BOOL b;

	wappname     = wce_mbtowc(appname);
	wcommandline = wce_mbtowc(commandline);
	wdir         = wce_mbtowc(dir);

	b = CreateProcessW(wappname, wcommandline,
			att, threadatt, bOpt, dwFlag, lpEnv,
			wdir, lpsi, lppi);

	free(wappname);
	free(wcommandline);
	free(wdir);

	return b;
}
Exemple #22
0
static HANDLE createNewHandle (os_cond * cond)
{
    HANDLE result = NULL;
    char name[OS_SERVICE_ENTITY_NAME_MAX];
    wchar_t* wStringName;

    _snprintf(name, sizeof(name), "%s%d%d",
                OS_SERVICE_SEM_NAME_PREFIX, cond->qId, os_getShmBaseAddressFromPointer(cond));
    wStringName = wce_mbtowc(name);
    result = CreateSemaphore(NULL, 0, 0x7fffffff, wStringName);
    os_free (wStringName);

    return result;
}
Exemple #23
0
DWORD FormatMessageA(DWORD dwFlags, LPCVOID lpSource, 
	DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, 
	DWORD nSize, va_list* args)
{
	DWORD dw;
	LPWSTR lpWBuffer;

	lpWBuffer = wce_mbtowc(lpBuffer);
	dw = FormatMessageW( dwFlags, lpSource,
			dwMessageId, dwLanguageId,
			lpWBuffer, nSize, (va_list*)args );
	free(lpWBuffer);
	return dw;
}
Exemple #24
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
}
Exemple #25
0
HRESULT Camera::takePicture(HWND hwndOwner,LPTSTR pszFilename) 
{
    HRESULT         hResult = S_OK;
#if defined(_WIN32_WCE)
    SHCAMERACAPTURE shcc;

    wchar_t* root  = wce_mbtowc(rho_rhodesapp_getblobsdirpath());
    wsprintf(pszFilename,L"%s",root );
    free(root);

	create_folder(pszFilename);

    //LPCTSTR szExt = wcsrchr(pszFilename, '.');
    TCHAR filename[256];
	generate_filename(filename,L".jpg");

    // Set the SHCAMERACAPTURE structure.
    ZeroMemory(&shcc, sizeof(shcc));
    shcc.cbSize             = sizeof(shcc);
    shcc.hwndOwner          = hwndOwner;
    shcc.pszInitialDir      = pszFilename;
    shcc.pszDefaultFileName = filename;
    shcc.pszTitle           = TEXT("Camera");
    shcc.VideoTypes			= CAMERACAPTURE_VIDEOTYPE_MESSAGING;
    shcc.nResolutionWidth   = 176;
    shcc.nResolutionHeight  = 144;
    shcc.nVideoTimeLimit    = 15;
    shcc.Mode               = CAMERACAPTURE_MODE_STILL;

    // Display the Camera Capture dialog.
    hResult = SHCameraCapture(&shcc);

    // The next statements will execute only after the user takes
    // a picture or video, or closes the Camera Capture dialog.
    if (S_OK == hResult) {
        LPTSTR fname = get_file_name(shcc.szFile,pszFilename);
		if (fname) {
			StringCchCopy(pszFilename, MAX_PATH, fname);
			free(fname);
		} else {
			hResult = E_INVALIDARG;
		}
    }
#endif //_WIN32_WCE

    return hResult;
}
Exemple #26
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;
}
Exemple #27
0
HRESULT Camera::selectPicture(HWND hwndOwner,LPTSTR pszFilename) {
	RHO_ASSERT(pszFilename);
	OPENFILENAMEEX ofn = {0};

	ofn.lStructSize     = sizeof(ofn);
	ofn.lpstrFilter     = NULL;
	ofn.lpstrFile       = pszFilename;
	ofn.nMaxFile        = MAX_PATH;
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrTitle      = _T("Select an image");
	ofn.ExFlags         = OFN_EXFLAG_THUMBNAILVIEW|OFN_EXFLAG_NOFILECREATE|OFN_EXFLAG_LOCKDIRECTORY;

	if (GetOpenFileNameEx(&ofn)) {
		HRESULT hResult = S_OK;

		TCHAR rhoroot[MAX_PATH];
		wchar_t* root  = wce_mbtowc(RhoGetRootPath());
		wsprintf(rhoroot,L"%s%s",root,L"apps\\public\\db-files");
		free(root);

		create_folder(rhoroot);

		TCHAR filename[256];
		generate_filename(filename);
		
		int len = wcslen(rhoroot) + wcslen(L"\\") + wcslen(filename);
		wchar_t* full_name = (wchar_t*) malloc((len+2)*sizeof(wchar_t));
		wsprintf(full_name,L"%s\\%s",rhoroot,filename);

		if (copy_file(pszFilename,full_name)) {
			StringCchCopy(pszFilename, MAX_PATH, filename);	
		} else {
			hResult = E_INVALIDARG;
		}

		free(full_name);

		return hResult;
	} else if (GetLastError()==ERROR_SUCCESS) {
		return S_FALSE; //user cancel op
	}
	return E_INVALIDARG;
}
Exemple #28
0
/* replace "open" with "CreateFile", etc. */
int _open(const char *path, int oflag, va_list arg)
{
    DWORD fileaccess = 0;               /* OS file access (requested) */
    DWORD fileshare = 0;                /* OS file sharing mode */
    DWORD filecreate = 0;               /* OS method of opening/creating */
    DWORD fileattrib = 0;               /* OS file attribute flags */
    SECURITY_ATTRIBUTES SecurityAttributes;
    HANDLE osfh;
    DWORD lasterror = 0;
    wchar_t *wfile = 0;
    int fNumber = -1;

    SecurityAttributes.nLength = sizeof( SecurityAttributes );
    SecurityAttributes.lpSecurityDescriptor = NULL;

    if (oflag & _O_NOINHERIT) {
        SecurityAttributes.bInheritHandle = FALSE;
    }else {
        SecurityAttributes.bInheritHandle = TRUE;
    }

    /*
     * decode the access flags
     */
    switch( oflag & (_O_RDONLY | _O_WRONLY | _O_RDWR) ) {

        case _O_RDONLY:         /* read access */
                fileaccess = GENERIC_READ;
                fileshare = FILE_SHARE_READ;

                break;
        case _O_WRONLY:         /* write access */
                /* giving it read access as well
                 * because in append (a, not a+), we need
                 * to read the BOM to determine the encoding
                 * (ie. ANSI, UTF8, UTF16)
                 */
                if ((oflag & _O_APPEND) /*&& (oflag & (_O_WTEXT | _O_U16TEXT | _O_U8TEXT)) != 0*/ )
                {
                    fileaccess = GENERIC_READ | GENERIC_WRITE;
                }
                else
                {
                    fileaccess = GENERIC_WRITE;
                }
                break;
        case _O_RDWR:           /* read and write access */
                fileaccess = GENERIC_READ | GENERIC_WRITE;
                break;
    }

    /*
     * decode open/create method flags
     */
    switch ( oflag & (_O_CREAT | _O_EXCL | _O_TRUNC) ) {
        case 0:
        case _O_EXCL:                   // ignore EXCL w/o CREAT
            filecreate = OPEN_EXISTING;
            break;

        case _O_CREAT:
            filecreate = OPEN_ALWAYS;
            break;

        case _O_CREAT | _O_EXCL:
        case _O_CREAT | _O_TRUNC | _O_EXCL:
            filecreate = CREATE_NEW;
            break;

        case _O_TRUNC:
        case _O_TRUNC | _O_EXCL:        // ignore EXCL w/o CREAT
            filecreate = TRUNCATE_EXISTING;
            break;

        case _O_CREAT | _O_TRUNC:
            filecreate = CREATE_ALWAYS;
            break;
    }

    /*
     * decode file attribute flags if _O_CREAT was specified
     */
    fileattrib = FILE_ATTRIBUTE_NORMAL;     /* default */

    fNumber = get_NewFileNumber();
    if ( fNumber == 0 )
        return -1;

    wfile = wce_mbtowc(path);
    if ( (osfh = CreateFileW( wfile,
                             fileaccess,
                             fileshare,
                             &SecurityAttributes,
                             filecreate,
                             fileattrib,
                             NULL )) == INVALID_HANDLE_VALUE  )
    {
        if ((fileaccess & (GENERIC_READ | GENERIC_WRITE)) == (GENERIC_READ | GENERIC_WRITE) &&
                (oflag & _O_WRONLY))
        {
            fileaccess &= ~GENERIC_READ;
            osfh = CreateFileW( wfile,
                     fileaccess,
                     fileshare,
                     &SecurityAttributes,
                     filecreate,
                     fileattrib, NULL );
        }
    }

    lasterror = GetLastError();
    free(wfile);

    if ( osfh != INVALID_HANDLE_VALUE  )
    {
        set_FileNumber(fNumber, osfh);
        return fNumber;
    }

    return -1;
}
Exemple #29
0
char* remote_data(LPWSTR verb, char* url, char* body, size_t body_size, 
				  bool bGetHeaders, bool bGetRawData = false, bool bCheckSession = false, DWORD* pdwDataSize = NULL) {
  char       *cstr = NULL;
  char		 *session = NULL;
  std::string data = "";
  //CAtlStringA data;
  char        sBuf[1024];
  DWORD       dwBytesRead  = 0;
  LPWSTR      urlw;
  HINTERNET   hInet, hConnection, hRequest;
  LPTSTR      pszFunction = NULL;

  if ( url==NULL || strlen(url)==0 ) return NULL;

  urlw = wce_mbtowc(url);  
  hInet = hConnection = hRequest = NULL;

  do {
	  // Don't make a connection attempt if there is no session
    session = get_db_session(load_source_url());
	  if ( bCheckSession && !session && !strstr(url, "clientcreate") ) {
	    break;
	  }
	  if (session) free(session);

    if( !SetupInternetConnection(urlw) ) {
      break;
    }

    hInet = InternetOpen(_T("rhodes-wm"), 
      INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
    if ( !hInet ) {
      pszFunction = L"InternetOpen";
      break;
    }

    DWORD lpdwBufferLength = sizeof(sBuf)/sizeof(wchar_t);
    if ( !InternetCanonicalizeUrl(urlw, (LPWSTR)sBuf, &lpdwBufferLength, 0) ) {
      pszFunction = L"InternetCanonicalizeUrl";
      break;
    }

    ATLTRACE(L"Connecting to url: %s\n",(LPWSTR)sBuf);

    URL_COMPONENTS uri;
    alloc_url_components(&uri,url);
    if( !InternetCrackUrl((LPWSTR)sBuf,lpdwBufferLength,0,&uri) ) {
      pszFunction = L"InternetCrackUrl";
      free_url_components(&uri);
      break;
    }

    hConnection = InternetConnect( hInet, 
      uri.lpszHostName, uri.nPort, _T("anonymous"), NULL, 
      INTERNET_SERVICE_HTTP, 0, 0 );
    if ( !hConnection ) {
      pszFunction = L"InternetConnect";
      free_url_components(&uri);
      break;
    }

    wsprintf((LPWSTR)sBuf,L"%s%s",uri.lpszUrlPath,uri.lpszExtraInfo);
    hRequest = HttpOpenRequest( hConnection, verb, 
      (LPWSTR)sBuf, NULL, NULL, NULL, 
      INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE, NULL );
    if ( !hRequest ) {
      pszFunction = L"HttpOpenRequest";
      free_url_components(&uri);
      break;
    }

    free_url_components(&uri);

    //Send data
    if ( HttpSendRequest( hRequest, NULL, 0, body, body_size) ) {
      wchar_t res[10];
      DWORD dwLen = 10;
      DWORD nIndex = 0;
      bool bOk = false;
      if( HttpQueryInfo(hRequest,HTTP_QUERY_STATUS_CODE,res,&dwLen,&nIndex) ){
        if ( wcscmp(res,L"200") == 0 )
          bOk = true;
		else {
          bOk = false;
		  // If we're unauthorized, delete any cookies that might have been
		  // stored so we don't reuse them later
		  if ( wcscmp(res,L"401") == 0 ) delete_winmo_session(load_source_url());
		}
      }

      if ( bOk ){
        if ( bGetHeaders ){
          DWORD dwSize = 0;
	        HttpQueryInfo(hRequest, HTTP_QUERY_RAW_HEADERS, NULL, &dwSize, NULL);
	        if( dwSize != 0 )
	        {
		        cstr = new char [dwSize+1];
		        // Call HttpQueryInfo again to get the headers.
		        bOk = (bool) HttpQueryInfoA(hRequest, HTTP_QUERY_RAW_HEADERS, (LPVOID) cstr, &dwSize, NULL);
          }
        }else{
          BOOL bRead = InternetReadFile(hRequest, &sBuf, sizeof(sBuf), &dwBytesRead);
          while (bRead && (dwBytesRead > 0)) {
            data.append(sBuf, dwBytesRead);
            //data.Append(sBuf, dwBytesRead);
            bRead = InternetReadFile(hRequest, &sBuf, sizeof(sBuf), &dwBytesRead);
          }
		      if ( bGetRawData && pdwDataSize ){
			      cstr = new char [*pdwDataSize];
            memcpy (cstr, data.c_str(), *pdwDataSize);
		      }
		      else {
			      //make a copy of recieved data
			      cstr = new char [data.size()+1];
			      strcpy (cstr, data.c_str());
            //cstr = new char [data.GetLength()+1];
            //strcpy (cstr, data.GetString());
		      }
        }
      }
    } else {
      pszFunction = L"HttpOpenRequest";
    }

  } while(0);

  if (pszFunction) {
    ErrorMessage(pszFunction);
  }

  if(hRequest) InternetCloseHandle(hRequest);
  if(hConnection) InternetCloseHandle(hConnection);
  if(hInet) InternetCloseHandle(hInet);

  free(urlw);
  return cstr;
}
Exemple #30
0
	strcpy( data->cFileName, mb1 );
	free(mb1);

	return b;
}

/* CreateFile doesn't support SECURITY_ATTRIBUTES in WinCE. */
/* it must be NULL. */
HANDLE CreateFileA(LPCSTR filename, DWORD access,
	DWORD sharing, LPSECURITY_ATTRIBUTES sa,
	DWORD creation, DWORD attributes, HANDLE template)
{
	LPWSTR wfilename;
	HANDLE h;

	wfilename = wce_mbtowc(filename);
	h = CreateFileW(wfilename, access, sharing,
			NULL, creation, 0, NULL);
	free(wfilename);

	return 0;
}

/* ---------------- CharNext, CharPrev. ---------------------*/
LPSTR CharNextA(LPCSTR a)
{
	char *p=(char *)a;
	if( TRUE==IsDBCSLeadByteEx(CP_ACP, (BYTE)*a) )
		p+=2;
	else
		p++;