Defines | Typedefs | Functions | Variables

Beesnest/DcGlobals.h File Reference

#include <stdlib.h>
#include <time.h>
#include <fstream>
#include <iostream>
#include <map>
#include <list>
#include <vector>
#include <set>
#include <string>
#include "DcString.h"

Go to the source code of this file.

Defines

#define OS_NAME   Windows
#define _INCLUDE_PATH(file_name)   OS_NAME/file_name
#define _CALL_QUOTE_PATH(path)   _QUOTE_PATH(path)
#define _QUOTE_PATH(path)   #path
#define _GET_INCLUDE_PATH(file_name)   _CALL_QUOTE_PATH(_INCLUDE_PATH(file_name))
#define BUFF_LEN   256
#define CRLF   "\r\n"
#define CRLF_SIZE   2
#define CRLFCRLF   "\r\n\r\n"
#define CRLFCRLF_SIZE   4
#define POST   "POST"
#define GET   "GET"
#define HEAD   "HEAD"
#define SERVER_NAME   "Beesnest HTTP 1.1 Server/1.0"
#define PROTOCOL11_VRS   "HTTP/1.1"
#define PROTOCOL10_VRS   "HTTP/1.0"
#define CONTINUE_MSG   "HTTP/1.1 100 Continue"
#define OVRLOAD_MSG   "HTTP/1.1 503 Service Unavailable\r\n\r\n"
#define OVRLOAD_MSG_LEN   40
#define TIME_FORMAT   "%a, %d %b %Y %H:%M:%S GMT"
#define PARM_SEP   "->"
#define PARM_SEP_LEN   2
#define PARM_FILE_EXT   "bnc"
#define SCRIPT_STR   "<bnscript"
#define SCRIPT_STR_LEN   9
#define SCRIPT_END   "</bnscript"
#define SCRIPT_END_LEN   10
#define SCRIPT_TRM   '>'
#define DEL_CMD   "delete"
#define DEL_CMD_LEN   6
#define PS_GEN   1
#define PS_LOG   2
#define PS_SEC   3
#define PS_TRD   4
#define PS_DBG   5

Typedefs

typedef map< string, string > t_map
 Map to store header fields values, variables and parameters.
typedef t_map::iterator t_itr
typedef t_map::const_iterator t_const_itr
typedef unsigned int uint

Functions

const CdcString EMPTY_STR ("")
int ProgramMain ()
 This is the real main function of the server.
void InitProgram ()
 Initialize classes of the server by calling some class static functions.
void ControlUsers (int argc, char *argv[])
 Add, Change password and Remove users from the users database.
void PrintString (CdcString str, int level=0)
 Thread safe function to print a messages to the console and/or log file.
void main (int argc, char *argv[])
 The Main function.

Variables

const CdcString CONTROLED_HEADERS = "Cache-Control, Connection, Server"

Define Documentation

#define _CALL_QUOTE_PATH (   path )    _QUOTE_PATH(path)

Definition at line 29 of file DcGlobals.h.

#define _GET_INCLUDE_PATH (   file_name )    _CALL_QUOTE_PATH(_INCLUDE_PATH(file_name))

Definition at line 31 of file DcGlobals.h.

#define _INCLUDE_PATH (   file_name )    OS_NAME/file_name

Definition at line 28 of file DcGlobals.h.

#define _QUOTE_PATH (   path )    #path

Definition at line 30 of file DcGlobals.h.

#define BUFF_LEN   256

Definition at line 58 of file DcGlobals.h.

#define CONTINUE_MSG   "HTTP/1.1 100 Continue"

Definition at line 69 of file DcGlobals.h.

#define CRLF   "\r\n"

Definition at line 59 of file DcGlobals.h.

#define CRLF_SIZE   2

Definition at line 60 of file DcGlobals.h.

#define CRLFCRLF   "\r\n\r\n"

Definition at line 61 of file DcGlobals.h.

#define CRLFCRLF_SIZE   4

Definition at line 62 of file DcGlobals.h.

#define DEL_CMD   "delete"

Definition at line 82 of file DcGlobals.h.

#define DEL_CMD_LEN   6

Definition at line 83 of file DcGlobals.h.

#define GET   "GET"

Definition at line 64 of file DcGlobals.h.

#define HEAD   "HEAD"

Definition at line 65 of file DcGlobals.h.

#define OS_NAME   Windows

Definition at line 24 of file DcGlobals.h.

#define OVRLOAD_MSG   "HTTP/1.1 503 Service Unavailable\r\n\r\n"

Definition at line 70 of file DcGlobals.h.

#define OVRLOAD_MSG_LEN   40

Definition at line 71 of file DcGlobals.h.

#define PARM_FILE_EXT   "bnc"

Definition at line 75 of file DcGlobals.h.

#define PARM_SEP   "->"

Definition at line 73 of file DcGlobals.h.

#define PARM_SEP_LEN   2

Definition at line 74 of file DcGlobals.h.

#define POST   "POST"

Definition at line 63 of file DcGlobals.h.

#define PROTOCOL10_VRS   "HTTP/1.0"

Definition at line 68 of file DcGlobals.h.

#define PROTOCOL11_VRS   "HTTP/1.1"

Definition at line 67 of file DcGlobals.h.

#define PS_DBG   5

Definition at line 90 of file DcGlobals.h.

#define PS_GEN   1

Definition at line 86 of file DcGlobals.h.

#define PS_LOG   2

Definition at line 87 of file DcGlobals.h.

#define PS_SEC   3

Definition at line 88 of file DcGlobals.h.

#define PS_TRD   4

Definition at line 89 of file DcGlobals.h.

#define SCRIPT_END   "</bnscript"

Definition at line 79 of file DcGlobals.h.

#define SCRIPT_END_LEN   10

Definition at line 80 of file DcGlobals.h.

#define SCRIPT_STR   "<bnscript"

Definition at line 77 of file DcGlobals.h.

#define SCRIPT_STR_LEN   9

Definition at line 78 of file DcGlobals.h.

#define SCRIPT_TRM   '>'

Definition at line 81 of file DcGlobals.h.

#define SERVER_NAME   "Beesnest HTTP 1.1 Server/1.0"

Definition at line 66 of file DcGlobals.h.

#define TIME_FORMAT   "%a, %d %b %Y %H:%M:%S GMT"

Definition at line 72 of file DcGlobals.h.


Typedef Documentation

typedef t_map::const_iterator t_const_itr

Definition at line 53 of file DcGlobals.h.

typedef t_map::iterator t_itr

Definition at line 52 of file DcGlobals.h.

typedef map<string, string> t_map

Map to store header fields values, variables and parameters.

Definition at line 51 of file DcGlobals.h.

typedef unsigned int uint

Definition at line 55 of file DcGlobals.h.


Function Documentation

void ControlUsers ( int  argc,
char *  argv[] 
)

Add, Change password and Remove users from the users database.

usage:
logins add 'username' 'password'.
logins change 'username' 'old_password' 'new_password'.
logins remove 'username' 'password'.

Definition at line 121 of file Main.cpp.

const CdcString EMPTY_STR ( ""   )
void InitProgram (  )

Initialize classes of the server by calling some class static functions.

Exceptions:
(CdcException)from the initialization functions.

Definition at line 95 of file Main.cpp.

void main ( int  argc,
char *  argv[] 
)

The Main function.

It checks the command line arguments.
install - will register this program as a demon/service.
uninstall - will unregister this program.
run - will run the program as regular console application.
logins - will add, remove and change password of users.
if no argument exists, it start the program as a demon/service.

Returns:
Zero on successful exit, or none zero if failed.

Definition at line 161 of file Main.cpp.

void PrintString ( CdcString  str,
int  level = 0 
)

Thread safe function to print a messages to the console and/or log file.

This is just a wrapper to CdcLogger::PrintString

Parameters:
strThe message to print.
levelOptional logging level (default is zero - always print).

Definition at line 43 of file Main.cpp.

int ProgramMain (  )

This is the real main function of the server.

it creates a CdcSocketServer object by calling the static function CdcSocketserver::GetSocketServer. Then it inserts a loop and listens to the selected port for incoming connections. When a new request is available Listen returns with a pointer to a CdcSocket object. Then the function will create a new CdcConnectionThread with the new socket, and call CdcConnectionThread::Start. The new thread will do the work while Main will return to listen on the port.

Returns:
(int) -1 if exit because of an error, otherwise it returns 0.

Definition at line 46 of file Main.cpp.


Variable Documentation

const CdcString CONTROLED_HEADERS = "Cache-Control, Connection, Server"

Definition at line 95 of file DcGlobals.h.