From a2f3b15a0b1b717b3c8c47e40938eea0433b98e5 Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 28 May 2007 14:13:01 +0000 Subject: [PATCH] General cleanup patch from Scott McKellar; static-ify local functions, clean up some getopt usage, fix readline memory leak. http://list.georgialibraries.org/pipermail/open-ils-dev/2007-May/000789.html git-svn-id: svn://svn.open-ils.org/ILS/trunk@7363 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/oils_requestor.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/extras/oils_requestor.c b/Open-ILS/src/extras/oils_requestor.c index 77d3a9ffcc..a6d2d986fd 100644 --- a/Open-ILS/src/extras/oils_requestor.c +++ b/Open-ILS/src/extras/oils_requestor.c @@ -11,12 +11,12 @@ char* script = NULL; char* authtoken = NULL; -int do_request( char* request ); -char* format_response( jsonObject* o ); +static int do_request( char* request ); +static char* format_response( jsonObject* o ); int main( int argc, char* argv[] ) { - char c; + int c; char* username = NULL; char* password = NULL; char* config = NULL; @@ -63,16 +63,24 @@ int main( int argc, char* argv[] ) { printf("Login Session: %s\n", authtoken); } - while((request=readline("oils# "))) - if(do_request(request)) break; + while( request=readline("oils# ") ) { + int retcode = do_request(request); + free(request); + if( retcode ) break; + } + free(config); + free(context); + free(username); + free(password); + free(script); free(authtoken); free(idl_filename); return 1; } -int do_request( char* request ) { +static int do_request( char* request ) { if(!strcasecmp(request, "exit") || !strcasecmp(request,"quit")) return 1; @@ -120,7 +128,7 @@ int do_request( char* request ) { } -char* format_response( jsonObject* o ) { +static char* format_response( jsonObject* o ) { if(!o) return NULL; int width = 20; -- 2.43.2