aqhome-cgi: use service code from AqCGI.
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
static void _handleRequest(AQCGI_REQUEST *rq, const char *sPathStaticFiles, const char *sPathRuntimeFiles, const char *sBaseUrl);
|
||||
static int _handlePath(AQH_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles);
|
||||
static int _handlePath(AQCGI_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles);
|
||||
static void logStart(void);
|
||||
static int _init(const char *sPathRuntimeFiles, const char *sBaseUrl);
|
||||
|
||||
@@ -126,26 +126,26 @@ int main(int argc, char **argv)
|
||||
|
||||
void _handleRequest(AQCGI_REQUEST *rq, const char *sPathStaticFiles, const char *sPathRuntimeFiles, const char *sBaseUrl)
|
||||
{
|
||||
AQH_SERVICE *sv;
|
||||
AQCGI_SERVICE *sv;
|
||||
int rv;
|
||||
|
||||
sv=AQH_ServiceFiles_new(sPathRuntimeFiles, sBaseUrl);
|
||||
AQH_Service_SetLoginUrl(sv, "/aqhome/login");
|
||||
AQCGI_Service_SetLoginUrl(sv, "/aqhome/login");
|
||||
|
||||
rv=_handlePath(sv, rq, sPathStaticFiles);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
}
|
||||
AQH_Service_free(sv);
|
||||
AQCGI_Service_free(sv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _handlePath(AQH_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles)
|
||||
int _handlePath(AQCGI_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles)
|
||||
{
|
||||
AQH_MODULE *mRoot;
|
||||
AQH_MODULE *mParent;
|
||||
AQH_SESSION *session;
|
||||
AQCGI_MODULE *mRoot;
|
||||
AQCGI_MODULE *mParent;
|
||||
AQCGI_SESSION *session;
|
||||
const GWEN_STRINGLIST *sl;
|
||||
|
||||
mRoot=AQH_ModRoot_new(sv, sPathStaticFiles);
|
||||
@@ -166,13 +166,13 @@ int _handlePath(AQH_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles
|
||||
s=GWEN_StringListEntry_Data(se);
|
||||
if (s && *s) {
|
||||
if (seNext) {
|
||||
AQH_MODULE *m;
|
||||
AQCGI_MODULE *m;
|
||||
|
||||
DBG_ERROR(NULL, "Entry: %s (%s)", s, seNext?"not last":"last");
|
||||
m=AQH_ModService_LoadSubModule(mParent, rq, session, s);
|
||||
if (m==NULL) {
|
||||
AQH_Session_free(session);
|
||||
AQH_Module_free(mRoot);
|
||||
AQCGI_Session_free(session);
|
||||
AQCGI_Module_free(mRoot);
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
mParent=m;
|
||||
@@ -185,8 +185,8 @@ int _handlePath(AQH_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles
|
||||
rv=AQH_ModService_HandleRequest(mParent, rq, session, s);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
AQH_Session_free(session);
|
||||
AQH_Module_free(mRoot);
|
||||
AQCGI_Session_free(session);
|
||||
AQCGI_Module_free(mRoot);
|
||||
return rv;
|
||||
}
|
||||
break;
|
||||
@@ -195,13 +195,13 @@ int _handlePath(AQH_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles
|
||||
|
||||
se=seNext;
|
||||
}
|
||||
AQH_Session_free(session);
|
||||
AQH_Module_free(mRoot);
|
||||
AQCGI_Session_free(session);
|
||||
AQCGI_Module_free(mRoot);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
AQH_Session_free(session);
|
||||
AQH_Module_free(mRoot);
|
||||
AQCGI_Session_free(session);
|
||||
AQCGI_Module_free(mRoot);
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ void logStart()
|
||||
|
||||
int _init(const char *sPathRuntimeFiles, const char *sBaseUrl)
|
||||
{
|
||||
AQH_SERVICE *sv;
|
||||
AQCGI_SERVICE *sv;
|
||||
int rv;
|
||||
|
||||
DBG_ERROR(NULL, "Creating aqhome-cgi environment in \"%s\"", sPathRuntimeFiles);
|
||||
@@ -231,32 +231,32 @@ int _init(const char *sPathRuntimeFiles, const char *sBaseUrl)
|
||||
rv=AQH_ModAdmin_Create(sv);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "Error creating module \"admin\"");
|
||||
AQH_Service_free(sv);
|
||||
AQCGI_Service_free(sv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv=AQH_ModAdmModules_Create(sv);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "Error creating module \"modules\"");
|
||||
AQH_Service_free(sv);
|
||||
AQCGI_Service_free(sv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv=AQH_ModAdmUsers_Create(sv);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "Error creating module \"users\"");
|
||||
AQH_Service_free(sv);
|
||||
AQCGI_Service_free(sv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv=AQH_ModDevices_Create(sv);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "Error creating module \"devices\"");
|
||||
AQH_Service_free(sv);
|
||||
AQCGI_Service_free(sv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
AQH_Service_free(sv);
|
||||
AQCGI_Service_free(sv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user