/* our stuff */
#include "opensrf/transport_client.h"
-#include "opensrf/generic_utils.h"
#include "opensrf/osrf_message.h"
#include "opensrf/osrf_app_session.h"
#include "opensrf/string_array.h"
*/
#define MODULE_NAME "ils_gateway_module"
+/*
struct session_list_struct {
- //char* service;
osrf_app_session* session;
struct session_list_struct* next;
int serve_count;
};
typedef struct session_list_struct session_list;
-/* the global session cache */
static session_list* the_list = NULL;
static void del_session( char* service ) {
}
-/* find a session in the list */
-/* if(update) we add 1 to the serve_count */
+// if(update) we add 1 to the serve_count
static osrf_app_session* find_session( char* service, int update ) {
session_list* item = the_list;
return NULL;
}
-/* add a session to the list */
static void add_session( char* service, osrf_app_session* session ) {
if(!session) return;
the_list = new_item;
}
}
+*/
static void mod_ils_gateway_child_init(apr_pool_t *p, server_rec *s) {
if( ! osrf_system_bootstrap_client(
info_handler( "param %s", string_array_get_string(sarray,k));
}
+ /*
osrf_app_session* session = find_session(service,1);
if(!session) {
session = osrf_app_client_session_init(service);
add_session(service, session);
}
+ */
+
+ osrf_app_session* session = osrf_app_client_session_init(service);
debug_handler("MOD session service: %s", session->remote_service );
/* connect to the remote service */
+ /*
if(!osrf_app_session_connect(session)) {
exception = json_object_new_object();
json_object_object_add( exception, "is_err", json_object_new_int(1));
json_object_put(exception);
return OK;
}
+ */
int req_id = osrf_app_session_make_request( session, NULL, method, 1, sarray );
string_array_destroy(sarray);
buffer_add(result_data, "[");
/* gather result data */
- while((omsg = osrf_app_session_request_recv( session, req_id, 30 ))) {
+ while((omsg = osrf_app_session_request_recv( session, req_id, 60 ))) {
if( omsg->result_string ) {
buffer_add(result_data, omsg->result_string);
osrf_app_session_request_finish( session, req_id );
debug_handler("gateway process message successfully");
+
+ osrf_app_session_destroy(session);
return OK;
}
CC_OPTS += -DASSUME_STATELESS
EXE_LD_OPTS += -lxml2 -lopensrf_transport -lopensrf_stack -lobjson -ljson -lc_utils
-SOURCES = osrf_message.c osrf_app_session.c osrf_stack.c osrf_system.c
-TARGETS = osrf_message.o osrf_app_session.o osrf_stack.o osrf_system.o
-HEADERS = osrf_message.h osrf_app_session.h osrf_stack.h osrf_system.h
+SOURCES = osrf_message.c osrf_app_session.c osrf_stack.c osrf_system.c osrf_config.c
+TARGETS = osrf_message.o osrf_app_session.o osrf_stack.o osrf_system.o osrf_config.o
+HEADERS = osrf_message.h osrf_app_session.h osrf_stack.h osrf_system.h osrf_config.h
all: lib
-#include "opensrf/osrf_app_session.h"
+#include "osrf_app_session.h"
#include <time.h>
/* the global app_session cache */
#include "libjson/json.h"
#include "opensrf/transport_client.h"
-#include "opensrf/generic_utils.h"
#include "osrf_message.h"
#include "osrf_system.h"
#include "string_array.h"
+#include "osrf_config.h"
#ifndef OSRF_APP_SESSION
#define OSRF_APP_SESSION
#include <stdio.h>
-#include "opensrf/transport_client.h"
-#include "opensrf/transport_message.h"
-#include "osrf_message.h"
-#include "opensrf/generic_utils.h"
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+#include "logging.h"
+#include "utils.h"
-char* osrf_config_value(char* path);
+/* libxml stuff for the config reader */
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+//#include <libxml/xpathInternals.h>
+#include <libxml/tree.h>
+
+#include "utils.h"
+
+#ifndef GENERIC_UTILS_H
+#define GENERIC_UTILS_H
+
+#define equals(a,b) !strcmp(a,b)
+
+// ---------------------------------------------------------------------------------
+// Config file module
+// ---------------------------------------------------------------------------------
+struct config_reader_struct {
+ xmlDocPtr config_doc;
+ xmlXPathContextPtr xpathCx;
+ char* name;
+ struct config_reader_struct* next;
+};
+typedef struct config_reader_struct config_reader;
+config_reader* conf_reader;
+//void config_reader_init( char* config_file );
+void config_reader_init( char* name, char* config_file );
+
+void config_reader_free();
+
+// allocastes a char*. FREE me.
+char* config_value( const char* config_name, const char* xp_query, ... );
+
+
+char* osrf_config_value(char* path);
void _osrf_config_grab_config();
+#endif
-#include "opensrf/osrf_message.h"
-
-#include "utils.h"
-#include "objson/object.h"
-#include "objson/json_parser.h"
+#include "osrf_message.h"
/* default to true */
int parse_json_result = 1;
int parse_json_params = 1;
+/* utility function for debugging a DOM doc */
static void recurse_doc( xmlNodePtr node ) {
if( node == NULL ) return;
debug_handler("Recurse: %s => %s", node->name, node->content );
#include "libjson/json.h"
-#include "opensrf/generic_utils.h"
#include "string_array.h"
+#include "utils.h"
+#include "logging.h"
+#include "osrf_config.h"
+#include "objson/object.h"
+#include "objson/json_parser.h"
+
+
+/* libxml stuff for the config reader */
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#include <libxml/tree.h>
+
+
#ifndef osrf_message_h
#define osrf_message_h
-#include "opensrf/osrf_stack.h"
+#include "osrf_stack.h"
osrf_message* _do_client( osrf_app_session*, osrf_message* );
osrf_message* _do_server( osrf_app_session*, osrf_message* );
#include "opensrf/transport_client.h"
#include "osrf_message.h"
#include "osrf_app_session.h"
+#include "osrf_config.h"
#ifndef OSRF_STACK_H
#define OSRF_STACK_H
-#include "opensrf/osrf_system.h"
+#include "osrf_system.h"
transport_client* global_client;
#include "opensrf/transport_client.h"
+#include "utils.h"
+#include "logging.h"
+#include "osrf_config.h"
#ifndef OSRF_SYSTEM_H
#define OSRF_SYSTEM_H
-#include "opensrf/string_array.h"
+#include "string_array.h"
/*
int main() {
LD_OPTS += -lxml2 -lopensrf_transport -lc_utils
-SOURCES = generic_utils.c transport_socket.c transport_session.c transport_message.c transport_client.c
-TARGETS = generic_utils.o transport_socket.o transport_message.o transport_session.o transport_client.o
-HEADERS = generic_utils.h transport_socket.h transport_message.h transport_session.h transport_client.h
+SOURCES = transport_socket.c transport_session.c transport_message.c transport_client.c
+TARGETS = transport_socket.o transport_message.o transport_session.o transport_client.o
+HEADERS = transport_socket.h transport_message.h transport_session.h transport_client.h
all: lib
-#include "opensrf/transport_client.h"
+#include "transport_client.h"
#include "signal.h"
pid_t pid;
-#include "opensrf/transport_client.h"
+#include "transport_client.h"
#include "signal.h"
+/*
+void print_stuff(void* blah, char* data) {
+ fprintf(stderr, "Received from socket: %s\n", data);
+}
+*/
+
/* connects and registers with the router */
int main( int argc, char** argv ) {
+
+
if( argc < 5 ) {
fatal_handler( "Usage: %s <server> <port> <name> <secret>", argv[0] );
}
#include "transport_session.h"
+#include "utils.h"
+#include "logging.h"
+
#include <time.h>
#ifndef TRANSPORT_CLIENT_H
-#include "generic_utils.h"
-
#include <string.h>
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
#include <libxml/debugXML.h>
#include <libxml/xmlmemory.h>
+#include "utils.h"
+#include "logging.h"
+
#ifndef TRANSPORT_MESSAGE_H
#define TRANSPORT_MESSAGE_H
// ---------------------------------------------------------------------------------
#include "transport_socket.h"
#include "transport_message.h"
-#include "generic_utils.h"
+
+#include "utils.h"
+#include "logging.h"
#include "sha.h"
-#include "generic_utils.h"
-
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <errno.h>
+#include "utils.h"
+#include "logging.h"
//---------------------------------------------------------------
// WIN32
//---------------------------------------------------------------
} else {
$app_session->reset;
$app_session->state( $app_session->DISCONNECTED );
- $app_session->push_resend( $app_session->app_request( $doc->documentElement->firstChild->threadTrace ) );
+ # below will lead to infinite looping, should return an exception
+ #$app_session->push_resend( $app_session->app_request(
+ # $doc->documentElement->firstChild->threadTrace ) );
+ $logger->debug(
+ "Got Jabber error on client connection $remote_id, nothing we can do..", ERROR );
return 1;
}
}
$0 = "$0*";
if( ! $data or ! defined( $data ) or $data eq "" ) {
+ close($self->{server}->{client});
$logger->debug("Unix child received empty data from socket", ERROR);
$0 = $orig;
return;
LD_OPTS += -lc_utils -lxml2 -lopensrf_stack -ljson -lobjson
LP = ../libtransport
-LIB_SOURCES = $(LP)/generic_utils.c $(LP)/transport_socket.c \
- $(LP)/transport_session.c $(LP)/transport_message.c $(LP)/transport_client.c
+LIB_SOURCES = $(LP)/transport_socket.c $(LP)/transport_session.c $(LP)/transport_message.c $(LP)/transport_client.c
all: router
#include "opensrf/transport_client.h"
#include "opensrf/transport_message.h"
#include "opensrf/osrf_message.h"
-#include "opensrf/generic_utils.h"
+
+#include "utils.h"
+#include "logging.h"
+#include "osrf_config.h"
#include <time.h>
#include <sys/select.h>
json_object_array_add(params, json_object_new_string("2"));
char* methods[] = { "add", "sub", "mult", "div" };
- char* answers[] = { "3", "-1", "2", "0.500000" };
+ char* answers[] = { "3", "-1", "2", "0.5" };
float times[ count * 4 ];
memset(times,0,count*4);
#include <sys/timeb.h>
#include "md5.h"
+#include "utils.h"
#include <signal.h>
#include <readline/history.h>
+
+
#define SRFSH_PORT 5222
#define COMMAND_BUFSIZE 4096