]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/c-apps/osrf_cslow.c
LP1999823: Bump libtool library version
[OpenSRF.git] / src / c-apps / osrf_cslow.c
1 #include <opensrf/osrf_app_session.h>
2 #include <opensrf/osrf_application.h>
3 #include <opensrf/osrf_json.h>
4 #include <opensrf/log.h>
5
6 #define MODULENAME "opensrf.cslow"
7
8 int osrfAppInitialize();
9 int osrfAppChildInit();
10 int osrfCSlowWait( osrfMethodContext* );
11
12
13 int osrfAppInitialize() {
14
15         osrfAppRegisterMethod( 
16                         MODULENAME, 
17                         "opensrf.cslow.wait", 
18                         "osrfCSlowWait", 
19                         "Wait specified number of seconds, then return that number", 1, 0 );
20
21         return 0;
22 }
23
24 int osrfAppChildInit() {
25         return 0;
26 }
27
28 int osrfCSlowWait( osrfMethodContext* ctx ) {
29         if( osrfMethodVerifyContext( ctx ) ) {
30                 osrfLogError( OSRF_LOG_MARK,  "Invalid method context" );
31                 return -1;
32         }
33
34         const jsonObject* x = jsonObjectGetIndex(ctx->params, 0);
35
36         if( x ) {
37
38                 char* a = jsonObjectToSimpleString(x);
39
40                 if( a ) {
41
42                         unsigned int pause = atoi(a);
43                         sleep(pause);
44
45                         jsonObject* resp = jsonNewNumberObject(pause);
46                         osrfAppRespondComplete( ctx, resp );
47                         jsonObjectFree(resp);
48
49                         free(a);
50                         return 0;
51                 }
52         }
53
54         return -1;
55 }
56
57
58