You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.0 KiB
96 lines
2.0 KiB
/*
|
|
* http.cpp
|
|
*
|
|
* These routines are exported to privately support the
|
|
* debugger's http source lookup cababilities.
|
|
*/
|
|
|
|
#include "pch.h"
|
|
#include "store.hpp"
|
|
|
|
BOOL
|
|
httpOpenFileHandle(
|
|
IN LPCSTR srv,
|
|
IN LPCSTR path,
|
|
IN DWORD options,
|
|
OUT HANDLE *hsite,
|
|
OUT HANDLE *hfile
|
|
)
|
|
{
|
|
CHAR file[MAX_PATH + 1];
|
|
CHAR srvsite[MAX_PATH + 1];
|
|
CHAR trgfile[MAX_PATH + 1];
|
|
DWORD type;
|
|
StoreHTTP *store;
|
|
|
|
if (strstr(path, "dll.c"))
|
|
dprint("%s\n", path);
|
|
|
|
if (srv && *srv) {
|
|
CopyStrArray(srvsite, srv);
|
|
if (strstr(path, srvsite) == path)
|
|
CopyStrArray(file, path + strlen(srvsite) + 1);
|
|
else
|
|
CopyStrArray(file, path);
|
|
ConvertBackslashes(file);
|
|
type = GetStoreType(srvsite);
|
|
} else {
|
|
type = ParsePath(path, srvsite, file, NULL, false);
|
|
}
|
|
if (type != stHTTP && type != stHTTPS) {
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
return false;
|
|
}
|
|
|
|
store = (StoreHTTP *)FindStore(srvsite);
|
|
if (!store) {
|
|
store = (StoreHTTP *)AddStore(srvsite);
|
|
if (!store)
|
|
return false;
|
|
}
|
|
|
|
if (!store->init())
|
|
return false;
|
|
|
|
if (!store->open(NULL, file))
|
|
return false;
|
|
|
|
*hsite = store->hsite();
|
|
*hfile = store->hfile();
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
BOOL
|
|
httpQueryDataAvailable(
|
|
IN HINTERNET hFile,
|
|
OUT LPDWORD lpdwNumberOfBytesAvailable OPTIONAL,
|
|
IN DWORD dwFlags,
|
|
IN DWORD_PTR dwContext
|
|
)
|
|
{
|
|
return InternetQueryDataAvailable(hFile, lpdwNumberOfBytesAvailable, dwFlags, dwContext);
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
httpReadFile(
|
|
IN HINTERNET hFile,
|
|
IN LPVOID lpBuffer,
|
|
IN DWORD dwNumberOfBytesToRead,
|
|
OUT LPDWORD lpdwNumberOfBytesRead
|
|
)
|
|
{
|
|
return InternetReadFile(hFile, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead);
|
|
}
|
|
|
|
|
|
BOOL
|
|
httpCloseHandle(
|
|
IN HINTERNET hInternet
|
|
)
|
|
{
|
|
return InternetCloseHandle(hInternet);
|
|
}
|