/**************************************************************************** * This file is part of the project AqHome. * AqHome (c) by 2025 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. ****************************************************************************/ #ifndef AQHOME_SERVICE_H #define AQHOME_SERVICE_H #include #include #include #include typedef struct AQH_SERVICE AQH_SERVICE; GWEN_INHERIT_FUNCTION_DEFS(AQH_SERVICE); GWEN_LIST_FUNCTION_DEFS(AQH_SERVICE, AQH_Service); #include "aqhome-cgi/service/user.h" #include "aqhome-cgi/service/module.h" #include "aqhome-cgi/service/session.h" #include typedef int (*AQH_SERVICE_HANDLEREQUEST_FN)(AQH_SERVICE *sv, AQCGI_REQUEST *req); typedef AQH_USER* (*AQH_SERVICE_LOADUSER_FN)(AQH_SERVICE *sv, const char *s); typedef int (*AQH_SERVICE_SAVEUSER_FN)(AQH_SERVICE *sv, AQH_USER *user); typedef int (*AQH_SERVICE_ADDUSER_FN)(AQH_SERVICE *sv, AQH_USER *user); typedef int (*AQH_SERVICE_DELUSER_FN)(AQH_SERVICE *sv, const char *s); typedef GWEN_STRINGLIST* (*AQH_SERVICE_LISTUSERS_FN)(AQH_SERVICE *sv); typedef AQH_MODULE* (*AQH_SERVICE_LOADMODULE_FN)(AQH_SERVICE *sv, const char *s); typedef int (*AQH_SERVICE_SAVEMODULE_FN)(AQH_SERVICE *sv, AQH_MODULE *module); typedef int (*AQH_SERVICE_ADDMODULE_FN)(AQH_SERVICE *sv, AQH_MODULE *module); typedef int (*AQH_SERVICE_DELMODULE_FN)(AQH_SERVICE *sv, const char *s); typedef GWEN_STRINGLIST* (*AQH_SERVICE_LISTMODULES_FN)(AQH_SERVICE *sv); typedef AQH_SESSION* (*AQH_SERVICE_LOADSESSION_FN)(AQH_SERVICE *sv, const char *s); typedef int (*AQH_SERVICE_SAVESESSION_FN)(AQH_SERVICE *sv, AQH_SESSION *session); typedef int (*AQH_SERVICE_ADDSESSION_FN)(AQH_SERVICE *sv, AQH_SESSION *session); typedef int (*AQH_SERVICE_DELSESSION_FN)(AQH_SERVICE *sv, const char *s); typedef GWEN_STRINGLIST* (*AQH_SERVICE_LISTSESSIONS_FN)(AQH_SERVICE *sv); AQH_SERVICE *AQH_Service_new(const char *baseFolder, const char *baseUrl); void AQH_Service_free(AQH_SERVICE *sv); const char *AQH_Service_GetBaseUrl(const AQH_SERVICE *sv); const char *AQH_Service_GetBaseFolder(const AQH_SERVICE *sv); const char *AQH_Service_GetRuntimeFolder(const AQH_SERVICE *sv); const char *AQH_Service_GetCacheFolder(const AQH_SERVICE *sv); int AQH_Service_HandleRequest(AQH_SERVICE *sv, AQCGI_REQUEST *req); AQH_USER *AQH_Service_LoadUser(AQH_SERVICE *sv, const char *s); int AQH_Service_SaveUser(AQH_SERVICE *sv, AQH_USER *user); int AQH_Service_AddUser(AQH_SERVICE *sv, AQH_USER *user); int AQH_Service_DelUser(AQH_SERVICE *sv, const char *s); GWEN_STRINGLIST *AQH_Service_ListUsers(AQH_SERVICE *sv); AQH_MODULE *AQH_Service_LoadModule(AQH_SERVICE *sv, const char *s); int AQH_Service_SaveModule(AQH_SERVICE *sv, AQH_MODULE *module); int AQH_Service_AddModule(AQH_SERVICE *sv, AQH_MODULE *module); int AQH_Service_DelModule(AQH_SERVICE *sv, const char *s); GWEN_STRINGLIST *AQH_Service_ListModules(AQH_SERVICE *sv); AQH_SESSION* AQH_Service_LoadSession(AQH_SERVICE *sv, const char *s); int AQH_Service_SaveSession(AQH_SERVICE *sv, AQH_SESSION *session); int AQH_Service_AddSession(AQH_SERVICE *sv, AQH_SESSION *session); int AQH_Service_DelSession(AQH_SERVICE *sv, const char *s); GWEN_STRINGLIST *AQH_Service_ListSessions(AQH_SERVICE *sv); void AQH_Service_SetHandleRequestFn(AQH_SERVICE *sv, AQH_SERVICE_HANDLEREQUEST_FN f); void AQH_Service_SetLoadUserFn(AQH_SERVICE *sv, AQH_SERVICE_LOADUSER_FN f); void AQH_Service_SetSaveUserFn(AQH_SERVICE *sv, AQH_SERVICE_SAVEUSER_FN f); void AQH_Service_SetAddUserFn(AQH_SERVICE *sv, AQH_SERVICE_ADDUSER_FN f); void AQH_Service_SetDelUserFn(AQH_SERVICE *sv, AQH_SERVICE_DELUSER_FN f); void AQH_Service_SetListUsersFn(AQH_SERVICE *sv, AQH_SERVICE_LISTUSERS_FN f); void AQH_Service_SetLoadModuleFn(AQH_SERVICE *sv, AQH_SERVICE_LOADMODULE_FN f); void AQH_Service_SetSaveModuleFn(AQH_SERVICE *sv, AQH_SERVICE_SAVEMODULE_FN f); void AQH_Service_SetAddModuleFn(AQH_SERVICE *sv, AQH_SERVICE_ADDMODULE_FN f); void AQH_Service_SetDelModuleFn(AQH_SERVICE *sv, AQH_SERVICE_DELMODULE_FN f); void AQH_Service_SetListModulesFn(AQH_SERVICE *sv, AQH_SERVICE_LISTMODULES_FN f); void AQH_Service_SetLoadSessionFn(AQH_SERVICE *sv, AQH_SERVICE_LOADSESSION_FN f); void AQH_Service_SetSaveSessionFn(AQH_SERVICE *sv, AQH_SERVICE_SAVESESSION_FN f); void AQH_Service_SetAddSessionFn(AQH_SERVICE *sv, AQH_SERVICE_ADDSESSION_FN f); void AQH_Service_SetDelSessionFn(AQH_SERVICE *sv, AQH_SERVICE_DELSESSION_FN f); void AQH_Service_SetListSessionsFn(AQH_SERVICE *sv, AQH_SERVICE_LISTSESSIONS_FN f); #endif