]> git.evergreen-ils.org Git - Evergreen.git/blob - OpenSRF/src/libstack/osrf_system.c
OK. This is the first early C version of the OpenSRF stack. It's highly
[Evergreen.git] / OpenSRF / src / libstack / osrf_system.c
1 #include "opensrf/osrf_system.h"
2
3
4 int osrf_system_bootstrap_client() {
5         // XXX config values 
6         transport_client* client = client_init( "judy", 5222, 0 );
7         char buf[256];
8         memset(buf,0,256);
9         char* host = getenv("HOSTNAME");
10         sprintf(buf, "client_%s_%d", host, getpid() );
11         if(client_connect( client, "system_client","jkjkasdf", buf, 10, AUTH_DIGEST )) {
12                 /* push ourselves into the client cache */
13                 osrf_system_push_transport_client( client, "client" );
14                 return 1;
15         }
16         return 0;
17 }
18
19 // -----------------------------------------------------------------------------
20 // Some client caching utility methods
21 transport_client_cache* client_cache;
22
23 void osrf_system_push_transport_client( transport_client* client, char* service ) {
24         if(client == NULL || service == NULL) return;
25         transport_client_cache* new = (transport_client_cache*) safe_malloc(sizeof(transport_client_cache));
26         new->service = strdup(service);
27         new->client = client;
28         if(client_cache == NULL) 
29                 client_cache = new;
30         else {
31                 transport_client_cache* tmp = client_cache->next;
32                 client_cache = new;
33                 new->next = tmp;
34         }
35 }
36
37 transport_client* osrf_system_get_transport_client( char* service ) {
38         if(service == NULL) return NULL;
39         transport_client_cache* cur = client_cache;
40         while(cur != NULL) {
41                 if( !strcmp(cur->service, service)) 
42                         return cur->client;
43                 cur = cur->next;
44         }
45         return NULL;
46 }
47 // -----------------------------------------------------------------------------
48
49