2008-12-10 05:42:49 +01:00
/*
* This file is a part of CMSLU - - Content Management System like Unix
* and is not publicly distributed
*
* Copyright ( c ) 2008 , Tomasz Sowa
* All rights reserved .
*
*/
# ifndef headerfilerequest
# define headerfilerequest
# include <fcgiapp.h>
# include <sstream>
# include <vector>
# include "requesttypes.h"
# include "log.h"
# include "session.h"
# include "getparser.h"
# include "postparser.h"
# include "cookieparser.h"
# include "item.h"
# include "error.h"
struct Request
{
FCGX_Stream * in , * out , * err ;
FCGX_ParamArray env ; // defined as 'char **'
enum Method { get , post , none } method ;
// headers, page and debug
std : : ostringstream headers , page , debug ;
GetTable get_table ;
PostTable post_table ;
CookieTable cookie_table ;
2008-12-12 04:11:29 +01:00
// environment variables
// they are not null -- when the server doesn't have such a variable it will be pointing into 'char_empty' which is default '\0'
2008-12-10 05:42:49 +01:00
const char * env_request_method ;
const char * env_request_uri ;
const char * env_http_cookie ;
2008-12-11 03:46:16 +01:00
const char * env_remote_addr ;
2008-12-12 04:11:29 +01:00
const char * env_http_host ;
2008-12-10 05:42:49 +01:00
// current session
// is set after calling session_manager.SetSession()
Session * session ;
// 'done_status' is set if 'done' is different than 'nothing'
Error done_status ;
// what to do
2008-12-21 22:17:09 +01:00
enum Result { err_internal , err404 , err_per_denied , show_dir , show_item , show_item_by_id , add_item , edit_item , del_item , del_item_confirm , confirm , redirect , logout } result ; // zamienic na to_do
2008-12-14 06:28:28 +01:00
2008-12-10 05:42:49 +01:00
// current directory e.g. /foo/bar
std : : vector < Item > cur_dir_table ;
// id of the last directory (bar) or -1
long dir ;
// items in the current directory
// maybe without contents?
std : : vector < Item > item_table ;
// directories in the current directory
std : : vector < Item > dir_table ;
// this item is used for many purposes such as editing, adding an item etc.
Item item ;
// this string is used for many purposes such as redirecting
std : : string str ;
// for debugging
void PrintGetTable ( ) ;
void PrintEnv ( ) ;
void PrintIn ( ) ;
Request ( ) ;
void Clear ( ) ;
void SetCookie ( const char * name , const char * value ) ;
void SetCookie ( const char * name , long value ) ;
bool IsPostVar ( const char * var ) ;
std : : string & PostVar ( const char * var ) ; // with a throw
// item_table[0] -> item
void CopyFirstItem ( ) ;
void ReadEnvVariables ( ) ;
void CheckMethod ( ) ;
void ReadParameters ( ) ;
void Read ( ) ;
void SendAll ( ) ;
2008-12-21 22:17:09 +01:00
bool CanChangeUser ( const Item & item , long new_user_id ) ;
bool CanChangeGroup ( const Item & item , long new_group_id ) ;
bool CanChangePrivileges ( const Item & item , int new_priv ) ;
bool HasAccess ( const Item & item , int mask ) ;
bool HasReadAccess ( const Item & item ) ;
bool HasWriteAccess ( const Item & item ) ;
bool HasReadWriteAccess ( const Item & item ) ;
2008-12-22 17:03:03 +01:00
bool HasReadExecAccess ( const Item & item ) ;
2008-12-21 22:17:09 +01:00
2008-12-12 04:11:29 +01:00
private :
// used to set some env_* variables into it, when the server didn't set that variable
// it contains '\0'
const char char_empty ;
const char * SetEnvVar ( const char * var ) ;
2008-12-10 05:42:49 +01:00
} ;
extern Request request ;
# endif