LP#1243841 - Quiet unused return value warning in srfsh.c Using the technique described here: https://stackoverflow.com/a/13999461. Signed-off-by: Chris Sharp <csharp@georgialibraries.org> Signed-off-by: Jason Stephenson <jason@sigio.com> Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
LP#1485371: Use client-supplied TZ Currently, there is no protocol-level mechanism for passing the client's desired timezone to the server. In much the same way we pass the locale, we can let the server know what timezone it should use when interpreting time stamps. To do this we: * Teach perl server code to live in the client TZ, if supplied * Teach perl client code to send the current $ENV{TZ} * Teach javascript library to include client TZ in gateway/translator/websocket communication * Teach C code to pull the incoming TZ and apply it to outgoing messages * Teach srfsh to pull TZ from the environment and pass it with requests Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
LP#1152272: do not log batch invocation of srfsh in .srfsh_history When running srfsh to process a script, do not log the requests in .srfsh_history. To test ------- [1] Run the following command: echo 'request opensrf.math opensrf.system.echo "foo"' | srfsh [2] Note that the last line of ~/.srfsh_history should be 'request opensrf.math opensrf.system.echo "foo"' [3] Apply the patch, compile, and run echo 'request opensrf.math opensrf.system.echo "bar"' | srfsh [4] This time, no additional line should have been added to ~/.srfsh_history [5] Another variation to try: srfsh test.srfsh Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com>
LP#1461625: ensure srfsh doesn't close STDOUT prematurely Ensure that when running srfsh in non-interactive mode that reads commands directly from a file, (i.e., "srfsh script.srfsh" or as a shebang script), it does not close STDOUT after handling the first request. To test ------- [1] Create a srfsh script containing: request opensrf.math opensrf.system.echo "foo" request opensrf.math opensrf.system.echo "bar" [2] Run "srfsh script.srfsh". Note that only the results of the first echo request are output. [3] Apply the patch and recompile, then run "srfsh script.srfsh" again. This time, the output of both requests is displayed. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com>
LP#1436047: make srfsh --safe act as if "! command" doesn't exist This patch make srfsh treat attempting to run an external command via "! command" as a parsing error if --safe is supplied. It also suppress mention of "! commands" from the internal help. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com>
LP#1436047: Allow disabling of "bang commands" in srfsh srfsh has the ability to execute commands via system() calls using the common "!command" syntax. This is very useful, but it would be nice to be able to turn that functionality off in some cases. This branch adds argument parsing to detect a new '--safe' command line parameter, which disables the "!command" syntax. Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Set OpenSRF ingress value for srfsh/gateways Sets the "srfsh", "gateway-v1", and "translator-v1" ingress values accordingly. For the translater, it's necessary to stamp the unpacked messages with the updated ingress, then re-serialize before sending the messages along. Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com>
Minor cleanup: Changed two calls to buffer_add(), when appending a single character, to call buffer_add_char() instead, which is slightly more efficient. M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1996 9efc2488-bf62-4759-914b-345cdb29e865
1. For the "request" command: removed the calls to osrfAppSessionConnect() and osrf_app_session_disconnect(). There's no point in opening and closing a connection for a single request. 2. For the "math_bench" command: coerce the first command argument to a positive value. In the old code, a zero value led to a division-by-zero, and a negative value led to a segfault. 3. For the "math_bench" command: accept an optional second parameter to control whether and when we call osrf_app_session_disconnect(). It has valid values of 0 (the default), 1, and 2; values out of range are coerced to valid values. 4. In do_math(): initialize the array of floats by setting each float to zero, instead of by using memset() to fill the array with all-bits-zero. The C Standard does not guarantee that all-bits-zero represents zero for a float. (This last change shouldn't make any difference anyway, because each float in the array is overwritten before it is read. Still, anything not worth doing is not worth doing badly.) M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1922 9efc2488-bf62-4759-914b-345cdb29e865
Rearrange the error handling a bit in send_request(). The old code looked like it would segfault in the case of a relay command. M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1913 9efc2488-bf62-4759-914b-345cdb29e865
1. In osrf_app_session.[ch]: Create a new function osrfAppSessionSendRequest(), similar to osrfAppSessionMakeRequest() but without the param_strings parameter. 2. Replace the old function with the new one in srfsh.c. M include/opensrf/osrf_app_session.h M src/libopensrf/osrf_app_session.c M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1873 9efc2488-bf62-4759-914b-345cdb29e865
1. Fixed a bug whereby the display of request results was not showing up when pretty-printing was turned off. We were calling jsonObjectGetString() when we should have been calling jsonObjectToJSON(), and thereby getting NULL instead of a usable string, for any but the most trivial of results. Also: applied some minor refinements to nearby code. 2. In handle_request(): eliminated a couple of superfluous variables. 3. Corrected an erroneous statement in the help message. Request output passes through less when raw_print is false, not when it's true. 4. Tidied up the white space here and there. M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1848 9efc2488-bf62-4759-914b-345cdb29e865
Corrected a glitch in the command-line parser. Now commas are treated as the equivalent of white space between parameters. For example { "a":5 },{ "b":true } is parsed as two separate JSON objects, even though there is no white space between them. M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1845 9efc2488-bf62-4759-914b-345cdb29e865
Improve the 'help' output for srfsh: * Document the method-name parameter for the introspect command * Document the currently supported srfsh variables * Reorganize the help slightly to place more emphasis on introspect and request and cut down on some of the blank lines. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1826 9efc2488-bf62-4759-914b-345cdb29e865
1. Replace the old JSON parser (jsonParseString()) with a newer, faster one (jsonParse()). 2. Because the new JSON parser is strict about syntax errors that the old parser would ignore, it was necessary to parse the srfsh command line more intelligently. Otherwise it would be impossible to build a JSON string internally with reliably correct syntax. Hence: instead of using strtok() to break up the command line into tokens, we now use a rudimentary recursive descent parser to isolate JSON strings as distinct arguments, even if they contain embedded white space. As a fairly benign side effect of these changes, the treatment of commas in the command line is changing a bit. All parts of the command line (not just JSON strings) may now be optionally separated by commas. 3. We now use an osrfStringArray to hold the results of parsing, rather than a bare array of pointers. 4. The function formerly known as "parse_request" is now named "process_request", because it does a lot more than just parsing. M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1817 9efc2488-bf62-4759-914b-345cdb29e865
Small performance tweak. Replaced two occurrences of jsonParseString( "[]" ) with the equivalant (and faster) call to jsonNewObject( JSON_ARRAY ). M src/libopensrf/osrf_application.c M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1808 9efc2488-bf62-4759-914b-345cdb29e865
Add two new commands, "open" and "close", to open and close ongoing connections to specified services. (Otherwise a connection is created and destroyed for every request.) Main purpose: to be able to use srfsh for database operations that require transactions. Warning: typically the <keepalive> value will need to be increased for the service in question in opensrf.xml, or else the server will close the connection before you can type your request. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1725 9efc2488-bf62-4759-914b-345cdb29e865
1. If an input line ends in a backslash, remove the backslash and append the following line as a continuation. 2. Disable the readline library's special treatment of horizontal tabs, which by default trigger file name completion (which is not useful for srfsh). 3. In calls to strtok(): accept horizontal tabs as delimiters, since they are no longer suppressed by readline(). git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1716 9efc2488-bf62-4759-914b-345cdb29e865
Plug a memory leak reported by Steven Chan. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1687 9efc2488-bf62-4759-914b-345cdb29e865
Patch from Scott McKellar: I stumbled across another redundant and deprecated identifier. This patch replaces osrf_app_session_connect with osrfAppSessionConnect. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1520 9efc2488-bf62-4759-914b-345cdb29e865