From 1e36675be57d3d9012fd862cea46afa2928d19cf Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 24 Mar 2023 08:31:57 -0700 Subject: [PATCH] qsrv: import softMain.cpp from Base circa 7.0.7 --- qsrv/makeInstallDir.pl | 28 +++++ qsrv/softIocPVXExit.db | 15 +++ qsrv/softMain.cpp | 277 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 qsrv/makeInstallDir.pl create mode 100644 qsrv/softIocPVXExit.db create mode 100644 qsrv/softMain.cpp diff --git a/qsrv/makeInstallDir.pl b/qsrv/makeInstallDir.pl new file mode 100644 index 0000000..32f5dfe --- /dev/null +++ b/qsrv/makeInstallDir.pl @@ -0,0 +1,28 @@ +#!/usr/bin/env perl +#************************************************************************* +# Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne +# National Laboratory. +# SPDX-License-Identifier: EPICS +# EPICS BASE is distributed subject to a Software License Agreement found +# in file LICENSE that is included with this distribution. +#************************************************************************* + +use strict; + +die "$0: Argument missing, INSTALL_LOCATION\n" if @ARGV == 0; +die "$0: Too many arguments, expecting one\n" unless @ARGV == 1; + +my $path = shift; + +$path =~ s/\\/\\\\/gx; +$path =~ s/^'//; +$path =~ s/'$//; + +print "/* THIS IS A GENERATED FILE. DO NOT EDIT! */\n", + "\n", + "#ifndef INC_epicsInstallDir_H\n", + "#define INC_epicsInstallDir_H\n", + "\n", + "#define EPICS_BASE \"$path\"\n", + "\n", + "#endif /* INC_epicsInstallDir_H */\n"; diff --git a/qsrv/softIocPVXExit.db b/qsrv/softIocPVXExit.db new file mode 100644 index 0000000..c530f77 --- /dev/null +++ b/qsrv/softIocPVXExit.db @@ -0,0 +1,15 @@ +# softIocExit.db + +record(sub,"$(IOC):exit") { + field(DESC,"Exit subroutine") + field(SCAN,"Passive") + field(SNAM,"exit") +} + +record(stringin,"$(IOC):BaseVersion") { + field(DESC,"EPICS Base Version") + field(DTYP,"getenv") + field(INP,"@EPICS_VERSION_FULL") + field(PINI,"YES") + field(DISP,1) +} diff --git a/qsrv/softMain.cpp b/qsrv/softMain.cpp new file mode 100644 index 0000000..11eb761 --- /dev/null +++ b/qsrv/softMain.cpp @@ -0,0 +1,277 @@ +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2003 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* SPDX-License-Identifier: EPICS +* EPICS BASE is distributed subject to the Software License Agreement +* found in the file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* Author: Andrew Johnson Date: 2003-04-08 */ + +#include +#include +#include +#include + +#include +#include "registryFunction.h" +#include "epicsThread.h" +#include "epicsExit.h" +#include "epicsStdio.h" +#include "epicsString.h" +#include "dbStaticLib.h" +#include "subRecord.h" +#include "dbAccess.h" +#include "asDbLib.h" +#include "iocInit.h" +#include "iocsh.h" +#include "osiFileName.h" +#include "epicsInstallDir.h" + +extern "C" int softIoc_registerRecordDeviceDriver(struct dbBase *pdbbase); + +#ifndef EPICS_BASE +// so IDEs knows EPICS_BASE is a string constant +# define EPICS_BASE "/" +# error -DEPICS_BASE required +#endif + +#define DBD_BASE "dbd" OSI_PATH_SEPARATOR "softIoc.dbd" +#define EXIT_BASE "db" OSI_PATH_SEPARATOR "softIocExit.db" +#define DBD_FILE_REL ".." OSI_PATH_SEPARATOR ".." OSI_PATH_SEPARATOR DBD_BASE +#define EXIT_FILE_REL ".." OSI_PATH_SEPARATOR ".." OSI_PATH_SEPARATOR EXIT_BASE +#define DBD_FILE EPICS_BASE OSI_PATH_SEPARATOR DBD_BASE +#define EXIT_FILE EPICS_BASE OSI_PATH_SEPARATOR EXIT_BASE + +namespace { + +bool verbose = false; + +static void exitSubroutine(subRecord *precord) { + epicsExitLater((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE); +} + +void usage(const char *arg0, const std::string& base_dbd) { + std::cout<<"Usage: "< If used, must come first. Specify the path to the softIoc.dbdfile." + " The compile-time install location is saved in the binary as a default.\n" + "\n" + " -h Print this mesage and exit.\n" + "\n" + " -S Prevents an interactive shell being started.\n" + "\n" + " -s Previously caused a shell to be started. Now accepted and ignored.\n" + "\n" + " -v Verbose, display steps taken during startup.\n" + "\n" + " -a Access Security configuration file. Macro substitution is\n" + " performed.\n" + "\n" + " -m =,... Set/replace macro definitions used by subsequent -d and\n" + " -a.\n" + "\n" + " -d Load records from file (dbLoadRecords). Macro substitution is\n" + " performed.\n" + "\n" + " -x Load softIocExit.db. Provides a record \":exit\".\n" + " Put 0 to exit with success, or non-zero to exit with an error.\n" + "\n" + "Any number of -m and -d arguments can be interspersed; the macros are applied\n" + "to the following .db files. Each later -m option causes earlier macros to be\n" + "discarded.\n" + "\n" + "A st.cmd file is optional. If any databases were loaded the st.cmd file will\n" + "be run *after* iocInit. To perform iocsh commands before iocInit, all database\n" + "loading must be performed by the script itself, or by the user from the\n" + "interactive IOC shell.\n" + "\n" + "Compiled-in path to softIoc.dbd is:\n" + "\t"<