installed WIN32/Makefile.Host

This commit is contained in:
Jeff Hill
1997-01-10 00:12:21 +00:00
parent 7f3c5e6cbb
commit 2fc75ca08e
32 changed files with 3002 additions and 6 deletions

76
src/dbtools/Makefile.Host Normal file
View File

@@ -0,0 +1,76 @@
# base/src/dbtools/Makefile.Host
#
TOP = ../../..
include $(TOP)/config/CONFIG_BASE
YACCOPT := -l
LEXOPT := -L
# includes and manual pages to install:
#
INC := dbVarSub.h
MAN1 := dbLoadTemplate.1 subtool.1
MAN3 := dbLoadRecords.3 dbLoadTemplate.3
MAN5 := templatefile.5 dbfile.5
# the BSlib is not ported to WIN32,
# this results in less buildable products
#
ifdef WIN32
# uses getopt, optind, optarg from lib Com:
PROD_LIBS := Db Com
PROD := dbLoadTemplate
else
# library to build from BSlib.c:
#
LIBSRCS := BSlib.c
LIBRARY := BSlib
# products to build,
# all use BSlib, dbLoadTemplate needs lib Db:
# (it doesn't hurt if all link Db...)
#
# but
#
PROD_LIBS := BSlib Db
PROD := subtool dbLoadTemplate rdbls rdbapplist PVSserver
endif
include $(TOP)/config/RULES.Host
# hard-coded dependencies and rules,
# hopefully system-independent
#
# These lex sources are included in some C sources,
# so they have to be created in time:
#
dbLoadTemplate$(OBJ) sub_src$(OBJ): dbLoadTemplate_lex.c
dbLoadRecords$(OBJ): dbLoadRecords_lex.c
# Problem: dbLoadTemplate is used twice:
# in dbLoadTemplate and
# (with SUB_TOOL defined!) in subtool
sub_src.c: dbLoadTemplate.c
$(CP) $^ $@
# special CFLAGS only for compiling sub_src.c:
#
sub_src_CFLAGS := -DSUB_TOOL
subtool$(EXE): sub_src$(OBJ) dbVarSub$(OBJ)
$(LINK.c) $^ $(LDLIBS)
dbLoadTemplate$(EXE): dbVarSub$(OBJ) dbLoadTemplate$(OBJ) dbLoadRecords$(OBJ)
$(LINK.c) $^ $(LDLIBS)
clean::
@$(RM) dbLoadTemplate_lex.c dbLoadTemplate.c dbLoadRecords_lex.c \
dbLoadRecords.c
# EOF base/src/dbtools/Makefile.Host

68
src/gdd/Makefile.Host Normal file
View File

@@ -0,0 +1,68 @@
# base/src/gdd/Makefile.Host
#
TOP= ../../..
include $(TOP)/config/CONFIG_BASE
#OPTIM_YES=-g
INC += gdd.h
INC += gddNewDel.h
INC += gddUtils.h
INC += gddErrorCodes.h
INC += aitTypes.h
INC += aitConvert.h
INC += aitHelpers.h
INC += dbMapper.h
INC += gddAppTable.h
INC += gddAppFuncTable.h
INC += gddAppFuncTable.cc
INC += gddApps.h
LIBSRCS := gdd.cc gddTest.cc gddAppTable.cc gddNewDel.cc \
gddAppDefs.cc aitTypes.c aitConvert.cc aitHelpers.cc dbMapper.cc
LIBRARY := gdd
# cannot generate these dependencies automatically
#
# Problem: Some dependencies are include files that may
# not have been installed if we are building for
# the first time
# -> use explicit reference to the uninstalled files in '..'
aitConvert$(OBJ): aitConvert.cc aitConvertGenerated.cc\
../aitConvert.h ../aitTypes.h
dbMapper.cc: ../gdd.h ../gddAppTable.h ../dbMapper.h\
./gddApps.h ../aitTypes.h
# Rules for generated files
#
aitConvertGenerated.cc: aitGen$(EXE) ../aitTypes.h
./aitGen$(EXE)
./gddApps.h: genApps$(EXE)
./genApps$(EXE) $@
# build locally:
TESTPROD:=genApps
TESTPROD_SRCS:=genApps.cc gdd.cc gddTest.cc gddAppTable.cc\
gddNewDel.cc gddAppDefs.cc \
aitTypes.cc aitConvert.cc aitHelpers.cc
# unfortunately there is only one TESTPROD/TESTPROD_SRCS allowed
# right now
# (or many 'simple' progs:
# TESTPROD:=a b c
# where a is build from a.cc, b from b.cc, c from c.cc
# )
#
# This rule, however, should be system-independent:
aitGen$(EXE): aitGen$(OBJ) aitTypes$(OBJ)
$(LINK.c) $^ $(LDLIBS)
clean::
$(RM) aitConvertGenerated.cc aitGen$(EXE) genApps$(EXE)
include $(TOP)/config/RULES.Host
# EOF base/src/gdd/Makefile.Host

19
src/include/Makefile.Host Normal file
View File

@@ -0,0 +1,19 @@
TOP = ../../..
include $(TOP)/config/CONFIG_BASE
INC += dbDefs.h
INC += camacLib.h
INC += epicsTypes.h
INC += epicsVersion.h
INC += gsd_sync_defs.h
INC += module_types.h
INC += shareLib.h
INC += createSoftLinks.sh
INC += bsdProto.h
INC += task_params.h
INC += osiMutexNOOP.h
OSINC += osiSock.h
include $(TOP)/config/RULES.Host

View File

@@ -0,0 +1,40 @@
#ifdef __cplusplus
extern "C" {
#endif
#pragma warning (disable:4237)
#include <winsock.h>
void ipAddrToA (const struct sockaddr_in *pInetAddr,
char *pBuf, const unsigned bufSize);
#ifdef __cplusplus
}
#endif
#define SOCKERRNO WSAGetLastError()
#define socket_close(S) closesocket(S)
#define socket_ioctl(A,B,C) ioctlsocket(A,B,(unsigned long *) C)
#define MAXHOSTNAMELEN 75
#define IPPORT_USERRESERVED 5000U
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOBUFS WSAENOBUFS
#define ECONNRESET WSAECONNRESET
#define ETIMEDOUT WSAETIMEDOUT
#define EADDRINUSE WSAEADDRINUSE
#define ECONNREFUSED WSAECONNREFUSED
#define ECONNABORTED WSAECONNABORTED
/*
* Under WIN32, FD_SETSIZE is the max. number of sockets,
* not the max. fd value that you use in select().
*
* Therefore, it is difficult to detemine if any given
* fd can be used with FD_SET(), FD_CLR(), and FD_ISSET().
*/
#define FD_IN_FDSET(FD) (1)

97
src/libCom/Com.def Normal file
View File

@@ -0,0 +1,97 @@
LIBRARY Com
EXPORTS
EPICS_AR_PORT
EPICS_CA_ADDR_LIST
EPICS_CA_AUTO_ADDR_LIST
EPICS_CA_BEACON_PERIOD
EPICS_CA_CONN_TMO
EPICS_CA_REPEATER_PORT
EPICS_CA_SERVER_PORT
EPICS_CMD_PROTO_PORT
EPICS_IOC_LOG_FILE_COMMAND
EPICS_IOC_LOG_FILE_LIMIT
EPICS_IOC_LOG_FILE_NAME
EPICS_IOC_LOG_INET
EPICS_IOC_LOG_PORT
EPICS_TS_MIN_WEST
EPICS_TS_NTP_INET
bucketAddItemUnsignedId
bucketCreate
bucketFree
bucketLookupItemUnsignedId
bucketRemoveItemUnsignedId
calcPerform
cvtCharToString
cvtDoubleToString
cvtLongToString
cvtShortToString
cvtUcharToString
cvtUlongToString
cvtUshortToString
ellAdd
ellConcat
ellDelete
ellFree
ellGet
ellInsert
ellNth
envGetConfigParam
envGetDoubleConfigParam
envGetInetAddrConfigParam
envGetLongConfigParam
envPrtConfigParam
envSetConfigParam
env_param_list
envParamIsEmpty
epicsAssert
errPrintf
errSymFind
freeListCalloc
freeListCleanup
freeListFree
freeListInitPvt
getopt
optind
optarg
gphAdd
gphDelete
gphDump
gphFind
gphFreeMem
gphInitPvt
macCreateHandle
macDeleteHandle
macExpandString
macInstallMacros
macParseDefns
nextAlph1UCField
nextIntFieldAsInt
nextIntFieldAsLong
postfix
tsAddDouble
tsCmpStamps
tsLocalTime
tsRoundDownLocal
tsRoundUpLocal
tsStampToText
tsTextToStamp
tsTimeTextToStamp
impInit
impFree
impSetIncludeToken
impSetEnvName
impGetMacHandle
impSetMacHandle
impMacFree
impMacAddSubstitutions
impMacAddNameValuePairs
impSetPath
impAddPath
impPrintInclude
impDumpPath
impOpenFile
impCloseFile
impGetLine
ipAddrToA

140
src/libCom/Makefile.Host Normal file
View File

@@ -0,0 +1,140 @@
# Makefile.Host for base/src/libCom
#
#
TOP = ../../..
include $(TOP)/config/CONFIG_BASE
CMPLR = STRICT
USR_CFLAGS = -D_NO_PROTO
# includes to install from this sub-project
#
INC += cvtFast.h
INC += ellLib.h
INC += envDefs.h
INC += epicsAssert.h
INC += epicsPrint.h
INC += errMdef.h
INC += error.h
INC += fdmgr.h
INC += freeList.h
INC += gpHash.h
INC += memDebugLib.h
INC += tsDefs.h
INC += bucketLib.h
INC += pal.h
INC += fdManager.h
INC += osiTime.h
INC += osiTimer.h
INC += macLib.h
INC += impLib.h
# For WIN32 we supply getopt as part of libCom:
INC_WIN32 := getopt.h
# general contents of library on all platforms
#
# system specific lines in RULES.Host figure out
# 1) what object names (.o, .obj,...) to build
# 2) where to find the sources: ., ./os/<ARCH_CLASS>, ./os/generic, ...
#
LIBSRCS += bucketLib.c
LIBSRCS += calcPerform.c
LIBSRCS += cvtFast.c
LIBSRCS += ellLib.c
LIBSRCS += envSubr.c
LIBSRCS += envData.c
LIBSRCS += errPrintfUNIX.c
LIBSRCS += errSymLib.c
LIBSRCS += errSymTbl.c
LIBSRCS += fdmgr.c
LIBSRCS += freeListLib.c
LIBSRCS += gpHashLib.c
LIBSRCS += memDebugLib.c
LIBSRCS += nextFieldSubr.c
LIBSRCS += postfix.c
LIBSRCS += realpath.c
LIBSRCS += tsSubr.c
LIBSRCS += assertUNIX.c
LIBSRCS += fdManager.cc
LIBSRCS += osiTimer.cc
LIBSRCS += macCore.c
LIBSRCS += macUtil.c
LIBSRCS += ipAddrToA.cc
LIBSRCS += osdTime.cc
LIBSRCS += impLib.c
# WIN32 has no getopt, we add it to the Com lib,
# special initialisation is done in winmain.c
LIBSRCS_WIN32 := getopt.c dllmain.cc
# Library to build:
# lib$(LIBRARY).a or ..dll/..exp/..lib
#
LIBRARY:=Com
# only for WIN32:
# build LIBRARY as a DLL, use the specified def file
LIBTYPE:=SHARED
# libs needed for PROD and TESTPRODUCT
PROD_LIBS=Com
# tsTest does not use the default tsTest.c:
#TESTPROD_SRCS=tsSubr.c
#TESTPROD=tsTest
#TESTPROD=envtest
#TESTPROD = errMtst.c
PROD := impExpand
MAN3 = gpHash.3 freeList.3
# for bldErrSymTbl:
#
ERR_S_FILES += $(TOP)/src/as/asLib.h
ERR_S_FILES += $(TOP)/src/db/dbAccess.h
ERR_S_FILES += $(TOP)/src/db/devLib.h
ERR_S_FILES += $(TOP)/src/db/devSup.h
ERR_S_FILES += $(TOP)/src/db/drvSup.h
ERR_S_FILES += $(TOP)/src/db/recSup.h
ERR_S_FILES += $(TOP)/src/dbStatic/dbStaticLib.h
ERR_S_FILES += $(TOP)/src/drv/ansi/drvEpvxi.h
ERR_S_FILES += $(TOP)/src/drv/old/drvBitBusErr.h
ERR_S_FILES += $(TOP)/src/drv/old/drvGpibErr.h
ERR_S_FILES += ../tsDefs.h
ERR_S_FILES += ../errMdef.h
ERR_S_FILES += $(TOP)/src/cas/generic/casdef.h
ERR_S_FILES += $(TOP)/src/gdd/gddAppFuncTable.h
include $(TOP)/config/RULES.Host
# The WIN32 scripts are simpler versions that should
# work on all systems.
# In order to keep the old ones, however, I moved
# the new ones to WIN32. -kuk-
# Improvements:
# 1) use only the simpler scripts (well,..)
# 2) use C code instead (yes!)
#
ifdef WIN32
TOOLDIR=../os/WIN32
else
TOOLDIR=..
endif
# The real dependecies seem to confuse GNUmake:
# envData.c is rebuild every time...
#envData.c: ../envDefs.h $(TOP)/config/CONFIG_ENV $(TOP)/config/CONFIG_SITE_ENV
envData.c: ../envDefs.h
$(TOOLDIR)/bldEnvData $(TOP)/config
errSymTbl.c: $(ERR_S_FILES)
@$(RM) -f errSymTbl.c
$(TOOLDIR)/makeStatTbl $(ERR_S_FILES) >errSymTbl.c
clean::
@$(RM) errSymTbl.c envData.c
# EOF Makefile.Host for base/src/libCom

View File

@@ -58,7 +58,7 @@ SRCS.c += ../assertUNIX.c
SRCS.c += ../macCore.c
SRCS.c += ../macUtil.c
SRCS.c += ../os/generic/ipAddrToA.c
SRCS.c += ../os/generic/osdTime.cc
#SRCS.c += ../os/generic/osdTime.cc
SRCS.c += ../impLib.c
SRCS.c += ../impExpand.c
@@ -86,9 +86,9 @@ LIBOBJS += assertUNIX.o
LIBOBJS += macCore.o
LIBOBJS += macUtil.o
LIBOBJS += ipAddrToA.o
LIBOBJS += osdTime.o
#LIBOBJS += osdTime.o
LIBOBJS += impLib.o
LIBOBJS += impExpand.o
#LIBOBJS += impExpand.o # this looks like an error, it's a product!!
LIBNAME = libCom.a

18
src/libCom/README.WIN32 Normal file
View File

@@ -0,0 +1,18 @@
On WIN32, libCom is build as a DLL Com.dll.
Because the sources are not adjusted to export all
functions 'automatically' with _declspec(dllexport),
a def-file 'Com.def' is used to list all
functions that should be included in the DLL.
It may well be that I missed to include some
functions in Com.def,
so if some function is missing in the DLL,
add a line to Com.def!
To rebuild the dll:
rm O.WIN32/Com.*
gnumake
-kuk-

View File

@@ -472,7 +472,7 @@ epicsPrtEnvParams()
* }
*
*-*/
int envParamIsEmpty(
int epicsShareAPI envParamIsEmpty(
ENV_PARAM *pParam /* I pointer to config param structure */
)
{

View File

@@ -472,7 +472,7 @@ epicsPrtEnvParams()
* }
*
*-*/
int envParamIsEmpty(
int epicsShareAPI envParamIsEmpty(
ENV_PARAM *pParam /* I pointer to config param structure */
)
{

View File

@@ -0,0 +1,4 @@
I took this from the GNU grep sources that should
also be part of the NT tools of this EPICS release.
-kuk-

View File

@@ -0,0 +1,18 @@
On WIN32, libCom is build as a DLL Com.dll.
Because the sources are not adjusted to export all
functions 'automatically' with _declspec(dllexport),
a def-file 'Com.def' is used to list all
functions that should be included in the DLL.
It may well be that I missed to include some
functions in Com.def,
so if some function is missing in the DLL,
add a line to Com.def!
To rebuild the dll:
rm O.WIN32/Com.*
gnumake
-kuk-

View File

@@ -0,0 +1,137 @@
#!/bin/sh
#
# base/tools $Id$
# Author: Andrew Johnson (RGO)
# Date: 14-Mar-95
#
# Experimental Physics and Industrial Control System (EPICS)
#
# $Log$
# Revision 1.1.2.1 1996/11/25 19:28:53 jhill
# installed
#
# Revision 1.1 1996/11/02 02:12:53 jhill
# installed
#
# Revision 1.4 1996/06/25 21:48:33 jba
# Makefile includes now from base/src/config, removed all soft links
#
# Revision 1.3 1996/05/10 16:10:18 mrk
# remove hard path to base/include
#
# Revision 1.2 1995/09/29 22:16:27 jhill
# ms windows changes
#
# Revision 1.1 1995/08/17 20:22:09 jba
# Moved bldEnvData,blderrSymTbl, makeStatTbl to libCom dir
#
# Revision 1.3 1995/08/14 19:27:24 jhill
# extern => epicsShareExtern
#
# Revision 1.2 1995/05/04 09:49:24 anj
# Added CONFIG_SITE_ENV, changed envData to .c file
#
# Revision 1.1 1995/04/24 16:02:29 anj
# Moved environment parameter defaults to config/CONFIG_ENV
#
#
# tool to build envData.c from envDefs.h and config/CONFIG*ENV
# Usage bldEnvData
HERE=`/bin/pwd`
cd $1
CONFIG_DIR=`/bin/pwd`
cd ${HERE}
SRC=../envDefs.h
ENV_DATA=${CONFIG_DIR}/CONFIG_ENV
SITE_DATA=${CONFIG_DIR}/CONFIG_SITE_ENV
OBJ=envData.c
TOOL=`basename $0`
# Start by creating a list of the ENV_PARAM declarations
PARAMS=`sed -n -e 's/;//' \
-e 's/^[ ]*epicsShareExtern[ ][ ]*ENV_PARAM[ ][ ]*//p' \
${SRC}`
echo 'For some unknown reason, the bldEnvData script hangs on WIN32'
echo 'sometimes...'
echo 'The reason might be some too-small buffer in gnumake or knts,'
echo 'because from inside the O.WIN32 directory everything is fine.'
echo 'If this happens, simply cd to O.WIN32, type the line above'
echo '(the one that started bldEnvData) by hand and restart gnumake'
# Create a new header file
rm -rf ${OBJ}
cat >${OBJ} <<!EOF
/* ${HERE}/${OBJ}
*
* created by ${TOOL}
*
* from:
* ${SRC}
* ${ENV_DATA}
* ${SITE_DATA}
*
* `date`
*
*/
#define epicsExportSharedSymbols
#include "envDefs.h"
#include "shareLib.h"
!EOF
# Make sure no corresponding shell environment variables
unset ${PARAMS}
# Read the default values from the config file into shell variables
. ${ENV_DATA}
. ${SITE_DATA}
# Scan through the parameters to create the definition
for ENV in ${PARAMS}
do
# The set | grep ... construct does not work on WIN32
# so we give no error for missing DEFAULTS
#
# Get the default, complain if not present
# if [ `set | grep -c ${ENV}=` = 0 ];
# then
# echo No default value for ${ENV}
# DEFAULT=""
# else
VAR='$'${ENV}
DEFAULT=`eval echo ${VAR}`
# fi
# Add this definition to the header file
#echo ${ENV} = ${DEFAULT}
echo ENV_PARAM ${ENV}'={"'${ENV}'","'${DEFAULT}'"};' >>${OBJ}
done
# Now create an array pointing to all parameters
cat >>${OBJ} <<!EOF
ENV_PARAM* env_param_list[EPICS_ENV_VARIABLE_COUNT+1] = {
!EOF
# Contents are the addresses of each parameter
for ENV in ${PARAMS}
do
echo ' &'${ENV}, >>${OBJ}
done
# Finally finish list with 0
cat >>${OBJ} <<!EOF
0
};
!EOF
exit 0

View File

@@ -0,0 +1,74 @@
/*
* dllmain.c
*
* WIN32 specific initialisation for the Com library,
* based on Chris Timossi's base/src/ca/windows_depend.c,
* especially initializing:
* ositime
*
* 8-2-96 -kuk-
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Lawrence Berkley National Laboratory
*
* Modification Log:
* -----------------
*/
#include <windows.h>
#include <stdio.h>
#ifndef WIN32
#error This source is specific to WIN32
#endif
extern int init_osi_time ();
extern int exit_osi_time ();
BOOL WINAPI DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
#if _DEBUG
/* for gui applications, setup console for error messages */
if (AllocConsole())
{
SetConsoleTitle("Channel Access Status");
freopen( "CONOUT$", "a", stderr );
}
#endif
if (init_osi_time ())
return FALSE;
break;
case DLL_PROCESS_DETACH:
exit_osi_time ();
break;
}
return TRUE;
}

View File

@@ -0,0 +1,735 @@
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
before changing it!
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* NOTE!!! AIX requires this to be the first thing in the file.
Do not put ANYTHING before it! */
#if !defined (__GNUC__) && defined (_AIX)
#pragma alloca
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef _MSC_VER
#include <malloc.h>
#else
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not __GNUC__ */
#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
#include <alloca.h>
#else
#ifndef _AIX
char *alloca ();
#endif
#endif /* alloca.h */
#endif
#endif /* not __GNUC__ */
#if !__STDC__ && !defined(const) && IN_GCC
#define const
#endif
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
#ifndef _NO_PROTO
#define _NO_PROTO
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#undef alloca
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#include <stdlib.h>
#else /* Not GNU C library. */
#define __alloca alloca
#endif /* GNU C library. */
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
long-named option. Because this is not POSIX.2 compliant, it is
being phased out. */
/* #define GETOPT_COMPAT */
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.
As `getopt' works, it permutes the elements of ARGV so that,
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
Setting the environment variable POSIXLY_CORRECT disables permutation.
Then the behavior is completely standard.
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
#include "getopt.h"
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
char *optarg = 0;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
/* XXX 1003.2 says this must be 1 before any call. */
int optind = 0;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
This allows us to pick up the scan where we left off.
If this is zero, or a null string, it means resume the scan
by advancing to the next ARGV-element. */
static char *nextchar;
/* Callers store zero here to inhibit the error message
for unrecognized options. */
int opterr = 1;
/* Set to an option character which was unrecognized.
This must be initialized on some systems to avoid linking in the
system's own getopt implementation. */
int optopt = '?';
/* Describe how to deal with options that follow non-option ARGV-elements.
If the caller did not specify anything,
the default is REQUIRE_ORDER if the environment variable
POSIXLY_CORRECT is defined, PERMUTE otherwise.
REQUIRE_ORDER means don't recognize them as options;
stop option processing when the first non-option is seen.
This is what Unix does.
This mode of operation is selected by either setting the environment
variable POSIXLY_CORRECT, or using `+' as the first character
of the list of option characters.
PERMUTE is the default. We permute the contents of ARGV as we scan,
so that eventually all the non-options are at the end. This allows options
to be given in any order, even with programs that were not written to
expect this.
RETURN_IN_ORDER is an option available to programs that were written
to expect options and other ARGV-elements in any order and that care about
the ordering of the two. We describe each non-option ARGV-element
as if it were the argument of an option with character code 1.
Using `-' as the first character of the list of option characters
selects this mode of operation.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
static enum
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
} ordering;
#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
#include <string.h>
#define my_index strchr
#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
#else
/* Avoid depending on library functions or files
whose names are inconsistent. */
char *getenv ();
static char *
my_index (str, chr)
const char *str;
int chr;
{
while (*str)
{
if (*str == chr)
return (char *) str;
str++;
}
return 0;
}
static void
my_bcopy (from, to, size)
const char *from;
char *to;
int size;
{
int i;
for (i = 0; i < size; i++)
to[i] = from[i];
}
#endif /* GNU C library. */
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first of them;
`last_nonopt' is the index after the last of them. */
static int first_nonopt;
static int last_nonopt;
/* Exchange two adjacent subsequences of ARGV.
One subsequence is elements [first_nonopt,last_nonopt)
which contains all the non-options that have been skipped so far.
The other is elements [last_nonopt,optind), which contains all
the options processed since those non-options were skipped.
`first_nonopt' and `last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
static void
exchange (argv)
char **argv;
{
int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
char **temp = (char **) __alloca (nonopts_size);
/* Interchange the two blocks of data in ARGV. */
my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size);
my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt],
(optind - last_nonopt) * sizeof (char *));
my_bcopy ((char *) temp,
(char *) &argv[first_nonopt + optind - last_nonopt],
nonopts_size);
/* Update records for the slots the non-options now occupy. */
first_nonopt += (optind - last_nonopt);
last_nonopt = optind;
}
/* Scan elements of ARGV (whose length is ARGC) for option characters
given in OPTSTRING.
If an element of ARGV starts with '-', and is not exactly "-" or "--",
then it is an option element. The characters of this element
(aside from the initial '-') are option characters. If `getopt'
is called repeatedly, it returns successively each of the option characters
from each of the option elements.
If `getopt' finds another option character, it returns that character,
updating `optind' and `nextchar' so that the next call to `getopt' can
resume the scan with the following option character or ARGV-element.
If there are no more option characters, `getopt' returns `EOF'.
Then `optind' is the index in ARGV of the first ARGV-element
that is not an option. (The ARGV-elements have been permuted
so that those that are not options now come last.)
OPTSTRING is a string containing the legitimate option characters.
If an option character is seen that is not listed in OPTSTRING,
return '?' after printing an error message. If you set `opterr' to
zero, the error message is suppressed but we still return '?'.
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
wants an optional arg; if there is text in the current ARGV-element,
it is returned in `optarg', otherwise `optarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
handling the non-option ARGV-elements.
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
Long-named options begin with `--' instead of `-'.
Their names may be abbreviated as long as the abbreviation is unique
or is an exact match for some defined option. If they have an
argument, it follows the option name in the same ARGV-element, separated
from the option name by a `=', or else the in next ARGV-element.
When `getopt' finds a long-named option, it returns 0 if that option's
`flag' field is nonzero, the value of the option's `val' field
if the `flag' field is zero.
The elements of ARGV aren't really const, because we permute them.
But we pretend they're const in the prototype to be compatible
with other systems.
LONGOPTS is a vector of `struct option' terminated by an
element containing a name which is zero.
LONGIND returns the index in LONGOPT of the long-named option found.
It is only valid when a long-named option has been found by the most
recent call.
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
long-named options. */
int
_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
int argc;
char *const *argv;
const char *optstring;
const struct option *longopts;
int *longind;
int long_only;
{
int option_index;
optarg = 0;
/* Initialize the internal data when the first call is made.
Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
non-option ARGV-elements is empty. */
if (optind == 0)
{
first_nonopt = last_nonopt = optind = 1;
nextchar = NULL;
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
{
ordering = RETURN_IN_ORDER;
++optstring;
}
else if (optstring[0] == '+')
{
ordering = REQUIRE_ORDER;
++optstring;
}
else if (getenv ("POSIXLY_CORRECT") != NULL)
ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
}
if (nextchar == NULL || *nextchar == '\0')
{
if (ordering == PERMUTE)
{
/* If we have just processed some options following some non-options,
exchange them so that the options come first. */
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (last_nonopt != optind)
first_nonopt = optind;
/* Now skip any additional non-options
and extend the range of non-options previously skipped. */
while (optind < argc
&& (argv[optind][0] != '-' || argv[optind][1] == '\0')
#ifdef GETOPT_COMPAT
&& (longopts == NULL
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
#endif /* GETOPT_COMPAT */
)
optind++;
last_nonopt = optind;
}
/* Special ARGV-element `--' means premature end of options.
Skip it like a null option,
then exchange with previous non-options as if it were an option,
then skip everything else like a non-option. */
if (optind != argc && !strcmp (argv[optind], "--"))
{
optind++;
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (first_nonopt == last_nonopt)
first_nonopt = optind;
last_nonopt = argc;
optind = argc;
}
/* If we have done all the ARGV-elements, stop the scan
and back over any non-options that we skipped and permuted. */
if (optind == argc)
{
/* Set the next-arg-index to point at the non-options
that we previously skipped, so the caller will digest them. */
if (first_nonopt != last_nonopt)
optind = first_nonopt;
return EOF;
}
/* If we have come to a non-option and did not permute it,
either stop the scan or describe it to the caller and pass it by. */
if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
#ifdef GETOPT_COMPAT
&& (longopts == NULL
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
#endif /* GETOPT_COMPAT */
)
{
if (ordering == REQUIRE_ORDER)
return EOF;
optarg = argv[optind++];
return 1;
}
/* We have found another option-ARGV-element.
Start decoding its characters. */
nextchar = (argv[optind] + 1
+ (longopts != NULL && argv[optind][1] == '-'));
}
if (longopts != NULL
&& ((argv[optind][0] == '-'
&& (argv[optind][1] == '-' || long_only))
#ifdef GETOPT_COMPAT
|| argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */
))
{
const struct option *p;
char *s = nextchar;
int exact = 0;
int ambig = 0;
const struct option *pfound = NULL;
int indfound;
while (*s && *s != '=')
s++;
/* Test all options for either exact match or abbreviated matches. */
for (p = longopts, option_index = 0; p->name;
p++, option_index++)
if (!strncmp (p->name, nextchar, s - nextchar))
{
if (s - nextchar == strlen (p->name))
{
/* Exact match found. */
pfound = p;
indfound = option_index;
exact = 1;
break;
}
else if (pfound == NULL)
{
/* First nonexact match found. */
pfound = p;
indfound = option_index;
}
else
/* Second nonexact match found. */
ambig = 1;
}
if (ambig && !exact)
{
if (opterr)
fprintf (stderr, "%s: option `%s' is ambiguous\n",
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
return '?';
}
if (pfound != NULL)
{
option_index = indfound;
optind++;
if (*s)
{
/* Don't test has_arg with >, because some C compilers don't
allow it to be used on enums. */
if (pfound->has_arg)
optarg = s + 1;
else
{
if (opterr)
{
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
"%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
"%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[optind - 1][0], pfound->name);
}
nextchar += strlen (nextchar);
return '?';
}
}
else if (pfound->has_arg == 1)
{
if (optind < argc)
optarg = argv[optind++];
else
{
if (opterr)
fprintf (stderr, "%s: option `%s' requires an argument\n",
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : '?';
}
}
nextchar += strlen (nextchar);
if (longind != NULL)
*longind = option_index;
if (pfound->flag)
{
*(pfound->flag) = pfound->val;
return 0;
}
return pfound->val;
}
/* Can't find it as a long option. If this is not getopt_long_only,
or the option starts with '--' or is not a valid short
option, then it's an error.
Otherwise interpret it as a short option. */
if (!long_only || argv[optind][1] == '-'
#ifdef GETOPT_COMPAT
|| argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */
|| my_index (optstring, *nextchar) == NULL)
{
if (opterr)
{
if (argv[optind][1] == '-')
/* --option */
fprintf (stderr, "%s: unrecognized option `--%s'\n",
argv[0], nextchar);
else
/* +option or -option */
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
argv[0], argv[optind][0], nextchar);
}
nextchar = (char *) "";
optind++;
return '?';
}
}
/* Look at and handle the next option-character. */
{
char c = *nextchar++;
char *temp = my_index (optstring, c);
/* Increment `optind' when we start to process its last character. */
if (*nextchar == '\0')
++optind;
if (temp == NULL || c == ':')
{
if (opterr)
{
#if 0
if (c < 040 || c >= 0177)
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
argv[0], c);
else
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
#else
/* 1003.2 specifies the format of this message. */
fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
#endif
}
optopt = c;
return '?';
}
if (temp[1] == ':')
{
if (temp[2] == ':')
{
/* This is an option that accepts an argument optionally. */
if (*nextchar != '\0')
{
optarg = nextchar;
optind++;
}
else
optarg = 0;
nextchar = NULL;
}
else
{
/* This is an option that requires an argument. */
if (*nextchar != '\0')
{
optarg = nextchar;
/* If we end this ARGV-element by taking the rest as an arg,
we must advance to the next element now. */
optind++;
}
else if (optind == argc)
{
if (opterr)
{
#if 0
fprintf (stderr, "%s: option `-%c' requires an argument\n",
argv[0], c);
#else
/* 1003.2 specifies the format of this message. */
fprintf (stderr, "%s: option requires an argument -- %c\n",
argv[0], c);
#endif
}
optopt = c;
if (optstring[0] == ':')
c = ':';
else
c = '?';
}
else
/* We already incremented `optind' once;
increment it again when taking next ARGV-elt as argument. */
optarg = argv[optind++];
nextchar = NULL;
}
}
return c;
}
}
int
getopt (argc, argv, optstring)
int argc;
char *const *argv;
const char *optstring;
{
return _getopt_internal (argc, argv, optstring,
(const struct option *) 0,
(int *) 0,
0);
}
#endif /* _LIBC or not __GNU_LIBRARY__. */
#ifdef TEST
/* Compile with -DTEST to make an executable for use in testing
the above definition of `getopt'. */
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
if (c == EOF)
break;
switch (c)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

View File

@@ -0,0 +1,129 @@
/* Declarations for getopt.
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _GETOPT_H
#define _GETOPT_H 1
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
#if __STDC__
const char *name;
#else
char *name;
#endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#if __STDC__
#if defined(__GNU_LIBRARY__)
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
#endif /* not __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind,
int long_only);
#else /* not __STDC__ */
extern int getopt ();
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
#endif /* not __STDC__ */
#ifdef __cplusplus
}
#endif
#endif /* _GETOPT_H */

View File

@@ -0,0 +1,70 @@
#!/bin/sh
#
# makeStatTbl
# share/src/misc $Id$
# makeStatTbl - Create Error Symbol Table
#
# modification history
# --------------------
# 17-JUL-90 mrk Modified vxWorks makeStatTbl
#
# SYNOPSIS
# createErrSymTbl hdir [...] >errSymTbl.c
#
# DESCRIPTION
# This tool creates a symbol table (ERRSYMTAB) structure which contains the
# names and values of all the status codes defined in the .h files in the
# specified directory(s). The status codes must be prefixed with "S_"
# in order to be included in this table.
# A "err.h" file must exist in each hdir which defines the module
# numbers, eg. "M_". The table is created on standard output.
#
# This tool's primary use is for creating an error status table used
# by errPrint, and errSymFind.
#
# FILES
# errMdef.h module number file for each h directory
#
# SEE ALSO: errnoLib(1), symLib(1)
#*/
tmp=/tmp/mstt$$
# knts cannot handle this -kuk-
# trap "rm -f $tmp ; exit" 0 1 2 3 15
cat $* | egrep '^#define[ ]*S_' >$tmp
echo '/* status code symbol table */'
echo
echo '/* CREATED BY makeStatTbl'
echo ' * FROM '`pwd`
echo ' * ON '`date`
echo ' */'
echo
echo '#include "errMdef.h"'
echo '#include "errSymTbl.h"'
echo
cat $tmp
echo
echo 'LOCAL ERRSYMBOL symbols[] ='
echo ' {'
# -kuk- had to change "\2" into \"\2\" for knts
sed -e 's/^.*define[ ]*\(S_[a-zA-Z0-9_]*\).*\/\*\(.*\)\*\/.*/ {\"\2\", (long) \1},/' \
$tmp
echo ' };'
echo
echo 'LOCAL ERRSYMTAB symTbl ='
echo ' {'
echo ' NELEMENTS (symbols), /* current number of symbols in table */'
echo ' symbols, /* ptr to symbol array */'
echo ' };'
echo
echo 'ERRSYMTAB_ID errSymTbl = &symTbl;'
exit 0

View File

@@ -0,0 +1,80 @@
#include <time.h>
#include <windows.h>
#include <mmsystem.h>
#define epicsExportSharedSymbols
#include <osiTime.h>
/*
* This code is mainly adapted form Chris Timossi's windows_depen.c
*
* 8-2-96 -kuk-
*/
/* offset from timeGetTime() to 1970 */
static unsigned long offset_secs;
static DWORD prev_time = 0;
static UINT res;
/*
* init_osi_time has to be called before using the timer,
* exit_osi_time has to be called in balance.
*/
int init_osi_time ()
{
TIMECAPS tc;
if (timeGetDevCaps (&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
fprintf (stderr, "init_osi_time: cannot get timer info\n");
return 1;
}
/* set for 1 ms resoulution */
res = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);
if (timeBeginPeriod (res) != TIMERR_NOERROR)
{
fprintf(stderr,"timer setup failed\n");
return 2;
}
offset_secs = (long)time(NULL) - (long)timeGetTime()/1000;
prev_time = timeGetTime();
return 0;
}
int exit_osi_time ()
{
timeEndPeriod (res);
return 0;
}
//
// osiTime::getCurrent ()
//
osiTime osiTime::getCurrent ()
{
unsigned long now;
/* MS Online help:
* Note that the value returned by the timeGetTime function is
* a DWORD value. The return value wraps around to
* 0 every 2^32 milliseconds, which is about 49.71 days.
*/
// get millisecs, timeGetTime gives DWORD
now = timeGetTime ();
if (prev_time > now) /* looks like a DWORD overflow */
offset_secs += 4294967; /* 0x100000000 / 1000 */
prev_time = now;
// compute secs and nanosecs from millisecs:
return osiTime (now / 1000L + offset_secs, (now % 1000L) * 1000000L);
}

View File

@@ -0,0 +1,74 @@
/*
* dllmain.c
*
* WIN32 specific initialisation for the Com library,
* based on Chris Timossi's base/src/ca/windows_depend.c,
* especially initializing:
* ositime
*
* 8-2-96 -kuk-
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Lawrence Berkley National Laboratory
*
* Modification Log:
* -----------------
*/
#include <windows.h>
#include <stdio.h>
#ifndef WIN32
#error This source is specific to WIN32
#endif
extern int init_osi_time ();
extern int exit_osi_time ();
BOOL WINAPI DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
#if _DEBUG
/* for gui applications, setup console for error messages */
if (AllocConsole())
{
SetConsoleTitle("Channel Access Status");
freopen( "CONOUT$", "a", stderr );
}
#endif
if (init_osi_time ())
return FALSE;
break;
case DLL_PROCESS_DETACH:
exit_osi_time ();
break;
}
return TRUE;
}

View File

@@ -0,0 +1,735 @@
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
before changing it!
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* NOTE!!! AIX requires this to be the first thing in the file.
Do not put ANYTHING before it! */
#if !defined (__GNUC__) && defined (_AIX)
#pragma alloca
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef _MSC_VER
#include <malloc.h>
#else
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not __GNUC__ */
#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
#include <alloca.h>
#else
#ifndef _AIX
char *alloca ();
#endif
#endif /* alloca.h */
#endif
#endif /* not __GNUC__ */
#if !__STDC__ && !defined(const) && IN_GCC
#define const
#endif
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
#ifndef _NO_PROTO
#define _NO_PROTO
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#undef alloca
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#include <stdlib.h>
#else /* Not GNU C library. */
#define __alloca alloca
#endif /* GNU C library. */
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
long-named option. Because this is not POSIX.2 compliant, it is
being phased out. */
/* #define GETOPT_COMPAT */
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.
As `getopt' works, it permutes the elements of ARGV so that,
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
Setting the environment variable POSIXLY_CORRECT disables permutation.
Then the behavior is completely standard.
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
#include "getopt.h"
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
char *optarg = 0;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
/* XXX 1003.2 says this must be 1 before any call. */
int optind = 0;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
This allows us to pick up the scan where we left off.
If this is zero, or a null string, it means resume the scan
by advancing to the next ARGV-element. */
static char *nextchar;
/* Callers store zero here to inhibit the error message
for unrecognized options. */
int opterr = 1;
/* Set to an option character which was unrecognized.
This must be initialized on some systems to avoid linking in the
system's own getopt implementation. */
int optopt = '?';
/* Describe how to deal with options that follow non-option ARGV-elements.
If the caller did not specify anything,
the default is REQUIRE_ORDER if the environment variable
POSIXLY_CORRECT is defined, PERMUTE otherwise.
REQUIRE_ORDER means don't recognize them as options;
stop option processing when the first non-option is seen.
This is what Unix does.
This mode of operation is selected by either setting the environment
variable POSIXLY_CORRECT, or using `+' as the first character
of the list of option characters.
PERMUTE is the default. We permute the contents of ARGV as we scan,
so that eventually all the non-options are at the end. This allows options
to be given in any order, even with programs that were not written to
expect this.
RETURN_IN_ORDER is an option available to programs that were written
to expect options and other ARGV-elements in any order and that care about
the ordering of the two. We describe each non-option ARGV-element
as if it were the argument of an option with character code 1.
Using `-' as the first character of the list of option characters
selects this mode of operation.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
static enum
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
} ordering;
#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
#include <string.h>
#define my_index strchr
#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
#else
/* Avoid depending on library functions or files
whose names are inconsistent. */
char *getenv ();
static char *
my_index (str, chr)
const char *str;
int chr;
{
while (*str)
{
if (*str == chr)
return (char *) str;
str++;
}
return 0;
}
static void
my_bcopy (from, to, size)
const char *from;
char *to;
int size;
{
int i;
for (i = 0; i < size; i++)
to[i] = from[i];
}
#endif /* GNU C library. */
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first of them;
`last_nonopt' is the index after the last of them. */
static int first_nonopt;
static int last_nonopt;
/* Exchange two adjacent subsequences of ARGV.
One subsequence is elements [first_nonopt,last_nonopt)
which contains all the non-options that have been skipped so far.
The other is elements [last_nonopt,optind), which contains all
the options processed since those non-options were skipped.
`first_nonopt' and `last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
static void
exchange (argv)
char **argv;
{
int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
char **temp = (char **) __alloca (nonopts_size);
/* Interchange the two blocks of data in ARGV. */
my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size);
my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt],
(optind - last_nonopt) * sizeof (char *));
my_bcopy ((char *) temp,
(char *) &argv[first_nonopt + optind - last_nonopt],
nonopts_size);
/* Update records for the slots the non-options now occupy. */
first_nonopt += (optind - last_nonopt);
last_nonopt = optind;
}
/* Scan elements of ARGV (whose length is ARGC) for option characters
given in OPTSTRING.
If an element of ARGV starts with '-', and is not exactly "-" or "--",
then it is an option element. The characters of this element
(aside from the initial '-') are option characters. If `getopt'
is called repeatedly, it returns successively each of the option characters
from each of the option elements.
If `getopt' finds another option character, it returns that character,
updating `optind' and `nextchar' so that the next call to `getopt' can
resume the scan with the following option character or ARGV-element.
If there are no more option characters, `getopt' returns `EOF'.
Then `optind' is the index in ARGV of the first ARGV-element
that is not an option. (The ARGV-elements have been permuted
so that those that are not options now come last.)
OPTSTRING is a string containing the legitimate option characters.
If an option character is seen that is not listed in OPTSTRING,
return '?' after printing an error message. If you set `opterr' to
zero, the error message is suppressed but we still return '?'.
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
wants an optional arg; if there is text in the current ARGV-element,
it is returned in `optarg', otherwise `optarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
handling the non-option ARGV-elements.
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
Long-named options begin with `--' instead of `-'.
Their names may be abbreviated as long as the abbreviation is unique
or is an exact match for some defined option. If they have an
argument, it follows the option name in the same ARGV-element, separated
from the option name by a `=', or else the in next ARGV-element.
When `getopt' finds a long-named option, it returns 0 if that option's
`flag' field is nonzero, the value of the option's `val' field
if the `flag' field is zero.
The elements of ARGV aren't really const, because we permute them.
But we pretend they're const in the prototype to be compatible
with other systems.
LONGOPTS is a vector of `struct option' terminated by an
element containing a name which is zero.
LONGIND returns the index in LONGOPT of the long-named option found.
It is only valid when a long-named option has been found by the most
recent call.
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
long-named options. */
int
_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
int argc;
char *const *argv;
const char *optstring;
const struct option *longopts;
int *longind;
int long_only;
{
int option_index;
optarg = 0;
/* Initialize the internal data when the first call is made.
Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
non-option ARGV-elements is empty. */
if (optind == 0)
{
first_nonopt = last_nonopt = optind = 1;
nextchar = NULL;
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
{
ordering = RETURN_IN_ORDER;
++optstring;
}
else if (optstring[0] == '+')
{
ordering = REQUIRE_ORDER;
++optstring;
}
else if (getenv ("POSIXLY_CORRECT") != NULL)
ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
}
if (nextchar == NULL || *nextchar == '\0')
{
if (ordering == PERMUTE)
{
/* If we have just processed some options following some non-options,
exchange them so that the options come first. */
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (last_nonopt != optind)
first_nonopt = optind;
/* Now skip any additional non-options
and extend the range of non-options previously skipped. */
while (optind < argc
&& (argv[optind][0] != '-' || argv[optind][1] == '\0')
#ifdef GETOPT_COMPAT
&& (longopts == NULL
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
#endif /* GETOPT_COMPAT */
)
optind++;
last_nonopt = optind;
}
/* Special ARGV-element `--' means premature end of options.
Skip it like a null option,
then exchange with previous non-options as if it were an option,
then skip everything else like a non-option. */
if (optind != argc && !strcmp (argv[optind], "--"))
{
optind++;
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (first_nonopt == last_nonopt)
first_nonopt = optind;
last_nonopt = argc;
optind = argc;
}
/* If we have done all the ARGV-elements, stop the scan
and back over any non-options that we skipped and permuted. */
if (optind == argc)
{
/* Set the next-arg-index to point at the non-options
that we previously skipped, so the caller will digest them. */
if (first_nonopt != last_nonopt)
optind = first_nonopt;
return EOF;
}
/* If we have come to a non-option and did not permute it,
either stop the scan or describe it to the caller and pass it by. */
if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
#ifdef GETOPT_COMPAT
&& (longopts == NULL
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
#endif /* GETOPT_COMPAT */
)
{
if (ordering == REQUIRE_ORDER)
return EOF;
optarg = argv[optind++];
return 1;
}
/* We have found another option-ARGV-element.
Start decoding its characters. */
nextchar = (argv[optind] + 1
+ (longopts != NULL && argv[optind][1] == '-'));
}
if (longopts != NULL
&& ((argv[optind][0] == '-'
&& (argv[optind][1] == '-' || long_only))
#ifdef GETOPT_COMPAT
|| argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */
))
{
const struct option *p;
char *s = nextchar;
int exact = 0;
int ambig = 0;
const struct option *pfound = NULL;
int indfound;
while (*s && *s != '=')
s++;
/* Test all options for either exact match or abbreviated matches. */
for (p = longopts, option_index = 0; p->name;
p++, option_index++)
if (!strncmp (p->name, nextchar, s - nextchar))
{
if (s - nextchar == strlen (p->name))
{
/* Exact match found. */
pfound = p;
indfound = option_index;
exact = 1;
break;
}
else if (pfound == NULL)
{
/* First nonexact match found. */
pfound = p;
indfound = option_index;
}
else
/* Second nonexact match found. */
ambig = 1;
}
if (ambig && !exact)
{
if (opterr)
fprintf (stderr, "%s: option `%s' is ambiguous\n",
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
return '?';
}
if (pfound != NULL)
{
option_index = indfound;
optind++;
if (*s)
{
/* Don't test has_arg with >, because some C compilers don't
allow it to be used on enums. */
if (pfound->has_arg)
optarg = s + 1;
else
{
if (opterr)
{
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
"%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
"%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[optind - 1][0], pfound->name);
}
nextchar += strlen (nextchar);
return '?';
}
}
else if (pfound->has_arg == 1)
{
if (optind < argc)
optarg = argv[optind++];
else
{
if (opterr)
fprintf (stderr, "%s: option `%s' requires an argument\n",
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : '?';
}
}
nextchar += strlen (nextchar);
if (longind != NULL)
*longind = option_index;
if (pfound->flag)
{
*(pfound->flag) = pfound->val;
return 0;
}
return pfound->val;
}
/* Can't find it as a long option. If this is not getopt_long_only,
or the option starts with '--' or is not a valid short
option, then it's an error.
Otherwise interpret it as a short option. */
if (!long_only || argv[optind][1] == '-'
#ifdef GETOPT_COMPAT
|| argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */
|| my_index (optstring, *nextchar) == NULL)
{
if (opterr)
{
if (argv[optind][1] == '-')
/* --option */
fprintf (stderr, "%s: unrecognized option `--%s'\n",
argv[0], nextchar);
else
/* +option or -option */
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
argv[0], argv[optind][0], nextchar);
}
nextchar = (char *) "";
optind++;
return '?';
}
}
/* Look at and handle the next option-character. */
{
char c = *nextchar++;
char *temp = my_index (optstring, c);
/* Increment `optind' when we start to process its last character. */
if (*nextchar == '\0')
++optind;
if (temp == NULL || c == ':')
{
if (opterr)
{
#if 0
if (c < 040 || c >= 0177)
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
argv[0], c);
else
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
#else
/* 1003.2 specifies the format of this message. */
fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
#endif
}
optopt = c;
return '?';
}
if (temp[1] == ':')
{
if (temp[2] == ':')
{
/* This is an option that accepts an argument optionally. */
if (*nextchar != '\0')
{
optarg = nextchar;
optind++;
}
else
optarg = 0;
nextchar = NULL;
}
else
{
/* This is an option that requires an argument. */
if (*nextchar != '\0')
{
optarg = nextchar;
/* If we end this ARGV-element by taking the rest as an arg,
we must advance to the next element now. */
optind++;
}
else if (optind == argc)
{
if (opterr)
{
#if 0
fprintf (stderr, "%s: option `-%c' requires an argument\n",
argv[0], c);
#else
/* 1003.2 specifies the format of this message. */
fprintf (stderr, "%s: option requires an argument -- %c\n",
argv[0], c);
#endif
}
optopt = c;
if (optstring[0] == ':')
c = ':';
else
c = '?';
}
else
/* We already incremented `optind' once;
increment it again when taking next ARGV-elt as argument. */
optarg = argv[optind++];
nextchar = NULL;
}
}
return c;
}
}
int
getopt (argc, argv, optstring)
int argc;
char *const *argv;
const char *optstring;
{
return _getopt_internal (argc, argv, optstring,
(const struct option *) 0,
(int *) 0,
0);
}
#endif /* _LIBC or not __GNU_LIBRARY__. */
#ifdef TEST
/* Compile with -DTEST to make an executable for use in testing
the above definition of `getopt'. */
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
if (c == EOF)
break;
switch (c)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

View File

@@ -0,0 +1,129 @@
/* Declarations for getopt.
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _GETOPT_H
#define _GETOPT_H 1
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
#if __STDC__
const char *name;
#else
char *name;
#endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#if __STDC__
#if defined(__GNU_LIBRARY__)
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
#endif /* not __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind,
int long_only);
#else /* not __STDC__ */
extern int getopt ();
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
#endif /* not __STDC__ */
#ifdef __cplusplus
}
#endif
#endif /* _GETOPT_H */

View File

@@ -0,0 +1,40 @@
#ifdef __cplusplus
extern "C" {
#endif
#pragma warning (disable:4237)
#include <winsock.h>
void ipAddrToA (const struct sockaddr_in *pInetAddr,
char *pBuf, const unsigned bufSize);
#ifdef __cplusplus
}
#endif
#define SOCKERRNO WSAGetLastError()
#define socket_close(S) closesocket(S)
#define socket_ioctl(A,B,C) ioctlsocket(A,B,(unsigned long *) C)
#define MAXHOSTNAMELEN 75
#define IPPORT_USERRESERVED 5000U
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOBUFS WSAENOBUFS
#define ECONNRESET WSAECONNRESET
#define ETIMEDOUT WSAETIMEDOUT
#define EADDRINUSE WSAEADDRINUSE
#define ECONNREFUSED WSAECONNREFUSED
#define ECONNABORTED WSAECONNABORTED
/*
* Under WIN32, FD_SETSIZE is the max. number of sockets,
* not the max. fd value that you use in select().
*
* Therefore, it is difficult to detemine if any given
* fd can be used with FD_SET(), FD_CLR(), and FD_ISSET().
*/
#define FD_IN_FDSET(FD) (1)

View File

@@ -0,0 +1,80 @@
#include <time.h>
#include <windows.h>
#include <mmsystem.h>
#define epicsExportSharedSymbols
#include <osiTime.h>
/*
* This code is mainly adapted form Chris Timossi's windows_depen.c
*
* 8-2-96 -kuk-
*/
/* offset from timeGetTime() to 1970 */
static unsigned long offset_secs;
static DWORD prev_time = 0;
static UINT res;
/*
* init_osi_time has to be called before using the timer,
* exit_osi_time has to be called in balance.
*/
int init_osi_time ()
{
TIMECAPS tc;
if (timeGetDevCaps (&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
fprintf (stderr, "init_osi_time: cannot get timer info\n");
return 1;
}
/* set for 1 ms resoulution */
res = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);
if (timeBeginPeriod (res) != TIMERR_NOERROR)
{
fprintf(stderr,"timer setup failed\n");
return 2;
}
offset_secs = (long)time(NULL) - (long)timeGetTime()/1000;
prev_time = timeGetTime();
return 0;
}
int exit_osi_time ()
{
timeEndPeriod (res);
return 0;
}
//
// osiTime::getCurrent ()
//
osiTime osiTime::getCurrent ()
{
unsigned long now;
/* MS Online help:
* Note that the value returned by the timeGetTime function is
* a DWORD value. The return value wraps around to
* 0 every 2^32 milliseconds, which is about 49.71 days.
*/
// get millisecs, timeGetTime gives DWORD
now = timeGetTime ();
if (prev_time > now) /* looks like a DWORD overflow */
offset_secs += 4294967; /* 0x100000000 / 1000 */
prev_time = now;
// compute secs and nanosecs from millisecs:
return osiTime (now / 1000L + offset_secs, (now % 1000L) * 1000000L);
}

View File

@@ -120,7 +120,7 @@ int lock_needed;
DLOG(3,"CAS: sending cmmd %d, postsize %d\n",
mp->m_cmmd, (int)mp->m_postsize,
NULL, NULL);
0, 0, 0, 0);
/* convert the complete header into host format */
mp->m_cmmd = htons (mp->m_cmmd);

62
src/tools/Makefile.Host Normal file
View File

@@ -0,0 +1,62 @@
# base/src/tools/Makefile.Host
#
TOP = ../../..
include $(TOP)/config/CONFIG_BASE
# install these scripts:
SCRIPTS := installEpics getrel makeBaseApp
# But: before anything is done, installEpics has to be in place
# The first action in a full build & install is 'make inc.host',
# that's where we hook into:
inc:: $(INSTALL_BIN)/installEpics
# This Makefile.Host is ugly
# because the install process (chmod ...)
# is different for WIN32.
#
# This is usually hidden in installEpics,
# but we are about to install installEpics...
#
# The same applies to the 'os' directory:
# If we are on e.g. WIN32 and have os/WIN32/stuff,
# that whould have precedence over ./stuff.
# But again: we are just installing the Makesystem here.
#
# -kuk-
ifdef WIN32
$(INSTALL_BIN)/installEpics: ../os/WIN32/installEpics
@echo "Installing $@ for WIN32"
@../os/WIN32/testmkdir $(INSTALL_LOCATION_BIN)
@../os/WIN32/testmkdir $(INSTALL_BIN)
@../os/WIN32/installEpics ../os/WIN32/testmkdir $(INSTALL_BIN)
@../os/WIN32/installEpics ../os/WIN32/installEpics $(INSTALL_BIN)
else
$(INSTALL_BIN)/installEpics: testmkdir installEpics
@echo "Installing $@"
@testmkdir $(INSTALL_LOCATION_BIN)
@testmkdir $(INSTALL_BIN)
@./installEpics -m 555 testmkdir $(INSTALL_BIN)
@./installEpics -m 555 installEpics $(INSTALL_BIN)
# make sure the scripts are executable:
testmkdir: ../testmkdir
@$(RM) $@
@$(CP) -p $< $@
@/bin/chmod 755 $@
installEpics: ../installEpics
@$(RM) $@
@$(CP) -p $< $@
@/bin/chmod 755 $@
endif
include $(TOP)/config/RULES.Host
# EOF base/src/tools/Makefile.Host

38
src/tools/os/WIN32/getrel Normal file
View File

@@ -0,0 +1,38 @@
#!/bin/sh
#
# $Id$
#
# simplified WIN32 version 7/25/96 -kuk-
#
# Author: Matthew Needes
#
# one arg
if [ $# -ne 1 ]; then
echo 'Usage:'
echo ' getrel <EpicsNodeFullPathName> '
echo ' '
echo 'ex: getrel /usr/local/epics/base_R3.13'
echo ' --------- OR -----------'
echo ' getrel ~/epics/base '
exit
fi
BASE=${1}
BIN=${BASE}/bin
DBD=${BASE}/dbd
if [ ! -d ${BIN} -o ! -d ${DBD} ]
then
echo "getrel: ${BASE} does not appear to be an epics BASE root tree"
echo " I cannot locate a /bin or /dbd directory in there"
exit 1
fi
echo EPICS_BASE=${BASE} > EPICS_BASE
echo ${BASE} - `date` >> .current_rel_hist
exit 0

View File

@@ -0,0 +1,26 @@
#!/bin/sh
#
# InstallEpics
#
# InstallEpics is used within makefiles to copy new versions of
# files into a destination directory.
#
##########################################################
# -kuk- use cp on WIN32
#
if [ $HOST_ARCH != WIN32 ]
then
echo "You are using the simple version of installEpics"
echo "though you seem not to be on WIN32?"
echo "Check this in ....epics/base/src/tools !"
fi
if [ $1 = '-m' ]
then
shift 2
fi
# echo WIN32-installEpics: calling cp $*
eval cp $*
# EOF installEpics

View File

@@ -0,0 +1,10 @@
#!/bin/sh
#
# iocMakeApp
#
# Author: Marty Kraimer
#
echo "makeBaseApp is not yet ported to WIN32"
exit 2

View File

@@ -0,0 +1,15 @@
#!/bin/sh
#
#
if [ $# -ne 1 ]
then
echo "USAGE:"
echo "$0 dirname"
echo 'Function: if dirname does not exist, create it.'
exit 2
fi
DIR=$1
test -d ${DIR} || mkdir ${DIR}

View File

@@ -0,0 +1,22 @@
# Makefile.Host for base/src/toolsComm/antelope
#
#
TOP = ../../../..
include $(TOP)/config/CONFIG_BASE
USR_CFLAGS = -D_NO_PROTO
SRCS= closure.c error.c lalr.c lr0.c main.c \
mkpar.c output.c reader.c skeleton.c \
symtab.c verbose.c warshall.c
# genric Unix needs libm.a, WIN32 not:
PROD_LIBS_DEFAULT:=m
PROD_LIBS_WIN32:=-nil-
PROD=antelope
include $(TOP)/config/RULES.Host
# EOF Makefile.Host

View File

@@ -0,0 +1,36 @@
# Makefile.Host for base/src/toolsComm/flex
#
#
TOP = ../../../..
include $(TOP)/config/CONFIG_BASE
YACC = $(EYACC)
YACCOPT = -l -d
SKELETON_FILE=include/flex.skel.static
# ARCH_CLASS hp700 needs special flags,
# everything else uses default:
#
USR_CFLAGS_DEFAULT := -DUSG
USR_CFLAGS_hp700 := -DSCO_UNIX
# This applies to all arch.classes:
#
USR_CFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_FILE)\"
INC += flex.skel.static
# main.c is included in parse.c
#
SRCS := ccl.c dfa.c ecs.c gen.c misc.c nfa.c sym.c tblcmp.c parse.c
PROD := e_flex
include $(TOP)/config/RULES.Host
clean::
$(RM) parse.c parse.h
# EOF Makefile.Host for base/src/toolsComm/flex

24
src/util/Makefile.Host Normal file
View File

@@ -0,0 +1,24 @@
# Makefile.Host for base/src/util
#
TOP = ../../..
include $(TOP)/config/CONFIG_BASE
# default Unix needs lib m, every system needs libs ca & Com:
PROD_LIBS_DEFAULT := m
PROD_LIBS_WIN32 := -nil-
PROD_LIBS := ca Com
PROD_DEFAULT := ca_test iocLogServer startCArepeater
PROD_solaris := ca_test iocLogServer startCArepeater S99logServer S99caRepeater
PROD_WIN32 := ca_test
include $(TOP)/config/RULES.Host
S99%: ../rc2.%
@/usr/bin/sed -e s%:EPICS:%`chdir $(TOP); /usr/bin/pwd`% \
-e s%:INSTALL_BIN:%`chdir $(INSTALL_BIN); /usr/bin/pwd`% \
$< >$@
# EOF Makefile.Host for base/src/util