23using std::ostringstream;
29 "HKEY_CURRENT_CONFIG",
57 string reg_key_and_remainder =
59 space_pos = reg_key_and_remainder.
find(
' ' );
61 string reg_key_name = reg_key_and_remainder.
substr( 0, space_pos );
97 for( string::iterator
i =
in.begin();
105 out <<
"%" << minibuf;
115 for( string::iterator
i =
in.begin();
123 if(
i !=
in.end() ) {
126 if(
i !=
in.end() ) {
148 for(
i = 0;
i < llen;
i++ ) {
150 (
data[
i] & 0xff) <<
" ";
156 for(
i = 0;
i < llen;
i++ ) {
157 if(
i <
len &&
i < llen &&
197 DWORD max_subkey_len;
199 DWORD max_value_name_len;
202 char *value_name_buf;
222 value_name_buf =
new char [max_value_name_len+1];
223 value_buf =
new char [max_value_len+1];
224 key_name_buf =
new char [max_subkey_len+1];
226 ending_slash =
key_name.rfind(
'/' );
227 if( ending_slash != string::npos )
228 up_level =
key_name.substr( 0, ending_slash );
230 text_out <<
"HTTP/1.0 200 OK\r\n"
231 <<
"Content-Type: text/html\r\n"
233 <<
"<html><head><title>Registry Key `"
235 <<
"'</title></head><body>\r\n"
236 <<
"<h1>Registry Key `" <<
key_name <<
"'</h1>\r\n"
237 <<
"<a href='/" <<
urlenc(up_level)
238 <<
"'>(Up one level)</a><p>\r\n"
239 <<
"<h2>Subkeys:</h2><table border='1'>\r\n";
244 for( which_index = 0; which_index < num_sub_keys; which_index++ ) {
245 key_name_size = max_subkey_len+1;
255 <<
urlenc(
string(key_name_buf,key_name_size)) <<
"'>"
256 <<
string(key_name_buf,key_name_size)
257 <<
"</a></td></tr>\r\n";
260 text_out <<
"</table><h2>Values:</h2><table border='1'>\r\n";
262 DWORD value_name_size;
263 DWORD value_data_size;
266 for( which_index = 0; which_index < num_values; which_index++ ) {
267 value_name_size = max_value_name_len+1;
268 value_data_size = max_value_len+1;
279 text_out <<
"<tr><td><b>" <<
string(value_name_buf,value_name_size)
285 text_out <<
"</ul></body></html>\r\n";
287 delete [] key_name_buf;
288 delete [] value_name_buf;
296 text_out <<
"HTTP/1.0 404 Not Found\r\n"
297 <<
"Content-Type: text/html\r\n"
299 <<
"<html><head><title>Can't find registry key `"
301 <<
"'</title></head><body>\r\n"
302 <<
"<H1>Can't find registry key `"
305 <<
"The registry key doesn't exist in the local registry.\r\n"
306 <<
"</body></html>\r\n";
315 text_out <<
"HTTP/1.0 200 OK\r\n"
316 <<
"Content-Type: text/html\r\n"
318 <<
"<html><head><title>Registry Browser</title></head>\r\n"
320 <<
"<H1>Registry Browser</H1>"
321 <<
"You can use this interface to browse the registry."
322 <<
"You will be presented with one registry key at a time and "
323 <<
"the decendents.\r\n"
324 <<
"<h2>Root Level</h2>\r\n"
325 <<
"Subkeys:<ul>\r\n";
333 text_out <<
"</ul></body></html>\r\n";
340 bool is_predefined_key =
true;
346 size_t slash = reg_key.
find(
'/' );
347 string reg_initial =
"";
349 if( slash == string::npos )
350 reg_initial = reg_key;
352 reg_initial = reg_key.
substr( 0, slash );
361 if( hRegKey != 0 && reg_initial != reg_key ) {
362 size_t start_of_reg_path = reg_initial.
size() + 1;
363 string reg_path = reg_key.
substr( start_of_reg_path,
364 reg_key.
size() - start_of_reg_path );
366 string reg_open_path = reg_path;
368 slash = reg_open_path.
find(
'/' );
369 string reg_single_key = reg_open_path;
371 if( slash != string::npos ) {
372 reg_single_key = reg_open_path.
substr( 0, slash );
373 reg_open_path = reg_open_path.
substr( slash+1,
374 reg_open_path.
size() );
377 HKEY oldKey = hRegKey;
387 is_predefined_key =
false;
388 }
while( slash != string::npos );
439 fd_set pollin,pollout,pollerr;
442 int port_to_listen = 80;
443 unsigned int active_fds = 0;
446 if(
string(
"-p" ) ==
argv[
i] ) {
461 active_fds = listen_socket + 1;
463 for( std::map<SOCKET,RequestHandler *>::iterator
i = requests.
begin();
466 if(
i->second->ShouldDie() ) {
476 if(
i->first > active_fds ) active_fds =
i->first + 1;
478 if(
i->second->WantPollout() )
FD_SET(
i->first,&pollout);
481 FD_SET(listen_socket,&pollin);
483 active_fds =
select( active_fds, &pollin, &pollout, &pollerr,
NULL );
485 if( active_fds > 0 ) {
486 if(
FD_ISSET(listen_socket,&pollin) ) {
493 for( std::map<SOCKET,RequestHandler *>::iterator
i = requests.
begin();
504 }
else i->second->RecvData(
string(
inbuf, rv ) );
507 i->second->OkToSend();
_STLP_PRIV _Ios_Manip_1< streamsize > _STLP_CALL setw(int __n)
_STLP_PRIV _Setfill_Manip< _CharT > _STLP_CALL setfill(_CharT __c)
static struct sockaddr_in sa
#define RegCloseKey(hKey)
void process_valid_request(HKEY open_reg_key, string key_name)
enum RequestHandler::_RHState RHState
string dump_one_line(const char *data, int llen, int len, int addr)
string present_value(DWORD type, const char *data, DWORD len)
string bindump(const char *data, int len)
@ REQUEST_RECVD_SENDING_REPLY
void process_request(string reg_key)
void RecvData(string input)
void process_root_request()
void process_invalid_request(string reg_key)
_Self substr(size_type __pos=0, size_type __n=npos) const
const _CharT * c_str() const
size_type find(const _Self &__s, size_type __pos=0) const
pair< iterator, bool > insert(const value_type &__x)
void erase(iterator __pos)
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
GLuint GLuint GLsizei GLenum type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum const GLvoid * addr
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_ _CRTIMP int __cdecl isalnum(_In_ int _C)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define sprintf(buf, format,...)
SOCKET make_listening_socket(int port)
const HKEY root_handles[]
const char * root_entries[]
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
#define HKEY_LOCAL_MACHINE
#define HKEY_CURRENT_CONFIG
#define HKEY_CURRENT_USER
#define HKEY_CLASSES_ROOT
#define FD_ISSET(fd, set)
int PASCAL FAR WSAGetLastError(void)
int PASCAL FAR WSACleanup(void)