add some commonnly used functions.
This commit is contained in:
@@ -28,6 +28,10 @@
|
|||||||
#define AQH_MOD_SERVICE_FOOTERFILE "footer.html"
|
#define AQH_MOD_SERVICE_FOOTERFILE "footer.html"
|
||||||
|
|
||||||
|
|
||||||
|
#define GBAS GWEN_Buffer_AppendString
|
||||||
|
#define GBAA GWEN_Buffer_AppendArgs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* global vars
|
* global vars
|
||||||
@@ -522,4 +526,81 @@ void AQH_ModService_HandleRequestWithTable(AQH_MODULE *m,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_ModService_WritePermsToForm(uint32_t perms, const AQH_PERMDEF_LIST *permDefList, const char *sPrefix, GWEN_BUFFER *dbuf)
|
||||||
|
{
|
||||||
|
if (permDefList) {
|
||||||
|
const AQH_PERMDEF *permDef;
|
||||||
|
GWEN_BUFFER *tbuf;
|
||||||
|
uint32_t pos;
|
||||||
|
|
||||||
|
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||||
|
if (sPrefix && *sPrefix)
|
||||||
|
GBAA(tbuf, "%s:", sPrefix);
|
||||||
|
pos=GWEN_Buffer_GetPos(tbuf);
|
||||||
|
|
||||||
|
permDef=AQH_PermDef_List_First(permDefList);
|
||||||
|
while(permDef) {
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=AQH_PermDef_GetId(permDef);
|
||||||
|
if (s && *s) {
|
||||||
|
uint32_t mask;
|
||||||
|
|
||||||
|
GBAS(tbuf, s);
|
||||||
|
mask=AQH_PermDef_GetMask(permDef);
|
||||||
|
if (perms & mask)
|
||||||
|
GBAA(dbuf, "<input type=\"checkbox\" name=\"%s\" checked>", GWEN_Buffer_GetStart(tbuf));
|
||||||
|
else
|
||||||
|
GBAA(dbuf, "<input type=\"checkbox\" name=\"%s\">", s?s:"");
|
||||||
|
GBAA(dbuf, "<label for=\"%s\">%s</label>", GWEN_Buffer_GetStart(tbuf), s?s:"");
|
||||||
|
GWEN_Buffer_Crop(tbuf, 0, pos);
|
||||||
|
}
|
||||||
|
permDef=AQH_PermDef_List_Next(permDef);
|
||||||
|
}
|
||||||
|
GWEN_Buffer_free(tbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQH_ModService_ReadPermsFromForm(GWEN_DB_NODE *dbPost, const AQH_PERMDEF_LIST *permDefList, const char *sPrefix)
|
||||||
|
{
|
||||||
|
uint32_t result=0;
|
||||||
|
|
||||||
|
if (permDefList) {
|
||||||
|
const AQH_PERMDEF *permDef;
|
||||||
|
GWEN_BUFFER *tbuf;
|
||||||
|
uint32_t pos;
|
||||||
|
|
||||||
|
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||||
|
if (sPrefix && *sPrefix)
|
||||||
|
GBAA(tbuf, "%s:", sPrefix);
|
||||||
|
pos=GWEN_Buffer_GetPos(tbuf);
|
||||||
|
|
||||||
|
permDef=AQH_PermDef_List_First(permDefList);
|
||||||
|
while(permDef) {
|
||||||
|
const char *id;
|
||||||
|
|
||||||
|
id=AQH_PermDef_GetId(permDef);
|
||||||
|
if (id && *id) {
|
||||||
|
uint32_t mask;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
GBAS(tbuf, id);
|
||||||
|
mask=AQH_PermDef_GetMask(permDef);
|
||||||
|
s=GWEN_DB_GetCharValue(dbPost, GWEN_Buffer_GetStart(tbuf), 0, NULL);
|
||||||
|
if (s && *s)
|
||||||
|
result|=mask;
|
||||||
|
GWEN_Buffer_Crop(tbuf, 0, pos);
|
||||||
|
}
|
||||||
|
permDef=AQH_PermDef_List_Next(permDef);
|
||||||
|
}
|
||||||
|
GWEN_Buffer_free(tbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ void AQH_ModService_AddPermDef(AQH_PERMDEF_LIST *permDefList, const char *id, ui
|
|||||||
void AQH_ModService_AddRole(AQH_ROLE_LIST *roleList, int id, const char *name, uint32_t perms, const char *descr);
|
void AQH_ModService_AddRole(AQH_ROLE_LIST *roleList, int id, const char *name, uint32_t perms, const char *descr);
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_ModService_WritePermsToForm(uint32_t perms, const AQH_PERMDEF_LIST *permDefList, const char *sPrefix, GWEN_BUFFER *dbuf);
|
||||||
|
uint32_t AQH_ModService_ReadPermsFromForm(GWEN_DB_NODE *dbPost, const AQH_PERMDEF_LIST *permDefList, const char *sPrefix);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQH_ModService_SetHandleRequestFn(AQH_MODULE *m, AQH_MODSERVICE_HANDLEREQUEST_FN fn);
|
void AQH_ModService_SetHandleRequestFn(AQH_MODULE *m, AQH_MODSERVICE_HANDLEREQUEST_FN fn);
|
||||||
void AQH_ModService_SetLoadSubModuleFn(AQH_MODULE *m, AQH_MODSERVICE_LOADSUBMODULE_FN fn);
|
void AQH_ModService_SetLoadSubModuleFn(AQH_MODULE *m, AQH_MODSERVICE_LOADSUBMODULE_FN fn);
|
||||||
|
|||||||
@@ -59,14 +59,6 @@
|
|||||||
<flags></flags>
|
<flags></flags>
|
||||||
</member>
|
</member>
|
||||||
|
|
||||||
|
|
||||||
<member name="perms" type="uint32_t" maxlen="4">
|
|
||||||
<default>0</default>
|
|
||||||
<preset>0</preset>
|
|
||||||
<access>public</access>
|
|
||||||
<flags>volatile</flags>
|
|
||||||
</member>
|
|
||||||
|
|
||||||
</members>
|
</members>
|
||||||
|
|
||||||
</type>
|
</type>
|
||||||
|
|||||||
Reference in New Issue
Block a user