Shadow Network Framework
0.0.2-alpha
C Server Library for Shadow Network Framework
|
The variables system made here is made to put for the purpose of gathering all variables required for the normal running of the core feeatures of SNF, it does not contain EVERY variable, as of this version do not expect to find all variables needed here. but it is not recommened to not touch any variable that isnt included in this structure as it will result in undefined behaviour.
To use the core headers of snf you can include
or if you want to include this specific header file only
The first thing to do before anything is to default the variables structure, which will of cause default the value but also allocated to strucutre,
we can default it by calling snf_var_default after that go and set what ever variable you see fit except those that are advised against manually Setting them
As of 0.0.2-alpha there are 11 variables stated in SNF_VARS
4 of which are advised to not manually be set, which are:
and 1 variable that is not implementedbear no effect:
and that leaves the rest of the variables being allowed to be changed by you -the developper-, which are:
After initializing you may want to set the variales to your needs and for that you can use snf_var_set Which requires two arguments:
However setting the variables may depend if the type of your variable is registred as a pointer of a Data type or an instance of one, Luckily as of 0.0.2-alpha there will be no need to handle to see what type of the variable you're gonna be setting as you're only advised to change an instance of int ( Or _Atomic int).
Eg: let's say we want to set the amount of threads used by SNF to 15 Threads
To get variables there are multiple functions each serving a purpose
This is the base function which returns a void **, which refers to a pointer in the variables structure where your variables are stored.
This is a wrapper macro for snf_var_geta_void which just casts it's return from void ** which cast it onto TYPE ** (TYPE must be a valid type)
This macro dereferences the return of snf_var_geta which returns a TYPE *
this is best used if you are using a variable that is a pointer to a data type. how ever if it was written in SNF_VARS that a variable's TYPE is DATA_TYPE * then put DATA_TYPE as the TYPE
Example we want to get the variable SNF_VAR_THREADPOOL which is of type SNF_thpool * we use
This macro dereferences the return of snf_var_get which returns a TYPE
this is best used if you are using a variable that is an instance of a data type.
Example we want to get the variable SNF_VAR_THREADS which is of type int we use