Ejemplo n.º 1
0
void build() {
		const char * request_method = cgi_request::get_request_method();
		
		if( !strcmp("GET", request_method) || !strcmp("POST", request_method) || !strcmp("PUT", request_method) ) {

				if( NULL != cgi_request::get_param_string("new") ) {
						handler_new();
						return;
				}

				const char * t_path_info = cgi_request::get_path_info();

				if( NULL == t_path_info || strlen(t_path_info) <= 1 ) {
						handler_redirect_homepage();
						return;
				}

				const char * tmp = util_htmlize(t_path_info, strlen(t_path_info));
				if( NULL == tmp )
						throw std::bad_alloc();
				ByteString_t path_info;
				try {
						path_info.append(tmp);
				} catch(...) {
						delete [] tmp;
						throw;
				}
				delete [] tmp;

				if( strlen("/favicon.ico") == path_info.length() &&	!memcmp("/favicon.ico", path_info.array(), path_info.length())  ) {
						handler_favicon();
						return;
				}

				if( strlen("/styles") == path_info.length() &&!memcmp("/styles", path_info.array(), path_info.length()) ) {
						handler_styles();
						return;
				}

				if( NULL != cgi_request::get_param_string("edit") ) {
						handler_edit(path_info);
						return;
				}

				handler_page(path_info);

				return;
				
		} else {
				cgi_responde::set_status( cgi_responde::status_501_not_implemented );
				cgi_responde::set_content_type( mime_text_plain );
				cgi_responde::append( cgi_responde::status_501_not_implemented );
				return;
		}
}
Ejemplo n.º 2
0
HrtThreadPool*
hrt_thread_pool_new_func (GFunc                      handler_func,
                          void                      *handler_data,
                          GDestroyNotify             handler_data_dnotify)
{
    Handler *handler;

    handler = handler_new(handler_func, handler_data,
                          handler_data_dnotify);

    return hrt_thread_pool_new(&handler_vtable,
                               handler,
                               handler_free);
}