Working on callbacks

This commit is contained in:
Pierre Pronchery 2014-05-30 22:33:02 +02:00
parent 09c9e615f0
commit 578210ff6c

View File

@ -336,41 +336,46 @@ void appinterface_delete(AppInterface * appinterface)
/* accessors */ /* accessors */
/* appinterface_can_call */ /* appinterface_can_call */
static int _can_call_client(AppInterface * appinterface); static int _can_call_client(AppInterface * appinterface,
static int _can_call_server(AppInterface * appinterface, char const * name, AppInterfaceCall * call, char const * name);
char const * method); static int _can_call_server(AppInterface * appinterface,
AppInterfaceCall * call, char const * name);
int appinterface_can_call(AppInterface * appinterface, char const * name, int appinterface_can_call(AppInterface * appinterface, char const * name,
char const * method) char const * method)
{ {
AppInterfaceCall * call;
if((call = _appinterface_get_call(appinterface, method)) == NULL)
return -1;
switch(appinterface->mode) switch(appinterface->mode)
{ {
case ATM_CLIENT: case ATM_CLIENT:
return _can_call_client(appinterface); return _can_call_client(appinterface, call, name);
case ATM_SERVER: case ATM_SERVER:
return _can_call_server(appinterface, name, method); return _can_call_server(appinterface, call, name);
} }
return -error_set_code(1, "%s", "Unknown AppInterface mode"); return -error_set_code(1, "%s", "Unknown AppInterface mode");
} }
static int _can_call_client(AppInterface * appinterface) static int _can_call_client(AppInterface * appinterface,
AppInterfaceCall * call, char const * name)
{ {
/* FIXME really implement */ /* FIXME really implement */
return -1; return 1;
} }
static int _can_call_server(AppInterface * appinterface, char const * name, static int _can_call_server(AppInterface * appinterface,
char const * method) AppInterfaceCall * call, char const * name)
{ {
int ret = 0; int ret = 0;
String * section; String * section;
String const * allow; String const * allow;
String const * deny; String const * deny;
if((section = string_new_append(APPINTERFACE_CALL_PREFIX, method, NULL)) if((section = string_new_append(APPINTERFACE_CALL_PREFIX, call->name,
== NULL) NULL)) == NULL)
/* XXX report as an error */ return -1;
return 0;
allow = config_get(appinterface->config, section, "allow"); allow = config_get(appinterface->config, section, "allow");
deny = config_get(appinterface->config, section, "deny"); deny = config_get(appinterface->config, section, "deny");
/* FIXME implement pattern matching */ /* FIXME implement pattern matching */