removed everything that is not "require"

This commit is contained in:
2015-08-12 11:39:02 +02:00
parent c9ebf19ba8
commit 122f3981c2
19 changed files with 2 additions and 1215 deletions
-5
View File
@@ -1,5 +0,0 @@
# Please change the following email with yours.
Email: dirk.zimoch@psi.ch
Module-Name: misc
Description: Miscellaneous helper funtions for EPICS
Project-Name:
-29
View File
@@ -1,36 +1,7 @@
include /ioc/tools/driver.makefile
# I need to find the Linux link.h before the EPICS link.h
USR_INCLUDES_Linux=-idirafter ${EPICS_BASE}/include
USR_INCLUDES+=$(USR_INCLUDES_$(OS_CLASS))
USR_CFLAGS=-DEPICS_RELEASE=$(EPICS_VERSION) -DT_A=$(T_A)
HEADERS += require.h
BUILDCLASSES += Linux
SOURCES += require.c
DBDS += require.dbd
SOURCES += listRecords.c
DBDS += listRecords.dbd
SOURCES += updateMenuConvert.c
DBDS += updateMenuConvert.dbd
SOURCES += addScan.c
DBDS += addScan.dbd
SOURCES_3.14 += disctools.c
DBDS_3.14 += disctools.dbd
SOURCES_3.14 += exec.c
DBDS_3.14 += exec.dbd
SOURCES_3.14 += mlock.c
DBDS_3.14 += mlock.dbd
SOURCES_vxWorks += bootNotify.c
HEADERS_3.13 += epicsEndian.h
HEADERS_3.14.8 += epicsEndian.h
+2 -35
View File
@@ -1,37 +1,4 @@
Functions in this library depend on EPICS but are not
real device drivers. It's a bunch of utilities.
Functions are:
require "<lib>" [,"<version>"]
require "<lib>" [,"<version>"] [,"macro1=value, macro2=value"]
shell function
load a library and its dbd file
updateMenuConvert
startup script function
add all loaded breakpoint tables found on this ioc to menu convert
to be called before iocInit
addScan rate
startup script function
create a new scan rate (seconds) and add it to menuScan
to be called before iocInit
bootNotify
startup script function
call a script on the boot pc and tell it a lot of boot infos
dir / ls / ll / mkdir / rmdir / rm / mv / umask / chmod
shell functions
make disc functions available in iocsh
not needed on vxWorks
exec / !
execute an externel command from iocsh
shell function
not available on vxWorks
listRecords filename fields
shell function
wrapper for dbl to get same syntax in 3.13 and 3.14
executes its startup script if available, applying macros and environment
-103
View File
@@ -1,103 +0,0 @@
/* addScan.c
*
* add a new scan rate to the ioc
*
* $Author: zimoch $
*
* $Source: /cvs/G/DRV/misc/addScan.c,v $
*
*/
#include <string.h>
#include <stdlib.h>
#include <dbScan.h>
#include <dbStaticLib.h>
#include <dbAccess.h>
#include <epicsVersion.h>
#ifdef BASE_VERSION
#define EPICS_3_13
extern DBBASE *pdbbase;
#else
#define EPICS_3_14
#include <iocsh.h>
#include <epicsExport.h>
#endif
int addScan (char* ratestr)
{
dbMenu *menuScan;
int l, i, j, nChoice;
char **papChoiceName;
char **papChoiceValue;
double rate, r;
char dummy;
char *name;
if (interruptAccept)
{
fprintf(stderr, "addScan: Can add a scan period only before iocInit!\n");
return -1;
}
if (!ratestr || sscanf (ratestr, "%lf%c", &rate, &dummy) != 1 || rate <= 0)
{
fprintf(stderr, "addScan: Argument '%s' must be a number > 0\n", ratestr);
return -1;
}
menuScan = dbFindMenu(pdbbase,"menuScan");
nChoice = menuScan->nChoice;
for (i=SCAN_1ST_PERIODIC; i < nChoice; i++)
{
r = strtod(menuScan->papChoiceValue[i], NULL);
if (r == rate)
{
fprintf(stderr, "addScan: rate %s already available\n", menuScan->papChoiceValue[i]);
return 0;
}
if (r < rate) break;
}
papChoiceName=dbCalloc(nChoice+1,sizeof(char*));
papChoiceValue=dbCalloc(nChoice+1,sizeof(char*));
for (j=0; j < i; j++)
{
papChoiceName[j] = menuScan->papChoiceName[j];
papChoiceValue[j] = menuScan->papChoiceValue[j];
}
name = ratestr;
while (name[0]=='0') name++;
l = strlen(name);
papChoiceValue[i] = dbCalloc(l+16,1);
strcpy(papChoiceValue[i], name);
strcpy(papChoiceValue[i]+l, " second");
for (j=i; j < nChoice; j++)
{
papChoiceName[j+1] = menuScan->papChoiceName[j];
papChoiceValue[j+1] = menuScan->papChoiceValue[j];
}
free(menuScan->papChoiceName);
free(menuScan->papChoiceValue);
menuScan->papChoiceName=papChoiceName;
menuScan->papChoiceValue=papChoiceValue;
menuScan->nChoice = nChoice+1;
return 0;
}
#ifdef EPICS_3_14
static const iocshArg addScanArg0 = { "rate", iocshArgString };
static const iocshArg * const addScanArgs[1] = { &addScanArg0 };
static const iocshFuncDef addScanDef = { "addScan", 1, addScanArgs };
static void addScanFunc (const iocshArgBuf *args)
{
addScan(args[0].sval);
}
static void addScanRegister(void)
{
static int firstTime = 1;
if (firstTime) {
iocshRegister (&addScanDef, addScanFunc);
firstTime = 0;
}
}
epicsExportRegistrar(addScanRegister);
#endif
-1
View File
@@ -1 +0,0 @@
registrar(addScanRegister)
-67
View File
@@ -1,67 +0,0 @@
/* bootNotify.c
*
* call a script on the boot PC and give it a lot of boot infos
*
* $Author: zimoch $
*
* $Log: bootNotify.c,v $
* Revision 1.4 2013/08/15 09:50:07 zimoch
* strip off leading strings from vxWorksVersion
*
* Revision 1.3 2006/03/03 13:30:33 zimoch
* made epicsver compatible to 3.14
*
* Revision 1.2 2004/05/24 15:18:58 zimoch
* use ifName()
*
* Revision 1.1 2004/04/16 08:07:12 zimoch
* put here from utilities
* these are EPICS dependend, utilities not
*
* Revision 1.4 2004/04/02 14:52:15 zimoch
* generic ethernet address support added
*
* Revision 1.3 2003/03/20 14:57:50 zimoch
* upload of ethernet address added
*
* Revision 1.2 2003/03/18 08:03:28 zimoch
* debugged
*
* Revision 1.1 2003/02/18 17:26:59 zimoch
* split bootUntil.c into 3 parts
*
*
*/
#include <stdio.h>
#include <bootInfo.h>
#include <rsh.h>
#include <version.h>
#include <epicsVersion.h>
int bootNotify (char* script, char* script2)
{
char command[256];
char epicsver[15];
char* vxver = vxWorksVersion;
if (script == NULL)
{
printErr ("usage: bootNotify [\"<path>\",] \"<script>\"\n");
return ERROR;
}
if (script2)
{
sprintf (command, "%s/%s", script, script2);
}
else
{
sprintf (command, "%s", script);
}
/* strip off any leading non-numbers */
while (vxver && (*vxver < '0' || *vxver > '9')) vxver++;
sprintf (epicsver, "%d.%d.%d",
EPICS_VERSION, EPICS_REVISION, EPICS_MODIFICATION);
return rsh (bootHost(), command, bootInfo("%T %e %n %d %F %s"),
vxver, epicsver, etherAddr(ifName()), 0);
}
-433
View File
@@ -1,433 +0,0 @@
/*
* disctools - dir etc.
*
* $Author: zimoch $
* $ID$
* $Date: 2015/07/22 12:25:23 $
*
* DISCLAIMER: Use at your own risc and so on. No warranty, no refund.
*/
#include <iocsh.h>
#include <stdio.h>
#ifdef UNIX
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <time.h>
#include <malloc.h>
#include <pwd.h>
#include <grp.h>
#include <glob.h>
#include <errno.h>
#endif
#include <epicsExport.h>
#ifdef UNIX
/* dir, ll, ls */
static const iocshArg dirArg0 = { "directrory", iocshArgString };
static const iocshArg * const dirArgs[1] = { &dirArg0 };
static const iocshFuncDef dirDef = { "dir", 1, dirArgs };
static const iocshFuncDef llDef = { "ll", 1, dirArgs };
static const iocshFuncDef lsDef = { "ls", 1, dirArgs };
static int nohidden(const struct dirent *entry)
{
return entry->d_name[0] != '.';
}
static void llFunc(const iocshArgBuf *args)
{
char* dirname = ".";
struct dirent** namelist;
struct stat filestat;
char type;
char filename[256];
char target[256];
struct group* group;
struct passwd* user;
struct tm time;
char timestr[20];
int n, i, len;
if (args[0].sval) dirname = args[0].sval;
n = scandir(dirname, &namelist, nohidden, alphasort);
if (n < 0)
{
perror(dirname);
return;
}
for (i = 0; i < n; i++)
{
sprintf(filename, "%s/%s", dirname, namelist[i]->d_name);
if (lstat(filename, &filestat))
{
perror(namelist[i]->d_name);
continue;
}
if (S_ISREG(filestat.st_mode)) type='-';
else if (S_ISDIR(filestat.st_mode)) type='d';
else if (S_ISCHR(filestat.st_mode)) type='c';
else if (S_ISBLK(filestat.st_mode)) type='b';
else if (S_ISFIFO(filestat.st_mode)) type='p';
else if (S_ISLNK(filestat.st_mode)) type='l';
else if (S_ISSOCK(filestat.st_mode)) type='s';
else type='?';
localtime_r(&filestat.st_mtime, &time);
strftime(timestr, 20, "%b %e %Y %H:%M", &time);
printf("%c%c%c%c%c%c%c%c%c%c %4lu",
type,
filestat.st_mode & S_IRUSR ? 'r' : '-',
filestat.st_mode & S_IWUSR ? 'w' : '-',
filestat.st_mode & S_ISUID ? 's' :
filestat.st_mode & S_IXUSR ? 'x' : '-',
filestat.st_mode & S_IRGRP ? 'r' : '-',
filestat.st_mode & S_IWGRP ? 'w' : '-',
filestat.st_mode & S_ISGID ? 's' :
filestat.st_mode & S_IXGRP ? 'x' : '-',
filestat.st_mode & S_IROTH ? 'r' : '-',
filestat.st_mode & S_IWOTH ? 'w' : '-',
filestat.st_mode & S_ISVTX ? 't' :
filestat.st_mode & S_IXOTH ? 'x' : '-',
(unsigned long) filestat.st_nlink);
user=getpwuid(filestat.st_uid);
if (user) printf(" %-8s", user->pw_name);
else printf(" %-8d", filestat.st_uid);
group=getgrgid(filestat.st_gid);
if (group) printf(" %-8s", group->gr_name);
else printf(" %-8d", filestat.st_gid);
printf (" %8ld %s %s",
filestat.st_size, timestr,
namelist[i]->d_name);
if (S_ISLNK(filestat.st_mode))
{
len = readlink(filename, target, 255);
if (len == -1) perror(filename);
else
{
target[len] = 0;
printf(" -> %s\n", target);
}
}
else
{
printf("\n");
}
free(namelist[i]);
}
free(namelist);
}
static void lsFunc(const iocshArgBuf *args)
{
char* dirname = ".";
struct dirent** namelist;
int n, i, cols, rows, r, c, len, maxlen=0;
if (args[0].sval) dirname = args[0].sval;
n = scandir(dirname, &namelist, nohidden, alphasort);
if (n < 0)
{
perror(dirname);
return;
}
for (i = 0; i < n; i++)
{
len = strlen(namelist[i]->d_name);
if (len > maxlen) maxlen = len;
}
cols=80/(maxlen+=2);
rows=(n-1)/cols+1;
for (r = 0; r < rows; r++)
{
for (c = 0; c < cols; c++)
{
i = r + c*rows;
if (i >= n) continue;
printf("%-*s",
maxlen, namelist[i]->d_name);
free(namelist[i]);
}
printf("\n");
}
free(namelist);
}
/* mkdir */
static const iocshArg mkdirArg0 = { "directrory", iocshArgString };
static const iocshArg * const mkdirArgs[1] = { &mkdirArg0 };
static const iocshFuncDef mkdirDef = { "mkdir", 1, mkdirArgs };
static void mkdirFunc(const iocshArgBuf *args)
{
char* dirname;
dirname = args[0].sval;
if (!dirname)
{
fprintf(stderr, "missing directory name\n");
return;
}
if (mkdir(dirname, 0777))
{
perror(dirname);
}
}
/* rmdir */
static const iocshArg rmdirArg0 = { "directrory", iocshArgString };
static const iocshArg * const rmdirArgs[1] = { &rmdirArg0 };
static const iocshFuncDef rmdirDef = { "rmdir", 1, rmdirArgs };
static void rmdirFunc(const iocshArgBuf *args)
{
char* dirname;
dirname = args[0].sval;
if (!dirname)
{
fprintf(stderr, "missing directory name\n");
return;
}
if (rmdir(dirname))
{
perror(dirname);
}
}
/* rm */
static const iocshArg rmArg0 = { "[-rf] files", iocshArgArgv};
static const iocshArg * const rmArgs[1] = { &rmArg0 };
static const iocshFuncDef rmDef = { "rm", 1, rmArgs };
static int globerr (const char *epath, int eerrno)
{
fprintf(stderr, "rm: %s %s\n", epath, strerror(eerrno));
return 0;
}
struct rmflags_t {
unsigned int r : 1;
unsigned int f : 1;
unsigned int endflags : 1;
};
static void rmPriv(char* pattern, struct rmflags_t flags)
{
char* filename;
int j;
glob_t globresult;
glob(pattern, GLOB_NOSORT|GLOB_NOMAGIC
#ifdef GLOB_BRACE
|GLOB_BRACE|GLOB_TILDE
#endif
,globerr, &globresult);
for (j = 0; j < globresult.gl_pathc; j++)
{
filename = globresult.gl_pathv[j];
if (unlink(filename))
{
if (errno == ENOENT && flags.f) continue;
if (errno == EISDIR && flags.r)
{
char* p=malloc(strlen(filename)+3);
if (p)
{
sprintf(p, "%s/*", filename);
rmPriv(p, flags);
free(p);
if (rmdir(filename) == 0) continue;
}
}
perror(filename);
}
}
globfree(&globresult);
}
static void rmFunc(const iocshArgBuf *args)
{
char *arg;
int i,j;
struct rmflags_t flags = {0};
for (i = 1; i < args[0].aval.ac; i++)
{
arg = args[0].aval.av[i];
if (arg[0] != '-') continue;
if (arg[1] == '-' && arg[2] == 0) break;
for (j = 1; arg[j]; j++)
{
switch (arg[j])
{
case 'r': flags.r = 1; break;
case 'f': flags.f = 1; break;
default:
fprintf(stderr, "rm: ignoring unknown option -%c\n", arg[j]);
}
}
}
for (i = 1; i < args[0].aval.ac; i++)
{
arg = args[0].aval.av[i];
if (!flags.endflags && arg[0] == '-')
{
if (arg[1] == '-' && arg[2] == 0)
flags.endflags = 1;
continue;
}
rmPriv(arg, flags);
}
}
/* mv */
static const iocshArg mvArg0 = { "oldname", iocshArgString };
static const iocshArg mvArg1 = { "newname", iocshArgString };
static const iocshArg * const mvArgs[2] = { &mvArg0, &mvArg1 };
static const iocshFuncDef mvDef = { "mv", 2, mvArgs };
static void mvFunc(const iocshArgBuf *args)
{
char* oldname;
char* newname;
struct stat filestat;
char filename[256];
oldname = args[0].sval;
newname = args[1].sval;
if (!oldname || !newname)
{
fprintf(stderr, "need 2 file names\n");
return;
}
if (!stat(newname, &filestat) && S_ISDIR(filestat.st_mode))
{
sprintf(filename, "%s/%s", newname, oldname);
newname = filename;
}
if (rename(oldname, newname))
{
perror("mv");
}
}
/* cp, copy */
static const iocshArg cpArg0 = { "source", iocshArgString };
static const iocshArg cpArg1 = { "target", iocshArgString };
static const iocshArg * const cpArgs[2] = { &cpArg0, &cpArg1 };
static const iocshFuncDef cpDef = { "cp", 2, cpArgs };
static const iocshFuncDef copyDef = { "copy", 2, cpArgs };
static void cpFunc(const iocshArgBuf *args)
{
char buffer [256];
char* sourcename;
char* targetname;
FILE* sourcefile;
FILE* targetfile;
size_t len;
sourcename = args[0].sval;
targetname = args[1].sval;
if (sourcename == NULL || sourcename[0] == '\0')
sourcefile = stdin;
else if (!(sourcefile = fopen(sourcename,"r")))
{
perror(sourcename);
return;
}
if (targetname == NULL || targetname[0] == '\0')
targetfile = stdout;
else if (!(targetfile = fopen(targetname,"w")))
{
perror(targetname);
return;
}
while (!feof(sourcefile))
{
len = fread(buffer, 1, 256, sourcefile);
if (ferror(sourcefile))
{
perror(sourcename);
break;
}
fwrite(buffer, 1, len, targetfile);
if (ferror(targetfile))
{
perror(targetname);
break;
}
}
if (sourcefile != stdin)
fclose(sourcefile);
if (targetfile != stdout)
fclose(targetfile);
else
fflush(stdout);
}
/* umask */
static const iocshArg umaskArg0 = { "mask", iocshArgString };
static const iocshArg * const umaskArgs[1] = { &umaskArg0 };
static const iocshFuncDef umaskDef = { "umask", 1, umaskArgs };
static void umaskFunc(const iocshArgBuf *args)
{
mode_t mask;
if (args[0].sval == NULL)
{
mask = umask(0);
umask(mask);
printf("%03o\n", (int)mask);
return;
}
if (sscanf(args[0].sval, "%o", &mask) == 1)
{
umask(mask);
return;
}
fprintf(stderr, "mode %s not recognized\n", args[0].sval);
}
/* chmod */
static const iocshArg chmodArg0 = { "mode", iocshArgInt };
static const iocshArg chmodArg1 = { "file", iocshArgString };
static const iocshArg * const chmodArgs[2] = { &chmodArg0, &chmodArg1 };
static const iocshFuncDef chmodDef = { "chmod", 2, chmodArgs };
static void chmodFunc(const iocshArgBuf *args)
{
mode_t mode = args[0].ival;
char* path = args[1].sval;
if (chmod(path, mode) != 0)
{
perror(path);
}
}
#endif
static void
disctoolsRegister(void)
{
static int firstTime = 1;
if (firstTime) {
#ifdef UNIX
iocshRegister(&dirDef, llFunc);
iocshRegister(&llDef, llFunc);
iocshRegister(&lsDef, lsFunc);
iocshRegister(&mkdirDef, mkdirFunc);
iocshRegister(&rmdirDef, rmdirFunc);
iocshRegister(&rmDef, rmFunc);
iocshRegister(&mvDef, mvFunc);
iocshRegister(&cpDef, cpFunc);
iocshRegister(&copyDef, cpFunc);
iocshRegister(&umaskDef, umaskFunc);
iocshRegister(&chmodDef, chmodFunc);
#endif
firstTime = 0;
}
}
epicsExportRegistrar(disctoolsRegister);
-1
View File
@@ -1 +0,0 @@
registrar(disctoolsRegister)
-83
View File
@@ -1,83 +0,0 @@
#ifndef INC_epicsEndian_H
#define INC_epicsEndian_H
#define EPICS_ENDIAN_LITTLE 1234
#define EPICS_ENDIAN_BIG 4321
#if defined (vxWorks)
#include <types/vxArch.h>
#if _BYTE_ORDER == _LITTLE_ENDIAN
# define EPICS_BYTE_ORDER EPICS_ENDIAN_LITTLE
#elif _BYTE_ORDER == _BIG_ENDIAN
# define EPICS_BYTE_ORDER EPICS_ENDIAN_BIG
#else
# error EPICS hasnt been ported to _BYTE_ORDER specified by vxWorks <types/vxArch.h>
#endif
/* for now, assume that vxWorks doesnt run on weird arch like ARM NWFP */
#define EPICS_FLOAT_WORD_ORDER EPICS_BYTE_ORDER
#elif defined (_WIN32)
/* for now, assume that win32 runs only on generic little endian */
#define EPICS_BYTE_ORDER EPICS_ENDIAN_LITTLE
#define EPICS_FLOAT_WORD_ORDER EPICS_BYTE_ORDER
#else
/* if compilation fails because this wasnt found then you may need to define an OS
specific osdWireConfig.h */
#include <sys/param.h>
#ifdef __BYTE_ORDER
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define EPICS_BYTE_ORDER EPICS_ENDIAN_LITTLE
# elif __BYTE_ORDER == __BIG_ENDIAN
# define EPICS_BYTE_ORDER EPICS_ENDIAN_BIG
# else
# error EPICS hasnt been ported to run on the <sys/param.h> specified __BYTE_ORDER
# endif
#else
# ifdef BYTE_ORDER
# if BYTE_ORDER == LITTLE_ENDIAN
# define EPICS_BYTE_ORDER EPICS_ENDIAN_LITTLE
# elif BYTE_ORDER == BIG_ENDIAN
# define EPICS_BYTE_ORDER EPICS_ENDIAN_BIG
# else
# error EPICS hasnt been ported to run on the <sys/param.h> specified BYTE_ORDER
# endif
# else
# error <sys/param.h> doesnt specify __BYTE_ORDER or BYTE_ORDER - is an OS specific osdWireConfig.h needed?
# endif
#endif
#ifdef __FLOAT_WORD_ORDER
# if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
# define EPICS_FLOAT_WORD_ORDER EPICS_ENDIAN_LITTLE
# elif __FLOAT_WORD_ORDER == __BIG_ENDIAN
# define EPICS_FLOAT_WORD_ORDER EPICS_ENDIAN_BIG
# else
# error EPICS hasnt been ported to <sys/param.h> specified __FLOAT_WORD_ORDER
# endif
#else
# ifdef FLOAT_WORD_ORDER
# if FLOAT_WORD_ORDER == LITTLE_ENDIAN
# define EPICS_FLOAT_WORD_ORDER EPICS_ENDIAN_LITTLE
# elif FLOAT_WORD_ORDER == BIG_ENDIAN
# define EPICS_FLOAT_WORD_ORDER EPICS_ENDIAN_BIG
# else
# error EPICS hasnt been ported to <sys/param.h> specified FLOAT_WORD_ORDER
# endif
# else
/* assume that if neither __FLOAT_WORD_ORDER nor FLOAT_WORD_ORDER are
defined then weird fp ordered archs like arm nwfp aren't supported */
# define EPICS_FLOAT_WORD_ORDER EPICS_BYTE_ORDER
# endif
#endif
#endif
#endif /* INC_epicsEndian_H */
-128
View File
@@ -1,128 +0,0 @@
/*
* exec - execute shell commands.
*
* $Author: zimoch $
* $ID$
* $Date: 2015/05/18 10:46:32 $
*
* DISCLAIMER: Use at your own risc and so on. No warranty, no refund.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <iocsh.h>
#include <stdio.h>
#ifdef UNIX
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <time.h>
#include <string.h>
#include <malloc.h>
#include <errno.h>
#endif
#include <epicsExport.h>
#ifdef UNIX
static const iocshArg execArg0 = { "command", iocshArgString };
static const iocshArg execArg1 = { "arguments", iocshArgArgv };
static const iocshArg * const execArgs[2] = { &execArg0, &execArg1 };
static const iocshFuncDef execDef = { "exec", 2, execArgs };
static const iocshFuncDef exclDef = { "!", 2, execArgs }; /* alias */
static void execFunc (const iocshArgBuf *args)
{
char commandline [256];
int i;
int status;
size_t len;
char *p = commandline;
char *arg;
char special;
if (args[0].sval == NULL)
{
system(getenv("SHELL"));
return;
}
else
{
for (i = 0; i < args[1].aval.ac; i++)
{
arg = args[1].aval.av[i];
len = strlen(arg);
special = 0;
if (len) {
special = arg[len-1];
if (special == '|' || special == ';' || special == '&') len--;
else special = 0;
}
if (p - commandline + len + 4 >= sizeof(commandline))
{
fprintf (stderr, "command line too long\n");
return;
}
/* quote words to protect special chars (e.g. spaces) */
p += sprintf(p, " \"%.*s\"", (int)len, arg);
/* add unquoted special chars | ; & */
if (special) p += sprintf(p, "%c", special);
}
status = system(commandline);
}
if (WIFSIGNALED(status))
{
#ifdef __USE_GNU
fprintf (stderr, "%s killed by signal %d: %s\n",
args[0].sval, WTERMSIG(status), strsignal(WTERMSIG(status)));
#else
fprintf (stderr, "%s killed by signal %d\n",
args[0].sval, WTERMSIG(status));
#endif
}
if (WEXITSTATUS(status))
{
fprintf (stderr, "exit status is %d\n", WEXITSTATUS(status));
}
}
/* sleep */
static const iocshArg sleepArg0 = { "seconds", iocshArgDouble };
static const iocshArg * const sleepArgs[1] = { &sleepArg0 };
static const iocshFuncDef sleepDef = { "sleep", 1, sleepArgs };
static void sleepFunc (const iocshArgBuf *args)
{
struct timespec sleeptime;
sleeptime.tv_sec = (long) args[0].dval;
sleeptime.tv_nsec = (long) ((args[0].dval - (long) args[0].dval) * 1000000000);
while (nanosleep (&sleeptime, &sleeptime) == -1)
{
if (errno != EINTR)
{
perror("sleep");
break;
}
}
}
#endif
static void
execRegister(void)
{
static int firstTime = 1;
if (firstTime) {
#ifdef UNIX
iocshRegister (&execDef, execFunc);
iocshRegister (&exclDef, execFunc);
iocshRegister (&sleepDef, sleepFunc);
#endif
firstTime = 0;
}
}
epicsExportRegistrar(execRegister);
-1
View File
@@ -1 +0,0 @@
registrar(execRegister)
-80
View File
@@ -1,80 +0,0 @@
/* listRecords.c
*
* listRecords is a wrapper function for dbl
* it hides the changed syntax of dbl in R3.14.
*
* $Author: zimoch $
*
* $Source: /cvs/G/DRV/misc/listRecords.c,v $
*
*/
#include <stddef.h>
#include <errno.h>
#include <epicsVersion.h>
#ifdef BASE_VERSION
#define EPICS_3_13
#include <stdio.h>
long dbl(char *precordTypename, char *filename, char *fields);
#else
#define EPICS_3_14
#include <string.h>
#include <dbTest.h>
#include <epicsStdio.h>
#include <iocsh.h>
#include <epicsExport.h>
#endif
int listRecords(char* filename, char* fields)
{
#ifdef EPICS_3_13
return dbl(NULL, filename, fields);
#else
{
FILE* oldStdout = NULL;
FILE* newStdout = NULL;
if (filename && *filename)
{
newStdout = fopen(filename, "w");
if (!newStdout)
{
fprintf (stderr, "Can't open %s for writing: %s\n",
filename, strerror(errno));
return errno;
}
oldStdout = epicsGetThreadStdout();
epicsSetThreadStdout(newStdout);
}
dbl(0L, fields);
if (newStdout)
{
fclose(newStdout);
epicsSetThreadStdout(oldStdout);
}
return 0;
}
#endif
}
#ifdef EPICS_3_14
static const iocshArg listRecordsArg0 = { "filename", iocshArgString };
static const iocshArg listRecordsArg1 = { "fields", iocshArgString };
static const iocshArg * const listRecordsArgs[2] = { &listRecordsArg0, &listRecordsArg1 };
static const iocshFuncDef listRecordsDef = { "listRecords", 2, listRecordsArgs };
static void listRecordsFunc (const iocshArgBuf *args)
{
listRecords(args[0].sval, args[1].sval);
}
static void listRecordsRegister(void)
{
static int firstTime = 1;
if (firstTime) {
iocshRegister (&listRecordsDef, listRecordsFunc);
firstTime = 0;
}
}
epicsExportRegistrar(listRecordsRegister);
#endif
-1
View File
@@ -1 +0,0 @@
registrar(listRecordsRegister)
-48
View File
@@ -1,48 +0,0 @@
#include <iocsh.h>
#include <epicsExport.h>
#ifdef UNIX
#include <stdio.h>
#include <sys/mman.h>
#endif
#ifdef UNIX
static const iocshFuncDef mlockDef = { "mlock", 0, NULL };
static void mlockFunc(const iocshArgBuf *args)
{
int status;
status = mlockall(MCL_CURRENT|MCL_FUTURE);
if (status != 0) {
perror ("mlock failed");
}
}
static const iocshFuncDef munlockDef = { "munlock", 0, NULL };
static void munlockFunc(const iocshArgBuf *args)
{
int status;
status = munlockall();
if (status != 0) {
perror ("mlock failed");
}
}
#endif
static void
mlockRegister(void)
{
static int firstTime = 1;
if (firstTime) {
#ifdef UNIX
iocshRegister(&mlockDef, mlockFunc);
iocshRegister(&munlockDef, munlockFunc);
#endif
}
}
epicsExportRegistrar(mlockRegister);
-1
View File
@@ -1 +0,0 @@
registrar(mlockRegister)
-119
View File
@@ -1,119 +0,0 @@
/* updateMenuConvert.c
*
* add all breakpoint tables found on this ioc
* to the menu convert (used by LINR field)
*
* $Author: zimoch $
*
* $Source: /cvs/G/DRV/misc/updateMenuConvert.c,v $
*
*/
#include <string.h>
#include <ellLib.h>
#include <stdlib.h>
#include <dbScan.h>
#include <dbStaticLib.h>
#include <dbAccess.h>
#include <epicsVersion.h>
#ifdef BASE_VERSION
#define EPICS_3_13
extern DBBASE *pdbbase;
#else
#define EPICS_3_14
#include <iocsh.h>
#include <epicsExport.h>
#endif
typedef struct node {
ELLNODE node;
char *name;
char *value;
} node;
int updateMenuConvert ()
{
brkTable *pbrkTable;
dbMenu *menuConvert;
ELLLIST missing;
node *pbtable;
int l, i, found, nChoice;
char **papChoiceName;
char **papChoiceValue;
if (interruptAccept)
{
fprintf(stderr, "updateMenuConvert: Can update menuConvert only before iocInit!\n");
return -1;
}
menuConvert = dbFindMenu(pdbbase,"menuConvert");
ellInit(&missing);
for(pbrkTable = (brkTable *)ellFirst(&pdbbase->bptList);
pbrkTable;
pbrkTable = (brkTable *)ellNext(&pbrkTable->node))
{
found=0;
for(i=0; i<menuConvert->nChoice; i++)
{
if (strcmp(menuConvert->papChoiceValue[i],pbrkTable->name)==0)
{
found=1;
break;
}
}
if (!found)
{
pbtable = dbCalloc(1,sizeof(struct node));
l=strlen(pbrkTable->name);
pbtable->name = dbCalloc(l+12,1);
pbtable->value = dbCalloc(l+1,1);
strcpy(pbtable->name, "menuConvert");
strcpy(pbtable->name+11, pbrkTable->name);
strcpy(pbtable->value, pbrkTable->name);
ellAdd(&missing, &pbtable->node);
}
}
if (ellCount(&missing))
{
nChoice = menuConvert->nChoice + ellCount(&missing);
papChoiceName=dbCalloc(nChoice,sizeof(char*));
papChoiceValue=dbCalloc(nChoice,sizeof(char*));
for (i=0; i<menuConvert->nChoice; i++)
{
papChoiceName[i] = menuConvert->papChoiceName[i];
papChoiceValue[i] = menuConvert->papChoiceValue[i];
}
for (; i<nChoice; i++)
{
pbtable = (node*)ellFirst(&missing);
papChoiceName[i] = pbtable->name;
papChoiceValue[i] = pbtable->value;
ellDelete(&missing, &pbtable->node);
}
free(menuConvert->papChoiceName);
free(menuConvert->papChoiceValue);
menuConvert->papChoiceName=papChoiceName;
menuConvert->papChoiceValue=papChoiceValue;
menuConvert->nChoice = nChoice;
}
return 0;
}
#ifdef EPICS_3_14
static const iocshFuncDef updateMenuConvertDef = { "updateMenuConvert", 0, NULL };
static void updateMenuConvertFunc (const iocshArgBuf *args)
{
updateMenuConvert();
}
static void updateMenuConvertRegister(void)
{
static int firstTime = 1;
if (firstTime) {
iocshRegister (&updateMenuConvertDef, updateMenuConvertFunc);
firstTime = 0;
}
}
epicsExportRegistrar(updateMenuConvertRegister);
#endif
-1
View File
@@ -1 +0,0 @@
registrar(updateMenuConvertRegister)
-78
View File
@@ -1,78 +0,0 @@
/* winunixconv.c
*
* convert backslashes into slashes
*
* $Author: brands $
*
* $Source: /cvs/G/DRV/misc/winunixconv.c,v $
*
*/
#include <string.h>
#include <stdlib.h>
#include <dbScan.h>
#include <dbStaticLib.h>
#include <dbAccess.h>
#include <epicsVersion.h>
#ifdef BASE_VERSION
#define EPICS_3_13
extern DBBASE *pdbbase;
#else
#define EPICS_3_14
#include <iocsh.h>
#include <epicsExport.h>
#endif
int winunixconv (char* envvar)
{
char *cp;
char *envstr = getenv(envvar);
int j = 0;
while (envstr[j] != '\0'){
if (envstr[j] == '\\') {
envstr[j] = '/';
}
j++;
}
cp = mallocMustSucceed (strlen (envvar) + strlen (envstr) + 2, "winunixconv");
strcpy (cp, envvar);
strcat (cp, "=");
strcat (cp, envstr);
if (putenv (cp) < 0) {
errPrintf(
-1L,
__FILE__,
__LINE__,
"Failed to set environment parameter \"%s\" to new value \"%s\": %s\n",
envvar,
envstr,
strerror (errno));
free (cp);
}
return 0;
}
#ifdef EPICS_3_14
static const iocshArg winunixconvArg0 = { "envVar", iocshArgString };
static const iocshArg * const winunixconvArgs[1] = { &winunixconvArg0 };
static const iocshFuncDef winunixconvDef = { "winunixconv", 1, winunixconvArgs };
static void winunixconvFunc (const iocshArgBuf *args)
{
winunixconv(args[0].sval);
}
static void winunixconvRegister(void)
{
static int winunixconvfirstTime = 1;
if (winunixconvfirstTime) {
iocshRegister (&winunixconvDef, winunixconvFunc);
winunixconvfirstTime = 0;
}
}
epicsExportRegistrar(winunixconvRegister);
#endif
-1
View File
@@ -1 +0,0 @@
registrar(winunixconvRegister)