moved the idl file fetching logic directly into oils_utils
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 21 Feb 2007 21:46:22 +0000 (21:46 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 21 Feb 2007 21:46:22 +0000 (21:46 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6979 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/Makefile
Open-ILS/src/c-apps/oils_auth.c
Open-ILS/src/c-apps/oils_cstore.c
Open-ILS/src/c-apps/oils_utils.c
Open-ILS/src/c-apps/oils_utils.h

index 4ebbbd1..3ecbe0e 100644 (file)
@@ -19,7 +19,7 @@ oils_dataloader:      oils_dataloader.o
 oils_cstore.so:        oils_cstore.o liboils_utils.so liboils_idl.so
        @echo $@
        $(CC) -shared -W1 -L/usr/local/lib/dbd \
-               $(LDLIBS) $(LDFLAGS) -loils_idl -ldbi -ldbdpgsql oils_cstore.o -o $(TMPDIR)/$@
+               $(LDLIBS) $(LDFLAGS) -loils_idl -ldbi -loils_utils -ldbdpgsql oils_cstore.o -o $(TMPDIR)/$@
 
 oils_rstore.o: oils_cstore.c oils_utils.h
        $(CC) $(CFLAGS) -I$(TMPDIR) -I$(TMPDIR)/opensrf/ -DRSTORE -c -o $@ oils_cstore.c 
index cb0bf0c..ad3fb3d 100644 (file)
@@ -27,9 +27,8 @@ int osrfAppInitialize() {
 
        osrfLogInfo(OSRF_LOG_MARK, "Initializing Auth Server...");
 
-       char* idl_filename = osrf_settings_host_value("/IDL");
-       if (!oilsInitIDL( idl_filename )) exit(1);
-       free(idl_filename);
+    /* load and parse the IDL */
+       if (!oilsInitIDL(NULL)) return 1; /* return non-zero to indicate error */
 
        osrfAppRegisterMethod( 
                MODULENAME, 
index 7cc33ab..72983a4 100644 (file)
@@ -89,14 +89,7 @@ int osrfAppInitialize() {
        osrfLogInfo(OSRF_LOG_MARK, "Initializing the CStore Server...");
        osrfLogInfo(OSRF_LOG_MARK, "Finding XML file...");
 
-       char* idl_filename = osrf_settings_host_value("/IDL", MODULENAME);
-       osrfLogInfo(OSRF_LOG_MARK, "Found file:");
-       osrfLogInfo(OSRF_LOG_MARK, idl_filename);
-
-       if (!oilsIDLInit( idl_filename )) {
-               osrfLogError(OSRF_LOG_MARK, "Problem loading the IDL.  Seacrest out!");
-               exit(1);
-       }
+       if (!oilsInitIDL(NULL)) return 1; /* return non-zero to indicate error */
 
        // Generic search thingy
        method_name =  buffer_init(64);
index 74fa652..845a657 100644 (file)
@@ -1,19 +1,27 @@
 #include "oils_utils.h"
 #include "oils_idl.h"
 
-// XXX this is entirely untested!!!
 osrfHash* oilsInitIDL(char* idl_filename) {
 
+    int freeme = 0;
+    if(!idl_filename) {
+           idl_filename = osrf_settings_host_value("/IDL");
+        freeme = 1;
+    }
+
        if (!idl_filename) {
-               osrfLogError(OSRF_LOG_MARK, "At least give me a file to try!");
+               osrfLogError(OSRF_LOG_MARK, "No settings config for '/IDL'");
                return NULL;
        }
 
+    osrfLogInfo(OSRF_LOG_MARK, "Parsing IDL %s", idl_filename);
+
        if (!oilsIDLInit( idl_filename )) {
                osrfLogError(OSRF_LOG_MARK, "Problem loading IDL file [%s]!", idl_filename);
                return NULL;
        }
 
+    if(freeme) free(idl_filename);
        return oilsIDL();
 }
 
index 590ff1d..3e134d5 100644 (file)
 #include "opensrf/osrf_settings.h"
 
 /**
-  An entirely untested IDL initializer. Returns NULL on failure
+  Loads the IDL. Returns NULL on failure
   or a pointer to the IDL data structure on success.
-  @param idl_filename The file to load the IDL from.
+  @param idl_filename If not provided, we'll fetch the 
+  filename from the settings server
  */
-osrfHash* oilsInitIDL(char* idl_filename);
+osrfHash* oilsInitIDL( char* idl_filename );
 
 /**
   Returns the string value for field 'field' in the given object.