From e9cfced8a9370f7e206f5e97d50b1452eaca15d4 Mon Sep 17 00:00:00 2001 From: Kevin Adler Date: Mon, 27 Jan 2020 13:49:57 -0600 Subject: [PATCH] fix: Make XMLVER always print version message The current RPG code calls writeIFS to write directly to file descriptor 1 (stdout), but this descriptor is not guaranteed to be set up and most certainly is *not* when the program is called from a CL command line instead of from QSH. Instead, of calling write() we can call printf(), which ensures that this descriptor gets set up and a temporary terminal output window is shown when XMLVER is called from a CL prompt and the output is shown like normal when called from QSH. In addition, print a trailing newline so as to not mess up the prompt when called from a shell. --- .bumpversion.cfg | 2 ++ Makefile.in | 7 ++++++ src/xmlver.c | 10 +++++++++ src/xmlver.rpgle | 56 ------------------------------------------------ 4 files changed, 19 insertions(+), 56 deletions(-) create mode 100644 src/xmlver.c delete mode 100644 src/xmlver.rpgle diff --git a/.bumpversion.cfg b/.bumpversion.cfg index a844b88..5854faa 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -10,6 +10,8 @@ serialize = [bumpversion:file:src/plugconf_h.rpgle] +[bumpversion:file:src/xmlver.c] + [bumpversion:file:docs/conf.py] [bumpversion:part:release] diff --git a/Makefile.in b/Makefile.in index aa4917e..346106c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -104,6 +104,13 @@ xmlstoredp.srvpgm: qsrvsrc.srcpf $(XMLSTOREDP_MODULES) if [ -e $*.failed ]; then rm $*.failed; exit 1; fi touch $@ +%.module: src/%.c + system "CRTCMOD MODULE($(LIBRARY)/$*) SRCSTMF('$<') DBGVIEW($(DBGVIEW)) REPLACE(*YES) TGTCCSID(37)" > $*.log 2> $*.msg && rm $*.log $*.msg || touch $*.failed + test ! -e $*.msg || cat $*.msg + test ! -e $*.log || cat $*.log + if [ -e $*.failed ]; then rm $*.failed; exit 1; fi + touch $@ + %.lib: (system -q 'CHKOBJ $* *LIB' || system -q 'CRTLIB $*') && touch $@ diff --git a/src/xmlver.c b/src/xmlver.c new file mode 100644 index 0000000..9b6b89a --- /dev/null +++ b/src/xmlver.c @@ -0,0 +1,10 @@ +#include + +const char* version = "XML Toolkit 2.0.2-dev"; + +int main() +{ + printf("%s\n", version); + return 0; +} + diff --git a/src/xmlver.rpgle b/src/xmlver.rpgle deleted file mode 100644 index 0100f8b..0000000 --- a/src/xmlver.rpgle +++ /dev/null @@ -1,56 +0,0 @@ - H AlwNull(*UsrCtl) - H BNDDIR('QC2LE') - - ***************************************************** - * Copyright (c) 2010, IBM Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, - * with or without modification, are permitted provided - * that the following conditions are met: - * - Redistributions of source code must retain - * the above copyright notice, this list of conditions - * and the following disclaimer. - * - Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions - * and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of the IBM Corporation nor the names - * of its contributors may be used to endorse or promote - * products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ***************************************************** - - ***************************************************** - * includes - ***************************************************** - /copy plugconf_h - - D Main PR ExtPgm('XMLVER') - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * main(): Control flow - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - D Main PI - d rc s 10i 0 inz(-1) - D myver S 100A inz(*BLANKS) - /free - myver = PLUGVER + x'00'; - rc = writeIFS(1:%addr(myver):strlen(%addr(myver))); - return; - /end-free -