TEL
Create your extensible application
Loading...
Searching...
No Matches
Extension.h File Reference

Add extension structure and functions. More...

#include <APIMacros/api.h>
#include <stddef.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  TelError
 The structure that represents the error on return. More...
struct  TelExtension
 The structure that represents the extension. More...

Macros

#define TEL_ERROR_NO   0
#define TEL_ERROR_GET_FUNC   1
#define TEL_ERROR_EXT_LOAD   2
#define TEL_NEW_EXTENSION(extension, struct)
 Macro that create TelExtension.

Functions

API TelError telExtensionLoad (TelExtension *self, const char *restrict path, const char *restrict setupFunctionName)
 Function that loads the extension.
API TelError telExtensionUnload (TelExtension *self, const char *restrict cleanupFunctionName)
 Function that unload the extension.

Detailed Description

Add extension structure and functions.

This file contains the basic functions and structures of TEL. It allows you to load and unload extensions.

Author
IHateGameDev(semenovihandrey)
Version
0.1.5 - v5

Macro Definition Documentation

◆ TEL_ERROR_EXT_LOAD

#define TEL_ERROR_EXT_LOAD   2

◆ TEL_ERROR_GET_FUNC

#define TEL_ERROR_GET_FUNC   1

◆ TEL_ERROR_NO

#define TEL_ERROR_NO   0

◆ TEL_NEW_EXTENSION

#define TEL_NEW_EXTENSION ( extension,
struct )
Value:
TelExtension* extension = (TelExtension*)malloc(sizeof(TelExtension)); \
extension->info = (struct*)malloc(sizeof(struct))
The structure that represents the extension.
Definition Extension.h:39
void * info
Definition Extension.h:40

Macro that create TelExtension.

@macro TEL_NEW_EXTENSION

The macro that allocate memory for extension and info.

Parameters
extensionName of TelExtension variable.
structName of info structure.
Returns
Pointer to TelExtension.

Function Documentation

◆ telExtensionLoad()

API TelError telExtensionLoad ( TelExtension * self,
const char *restrict path,
const char *restrict setupFunctionName )

Function that loads the extension.

The function that loads the extension, processes the setup function, and allocates memory for the extension information.

Parameters
selfExtension over which actions are performed.
pathPath to extension (shared library).
setupFunctionNameName of the setup function in the extension (requires the information parameter in the setup function of the extension).
infoSizeSize of extension info for allocate memory (use sizeof(ExtensionInfoStruct)).
Returns
TelError structure.

◆ telExtensionUnload()

API TelError telExtensionUnload ( TelExtension * self,
const char *restrict cleanupFunctionName )

Function that unload the extension.

The function unloads the extension frees the associated memory and calls the cleanup function, which is used to clean the allocated memory by the extension itself.

Parameters
selfExtension over which actions are performed.
cleanupInfoPointer that is the second argument to "setupFunction"
cleanupFunctionNameName of cleanup function in the extension (requires the information parameter in the cleanup function of the extension).
Returns
TelError structure.