webc v0.0.11
Write and deploy websites using the C Programming Language.
Loading...
Searching...
No Matches
webc-actions.h File Reference
#include "extern/httpd.h"
#include "extern/clib.h"
#include "webc-core.h"
Include dependency graph for webc-actions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  WebcAction
 
struct  Route
 
struct  Tree
 

Functions

WEBCAPI RouteWEBC_MakeRoute (Cstr path, char *buffer)
 
WEBCAPI Tree WEBC_MakeTree (Cstr root, Route *first,...)
 
WEBCAPI Tree WEBC_AllocTree (Cstr root, size_t capacity)
 
WEBCAPI void WEBC_AddRoute (Tree *tree, Route *route)
 
WEBCAPI void WEBC_CleanRoute (Route *route)
 
WEBCAPI void WEBC_CleanTree (Tree tree)
 
WEBCAPI WebcAction WEBC_ParseCliArgs (int argc, char **argv)
 
WEBCAPI void WEBC_HandleAction (WebcAction action, Tree tree)
 
WEBCAPI void WEBC_Export (char *buffer, Cstr path)
 
WEBCAPI void WEBC_ExportRoute (Route route)
 
WEBCAPI void WEBC_ExportTree (Tree tree)
 

Detailed Description

MIT License

Copyright (c) 2024 Konstantinos Despoinidis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
KDesp73 (Konstantinos Despoinidis)
Version
0.0.2

Function Documentation

◆ WEBC_AddRoute()

WEBCAPI void WEBC_AddRoute ( Tree * tree,
Route * route )

Appends a Route struct pointer to the tree

Parameters
treeThe tree to append to
routeThe new Route struct pointer

◆ WEBC_AllocTree()

WEBCAPI Tree WEBC_AllocTree ( Cstr root,
size_t capacity )

Allocates space for the Tree

Parameters
rootThe root of the tree (in case of serving without exporting it doesn't really matter)
capacityThe number of routes to allocate for
Returns
Tree

◆ WEBC_CleanRoute()

WEBCAPI void WEBC_CleanRoute ( Route * route)

Frees the memory allocated by a Route

Parameters
routeThe Route* to free

◆ WEBC_CleanTree()

WEBCAPI void WEBC_CleanTree ( Tree tree)

Frees the memory allocated by a Tree

Parameters
treeThe virtual tree contating the Routes

◆ WEBC_Export()

WEBCAPI void WEBC_Export ( char * buffer,
Cstr path )

Exports the contents of the buffer to an html file, while also creating the path that is being passed. Finally the buffer is freed

Parameters
bufferThe contents of the buffer
pathThe path to export the html file to

◆ WEBC_ExportRoute()

WEBCAPI void WEBC_ExportRoute ( Route route)

Exports the Route struct containing a buffer and a path

Parameters
routeThe Route struct

◆ WEBC_ExportTree()

WEBCAPI void WEBC_ExportTree ( Tree tree)

Exports every Route in the tree

Parameters
treeThe virtual tree created by the user

◆ WEBC_HandleAction()

WEBCAPI void WEBC_HandleAction ( WebcAction action,
Tree tree )

Depending on the action the method exports / serves the tree (physical or virtual)

Parameters
actionthe WebcAction returned from the ParseCliArgs method
treeThe virtual tree created by the user

◆ WEBC_MakeRoute()

WEBCAPI Route * WEBC_MakeRoute ( Cstr path,
char * buffer )

Creates a Route struct pointer

Parameters
pathThe path of the route (physical or virtual)
bufferThe html to serve or export
Returns
Route*

◆ WEBC_MakeTree()

WEBCAPI Tree WEBC_MakeTree ( Cstr root,
Route * first,
... )

Creates a Tree struct contatining multiple Route struct pointers

Parameters
rootThe root of the tree (in case of serving without exporting it doesn't really matter)
firstThe first Route struct pointer to add
...The rest of the Route pointers to add
Returns
Tree

◆ WEBC_ParseCliArgs()

WEBCAPI WebcAction WEBC_ParseCliArgs ( int argc,
char ** argv )

Parses the cli arguments

Parameters
argc
argv
Returns
WebcAction struct