4 #include "opensrf/utils.h"
5 #include "opensrf/logging.h"
6 #include "objson/object.h"
7 #include "osrf_app_session.h"
10 This macro verifies methods receive the correct parameters
11 It also creates local variables "session", "method",
12 "params", and "request"
15 #define OSRF_METHOD_VERIFY_CONTEXT(__d) \
18 osrfAppSession* session = __d->session; \
19 osrfMethod* method = __d->method; \
20 jsonObject* params = __d->params; \
21 int request = __d->request; \
23 if( !(session && method && params) ) return -1; \
24 if( !params->type == JSON_ARRAY ) return -1; \
25 if( !method->name ) return -1; \
27 char* __j = jsonObjectToJSON(params);\
29 debug_handler("Service: %s | Params: %s", session->remote_service, __j);free(__j);}
35 struct _osrfApplicationStruct {
36 char* name; /* the name of our application */
37 void* handle; /* the lib handle */
38 struct _osrfMethodStruct* methods; /* list of methods */
39 struct _osrfApplicationStruct* next; /* next application */
41 typedef struct _osrfApplicationStruct osrfApplication;
44 struct _osrfMethodStruct {
45 char* name; /* the method name */
46 char* symbol; /* the symbol name (function) */
47 char* notes; /* public method documentation */
48 int argc; /* how many args this method expects */
49 void* methodHandle; /* cached version of the method handle */
50 struct _osrfMethodStruct* next;
52 typedef struct _osrfMethodStruct osrfMethod;
54 struct _osrfMethodContextStruct {
55 osrfAppSession* session;
60 typedef struct _osrfMethodContextStruct osrfMethodContext;
64 Register an application
65 @param appName The name of the application
66 @param soFile The library (.so) file that implements this application
67 @return 0 on success, -1 on error
69 int osrfAppRegisterApplication( char* appName, char* soFile );
73 @param appName The name of the application that implements the method
74 @param methodName The fully qualified name of the method
75 @param symbolName The symbol name (function) that implements the method
76 @param notes Public documentation for this method.
77 @params argc The number of arguments this method expects
78 @return 0 on success, -1 on error
80 int osrfAppRegisterMethod( char* appName,
81 char* methodName, char* symbolName, char* notes, int argc );
84 Finds the given app in the list of apps
85 @param name The name of the application
86 @return The application pointer or NULL if there is no such application
88 osrfApplication* _osrfAppFindApplication( char* name );
91 Finds the given method for the given app
92 @param appName The application
93 @param methodName The method to find
94 @return A method pointer or NULL if no such method
95 exists for the given application
97 osrfMethod* _osrfAppFindMethod( char* appName, char* methodName );
100 Finds the given method for the given app
101 @param app The application object
102 @param methodName The method to find
103 @return A method pointer or NULL if no such method
104 exists for the given application
106 osrfMethod* __osrfAppFindMethod( osrfApplication* app, char* methodName );
110 Runs the specified method for the specified application.
111 @param appName The name of the application who's method to run
112 @param methodName The name of the method to run
113 @param ses The app session attached to this request
114 @params reqId The request id for this request
115 @param params The method parameters
117 int osrfAppRunMethod( char* appName, char* methodName,
118 osrfAppSession* ses, int reqId, jsonObject* params );