Shadow Network Framework  0.0.2-alpha
C Server Library for Shadow Network Framework
Loading...
Searching...
No Matches
vars.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2///
3/// \brief this file Defines everything related to Globaly accessed variable
4/// \file vars.h
5///
6/// This file serves as a way to put the variables that are required to be
7/// globally accessed, as this will ease for developper's access to them
8/// and store them in one place instead of them being scattered in different
9/// files.
10///
11/// \note <br>
12/// Headers that are cable of working independently ( aka
13/// lookup3.h, hashtable.h and thpool.h are unaffected by these variables)
14/// do not require to default the variables if you're just using those headers
15////////////////////////////////////////////////////////////////////////////////
16#ifndef snf_vars_h
17#define snf_vars_h
18
19
20#include <SNF/SNF.h>
21
22/// @brief This Enum saved the identifiers for variables available as of this version
23typedef enum SNF_VARS_e {
24 /// @brief Variable for threads used by SNF
25 /// @line
26 ///
27 /// **Type**: int <br>
28 /// **Default Value**: 4 <br>
29 /// @warning Do not change after starting snf server
31 /// @brief Variable for saving the threadpool instance
32 /// @line
33 ///
34 /// **Type**: SNF_thpool <br>
35 /// **Default Value**: Default Instance of SNF_thpool<br>
36 /// @warning Never Set/Change this variable manually
38 /// @brief Variable for saving the port used by SNF
39 /// @line
40 ///
41 /// **Type**: int <br>
42 /// **Default Value**: 9114<br>
44 /// @brief Variable for saving maximum connections that are able to queue while waiting forthe server to accept, (aka passed as a parameter to listen())
45 /// @line
46 ///
47 /// **Type**: int <br>
48 /// **Default Value**: 1000<br>
50 /// @brief Variable for saving if SNF_VAR_OPCODE_INIS
51 /// @line
52 ///
53 /// **Type**: int <br>
54 /// **Default Value**: 0<br>
55 /// @note Ignored, use \ref SNF_opcode_base_isinit to Check if the opcode is initialized or not.
57 /// @brief Variable for saving the amount possible of concurrent connections ( See limitations of epoll )
58 /// @line
59 ///
60 /// **Type**: int <br>
61 /// **Default Value**: 4096<br>
63 /// @brief Variable for saving events that are used by epoll
64 /// @line
65 ///
66 /// **Type**: struct event_epoll * <br>
67 /// **Default Value**: Table of (struct event_epoll) x (value of SNF_VAR_EPOLL_MAXEVENTS)<br>
68 /// @warning Never Set/Change this variable manually
70 /// @brief Variable for saving the maximum timeout in miliseconds for epoll_wait()
71 /// @line
72 ///
73 /// **Type**: _Atomic int <br>
74 /// **Default Value**: 10<br>
76 /// @brief Variable for the amount of initially planned amount of client to connect, for the Hashtable saving the clients
77 /// @line
78 ///
79 /// **Type**: int <br>
80 /// **Default Value**: 100<br>
81 /// @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 <br>
82 /// **eg**: If you set SNF_VAR_CLTS_INITIAL's value to 100, the actual hashtable length will be 128
84 /// @brief Variable for saving the maximum allowed length of a Request
85 /// @line
86 ///
87 /// **Type**: int <br>
88 /// **Default Value**: 4096<br>
90 /// @brief Variable for saving if the Variables has been defaulted and/or initalized before.
91 /// @line
92 ///
93 /// **Type**: int <br>
94 /// **Default Value**: 0<br>
95 /// @warning Never Set/Change this variable manually
98
99/// @brief Returns the amount of variables registred in this structure
100#define SNF_N_VARS ((int)SNF_VAR_INITIALIZED + 1)
101/// @brief Defaults and allocates the variables
102extern void snf_var_default();
103
104/// @brief Returns the address of the void* pointer of the variable
105/// @param VARNAME Variable's Idnetifier
106/// @return
107extern void **snf_var_geta_void(SNF_VARS VARNAME);
108/// @brief The same as snf_var_geta_void but casts the return from (void **) into (TYPE **)
109/// @param VARNAME Variable's identifier
110/// @param TYPE Variable's pointer's type
111#define snf_var_geta(VARNAME, TYPE) ((TYPE **)snf_var_geta_void(VARNAME))
112/// @brief Derenferences the return of snf_var_geta from TYPE** into TYPE *
113/// @param VARNAME Variable's identifier
114/// @param TYPE Variable's pointer type
115/// @note Best in case the variable's type is a pointer
116#define snf_var_get(VARNAME, TYPE) *snf_var_geta(VARNAME, TYPE)
117/// @brief Dereferences the return of snf_var_get from TYPE * to TYPE
118/// @param VARNAME Variable's identifier
119/// @param TYPE Variable's Type
120/// @note Best in case your type was not registred as a pointer ( eg: TYPE == int )
121#define snf_var_getv(VARNAME, TYPE) *snf_var_get(VARNAME, TYPE)
122/// @brief Allows to set the value of a variable
123/// @param VARNAME Variable's identifier
124/// @param Value Variable's new value
125/// @warning Make sure you dont change certain values on unappropriate moments, Check \ref SNF_VARS
126extern void snf_var_set(SNF_VARS VARNAME, void* Value);
127
128#include <SNF/thpool.h>
129#endif
Main Header FileThis File Calls for all the header files exisitng in this library,...
this file Defines everything related to ThreadPool
enum SNF_VARS_e SNF_VARS
This Enum saved the identifiers for variables available as of this version.
SNF_VARS_e
This Enum saved the identifiers for variables available as of this version.
Definition vars.h:23
@ SNF_VAR_THREADPOOL
Variable for saving the threadpool instance
Definition vars.h:37
@ SNF_VAR_CLTS_INITIAL
Variable for the amount of initially planned amount of client to connect, for the Hashtable saving th...
Definition vars.h:83
@ SNF_VAR_MAX_QUEUE
Variable for saving maximum connections that are able to queue while waiting forthe server to accept,...
Definition vars.h:49
@ SNF_VAR_EPOLL_EVENTS
Variable for saving events that are used by epoll
Definition vars.h:69
@ SNF_VAR_EPOLL_TIMEOUT
Variable for saving the maximum timeout in miliseconds for epoll_wait()
Definition vars.h:75
@ SNF_VAR_EPOLL_MAXEVENTS
Variable for saving the amount possible of concurrent connections ( See limitations of epoll )
Definition vars.h:62
@ SNF_VAR_OPCODE_INIS
Variable for saving if SNF_VAR_OPCODE_INIS
Definition vars.h:56
@ SNF_VAR_INITIALIZED
Variable for saving if the Variables has been defaulted and/or initalized before.
Definition vars.h:96
@ SNF_VAR_RQST_MAX_LENGTH
Variable for saving the maximum allowed length of a Request
Definition vars.h:89
@ SNF_VAR_PORT
Variable for saving the port used by SNF
Definition vars.h:43
@ SNF_VAR_THREADS
Variable for threads used by SNF
Definition vars.h:30
void snf_var_set(SNF_VARS VARNAME, void *Value)
Allows to set the value of a variable.
void ** snf_var_geta_void(SNF_VARS VARNAME)
Returns the address of the void* pointer of the variable.
void snf_var_default()
Defaults and allocates the variables.