Shadow Network Framework  0.0.2-alpha
C Server Library for Shadow Network Framework
Loading...
Searching...
No Matches
vars.h File Reference

this file Defines everything related to Globaly accessed variable More...

Go to the source code of this file.

Macros

#define SNF_N_VARS   ((int)SNF_VAR_INITIALIZED + 1)
 Returns the amount of variables registred in this structure.
 
#define snf_var_geta(VARNAME, TYPE)
 The same as snf_var_geta_void but casts the return from (void **) into (TYPE **)
 
#define snf_var_get(VARNAME, TYPE)
 Derenferences the return of snf_var_geta from TYPE** into TYPE *.
 
#define snf_var_getv(VARNAME, TYPE)
 Dereferences the return of snf_var_get from TYPE * to TYPE.
 

Typedefs

typedef enum SNF_VARS_e SNF_VARS
 This Enum saved the identifiers for variables available as of this version.
 

Enumerations

enum  SNF_VARS_e {
  SNF_VAR_THREADS , SNF_VAR_THREADPOOL , SNF_VAR_PORT , SNF_VAR_MAX_QUEUE ,
  SNF_VAR_OPCODE_INIS , SNF_VAR_EPOLL_MAXEVENTS , SNF_VAR_EPOLL_EVENTS , SNF_VAR_EPOLL_TIMEOUT ,
  SNF_VAR_CLTS_INITIAL , SNF_VAR_RQST_MAX_LENGTH , SNF_VAR_INITIALIZED
}
 This Enum saved the identifiers for variables available as of this version. More...
 

Functions

void snf_var_default ()
 Defaults and allocates the variables.
 
void ** snf_var_geta_void (SNF_VARS VARNAME)
 Returns the address of the void* pointer of the variable.
 
void snf_var_set (SNF_VARS VARNAME, void *Value)
 Allows to set the value of a variable.
 

Detailed Description

this file Defines everything related to Globaly accessed variable

This file serves as a way to put the variables that are required to be globally accessed, as this will ease for developper's access to them and store them in one place instead of them being scattered in different files.

Note

Headers that are cable of working independently ( aka lookup3.h, hashtable.h and thpool.h are unaffected by these variables) do not require to default the variables if you're just using those headers

Macro Definition Documentation

◆ SNF_N_VARS

#define SNF_N_VARS   ((int)SNF_VAR_INITIALIZED + 1)

Returns the amount of variables registred in this structure.

◆ snf_var_geta

#define snf_var_geta ( VARNAME,
TYPE )
Value:
((TYPE **)snf_var_geta_void(VARNAME))
void ** snf_var_geta_void(SNF_VARS VARNAME)
Returns the address of the void* pointer of the variable.

The same as snf_var_geta_void but casts the return from (void **) into (TYPE **)

Parameters
VARNAMEVariable's identifier
TYPEVariable's pointer's type

◆ snf_var_get

#define snf_var_get ( VARNAME,
TYPE )
Value:
*snf_var_geta(VARNAME, TYPE)
#define snf_var_geta(VARNAME, TYPE)
The same as snf_var_geta_void but casts the return from (void **) into (TYPE **)
Definition vars.h:111

Derenferences the return of snf_var_geta from TYPE** into TYPE *.

Parameters
VARNAMEVariable's identifier
TYPEVariable's pointer type
Note
Best in case the variable's type is a pointer

◆ snf_var_getv

#define snf_var_getv ( VARNAME,
TYPE )
Value:
*snf_var_get(VARNAME, TYPE)
#define snf_var_get(VARNAME, TYPE)
Derenferences the return of snf_var_geta from TYPE** into TYPE *.
Definition vars.h:116

Dereferences the return of snf_var_get from TYPE * to TYPE.

Parameters
VARNAMEVariable's identifier
TYPEVariable's Type
Note
Best in case your type was not registred as a pointer ( eg: TYPE == int )

Typedef Documentation

◆ SNF_VARS

typedef enum SNF_VARS_e SNF_VARS

This Enum saved the identifiers for variables available as of this version.

Enumeration Type Documentation

◆ SNF_VARS_e

enum SNF_VARS_e

This Enum saved the identifiers for variables available as of this version.

Enumerator
SNF_VAR_THREADS 

Variable for threads used by SNF

Type: int
Default Value: 4

Warning
Do not change after starting snf server
SNF_VAR_THREADPOOL 

Variable for saving the threadpool instance

Type: SNF_thpool
Default Value: Default Instance of SNF_thpool

Warning
Never Set/Change this variable manually
SNF_VAR_PORT 

Variable for saving the port used by SNF

Type: int
Default Value: 9114

SNF_VAR_MAX_QUEUE 

Variable for saving maximum connections that are able to queue while waiting forthe server to accept, (aka passed as a parameter to listen())

Type: int
Default Value: 1000

SNF_VAR_OPCODE_INIS 

Variable for saving if SNF_VAR_OPCODE_INIS

Type: int
Default Value: 0

Note
Ignored, use SNF_opcode_base_isinit to Check if the opcode is initialized or not.
SNF_VAR_EPOLL_MAXEVENTS 

Variable for saving the amount possible of concurrent connections ( See limitations of epoll )

Type: int
Default Value: 4096

SNF_VAR_EPOLL_EVENTS 

Variable for saving events that are used by epoll

Type: struct event_epoll *
Default Value: Table of (struct event_epoll) x (value of SNF_VAR_EPOLL_MAXEVENTS)

Warning
Never Set/Change this variable manually
SNF_VAR_EPOLL_TIMEOUT 

Variable for saving the maximum timeout in miliseconds for epoll_wait()

Type: _Atomic int
Default Value: 10

SNF_VAR_CLTS_INITIAL 

Variable for the amount of initially planned amount of client to connect, for the Hashtable saving the clients

Type: int
Default Value: 100

Note
It will be changed where the actual hashtable length equals to 2^n where n will be the lowest value that makes the 2^n fit the value set for this variable
eg: If you set SNF_VAR_CLTS_INITIAL's value to 100, the actual hashtable length will be 128
SNF_VAR_RQST_MAX_LENGTH 

Variable for saving the maximum allowed length of a Request

Type: int
Default Value: 4096

SNF_VAR_INITIALIZED 

Variable for saving if the Variables has been defaulted and/or initalized before.

Type: int
Default Value: 0

Warning
Never Set/Change this variable manually

Function Documentation

◆ snf_var_default()

void snf_var_default ( )
extern

Defaults and allocates the variables.

◆ snf_var_geta_void()

void ** snf_var_geta_void ( SNF_VARS VARNAME)
extern

Returns the address of the void* pointer of the variable.

Parameters
VARNAMEVariable's Idnetifier
Returns

◆ snf_var_set()

void snf_var_set ( SNF_VARS VARNAME,
void * Value )
extern

Allows to set the value of a variable.

Parameters
VARNAMEVariable's identifier
ValueVariable's new value
Warning
Make sure you dont change certain values on unappropriate moments, Check SNF_VARS