This commit is contained in:
Alan Dipert
2010-03-08 05:55:21 -05:00
commit 29c82be0c2
528 changed files with 159411 additions and 0 deletions

171
libdtm/Makefile Normal file
View File

@@ -0,0 +1,171 @@
#
# Makefile for libdtm
#
# USAGE:
# make all - if you have the $ARCH variable set
# setenv ARCH .`arch`
# make sun - if you want to build for the sun
# make XXX - for any machine in particular
# make spec - to build a version libdtmXXX.a where XXX is $ARCH
#
.SUFFIXES: $(ARCH).o
DTMINC = .
LIBDTM=libdtm.a
OBJ=dtminit.o dtm.o dtmmisc.o socket.o rwrtns.o fatal.o sds.o sdl.o ris.o \
dtmnserv.o ninit.o nmsg.o callback.o vdata.o
OBJ_SPEC=dtminit$(ARCH).o dtm$(ARCH).o dtmmisc$(ARCH).o socket$(ARCH).o \
rwrtns$(ARCH).o fatal$(ARCH).o sds$(ARCH).o sdl$(ARCH).o ris$(ARCH).o \
dtmnserv$(ARCH).o ninit$(ARCH).o nmsg$(ARCH).o callback$(ARCH).o
DEPENDS = make.depend
CFT = cft77
FOBJS = dtmf77.o crayinit.o
dtmlib : dtm_$(ARCH)
all : dtm_$(ARCH)
spec : $(ARCH)
all_spec: $(ARCH)
dtm_.sun4 : sun
dtm_.alpha : alpha
dtm_.sgi : sgi
dtm_.next : next
dtm_.cray : cray
dtm_.ibm : ibm
dtm_.convex : convex
dtm_.dec : dec
dtm_.vax : vax
dtm_.hp : hp
dtm_ ::
@echo Either set up the ARCH environment or specify a machine type
@echo " ex: make sun"
solaris :
make internal "CC=$(CC)" "CFLAGS = -DSUN -DSOLARIS" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = /bin/true libdtm.a"
solarisx86 :
make internal "CC=$(CC)" "CFLAGS = -DSUN -DSOLARIS" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = /bin/true libdtm.a"
alpha :
make internal "CFLAGS = -DOSF1 -target $(TARGET_ARCH:-%=%)" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
linux :
make internal "CFLAGS = -DLINUX" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
sun4 : sun
sun :
make internal "CFLAGS = -DSUN -target $(TARGET_ARCH:-%=%)" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
.sun4 :
make internal_spec "CFLAGS = -g -DSUN -target $(TARGET_ARCH:-%=%)" \
"OBJECTS = $(OBJ_SPEC) convert$(ARCH).o mdd$(ARCH).o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm$(ARCH).a"
next :
make internal "CFLAGS = -DNEXT " \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
sgi :
make internal "CFLAGS = -DSGI -cckr -I/usr/include/sun -I/usr/include/bsd" \
"OBJECTS = $(OBJ) convert.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = "
indy: $(OBJ) convert.o
ar cr libdtm.a $(OBJ)
.sgi :
make internal_spec "CFLAGS = -DSGI -I/usr/include/sun -I/usr/include/bsd" \
"OBJECTS = $(OBJ_SPEC) convert$(ARCH).o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = "
cray :
make internal "CFLAGS = -DCRAY" "CFT = cft77" \
"OBJECTS = $(OBJ) craycvt.o crayrtns.o" \
"ARCHIVE = bld q" \
"RANLIB_CMD = "
make libdtmf77.a "CFLAGS = -DCRAY" "CFT = cft77" \
"OBJECTS = $(OBJ) craycvt.o crayrtns.o sdsF.o" \
"ARCHIVE = bld q"
convex :
make internal "CFLAGS = -DCONVEX -fi" \
"OBJECTS = $(OBJ) mdd.o convert.o" "ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
ibm :
make internal "CFLAGS = -DRS6000" "OBJECTS = $(OBJ) mdd.o convert.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
hp :
make internal "CFLAGS = -Aa -D_HPUX_SOURCE" "OBJECTS = $(OBJ) mdd.o convert.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = "
dec :
make internal "CFLAGS = -DDEC" "OBJECTS = $(OBJ) mdd.o deccvt.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ar ts libdtm.a"
vax :
make internal "CFLAGS = -DVAX" "OBJECTS = $(OBJ) mdd.o vaxcvt.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = "
%$(ARCH).o: %.c
$(CC) $(CFLAGS) $(DTMCFLAGS) -c $< -o $@
internal : $(LIBDTM)
$(LIBDTM): $(OBJECTS)
$(ARCHIVE) libdtm.a $(OBJECTS)
$(RANLIB_CMD)
internal_spec : $(OBJECTS)
$(ARCHIVE) libdtm$(ARCH).a $(OBJECTS)
$(RANLIB_CMD)
libdtmf77.a : $(OBJECTS) $(FOBJS)
$(ARCHIVE) libdtmf77.a $(OBJECTS) $(FOBJS)
depend::
makedepend -f $(DEPENDS) -I$(DTMINC) *.c *.f
sed -e "s/\.o/$(ARCH).o/1w .depend.temp" -e "d" < $(DEPENDS)
cat .depend.temp >> $(DEPENDS)
clean::
-rm -f *.o *.a
install::
-mv $(DIR)/lib/libdtm.a $(DIR)/lib/libdtm.bak
cp *.a $(DIR)/lib
-ranlib $(DIR)/lib/libdtm.a
-rm -f $(DIR)/include/dtm.h $(DIR)/include/sds.h
-rm -f $(DIR)/include/ris.h $(DIR)/include/db.h
-rm -f $(DIR)/include/mdd.h $(DIR)/include/sdl.h
-rm -f $(DIR)/include/debug.h $(DIR)/include/arch.h
cp dtm.h debug.h sds.h ris.h db.h mdd.h sdl.h arch.h $(DIR)/include
include $(DEPENDS)

171
libdtm/Makefile.orig Normal file
View File

@@ -0,0 +1,171 @@
#
# Makefile for libdtm
#
# USAGE:
# make all - if you have the $ARCH variable set
# setenv ARCH .`arch`
# make sun - if you want to build for the sun
# make XXX - for any machine in particular
# make spec - to build a version libdtmXXX.a where XXX is $ARCH
#
.SUFFIXES: $(ARCH).o
DTMINC = .
LIBDTM=libdtm.a
OBJ=dtminit.o dtm.o dtmmisc.o socket.o rwrtns.o fatal.o sds.o sdl.o ris.o \
dtmnserv.o ninit.o nmsg.o callback.o vdata.o
OBJ_SPEC=dtminit$(ARCH).o dtm$(ARCH).o dtmmisc$(ARCH).o socket$(ARCH).o \
rwrtns$(ARCH).o fatal$(ARCH).o sds$(ARCH).o sdl$(ARCH).o ris$(ARCH).o \
dtmnserv$(ARCH).o ninit$(ARCH).o nmsg$(ARCH).o callback$(ARCH).o
DEPENDS = make.depend
CFT = cft77
FOBJS = dtmf77.o crayinit.o
dtmlib : dtm_$(ARCH)
all : dtm_$(ARCH)
spec : $(ARCH)
all_spec: $(ARCH)
dtm_.sun4 : sun
dtm_.alpha : alpha
dtm_.sgi : sgi
dtm_.next : next
dtm_.cray : cray
dtm_.ibm : ibm
dtm_.convex : convex
dtm_.dec : dec
dtm_.vax : vax
dtm_.hp : hp
dtm_ ::
@echo Either set up the ARCH environment or specify a machine type
@echo " ex: make sun"
solaris :
make internal "CC=$(CC)" "CFLAGS = -DSUN -DSOLARIS" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = /bin/true libdtm.a"
solarisx86 :
make internal "CC=$(CC)" "CFLAGS = -DSUN -DSOLARIS" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = /bin/true libdtm.a"
alpha :
make internal "CFLAGS = -DOSF1 -target $(TARGET_ARCH:-%=%)" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
linux :
make internal "CFLAGS = -DLINUX" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
sun4 : sun
sun :
make internal "CFLAGS = -DSUN -target $(TARGET_ARCH:-%=%)" \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
.sun4 :
make internal_spec "CFLAGS = -g -DSUN -target $(TARGET_ARCH:-%=%)" \
"OBJECTS = $(OBJ_SPEC) convert$(ARCH).o mdd$(ARCH).o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm$(ARCH).a"
next :
make internal "CFLAGS = -DNEXT " \
"OBJECTS = $(OBJ) convert.o mdd.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
sgi :
make internal "CFLAGS = -DSGI -cckr -I/usr/include/sun -I/usr/include/bsd" \
"OBJECTS = $(OBJ) convert.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = "
indy: $(OBJ) convert.o
ar cr libdtm.a $(OBJ)
.sgi :
make internal_spec "CFLAGS = -DSGI -I/usr/include/sun -I/usr/include/bsd" \
"OBJECTS = $(OBJ_SPEC) convert$(ARCH).o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = "
cray :
make internal "CFLAGS = -DCRAY" "CFT = cft77" \
"OBJECTS = $(OBJ) craycvt.o crayrtns.o" \
"ARCHIVE = bld q" \
"RANLIB_CMD = "
make libdtmf77.a "CFLAGS = -DCRAY" "CFT = cft77" \
"OBJECTS = $(OBJ) craycvt.o crayrtns.o sdsF.o" \
"ARCHIVE = bld q"
convex :
make internal "CFLAGS = -DCONVEX -fi" \
"OBJECTS = $(OBJ) mdd.o convert.o" "ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
ibm :
make internal "CFLAGS = -DRS6000" "OBJECTS = $(OBJ) mdd.o convert.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ranlib libdtm.a"
hp :
make internal "CFLAGS = -Aa -D_HPUX_SOURCE" "OBJECTS = $(OBJ) mdd.o convert.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = "
dec :
make internal "CFLAGS = -DDEC" "OBJECTS = $(OBJ) mdd.o deccvt.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = ar ts libdtm.a"
vax :
make internal "CFLAGS = -DVAX" "OBJECTS = $(OBJ) mdd.o vaxcvt.o" \
"ARCHIVE = ar rv" \
"RANLIB_CMD = "
%$(ARCH).o: %.c
$(CC) $(CFLAGS) $(DTMCFLAGS) -c $< -o $@
internal : $(LIBDTM)
$(LIBDTM): $(OBJECTS)
$(ARCHIVE) libdtm.a $(OBJECTS)
$(RANLIB_CMD)
internal_spec : $(OBJECTS)
$(ARCHIVE) libdtm$(ARCH).a $(OBJECTS)
$(RANLIB_CMD)
libdtmf77.a : $(OBJECTS) $(FOBJS)
$(ARCHIVE) libdtmf77.a $(OBJECTS) $(FOBJS)
depend::
makedepend -f $(DEPENDS) -I$(DTMINC) *.c *.f
sed -e "s/\.o/$(ARCH).o/1w .depend.temp" -e "d" < $(DEPENDS)
cat .depend.temp >> $(DEPENDS)
clean::
-rm -f *.o *.a
install::
-mv $(DIR)/lib/libdtm.a $(DIR)/lib/libdtm.bak
cp *.a $(DIR)/lib
-ranlib $(DIR)/lib/libdtm.a
-rm -f $(DIR)/include/dtm.h $(DIR)/include/sds.h
-rm -f $(DIR)/include/ris.h $(DIR)/include/db.h
-rm -f $(DIR)/include/mdd.h $(DIR)/include/sdl.h
-rm -f $(DIR)/include/debug.h $(DIR)/include/arch.h
cp dtm.h debug.h sds.h ris.h db.h mdd.h sdl.h arch.h $(DIR)/include
include $(DEPENDS)

6
libdtm/README Normal file
View File

@@ -0,0 +1,6 @@
This is version 2.3r2 of NCSA DTM.
See Makefile for build instructions; e.g.
make sgi
make sun

52
libdtm/anim.h Normal file
View File

@@ -0,0 +1,52 @@
#define ANIMclass "ANIM"
#define ANIMtag "ANIMATION"
#define ANIMtitle "TTL"
#define ANIMframeNumber "FRN"
#define ANIMfunc "FNC"
#define ANIMid "ID"
#define ANIMskip "SKIP"
#define ANIMRunType "RType"
#define ANIMExpandX "XEXPAND"
#define ANIMExpandY "YEXPAND"
#define ANIM_FUNC_STOP 1
#define ANIM_FUNC_FPLAY 2 /* forward play */
#define ANIM_FUNC_RPLAY 3 /* reverse play */
#define ANIM_RUN_TYPE_SINGLE 1 /* single play */
#define ANIM_RUN_TYPE_CONT 2 /* continuous play in one direction*/
#define ANIM_RUN_TYPE_BOUNCE 3 /* continuous play alternating direction*/
#define ANIMsetClass(h) dtm_set_class(h,ANIMclass)
#define ANIMcompareClass(h) dtm_compare_class(h,ANIMclass)
#define ANIMsetTitle dtm_set_title
#define ANIMgetTitle dtm_get_title
#define ANIMsetID(h,s) dtm_set_char(h,ANIMid,s)
#define ANIMgetID(h,s,l) dtm_get_char(h,ANIMid,s,l)
#define ANIMsetFunc(h,i) dtm_set_int(h,ANIMfunc,i)
#define ANIMgetFunc(h,i) dtm_get_int(h,ANIMfunc,i)
#define ANIMsetRunType(h,i) dtm_set_int(h,ANIMRunType,i)
#define ANIMgetRunType(h,i) dtm_get_int(h,ANIMRunType,i)
#define ANIMsetFrame(h,i) dtm_set_int(h,ANIMframeNumber,i)
#define ANIMgetFrame(h,i) dtm_get_int(h,ANIMframeNumber,i)
#define ANIMsetFrameSkip(h,i) dtm_set_int(h,ANIMskip,i)
#define ANIMgetFrameSkip(h,i) dtm_get_int(h,ANIMskip,i)
/* used to mark SDS as animation frame */
#define ANIMmarkAnimation(h) dtm_set_int(h,ANIMtag,1)
#define ANIMisAnimation(h,i) ((dtm_get_int(h,ANIMtag,&(i)) == -1)?0:1)
#define ANIMsetExpansion(h,x,y) {dtm_set_float(h,ANIMExpandX,x); \
dtm_set_float(h,ANIMExpandY,y); }
#define ANIMgetExpansion(h,x,y) {if (-1 == dtm_get_float(h,ANIMExpandX,x)) \
{ (*(x)) = 1.0; (*(y)) = 1.0;} \
if (-1 == dtm_get_float(h,ANIMExpandY,y)) \
{ (*(x)) = 1.0; (*(y)) = 1.0;} \
}

341
libdtm/arch.h Normal file
View File

@@ -0,0 +1,341 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/arch.h,v 1.5 1996/06/06 19:47:12 spowers Exp $
**
**********************************************************************/
#ifndef ARCH_INC
#define ARCH_INC
/*
* Revision 1.2 1993/10/29 03:46:43 marca
* Tweaks.
*
* Revision 1.1.1.1 1993/07/04 00:03:16 marca
* Mosaic for X version 2 distribution
*
* Revision 1.3 1993/04/18 05:51:45 marca
* Tweaks.
*
* Revision 1.2 1993/01/23 15:30:18 marca
* Fixed define typo.
*
* Revision 1.1 1993/01/18 21:50:00 marca
* I think I got it now.
*
* Revision 1.7 92/04/30 20:27:05 jplevyak
* Changed Version to 2.3
*
* Revision 1.6 1992/04/14 22:59:57 jefft
* included sys/limits.h instead of sys/limit.h
*
* Revision 1.5 1992/04/13 16:07:10 jplevyak
* Changes for DEC and RS6000.
*
* Revision 1.4 92/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.3 1992/03/10 16:52:43 jefft
* modified convex define to __convex__
*
* Revision 1.2 1992/01/14 16:35:22 creiman
* Added _ARCH_PROTO to applec
*
* Revision 1.1 1991/12/17 23:50:49 jefft
* Initial revision
*
*/
/*
The intent of this file is to provide a standard set of
architecturally descriptive preprocessor definitions by
examining the preprocessor identifiers that are defined
in the native compiler running in the default mode.
Please feel free to add to or correct this file.
If you are feeling particularly generous, it would be
appreciated if you would send you changes to:
jplevyak@ncsa.uiuc.edu
so that I may update my version.
Definitions are of the form:
_ARCH_xxxx where xxxx is:
General Manufacturer
SUN - generally any machine by Sun Microsystems
SGI - Silicon Graphics
CRAY - Cray Research
CONVEX - Convex
CM - Connection Machine
IBM
APPLE
HP
DEC
COMMODORE
General OS
DOS
UNIX
MACOS
AMIGA
VMS
OS2
General Processor
SPARC
MIPS
68000
8086
80286
80386
VAX
PA - HP Percision Architecture
RS6000
Specific Interesting Qualities
BIG_ENDIAN
LITTLE_ENDIAN
WORD_SIZE - values include 16, 32, 64 (bits)
SYSV
BSD
PROTO - Compiler supports prototypes
( possible interesting definitions )
mc68k unix unixpc (hp 68k ?)
mc68000
_I386 i386 AIX _AIX (PS2 running AIX)
alliant (68000 unix)
vax mc68k32 PORTAR (altos? 30068)
apollo aegis unix (??) (apollo)
i80386 (compac?) BSD
convex unix (32 bit)
__convex_c1__
__convex_c2__
__MIPSEL __R3000 __SYSTYPE_BSD __bsd4_2 __host_mips __mips
__ultrix __unix, same without __ prefix, Dec Station
ns32000 n16 ns16000 ns32332 unix (encore)
tahoe unix hcx (harris tahoe)
mc68000 mc68010 hp200 unix (hp is BSD)
mc68020
_HPUX_SOURCE hp9000s300 hp9000s200 PWB hpux unix (68000)
hp9000 (BSD)
unix M_UNIX M_I386 M_COFF M_WORDSWAP (ESIX Unix System V)
- Iteractive Unix is like system V
- SCO same as ESIX
SCO_UNIX
i860 (generic) (32 bit)
unix mips sgi SVR3 MIPSEB SYSTYPE_SYSV (IRIS)
r3000 MISPEB SYSTYPE_BSD sony_news unix (mips sony)
mc68000 mc68020 news800 bsd43 (68k sony)
NeXT unix __MACH__ mc68000 (BSD ??)
ns32000 unix (generic) (not big-endian) (32 bit)
pyr unix (Pyramid) (not big-endian) (32 bit)
sequent unix i386
sequent unix ns32000
spur (32 bit machine) (not big or little endian)
sun386 i386 sun unix
mc68000 sun sun3 unix MACH CMU MTXINU BIT_MSF BYTE_MSF (??)
tahoe (generic)
unix tower32 (68k) (NCR Tower running Sys V release 3)
ultrix bsd4_2 vax unix __vax (you guessed it)
vax unix (generic) (not big endian)
vax vms VMS
__TURBOC__
OS2_MC - microsoft C for os2
AMIGA
USG (as indicator or SYSV or SYS_V)
MS_DOS (as general indicator)
applec (MPW)
THINK_C
*/
#if defined( __hpux )
# define _ARCH_HP
# define _ARCH_UNIX
# define _ARCH_SYSV
# define _ARCH_BIG_ENDIAN
# define _ARCH_WORD_SIZE 32
#elif defined( __sgi )
# define _ARCH_SGI
# define _ARCH_UNIX
# define _ARCH_SYSV
# define _ARCH_MIPS
# define _ARCH_BIG_ENDIAN
# define _ARCH_WORD_SIZE 32
# define _ARCH_PROTO
#elif defined( sun )
# define _ARCH_SUN
# define _ARCH_UNIX
# define _ARCH_BSD
# define _ARCH_WORD_SIZE 32
# if defined(sparc)
# define _ARCH_BIG_ENDIAN
# define _ARCH_SPARC
# elif defined( i386 )
# define _ARCH_LITTLE_ENDIAN
# define _ARCH_80386
# else
/* assume */
# define _ARCH_BIG_ENDIAN
# define _ARCH_68000
# endif
#elif defined( NEXT )
# define _ARCH_NEXT
# define _ARCH_UNIX
# define _ARCH_BSD
# define _ARCH_WORD_SIZE 32
# define _ARCH_BIG_ENDIAN
# define _ARCH_68000
#elif defined( cray )
# define _ARCH_CRAY
# define _ARCH_UNIX
# define _ARCH_SYSV /* A rough approximation */
# define _ARCH_BIG_ENDIAN /* ?? */
# define _ARCH_WORD_SIZE 64
#elif defined(vax)
# define _ARCH_DEC
# define _ARCH_VAX
# define _ARCH_WORD_SIZE 32
# define _ARCH_LITTLE_ENDIAN
# if defined( vmx )
# define _ARCH_VMX
# elif defined( unix )
# define _ARCH_UNIX
# define _ARCH_BSD
# endif
#elif defined( __ultrix ) && defined( __mips )
#define _ARCH_DEC
#define _ARCH_DEC_STATION
#define _ARCH_MIPS
#define _ARCH_BSD
#define _ARCH_WORD_SIZE 32
#define _ARCH_LITTLE_ENDIAN
#define _ARCH_PROTO
#elif defined( _IBMR2 )
#define _ARCH_IBM
#define _ARCH_RS6000
#elif defined( AMIGA )
/* incomplete */
# define _ARCH_COMMODORE
# define _ARCH_AMIGA
# define _ARCH_BIG_ENDIAN
# define _ARCH_68000
# define _ARCH_WORD_SIZE 32
#elif defined ( MS_DOS ) || defined(__TURBOC__)
# define _ARCH_MSDOS
# define _ARCH_8086
# define _ARCH_LITTLE_ENDIAN
# define _ARCH_WORD_SIZE 16
# define _ARCH_PROTO
#elif defined ( OS2_MC )
# define _ARCH_OS2
# define _ARCH_80286
# define _ARCH_LITTLE_ENDIAN
# define _ARCH_WORD_SIZE 16
# define _ARCH_MSDOS
# define _ARCH_PROTO
#elif defined ( THINK_C ) || defined( applec )
# define _ARCH_APPLE
# define _ARCH_MACOS
# define _ARCH_68000
# define _ARCH_BIG_ENDIAN
# define _ARCH_WORD_SIZE 32
# define _ARCH_PROTO
#elif defined( alliant )
/* ?? */
# define _ARCH_UNIX
# define _ARCH_68000
# define _ARCH_BIG_ENDIAN
# define _ARCH_WORD_SIZE 32
#elif defined( __convex__ ) || defined( __convex_c1__ ) || defined( __convex_c2__ )
/* ?? */
# define _ARCH_CONVEX
# define _ARCH_UNIX
# define _ARCH_WORD_SIZE 32
#endif
/*
Make best guess from environment.
*/
#if !defined( _ARCH_UNIX ) && !defined( _ARCH_MSDOS ) && !defined( _ARCH_VMS ) \
&& !defined( _ARCH_MACOS ) && !defined( _ARCH_AMIGA ) && !defined( _ARCH_OS2)
# if defined( unix )
# define _ARCH_UNIX
# endif
#endif
#if !defined( _ARCH_BSD ) && !defined( _ARCH_SYSV ) && defined( _ARCH_UNIX )
# if defined( USG )
# define _ARCH_SYSV
# endif
#endif
#if !defined( _ARCH_68000 )
# if defined( mc68k ) || defined( mc68000 ) || defined( mc68k32 ) \
|| defined( mc68020 ) || defined( mc68010 )
# define _ARCH_68000
# if !defined( _ARCH_BIG_ENDIAN )
# define _ARCH_BIG_ENDIAN
# endif
# endif
#endif
#if !defined( _ARCH_PROTO )
# if defined( _STDC_ ) || defined( __STDC__ )
#if !defined(__hpux) && !defined(LINUX)
# define _ARCH_PROTO
#endif /* not __hpux && not LINUX */
# endif
#endif
#if !defined( _ARCH_WORD_SIZE )
# if !defined( INT_MAX )
# ifdef _ARCH_MSDOS
# include <limits.h>
# else
# ifdef _ARCH_NEXT
# include <ansi/limits.h>
# else
# ifdef LINUX
# include <limits.h>
# else
# include <sys/limits.h>
# endif
# endif
# endif
# if INT_MAX == 0x7FFF
# define _ARCH_WORD_SIZE 16
# endif
# if !defined( _ARCH_WORD_SIZE )
# if INT_MAX == 0x7FFFFFFF
# define _ARCH_WORD_SIZE 32
# endif
# endif
# if !defined( _ARCH_WORD_SIZE )
# if INT_MAX == 0x7FFFFFFFFFFFFFFF
# define _ARCH_WORD_SIZE 64
# endif
# endif
# endif
#endif
#endif

163
libdtm/callback.c Normal file
View File

@@ -0,0 +1,163 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
#include <sys/types.h>
#if !defined(NEXT) && !defined(_ARCH_MSDOS)
#include <unistd.h>
#endif
#ifdef __hpux
#include <termio.h>
#endif
#include <fcntl.h>
#ifdef _ARCH_BSD
#include <sys/filio.h>
#endif
#ifdef _ARCH_MSDOS
# include <signal.h>
#else
# include <sys/signal.h>
#endif
#include <sys/file.h>
#include <stdio.h>
#include "dtmint.h"
#include "debug.h"
#ifdef DTM_PROTOTYPES
static void DTMsigioHandler(int sig,int code,struct sigcontext *scp,char *addr )
#else
static void DTMsigioHandler( sig, code, scp, addr )
int sig;
int code;
struct sigcontext *scp;
char *addr;
#endif
{
/*
Unfortunately, not one of the parameters listed above
provides even the slightest help in determinine WHICH
port is now ready for input, and any system calls
screw up any other system calls in progress.
*/
reg int i;
/* DBGMSG2( "DTMsigioHandler enter %X %X\n", code, addr); */
for ( i = 0 ; i < DTMptCount ; i++ ) {
int port;
int ready;
if ( !DTMpt[i] ) continue;
if ( !DTMpt[i]->callback ) continue;
port = i;
dtm_map_port_external(&port);
#if 0
if ((ready = DTMavailRead( port ))== DTMERROR) continue;
if ( ready == DTM_PORT_READY ) {
DBGMSG( "DTMsigioHandler calling user routine\n" );
#endif
(*DTMpt[i]->callback)();
#if 0
}
#endif
}
/* DBGMSG( "DTMsigioHandler exit\n" ); */
}
#ifdef DTM_PROTOTYPES
int dtm_sigio( int fd )
#else
int dtm_sigio( fd )
int fd;
#endif
{
int flags;
int pid=getpid();
int sigio_on=1;
DBGMSG1( "dtm_sigio on fd %d\n", fd );
#ifdef __hpux
if (flags = ioctl( fd, FIOSSAIOOWN, &pid) == -1 ) {
#else
if (flags = fcntl( fd, F_SETOWN, getpid()) == -1 ) {
#endif
DTMerrno = DTMSOCK;
return DTMERROR;
}
#ifdef __hpux
if (flags = ioctl( fd, FIOSSAIOSTAT, &sigio_on ) == -1 ) {
#else
if (flags = fcntl( fd, F_SETFL, FASYNC ) == -1 ) {
#endif
DTMerrno = DTMSOCK;
return DTMERROR;
}
return DTM_OK;
}
#ifdef DTM_PROTOTYPES
int DTMreadReady( int port, void (*pfn)() )
#else
int DTMreadReady( port, pfn )
int32 port;
void (*pfn)();
#endif
{
DTMPORT * pp;
DBGMSG1( "DTMreadReady on port %d\n", port );
CHECK_ERR( port = dtm_map_port_internal( port ));
pp = DTMpt[port];
/*
Just replace the function
*/
if ( pp->callback ) {
pp->callback = pfn;
return DTM_OK;
}
if ( pp->porttype != INPORTTYPE ) {
DTMerrno = DTMBADPORT;
return DTMERROR;
}
DBGMSG1( "DTMreadReady port has sockfd %d\n", pp->sockfd );
#ifndef _ARCH_MSDOS
if ( (int)signal( SIGIO, DTMsigioHandler) == -1 ) {
DBGMSG( "DTMreadReady signal failed\n" );
DTMerrno = DTMSOCK;
return DTMERROR;
}
#endif
pp->callback = pfn;
{
reg Inport *inp;
if( dtm_sigio( pp->sockfd )== DTMERROR) {
DTMerrno = DTMSOCK;
return DTMERROR;
}
FOR_EACH_IN_PORT( inp, pp ) {
if (dtm_sigio( inp->fd )== DTMERROR) {
DTMerrno = DTMSOCK;
return DTMERROR;
}
}
}
return DTM_OK;
}

62
libdtm/col.h Normal file
View File

@@ -0,0 +1,62 @@
#define COL_TRIPLET DTM_TRIPLET
#define COLclass "COL"
#define COLtitle "TTL"
#define COLdims "DIM"
#define COLwidth "WTH"
#define COLfunc "FNC"
#define COLsel "SEL"
#define COLid "ID"
#define COLviewType "ViewType"
#define COLassociated "ASSOCIATED"
#define COL_POINT 1
#define COL_LINE 2
#define COL_AREA 3
#define COL_DOODLE_CONT 4
#define COL_DOODLE_DISC 5
#ifndef V_RASTER
# define V_RASTER 1
# define V_WHITEBOARD 2
# define V_SHEET 3
# define V_TEXT 4
#endif /* ! V_RASTER */
#ifdef DTM1
#define COLsetClass(h) DTMsetClass(h,COLclass)
#define COLcompareClass(h) DTMcompareClass(h,COLclass)
#else
#define COLsetClass(h) dtm_set_class(h,COLclass)
#define COLcompareClass(h) dtm_compare_class(h,COLclass)
#endif
#ifdef DTM1
#define COLsetTitle DTMsetTitle
#define COLgetTitle DTMgetTitle
#else
#define COLsetTitle dtm_set_title
#define COLgetTitle dtm_get_title
#endif
#define COLsetID(h,i) dtm_set_char(h,COLid,i)
#define COLgetID(h,s,l) dtm_get_char(h,COLid,s,l)
#define COLsetFunc(h,f,s) { dtm_set_char(h,COLfunc,f); \
dtm_set_int(h,COLsel,s); }
/* COLgetFunc(char *header, char *function, int length, int *selType) */
#define COLgetFunc(h,f,l,i) ( dtm_get_char(h,COLfunc,f,l) || \
dtm_get_int(h,COLsel,i) )
#define COLsetDimension(h,i) dtm_set_int(h,COLdims,i)
#define COLgetDimension(h,i) dtm_get_int(h,COLdims,i)
#define COLsetWidth(h,i) dtm_set_int(h,COLwidth,i)
#define COLgetWidth(h,i) dtm_get_int(h,COLwidth,i)
#define COLsetView(h, v) dtm_set_int((h), COLviewType, (v))
#define COLgetView(h, v) (*(v) = 0, dtm_get_int((h), COLviewType, (v)))
#define COLsetAssoc(h, a) dtm_set_char(h, COLassociated, a)
#define COLgetAssoc(h, a, l) dtm_get_char(h, COLassociated, a, l)

16
libdtm/com.h Normal file
View File

@@ -0,0 +1,16 @@
#define COMclass "COM"
#define COMid "ID"
#define COMdomain "COMDOMAIN"
#define COMmesg "COMMAND"
#define COMsetClass(h) dtm_set_class(h,COMclass)
#define COMcompareClass(h) dtm_compare_class(h,COMclass)
#define COMsetID(h,s) dtm_set_char(h,COMid,s)
#define COMgetID(h,s,l) dtm_get_char(h,COMid,s,l)
#define COMsetDomain(h,s) dtm_set_char(h,COMdomain,s)
#define COMgetDomain(h,s,l) dtm_get_char(h,COMdomain,s,l)
#define COMsetMesg(h,s) dtm_set_char(h,COMmesg,s)
#define COMgetMesg(h,s,l) dtm_get_char(h,COMmesg,s,l)

154
libdtm/convert.c Normal file
View File

@@ -0,0 +1,154 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/******************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/convert.c,v 1.2 1995/10/13 06:33:03 spowers Exp $
**
******************************************************************/
/*
#ifdef RCSLOG
$Log: convert.c,v $
Revision 1.2 1995/10/13 06:33:03 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:02:56 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:39:19 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:30 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:09 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:05 marca
* I think I got it now.
*
* Revision 1.3 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.2 1991/06/11 15:21:13 sreedhar
* disclaimer added
*
* Revision 1.1 1990/11/08 16:28:46 jefft
* Initial revision
*
#endif
*/
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include "dtmint.h"
#include "debug.h"
static int dtm_char(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_char called.\n");
return size;
}
static int dtm_short(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_short called.\n");
return ((mode == DTMLOCAL) ? (size / 2) : (size * 2));
}
static int dtm_int(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_int called.\n");
return ((mode == DTMLOCAL) ? (size / 4) : (size * 4));
}
static int dtm_float(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_float called.\n");
return ((mode == DTMLOCAL) ? (size / 4) : (size * 4));
}
static int dtm_double(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_flt64 called.\n");
return ((mode == DTMLOCAL) ? (size / 8) : (size * 8));
}
static int dtm_complex(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_complex called.\n");
return ((mode == DTMLOCAL) ? (size / 8) : (size * 8));
}
static int dtm_triplet(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_triplet called.\n");
return ((mode == DTMLOCAL) ? (size / 16) : (size * 16));
}
/* conversion routine function table */
int (*DTMconvertRtns[])() = {
dtm_char,
dtm_short,
dtm_int,
dtm_float,
dtm_double,
dtm_complex,
dtm_triplet
};

216
libdtm/craycvt.c Normal file
View File

@@ -0,0 +1,216 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/craycvt.c,v 1.1.1.1 1995/01/11 00:02:57 alanb Exp $
**
**********************************************************************/
#ifdef RCSLOG
$Log: craycvt.c,v $
Revision 1.1.1.1 1995/01/11 00:02:57 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:39:21 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:30 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:09 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:06 marca
* I think I got it now.
*
* Revision 1.4 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.3 1991/06/11 15:21:41 sreedhar
* disclaimer added
*
* Revision 1.2 1991/01/31 17:08:16 jefft
* Added 'icheck' variable to force checking of floating point values and
* changing to 0 on underflow.
*
* Revision 1.1 90/11/08 16:29:13 jefft
* Initial revision
*
#endif
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include "dtmint.h"
#include "debug.h"
static int dtm_char(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_char called.\n");
return size;
}
static int dtm_short(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_short called.\n");
return ((mode == DTMLOCAL) ? (size / 2) : (size * 2));
}
static int dtm_int(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_int called.\n");
if (mode == DTMLOCAL) {
if (buf != NULL) {
int tmp;
tmp = size / 4;
DTMSCI(buf, buf, &tmp);
}
return (size / 4);
}
else {
if (buf != NULL)
DTMCSI(buf, buf, &size);
return (size * 4);
}
}
static int dtm_float(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
int icheck = 1;
DBGFLOW("# dtm_float called.\n");
if (mode == DTMLOCAL) {
if (buf != NULL) {
int tmp;
tmp = size / 4;
DTMSCF(buf, buf, &tmp);
}
return (size / 4);
}
else {
if (buf != NULL)
DTMCSF(buf, buf, &size, &icheck);
return (size * 4);
}
}
static int dtm_double(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_flt64 called.\n");
return ((mode == DTMLOCAL) ? (size / 8) : (size * 8));
}
static int dtm_complex(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
int icheck = 1;
DBGFLOW("# dtm_complex called.\n");
if (mode == DTMLOCAL) {
if (buf != NULL) {
int tmp;
tmp = size / 8;
DTMSCF(buf, buf, &tmp);
}
return (size / 8);
}
else {
if (buf != NULL)
DTMCSF(buf, buf, &size, &icheck);
return (size * 8);
}
}
static int dtm_triplet(mode, buf, size)
int mode, size;
VOIDPTR buf;
{
DBGFLOW("# dtm_triplet called.\n");
if (mode == DTMLOCAL) {
if (buf != NULL) {
int tmp;
tmp = size / 16;
DTMSCT(buf, buf, &tmp);
}
return (size / 16);
}
else {
if (buf != NULL)
DTMCST(buf, buf, &size);
return (size * 16);
}
}
/* conversion routine function table */
int (*DTMconvertRtns[])() = {
dtm_char,
dtm_short,
dtm_int,
dtm_float,
dtm_double,
dtm_complex,
dtm_triplet
};

77
libdtm/crayinit.f Normal file
View File

@@ -0,0 +1,77 @@
C NCSA DTM version 2.0
C June 10, 1991
C
C NCSA DTM Version 2.0 source code and documentation are in the public
C domain. Specifically, we give to the public domain all rights for future
C licensing of the source code, all resale rights, and all publishing rights.
C
C We ask, but do not require, that the following message be included in all
C derived works:
C
C Portions developed at the National Center for Supercomputing Applications at
C the University of Illinois at Urbana-Champaign.
C
C THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
C SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
C WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
C
C $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/crayinit.f,v 1.1.1.1 1995/01/11 00:02:57 alanb Exp $
C $Log: crayinit.f,v $
C Revision 1.1.1.1 1995/01/11 00:02:57 alanb
C New CVS source tree, Mosaic 2.5 beta 4
C
c Revision 2.5 1994/12/29 23:39:23 alanb
c I'm committing with a new symbolic revision number.
c
c Revision 1.1.1.1 1994/12/28 21:37:30 alanb
c
c Revision 1.1.1.1 1993/07/04 00:03:09 marca
c Mosaic for X version 2 distribution
c
c Revision 1.1 1993/01/18 21:50:07 marca
c I think I got it now.
c
c Revision 1.2 1993/01/18 21:46:45 marca
c Plugging DTM in...
c
c Revision 1.3 91/06/13 21:23:57 jefft
c added type of function to prevent returning of a float
c
c Revision 1.2 1991/06/11 15:21:54 sreedhar
c disclaimer added
c
c Revision 1.1 1990/11/08 16:29:43 jefft
c Initial revision
c
integer function DTMINIT()
integer i, tmp, pcnt
integer DTMMIP, DTMMOP
character*64 portname
pcnt = 0
do 10 i = 1, iargc()
call getarg(i, portname)
if (index(portname, '-DTMIN') .NE. 0) then
call getarg(i+1, portname)
tmp = DTMMIP(portname)
pcnt = pcnt + 1
elseif (index(portname, '-DTMOUT') .NE. 0) then
call getarg(i+1, portname)
tmp = DTMMOP(portname)
pcnt = pcnt + 1
elseif (index(portname, '-DTM') .NE. 0) then
call getarg(i+1, portname)
tmp = DTMMOP(portname)
pcnt = pcnt + 1
endif
10 continue
DTMINIT = pcnt
return
end

269
libdtm/crayrtns.f Normal file
View File

@@ -0,0 +1,269 @@
C NCSA DTM version 2.0
C June 10, 1991
C
C NCSA DTM Version 2.0 source code and documentation are in the public
C domain. Specifically, we give to the public domain all rights for future
C licensing of the source code, all resale rights, and all publishing rights.
C
C We ask, but do not require, that the following message be included in all
C derived works:
C
C Portions developed at the National Center for Supercomputing Applications at
C the University of Illinois at Urbana-Champaign.
C
C THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
C SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
C WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
C
C $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/crayrtns.f,v 1.1.1.1 1995/01/11 00:02:57 alanb Exp $
C $Log: crayrtns.f,v $
C Revision 1.1.1.1 1995/01/11 00:02:57 alanb
C New CVS source tree, Mosaic 2.5 beta 4
C
c Revision 2.5 1994/12/29 23:39:27 alanb
c I'm committing with a new symbolic revision number.
c
c Revision 1.1.1.1 1994/12/28 21:37:30 alanb
c
c Revision 1.1.1.1 1993/07/04 00:03:09 marca
c Mosaic for X version 2 distribution
c
c Revision 1.1 1993/01/18 21:50:08 marca
c I think I got it now.
c
c Revision 1.2 1993/01/18 21:46:47 marca
c Plugging DTM in...
c
c Revision 1.4 91/06/11 15:21:47 sreedhar
c disclaimer added
c
c Revision 1.3 1991/05/16 04:40:13 jefft
c Fixed bugs in TRIPLET conversion
c
c Revision 1.2 1991/01/31 17:06:05 jefft
c Fixed bug in Cray floating point conversion routines.
c
c Revision 1.1 90/11/08 16:30:17 jefft
c Initial revision
c
C Cray_to_Sun_32-bit_floating-point (with packing) conversion routine.
C USAGE: call cspk32 (carray, sarray, size)
C WHERE carray is the array of Cray floating point numbers
C (64 bit) to be converted to 32-bit IEEE format
C reals and packed 2 to 1 (high to low order) in sarray.
C Size is the dimension of the input carray.
C (sarray is assumed to be (size+1)/2 )
C Icheck, if 1, provides checking for over/underflow
C and writes the appropriate "infinity" pattern.
C
subroutine DTMCSF (carray,sarray,size,icheck)
integer size,carray(0:size-1),sarray(0:(size+1)/2-1)
integer stemp1,stemp2,exp1,exp2,mant1,mant2
if (icheck.eq.1) goto 30
do 20 i=0,(size+1)/2-1
sign1=and(carray(2*i),x'8000000000000000')
sign2=and(carray(2*i+1),x'8000000000000000')
exp1=shiftr(and(carray(2*i),x'7fff000000000000'),48)-16258
exp2=shiftr(and(carray(2*i+1),x'7fff000000000000'),48)-16258
mant1=shiftr(and(carray(2*i),x'00007fffff000000'),24)
& +shiftr(and(carray(2*i),x'0000000000800000'),23)
mant2=shiftr(and(carray(2*i+1),x'00007fffff000000'),24)
& +shiftr(and(carray(2*i+1),x'0000000000800000'),23)
stemp1=or(sign1, (shiftl(exp1,55) + shiftl(mant1,32)) )
stemp2=or(sign2, (shiftl(exp2,55) + shiftl(mant2,32)) )
stemp1=cvmgn(stemp1,0,carray(2*i))
stemp2=cvmgn(stemp2,0,carray(2*i+1))
sarray(i)=or(stemp1,shiftr(stemp2,32))
20 continue
return
30 continue
do 10 i=0,(size+1)/2-1
sign1=and(carray(2*i),x'8000000000000000')
sign2=and(carray(2*i+1),x'8000000000000000')
exp1=shiftr(and(carray(2*i),x'7fff000000000000'),48)-16258
exp2=shiftr(and(carray(2*i+1),x'7fff000000000000'),48)-16258
mant1=shiftr(and(carray(2*i),x'00007fffff000000'),24)
& +shiftr(and(carray(2*i),x'0000000000800000'),23)
mant2=shiftr(and(carray(2*i+1),x'00007fffff000000'),24)
& +shiftr(and(carray(2*i+1),x'0000000000800000'),23)
stemp1=or(sign1, (shiftl(exp1,55) + shiftl(mant1,32)) )
stemp2=or(sign2, (shiftl(exp2,55) + shiftl(mant2,32)) )
stemp1=cvmgm(or(sign1,x'7f80000000000000'),stemp1,254-exp1)
stemp2=cvmgm(or(sign2,x'7f80000000000000'),stemp2,254-exp2)
stemp1=cvmgn(stemp1,0,carray(2*i))
stemp2=cvmgn(stemp2,0,carray(2*i+1))
stemp1=cvmgm(0,stemp1,exp1-1)
stemp2=cvmgm(0,stemp2,exp2-1)
sarray(i)=or(stemp1,shiftr(stemp2,32))
10 continue
end
C Sun_to_Cray_32-bit_Floating-point (with unpacking) conversion routine.
C USAGE: call scup32 (sarray, carray, size)
C WHERE sarray is the array of 32-bit IEEE floating-point numbers
C (packed 2 per word) to be converted 64-bit Cray format
C and stored in carray. Size is the dimension
C of the output carray. (sarray is assumed to be (size+1)/2 ).
C Icheck is not used.
C
subroutine DTMSCF (sarray,carray,size,icheck)
integer size,sarray(0:(size+1)/2-1),carray(0:size-1),temp
cdir$ ivdep
do 40 i=(size+1)/2-1,0,-1
carray(2*i)=and(sarray(i),x'ffffffff00000000')
carray(2*i+1)=shiftl(sarray(i),32)
40 continue
do 50 i=0, size-1
temp=carray(i)
CARRAY(I)=OR(OR(AND(carray(I),X'8000000000000000'),SHIFTR
& (AND(carray(I),X'7F80000000000000'),7)+shiftl(16258,48)),or(
&shiftr(AND(carray(I),X'007FFFFF00000000'),8),X'0000800000000000'))
carray(i)=cvmgn(carray(i),0,shiftl(temp,1))
50 continue
end
C
C Integer_Cray_to_Sun_32-bit (with packing) conversion routine.
C USAGE: call icspk32 (carray, sarray, size)
C WHERE carray is the array of 64-bit signed integers to be
C into 32-bit integers packed 2 per word and stored in
C sarray. Size is the dimension of the input carray,
C Sarray is assumed to be (size+1)/2.
C
subroutine DTMCSI (sarray,carray,size)
integer size,sarray(0:(size+1)/2-1),carray(0:size-1),temp
cdir$ ivdep
do 60 i=0, (size+1)/2-1
sarray(i)=or(
& and(shiftl(carray(2*i),32),x'ffffffff00000000'),
& and(carray(2*i+1), x'00000000ffffffff'))
60 continue
end
C
C Integer_Sun_32-bit_to_Cray_64-bit with unpacking conversion routine.
C USAGE: call iscup32 (sarray, carray, size)
C WHERE sarray is the array of 32-bit signed integers packed 2
C per word to be converted to 64 bit Cray integers and
C stored in carray. Size is the dimension of the output
C carray. (sarray is assumed to be (size+1)/2 ).
C
subroutine DTMSCI (sarray,carray,size)
integer size,sarray(0:(size+1)/2-1),carray(0:size-1),temp
cdir$ ivdep
do 80 i=(size+1)/2-1,0,-1
carray(2*i) = shiftr(sarray(i), 32)
carray(2*i+1)=and(sarray(i),x'ffffffff')
80 continue
do 90 i=0, size-1
carray(i) = or(carray(i), cvmgz(0, x'ffffffff00000000',
& and(carray(i), x'80000000')))
90 continue
end
C
C Cray to Sun Triplet (with packing) conversion routine.
C USAGE: call DTMCST (carray, sarray, size)
C WHERE carray is the array of DTM triplet structures
C (cray format) to be converted into standard format
C and packed into sarray.
C size is the dimension of the input carray,
C sarray is assumed to be size/2.
C
subroutine DTMCST (sarray,carray,size)
integer size,sarray(0:size*2-1),carray(0:size*4-1)
integer stemp1,stemp2,exp1,exp2,mant1,mant2
cdir$ ivdep
do 100 i=0, size*2-1, 2
sign2=and(carray(2*i+1),x'8000000000000000')
exp2=shiftr(and(carray(2*i+1),x'7fff000000000000'),48)-16258
mant2=shiftr(and(carray(2*i+1),x'00007fffff000000'),24)
& +shiftr(and(carray(2*i+1),x'0000000000800000'),23)
stemp2=or(sign2, (shiftl(exp2,55) + shiftl(mant2,32)) )
stemp2=cvmgm(or(sign2,x'7f80000000000000'),stemp2,254-exp2)
stemp2=cvmgn(stemp2,0,carray(2*i+1))
stemp2=cvmgm(0,stemp2,exp2-1)
sarray(i)=or(and(shiftl(carray(2*i),32),x'ffffffff00000000'),
& shiftr(stemp2,32))
sign1=and(carray(2*i+2),x'8000000000000000')
sign2=and(carray(2*i+3),x'8000000000000000')
exp1=shiftr(and(carray(2*i+2),x'7fff000000000000'),48)-16258
exp2=shiftr(and(carray(2*i+3),x'7fff000000000000'),48)-16258
mant1=shiftr(and(carray(2*i+2),x'00007fffff000000'),24)
& +shiftr(and(carray(2*i+2),x'0000000000800000'),23)
mant2=shiftr(and(carray(2*i+3),x'00007fffff000000'),24)
& +shiftr(and(carray(2*i+3),x'0000000000800000'),23)
stemp1=or(sign1, (shiftl(exp1,55) + shiftl(mant1,32)) )
stemp2=or(sign2, (shiftl(exp2,55) + shiftl(mant2,32)) )
stemp1=cvmgm(or(sign1,x'7f80000000000000'),stemp1,254-exp1)
stemp2=cvmgm(or(sign2,x'7f80000000000000'),stemp2,254-exp2)
stemp1=cvmgn(stemp1,0,carray(2*i+2))
stemp2=cvmgn(stemp2,0,carray(2*i+3))
stemp1=cvmgm(0,stemp1,exp1-1)
stemp2=cvmgm(0,stemp2,exp2-1)
sarray(i+1)=or(stemp1,shiftr(stemp2,32))
100 continue
end
C
C Sun to Cray Triplet with unpacking conversion routine.
C USAGE: call DTMSCT (sarray, carray, size)
C WHERE sarray is the array of 32-bit signed integers packed 2
C per word to be converted to 64 bit Cray integers and
C stored in carray. Size is the dimension of the output
C carray. (sarray is assumed to be (size+1)/2 ).
C
subroutine DTMSCT (sarray,carray,size)
integer size,sarray(0:size*2-1),carray(0:size*4-1),temp
cdir$ ivdep
do 110 i=size*2-1, 0, -1
carray(2*i)=and(sarray(i),x'ffffffff00000000')
carray(2*i+1)=shiftl(sarray(i),32)
110 continue
do 120 i=0, size-1, 4
C convert tag
carray(i) = or(carray(i), cvmgz(0, x'ffffffff00000000',
& and(carray(i), x'80000000')))
C convert 1st float
temp=carray(i+1)
CARRAY(I+1)=OR(OR(AND(carray(I+1),X'8000000000000000'),
& SHIFTR(AND(carray(I+1),X'7F80000000000000'),7)+
& shiftl(16258,48)),or(shiftr(AND(carray(I+1),
& X'007FFFFF00000000'),8),X'0000800000000000'))
carray(i+1)=cvmgn(carray(i+1),0,shiftl(temp,1))
C convert 2nd float
temp=carray(i+2)
CARRAY(I+2)=OR(OR(AND(carray(I+2),X'8000000000000000'),
& SHIFTR(AND(carray(I+2),X'7F80000000000000'),7)+
& shiftl(16258,48)),or(shiftr(AND(carray(I+2),
& X'007FFFFF00000000'),8),X'0000800000000000'))
carray(i+2)=cvmgn(carray(i+2),0,shiftl(temp,1))
C convert 3rd float
temp=carray(i+3)
CARRAY(I+3)=OR(OR(AND(carray(I+3),X'8000000000000000'),
& SHIFTR(AND(carray(I+3),X'7F80000000000000'),7)+
& shiftl(16258,48)),or(shiftr(AND(carray(I+3),
& X'007FFFFF00000000'),8),X'0000800000000000'))
carray(i+3)=cvmgn(carray(i+3),0,shiftl(temp,1))
120 continue
end

68
libdtm/db.h Normal file
View File

@@ -0,0 +1,68 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*
**
** Database Message Headers
**
**
*/
#define DBclass "DB"
#define DBsize 1024
#define DBfile "DBF"
#define DBauthor "AUTH"
#define DBscience "SCI"
#define DBtitle "TITLE"
#define DBdatatype "DT"
#define DBkeywords "KEYS"
#define DBrecsize "RS"
#define DBmatch "MATCH"
#define DBsetClass(h) DTMsetClass(h, DBclass)
#define DBcompareClass(h) DTMcompareClass(h, DBclass)
#define DBsetDB(h, s) dtm_set_char(h, DBfile, s)
#define DBgetDB(h, s, l) dtm_get_char(h, DBfile, s, l)
#define DBsetAuthor(h, s) dtm_set_char(h, DBauthor, s)
#define DBgetAuthor(h, s, l) dtm_get_char(h, DBauthor, s, l)
#define DBsetTitle(h, s) dtm_set_char(h, DBtitle, s)
#define DBgetTitle(h, s, l) dtm_get_char(h, DBtitle, s, l)
#define DBsetScience(h, s) dtm_set_char(h, DBscience, s)
#define DBgetScience(h, s, l) dtm_get_char(h, DBscience, s, l)
#define DBsetKeywords(h, s) dtm_set_char(h, DBkeywords, s)
#define DBgetKeywords(h, s, l) dtm_get_char(h, DBkeywords, s, l)
#define DBsetDatatype(h, s) dtm_set_char(h, DBdatatype, s)
#define DBgetDatatype(h, s, l) dtm_get_char(h, DBdatatype, s, l)
#define DBsetRecordSize(h, i) dtm_set_int(h, DBrecsize, i)
#define DBgetRecordSize(h, ip) dtm_get_int(h, DBrecsize, ip)
#define DBsetMatches(h, i) dtm_set_int(h, DBmatch, i)
#define DBgetMatches(h, ip) dtm_get_int(h, DBmatch, ip)

98
libdtm/debug.h Normal file
View File

@@ -0,0 +1,98 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/**********************************************************************
**
** DEBUG macro routines
**
***********************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/debug.h,v 1.3 1995/01/12 02:33:31 spowers Exp $
**
**********************************************************************/
/*
* Revision 1.1.1.1 1993/07/04 00:03:10 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:11 marca
* I think I got it now.
*
* Revision 1.8 92/04/30 20:27:05 jplevyak
* Changed Version to 2.3
*
* Revision 1.7 1991/11/15 19:42:34 jplevyak
* Removed dependancy on dtmint.h
*
* Revision 1.6 1991/10/29 22:52:43 jplevyak
* Added debugging test before printing DTMERR messages.
*
* Revision 1.5 1991/10/10 14:21:33 jplevyak
* Added new macros for DBGMSG2 DBGMSG3.
*
* Revision 1.4 91/09/26 20:13:12 jplevyak
* Changed to allow setting of debug flags at run time.
*
* Revision 1.3 91/08/15 19:10:25 sreedhar
* Changes for logical portname version
*
* Revision 1.2 1991/06/11 15:22:30 sreedhar
* disclaimer added
*
* Revision 1.1 1990/11/08 16:30:41 jefft
* Initial revision
*
*/
#ifndef DEBUG_INC
#define DEBUG_INC
#define DBGFLOW(s) if (uDTMdbg & DTM_DBG_MSG) fprintf(stderr, s)
#define DBGINT(s, i) if (uDTMdbg & DTM_DBG_MSG) fprintf(stderr, s, i)
#define DBGFLT(s, f) if (uDTMdbg & DTM_DBG_MSG) fprintf(stderr, s, f)
#define DBGSTR(s, str) if (uDTMdbg & DTM_DBG_MSG) fprintf(stderr, s, str)
#define DBGPTR(s, p) if (uDTMdbg & DTM_DBG_MSG) fprintf(stderr, s, (int)p)
/*
The new method will be to use
DBGXXX for 0 argument debugging message of class XXXS
DBGXXXN for N argument debugging messages of calss XXX including MSG
MSG is the general class
*/
#define DBGMSG(s) if (uDTMdbg & DTM_DBG_MSG) fprintf(stderr, s)
#define DBGMSG1(s, arg1 ) if (uDTMdbg & DTM_DBG_MSG) fprintf(stderr, s, arg1 )
#define DBGMSG2(s, arg1, arg2 ) if (uDTMdbg & DTM_DBG_MSG) \
fprintf(stderr, s, arg1, arg2 )
#define DBGMSG3(s, arg1, arg2, arg3 ) if (uDTMdbg & DTM_DBG_MSG) \
fprintf(stderr, s, arg1, arg2, arg3 )
#define DTMERR(x) if (uDTMdbg & DTM_DBG_MSG) fprintf( stderr, "%s\n", x )
#define DTM_DBG_MSG 0x0001
extern unsigned int uDTMdbg;
#endif /* DEBUG_INC */

223
libdtm/deccvt.c Normal file
View File

@@ -0,0 +1,223 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/deccvt.c,v 1.1.1.1 1995/01/11 00:02:58 alanb Exp $
**
**********************************************************************/
#ifdef RCSLOG
$Log: deccvt.c,v $
Revision 1.1.1.1 1995/01/11 00:02:58 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:39:34 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:30 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:10 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:12 marca
* I think I got it now.
*
* Revision 1.4 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.3 1992/04/03 18:25:50 jplevyak
* Fixed indice computation problem.
*
* Revision 1.2 1991/06/11 15:22:22 sreedhar
* diclaimer added
*
* Revision 1.1 1991/05/30 15:52:54 sreedhar
* Initial revision
*
* Revision 1.2 1990/11/08 16:48:12 jefft
* Fixed dtm_triplet and dtm_complex conversion routines. 'size' is set
* first instead of only on return.
*
* Revision 1.1 90/11/08 16:40:06 jefft
* Initial revision
*
#endif
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include "dtmint.h"
#include "debug.h"
#define swap(x,y) x ^= y; y ^= x; x ^= y
static int dtm_char(mode, buf, size)
int mode, size;
char *buf;
{
DBGFLOW("# dtm_char called.\n");
return size;
}
static int dtm_short(mode, buf, size)
int mode, size;
char *buf;
{
int nShorts, i;
DBGFLOW("# dtm_short called.\n");
nShorts = (mode == DTMLOCAL) ? (size / 2) : size;
if (buf)
for ( i = 0; i < nShorts ; i++ ) {
swap(*buf, *(buf+1));
buf += 2;
}
return ((mode == DTMLOCAL) ? (size / 2) : (size * 2));
}
static int dtm_int(mode, buf, size)
int mode, size;
char *buf;
{
int nWords, i;
DBGFLOW("# dtm_int called.\n");
nWords = (mode == DTMLOCAL) ? (size / 4) : size;
size = ((mode == DTMLOCAL) ? (size / 4) : (size * 4));
if (buf)
for ( i=0 ; i < nWords ; i++ ) {
swap( *buf, *(buf+3) );
swap( *(buf+1), *(buf+2) );
buf += 4;
}
return size;
}
static int dtm_float(mode, buf, size)
int mode, size;
char *buf;
{
int nWords, i;
DBGFLOW("# dtm_float called.\n");
nWords = (mode == DTMLOCAL) ? (size / 4) : size;
size = ((mode == DTMLOCAL) ? (size / 4) : (size * 4));
if (buf)
for ( i=0 ; i < nWords ; i++ ) {
swap( *buf, *(buf+3) );
swap( *(buf+1), *(buf+2) );
buf += 4;
}
return size;
}
static int dtm_double(mode, buf, size)
int mode, size;
char *buf;
{
int nWords, i;
DBGFLOW("# dtm_flt64 called.\n");
nWords = (mode == DTMLOCAL) ? (size / 4) : size * 2;
if (buf)
for ( i=0 ; i < nWords ; i++ ) {
swap( *buf, *(buf+3) );
swap( *(buf+1), *(buf+2) );
buf += 4;
}
return ((mode == DTMLOCAL) ? (size / 8) : (size * 8));
}
static int dtm_complex(mode, buf, size)
int mode, size;
char *buf;
{
int nWords, i;
DBGFLOW("# dtm_complex called.\n");
nWords = (mode == DTMLOCAL) ? (size / 4) : size * 2;
size = ((mode == DTMLOCAL) ? (size / 8) : (size * 8));
if (buf)
for ( i=0 ; i < nWords ; i++ ) {
swap( *buf, *(buf+3) );
swap( *(buf+1), *(buf+2) );
buf += 4;
}
return size;
}
static int dtm_triplet(mode, buf, size)
int mode, size;
char *buf;
{
int nWords, i;
DBGFLOW("# dtm_triplet called.\n");
nWords = (mode == DTMLOCAL) ? (size / 4) : size * 4;
size = ((mode == DTMLOCAL) ? (size / 16) : (size * 16));
if (buf)
for ( i=0 ; i < nWords ; i++ ) {
swap( *buf, *(buf+3) );
swap( *(buf+1), *(buf+2) );
buf += 4;
}
return size;
}
/* conversion routine function table */
int (*DTMconvertRtns[])() = {
dtm_char,
dtm_short,
dtm_int,
dtm_float,
dtm_double,
dtm_complex,
dtm_triplet
};

1834
libdtm/dtm.c Normal file

File diff suppressed because it is too large Load Diff

371
libdtm/dtm.h Normal file
View File

@@ -0,0 +1,371 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*************************************************************************
**
** dtm.h -
**
*************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/dtm.h,v 1.4 1996/02/18 23:40:11 spowers Exp $
**
**********************************************************************/
/*
* Revision 1.1.1.1 1993/07/04 00:03:11 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:15 marca
* I think I got it now.
*
* Revision 1.32 92/05/06 16:40:17 jefft
* Modified prototype on DTMaddInput
*
* Revision 1.31 1992/04/30 20:27:05 jplevyak
* Changed Version to 2.3
*
* Revision 1.30 1992/04/29 21:56:53 jplevyak
* Add prototypes for DTMgetConnectionCount and DTMaddInput. Remove
* Cray #define for VOIDPTR since they have fixed their compiler.
*
* Revision 1.29 92/03/20 21:14:40 jplevyak
* Add DTMgetPortAddr and remove DTMgetPortName
*
* Revision 1.28 1992/03/13 18:20:31 jefft
* dtm.h depended on TRUE being defined before it was included. This word
* TRUE was changed to 1 and FALSE to 0
*
* Revision 1.27 1992/02/27 23:43:34 jplevyak
* New prototype DTMgetReturnPortName.
*
* Revision 1.26 1992/02/21 13:46:12 dweber
* Fixed prototype problems in dtm_get_type.
*
* Revision 1.25 92/02/18 14:02:36 jplevyak
* Added prototype for DTMaddInPortSocket.
*
* Revision 1.24 92/01/30 19:28:24 jplevyak
* add prototypes
*
* Revision 1.23 1992/01/02 16:31:56 dweber
* Reorganized the DTM class and MSG class
*
* Revision 1.22 91/12/13 22:34:48 jefft
* Removed DTMtitle and DTMtype constants. Added dtm_(sg)et_address macros.
* Added MSG(sg)etString macros.
*
* Revision 1.21 91/12/13 15:37:55 dweber
* Fixed DTMHL bugs and re-ordered some macros for clarification
*
* Revision 1.20 91/12/12 22:55:27 jefft
* Add numbers to the comments beside the DTM errors
*
* Revision 1.19 1991/12/10 22:15:56 jefft
* fixed DTMgetAddress macro (it was calling dtm_set_char).
*
* Revision 1.18 1991/12/09 18:36:18 jplevyak
* Added support for Callback ( DTMreadReady ).
* Use arch.h as a general architecture definition header.
*
* Revision 1.17 1991/10/29 23:48:17 jefft
* move environmental variables definition from dtmnserv.h to dtm.h
*
* Revision 1.16 1991/10/16 23:23:56 jplevyak
* Added new error message and more parameters to DTMsendRoute
*
* Revision 1.15 91/10/11 20:23:31 jplevyak
* Added prototype for DTMcheckRoute,
* Changed DTMSYNC, DTMNOSYNC to DTM_SYNC, DTM_ASYNC.
*
* Revision 1.14 1991/10/10 14:23:43 jplevyak
* All prototypes are now included and tested.
*
* Revision 1.13 1991/09/26 20:13:54 jplevyak
* Added many prototypes. Moved some internal function out to dtmint.h
*
* Revision 1.12 91/09/18 15:27:54 jplevyak
* Added extern definition for DTMinit()
*
* Revision 1.11 91/09/13 17:36:05 sreedhar
* DTMSYNC, DTMNOSYNC added
*
* Revision 1.10 1991/09/13 15:31:45 jefft
* fixed DTMHL macro, it should not have taken an arguement.
*
* Revision 1.9 1991/09/11 21:09:20 jplevyak
* Fixed typeo dtm_set_type -> dtm_get_type.
*
* Revision 1.8 1991/09/10 15:06:08 jefft
* cleaned-up message class macros and added standard macros for passing
* port address (DTMsetAddress and DTMgetAddress).
*
* Revision 1.7 1991/08/15 19:10:39 sreedhar
* Changes for logical portname version
*
* Revision 1.5 1991/06/11 15:22:39 sreedhar
* disclaimer added
*
* Revision 1.4 1991/06/07 16:04:51 sreedhar
* Changes for "Sequence start" message
*
* Revision 1.3 1991/05/30 15:43:27 sreedhar
* recvDataset, sendDataset replaced by readDataset/writeDataset
*
* Revision 1.2 1990/11/16 16:04:32 jefft
* fixed typecast problem with DTMgetType
*
* Revision 1.1 90/11/08 16:31:19 jefft
* Initial revision
*
*/
#ifndef DTM_INC
#define DTM_INC
#include <sys/types.h>
#ifndef ARCH_INC
#include "arch.h"
#endif
#if defined( _ARCH_PROTO )
#define DTM_PROTOTYPES
#define DTM_PROTO(x) x
#else
#define DTM_PROTO(x) ()
#endif
/* DTM constants */
#define DTM_WAIT_TIMEOUT 30 /* Seconds */
#define DTM_MAX_HEADER 1024 /* Max. header length */
/* general macros used by other message classes */
#define dtm_set_class(h, c) (strcpy((h), (c)), strcat((h), " "))
#define dtm_compare_class(h, c) !strncmp((h), (c), strlen(c))
#define dtm_header_length(h) (strlen(h)+1)
#define dtm_set_type(h, t) dtm_set_int((h), "DT", (t))
#define dtm_get_type(h, t) ((*(t)=(int)DTM_FLOAT), \
(dtm_get_int((h), "DT",((int *)t))))
#define dtm_set_title(h, c) dtm_set_char((h), "TTL", (c))
#define dtm_get_title(h, c, l) dtm_get_char((h), "TTL", (c), (l))
#define dtm_set_address(h, c) dtm_set_char((h), "PORT", (c))
#define dtm_get_address(h, c, l) dtm_get_char((h), "PORT", (c), (l))
/* standard types supported by DTM */
typedef enum {
DTM_CHAR = 0,
DTM_SHORT,
DTM_INT,
DTM_FLOAT,
DTM_DOUBLE,
DTM_COMPLEX,
DTM_TRIPLET
} DTMTYPE;
/* DTM triplet type */
struct DTM_TRIPLET {
int tag;
float x, y, z;
};
#define DTM_DEFAULT DTM_SYNC
typedef enum {
DTM_SYNC=0,
DTM_ASYNC
} DTMqserv ;
/* Environmental variables used by DTM name server */
#define DTM_NAMESERVER "_DTM_NAMESERVER"
#define DTM_REFNAME "_DTM_REFNAME"
/* commands supported for groups */
typedef enum {
DTM_NEW = 1,
DTM_APPEND,
DTM_DELETE,
DTM_DONE
} DTMCMD;
/*
NOTE: the strings that describe the errors in DTMerr
are located in fatal.c. Any changes to this list
must be accompanied by a corresponding change there.
*/
#define DTMERROR -1
#define DTM_OK DTMNOERR
typedef enum {
DTMNOERR=0, /* no error */
DTMMEM, /* (1) Out of memory */
DTMHUH, /* (2) Unknown port definition */
DTMNOPORT, /* (3) No DTM ports available */
DTMPORTINIT, /* (4) DTM port not initialized */
DTMCALL, /* (5) calling routines in wrong order */
DTMEOF, /* (6) EOF error */
DTMSOCK, /* (7) Socket error */
DTMHOST, /* (8) That hostname is not found/bad */
DTMTIMEOUT, /* (9) Timeout waiting for connection */
DTMCCONN, /* (10) DTM cannot connect (network down?) */
DTMREAD, /* (11) error returned from system read */
DTMWRITE, /* (12) error returned from system write(v) */
DTMHEADER, /* (13) Header to long for buffer */
DTMSDS, /* (14) SDS error */
DTMSELECT, /* (15) Select call error */
DTMENV, /* (16) Environment not setup */
DTMBUFOVR, /* (17) User buffer overflow */
DTMCORPT, /* (18) Port table corrupted */
DTMBADPORT, /* (19) Port identifier is bad/corrupt/stale */
DTMBADACK, /* (20) Bad ack to internal flow control */
DTMADDR, /* (21) Bad address */
DTMSERVER /* (22) Problem communicating with the server */
} DTMerr;
typedef struct Dtm_set {
int port ;
int status ;
} Dtm_set ;
typedef struct Sock_set {
int sockfd ;
int status ;
} Sock_set ;
typedef void * VOIDPTR;
/* function definitions and extern references */
#ifdef __cplusplus
extern "C" {
#endif
extern int DTMmakeInPort DTM_PROTO((char * portname, int qservice));
extern int DTMaddInPortSocket DTM_PROTO((int port, int socket ));
extern int DTMmakeOutPort DTM_PROTO((char * portname, int qservice));
#define DTM_PORT_READY 1
#define DTM_PORT_NOT_READY 0
extern int DTMavailWrite DTM_PROTO(( int port ));
extern int DTMavailRead DTM_PROTO(( int port ));
extern int DTMbeginRead DTM_PROTO(( int port, VOIDPTR header, int size));
extern int DTMbeginWrite DTM_PROTO(( int port, VOIDPTR header, int size));
extern int DTMreadDataset DTM_PROTO(( int p, VOIDPTR ds, int size, DTMTYPE type));
extern int DTMwriteDataset DTM_PROTO(( int p, VOIDPTR ds, int size, DTMTYPE type));
extern int DTMendRead DTM_PROTO(( int port ));
extern int DTMendWrite DTM_PROTO(( int port ));
extern int DTMreadMsg DTM_PROTO(( int p, char *hdr, int hdrsize,
VOIDPTR data, int datasize, int datatype ));
extern int DTMdestroyPort DTM_PROTO(( int port));
extern char *DTMerrmsg();
extern int DTMgetPortAddr DTM_PROTO(( int port, char * addr, int length ));
extern int DTMgetReturnPortName DTM_PROTO(( int port, char *** addrs,
int * n_addrs));
extern int DTMselectRead DTM_PROTO(( Dtm_set *dtmset, int dtmnum,
Sock_set *sockset, int socknum, int period ));
extern void DTMsetGroup DTM_PROTO(( char * header, DTMCMD cmd, char * parent,
char * self ));
extern int DTMgetGroup DTM_PROTO(( char * header, DTMCMD cmd, char * parent,
char * self ));
extern int DTMsendRoute DTM_PROTO(( int fd, char * sendto_addr, int addcount,
char **add_addresses, int delcount,
char **del_addresses ));
extern int DTMcheckRoute DTM_PROTO(( int port ));
/* Not implemented Yet */
extern int DTMrecvServerMsg DTM_PROTO(( int fd, int len, void * buffer ));
extern int DTMreadReady DTM_PROTO(( int port, void (*func)() ));
extern int DTMgetConnectionCount DTM_PROTO(( int port, int * n_connects ));
/* If you do not have X included you are not likely to use this function */
typedef (*DTMfuncPtr)();
#ifdef _XtIntrinsic_h
extern int DTMaddInput DTM_PROTO(( int port, long condition,
XtInputCallbackProc proc, caddr_t client_data));
#else
extern int DTMaddInput DTM_PROTO(( int port, long condition,
DTMfuncPtr proc, caddr_t client_data));
#endif
extern DTMerr DTMerrno;
extern char *dtm_find_tag DTM_PROTO(( char * h, char * tag ));
extern void dtm_set_char DTM_PROTO(( char * h, char * tag, char * s));
extern int dtm_get_char DTM_PROTO(( char * h, char * tag,
char * destination, int length ));
extern void dtm_set_int DTM_PROTO(( char * h, char * tag, int i ));
extern int dtm_get_int DTM_PROTO(( char * h, char * tag, int *x));
extern void dtm_set_float DTM_PROTO(( char * h, char * tag, float f));
extern int dtm_get_float DTM_PROTO(( char * h, char * tag, float *f));
#ifdef __cplusplus
};
#endif
/*
* The following macros are defined for the specific DTM class. They are
* included to provide a standard framework for other classes to emulate.
*/
/*
* DTM class specific macros
*/
#define DTMclass "DTM"
#define DTMsetClass(h) dtm_set_class((h), DTMclass)
#define DTMcompareClass(h) dtm_compare_class((h), DTMclass)
#define DTMheaderLength dtm_header_length
#define DTMHL dtm_header_length
#define DTMsetAddress dtm_set_address
#define DTMgetAddress dtm_get_address
/*
* MSG class specific macros
*/
#define MSGclass "MSG"
#define MSGsetClass(h) dtm_set_class((h), MSGclass)
#define MSGcompareClass(h) dtm_compare_class((h), MSGclass)
#define MSGsetString(h, s) dtm_set_char((h), "STR", (s))
#define MSGgetString(h, s, l) dtm_get_char((h), "STR", (s), (l))
#define MSGheaderLength dtm_header_length
#define MSGHL dtm_header_length
#endif /* DTM_INC */

233
libdtm/dtmf77.c Normal file
View File

@@ -0,0 +1,233 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
#ifdef RCSLOG
$Log: dtmf77.c,v $
Revision 1.1.1.1 1995/01/11 00:02:59 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:39:40 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:31 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:11 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:16 marca
* I think I got it now.
*
* Revision 1.7 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.6 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.5 1991/11/15 23:01:21 jefft
* Added quality of service options to DTMMOP and DTMMIP
*
* Revision 1.4 1991/06/11 15:22:00 sreedhar
* disclaimer added
*
* Revision 1.3 1991/05/30 15:53:35 sreedhar
* Changes for readMsg/writeMsg internal release
*
* Revision 1.2 1991/02/01 10:41:40 jefft
* Fixed bug with DTMBR, the _cptofcd was not used correctly.
*
* Revision 1.1 90/11/08 16:31:46 jefft
* Initial revision
*
#endif
#include <stdio.h>
#include <fortran.h>
#include "dtm.h"
#ifdef DTM_PROTOTYPES
int DTMMIP(_fcd s)
#else
int DTMMIP(s)
_fcd s;
#endif
{
int len;
char portname[128];
len = _fcdlen(s);
strncpy(portname, _fcdtocp(s), len);
portname[len] = '\0';
return DTMmakeInPort(portname, DTM_DEFAULT);
}
#ifdef DTM_PROTOTYPES
int DTMMOP(_fcd s)
#else
int DTMMOP(s)
_fcd s;
#endif
{
int len;
char portname[128];
len = _fcdlen(s);
strncpy(portname, _fcdtocp(s), len);
portname[len] = '\0';
return DTMmakeOutPort(portname, DTM_DEFAULT);
}
#ifdef DTM_PROTOTYPES
int DTMGPA(int *p,_fcd s,int *len)
#else
int DTMGPA(p, s, len)
int *p, *len;
_fcd s;
#endif
{
char portaddr[128];
if (DTMgetPortAddr(*p, portaddr, sizeof portaddr) == DTMERROR)
return DTMERROR;
if (strlen(portaddr) > *len) {
strncpy(_fcdtocp(s), portaddr, *len);
return DTMERROR;
}
else {
strncpy(_fcdtocp(s), portaddr, strlen(portaddr));
return 0;
}
}
#ifdef DTM_PROTOTYPES
int DTMAR(int *p)
#else
int DTMAR(p)
int *p;
#endif
{
return DTMavailRead(*p);
}
#ifdef DTM_PROTOTYPES
int DTMBR(int *p,_fcd header,int *size)
#else
int DTMBR(p, header, size)
int *p, *size;
_fcd header;
#endif
{
return DTMbeginRead(*p, _fcdtocp(header), *size);
}
#ifdef DTM_PROTOTYPES
int DTMRD(int *p,char *ds,int *size,DTMTYPE type)
#else
int DTMRD(p, ds, size, type)
int *p, *size;
char *ds;
DTMTYPE *type;
#endif
{
return DTMreadDataset(*p, ds, *size, *type);
}
#ifdef DTM_PROTOTYPES
int DTMER(int *p)
#else
int DTMER(p)
int *p;
#endif
{
return DTMendRead(*p);
}
#ifdef DTM_PROTOTYPES
int DTMAW(int *p)
#else
int DTMAW(p)
int *p;
#endif
{
return DTMavailWrite(*p);
}
#ifdef DTM_PROTOTYPES
int DTMBW(int *p,_fcd header,int *size)
#else
int DTMBW(p, header, size)
int *p, *size;
_fcd header;
#endif
{
int len;
char buffer[DTM_MAX_HEADER];
len = _fcdlen(header);
strncpy(buffer, _fcdtocp(header), len);
buffer[len] = '\0';
return DTMbeginWrite(*p, buffer, len+1);
}
#ifdef DTM_PROTOTYPES
int DTMSD(int *p,char *ds,int *size,DTMTYPE type)
#else
int DTMSD(p, ds, size, type)
int *p, *size;
char *ds;
DTMTYPE *type;
#endif
{
return DTMwriteDataset(*p, ds, *size, *type);
}
#ifdef DTM_PROTOTYPES
int DTMEW(int *p)
#else
int DTMEW(p)
int *p;
#endif
{
return DTMendWrite(*p);
}

755
libdtm/dtminit.c Normal file
View File

@@ -0,0 +1,755 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/**********************************************************************
**
** dtminit.c - contains routines to initialize the dtm routines
** based on command line options.
**
**********************************************************************/
/*
* $Log: dtminit.c,v $
* Revision 1.4 1996/02/18 23:40:12 spowers
* PROTO -> DTM_PROTO
*
* Revision 1.3 1995/10/14 22:07:25 spowers
* Bzero and Bcopy removed...memset memcpy used instead.
*
* Revision 1.2 1995/10/13 06:33:07 spowers
* Solaris support added.
*
* Revision 1.1.1.1 1995/01/11 00:02:59 alanb
* New CVS source tree, Mosaic 2.5 beta 4
*
* Revision 2.5 1994/12/29 23:39:43 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:31 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:16 marca
* Mosaic for X version 2 distribution
*
* Revision 1.3 1993/04/18 05:51:46 marca
* Tweaks.
*
* Revision 1.2 1993/02/26 05:21:53 marca
* Unknown change.
*
* Revision 1.1 1993/01/18 21:50:18 marca
* I think I got it now.
*
* Revision 1.33 92/05/05 22:27:50 jplevyak
* Corrected X interface code.
*
* Revision 1.32 1992/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.31 1992/04/29 21:57:46 jplevyak
* Initialize the new DTMPORT structure elements used for DTMaddInput.
*
* Revision 1.30 1992/04/06 15:58:25 jplevyak
* Fixed minor problems for machines little Endian machines.
*
* Revision 1.29 92/03/20 21:14:40 jplevyak
* Remove comments about DTMgetPortName
*
* Revision 1.28 1992/03/16 20:38:36 creiman
* Added #include "arch.h"
*
* Revision 1.27 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.26 1992/02/27 23:44:07 jplevyak
* New function DTMgetRemotePortAddr.
*
* Revision 1.25 1992/02/18 14:03:16 jplevyak
* Used _ARCH_MACOS instead of macintosh.
*
* Revision 1.24 1992/01/14 19:37:50 creiman
* Removed malloc.h from mac version
*
* Revision 1.23 1992/01/14 16:31:40 creiman
* Removed mac #include
*
* Revision 1.22 1991/12/09 18:36:18 jplevyak
* Added support for Callback ( DTMreadReady ).
*
* Revision 1.21 1991/12/02 11:14:53 dweber
* Deleted DTMgetPortName function
*
* Revision 1.20 91/11/22 21:31:00 jplevyak
* Added initialization for fDiscard (fGotList and fLastWasSuccessfull...)
*
* Revision 1.19 1991/10/29 22:05:53 sreedhar
* <sys/malloc.h> for CONVEX
*
* Revision 1.18 1991/10/16 23:24:40 jplevyak
* Added new error message.
*
* Revision 1.17 1991/10/14 16:47:48 jplevyak
* Fix bug in physical port addressing.
*
* Revision 1.16 1991/10/11 20:43:55 jplevyak
* Fixed bug in dtm_get_naddr, incorrect error handling.
*
* Revision 1.15 1991/10/10 14:25:07 jplevyak
* Finished fixing naming convensions. Added code to handle multiple
* open read sockets on a single DTM socket.
*
* Revision 1.14 91/09/26 20:14:58 jplevyak
* Major reorganization. Dynamically allocate port table. Encode a
* key in the external ports to detect stale ports. Rename and
* comment functions.
*
* Revision 1.13 91/09/18 15:28:11 jplevyak
* Added some external definitions for shared functions.
*
* Revision 1.12 91/09/16 11:25:37 jplevyak
* Fix bug, use of uninitialized register variable in function
* DTMdestroyPort
*
* Revision 1.11 91/09/13 20:09:31 sreedhar
* supporting :9900, absence of env variable
*
* Revision 1.10 1991/09/13 18:57:13 sreedhar
* removed DTMinit() fn., added qservice in some places
*
* Revision 1.9 1991/08/15 18:56:19 sreedhar
* Changes for logical portname version
*
* Revision 1.7 1991/06/11 15:34:15 sreedhar
* quality of service parameter for future use
*
* Revision 1.6 1991/06/11 15:18:36 sreedhar
* disclaimer added, availwrite/seqstart flags inited.
*
* Revision 1.5 1991/06/07 16:05:21 sreedhar
* *colon = '\0' removed, it writes into user buffer
*
* Revision 1.4 1991/01/09 16:50:34 jefft
* added include sys/include.h
*
* Revision 1.3 91/01/09 14:10:04 jefft
* Now ignoring SIGPIPE signals.
*
* Revision 1.2 90/11/21 10:53:08 jefft
* Modified DTMgetPortAddr to return IP address instead of hostname.
*
* Revision 1.1 90/11/08 16:21:54 jefft
* Initial revision
*
*/
#include "arch.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifndef _ARCH_MACOS
# include <sys/signal.h>
#endif
#include <netinet/in.h>
#ifndef _ARCH_MACOS
# if defined(CONVEX) || defined(NEXT)
# include <sys/malloc.h>
# else
# include <malloc.h>
# endif
#endif
#include "dtm.h"
#include "dtmint.h"
#include "debug.h"
/*
CONTENTS
STATIC
init_port() - initialize DTM port.
grow_ports() - enlarge the DTM port table
initialize() - initialize DTM library
get_init_port() - find a new port and initialize it
set_out_port_address() - set a physical out port adress
free_port() - free the internal port structure
register_port() - register a logical port with the server
IN-LIBRARY GLOBAL
dtm_map_port_internal() - map external port ID to internal port number
dtm_map_port_external() - map internal port number to external port ID
EXTERNALLY GLOBAL
DTMmakeInPort() - make a DTM input port
DTMmakeOutPort() - make a DTM output port
DTMdestroyPort() - close and free a DTM port
DTMgetPortAddr() - returns the main port address
END CONTENTS */
#ifdef DTM_PROTOTYPES
/*
STATIC FUNCTION PROTOTYPES
*/
static int init_port DTM_PROTO((int ,int ,int ));
static int grow_ports DTM_PROTO((VOID ));
static int initialize DTM_PROTO((VOID ));
static int get_init_port DTM_PROTO((char *,int ,int ));
static int set_out_port_address DTM_PROTO((int ,S_ADDR ));
static int free_port DTM_PROTO((int ));
static int register_port DTM_PROTO((int ));
static char *dtm_addr_to_a DTM_PROTO((S_ADDR addr));
#endif
/*
STATIC FUNCTIONS
*/
/*
init_port()
Allocate and intialize port p.
*/
#ifdef DTM_PROTOTYPES
static int init_port(int port,int porttype,int qservice )
#else
static int init_port( port, porttype, qservice )
int port;
int porttype ;
int qservice ;
#endif
{
register DTMPORT *pp ;
DBGFLOW( "init_port called\n" );
/* allocate port structure */
if( (pp = DTMpt[port] = (DTMPORT *)malloc(sizeof (DTMPORT))) == NULL ) {
DTMerrno = DTMMEM;
DBGFLOW("init_port: could not allocate DTMPORT structure.");
return DTMERROR;
}
memset(pp,0,sizeof(DTMPORT));
/*
#ifdef SOLARIS
memset(pp,0,sizeof(DTMPORT));
#else
bzero( pp, sizeof( DTMPORT ) );
#endif
*/
pp->porttype = porttype ;
pp->qservice = qservice ;
pp->Xcallback_data = NULL;
pp->Xcallback = NULL;
pp->XaddInput = NULL;
/* Input port data init */
pp->in = NULL;
pp->nextToRead = NULL;
pp->callback = NULL;
/* Output port data init */
pp->out = NULL ;
pp->fLastWasSuccessfulAvailWrite = FALSE;
pp->fGotList = FALSE;
pp->fDiscard = FALSE;
return 0;
}
/*
grow_ports()
Extend the size of the port table by DTM_PORTS_GROW ports.
*/
static int grow_ports( VOID )
{
if ( ( DTMpt = (DTMPORT **) realloc( (void *) DTMpt, (DTMptCount +
DTM_PORTS_GROW) * sizeof(DTMPORT))) == NULL ) {
DTMerrno = DTMMEM;
DTMERR("initialize: insufficient memory for port table.");
return DTMERROR;
}
memset( (char *)&DTMpt[DTMptCount],0,DTM_PORTS_GROW * sizeof(DTMPORT));
/*
#ifdef SOLARIS
memset( (char *)&DTMpt[DTMptCount],0,DTM_PORTS_GROW * sizeof(DTMPORT));
#else
bzero( (char *)&DTMpt[DTMptCount], DTM_PORTS_GROW * sizeof(DTMPORT));
#endif
*/
DTMptCount += DTM_PORTS_GROW;
return DTM_OK;
}
/*
initialize()
Initailized DTM by allocating memory for dtm_discard
and DTMpt ( the port table ).
*/
static int initialize( VOID )
{
/* get the debug option flag */
if ( getenv( "DTMDEBUG" ) ) uDTMdbg = -1;
/* create discard buffer */
if ((dtm_discard = (char *)malloc(DISCARDSIZE)) == NULL) {
DTMerrno = DTMMEM;
DTMERR("initialize: insufficient memory for dicard buffer.");
return DTMERROR;
}
if ((DTMpt = (DTMPORT **)calloc(DTM_PORTS_INITIAL, sizeof(DTMPORT)))
== NULL) {
DTMerrno = DTMMEM;
DTMERR("initialize: insufficient memory for port table.");
return DTMERROR;
}
DTMptCount = DTM_PORTS_INITIAL;
#if !defined(_ARCH_MACOS) & !defined(_ARCH_MSDOS)
/* ignore SIGPIPE signals, handled by dtm_write call */
signal(SIGPIPE, SIG_IGN);
#endif
}
/*
get_init_port()
Get and initialize a new port. Setting the porttype, qservice
and key fields. Remember to build the external port
name before returning it to the user!
*/
#ifdef DTM_PROTOTYPES
static int get_init_port(char *portname,int porttype,int qservice )
#else
static int get_init_port( portname, porttype, qservice )
char *portname ;
int porttype ;
int qservice ;
#endif
{
int tries = 2;
int port ;
DBGFLOW("get_init_port called.\n");
/* check for library initialization */
if( !DTM_INITIALIZED ) CHECK_ERR( initialize());
/* find first open DTM port */
while ( tries-- ) {
for (port=0; port < DTMptCount; port+=1) {
if (DTMpt[port] == NULL) {
CHECK_ERR(init_port( port, porttype, qservice ));
strncpy( DTMpt[port]->portname, portname, (PNAMELEN - 1) );
DTMpt[ port ]->portname[ PNAMELEN - 1 ] = '\0' ;
DTMpt[ port ]->key = DTMportSequenceNumber++;
return port;
}
}
grow_ports();
}
/* we should never get here */
DTMerrno = DTMNOPORT;
return DTMERROR;
}
/*
set_out_port_address()
Set the single out port address of a DTMPORT with a physical
specification.
*/
#ifdef DTM_PROTOTYPES
static int set_out_port_address(int port,S_ADDR addr )
#else
static int set_out_port_address( port, addr )
int port;
S_ADDR addr;
#endif
{
Port aPort ;
Outport *outp ;
DBGINT( "set_out_port_address: Physical TCP portname - %x ",
ntohl( addr.sin_addr.s_addr ));
DBGINT( "%d\n", ntohs( addr.sin_port ));
aPort.portid = addr.sin_port ;
aPort.nethostid = addr.sin_addr.s_addr ;
CHECK_ERR( outp = dtm_new_out_port( &aPort ));
DTMpt[port]->out = outp ;
return DTM_OK;
}
#ifdef DTM_PROTOTYPES
static int free_port(int port )
#else
static int free_port( port )
int port;
#endif
{
Outport * outport = DTMpt[ port ]->out;
Outport * tempPort;
int returnValue = DTM_OK;
while ( outport != NULL ) {
tempPort = outport->next;
#ifdef FREE_RETURNS_INT
if ( free( outport ) != 0 ) {
DTMerrno = DTMCORPT;
returnValue = DTMERROR;
break;
}
#else
free( outport );
#endif
outport = tempPort;
}
#ifdef FREE_RETURNS_INT
if ( free( DTMpt[ port ] ) != 0 ) {
DTMerrno = DTMCORPT;
returnValue = DTMERROR;
}
#else
free( DTMpt[ port ] );
#endif
DTMpt[port] = NULL;
return DTM_OK ;
}
/*
register_port()
Attempt to register the logical port with the name server.
On failure, destroy the port.
returns: DTM_OK and DTMERROR.
*/
#ifdef DTM_PROTOTYPES
static int register_port(int port )
#else
static int register_port( port )
int port;
#endif
{
int fd ;
S_ADDR addr ;
char *naddr ;
CHECK_ERR( naddr = dtm_get_naddr( &addr, &fd ));
if(dtm_nsend_sockaddr(fd, naddr, dtm_get_refname(), DTMpt[port]->portname,
&DTMpt[ port ]->sockaddr ) < 0 ) {
DTMdestroyPort( DTMpt[port]->sockfd ) ;
DTMerrno = DTMTIMEOUT;
return DTMERROR ;
}
return DTM_OK;
}
/*
IN-LIBRARY GLOBAL FUNCTIONS
*/
/*
dtm_map_port_internal()
This function takes a pointer to a port and then validates
that port. If the validation passes, the port is converted
to the internal representation (which is an index into the
port table DTMpt).
returns: DTMERROR, DTM_OK sets error codes DTMBADPORT
*/
#ifdef DTM_PROTOTYPES
int dtm_map_port_internal( int32 port )
#else
int dtm_map_port_internal( port )
int32 port;
#endif
{
int32 thePort = port & DTM_PORT_MASK;
if ( ( thePort ) >= DTMptCount ) {
DTMerrno = DTMBADPORT;
return DTMERROR;
}
if ( DTMpt[ thePort ] == NULL ) {
DTMerrno = DTMBADPORT;
return DTMERROR;
}
if ( ( port >> DTM_PORT_KEY_SHIFT ) != DTMpt[ thePort ]->key ) {
DTMerrno = DTMBADPORT;
return DTMERROR;
}
return thePort;
}
#ifdef DTM_PROTOTYPES
void dtm_map_port_external(int32 *port )
#else
void dtm_map_port_external( port )
int32 *port;
#endif
{
*port = *port | (DTMpt[ *port ]->key << DTM_PORT_KEY_SHIFT);
}
/*
EXTERNALLY GLOBAL FUNCTIONS
*/
/*
DTMmakeInPort()
Create and initialize a new port.
portname may be a logical or a physical port.
qservice is reserved for future use.
*/
#ifdef DTM_PROTOTYPES
int DTMmakeInPort(char *portname,int qservice )
#else
int DTMmakeInPort(portname, qservice )
char *portname;
int qservice ;
#endif
{
int port;
int fLogicalName = FALSE;
DBGFLOW("DTMmakeInPort called.\n");
CHECK_ERR(port = get_init_port(portname, INPORTTYPE, qservice ));
DBGMSG2("DTMmakeInPort port %d addr %X\n", port, DTMpt[port] );
CHECK_ERR(dtm_init_sockaddr( &DTMpt[ port ]->sockaddr,
DTMpt[ port ]->portname, &fLogicalName ));
DTMpt[port]->fLogical = fLogicalName;
if ((DTMpt[port]->sockfd = dtm_socket_init( &DTMpt[port]->sockaddr,
INPORTTYPE, fLogicalName )) == DTMERROR ) {
free_port(port);
return DTMERROR ;
}
DBGMSG1( "DTMmakeInPort: sockfd = %d\n", DTMpt[ port ]->sockfd );
if( fLogicalName ) CHECK_ERR( register_port( port ));
dtm_map_port_external( &port ) ;
return port;
}
/*
DTMmakeOutPort()
Create and initialze a new port.
portname may be a logical or a physical port.
qservice is reserved for future use.
*/
#ifdef DTM_PROTOTYPES
int DTMmakeOutPort(char *portname,int qservice )
#else
int DTMmakeOutPort(portname, qservice )
char *portname;
int qservice ;
#endif
{
int port;
int fLogicalName = TRUE;
S_ADDR addr;
DBGFLOW("DTMmakeOutPort called.\n");
CHECK_ERR( (port = get_init_port( portname, OUTPORTTYPE, qservice)));
CHECK_ERR((dtm_init_sockaddr(&addr, DTMpt[port]->portname,&fLogicalName)));
DTMpt[port]->fLogical = fLogicalName;
if( !fLogicalName ) CHECK_ERR( set_out_port_address( port, addr ));
if( (DTMpt[port] -> sockfd = dtm_socket_init( &DTMpt[port] -> sockaddr,
OUTPORTTYPE, fLogicalName )) == DTMERROR ) {
DTMdestroyPort( port );
return DTMERROR ;
}
if( fLogicalName ) CHECK_ERR( register_port( port ));
dtm_map_port_external( &port ) ;
return port;
}
/*
DTMdestroyPort()
Close all connections attached to this port then free up the memory
that it uses.
returns: DTMERROR, DTM_OK
*/
#ifdef DTM_PROTOTYPES
int DTMdestroyPort(int port)
#else
int DTMdestroyPort(port)
int port;
#endif
{
reg DTMPORT *pp ;
DBGFLOW("DTMdestroyPort called.\n");
CHECK_ERR( port = dtm_map_port_internal( port ));
/* close main socket */
pp = DTMpt[port];
if (pp->sockfd != -1) {
if ( pp->XinputId ) pp->XremoveInput( pp->XinputId );
close(pp->sockfd);
}
/* close connections */
if( pp -> porttype == INPORTTYPE ) {
register Inport *pcur ;
FOR_EACH_IN_PORT( pcur, pp ) {
if( pcur->fd != DTM_NO_CONNECTION ) {
if ( pp->Xcallback ) pp->XremoveInput( pcur->XinputId );
close( pcur->fd ) ;
}
}
} else {
register Outport *pcur ;
FOR_EACH_OUT_PORT( pcur, pp ) {
if( pcur->connfd != DTM_NO_CONNECTION ) close( pcur->connfd ) ;
}
}
/* free space allocated for port */
free_port( port );
return DTM_OK;
}
/*
DTMgetPortAddr()
Copies the physical address of the port into the given
buffer up the the length.
returns: DTMERROR, DTM_OK.
BUGS: does not check the length until adding the port.
*/
#ifdef DTM_PROTOTYPES
int DTMgetPortAddr(int port,char *addr,int length)
#else
int DTMgetPortAddr(port, addr, length)
int port;
int length;
char *addr;
#endif
{
char pnum[10];
DBGFLOW("DTMgetPortAddr called.\n");
CHECK_ERR( port = dtm_map_port_internal( port ));
if (dtm_get_ipaddr(addr) == 0) {
DTMerrno = DTMHOST;
return DTMERROR;
}
sprintf(pnum, ":%d", ntohs( DTMpt[port]->sockaddr.sin_port ) );
if ( strlen( pnum ) + strlen( addr ) + 1 > length ) {
DTMerrno = DTMBUFOVR;
return DTMERROR;
}
strcat(addr, pnum);
return DTM_OK;
}
#ifdef DTM_PROTOTYPES
static char * dtm_addr_to_a(S_ADDR addr )
#else
static char * dtm_addr_to_a( addr )
S_ADDR addr;
#endif
{
static char addr_buf[32];
uint32 hnum = addr.sin_addr.s_addr;
unsigned char * p_hnum = (unsigned char *) &hnum;
sprintf(addr_buf, "%d.%d.%d.%d:%d",
p_hnum[0], p_hnum[1], p_hnum[2], p_hnum[3], ntohs( addr.sin_port ));
return addr_buf;
}
/*
DTMgetRemotePortAddr
Returns:
Pointer to a malloc'ed array of pointers to strings.
Number of strings in the array.
Up to the user to free the list.
*/
#ifdef DTM_PROTOTYPES
int DTMgetRemotePortAddr(int port,char ***addrs,int *n_addrs)
#else
int DTMgetRemotePortAddr(port, addrs, n_addrs)
int port;
char *** addrs;
int * n_addrs;
#endif
{
int size = 0;
int count = 0;
reg Outport * pcur;
reg DTMPORT * pp;
char * strings;
CHECK_ERR( port = dtm_map_port_internal( port ));
pp = DTMpt[port];
FOR_EACH_OUT_PORT( pcur, pp ) {
count++;
size += strlen( dtm_addr_to_a( pcur->sockaddr )) + 1 + 4;
}
*n_addrs = count;
*addrs = (char **) malloc( size );
if ( !*addrs ) {
DTMerrno = DTMMEM;
return DTMERROR;
}
strings = (char *) *addrs;
strings += 4 * count;
FOR_EACH_OUT_PORT( pcur, pp ) {
(*addrs)[--count] = strings;
strcpy( strings, dtm_addr_to_a( pcur->sockaddr ));
strings += strlen(strings) + 1;
}
return DTM_OK;
}

477
libdtm/dtmint.h Normal file
View File

@@ -0,0 +1,477 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/dtmint.h,v 1.5 1996/02/18 23:40:13 spowers Exp $
**
**********************************************************************/
/*
* Revision 1.2 1993/10/06 06:16:06 ebina
* Fix stupid cont annoyance
*
* Revision 1.1.1.1 1993/07/04 00:03:11 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:19 marca
* I think I got it now.
*
* Revision 1.28 92/05/05 22:27:50 jplevyak
* Corrected X interface code.
*
* Revision 1.27 1992/04/30 20:27:05 jplevyak
* Changed Version to 2.3
*
* Revision 1.26 1992/04/29 21:58:54 jplevyak
* Add new structure elements to DTMPORT to support DTMaddInput.
* Add prototypes for dtm_accept_read_connections and
* dtm_set_Xcallback
*
* Revision 1.25 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.24 1992/03/02 18:29:41 jplevyak
* Fixed bug in EAGAIN handling.
*
* Revision 1.23 1992/03/02 17:20:14 jplevyak
* Temporary back out.
*
* Revision 1.21 1992/02/28 03:40:24 jplevyak
* int/long confict fix (no diff on workstations)
* ,
*
* Revision 1.20 92/02/27 23:59:56 jplevyak
* Fixup prototype problems.
*
* Revision 1.19 1992/01/30 19:28:50 jplevyak
* Add support for c++ type external definitions.
*
* Revision 1.18 92/01/24 18:45:50 jefft
* Removed prototypes for dtm_set_<type> and dtm_get_<type>, added them to dtm.h
*
* Revision 1.17 1991/12/16 19:44:04 jefft
* Fixed bug with defining of NULL macro
*
* Revision 1.16 1991/12/09 18:36:18 jplevyak
* Added support for Callback ( DTMreadReady ).
*
* Revision 1.15 1991/11/22 21:31:37 jplevyak
* Added fDiscard to port structure. Removed prototype for dtm_get_nlist
* and dtm_check_server.
*
* Revision 1.14 1991/10/16 11:25:23 jplevyak
* ifdef around a duplicated include that was giving the SGIs trouble.
*
* Revision 1.13 1991/10/14 16:48:21 jplevyak
* Add flag in DTMPORT indicating whether or not the address is
* logical.
*
* Revision 1.12 1991/10/11 20:24:11 jplevyak
* Changed DTMSendCTSAhead default to be 0 (no chance of deadlock) as
* default.
*
* Revision 1.11 1991/10/10 14:26:16 jplevyak
* Finished fixing naming convensions. All prototypes are now included.
*
* Revision 1.10 91/09/26 20:16:46 jplevyak
* Major reorganization. Made this file compatible with dtm.h. Moved
* redundant out. Added several configuration parameters, added
* prototypes for internally global functions.
*
* Revision 1.9 91/09/18 15:28:50 jplevyak
* Added some external definitions for shared functions.
*
* Revision 1.8 91/09/13 17:37:37 sreedhar
* MAX132 instead of MAXBUFSIZE
*
* Revision 1.7 1991/08/15 19:10:53 sreedhar
* Changes for logical portname version
*
* Revision 1.6 1991/06/11 15:22:46 sreedhar
* disclaimer added
*
* Revision 1.5 1991/06/07 16:06:03 sreedhar
* Changes for sequence start message
*
* Revision 1.4 1991/05/30 15:50:58 sreedhar
* Changes for readMsg/writeMsg internal release
*
* Revision 1.3 1991/03/14 23:26:55 jefft
* removed call to dtm_fatal when errors occur.
*
* Revision 1.2 90/11/21 12:35:44 jefft
* Removed trailing comma from DTM error enum type.
*
* Revision 1.1 90/11/08 16:32:03 jefft
* Initial revision
*
*/
#ifndef DTMINT_INC
#define DTMINT_INC
#ifndef DTM_INC
#include "dtm.h"
#endif
#ifndef u_char /* it is not clear if we can count on __sys_types_h */
#include <sys/types.h>
#endif
#ifndef IPPROTO_IP
#ifdef _ARCH_MSDOS
# include <nmpcip.h>
#else
# include <netinet/in.h>
#endif
#endif
/* Added to shut up the SGI compiler which quotes ANSI regulations at
you.
*/
#ifdef DTM_PROTOTYPES
struct sockaddr;
struct timeval;
struct iovec;
#endif
#ifdef MAIN
#define global
#define INIT(x) = x
#else
#define global extern
#define INIT(x)
#endif
#define reg register
/*
MACHINE SPECIFIC #defines
*/
/*
These at least work on a 68k architecture....
*/
#ifdef _ARCH_MSDOS
typedef unsigned int uint16;
typedef unsigned long uint32;
typedef int int16;
typedef long int32;
#else /* _ARCH_MSDOS */
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef short int16;
typedef int int32;
#endif /* _ARCH_MSDOS */
#ifdef SUN
#define BSD
#endif
#ifdef CRAY
# define STDINT(x) (x <<= 32)
# define LOCALINT(x) (x >>= 32)
#else
# define STDINT(x) x = htonl(x)
# define LOCALINT(x) x = ntohl(x)
#endif
/*
The SGI compiler does not like to see true floats in prototypes
*/
#ifdef SGI
#define FLOAT double
#else
#define FLOAT float
#endif
#if defined(BSD) && !defined(NEXT) && !defined(SOLARIS)
#define FREE_RETURNS_INT
#endif
#define DTM_VERSION "2.3"
#if defined(_STDC_) || defined(__STDC__)
#define VOID void
#else
#define VOID
#endif
/*
GENERIC #defines
*/
#ifdef _ARCH_MSDOS
#define CHECK_ERR(X) if (((long)(X)) == DTMERROR) return DTMERROR
#else
#define CHECK_ERR(X) if (((int)(X)) == DTMERROR) return DTMERROR
#endif
#ifndef FALSE
# define FALSE 0
# define TRUE !FALSE
#endif
#define DTM_BUFF_SIZE 32768
#define DTM_REFUSE_LIMIT 120
#define DTM_NO_CONNECTION -1
/*
Perhaps we should distinguish these
*/
#define DTM_CTS 0
#define DTM_RTS 0
#define DTM_EOT 0
#if !defined(_ARCH_MACOS) && !defined(_ARCH_MSDOS)
# define DISCARDSIZE 32768
#else
# define DISCARDSIZE 4096
#endif
#define DTMSTD 0
#define DTMLOCAL 1
#define INPORTTYPE 0 /* input port type */
#define OUTPORTTYPE 1 /* output port type */
#define PNAMELEN 64 /* max length of portname */
#define REFNAMELEN 32 /* max length of reference name given by
nameserver.
*/
#define MAX132 132 /* max space of 132 */
#define SEP " " /* blank as separator */
#define COLON ":" /* colon as separator */
#ifndef NULL
# if defined( _STDC_ ) || defined( __STDC__ )
# define NULL ((void *)0)
# else
# define NULL 0
# endif
#endif
#define FOR_EACH_OUT_PORT( pcur, pp ) \
for ( pcur = pp->out; pcur != NULL ; pcur = pcur->next )
#define FOR_EACH_IN_PORT( inp, pp ) \
for ( inp = pp->in; inp != NULL ; inp = inp->next )
/*
PORT STRUCTURES
*/
typedef struct sockaddr_in S_ADDR;
typedef struct Port
{
uint32 nethostid ;
uint16 portid ;
} Port ;
typedef struct Outport
{
S_ADDR sockaddr ; /* Socket family, netid/hostid, portid */
int32 connfd ; /* connection fd */
int availwrite ; /* port availability for write */
int seqstart ; /* "Sequence start" message sent or not */
struct Outport * next; /* link to next outport */
} Outport ;
#define DTM_NEW_DATASET -1
typedef struct Inport {
int32 fd; /* connection fds */
int32 blocklen; /* records no. of bytes read */
/*
Perhaps we should make these sequence, enums... that
would allow > < comparisions
*/
int fCTSsent; /* CTS already sent */
int fGotHeader; /* Already got the header */
#ifdef _XtIntrinsic_h
#ifdef __STDC__
#if sizeof( XtInputId ) != sizeof( int )
Balk - The following structure definition needs to be repaired
to restore the assertion
#endif
#endif
XtInputId XinputId;
#else
int XinputId;
#endif
struct Inport * next;
} Inport;
typedef struct
{
S_ADDR sockaddr ;
/* Socket family, netid/hostid, portid */
int32 sockfd ; /* Main socket of port
Outport - UDP socket
Inport - TCP socket
*/
#ifdef _XtIntrinsic_h
XtInputId XinputId;
#else
int XinputId;
#endif
int fLogical;
char portname[ PNAMELEN ] ; /* Logical portname */
int porttype ; /* Input or Output port */
int qservice ; /* Quality of service - actually qserv enum */
int32 key ; /* unique value used to catch stale port access */
char * Xcallback_data;
void (*Xcallback)();
#ifdef _XtIntrinsic_h
XtInputCallbackProc XaddInput;
XtInputCallbackProc XremoveInput;
#else
int (*XaddInput)();
int (*XremoveInput)();
#endif
/* Input port specific data */
Inport *in;
Inport *nextToRead;
void (*callback)();
/* Output port specific data */
Outport *out ; /* Linked list of Out port specific structures */
/* If the last action on this port was a successful
availWrite, then when we do a beginWrite, we
will NOT check for new routing information */
int fLastWasSuccessfulAvailWrite;
int fGotList; /* initially false, TRUE after any list is read */
int fDiscard; /* initially false, TRUE means /dev/null output */
} DTMPORT ;
/*
GLOBAL VARIABLES
*/
#define DTM_INITIALIZED (DTMpt != NULL)
#define DTM_PORTS_INITIAL 20
#define DTM_PORTS_GROW 20
global DTMPORT **DTMpt INIT( NULL );
global int32 DTMptCount INIT( 0 );
global int32 DTMportSequenceNumber INIT( 1 );
#ifdef _ARCH_MSDOS
#include <errno.h>
#else
extern int errno;
#endif
global DTMerr DTMerrno INIT( DTM_OK );
global char * dtm_discard INIT( NULL );
extern int (*DTMconvertRtns[]) DTM_PROTO(( int, VOIDPTR, int ));
/* global options */
/*
NOTE: setting this value to anything other than 0 can result
in deadlock. However, in correctly configure graphs, this should
not occure and performance is considerably better with values > 0.
DO NOT SET THIS VALUE TO SOME ARBITRARILY LARGE NUMBER.
*/
global int DTMSendCTSAhead INIT( 0 );
/*
FUNCTION PROTOTYPES
*/
#ifdef __cplusplus
extern "C" {
#endif
#define NOT_LOGICAL_NAME FALSE
#define LOGICAL_NAME TRUE
extern char * dtm_get_refname DTM_PROTO(( VOID ));
extern char * dtm_get_refname DTM_PROTO(( VOID ));
extern int dtm_nsend_ackroute DTM_PROTO(( char * portname ));
extern int dtm_nsend_sockaddr DTM_PROTO(( int fd, char * sendto_addr,
char * refname, char * portname, S_ADDR * sockaddr ));
extern Outport * dtm_new_out_port DTM_PROTO(( Port * port ));
#define DTM_PORT_MASK 0xFFFF
#define DTM_PORT_KEY_SHIFT 16
extern int dtm_map_port_internal DTM_PROTO(( int32 port ));
extern void dtm_map_port_external DTM_PROTO(( int32 * port ));
#define DTM_WAIT TRUE
#define DTM_DONT_WAIT FALSE
extern int dtm_check_server DTM_PROTO(( DTMPORT *pp, int fWait ));
extern int dtm_send_ack DTM_PROTO(( int fd, int32 ack ));
extern int dtm_recv_ack DTM_PROTO(( int fd, int32 * ack ));
extern int dtm_destroy_in_port DTM_PROTO(( Inport * inp, DTMPORT * pp ));
extern int dtm_writev_buffer DTM_PROTO(( int fd, struct iovec *iov,
int32 iovlen, int32 iovsize,
struct sockaddr * addr, int addrlen ));
extern int dtm_read_buffer DTM_PROTO(( int d, int32 * blocklen,
void * buffer, int length ));
extern int dtm_recv_header DTM_PROTO((int fd , void * header,
int length));
extern int dtm_read_header DTM_PROTO((int fd , void * header,
int length));
extern int dtm_parse_ipaddr DTM_PROTO(( char * source,
unsigned long * dest ));
extern int dtm_quick_select DTM_PROTO(( int socket, int32 * count ));
extern int dtm_select DTM_PROTO(( int fd, int32 * count,
int32 time ));
extern int dtm_accept DTM_PROTO(( int fd, S_ADDR * sn,
struct timeval * timeout ));
extern int dtm_connect DTM_PROTO(( S_ADDR * sn, int * sockret ));
extern int dtm_quick_connect DTM_PROTO(( S_ADDR * sn, int * sockret ));
extern int dmt_end_connect DTM_PROTO(( int32 socket ));
extern unsigned long dtm_get_ipaddr DTM_PROTO(( char * ipaddrstr ));
extern int dtm_socket_init DTM_PROTO(( S_ADDR * sockaddr, int porttype,
int fLogicalName ));
extern int dtm_init_sockaddr DTM_PROTO(( S_ADDR * sockaddr,
char * portname,
int * pfLogicalName ));
extern int dtm_ninit DTM_PROTO(( void ));
extern char * dtm_get_naddr DTM_PROTO(( S_ADDR * addr, int * sockfd ));
extern void dtm_version DTM_PROTO(( void ));
extern int dtm_sigio DTM_PROTO(( int ));
extern char * dtm_find_tag DTM_PROTO(( char *, char *));
extern int dtm_accept_read_connections DTM_PROTO(( DTMPORT *pp,int fWait ));
extern void dtm_set_Xcallback DTM_PROTO(( DTMPORT *pp, Inport * inp ));
#ifdef _XtIntrinsic_h
extern void dtm_handle_in DTM_PROTO(( caddr_t client_data,
int * fd, XtInputId * in ));
#else
extern void dtm_handle_in DTM_PROTO(( caddr_t client_data,
int * fd, void * in ));
#endif
#ifdef __cplusplus
};
#endif
#endif /* DTMINT_INC */

358
libdtm/dtmmisc.c Normal file
View File

@@ -0,0 +1,358 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/dtmmisc.c,v 1.2 1995/10/13 06:33:11 spowers Exp $
**
**********************************************************************/
/*
#ifdef RCSLOG
$Log: dtmmisc.c,v $
Revision 1.2 1995/10/13 06:33:11 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:02:59 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:39:48 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:31 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:11 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:20 marca
* I think I got it now.
*
* Revision 1.8 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.7 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.6 1991/10/10 14:29:30 jplevyak
* Included "string.h" instead of declaring externs atoi atof().
*
* Revision 1.5 91/09/26 20:24:21 jplevyak
* Added debug.h as include file.
*
* Revision 1.4 1991/06/11 15:19:36 sreedhar
* disclaimer added
*
* Revision 1.3 1991/05/14 14:13:48 jefft
* modified dtm_set_char to delimit string with "'"
*
* Revision 1.2 1991/04/29 16:44:56 jefft
* increased length of num array in dtm_set_float
*
* Revision 1.1 90/11/08 16:32:18 jefft
* Initial revision
*
#endif
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifdef _ARCH_MSDOS
#include <nmpcip.h>
#else
#include <netdb.h>
#include <netinet/in.h>
#endif
#include "dtmint.h"
#include "debug.h"
#ifndef min
#define min(a, b) (((a) <= (b)) ? (a) : (b))
#endif
/*************************************************************************
**
** Header Utilitiy Functions
**
**************************************************************************/
#ifdef DTM_PROTOTYPES
void dtm_set_char(char *h,char *tag,char *s)
#else
void dtm_set_char(h, tag, s)
char *h, *tag, *s;
#endif
{
strcat(h, tag); strcat(h, " '");
strcat(h, s); strcat(h, "' ");
}
#ifdef DTM_PROTOTYPES
void dtm_set_int(char *h,char *tag,int x)
#else
void dtm_set_int(h, tag, x)
char *h, *tag;
int x;
#endif
{
char num[8];
strcat(h, tag); strcat(h, " ");
sprintf(num, "%d ", x);
strcat(h, num);
}
#ifdef DTM_PROTOTYPES
void dtm_set_float( char * h, char * tag, float x)
#else
void dtm_set_float(h, tag, x)
char *h, *tag;
float x;
#endif
{
char num[20];
strcat(h, tag); strcat(h, " ");
sprintf(num, "%f ", x);
strcat(h, num);
}
#ifdef DTM_PROTOTYPES
char *dtm_find_tag(char *h,char *tag)
#else
char *dtm_find_tag(h, tag)
char *h, *tag;
#endif
{
int len;
len = strlen(tag);
while ((h = strchr(h, ' ')) != NULL) {
h++;
if (!strncmp(h, tag, len) && *(h+len) == ' ')
return h;
}
return NULL;
}
#ifdef DTM_PROTOTYPES
int dtm_get_char(char *h,char *tag,char *s,int l)
#else
int dtm_get_char(h, tag, s, l)
char *h, *tag, *s;
int l;
#endif
{
/* set NULL string incase tag does not exist */
*s = '\0';
/* decrement length to save space for final NUL */
l -= 1;
/* no tag return error */
if ((h = dtm_find_tag(h, tag)) == NULL)
return DTMERROR;
/* no field available, return error */
if ((h = strchr(h, '\'')) == NULL)
return DTMERROR;
else
h += 1;
if ((tag = strchr(h, '\'')) == NULL) {
strncpy(s, h, min(strlen(h)+1, l));
*(s+min(strlen(h)+1, l)) = '\0';
}
else {
strncpy(s, h, min(tag-h, l));
*(s+min(tag-h, l)) = '\0';
}
return 0;
}
#ifdef DTM_PROTOTYPES
int dtm_get_int(char *h,char *tag,int *x)
#else
int dtm_get_int(h, tag, x)
char *h, *tag;
int *x;
#endif
{
/* no tag return error */
if ((h = dtm_find_tag(h, tag)) == NULL)
return DTMERROR;
/* no field available, return error */
if ((h = strchr(h, ' ')) == NULL)
return DTMERROR;
else
h += 1;
*x = atoi(h);
return 0;
}
#ifdef DTM_PROTOTYPES
int dtm_get_float(char *h,char *tag,float *x)
#else
int dtm_get_float(h, tag, x)
char *h, *tag;
float *x;
#endif
{
/* no tag return error */
if ((h = dtm_find_tag(h, tag)) == NULL)
return DTMERROR;
/* no field available, return error */
if ((h = strchr(h, ' ')) == NULL)
return DTMERROR;
else
h += 1;
*x = atof(h);
return 0;
}
#ifdef NONO
#ifdef DTM_PROTOTYPES
void DTMsetType(char *h,DTMTYPE type)
#else
void DTMsetType(h, type)
char *h;
DTMTYPE type;
#endif
{
char num[8];
strcat(h, DTMtype); strcat(h, " ");
sprintf(num, "%d ", type);
strcat(h, num);
}
#ifdef DTM_PROTOTYPES
DTMTYPE DTMgetType(char *h)
#else
DTMTYPE DTMgetType(h)
char *h;
#endif
{
char *f;
if ((f = dtm_find_tag(h, DTMtype)) != NULL)
return (DTMTYPE)atoi(f);
else
return DTM_FLOAT;
}
#ifdef DTM_PROTOTYPES
void DTMsetGroup(char *h,DTMCMD cmd,char *parent,char *self)
#else
void DTMsetGroup(h, cmd, parent, self)
char *h, *parent, *self;
DTMCMD cmd;
#endif
{
char num[12];
strcat(h, "GRP ");
sprintf(num, "%d ", (int)cmd);
strcat(h, num);
if (parent != NULL)
strcat(h, parent);
strcat(h, " ");
if (self != NULL)
strcat(h, self);
strcat(h, " ");
}
#ifdef DTM_PROTOTYPES
int DTMgetGroup(char *h,DTMCMD cmd,char *parent,char *self)
#else
int DTMgetGroup(h, cmd, parent, self)
char *h, *parent, *self;
DTMCMD *cmd;
#endif
{
int len;
*self = *parent = '\0';
if ((h = dtm_find_tag(h, "GRP")) == NULL)
return DTMERROR;
h = strchr(h, ' ')+1;
/* get DTM command */
*cmd = (DTMCMD)atoi(h);
h = strchr(h, ' ')+1;
/* get parent name */
if (*h != ' ') {
len = strchr(h, ' ')-h;
strncpy(parent, h, len);
*(parent+len) = '\0';
}
else
*parent = '\0';
h = strchr(h, ' ')+1;
/* get self name */
if (*h != ' ') {
len = strchr(h, ' ')-h;
strncpy(self, h, len);
*(self+len) = '\0';
}
else
*self = '\0';
return 1;
}
#endif

325
libdtm/dtmnserv.c Normal file
View File

@@ -0,0 +1,325 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/dtmnserv.c,v 1.4 1996/02/18 23:40:14 spowers Exp $
**
**********************************************************************/
/*
#ifdef RCSLOG
$Log: dtmnserv.c,v $
Revision 1.4 1996/02/18 23:40:14 spowers
PROTO -> DTM_PROTO
Revision 1.3 1995/10/14 22:07:27 spowers
Bzero and Bcopy removed...memset memcpy used instead.
Revision 1.2 1995/10/13 06:33:12 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:02:59 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:39:50 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:31 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:11 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:22 marca
* I think I got it now.
*
* Revision 1.19 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
#endif
*/
/*
Purpose : Functions to interact with name server.
*/
#include "arch.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef _ARCH_MSDOS
#include <nmpcip.h>
#include "uio.h"
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/uio.h>
#endif
#if !defined _ARCH_MACOS & !defined NEXT
# ifdef CONVEX
# include <sys/malloc.h>
# else
# include <malloc.h>
# endif
#endif
#include "dtmint.h"
#include "dtmnserv.h"
#include <stdio.h>
#include "debug.h"
/*
STATIC FUNCTION PROTOTYPES
*/
static int init_refname DTM_PROTO(( char *refname, int len ));
static void del_nlist DTM_PROTO(( DTMPORT *pp, int count ));
static void add_nlist DTM_PROTO(( DTMPORT *pp, int count ));
/*
Function to initialise self's reference name from environment
variable passed by nameserver.
Return value : 0 on success,
-1 on error.
Notes : Environment variable - DTM_REFNAME
*/
#ifdef DTM_PROTOTYPES
static int init_refname(char *refname,int len )
#else
static int init_refname( refname, len )
char * refname;
int len;
#endif
{
char *p ;
DBGFLOW( "init_refname called\n" );
if( (p = getenv( DTM_REFNAME )) == NULL )
{
DTMerrno = DTMENV ;
DTMERR( "init_refname: Env not setup" );
return DTMERROR ;
}
strncpy( refname, p, (len - 1) );
refname[ len - 1 ] = '\0' ;
DBGINT( "init_refname: user process reference name is %s\n",
refname );
return DTM_OK;
}
/*
Function to return process reference name.
*/
#ifdef DTM_PROTOTYPES
char *dtm_get_refname(void )
#else
char *dtm_get_refname()
#endif
{
static char refname[ REFNAMELEN ] = {0};
if( refname[0] == '\0' ) init_refname( refname, REFNAMELEN ) ;
return refname ;
}
/*
I am not sure that this function still works, so it is
not in the header
*/
#ifdef DTM_PROTOTYPES
void dtm_display_buf(Outport *outp,char *portname )
#else
void dtm_display_buf( outp, portname )
Outport *outp ;
char *portname ;
#endif
{
DBGINT( "dtm_display_buf: Logical port %s\n", portname );
while ( outp != NULL );
{
DBGINT( "dtm_display_buf: Nethostid = %x\n",
ntohl( outp -> sockaddr.sin_addr.s_addr) );
DBGINT( "dtm_display_buf: Portid = %d\n",
ntohs( outp -> sockaddr.sin_port) );
outp = outp->next;
}
}
/*
dtm_new_out_port()
Allocate and initialize a new outport.
*/
#ifdef DTM_PROTOTYPES
Outport * dtm_new_out_port(Port *port )
#else
Outport * dtm_new_out_port( port )
Port * port;
#endif
{
Outport * p;
if ( (p = (Outport *) malloc( sizeof( Outport ))) == NULL ) {
DTMerrno = DTMMEM;
return (Outport *)DTMERROR;
}
memset(p,0,sizeof(Outport));
/*
#ifdef SOLARIS
memset(p,0,sizeof(Outport));
#else
bzero( p, sizeof( Outport ));
#endif
*/
DBGFLOW( "dtm_new_out_port called\n" );
p -> sockaddr.sin_family = AF_INET ;
p -> sockaddr.sin_port = port -> portid ;
p -> sockaddr.sin_addr.s_addr = port -> nethostid ;
p -> connfd = DTM_NO_CONNECTION ;
p -> availwrite = FALSE ;
p -> seqstart = FALSE ;
return p;
}
#ifdef DTM_PROTOTYPES
static void del_nlist(DTMPORT *pp,int count )
#else
static void del_nlist( pp, count )
DTMPORT *pp;
int count;
#endif
{
Outport * outp, * outpLast, * outpNext;
Port port;
while( count-- ) {
port.nethostid = inet_addr( strtok( NULL, COLON) );
port.portid = (unsigned short)atol( strtok( NULL, SEP));
outpLast = NULL;
for ( outp = pp->out ; outp != NULL ; outp = outpNext ) {
outpNext = outp->next;
if ((outp->sockaddr.sin_port == port.portid ) &&
(outp-> sockaddr.sin_addr.s_addr == port.nethostid)) {
if ( outpLast==NULL ) pp->out = outp->next;
else outpLast->next = outp->next;
free( outp );
}
else outpLast = outp;
}
}
}
#ifdef DTM_PROTOTYPES
static void add_nlist(DTMPORT *pp,int count )
#else
static void add_nlist( pp, count )
DTMPORT *pp;
int count;
#endif
{
Port port;
Outport * outp;
while( count-- ) {
port.nethostid = inet_addr( strtok(NULL, COLON));
port.portid = (unsigned short)atol( strtok( NULL, SEP));
outp = dtm_new_out_port( &port );
if ( pp->out != NULL ) outp->next = pp->out;
pp->out = outp;
}
}
/*
dtm_check_server()
Service messages from the server, including the new route list.
We only wait if we were asked to and we have not gotten ANY list yet.
Returns the number of added ports.
*/
#ifdef DTM_PROTOTYPES
int dtm_check_server( DTMPORT *pp,int fWait )
#else
int dtm_check_server( pp, fWait )
DTMPORT *pp;
int fWait;
#endif
{
char *portname = pp->portname;
int32 tmp;
char mbuf[MAX132];
int addcount;
/* If it is not a logical port is is not listed with the server */
if ( !pp->fLogical ) return DTM_OK;
/* Check for new or first routing list */
fWait = fWait && (pp->out == NULL);
if( dtm_select( pp->sockfd, &tmp, !fWait ? 0:DTM_WAIT_TIMEOUT ) ==FALSE){
if ( !fWait ) return 0;
DBGFLOW( "dtm_get_nlist: timeout waiting on server\n") ;
DTMerrno = DTMTIMEOUT;
return DTMERROR;
}
while ( dtm_select( pp->sockfd, &tmp, 0 ) ) {
/* Get the new server message */
if( dtm_recv_header( pp->sockfd, mbuf, MAX132 ) == DTMERROR ) {
DBGFLOW( "dtm_get_nlist: No Mport msg from name server\n") ;
DTMerrno = DTMPORTINIT;
return DTMERROR;
}
/* Ack the route message */
#if 0
CHECK_ERR( dtm_nsend_ackroute( portname ));
#endif
/* Process the routing message */
{
char * msg_type = strtok( mbuf, SEP );
if (!strcmp( msg_type, MROUTEID)) {
int delcount = atoi( strtok( NULL, SEP ));
DBGMSG1( "dtm_get_nlist: got routing: %s\n", mbuf ) ;
addcount = atoi( strtok( NULL, SEP ));
del_nlist( pp, delcount );
add_nlist( pp, addcount );
pp->fGotList = TRUE;
return addcount;
} else if ( !strcmp( msg_type, MDISCARD ) ) {
pp->fDiscard = atoi( strtok( NULL, SEP));
}
}
}
return 0;
}

75
libdtm/dtmnserv.h Normal file
View File

@@ -0,0 +1,75 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/dtmnserv.h,v 1.3 1995/01/12 02:33:34 spowers Exp $
**
**********************************************************************/
/*
* Revision 1.1.1.1 1993/07/04 00:03:12 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:23 marca
* I think I got it now.
*
* Revision 1.5 92/04/30 20:27:05 jplevyak
* Changed Version to 2.3
*
*/
/*
Purpose : Header file for name server interaction
Notes :
Message format:
Portid - nethostid:portid
Header - opcode
DTM to nameserver
Send message length.
Mreg - Header refname portname Portid
Mackroute - Header refname portname
Nameserver to DTM
Send message length.
Mroute - Header delcount addcount Portid1 Portid2 ...
Ports to be deleted should be before ports to be added.
Nethostid is in dotted decimal notation of internet.
*/
#define MREGID "REGISTER"
#define MREG "%s %s %s %s:%d"
#define MROUTEID "ROUTE"
#define MROUTE "%s %d %d" /* %s:%d %s:%d .... */
#define MACKROUTEID "ROUTE_ACK"
#define MACKROUTE "%s %s %s"
#define MDISCARDID "DISCARD"
#define MDISCARD "%s %d"

60
libdtm/exec.h Normal file
View File

@@ -0,0 +1,60 @@
#define EXECclass "EXEC"
#define EXECid "ID"
#define EXECtime "TIME"
#define EXECaddress "ADDRESS"
#define EXECauth "AUTHENTICATION"
#define EXECtype "TYPE"
#define EXEC_HOST_STATUS_QUERY 1
#define EXEC_HOST_STATUS_RETURN 2
#define EXEC_EXECUTE 3
#define EXEC_EXECUTE_RETURN 4
#define EXEC_PROC_STATUS_QUERY 5
#define EXEC_PROC_STATUS_RETURN 6
#define EXEC_FILE_PUT 7
#define EXEC_FILE_GET 8
#define EXEC_HS_LOAD1 "LOAD1"
#define EXEC_HS_LOAD5 "LOAD5"
#define EXEC_HS_LOAD15 "LOAD15"
#define EXEC_HS_NUM_USERS "NUMUSERS"
#define EXECsetClass(h) dtm_set_class(h,EXECclass)
#define EXECcompareClass(h) dtm_compare_class(h,EXECclass)
#define EXECsetID(h,s) dtm_set_char(h,EXECid,s)
#define EXECgetID(h,s,l) dtm_get_char(h,EXECid,s,l)
#define EXECsetAddress(h,s) dtm_set_char(h,EXECaddress,s)
#define EXECgetAddress(h,s,l) dtm_get_char(h,EXECaddress,s,l)
#define EXECsetTimeStamp(h,s) dtm_set_char(h,EXECtime,s)
#define EXECgetTimeStamp(h,s,l) dtm_get_char(h,EXECtime,s,l)
#define EXECsetAuthentication(h,s) dtm_set_char(h,EXECauth,s)
#define EXECgetAuthentication(h,s,l) dtm_get_char(h,EXECauth,s,l)
#define EXECsetType(h,i) dtm_set_int(h,EXECtype,i)
#define EXECgetType(h,i) dtm_get_int(h,EXECtype,i)
/*************************/
/* if type is EXEC_HOST_STATUS_RETURN */
#define EXECsetLoad1(h,f) dtm_set_float(h,EXEC_HS_LOAD1,f)
#define EXECgetLoad1(h,f) dtm_get_float(h,EXEC_HS_LOAD1,f)
#define EXECsetLoad5(h,f) dtm_set_float(h,EXEC_HS_LOAD5,f)
#define EXECgetLoad5(h,f) dtm_get_float(h,EXEC_HS_LOAD5,f)
#define EXECsetLoad15(h,f) dtm_set_float(h,EXEC_HS_LOAD15,f)
#define EXECgetLoad15(h,f) dtm_get_float(h,EXEC_HS_LOAD15,f)
#define EXECsetNumUsers(h,i) dtm_set_int(h,EXEC_HS_NUM_USERS,i)
#define EXECgetNumUsers(h,i) dtm_get_int(h,EXEC_HS_NUM_USERS,i)
/*************************/

151
libdtm/fatal.c Normal file
View File

@@ -0,0 +1,151 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/fatal.c,v 1.2 1995/10/13 06:33:14 spowers Exp $
**
**********************************************************************/
/*
#ifdef RCSLOG
$Log: fatal.c,v $
Revision 1.2 1995/10/13 06:33:14 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:03:00 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:39:56 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:32 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:12 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:25 marca
* I think I got it now.
*
* Revision 1.8 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.7 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.6 1991/10/16 23:25:00 jplevyak
* Added new error message.
*
* Revision 1.5 1991/10/10 14:31:48 jplevyak
* Added new error messages for "bad ack to internal flow control" and
* "Bad address". These may not end up as user error messages.
*
* Revision 1.4 91/09/26 20:19:14 jplevyak
* Added several new errors, changed the DTMerrmsg function to detect
* and return 'unknown error:' errors. Generally encorporated the
* good features of sherr (from the libtest directory).
*
* Revision 1.3 91/06/25 20:13:28 creiman
* Removed varargs and dtm_fatal.
*
* Revision 1.2 1991/06/11 15:19:57 sreedhar
* disclaimer added
*
* Revision 1.1 1990/11/08 16:33:22 jefft
* Initial revision
*
#endif
*/
#include <stdio.h>
#include <sys/types.h>
#ifdef _ARCH_MSDOS
#include <nmpcip.h>
#else
#include <netinet/in.h>
#endif
#include "dtmint.h"
static char *err_msg[] = {
"No error",
"Out of memory - can not create port",
"Invalid port name - should be 'hostname:tcp port'",
"Out of DTM ports - 256 ports max",
"Couldn't initialize port",
"DTM routines called in wrong order",
"Encounted EOF",
"Error creating socket",
"Bad hostname",
"Timeout waiting for connection",
"Couldn't connect",
"DTM read error",
"DTM write error",
"DTM header to long for buffer",
"SDS error",
"Select call error",
"Environment not setup",
"User buffer overflow",
"Port table corrupted",
"Bad port supplied to library",
"Bad ack to internal flow control",
"Bad address",
"Problem communicating with server"
};
#ifdef DTM_PROTOTYPES
void dtm_version(void )
#else
void dtm_version()
#endif
{
fprintf(stderr, "\nDTMlib version %s.\n", DTM_VERSION);
}
#ifdef DTM_PROTOTYPES
char *DTMerrmsg(int quiet)
#else
char *DTMerrmsg(quiet)
int quiet;
#endif
{
char * strUnknown = "unknown error: %d";
char strOut[60];
char * strErr;
if ( DTMerrno < (sizeof(err_msg)/sizeof(char *)))
strErr = err_msg[(int)DTMerrno];
else {
sprintf( strOut, strUnknown, DTMerrno);
strErr = strOut;
}
if (!quiet)
fprintf(stderr, "\nDTMerrno = %d: %s\n", DTMerrno,
strErr);
return strErr;
}

72
libdtm/linux-uio.h Normal file
View File

@@ -0,0 +1,72 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
#ifndef UIO_H
#define UIO_H
#include <sys/types.h>
struct iovec {
caddr_t iov_base;
long int iov_len;
};
struct uio {
struct iovec *uio_iov;
long int uio_iovcnt;
off_t uio_offset;
long int uio_segflg;
short uio_fmode;
int uio_resid;
};
struct msghdr {
caddr_t msg_name; /* optional address */
long int msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter/gather array */
long int msg_iovlen; /* # elements in msg_iov */
caddr_t msg_accrights; /* access rights sent/received */
long int msg_accrightslen;
};
#ifndef EFAULT
#define EFAULT 14 /* for UNIX compability */
#endif
enum uio_rw { UIO_READ, UIO_WRITE };
/*
* Segment flag values (should be enum).
*/
#define UIO_USERSPACE 0 /* from user data space */
#define UIO_SYSSPACE 1 /* from system space */
#define UIO_USERISPACE 2 /* from user I space */
#if defined(__STDC__) | defined (_STDC_)
extern long int readv(int ,struct iovec *,int );
extern long int writev(int ,struct iovec *,int );
extern long int recvmsg(int ,struct msghdr *,int );
extern long int sendmsg(int ,struct msghdr *,int );
#endif /* defined(__STDC__) */
#endif /* UIO_H */

0
libdtm/make.depend Normal file
View File

212
libdtm/mdd.c Normal file
View File

@@ -0,0 +1,212 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/************************************************************************
**
** mdd.c - Multi-Dimensional Data set routines
**
*************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/mdd.c,v 1.2 1995/10/13 06:33:17 spowers Exp $
**
**********************************************************************/
/*
#ifdef RCSLOG
$Log: mdd.c,v $
Revision 1.2 1995/10/13 06:33:17 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:03:00 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:40:02 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:32 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:12 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:29 marca
* I think I got it now.
*
* Revision 1.5 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.4 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.3 1991/09/26 20:24:51 jplevyak
* removed atoi() and atof() in favor of <stdlib.h>.
*
* Revision 1.2 1991/06/11 15:22:06 sreedhar
* disclaimer added
*
* Revision 1.1 1990/11/08 16:37:13 jefft
* Initial revision
*
#endif
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "dtmint.h"
#include "mdd.h"
#ifdef DTM_PROTOTYPES
void MDDsetDimensions(char *h,int rank,int *dims)
#else
void MDDsetDimensions(h, rank, dims)
char *h;
int rank, *dims;
#endif
{
char num[8];
int i;
sprintf(num, "%d ", rank);
strcat(h, MDDdims); strcat(h, " ");
strcat(h, num);
for (i=0; i<rank; i+=1) {
sprintf(num, "%d ", dims[i]);
strcat(h, num);
}
}
#ifdef DTM_PROTOTYPES
int MDDgetDimensions(char *h,int *rank,int *dims,int len)
#else
int MDDgetDimensions(h, rank, dims, len)
char *h;
int *rank, *dims, len;
#endif
{
int i;
if ((h = dtm_find_tag(h, MDDdims)) == NULL)
return DTMERROR;
else
h = strchr(h, ' ')+1;
*rank = atoi(h);
for (i=0; i<*rank && i<len; i+=1)
if ((h = strchr(h, ' ')) == NULL)
return DTMERROR;
else
dims[i] = atoi(++h);
return 0;
}
#ifdef DTM_PROTOTYPES
int MDDnumElements(int rank,int *dims)
#else
int MDDnumElements(rank, dims)
int rank, *dims;
#endif
{
int size;
size = *dims++;
while (--rank > 0)
size *= *dims++;
return size;
}
#ifdef DTM_PROTOTYPES
void MDDsetMinMax(char *h,float min,float max)
#else
void MDDsetMinMax(h, min, max)
char *h;
float min, max;
#endif
{
char num[12];
strcat(h, MDDminmax); strcat(h, " ");
sprintf(num, "%f ", min);
strcat(h, num);
sprintf(num, "%f ", max);
strcat(h, num);
}
#ifdef DTM_PROTOTYPES
int MDDgetMinMax(char *h,float *min,float *max)
#else
int MDDgetMinMax(h, min, max)
char *h;
float *min, *max;
#endif
{
if ((h = dtm_find_tag(h, MDDminmax)) == NULL)
return DTMERROR;
else
h = strchr(h, ' ')+1;
*min = (float)atof(h);
h = strchr(h, ' ') + 1;
*max = (float)atof(h);
return 0;
}
#ifdef DTM_PROTOTYPES
void MDDfindMinMax(char *h,float *mdd,float *min,float *max)
#else
void MDDfindMinMax(h, mdd, min, max)
char *h;
float *mdd, *min, *max;
#endif
{
int i, rank, dims[10];
MDDgetDimensions(h, &rank, dims, sizeof dims);
rank = MDDnumElements(rank, dims);
*min = *max = *mdd++;
for (i=1; i<rank; mdd+=1, i+=1)
if (*mdd < *min)
*min = *mdd;
if (*mdd > *max)
*max = *mdd;
}

112
libdtm/mdd.h Normal file
View File

@@ -0,0 +1,112 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/**************************************************************************
**
** Multi-Dimensional Data set include file - contains constants used
** with the MDD & PAL header type.
**
**
**
**************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/mdd.h,v 1.4 1996/02/18 23:40:14 spowers Exp $
**
**********************************************************************/
/*
* Revision 1.1.1.1 1993/07/04 00:03:12 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:30 marca
* I think I got it now.
*
* Revision 1.4 92/04/30 20:27:05 jplevyak
* Changed Version to 2.3
*
* Revision 1.3 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.2 1991/06/11 15:23:09 sreedhar
* disclaimer added
*
* Revision 1.1 1990/11/08 16:37:32 jefft
* Initial revision
*
*/
#define MDDclass "MDD"
#define MDDsize 256
#define PALclass "PAL"
#define PALsize 64
/* MDD specific tags */
#define MDDdims "DIM"
#define MDDminmax "MM"
/* MDD & PAL specific macros */
#define MDDsetClass(h) DTMsetClass(h, MDDclass)
#define MDDcompareClass(h) DTMcompareClass(h, MDDclass)
#define PALsetClass(h) DTMsetClass(h, PALclass)
#define PALcompareClass(h) DTMcompareClass(h, PALclass)
#define MDDsetPalette(h, t) dtm_set_char(h, PALclass, t)
#define MDDgetPalette(h, t, l) dtm_get_char(h, PALclass, t, l)
/* MDD & PAL rename macros */
#define MDDheaderLength DTMheaderLength
#define MDDHL DTMheaderLength
#define PALheaderLength DTMheaderLength
#define PALHL DTMheaderLength
#define MDDsetTitle DTMsetTitle
#define MDDgetTitle DTMgetTitle
#define PALsetTitle DTMsetTitle
#define PALgetTitle DTMgetTitle
#define MDDsetType DTMsetType
#define MDDgetType DTMgetType
/* MDD routines */
#ifdef __cplusplus
extern "C" {
#endif
extern void MDDsetDimensions DTM_PROTO((char *h, int rank, int *dims));
extern int MDDgetDimensions DTM_PROTO((char *h, int *rank, int *dims, int len));
extern int MDDnumElements DTM_PROTO((int rank, int *dims));
extern void MDDsetMinMax DTM_PROTO((char *h, float min, float max));
extern int MDDgetMinMax DTM_PROTO((char *h, float *min, float *max));
extern void MDDfindMinMax DTM_PROTO((char *h, float *mdd, float *min, float *max));
#ifdef __cplusplus
};
#endif

166
libdtm/ninit.c Normal file
View File

@@ -0,0 +1,166 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/ninit.c,v 1.2 1995/10/13 06:33:18 spowers Exp $
**
**********************************************************************/
/*
#ifdef RCSLOG
$Log: ninit.c,v $
Revision 1.2 1995/10/13 06:33:18 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:03:01 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:40:06 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:32 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:13 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:31 marca
* I think I got it now.
*
* Revision 1.7 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
#endif
*/
/*
Purpose : Functions to initialise name server address, fd and to
to return it.
*/
#include <stdlib.h>
#include <sys/types.h>
#ifdef _ARCH_MSDOS
#include <nmpcip.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include <stdio.h>
#include <string.h>
#include "dtmnserv.h"
#include "dtmint.h"
#include "debug.h"
static struct sockaddr_in nsaddr ; /* name server's address */
static int nssockfd = -1 ; /* name server's socket */
static char nameserver[ MAX132 ] ;
/*
name server address -
dotted decimal: port number
*/
/*
Function to initialise the name server's address by
looking up the environment variable.
Return values : DTMERROR on error.
DTM_OK on success.
Notes :
Environment variable format :
DTM_NAMESERVER=nethostid:portid
e.g. DTM_NAMESERVER=141.142.221.66:9900
*/
#ifdef DTM_PROTOTYPES
int dtm_ninit(void )
#else
int dtm_ninit()
#endif
{
char *p ;
DBGFLOW( "dtm_ninit called\n" );
if( (p = getenv( DTM_NAMESERVER )) == NULL ) {
DTMerrno = DTMENV ;
DTMERR( "dtm_ninit: Env not setup" );
return DTMERROR ;
}
/* Initialise name server's address, used in send() */
strncpy( nameserver, p, MAX132 );
DBGINT( "dtm_ninit: Nameserver is %s\n", nameserver );
nsaddr.sin_family = AF_INET ;
{
char *portstr;
portstr = strchr( p, ':' );
if ( portstr == NULL ) {
DTMerrno = DTMADDR;
return DTMERROR;
}
*portstr++ = '\0';
nsaddr.sin_addr.s_addr = inet_addr( p ) ;
nsaddr.sin_port = (unsigned short)atol( portstr ) ;
DBGMSG1("dtm_ninit: Nethostid = %x\n", ntohl( nsaddr.sin_addr.s_addr) );
DBGMSG1("dtm_ninit: Portid = %d\n", ntohs( nsaddr.sin_port) );
}
/* Acquire socket to be used for sending to name server */
if( (nssockfd = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP )) == -1 ){
DTMerrno = DTMSOCK ;
DBGFLOW( "dtm_ninit: Socket call fails" );
return DTMERROR;
}
return DTM_OK;
}
/*
Function to return name server's address and associated socket fd.
*/
#ifdef DTM_PROTOTYPES
char *dtm_get_naddr(struct sockaddr_in *addr,int *sockfd )
#else
char *dtm_get_naddr( addr, sockfd )
struct sockaddr_in *addr ;
int *sockfd ;
#endif
{
if( nssockfd < 0 ) if ( dtm_ninit() == DTMERROR)
return (char *) DTMERROR;
*addr = nsaddr ;
*sockfd = nssockfd ;
return (nssockfd < 0) ? NULL : nameserver ;
}

390
libdtm/nmsg.c Normal file
View File

@@ -0,0 +1,390 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/nmsg.c,v 1.3 1996/02/18 23:40:15 spowers Exp $
**
**********************************************************************/
/*
#ifdef RCSLOG
$Log: nmsg.c,v $
Revision 1.3 1996/02/18 23:40:15 spowers
PROTO -> DTM_PROTO
Revision 1.2 1995/10/13 06:33:20 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:03:01 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:40:08 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:33 alanb
*
* Revision 1.2 1993/10/06 06:19:08 ebina
* Ditto const shit
*
* Revision 1.1.1.1 1993/07/04 00:03:13 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:33 marca
* I think I got it now.
*
* Revision 1.15 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
#endif
*/
/*
Purpose : Set of library calls for name server applications to use.
Notes :
This file contains functions to send and receive
DTM control messages such MREG, MROUTE etc.
The fd parameter should be removed from all calls
for portability.
*/
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef _ARCH_MSDOS
#include <nmpcip.h>
#include <errno.h>
#include "uio.h"
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/uio.h>
#include <sys/errno.h>
#endif
#include "dtmint.h"
#include "dtmnserv.h"
#include <stdio.h>
#include "debug.h"
/*
STATIC FUNCTION PROTOTYPES
*/
static int dtm_send_control DTM_PROTO(( int fd, char *msg, int msize,
char *sendto_addr ));
/*
Function to send a DTM control message ( messages like MREG, MROUTE etc. )
Notes :
*/
#ifdef DTM_PROTOTYPES
static int dtm_send_control(int fd,char *msg,int msize,char *sendto_addr )
#else
static int dtm_send_control( fd, msg, msize, sendto_addr )
int fd ;
char *msg ;
int msize ;
char *sendto_addr ; /* read-only */
#endif
{
S_ADDR sockaddr ; /* destination address */
struct iovec iov[ 1 ] ; /* message iovec */
int status ; /* return value from a call */
int32 tmp ; /* temporary */
char sendaddr[ MAX132 ] ;
int fLogical;
DBGFLOW( "dtm_send_control called\n" );
DBGINT( "dtm_send_control: sendto_addr is '%s'\n", sendto_addr );
/* Get destination address in sockaddr_in structure */
strncpy( sendaddr, sendto_addr, (MAX132 - 1)) ;
sendaddr[ MAX132 - 1 ] = '\0' ;
sockaddr.sin_family = AF_INET ;
CHECK_ERR( dtm_init_sockaddr( &sockaddr, sendaddr, &fLogical));
/* Prepare iovec and send message length */
tmp = msize ;
STDINT( tmp );
iov[ 0 ].iov_base = (char *)&tmp ;
iov[ 0 ].iov_len = 4 ;
if((status = dtm_writev_buffer( fd, iov, 1, 4, (struct sockaddr *)&sockaddr,
sizeof( struct sockaddr_in ))) < 0 )
{
DBGFLOW( "dtm_send_control: message length send error\n" );
return status ;
}
/* Prepare iovec and send message */
iov[ 0 ].iov_base = msg ;
iov[ 0 ].iov_len = msize ;
return dtm_writev_buffer( fd, iov, 1, msize, (struct sockaddr *)&sockaddr,
sizeof( struct sockaddr_in )) ;
}
/*
DTMsendDiscard
Function to send a discard message setting the discard state.
*/
#ifdef DTM_PROTOTYPES
int DTMsendDiscard(int fd,char *sendto_addr,int set_or_clear )
#else
int DTMsendDiscard( fd, sendto_addr, set_or_clear )
int fd; /* output socket */
char *sendto_addr; /* destination address addr:port number */
int set_or_clear;
#endif
{
char mbuf[ MAX132 ]; /* buffer to build messages */
DBGFLOW( "DTMsendDiscard called\n" );
sprintf( mbuf, MDISCARD, MROUTEID, set_or_clear );
DBGFLOW( "DTMsendDiscard: Message:- " );
DBGFLOW( mbuf ); DBGFLOW( "\n" );
return dtm_send_control( fd, mbuf, (strlen( mbuf ) + 1), sendto_addr );
}
/*
Function to send a routing message to designated address.
Notes : delcount parameter to be added, currently
forced to zero.
Destination address, and array of addresses are in
format IPaddr( dotted decimal ):portid.
int fd; output socket
char *sendto_addr; destination address addr:port number
int addcount; number of addresses to connect to
char **add_addresses; array of addresses to connect to
int delcount; number of addresses to connect to
char **del_addresses; array of addresses to connect to
*/
#ifdef DTM_PROTOTYPES
int DTMsendRoute(int fd,char *sendto_addr,int addcount,char **add_addresses,
int delcount, char **del_addresses )
#else
int DTMsendRoute( fd, sendto_addr, addcount, add_addresses,
delcount, del_addresses )
int fd; /* output socket */
char *sendto_addr; /* destination address addr:port number */
int addcount; /* number of addresses to connect to */
char **add_addresses;/* array of addresses to connect to */
int delcount; /* number of addresses to connect to */
char **del_addresses;/* array of addresses to connect to */
#endif
{
char mbuf[ MAX132 ]; /* buffer to build messages */
DBGFLOW( "DTMsendRoute called\n" );
/* Prepare MROUTE message and send it */
sprintf( mbuf, MROUTE, MROUTEID, delcount, addcount ) ;
while( delcount-- ) {
strncat( mbuf, " ", (MAX132-1));
strncat( mbuf, del_addresses[ delcount ], (MAX132 - 1));
}
while( addcount-- ) {
strncat( mbuf, " ", (MAX132-1));
strncat( mbuf, add_addresses[ addcount ], (MAX132 - 1));
}
mbuf[ MAX132 - 1 ] = '\0' ;
DBGFLOW( "DTMsendRoute: Message:- " );
DBGFLOW( mbuf ); DBGFLOW( "\n" );
return dtm_send_control( fd, mbuf, (strlen( mbuf ) + 1), sendto_addr );
}
/*
Function to send ack to routing message to designated address.
NOTE: this function is not used yet as the name server has
not implemented the receive portion.
*/
#ifdef DTM_PROTOTYPES
int dtm_nsend_ackroute( char *portname )
#else
int dtm_nsend_ackroute( portname )
char *portname ;
#endif
{
int fd ;
S_ADDR addr;
char *sendto_addr ;
char *refname = dtm_get_refname() ;
char mbuf[ MAX132 ]; /* buffer to build messages */
CHECK_ERR( sendto_addr = dtm_get_naddr( &addr, &fd ));
DBGFLOW( "dtm_nsend_ackroute called\n" );
/* Prepare Ackroute, send it */
sprintf( mbuf, MACKROUTE, MACKROUTEID, refname, portname );
mbuf[ MAX132 - 1 ] = '\0' ;
DBGFLOW( "dtm_nsend_ackroute: Message:- " );
DBGFLOW( mbuf ); DBGFLOW( "\n" );
return dtm_send_control( fd, mbuf, (strlen( mbuf ) + 1), sendto_addr );
}
/*
Function to send self's socket address to name server process.
*/
#ifdef DTM_PROTOTYPES
dtm_nsend_sockaddr(int fd,char *sendto_addr,char *refname,char *portname,
S_ADDR *sockaddr )
#else
dtm_nsend_sockaddr( fd, sendto_addr, refname, portname, sockaddr )
int fd ;
char *sendto_addr ;
char *refname ;
char *portname ;
S_ADDR *sockaddr ;
#endif
{
struct in_addr inaddr ;
char mbuf[ MAX132 ]; /* buffer to build messages */
DBGFLOW( "dtm_nsend_sockaddr called\n" );
/* Prepare MREG, send it */
inaddr.s_addr = sockaddr -> sin_addr.s_addr ;
#ifdef _ARCH_MSDOS
sprintf( mbuf, MREG, MREGID, refname, portname,
inet_ntoa( inaddr.s_addr ), ntohs( sockaddr -> sin_port ) );
#else
sprintf( mbuf, MREG, MREGID, refname, portname,
inet_ntoa( inaddr ), ntohs( sockaddr -> sin_port ) );
#endif
mbuf[ MAX132 - 1 ] = '\0' ;
DBGFLOW( "dtm_nsend_sockaddr: Message:- " ); DBGFLOW( mbuf ); DBGFLOW( "\n" );
return dtm_send_control( fd, mbuf, (strlen( mbuf ) + 1), sendto_addr );
}
/*
Function to recieve registation messages from other processes.
Notes : does not block, return length is message
received, 0 otherwise
*/
#ifdef DTM_PROTOTYPES
int DTMrecvRegistration(int fd,char *buffer,int len)
#else
int DTMrecvRegistration(fd, buffer, len)
int fd, len;
char *buffer;
#endif
{
int count;
if( dtm_quick_select(fd, &count) )
return dtm_recv_header(fd, buffer, len);
else
return 0;
}
/*
Function to create a nameserver port for receiving registration
messages and sending routing messages.
*/
#ifdef DTM_PROTOTYPES
int DTMmakeNameServerPort(char *portid)
#else
int DTMmakeNameServerPort(portid)
char *portid;
#endif
{
struct sockaddr_in saddr;
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = htonl(0);
saddr.sin_port = htons(0);
if (strcmp(portid, ":0") != 0)
saddr.sin_port = htons((unsigned short)atoi(strchr(portid, ':')+1));
return dtm_socket_init( &saddr, OUTPORTTYPE, NOT_LOGICAL_NAME );
}
/*
Fucntion to get the port address of the name server port.
++++ should be a socket.c function that returns bound address of
socket file descriptor
*/
#ifdef DTM_PROTOTYPES
int DTMgetNameServerAddr(int fd,char *name,int len)
#else
int DTMgetNameServerAddr(fd, name, len)
int fd, len;
char *name;
#endif
{
char pnum[8];
struct sockaddr_in saddr;
int saddr_size = sizeof (struct sockaddr_in);
if (dtm_get_ipaddr(name) == 0) {
DTMerrno = DTMHOST;
return DTMERROR;
}
if (getsockname( fd, (struct sockaddr *)&saddr, &saddr_size ) < 0 ) {
#ifndef _ARCH_MSDOS
extern int errno ;
#endif
DBGINT( "dtm_socket_init: Unable to get sin_port, errno %d\n", errno );
DTMerrno = DTMSOCK ;
return -1 ;
}
sprintf(pnum, ":%d", (int)ntohs( saddr.sin_port ));
strcat(name, pnum);
return 0;
}

126
libdtm/ris.c Normal file
View File

@@ -0,0 +1,126 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/ris.c,v 1.2 1995/10/13 06:33:21 spowers Exp $
**
**********************************************************************/
/*
#ifdef RCSLOG
$Log: ris.c,v $
Revision 1.2 1995/10/13 06:33:21 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:03:01 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:40:10 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:33 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:13 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:34 marca
* I think I got it now.
*
* Revision 1.9 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.8 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.7 1992/02/18 16:18:43 dweber
* Deleted the old-style palette functions.
*
* Revision 1.6 92/01/24 19:12:55 dweber
* *** empty log message ***
*
* Revision 1.5 91/11/04 12:57:55 dweber
* Deleted (via comments) superfluous functions. Later to be removed.
*
* Revision 1.4 91/09/26 20:26:11 jplevyak
* Use dtminit.h for access to internally global functions.
*
* Revision 1.3 1991/06/11 15:21:05 sreedhar
* disclaimer added
*
* Revision 1.2 1991/05/30 15:53:16 sreedhar
* Changes for readMsg/writeMsg internal release
*
* Revision 1.1 1990/11/08 16:37:49 jefft
* Initial revision
*
#endif
*/
#include <stdio.h>
#include <string.h>
#include "dtmint.h"
#include "ris.h"
char PAL[] = "PAL ";
#ifdef DTM_PROTOTYPES
void RISsetDimensions(char *h,int x,int y)
#else
void RISsetDimensions(h, x, y)
char *h;
int x, y;
#endif
{
char append[32];
sprintf(append, "%s 2 %d %d ", RISdims, x, y);
strcat(h, append);
}
#ifdef DTM_PROTOTYPES
int RISgetDimensions(char *h,int *x,int *y)
#else
int RISgetDimensions(h, x, y)
char *h;
int *x, *y;
#endif
{
if ((h = dtm_find_tag(h, RISdims)) == NULL)
return DTMERROR;
else
h = strchr(h, ' ')+1;
/* skip rank */
h = strchr(h, ' ')+1;
*x = atoi(h);
h = strchr(h, ' ') + 1;
*y = atoi(h);
return 0;
}

134
libdtm/ris.h Normal file
View File

@@ -0,0 +1,134 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/ris.h,v 1.3 1995/01/12 02:33:37 spowers Exp $
**
**********************************************************************/
/*
* Revision 1.1.1.1 1993/07/04 00:03:13 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:36 marca
* I think I got it now.
*
* Revision 1.11 92/04/30 20:27:05 jplevyak
* Changed Version to 2.3
*
* Revision 1.10 1992/02/21 13:48:04 dweber
* Fixed prototyping problem in RISgetType.
*
* Revision 1.9 92/02/18 16:22:04 dweber
* Added functions for setting/getting associated palette names.
* (RISsetPaletteName and RISgetPaletteName)
*
* Revision 1.8 92/01/24 19:12:55 dweber
* *** empty log message ***
*
* Revision 1.7 91/11/18 11:48:57 dweber
* Returned the RISsize definition and changed PALsize to PALelements for same reason
*
* Revision 1.6 91/11/04 15:06:08 dweber
* Added PAL size commands
*
* Revision 1.5 91/11/04 12:58:36 dweber
* Added RIS types and removed 8/24 bit distinction from class level.
*
* Revision 1.4 91/09/10 15:07:32 jefft
* cleaned-up message class macros.
*
* Revision 1.3 1991/06/11 15:23:04 sreedhar
* disclaimer added
*
* Revision 1.2 1991/03/14 23:39:38 jefft
* add dtm_compare_class calls
*
* Revision 1.1 90/11/08 16:38:04 jefft
* Initial revision
*
*/
/*
* PALETTE constants and macros
*/
#define PALclass "PAL"
#define PALelements "PE"
#define PALsize 128
#define PALsetClass(h) dtm_set_class(h, PALclass)
#define PALcompareClass(h) dtm_compare_class(h, PALclass)
#define PALsetSize(h, s) dtm_set_int((h), PALelements, (s))
#define PALgetSize(h, s) ((*(s)=(int)256), \
(dtm_get_int((h), PALelements, (s))))
/*
* PALETTE rename macros
*/
#define PALheaderLength dtm_header_length
#define PALHL dtm_header_length
#define PALsetTitle dtm_set_title
#define PALgetTitle dtm_get_title
/*
* RASTER IMAGE constants and macros
*/
/*
* standard image types: 8 bit colormap entries or 24-bit RGB entries.
*/
typedef enum {
RIS8BIT = 0,
RIS24BIT
} RISTYPE;
#define RISclass "RIS"
#define RIStype "RT"
#define RISdims "DIM"
#define RISpalette "APN"
#define RISsize 256
#define RISsetClass(h) dtm_set_class(h, RISclass)
#define RIScompareClass(h) dtm_compare_class(h, RISclass)
#define RISsetType(h, t) ((dtm_set_int((h), RIStype, (t))), \
(dtm_set_type((h), DTM_CHAR)))
#define RISgetType(h, t) ((*(t)=(int)RIS24BIT), \
(dtm_get_int((h), RIStype, (int *)(t))))
/*
* RIS rename macros
*/
#define RISheaderLength dtm_header_length
#define RISHL dtm_header_length
#define RISsetTitle dtm_set_title
#define RISgetTitle dtm_get_title
#define RISsetPaletteName(h, c) dtm_set_char((h), RISpalette, (c))
#define RISgetPaletteName(h, c, l) dtm_get_char((h), RISpalette, (c), (l))

680
libdtm/rwrtns.c Normal file
View File

@@ -0,0 +1,680 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/***************************************************************************
**
** rwrtns.c - provides very low level routines for reading and writing
** buffer. This code should be independent of communication
** channel as long as the descriptor will work with system
** read and write routines.
**
***************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/rwrtns.c,v 1.5 1996/06/06 19:48:08 spowers Exp $
**
**********************************************************************/
/*
#ifdef RCSLOG
$Log: rwrtns.c,v $
Revision 1.5 1996/06/06 19:48:08 spowers
Linux is brain ded.
Revision 1.4 1996/02/18 23:40:16 spowers
PROTO -> DTM_PROTO
Revision 1.3 1995/11/10 12:03:32 spowers
dumb warning messages
Revision 1.2 1995/10/13 06:33:23 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:03:02 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:40:14 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:33 alanb
*
* Revision 1.2 1993/10/29 03:46:49 marca
* Tweaks.
*
* Revision 1.1.1.1 1993/07/04 00:03:13 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:37 marca
* I think I got it now.
*
* Revision 1.19 92/05/14 19:27:48 jefft
* modified dtm_recv_reliable
*
* Revision 1.18 1992/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.17 1992/04/29 22:01:34 jplevyak
* Fix big with exact size buffers. Remove dead code.
*
* Revision 1.16 1992/04/13 16:07:10 jplevyak
* Changes for DEC and RS6000.
*
* Revision 1.15 92/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.14 1992/03/02 18:29:41 jplevyak
* Fixed bug in EAGAIN handling.
*
* Revision 1.13 1992/03/02 17:20:14 jplevyak
* Temporary back out.
*
* Revision 1.11 1992/02/27 23:44:31 jplevyak
* Surrounded writes by code intended to recover from signal interruptions.
*
* Revision 1.10 1992/01/14 16:31:40 creiman
* Removed mac #include
*
* Revision 1.9 1991/10/11 20:26:23 jplevyak
* Fixed incorrect #def use.
*
* Revision 1.8 1991/10/10 15:14:01 jplevyak
* Fixed naming convensions.
*
* Revision 1.7 91/08/20 15:56:06 sreedhar
* Removed unused functions - dtm_write_buffer, dtm_send, dtm_recv
*
* Revision 1.6 1991/08/15 18:56:52 sreedhar
* Changes for logical portname version
*
* Revision 1.4 1991/06/11 15:19:51 sreedhar
* disclaimer added
*
* Revision 1.3 1991/06/07 16:06:29 sreedhar
* sizeof( int ) replaced by 4 for message to be sent out
*
* Revision 1.2 1991/05/30 15:51:50 sreedhar
* Changes for readMsg/writeMsg internal release
*
* Revision 1.1 1990/11/08 16:38:13 jefft
* Initial revision
*
#endif
*/
#include <stdio.h>
#include <sys/types.h>
#if defined(_ARCH_MSDOS)
#include <nmpcip.h>
#include <time.h>
#include "uio.h"
#else
#include <sys/socket.h>
#include <sys/ioctl.h>
#ifdef LINUX
#include "linux-uio.h"
#else
#include <sys/uio.h>
#endif
#include <netinet/in.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#ifdef SOLARIS
#include <sys/filio.h>
#endif
#ifdef RS6000
#include <sys/select.h>
#endif
#include "dtmint.h"
#include "debug.h"
/*
CONTENTS
dtm_read_buffer() - attempts to fill the next dtm buffer.
dtm_recv_header() - Function to read header and return size.
dtm_recv_ack() - receive message ackowledgement
tm_send_ack() - send message acknowledgement
dtm_writev_buffer() - sends the buffers to receiving process.
*/
/*
STATIC FUNCTION PROTOTYPES
*/
#ifdef DTM_PROTOTYPES
static int dtm_recv_reliable DTM_PROTO((int ,char *,int ));
static int dtm_writev_failed DTM_PROTO((int ,struct msghdr *,int ));
static int dtm_send_some DTM_PROTO((int d, char *buf, int bufsize ));
#endif
static int padding[] = {0, 3, 2, 1};
/* Technique from XlibInt.c
*/
#if defined(EAGAIN) && defined(EWOULDBLOCK)
#define ERRTEST(err) (err == EAGAIN || err == EWOULDBLOCK)
#else
#if defined(EAGAIN)
#define ERRTEST(err) (err == EAGAIN)
#else
#define ERRTEST(err) (err == EWOULDBLOCK)
#endif
#endif
#ifdef DTM_PROTOTYPES
static int ready_bytes(int d, int length )
#else
static int ready_bytes( d, length )
int d, length;
#endif
{
int num;
fd_set mask;
struct timeval timeout ;
/* set the select timeout value */
timeout.tv_sec = 2;
timeout.tv_usec = 0;
FD_ZERO(&mask);
FD_SET(d, &mask);
#ifdef __hpux
num = select(FD_SETSIZE, (int *)&mask, (int *)0, (int *)0, &timeout);
#else
num = select(FD_SETSIZE, &mask, (fd_set *)0, (fd_set *)0, &timeout);
#endif
if (num < 0) {
DTMerrno = DTMSELECT;
return DTMERROR;
}
else if (num == 0) {
DTMerrno = DTMTIMEOUT;
return DTMERROR;
}
else {
ioctl(d, FIONREAD, &num);
if (num < length) {
DTMerrno = DTMTIMEOUT;
return DTMERROR;
}
else
return DTM_OK;
}
}
/*
Reliably read from a port in the face of signals and other
'errors' produced by the operating system.
*/
#ifdef DTM_PROTOTYPES
static int dtm_recv_reliable(int d,char *buffer,int length )
#else
int dtm_recv_reliable( d, buffer, length )
int d;
char * buffer;
int length;
#endif
{
int bytes_read;
while ( (bytes_read = recv( d, buffer, length, 0)) != length ) {
if ( bytes_read > 0) {
length -= bytes_read;
buffer += bytes_read;
} else if (ERRTEST(errno)) {
fd_set filedes;
int got;
/* FD_ZERO and FD_SET were moved into the select loop */
/* just in case the select is clearing filedes */
do {
FD_ZERO( &filedes );
FD_SET( d, &filedes );
#ifdef __hpux
got = select( d, (int *)&filedes, (int *)NULL, (int *)NULL,
#else
got = select( d, &filedes, (fd_set *)NULL, (fd_set *)NULL,
#endif
NULL );
if (got < 0 && errno != EINTR ) {
DTMerrno = DTMREAD;
return DTMERROR;
}
} while ( got <= 0 );
continue;
} else if (bytes_read == 0) {
DTMerrno = DTMEOF;
return DTMERROR;
} else if (errno != EINTR) {
DTMerrno = DTMREAD;
return DTMERROR;
}
}
return DTM_OK;
}
/*
* dtm_read_buffer() - attempts to fill the next dtm buffer. The
* blocklen variable must be set to DTM_NEW_DATASET after each dataset
* to force recv_buffer to move the next dataset.
*/
#ifdef DTM_PROTOTYPES
int dtm_read_buffer(int d,int32 *blocklen,VOIDPTR buffer,int length)
#else
int dtm_read_buffer(d, blocklen, buffer, length)
int d, *blocklen;
VOIDPTR buffer;
int length;
#endif
{
reg int tmp, readcnt, count = 0;
DBGFLOW("# dtm_read_buffer called.\n");
DBGMSG1("dtm_recv_buffer: attempting to read %d bytes.\n", length);
DBGMSG1("dtm_recv_buffer: initial blocklen = %d\n", *blocklen);
/* if block length is DTM_NEW_DATASET this is a new dataset
* get initial block count
*/
if (*blocklen == DTM_NEW_DATASET) {
CHECK_ERR(dtm_recv_reliable(d, (char *)blocklen, 4));
LOCALINT(*blocklen);
DBGINT("initial blocklen = %d\n", *blocklen);
}
/* attempt to get a full buffer */
while (TRUE) {
/* if block length is 0, because last call to fill_buffer hit
* the EOS or because this dataset is zero length, return 0
* to indicate the end of dataset.
*/
if (*blocklen == 0)
return 0;
/* if block length is greater than buffer size then... */
if (*blocklen >= length - count) {
readcnt = length - count;
CHECK_ERR( dtm_recv_reliable( d, ((char *)buffer) + length - readcnt,
readcnt));
/* decrement block length, if 0 get next block length */
*blocklen -= (length - count);
if (*blocklen == 0)
*blocklen = DTM_NEW_DATASET;
/* if block length is 0 now, the EOS will be returned on */
/* the next call to fill_buffer */
/* return full buffer count */
DBGINT("recv_buffer: buffer full, returning %d\n", length);
return length;
}
/* else block length is less than buffer size */
else {
readcnt = *blocklen;
CHECK_ERR( dtm_recv_reliable( d, (char *)buffer + count +
*blocklen - readcnt, readcnt));
/* increment count */
count += *blocklen;
/* get next block length */
CHECK_ERR( dtm_recv_reliable(d, (char *)blocklen, 4));
LOCALINT(*blocklen);
DBGINT("blocklen = %d\n", *blocklen);
/* if block length is 0 now, the correct count will be */
/* returned now, and EOS on the next call to fill_buffer */
if (*blocklen == 0)
return count;
}
} /* end while */
}
/*
Replaces dtm_recv_header for nornal communication.
*/
#ifdef DTM_PROTOTYPES
int dtm_read_header(int fd,void *buf,int buflen )
#else
int dtm_read_header( fd, buf, buflen )
int fd;
void * buf;
int buflen;
#endif
{
int32 hdrsize;
CHECK_ERR(ready_bytes(fd, 4));
CHECK_ERR( dtm_recv_reliable( fd, (char *)&hdrsize, 4 ));
LOCALINT(hdrsize);
if ( hdrsize <= buflen ) {
CHECK_ERR( dtm_recv_reliable( fd, buf, hdrsize ));
return hdrsize;
} else {
CHECK_ERR( dtm_recv_reliable( fd, buf, buflen ));
{
int left = hdrsize - buflen;
int readcnt = left % DISCARDSIZE;
if (!readcnt) readcnt = DISCARDSIZE;
while (left) {
CHECK_ERR(dtm_recv_reliable( fd, dtm_discard, readcnt ));
left -= readcnt;
readcnt = DISCARDSIZE;
}
}
}
DTMerrno = DTMHEADER;
return DTMERROR;
}
/*
dtm_recv_header()
Function to read header and return size.
Notes : If buffer is too small, dump remainder of header
and return error.
Actually, this is function to read length of data and
then to receive that much data - the data is called header
everywhere since that was the first usage of the function.
*/
#ifdef DTM_PROTOTYPES
int dtm_recv_header(int d,VOIDPTR header,int length )
#else
int dtm_recv_header( d, header, length )
int d;
int length;
VOIDPTR header;
#endif
{
int readcnt, headerlen, tmp;
struct sockaddr_in from ;
int fromlen = sizeof( struct sockaddr_in ) ;
DBGFLOW("# dtm_recv_header called.\n");
DBGMSG1("dtm_recv_header: fd = %d.\n", d);
DBGMSG1("dtm_recv_header: buf length = %d.\n", length);
/* get header length */
if( (readcnt = recvfrom(d, (char *)&headerlen, 4, 0, ( struct sockaddr *)&from,
( int *)&fromlen)) != 4) {
/* somehow hit EOF, return DTMEOF instead */
if( readcnt == 0 ) {
DTMerrno = DTMEOF;
DBGMSG("dtm_recv_header: EOF1.\n");
return DTMERROR;
} else {
if( errno == ECONNRESET ) {
/* connection closed by writer, return EOF */
DBGMSG("dtm_recv_header: EOF2.\n");
DTMerrno = DTMEOF;
return DTMERROR;
} else {
/* don't know what the problem is, punt... */
DBGMSG("dtm_recv_header: EOF3.\n");
DTMerrno = DTMREAD;
return DTMERROR;
}
}
}
LOCALINT(headerlen);
DBGMSG("dtm_recv_header: got length.\n");
/* read the header */
readcnt = (length > headerlen) ? headerlen : length ;
header = (void *) (((char *) header) + readcnt);
while(readcnt) {
if( (tmp = recvfrom(d, ((char *)header) - readcnt, readcnt, 0,
( struct sockaddr *)&from, ( int *)&fromlen)) > 0)
readcnt -= tmp;
else {
DTMerrno = DTMREAD;
return DTMERROR;
}
}
/* check for header greater than buffer size provided */
if( length >= headerlen )
return headerlen;
else {
/* discard remaining header */
readcnt = headerlen - length;
while (readcnt) {
if ((tmp = recvfrom(d, dtm_discard, readcnt, 0,
(struct sockaddr *)&from, (int *)&fromlen)) > 0)
readcnt -= tmp;
else {
DTMerrno = DTMREAD;
return DTMERROR;
}
}
DTMerrno = DTMHEADER;
return DTMERROR;
}
}
/*
dtm_recv_ack() - receive message ackowledgement
Notes : Berkeley implementation returns 0 from recv
if socket connection breaks while waiting in
recv system call. System V returns -1 and
ECONNRESET in errno for same error.
For historical reasons, DTMEOF is returned when
socket connection breaks in middle instead of
say DTMFCONN ( DTM connection failed error )
*/
#ifdef DTM_PROTOTYPES
int dtm_recv_ack(int d,int *ack )
#else
int dtm_recv_ack( d, ack )
int d;
int *ack;
#endif
{
int tmp ;
DBGFLOW("# dtm_recv_ack called.\n");
/* there should be no possibility of blocking after this call */
CHECK_ERR(ready_bytes(d, 4));
if( (tmp = recv( d, (char *)ack, 4, 0 )) != 4 ) {
DBGINT( "Recv_ack errno = %d\n", errno ) ;
if( tmp == 0 )
/* Courtesy Berkeley */
DTMerrno = DTMEOF ;
else {
if( errno == ECONNRESET )
/* Courtesy system V */
DTMerrno = DTMEOF;
else
DTMerrno = DTMREAD;
}
return DTMERROR;
}
DBGMSG1( "ack received, tmp = %d\n", tmp );
LOCALINT(*ack);
return DTM_OK;
}
#ifdef DTM_PROTOTYPES
static int dtm_send_some(int d, char *buf, int bufsize )
#else
int dtm_send_some( d, buf, bufsize )
int d;
char * buf;
int bufsize;
#endif
{
int tmp ;
while (bufsize ) {
tmp = send(d, buf, bufsize, 0);
if ( tmp >= 0 ) {
bufsize -= tmp;
buf += tmp;
continue;
}
if (errno == EPIPE) {
/* socket connection broke in middle */
DTMerrno = DTMEOF ;
return DTMERROR;
} else if ( ERRTEST( errno ) ) {
fd_set filedes;
int got;
FD_ZERO( &filedes );
FD_SET( d, &filedes );
do {
#ifdef __hpux
got = select( 32, (int *)&filedes, (int *)NULL, (int *)NULL,
#else
got = select( 32, &filedes, (fd_set *)NULL, (fd_set *)NULL,
#endif
NULL );
if (got < 0 && errno != EINTR ) {
DTMerrno = DTMWRITE;
return DTMERROR;
}
} while ( got <= 0 );
continue;
} else DTMerrno = DTMWRITE ;
return DTMERROR;
}
return DTM_OK;
}
/*
* dtm_send_ack() - send message acknowledgement
*/
#ifdef DTM_PROTOTYPES
int dtm_send_ack(int d, int32 ack)
#else
int dtm_send_ack(d, ack)
int d;
int32 ack;
#endif
{
DBGFLOW("# dtm_send_ack called.\n");
STDINT(ack);
return dtm_send_some( d, (char *)&ack, 4 );
}
#ifdef DTM_PROTOTYPES
static int dtm_writev_failed(int fd,struct msghdr *msgbuf,int tmp )
#else
int dtm_writev_failed( fd, msgbuf, tmp )
int fd;
struct msghdr * msgbuf;
int tmp;
#endif
{
int done = tmp;
int i;
struct iovec * iov;
iov=msgbuf->msg_iov;
if ( tmp < 0 ) done = 0;
for ( i = 0; i < msgbuf->msg_iovlen; i++ ) {
done -= iov[i].iov_len;
if ( done > 0 ) continue;
if ( dtm_send_some( fd, iov[i].iov_base + done + iov[i].iov_len,
(- done )) == DTMERROR )
return DTMERROR;
done = 0;
}
}
/*
dtm_writev_buffer() - sends the buffers to receiving process.
*/
#ifdef DTM_PROTOTYPES
int dtm_writev_buffer(int fd,struct iovec *iov,int32 iovlen,int32 iovsize,
struct sockaddr *addr,int addrlen )
#else
int dtm_writev_buffer( fd, iov, iovlen, iovsize, addr, addrlen )
int fd ;
struct iovec *iov ;
int32 iovlen ;
int32 iovsize ;
struct sockaddr *addr ;
int addrlen ;
#endif
{
int tmp;
struct msghdr msgbuf ;
int todo;
DBGINT("# dtm_writev_buffer called, fd %d.\n", fd );
msgbuf.msg_name = (caddr_t)addr ;
msgbuf.msg_namelen = addrlen ;
msgbuf.msg_iov = iov ;
msgbuf.msg_iovlen = iovlen ;
msgbuf.msg_accrights = 0 ;
if( (tmp = sendmsg( fd, &msgbuf, 0 )) != iovsize )
return dtm_writev_failed( fd, &msgbuf, tmp );
DBGINT( "dtm_writev_buffer tmp = %d\n", tmp );
return DTM_OK ;
}

131
libdtm/sdl.c Normal file
View File

@@ -0,0 +1,131 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/************************************************************************
**
** sdl.c - Surface Description Language
**
*************************************************************************/
/*
* $Log: sdl.c,v $
* Revision 1.1.1.1 1995/01/11 00:03:02 alanb
* New CVS source tree, Mosaic 2.5 beta 4
*
* Revision 2.5 1994/12/29 23:40:17 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:33 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:14 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:38 marca
* I think I got it now.
*
* Revision 1.9 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.8 1992/04/06 15:58:56 jplevyak
* Fixed levels of indirection on some arguments for non-prototype
* machines.
*
* Revision 1.7 92/04/03 12:39:33 dweber
* Fixed SDLbounds bug.
*
* Revision 1.6 92/04/03 12:33:10 dweber
* Added bounding box functions.
*
* Revision 1.5 91/09/10 15:09:00 jefft
* I removed all functionality from this file, HA!
*
* Revision 1.4 1991/07/18 16:29:15 jefft
* corrected the spelling of "primitive"
*
* Revision 1.3 1991/06/11 15:20:56 sreedhar
* disclaimer added
*
* Revision 1.2 1991/05/14 14:17:06 jefft
* cleaned-up and started using dtmmisc routines.
*
* Revision 1.1 90/11/08 16:38:33 jefft
* Initial revision
*
*/
#include <stdio.h>
#include <string.h>
#include "dtm.h"
#include "sdl.h"
#ifdef DTM_PROTOTYPES
void SDLsetBoundingBox(char *header, float *min, float *max)
#else
void SDLsetBoundingBox(header, min, max)
char *header;
float *min, *max;
#endif
{
char num[128];
strcat(header, SDLbounds);
strcat(header, " ");
sprintf(num, "%f %f %f %f %f %f ",
min[0], min[1], min[2], max[0], max[1], max[2]);
strcat(header, num);
}
#ifdef DTM_PROTOTYPES
int SDLgetBoundingBox(char *header, float *min, float *max)
#else
int SDLgetBoundingBox(header, min, max)
char *header;
float *min, *max;
#endif
{
int i;
if ((header = dtm_find_tag(header, SDLbounds)) == NULL)
return DTMERROR;
else
header = strchr(header, ' ')+1;
for (i=0; i<3; i+=1)
if ((header = strchr(header, ' ')) == NULL)
return DTMERROR;
else
min[i] = atoi(++header);
for (i=0; i<3; i+=1)
if ((header = strchr(header, ' ')) == NULL)
return DTMERROR;
else
max[i] = atoi(++header);
return 0;
}

162
libdtm/sdl.h Normal file
View File

@@ -0,0 +1,162 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/**************************************************************************
**
** Surface Description Language include file - contains constants used
** with the SDL header type.
**
**
**
**************************************************************************/
/*
* $Log: sdl.h,v $
* Revision 1.3 1996/02/18 23:40:17 spowers
* PROTO -> DTM_PROTO
*
* Revision 1.2 1995/01/12 02:33:38 spowers
* Finally...Dave complained that I blew away the RCSLOGs without leaving the
* actual entries there as comments...so I put them back in as COMMENTS! Not as
* RCSLOG. Hopefully our woeful begining with cvs will now become a happy one.
*
* Revision 1.1.1.1 1993/07/04 00:03:14 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:39 marca
* I think I got it now.
*
* Revision 1.13 92/04/30 20:27:05 jplevyak
* Changed Version to 2.3
*
* Revision 1.12 1992/04/03 12:39:42 dweber
* Fixed SDLbounds bug.
*
* Revision 1.11 92/04/03 12:33:23 dweber
* Added bounding box functions.
*
* Revision 1.10 1992/02/25 20:36:35 dweber
* Fixed another prototyping clash, SDLgetPrimitive.
*
* Revision 1.9 1992/01/31 09:46:35 dweber
* Added #define SDL_INC to avoid duplicate inclusions.
*
* Revision 1.8 1992/01/24 19:14:33 dweber
* Added header length macros.
*
* Revision 1.7 91/11/01 10:10:28 dweber
* Added SDLtristrip
*
* Revision 1.6 91/09/10 15:07:55 jefft
* cleaned-up message class macros.
*
* Revision 1.5 1991/07/25 22:22:27 jefft
* Added transformation triplet enum types
*
* Revision 1.4 1991/07/18 16:29:43 jefft
* corrected the spelling of "primitive" and added macros for backwards
* compatibility.
*
* Revision 1.3 1991/06/11 15:22:58 sreedhar
* disclaimer added
*
* Revision 1.2 1991/03/01 10:27:13 jefft
* Added SDLcompareClass functions and enum for triplet types
*
* Revision 1.1 90/11/08 16:38:51 jefft
* Initial revision
*
*/
#ifndef SDL_INC
#define SDL_INC
/*
* Surface description language class typedefs and macros
*/
#define SDLclass "SDL"
#define SDLsize 256
#define SDLprimitive "PT"
#define SDLbounds "BB"
typedef enum {
SDLpoint = 1, SDLlineseg, SDLtriangle, SDLtristrip, SDLquad, SDLsphere
} SDLprim_t;
typedef enum {
SDLposition, SDLcolor, SDLnormal, SDLtranslate, SDLrotate, SDLscale
} SDLtriplet;
typedef enum {
SDLflat, SDLgouraud, SDLphong
} SDLshade_t;
typedef enum {
SDLpoints, SDLlines, SDLpolygons
} SDLdraw_t;
#define SDLsetClass(h) dtm_set_class((h), SDLclass)
#define SDLcompareClass(h) dtm_compare_class((h), SDLclass)
#define SDLsetPrimitive(h, p) dtm_set_int((h), SDLprimitive, (p))
#define SDLgetPrimitive(h, p) ((*(p)=(int)SDLpoint), \
(dtm_get_int((h), SDLprimitive, (int *)(p))))
#define SDLsetTitle dtm_set_title
#define SDLgetTitle dtm_get_title
#define SDLheaderLength dtm_header_length
#define SDLHL dtm_header_length
#ifdef __cplusplus
extern "C" {
#endif
extern void SDLsetBoundingBox DTM_PROTO(( char* h, float *min, float *max));
extern int SDLgetBoundingBox DTM_PROTO(( char* h, float *min, float *max));
#ifdef __cplusplus
};
#endif
/*
* View control matrix class typedefs and macros
*/
#define VCTRLclass "VCTRL"
#define VCTRLsize 256
#define VCTRLgtm "GTM "
#define VCTRLsetClass(h) dtm_set_class((h), VCTRLclass)
#define VCTRLcompareClass(h) dtm_compare_class((h), VCTRLclass)
#define VCTRLsetGTM(h) strcat(h, VCTRLgtm)
#define VCTRLgetGTM(h) ((dtm_find_tag(h, VCTRLgtm) == NULL) ? 0 : 1)
#define VCTRLsetTitle dtm_set_title
#define VCTRLgetTitle dtm_get_title
#define VCTRLheaderLength dtm_header_length
#define VCTRLHL dtm_header_length
#endif /* SDL_INC */

235
libdtm/sds.c Normal file
View File

@@ -0,0 +1,235 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/************************************************************************
**
** sds.c - Scientific Data Set utility routines.
**
*************************************************************************/
/*
#ifdef RCSLOG
$Log: sds.c,v $
Revision 1.2 1995/10/13 06:33:25 spowers
Solaris support added.
Revision 1.1.1.1 1995/01/11 00:03:02 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:40:20 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:33 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:14 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:40 marca
* I think I got it now.
*
* Revision 1.12 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.11 1992/03/16 20:39:10 creiman
* Changed declaration of SDSgetMinMax to match prototype. (Changed doubles
* to floats)
*
* Revision 1.10 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.9 1992/01/30 19:31:14 jplevyak
* Change float to double (standard coersion).
* Needed to correct problem with protot
* types.
*
* Revision 1.8 1991/12/19 09:32:18 jefft
* Removed the single quote from the log message. Even though the line
* is #ifdefed out. The SGI still pukes.
*
* Revision 1.7 91/12/18 02:42:41 dweber
* Oops. Guess I forgot to change getRanks name.
*
* Revision 1.6 1991/12/18 02:41:53 dweber
* Added SDSgetRank
*
* Revision 1.5 91/12/09 12:12:27 dweber
* Deleted the function SDSconvert
*
* Revision 1.4 91/09/26 20:20:52 jplevyak
* Minor header file reorganization.
*
* Revision 1.3 91/09/13 18:01:21 jplevyak
* Fixed minor bug w/extra argument in call.
*
* Revision 1.2 91/06/11 15:20:50 sreedhar
* disclaimer added
*
* Revision 1.1 1990/11/08 16:39:09 jefft
* Initial revision
*
#endif
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef _ARCH_MSDOS
#include <nmpcip.h>
#else
#include <netinet/in.h>
#endif
#include "dtm.h"
#include "dtmint.h"
#include "sds.h"
#ifdef DTM_PROTOTYPES
void SDSsetDimensions(char *h,int rank,int *dims)
#else
void SDSsetDimensions(h, rank, dims)
char *h;
int rank, *dims;
#endif
{
char num[8];
int i;
sprintf(num, "%d ", rank);
strcat(h, SDSdims); strcat(h, " ");
strcat(h, num);
for (i=0; i<rank; i+=1) {
sprintf(num, "%d ", dims[i]);
strcat(h, num);
}
}
#ifdef DTM_PROTOTYPES
int SDSgetDimensions(char *h,int *rank,int *dims,int len)
#else
int SDSgetDimensions(h, rank, dims, len)
char *h;
int *rank, *dims, len;
#endif
{
int i;
if ((h = dtm_find_tag(h, SDSdims)) == NULL)
return DTMERROR;
else
h = strchr(h, ' ')+1;
*rank = atoi(h);
for (i=0; i<*rank && i<len; i+=1)
if ((h = strchr(h, ' ')) == NULL)
return DTMERROR;
else
dims[i] = atoi(++h);
return 0;
}
#ifdef DTM_PROTOTYPES
int SDSgetRank(char *h,int *rank)
#else
int SDSgetRank(h, rank)
char *h;
int *rank;
#endif
{
if ((h = dtm_find_tag(h, SDSdims)) == NULL)
return DTMERROR;
else
h = strchr(h, ' ')+1;
*rank = atoi(h);
return 0;
}
#ifdef DTM_PROTOTYPES
void SDSsetMinMax(char *h,float min,float max)
#else
void SDSsetMinMax(h, min, max)
char *h;
float min, max;
#endif
{
char num[12];
strcat(h, SDSminmax); strcat(h, " ");
sprintf(num, "%f ", min);
strcat(h, num);
sprintf(num, "%f ", max);
strcat(h, num);
}
#ifdef DTM_PROTOTYPES
int SDSgetMinMax(char *h,float *min,float *max)
#else
int SDSgetMinMax(h, min, max)
char *h;
float *min, *max;
#endif
{
if ((h = dtm_find_tag(h, SDSminmax)) == NULL)
return DTMERROR;
else
h = strchr(h, ' ')+1;
*min = (float)atof(h);
h = strchr(h, ' ') + 1;
*max = (float)atof(h);
return 0;
}
#ifdef DTM_PROTOTYPES
int SDSnumElements(int rank,int *dims)
#else
int SDSnumElements(rank, dims)
int rank, *dims;
#endif
{
int size;
size = *dims++;
while (--rank > 0)
size *= *dims++;
return size;
}

109
libdtm/sds.h Normal file
View File

@@ -0,0 +1,109 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/**************************************************************************
**
** Scientific Data Set include file - contains constants used with the
** SDS header type.
**
**************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/sds.h,v 1.4 1996/02/18 23:40:18 spowers Exp $
**
**********************************************************************/
/*
* Revision 1.1.1.1 1993/07/04 00:03:14 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:42 marca
* I think I got it now.
*
* Revision 1.8 92/04/30 20:27:37 jplevyak
* Changed Version to 2.3
*
* Revision 1.7 1992/03/16 21:03:18 creiman
* Changed SDSsetMinMax prototype to use floats. NOT related to the change in
* sds.c for SDSgetMinMax. This is getting confusing...
*
* Revision 1.6 1992/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.5 1992/01/30 19:32:29 jplevyak
* Added prototypes and support for C++ type external definitions.
*
* Revision 1.4 92/01/24 19:13:51 dweber
* Added header lenght macros
*
* Revision 1.3 91/09/10 15:07:10 jefft
* cleaned-up message class macros.
*
* Revision 1.2 1991/06/11 15:22:52 sreedhar
* disclaimer added
*
* Revision 1.1 1990/11/08 16:39:26 jefft
* Initial revision
*
*/
#define SDSclass "SDS"
#define SDSsize 256
/* SDS specific tags */
#define SDSdims "DIM"
#define SDSminmax "MM"
/* SDS specific macros */
#define SDSsetClass(h) dtm_set_class(h, SDSclass)
#define SDScompareClass(h) dtm_compare_class(h, SDSclass)
/* SDS rename macros */
#define SDSheaderLength dtm_header_length
#define SDSHL dtm_header_length
#define SDSsetType dtm_set_type
#define SDSgetType dtm_get_type
#define SDSsetTitle dtm_set_title
#define SDSgetTitle dtm_get_title
/* SDS routines */
#ifdef __cplusplus
extern "C" {
#endif
extern void SDSsetDimensions DTM_PROTO(( char* h, int rank, int *dims ));
extern int SDSgetDimensions DTM_PROTO(( char* h, int * rank, int* dims,
int len ));
extern int SDSgetRank DTM_PROTO(( char* h, int * rank ));
extern int SDSnumElements DTM_PROTO(( int rank, int *dims ));
extern void SDSsetMinMax DTM_PROTO(( char* h, float min, float max));
extern int SDSgetMinMax DTM_PROTO(( char* h, float* min, float* max));
#ifdef __cplusplus
};
#endif

243
libdtm/sdsF.c Normal file
View File

@@ -0,0 +1,243 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/sdsF.c,v 1.1.1.1 1995/01/11 00:03:03 alanb Exp $
**
**********************************************************************/
#ifdef RCSLOG
$Log: sdsF.c,v $
Revision 1.1.1.1 1995/01/11 00:03:03 alanb
New CVS source tree, Mosaic 2.5 beta 4
* Revision 2.5 1994/12/29 23:40:25 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:34 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:14 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:43 marca
* I think I got it now.
*
* Revision 1.5 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
#endif
#include <stdio.h>
#include <string.h>
#include <fortran.h>
#include "dtmint.h"
#include "sds.h"
extern int atoi();
extern double atof();
extern char * dtm_find_tag();
/*************************************************************************
**
** Cray version of SDS macros
**
*************************************************************************/
/* SDSsetClass */
void SDSSC(s)
_fcd s;
{
strcat(strcpy(_fcdtocp(s), SDSclass), " ");
}
/* SDScompareClass */
long SDSCC(s)
_fcd s;
{
return _btol(!strncmp(_fcdtocp(s), SDSclass, strlen(SDSclass)));
}
/* SDSheaderLength */
#undef SDSHL
long SDSHL(s)
_fcd s;
{
return _fcdlen(s);
}
/* SDSsetType */
void SDSSDT(s, type)
_fcd s;
int *type;
{
dtm_set_int(_fcdtocp(s), DTMtype, *type);
}
/* SDSgetType */
void SDSGDT(s, type)
_fcd s;
int *type;
{
dtm_get_int(_fcdtocp(s), DTMtype, *type);
}
/* SDSsetTitle */
void SDSST(s, t)
_fcd s, t;
{
int i;
char *tptr = _fcdtocp(t);
strcat(strcat(_fcdtocp(s), DTMtitle), " '");
for (i=0; i< _fcdlen(t); i+=1)
if (*tptr == ' ' && *(tptr+1) == ' ')
break;
strcat(strncat(_fcdtocp(s), _fcdtocp(t), i), "' ");
}
/* SDSgetTitle */
void SDSGT(s, t)
_fcd s, t;
{
dtm_get_int(_fcdtocp(s), DTMtype, _fcdtocp(t), _fcdlen(t));;
}
/*************************************************************************
**
** Cray version of SDS functions
**
*************************************************************************/
/* SDSsetDimensions */
void SDSSD(s, rank, dims)
_fcd s;
int *rank, *dims;
{
char *h = _fcdtocp(s);
char num[8];
int i;
sprintf(num, "%d ", *rank);
strcat(h, SDSdims); strcat(h, " ");
strcat(h, num);
for (i=0; i< *rank; i+=1) {
sprintf(num, "%d ", dims[i]);
strcat(h, num);
}
}
/* SDSgetDimensions */
int SDSGD(s, rank, dims, len)
_fcd s;
int *rank, *dims, *len;
{
char *h = _fcdtocp(s);
int i;
if ((h = dtm_find_tag(h, SDSdims)) == NULL)
return DTMERROR;
else
h = strchr(h, ' ')+1;
*rank = atoi(h);
for (i=0; i<*rank && i<*len; i+=1)
if ((h = strchr(h, ' ')) == NULL)
return DTMERROR;
else
dims[i] = atoi(++h);
return 0;
}
/* SDSsetMinMax */
void SDSSMM(s, min, max)
_fcd s;
float *min, *max;
{
char *h = _fcdtocp(s);
char num[12];
strcat(h, SDSminmax); strcat(h, " ");
sprintf(num, "%f ", *min);
strcat(h, num);
sprintf(num, "%f ", *max);
strcat(h, num);
}
/* SDSgetMinMax */
long SDSGMM(s, min, max)
_fcd s;
float *min, *max;
{
char *h = _fcdtocp(s);
if ((h = dtm_find_tag(h, SDSminmax)) == NULL)
return _btol(0);
else
h = strchr(h, ' ')+1;
*min = atof(h);
h = strchr(h, ' ') + 1;
*max = atof(h);
return _btol(1);
}
/* SDSnumElements */
long SDSNE(rank, dims)
int *rank, *dims;
{
int size;
size = *dims++;
while (--(*rank) > 0)
size *= *dims++;
return size;
}

776
libdtm/socket.c Normal file
View File

@@ -0,0 +1,776 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/socket.c,v 1.2 1995/10/13 06:33:27 spowers Exp $
**
**********************************************************************/
/*
* $Log: socket.c,v $
* Revision 1.2 1995/10/13 06:33:27 spowers
* Solaris support added.
*
* Revision 1.1.1.1 1995/01/11 00:03:03 alanb
* New CVS source tree, Mosaic 2.5 beta 4
*
* Revision 2.5 1994/12/29 23:40:27 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:34 alanb
*
* Revision 1.3 1993/10/29 03:46:50 marca
* Tweaks.
*
* Revision 1.2 1993/10/06 06:19:10 ebina
* Ditto const shit
*
* Revision 1.1.1.1 1993/07/04 00:03:14 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:44 marca
* I think I got it now.
*
* Revision 1.28 92/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.27 1992/04/06 15:58:49 jplevyak
* Fixed minor problems for machines little Endian machines.
*
* Revision 1.26 92/03/10 22:07:10 jplevyak
* Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
* with modification.
*
* Revision 1.25 1992/02/28 03:40:24 jplevyak
* int/long confict fix (no diff on workstations)
* ,
*
* Revision 1.24 92/01/30 19:33:07 jplevyak
* Fix bug in MAC version of dtm_get_ipaddr.
*
* Revision 1.23 1992/01/15 17:05:37 creiman
* Added typecast to dtm_socket_init:getsockname
*
* Revision 1.22 1992/01/14 16:31:40 creiman
* Removed mac #include
*
* Revision 1.21 1991/12/17 23:46:30 jefft
* dtm_socket_init used to only determine the socketname for logical ports,
* it now correctly sets the sockaddr_in structure maintained within the DTM
* port structure for every call.
*
* Revision 1.20 1991/10/29 22:07:10 sreedhar
* struct sockaddr * type casting
*
* Revision 1.19 1991/10/29 16:38:58 jplevyak
* Fixed bug in code that parses addressses. (extra (STDINT)).
*
* Revision 1.18 1991/10/16 23:26:00 jplevyak
* Fixed debugging message.
*
* Revision 1.17 1991/10/15 18:21:25 jplevyak
* Changed memcpy to structure cast, select field and assign. This
* is less kludgy and not only that, it works on the CRAY which the other
* did not.
*
* Revision 1.16 1991/10/14 16:49:32 jplevyak
* Fix problem with physical addressing.
*
* Revision 1.15 1991/10/10 15:15:04 jplevyak
* Fixed naming convensions.
*
* Revision 1.14 91/09/26 20:21:55 jplevyak
* Cosmetics
*
* Revision 1.13 91/09/18 15:33:08 jplevyak
* Added additional parameter to dtm_socket_init
*
* Revision 1.12 91/09/13 20:28:52 sreedhar
* accept :9900 change
*
* Revision 1.11 1991/09/13 20:13:35 sreedhar
* take current host as default
*
* Revision 1.10 1991/08/19 18:53:37 jefft
* Fixed bug with dtm_socket_init, now checks port number for absolute
* address instead of the IP address (which isn't used anyway).
*
* Revision 1.9 1991/08/15 18:56:35 sreedhar
* Changes for logical portname version
*
* Revision 1.7 1991/06/11 15:19:45 sreedhar
* disclaimer added
*
* Revision 1.6 1991/06/07 16:07:21 sreedhar
* Changes for sequence start message
*
* Revision 1.5 1991/05/30 15:52:10 sreedhar
* Changes for readMsg/writeMsg internal release
*
* Revision 1.4 1990/12/11 14:11:38 jefft
* made dtm_get_ipaddr CRAY specific to fix final portability problem.
*
* Revision 1.3 90/11/21 12:43:15 jefft
* Fixed portibility problem with dtm_get_ipaddr.
*
* Revision 1.2 90/11/21 10:54:18 jefft
* Added new routine, dtm_get_ipaddr. It returns an ascii string of the
* current hosts IP address.
*
* Revision 1.1 90/11/08 16:39:40 jefft
* Initial revision
*
*/
/*
+++++ System call - merge dtm_connect, dtm_quick_connect +++++
Check on whether dtm_get_ipaddr and dtm_init_sockaddr can be merged.
*/
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#ifdef _ARCH_MSDOS
#include <io.h>
#include <time.h>
#include <stdlib.h>
#include <nmpcip.h>
#include "uio.h"
#else
#include <sys/param.h>
#include <sys/uio.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/socket.h>
#endif
#include <string.h>
/* Machine specific header file(s) */
#ifdef SOLARIS
#include <sys/filio.h>
#endif
#ifdef RS6000
#include <sys/select.h>
#endif
#ifdef _ARCH_MSDOS
#include <nmpcip.h>
#else
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#include <errno.h>
#include "dtmint.h"
#include "debug.h"
static int buf_size = DTM_BUFF_SIZE;
/*
dtm_parse_ipaddr()
Check whetherer given address string is in dotted
decimal notation and if so, to return the address in network byte
order.
Return values : TRUE, if in dotted decimal notation.
( network order address returned thru *addr )
FALSE, if not.
*/
#ifdef DTM_PROTOTYPES
int dtm_parse_ipaddr(char *s,unsigned long *addr )
#else
int dtm_parse_ipaddr( s, addr )
char *s; /* address string */
unsigned long *addr; /* location to return network byte order address */
#endif
{
int b1, b2, b3, b4;
int got;
if( (got = sscanf(s, "%d.%d.%d.%d", &b1, &b2, &b3, &b4)) != 4 ) {
DTMerrno = DTMADDR;
return DTMERROR;
}
*addr = htonl(b1 << 24 | b2 << 16 | b3 << 8 | b4);
return DTM_OK;
}
/*
dtm_quick_select()
Check whether a socket (s) has count bytes ready.
*/
#ifdef DTM_PROTOTYPES
int dtm_quick_select(int s,int *count)
#else
int dtm_quick_select(s, count)
int s;
int *count;
#endif
{
fd_set filedes;
static struct timeval timeout = {0L, 0L};
DBGFLOW("# dtm_quick_select called.\n");
FD_ZERO(&filedes);
FD_SET(s, &filedes);
#ifdef __hpux
if (select(32, (int *)&filedes, (int *)NULL, (int *)NULL, &timeout)) {
#else
if (select(32, &filedes, (fd_set *)NULL, (fd_set *)NULL, &timeout)) {
#endif
ioctl(s, FIONREAD, count);
return TRUE;
} else {
*count = 0;
return FALSE;
}
}
/*
dtm_select()
Wait (time) seconds for count bytes to be ready on socket s.
*/
#ifdef DTM_PROTOTYPES
int dtm_select(int s,int32 *count,int32 time )
#else
int dtm_select( s, count, time )
int s;
int32 *count;
int32 time;
#endif
{
fd_set filedes;
static struct timeval timeout = { 0L, 0L };
DBGFLOW("# dtm_select called.\n");
timeout.tv_sec = time ;
FD_ZERO( &filedes );
FD_SET( s, &filedes );
#ifdef __hpux
if( (*count = select( 32, (int *)&filedes, (int *)NULL, (int *)NULL,
#else
if( (*count = select( 32, &filedes, (fd_set *)NULL, (fd_set *)NULL,
#endif
&timeout ) )) {
ioctl( s, FIONREAD, count );
return TRUE;
} else {
return FALSE;
}
}
/*
dtm_accept().
Function to accept connection request on specified socket.
*/
#ifdef DTM_PROTOTYPES
int dtm_accept(int s,S_ADDR *sn,struct timeval *timeout )
#else
int dtm_accept( s, sn, timeout )
int s;
S_ADDR *sn;
struct timeval *timeout ;
#endif
{
int snsize = sizeof (S_ADDR);
DBGFLOW( "dtm_accept called.\n");
DBGMSG1( "dtm_accept: sockfd = %d\n", s );
/*
Await connect for specified time period only.
if timeout == NULL, it means just goahead and accept,
else wait for specified period and accept only if
connection request arrives in that period.
*/
if ( timeout ) {
fd_set readmask ;
fd_set *fchk = &readmask ;
int nf ;
FD_ZERO( fchk );
FD_SET( s, fchk );
#ifdef __hpux
nf = select( FD_SETSIZE, (int *)fchk, (int *)0, (int *)0, timeout );
#else
nf = select( FD_SETSIZE, fchk, (fd_set *)0, (fd_set *)0, timeout );
#endif
if ( nf < 0 ) {
DBGINT( "dtm_accept: select errno %d\n", errno );
DTMerrno = DTMSELECT ;
return DTMERROR ;
}
if ( nf == 0 ) {
/* No connect request in specified time */
DBGFLOW( "dtm_accept: timed out\n" );
return DTMERROR ;
}
}
/* accept connections on socket */
if ((s = accept(s, (struct sockaddr *)sn, &snsize)) < 0 ) {
DTMerrno = DTMSOCK;
DBGINT("dtm_accept: error %d accepting connection.", errno );
return DTMERROR ;
}
return s;
}
/*
dtm_connect()
Attempt to connect to the the address sn, returning
the connected port in *s.
returns DTMERROR on failure. DTM_OK on success.
*/
#ifdef DTM_PROTOTYPES
int dtm_connect(S_ADDR *sn,int *s)
#else
int dtm_connect(sn, s)
S_ADDR *sn;
int *s;
#endif
{
int d;
int refusedcount = 0;
DBGFLOW("dtm_connect called.\n");
DBGINT( "dtm_connect: s_addr = %x\n",
ntohl( sn -> sin_addr.s_addr ) );
DBGINT( "dtm_connect: sin_port = %d\n",
ntohs( sn -> sin_port ));
while (TRUE) {
/* create socket */
if ((d = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
DTMerrno = DTMSOCK;
DTMERR("dtm_connect: could not create socket.");
return DTMERROR;
}
/* attempt to connect to receiver */
if (connect(d, (struct sockaddr *)sn, sizeof (S_ADDR)) < 0) {
/* if connection refused, try again in 2 second */
if (errno == ECONNREFUSED) {
close(d);
sleep(2);
if ((refusedcount += 1) > DTM_REFUSE_LIMIT) {
DTMerrno = DTMTIMEOUT;
return DTMERROR;
} else
continue;
} else {
/* system error, can not connect, quit */
DTMerrno = DTMSOCK;
DTMERR("dtm_connect: could not connect.");
return DTMERROR;
}
} else {
/* connect complete, set working socket to original socket */
*s = d;
setsockopt(*s, IPPROTO_TCP, TCP_NODELAY, (char *)&d, sizeof d);
setsockopt(*s, SOL_SOCKET, SO_SNDBUF, (char *)&buf_size,
sizeof(int));
return DTM_OK;
}
} /* end while */
}
/*
dtm_quick_connect()
*/
#ifdef DTM_PROTOTYPES
int dtm_quick_connect(S_ADDR *sn,int *s)
#else
int dtm_quick_connect(sn, s)
S_ADDR *sn;
int *s;
#endif
{
int d;
DBGFLOW("# dtm_quick_connect called.\n");
/* create socket */
if ((d = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
DTMerrno = DTMSOCK;
DBGFLOW("dtm_quick_connect: could not create socket.");
return DTMERROR;
}
/* attempt to connect to receiver */
if (connect(d, (struct sockaddr *)sn, sizeof (S_ADDR)) < 0) {
/* if connection refused */
if (errno == ECONNREFUSED) {
close(d);
DTMerrno = DTMTIMEOUT;
return DTMERROR;
} else {
/* system error, can not connect, quit */
DTMerrno = DTMSOCK;
DBGFLOW("dtm_quick_connect: could not connect.");
return DTMERROR;
}
} else {
/* else connection has been made */
*s = d;
setsockopt(*s, IPPROTO_TCP, TCP_NODELAY, (char *)&d, sizeof d);
setsockopt(*s, SOL_SOCKET, SO_SNDBUF, (char *)&buf_size, sizeof (int));
return DTM_OK;
}
}
#ifdef DTM_PROTOTYPES
int dtm_end_connect(int s)
#else
int dtm_end_connect(s)
int s;
#endif
{
struct linger lbuf ;
DBGFLOW("# dtm_end_connect called.\n");
DBGINT( "dtm_end_connect: sockfd %d\n", s );
#if 0
lbuf.l_onoff = 0 ;
setsockopt( s, SOL_SOCKET, SO_LINGER, &lbuf, sizeof( struct linger ) );
#endif
return close( s );
}
/*
Return values :
On success,
Direct - host address in network byte order.
Indirect - *ipaddr has host address in dotted
decimal notation.
On error, 0.
Notes:
Error is returned as 0, since an internet address
of 0 is not possible for any host ( 0 refers to 'this' host
in internet context ).
*/
#ifdef DTM_PROTOTYPES
unsigned long dtm_get_ipaddr(char *ipaddrstr )
#else
unsigned long dtm_get_ipaddr( ipaddrstr )
char *ipaddrstr ;
#endif
{
char hostname[MAXHOSTNAMELEN];
struct hostent *hp;
unsigned long tmp;
DBGFLOW( "dtm_get_ipaddr called\n" );
/* get hostname */
gethostname( hostname, sizeof hostname );
#ifdef _ARCH_MACOS
/* check if hostname is in dotted decimal notation - this is a Mac-Hack */
if ( dtm_parse_ipaddr( hostname, &tmp ) != DTMERROR ) {
strcpy( ipaddrstr , hostname );
return tmp;
}
#endif
/* lookup IP address */
if( (hp = gethostbyname(hostname)) == NULL ) {
DTMerrno = DTMHOST;
return 0;
}
/* extract dotted decimal address */
{
struct in_addr inaddr ;
#ifdef _ARCH_MSDOS
inaddr = *((struct in_addr *)( hp -> h_addr)) ;
strcpy( ipaddrstr , inet_ntoa( inaddr.s_addr ));
#else
inaddr = *((struct in_addr *)( hp -> h_addr_list[ 0 ])) ;
strcpy( ipaddrstr , inet_ntoa( inaddr ));
#endif
}
DBGINT( "dtm_get_ipaddr: dotted decimal address = '%s'\n", ipaddrstr );
return inet_addr( ipaddrstr ) ;
}
/*
Function to acquire and bind a UDP or TCP port.
*/
#ifdef DTM_PROTOTYPES
int dtm_socket_init(S_ADDR *sockaddr,int porttype,int fLogicalName )
#else
int dtm_socket_init( sockaddr, porttype, fLogicalName )
S_ADDR *sockaddr;
int porttype;
int fLogicalName;
#endif
{
int sockfd;
int type;
int protocol;
int opt = 1;
int sockaddrsize = sizeof (struct sockaddr_in);
char buf[128];
DBGMSG1( "dtm_socket_init: sockaddr -> s_addr = %x\n",
ntohl( sockaddr -> sin_addr.s_addr) );
DBGMSG1( "dtm_socket_init: sockaddr -> sin_port = %d\n",
ntohs( sockaddr -> sin_port) );
sockaddr -> sin_family = AF_INET ;
if ( fLogicalName ) {
/*
Logical name had been supplied for makeport.
Assign port from system ( sin_port = 0 ), and accept
from all network interfaces for multi-homed host
( INADDR_ANY ).
*/
sockaddr -> sin_addr.s_addr = htonl( INADDR_ANY );
sockaddr -> sin_port = htons( 0 ) ;
}
/* Acquire appropriate socket ( UDP or TCP ) */
if( porttype == INPORTTYPE ) {
sockaddr -> sin_addr.s_addr = htonl( INADDR_ANY );
type = SOCK_STREAM ;
protocol = IPPROTO_TCP ;
} else {
type = SOCK_DGRAM ;
protocol = IPPROTO_UDP ;
}
if( (sockfd = socket( sockaddr -> sin_family, type, protocol )) < 0 ) {
DTMerrno = DTMSOCK ;
DBGINT( "dtm_socket_init: socket create error %d", errno );
return DTMERROR ;
}
/* Set socket options. */
setsockopt( sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof opt );
setsockopt( sockfd, SOL_SOCKET, SO_RCVBUF, (char *)&buf_size, sizeof(int) );
if( porttype == INPORTTYPE ) {
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&opt, sizeof opt );
}
/* Bind name to socket */
DBGFLOW( "dtm_socket_init: Before bind\n" );
DBGINT( "dtm_socket_init: sockfd = %d\n", sockfd );
DBGINT( "dtm_socket_init: sockaddr -> family = %d\n",
sockaddr -> sin_family );
DBGINT( "dtm_socket_init: sockaddr -> s_addr = %x\n",
ntohl( sockaddr -> sin_addr.s_addr) );
DBGINT( "dtm_socket_init: sockaddr -> sin_port = %d\n",
ntohs( sockaddr -> sin_port) );
if( bind( sockfd, (struct sockaddr *)sockaddr,
sizeof( struct sockaddr_in ) ) < 0 ) {
DTMerrno = DTMSOCK ;
DBGMSG1( "dtm_socket_init: could not bind to sockaddr, errno = %d\n",
errno );
return DTMERROR;
}
/* Listen at socket for TCP port, buffer for 5 pending connections */
if( porttype == INPORTTYPE )
listen( sockfd, 5 );
/*
Get the actual assigned (port) address ( netid/hostid/portid )
- netid/hostid from dtm_get_ipaddr(),portid from getsockname().
Netid/hostid and portid is in network byte order.
Assumption - host is not multi-homed.
*/
/* get the port number */
if(getsockname(sockfd,(struct sockaddr *)sockaddr,&sockaddrsize)<0) {
DBGINT( "dtm_socket_init: Unable to get sin_port, errno %d\n", errno );
DTMerrno = DTMSOCK ;
return DTMERROR;
}
/* get the IP address */
if( (sockaddr -> sin_addr.s_addr = dtm_get_ipaddr( buf )) == 0) {
DBGFLOW( "dtm_socket_init: Unable to get s_addr\n" );
DTMerrno = DTMSOCK ;
return DTMERROR ;
}
DBGFLOW( "dtm_socket_init: Verify nethostid/portid\n" );
DBGINT( "dtm_socket_init: Nethostid = %x\n",
ntohl( sockaddr -> sin_addr.s_addr ) );
DBGINT( "dtm_socket_init: Portid = %d \n",
ntohs( sockaddr -> sin_port ) );
DBGINT( "dtm_socket_init: exit sockfd = %d\n", sockfd );
return sockfd ;
}
/*
Function to get sockaddr if portname is specified in
physical portname format ( e.g. "kankakee:9900" )
Return value : 0 on success,
DTMERROR on error
Notes : Algorithm -
1. Check portname format.
2. If logical format, sockaddr.sin_addr.s_addr = 0
3. If physical format, fill in sockaddr.sin_port and
sockaddr.sin_addr.s_addr.
It returns:
sockaddr in network byte order.
*pfLogicalName = TRUE if the port is logical.
*/
#ifdef DTM_PROTOTYPES
int dtm_init_sockaddr(struct sockaddr_in *sockaddr,char *portname,
int *pfLogicalName )
#else
int dtm_init_sockaddr( sockaddr, portname, pfLogicalName )
struct sockaddr_in *sockaddr ;
char *portname ; /* read-only */
int *pfLogicalName;
#endif
{
char *host ;
char *port ;
char lportname[ PNAMELEN ] ;
char hostname[ MAXHOSTNAMELEN ] ;
u_long saddr_temp;
strncpy( lportname, portname, PNAMELEN - 1 );
lportname[ PNAMELEN - 1 ] = '\0' ;
DBGFLOW( "dtm_init_sockaddr called\n" );
if( lportname[0] == ':' ) {
host = NULL ;
port = lportname + 1;
} else {
if( (port = strchr( lportname, ':' )) == NULL ) {
/* Logical format */
DBGSTR( "dtm_init_sockaddr: logical portname %s\n", lportname );
sockaddr -> sin_port = htons( 0 );
sockaddr -> sin_addr.s_addr = htonl(0);
*pfLogicalName = TRUE;
DBGINT( "dtm_init_sockaddr: sin_port = %d\n",
ntohs( sockaddr->sin_port ));
return DTM_OK;
}
*port++ = '\0';
host = lportname;
}
*pfLogicalName = FALSE;
/*
Physical format - hostname is either in dotted decimal
notation ( call ipaddr() ) or direct or missing.
*/
if( host == NULL ) {
gethostname( hostname, sizeof hostname );
host = hostname ;
}
DBGINT( "dtm_init_sockaddr: host %s\n", host );
DBGINT( "dtm_init_sockaddr: port %s\n", port );
if( dtm_parse_ipaddr( host, &saddr_temp ) == DTMERROR) {
struct hostent *hp ;
if( (hp = gethostbyname( host )) == NULL ) {
DBGFLOW("dtm_init_sockaddr: gethostbyname returns error\n");
DTMerrno = DTMHOST ;
return DTMERROR ;
} else {
#ifdef _ARCH_MSDOS
saddr_temp = ((struct in_addr *)(hp->h_addr))->s_addr;
#else
saddr_temp = ((struct in_addr *)(hp->h_addr_list[0]))->s_addr;
#endif
}
}
sockaddr->sin_addr.s_addr = saddr_temp;
/* Fill in port id */
sockaddr -> sin_port = htons((unsigned short)atol( port ));
DBGINT( "dtm_init_sockaddr: nethostid = %x\n",
ntohl( sockaddr -> sin_addr.s_addr ));
DBGINT( "dtm_init_sockaddr: portid = %d\n", ntohs( sockaddr -> sin_port) );
return DTM_OK ;
}

91
libdtm/srv.h Normal file
View File

@@ -0,0 +1,91 @@
#define SRVclass "SRV"
#define SRVid "ID"
#define SRVFunc "FNC"
#define SRVInPort "INPORT"
#define SRVVString "VERSION"
#define SRVVnumber "VERSIONNUM"
#define SRVLock "LOCK"
#define SRV_FUNC_CONNECT 1
#define SRV_FUNC_DISCONNECT 2
#define SRV_FUNC_LOCK 3
#define SRV_FUNC_UNLOCK 4
#define SRV_FUNC_ADD_USER 5
#define SRV_FUNC_REMOVE_USER 6
/* for future use */
#define SRV_FUNC_LOCK_REQUEST 7
/**************************************************************
*
* for a connect message:
* SRVclass SRVid SRV_FUNC_CONNECT SRVInPort SRVVString SRVnumber
* for a disconnect message:
* SRVclass SRVid SRV_FUNC_DISCONNECT SRVInPort
* for a lock:
* SRVclass SRVid SRV_FUNC_LOCK SRVLock
* for a lock:
* SRVclass SRVid SRV_FUNC_UNLOCK SRVLock
* for a user joining:
* SRVclass SRVid SRV_FUNC_ADD_USER SRVInPort
* for a user leaving:
* SRVclass SRVid SRV_FUNC_REMOVE_USER SRVInPort
*/
/* SRVsetClass(char *header,char *title) */
/* SRVcompareClass(char *header,char *title, int maxTitleLength) */
#ifdef DTM1
#define SRVsetClass(h) DTMsetClass((h), SRVclass)
#define SRVcompareClass(h) DTMcompareClass((h), SRVclass)
#else
#define SRVsetClass(h) dtm_set_class((h), SRVclass)
#define SRVcompareClass(h) dtm_compare_class((h), SRVclass)
#endif
/* SRVsetID(char *header,char *id) */
/* SRVgetID(char *header,char *id, int maxIdLength) */
#define SRVsetID(h,s) dtm_set_char(h,SRVid,s)
#define SRVgetID(h,s,l) dtm_get_char(h,SRVid,s,l)
/* SRVsetFunction(char *header,int function) */
/* SRVgetFunction(char *header,int &function) */
/* function is either SRV_FUNC_CONNECT or SRV_FUNC_DISCONNECT */
#define SRVsetFunction(h,i) dtm_set_int(h,SRVFunc,i)
#define SRVgetFunction(h,i) dtm_get_int(h,SRVFunc,i)
/* SRVsetInPort(char *header,char *InPort) */
/* SRVgetInPort(char *header,char *InPort,int maxInPortStringLength) */
#define SRVsetInPort(h,s) dtm_set_char(h,SRVInPort,s)
#define SRVgetInPort(h,s,l) dtm_get_char(h,SRVInPort,s,l)
/* SRVsetVersionString(char *header,char *version) */
/* SRVgetVersionString(char *header,char *version, int maxIdLength) */
#define SRVsetVersionString(h,s) dtm_set_char(h,SRVVString,s)
#define SRVgetVersionString(h,s,l) dtm_get_char(h,SRVVSTRING,s,l)
/* SRVsetVersionNumber(char *header,int number) */
/* SRVgetVersionNumber(char *header,int &number) */
#define SRVsetVersionNumber(h,i) dtm_set_int(h,SRVVnumber,i)
#define SRVgetVersionNumber(h,i) dtm_get_int(h,SRVVnumber,i)
/* SRVsetLockClass(char *header,int mask) */
/* SRVgetLockClass(char *header,int &mask) */
/* 1 is locked 0 is unlocked */
#define SRV_SDS_MASK (1L << 0)
#define SRV_RIS8_MASK (1L << 1)
#define SRV_PAL_MASK (1L << 2)
#define SRV_ANIM_MASK (1L << 3)
#define SRV_COL_MASK (1L << 4)
#define SRV_TXT_MASK (1L << 5)
#define SRV_VDATA_MASK (1L << 6)
#define SRV_MESG_MASK (1L << 7)
#define SRV_COM_MASK (1L << 8)
#define SRV_EXEC_MASK (1L << 9)
#define SRVsetLockClass(h,i) dtm_set_int(h,SRVLock,i)
#define SRVgetLockClass(h,i) dtm_get_int(h,SRVLock,i)

69
libdtm/text.h Normal file
View File

@@ -0,0 +1,69 @@
#define TXTclass "TXT"
#define TXTid "ID"
#define TXTdims "DIM"
#define TXTip "IPT" /* Insertion Point */
#define TXTncr "NCR" /* Number of characters to Replace */
#define TXTra "TRA" /* Text should replace entire file*/
#define TXTsl "TSL" /* Text selection left position */
#define TXTsr "TSR" /* Text selection right position */
/* TXTsetClass(char *header) */
#ifdef DTM1
#define TXTsetClass(h) DTMsetClass((h), TXTclass)
#define TXTcompareClass(h) DTMcompareClass((h), TXTclass)
#else
#define TXTsetClass(h) dtm_set_class((h), TXTclass)
#define TXTcompareClass(h) dtm_compare_class((h), TXTclass)
#endif
/* TXTsetTitle(char *header,char *title) */
/* TXTgetTitle(char *header,char *title, int maxTitleLength) */
#ifdef DTM1
#define TXTsetTitle DTMsetTitle
#define TXTgetTitle DTMgetTitle
#else
#define TXTsetTitle dtm_set_title
#define TXTgetTitle dtm_get_title
#endif
/* TXTsetID(char *header,char *id) */
/* TXTgetID(char *header,char *id, int maxIdLength) */
#define TXTsetID(h,s) dtm_set_char(h,TXTid,s)
#define TXTgetID(h,s,l) dtm_get_char(h,TXTid,s,l)
/* TXTsetInsertionPt(char *header,int InsertionPoint) */
/* TXTsetInsertionPt(char *header,int &InsertionPoint) */
#define TXTsetInsertionPt(h,i) dtm_set_int(h,TXTip,i)
#define TXTgetInsertionPt(h,i) dtm_get_int(h,TXTip,i)
/* TXTsetNumReplace(char *header,int numberToReplace) */
/* if (numberToReplace == 0) then no replace just insert */
/* TXTgetNumReplace(char *header,int &numberToReplace) */
#define TXTsetNumReplace(h,i) dtm_set_int(h,TXTncr,i)
#define TXTgetNumReplace(h,i) dtm_get_int(h,TXTncr,i)
/* TXTsetReplaceAll(char *header) */
/* Boolean TXTshouldReplaceAll(char *header,int garbage) */
#define TXTsetReplaceAll(h) dtm_set_int(h,TXTra,1)
#define TXTshouldReplaceAll(h,i) (dtm_get_int(h,TXTra,&(i)) == -1)?0:1
/* TXTsetDimension(char *header,int numBytes) */
/* TXTgetDimension(char *header,int &numBytes) */
#define TXTsetDimension(h,i) dtm_set_int(h,TXTdims,i)
#define TXTgetDimension(h,i) dtm_get_int(h,TXTdims,i)
/* TXTsetSelectionLeft(char *header, int leftPosition) */
/* TXTsetSelectionLeft(char *header, int &leftPosition) */
#define TXTsetSelectionLeft(h,i) dtm_set_int(h,TXTsl,i)
#define TXTgetSelectionLeft(h,i) dtm_get_int(h,TXTsl,i)
/* TXTsetSelectionRight(char *header, int rightPosition) */
/* TXTsetSelectionRight(char *header, int &rightPosition) */
#define TXTsetSelectionRight(h,i) dtm_set_int(h,TXTsr,i)
#define TXTgetSelectionRight(h,i) dtm_get_int(h,TXTsr,i)
#define TXTheaderLength dtm_header_length
#define TXTHL(h) dtm_header_length

95
libdtm/uio.h Normal file
View File

@@ -0,0 +1,95 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/*********************************************************************
**
* $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/uio.h,v 1.3 1995/01/12 02:33:40 spowers Exp $
**
**********************************************************************/
/*
* Revision 1.1.1.1 1993/07/04 00:03:15 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:49 marca
* I think I got it now.
*
* Revision 1.2 92/04/30 20:27:37 jplevyak
* Changed Version to 2.3
*
* Revision 1.1 1992/03/06 22:51:22 jplevyak
* Initial revision
*
*/
#ifndef UIO_H
#define UIO_H
#include <sys\types.h>
typedef char far *caddr_t;
struct iovec {
caddr_t iov_base;
long int iov_len;
};
struct uio {
struct iovec *uio_iov;
long int uio_iovcnt;
off_t uio_offset;
long int uio_segflg;
short uio_fmode;
int uio_resid;
};
struct msghdr {
caddr_t msg_name; /* optional address */
long int msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter/gather array */
long int msg_iovlen; /* # elements in msg_iov */
caddr_t msg_accrights; /* access rights sent/received */
long int msg_accrightslen;
};
#ifndef EFAULT
#define EFAULT 14 /* for UNIX compability */
#endif
enum uio_rw { UIO_READ, UIO_WRITE };
/*
* Segment flag values (should be enum).
*/
#define UIO_USERSPACE 0 /* from user data space */
#define UIO_SYSSPACE 1 /* from system space */
#define UIO_USERISPACE 2 /* from user I space */
#if defined(__STDC__) | defined (_STDC_)
extern long int readv(int ,struct iovec *,int );
extern long int writev(int ,struct iovec *,int );
extern long int recvmsg(int ,struct msghdr *,int );
extern long int sendmsg(int ,struct msghdr *,int );
#endif /* defined(__STDC__) */
#endif /* UIO_H */

561
libdtm/vaxcvt.c Normal file
View File

@@ -0,0 +1,561 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include "dtmint.h"
#include "debug.h"
#define swap(x,y) x ^= y; y ^= x; x ^= y
union float_uint_uchar {
float f;
int i;
unsigned char c[4];
};
union double_uint_uchar {
double f;
int i[2];
unsigned char c[8];
};
#ifdef DTM_PROTOTYPES
static int dtm_char(int mode,char *buf,int size)
#else
static int dtm_char(mode, buf, size)
int mode, size;
char *buf;
#endif
{
DBGFLOW("# dtm_char called.\n");
return size;
}
#ifdef DTM_PROTOTYPES
static int dtm_short(int mode,char *buf,int size)
#else
static int dtm_short(mode, buf, size)
int mode, size;
char *buf;
#endif
{
int i;
DBGFLOW("# dtm_short called.\n");
if (mode == DTMLOCAL) size /= 2;
if (buf != NULL) {
for (i=0; i<size; i++) {
swap(*buf, *(buf+1));
buf += 2;
}
}
return ((mode == DTMLOCAL) ? size : (size * 2));
}
#ifdef DTM_PROTOTYPES
static int dtm_int(int mode,char *buf,int size)
#else
static int dtm_int(mode, buf, size)
int mode, size;
char *buf;
#endif
{
int i;
DBGFLOW("# dtm_int called.\n");
if (mode == DTMLOCAL) size /= 4;
if (buf != NULL) {
for (i=0; i<size; i++) {
swap(*buf, *(buf+3));
swap(*(buf+1), *(buf+2));
buf += 4;
}
}
return ((mode == DTMLOCAL) ? size : (size * 4));
}
#ifdef DTM_PROTOTYPES
static int dtm_float(int mode,char *buf,int size)
#else
static int dtm_float(mode, buf, size)
int mode, size;
char *buf;
#endif
{
int i;
DBGFLOW("# dtm_float called.\n");
if (mode == DTMLOCAL) {
size >>= 2;
if (buf != NULL) DTMVieeeF2vaxF(buf, size);
return (size);
} else {
if (buf != NULL) DTMVvaxF2ieeeF(buf, size);
return (size << 2);
}
}
#ifdef DTM_PROTOTYPES
static int dtm_double(int mode,char *buf,int size)
#else
static int dtm_double(mode, buf, size)
int mode, size;
char *buf;
#endif
{
DBGFLOW("# dtm_flt64 called.\n");
if (mode == DTMLOCAL) {
size >>= 3;
if (buf != NULL) DTMVieeeD2vaxD(buf, size);
return (size);
} else {
if (buf != NULL) DTMVvaxD2ieeeD(buf, size);
return (size << 3);
}
}
#ifdef DTM_PROTOTYPES
static int dtm_complex(int mode,char *buf,int size)
#else
static int dtm_complex(mode, buf, size)
int mode, size;
char *buf;
#endif
{
int i;
DBGFLOW("# dtm_complex called.\n");
if (mode == DTMLOCAL) {
size >>= 2;
if (buf != NULL) DTMVieeeF2vaxF(buf, size);
return (size >> 1);
} else {
size <<= 1;
if (buf != NULL) DTMVvaxF2ieeeF(buf, size);
return (size << 2);
}
}
#ifdef DTM_PROTOTYPES
static int dtm_triplet(int mode,char *buf,int size)
#else
static int dtm_triplet(mode, buf, size)
int mode, size;
char *buf;
#endif
{
int i;
DBGFLOW("# dtm_triplet called.\n");
if (mode == DTMLOCAL) size /= 16;
if (buf != NULL) {
for (i=0; i<size; i++) {
swap(*buf, *(buf+3));
swap(*(buf+1), *(buf+2));
buf += 4;
if (mode == DTMLOCAL) DTMVieeeF2vaxF(buf, 3);
else DTMVvaxF2ieeeF(buf, 3);
buf += 12;
}
}
return ((mode == DTMLOCAL) ? size : (size * 16));
}
/* conversion routine function table */
int (*DTMconvertRtns[])() = {
dtm_char,
dtm_short,
dtm_int,
dtm_float,
dtm_double,
dtm_complex,
dtm_triplet
};
#ifdef DTM_PROTOTYPES
int DTMVvaxF2ieeeF(union float_uint_uchar f[],int size)
#else
int DTMVvaxF2ieeeF(f, size)
union float_uint_uchar f[];
int size;
#endif
{
register int i;
register unsigned char exp;
unsigned char c0, c1, c2, c3;
for (i=0; i<size; i++)
{
c0 = f[i].c[0];
c1 = f[i].c[1];
c2 = f[i].c[2];
c3 = f[i].c[3];
exp = (c1 << 1) | (c0 >> 7); /* extract exponent */
if (!exp && !c1) f[i].i = 0; /* zero value */
else if (exp>2) { /* normal value */
f[i].c[0] = c1 - 1; /* subtracts 2 from exponent */
/* copy mantissa, LSB of exponent */
f[i].c[1] = c0;
f[i].c[2] = c3;
f[i].c[3] = c2;
}
else if (exp) { /* denormalized number */
register int shft;
f[i].c[0] = c1 & 0x80; /* keep sign, zero exponent */
shft = 3 - exp;
/* shift original mant by 1 or 2 to get denormalized mant */
/* prefix mantissa with '1'b or '01'b as appropriate */
f[i].c[1] = ((c0 & 0x7f) >> shft) | (0x10 << exp);
f[i].c[2] = (c0 << (8-shft)) | (c3 >> shft);
f[i].c[3] = (c3 << (8-shft)) | (c2 >> shft);
}
else { /* sign=1 -> infinity or NaN */
f[i].c[0] = 0xff; /* set exp to 255 */
/* copy mantissa */
f[i].c[1] = c0 | 0x80; /* LSB of exp = 1 */
f[i].c[2] = c3;
f[i].c[3] = c2;
}
}
return(0);
}
#ifdef DTM_PROTOTYPES
int DTMVieeeF2vaxF(union float_uint_uchar f[],int size)
#else
int DTMVieeeF2vaxF(f, size)
union float_uint_uchar f[];
int size;
#endif
{
register int i;
register unsigned char exp;
unsigned char c0, c1, c2, c3;
for (i=0; i<size; i++)
{
c0 = f[i].c[0];
c1 = f[i].c[1];
c2 = f[i].c[2];
c3 = f[i].c[3];
exp = (c0 << 1) | (c1 >> 7); /* extract exponent */
if (exp) { /* non-zero exponent */
/* copy mantissa, last bit of exponent */
f[i].c[0] = c1;
f[i].c[2] = c3;
f[i].c[3] = c2;
if (exp<254) /* normal value */
f[i].c[1] = c0 + 1; /* actually adds two to exp */
else { /* infinity or NaN */
if (exp==254) /* unrepresentable - OFL */
f[i].i = 0; /* set mant=0 for overflow */
f[i].c[0] &= 0x7f; /* set last bit of exp to 0 */
f[i].c[1] = 0x80; /* sign=1 exp=0 -> OFL or NaN */
}
}
else if (c1 & 0x60) { /* denormalized value */
register int shft;
shft = (c1 & 0x40) ? 1 : 2; /* shift needed to normalize */
/* shift mantissa */
/* note last bit of exp set to 1 implicitly */
f[i].c[0] = (c1 << shft) | (c2 >> (8-shft));
f[i].c[3] = (c2 << shft) | (c3 >> (8-shft));
f[i].c[2] = c3 << shft;
f[i].c[1] = (c0 & 0x80); /* sign */
if (shft==1) { /* set exp to 2 */
f[i].c[1] |= 0x01;
f[i].c[0] &= 0x7f; /* set LSB of exp to 0 */
}
}
else f[i].i = 0; /* zero */
}
return(0);
}
#ifdef DTM_PROTOTYPES
int DTMVvaxD2ieeeD(union double_uint_uchar d[],int size)
#else
int DTMVvaxD2ieeeD(d, size)
union double_uint_uchar d[];
int size;
#endif
/* GFLOAT is much closer match to IEEE than DFLOAT */
/* but there is no support for GFLOAT under f77 */
/* and both cc and vcc don't work right with GLOAT */
{
register int i;
register int exp;
unsigned char c0, c1, c2, c3, c4, c5, c6, c7;
for (i=0; i<size; i++)
{
c0 = d[i].c[0];
c1 = d[i].c[1];
c2 = d[i].c[2];
c3 = d[i].c[3];
c4 = d[i].c[4];
c5 = d[i].c[5];
c6 = d[i].c[6];
c7 = d[i].c[7];
exp = (((c1 & 0x7f) << 1) | (c0 >> 7)); /* extract exponent */
if (!exp && !c1) { /* zero value */
d[i].i[0] = 0;
d[i].i[1] = 0;
} else {
if (exp) { /* normal value */
exp += 894;
d[i].c[0] = (c1 & 0x80) | (exp >> 4);
d[i].c[1] = ((exp & 0xf) << 4) | (c0 >> 3);
} else { /* sign=1 -> infinity or NaN */
d[i].c[0] = 0xff; /* set exp to 2047 */
d[i].c[1] = 0xf0 | (c0 >> 3); /* and copy mantissa */
}
d[i].c[2] = (c3 >> 3) | (c0 << 5);
d[i].c[3] = (c2 >> 3) | (c3 << 5);
d[i].c[4] = (c5 >> 3) | (c2 << 5);
d[i].c[5] = (c4 >> 3) | (c5 << 5);
d[i].c[6] = (c7 >> 3) | (c4 << 5);
d[i].c[7] = (c6 >> 3);
}
}
return(0);
}
#ifdef DTM_PROTOTYPES
int DTMVieeeD2vaxD(union double_uint_uchar d[],int size)
#else
int DTMVieeeD2vaxD(d, size)
union double_uint_uchar d[];
int size;
#endif
/* GFLOAT is much closer match to IEEE than DFLOAT */
/* but there is no support for GFLOAT under f77 */
/* and both cc and vcc don't work right with GLOAT */
{
register int i;
register int exp;
unsigned char c0, c1, c2, c3, c4, c5, c6, c7;
for (i=0; i<size; i++)
{
c0 = d[i].c[0];
c1 = d[i].c[1];
c2 = d[i].c[2];
c3 = d[i].c[3];
c4 = d[i].c[4];
c5 = d[i].c[5];
c6 = d[i].c[6];
c7 = d[i].c[7];
exp = (((c0 & 0x7f) << 4) | (c1 >> 4)) - 894; /* extract exponent */
if (exp > 0) { /* non-zero exponent */
/* copy mantissa, last bit of exponent */
d[i].c[0] = (c1 << 3) | (c2 >> 5);
d[i].c[2] = (c3 << 3) | (c4 >> 5);
d[i].c[3] = (c2 << 3) | (c3 >> 5);
d[i].c[4] = (c5 << 3) | (c6 >> 5);
d[i].c[5] = (c4 << 3) | (c5 >> 5);
d[i].c[6] = (c7 << 3);
d[i].c[7] = (c6 << 3) | (c7 >> 5);
if (exp<=255) /* normal value */
d[i].c[1] = (c0 & 0x80) | (exp >> 1);
else { /* infinity or NaN */
if (exp != 1153) { /* unrepresentable - OFL */
d[i].i[0] = 0; /* set mant=0 for overflow */
d[i].i[1] = 0;
}
d[i].c[0] &= 0x7f; /* set last bit of exp to 0 */
d[i].c[1] = 0x80; /* sign=1 exp=0 -> OFL or NaN */
}
}
/* Some serious shifting of mantissa needed for exp values <= 0 */
else {
d[i].i[0] = 0; /* zero */
d[i].i[1] = 1;
}
}
return(0);
}
#ifdef DTM_PROTOTYPES
int DTMVvaxG2ieeeD(union double_uint_uchar g[],int size)
#else
int DTMVvaxG2ieeeD(g, size)
union double_uint_uchar g[];
int size;
#endif
{
register int i;
register int exp;
unsigned char c0, c1, c2, c3, c4, c5, c6, c7;
for (i=0; i<size; i++)
{
c0 = g[i].c[0];
c1 = g[i].c[1];
c2 = g[i].c[2];
c3 = g[i].c[3];
c4 = g[i].c[4];
c5 = g[i].c[5];
c6 = g[i].c[6];
c7 = g[i].c[7];
exp = ((c1 & 0x7f) << 4) | (c0 >> 4); /* extract exponent */
if (!exp && !c1) { /* zero value */
g[i].i[0] = 0;
g[i].i[1] = 0;
}
else if (exp>2) { /* normal value */
exp -= 2;
g[i].c[0] = (c1 & 0x80) | (exp >> 4);
g[i].c[1] = (c0 & 0x0f) | ((exp & 0x0f) << 4);
g[i].c[2] = c3;
g[i].c[3] = c2;
g[i].c[4] = c5;
g[i].c[5] = c4;
g[i].c[6] = c7;
g[i].c[7] = c6;
}
else if (exp) { /* denormalized number */
register int shft;
g[i].c[0] = c1 & 0x80; /* keep sign, zero exponent */
shft = 3 - exp;
/* shift original mant by 1 or 2 to get denormalized mant */
/* prefix mantissa with '1'b or '01'b as appropriate */
g[i].c[1] = ((c0 & 0x0f) >> shft) | (0x02 << exp);
g[i].c[2] = (c0 << (8-shft)) | (c3 >> shft);
g[i].c[3] = (c3 << (8-shft)) | (c2 >> shft);
g[i].c[4] = (c2 << (8-shft)) | (c5 >> shft);
g[i].c[5] = (c5 << (8-shft)) | (c4 >> shft);
g[i].c[6] = (c4 << (8-shft)) | (c7 >> shft);
g[i].c[7] = (c7 << (8-shft)) | (c6 >> shft);
}
else { /* sign=1 -> infinity or NaN */
g[i].c[0] = 0xff; /* set exp to 2047 */
/* copy mantissa */
g[i].c[1] = c0 | 0xf0; /* LSBs of exp = 1 */
g[i].c[2] = c3;
g[i].c[3] = c2;
g[i].c[4] = c5;
g[i].c[5] = c4;
g[i].c[6] = c7;
g[i].c[7] = c6;
}
}
return(0);
}
#ifdef DTM_PROTOTYPES
int DTMVieeeD2vaxG(union double_uint_uchar g[],int size)
#else
int DTMVieeeD2vaxG(g, size)
union double_uint_uchar g[];
int size;
#endif
{
register int i;
register int exp;
unsigned char c0, c1, c2, c3, c4, c5, c6, c7;
for (i=0; i<size; i++)
{
c0 = g[i].c[0];
c1 = g[i].c[1];
c2 = g[i].c[2];
c3 = g[i].c[3];
c4 = g[i].c[4];
c5 = g[i].c[5];
c6 = g[i].c[6];
c7 = g[i].c[7];
exp = (((c0 & 0x7f) << 4) | (c1 >> 4)) + 2;/* extract exponent */
if (exp > 2) { /* non-zero exponent */
/* copy mantissa */
g[i].c[2] = c3;
g[i].c[3] = c2;
g[i].c[4] = c5;
g[i].c[5] = c4;
g[i].c[6] = c7;
g[i].c[7] = c6;
if (exp<=2047) { /* normal value */
g[i].c[0] = (c1 & 0x0f) | ((exp & 0x0f) << 4);
g[i].c[1] = (c0 & 0x80) | (exp >> 4);
} else { /* infinity or NaN */
if (exp==2048) { /* unrepresentable - OFL */
g[i].i[0] = 0; /* set mant=0 for overflow */
g[i].i[1] = 0;
}
g[i].c[0] &= 0x0f; /* set last bit of exp to 0 */
g[i].c[1] = 0x80; /* sign=1 exp=0 -> OFL or NaN */
}
}
else if (c1 & 0x0c) { /* denormalized value */
register int shft;
shft = (c1 & 0x08) ? 1 : 2; /* shift needed to normalize */
/* shift mantissa */
/* note last bit of exp set to 1 implicitly */
g[i].c[0] = (c1 << shft) | (c2 >> (8-shft));
g[i].c[1] = (c0 & 0x80); /* sign */
g[i].c[2] = (c3 << shft) | (c4 >> (8-shft));
g[i].c[3] = (c2 << shft) | (c3 >> (8-shft));
g[i].c[4] = (c5 << shft) | (c6 >> (8-shft));
g[i].c[5] = (c4 << shft) | (c5 >> (8-shft));
g[i].c[6] = c7 << shft;
g[i].c[7] = (c6 << shft) | (c7 >> (8-shft));
g[i].c[1] = (c0 & 0x80); /* sign */
if (shft==1) { /* set exp to 2 */
g[i].c[1] |= 0x20;
g[i].c[1] &= 0xef; /* set LSB of exp to 0 */
}
}
else {
g[i].i[0] = 0; /* zero */
g[i].i[1] = 1;
}
}
return(0);
}

79
libdtm/vdata.c Normal file
View File

@@ -0,0 +1,79 @@
#include <stdio.h>
#include "dtm.h"
#include "vdata.h"
#ifndef MALLOC
#define MALLOC(x) malloc(x)
#define FREE(x) free(x)
#endif
int VDATAsetPath(header,magicPath,pathLength)
char *header;
VdataPathElement **magicPath;
int pathLength;
{
int x;
char pathString[DTM_MAX_HEADER];
char idString[DTM_MAX_HEADER];
char buff[80];
pathString[0]='\0';
for (x=0; x < pathLength; x++) {
strcat(pathString,magicPath[x]->nodeName);
strcat(pathString," ");
}
idString[0]='\0';
for (x=0; x < pathLength; x++) {
sprintf(buff,"%d ",magicPath[x]->nodeID);
strcat(idString,buff);
}
dtm_set_int(header,VDATApathLength,pathLength);
dtm_set_char(header,VDATApathName,pathString);
dtm_set_char(header,VDATApathID,idString);
return(1);
}
int VDATAgetPath(header,magicPath,pathLength)
char *header;
VdataPathElement **magicPath;
int *pathLength;
{
char pathString[DTM_MAX_HEADER];
char pathID[DTM_MAX_HEADER];
int numPath;
int integer[10];
char pathStep[DTM_MAX_HEADER];
char *ptr;
int x;
dtm_get_int(header,VDATApathLength,&numPath);
dtm_get_char(header,VDATApathName,pathString,DTM_MAX_HEADER);
dtm_get_char(header,VDATApathID,pathID,DTM_MAX_HEADER);
numPath = (numPath > *pathLength)? (*pathLength) : numPath;
*pathLength = numPath;
ptr = pathID;
for (x = 0; x < numPath; x++) {
sscanf(ptr,"%s ",integer);
ptr += (strlen(ptr) + 1);
magicPath[x]->nodeID = atoi(integer);
}
ptr = pathString;
for (x = 0; x < numPath; x++) {
sscanf(ptr,"%s ",pathStep);
ptr += (strlen(ptr) + 1);
if (!(magicPath[x]->nodeName = (char *)
MALLOC( strlen(pathStep) + 1))) {
fprintf(stderr,"VDATAgetPath: Out of Memory\n");
return(-1);
}
strcpy(magicPath[x]->nodeName,pathStep);
}
return(1);
}

49
libdtm/vdata.h Normal file
View File

@@ -0,0 +1,49 @@
#ifndef VDATA_DTM_INCLUDE_BEFORE
#define VDATA_DTM_INCLUDE_BEFORE
#define VDATAclass "VDATA"
#define VDATAid "ID"
#define VDATApathLength "PLEN"
#define VDATApathName "PNAME"
#define VDATApathID "PID"
#define VDATAnodeID "NID"
#define VDATAnodeName "NNAME"
#define VDATAfield "FIELD"
#define VDATAnumRec "NREC"
#define VDATAnumElem "NELEM"
#define VDATAsetClass(h) dtm_set_class(h,VDATAclass)
#define VDATAcompareClass(h) dtm_compare_class(h,VDATAclass)
#define VDATAsetTitle dtm_set_title
#define VDATAgetTitle dtm_get_title
#define VDATAsetID(h,s) dtm_set_char(h,VDATAid,s)
#define VDATAgetID(h,s,l) dtm_get_char(h,VDATAid,s,l)
#define VDATAsetType dtm_set_type
#define VDATAgetType dtm_get_type
#define VDATAgetPathLength(h,i) dtm_get_int(h,VDATApathLength,i)
#define VDATAsetNodeID(h,i) dtm_set_int(h,VDATAnodeID,i);
#define VDATAgetNodeID(h,i) dtm_get_int(h,VDATAnodeID,i);
#define VDATAsetNodeName(h,s) dtm_set_char(h,VDATAnodeName,s)
#define VDATAgetNodeName(h,s,l) dtm_get_char(h,VDATAnodeName,s,l)
#define VDATAsetField(h,s) dtm_set_char(h,VDATAfield,s)
#define VDATAgetField(h,s,l) dtm_get_char(h,VDATAfield,s,l)
#define VDATAsetNumRecords(h,i) dtm_set_int(h,VDATAnumRec,i);
#define VDATAgetNumRecords(h,i) dtm_get_int(h,VDATAnumRec,i);
#define VDATAsetNumElements(h,i) dtm_set_int(h,VDATAnumElem,i);
#define VDATAgetNumElements(h,i) dtm_get_int(h,VDATAnumElem,i);
typedef struct {
int nodeID;
char *nodeName;
} VdataPathElement;
#endif /* VDATA_DTM_INCLUDE_BEFORE */

162
libdtm/x.c Normal file
View File

@@ -0,0 +1,162 @@
/*****************************************************************************
*
* NCSA DTM version 2.3
* May 1, 1992
*
* NCSA DTM Version 2.3 source code and documentation are in the public
* domain. Specifically, we give to the public domain all rights for future
* licensing of the source code, all resale rights, and all publishing rights.
*
* We ask, but do not require, that the following message be included in all
* derived works:
*
* Portions developed at the National Center for Supercomputing Applications at
* the University of Illinois at Urbana-Champaign.
*
* THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
* SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
* WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
*
*****************************************************************************/
/***************************************************************************
**
** x.c Contains the DTM interface to X.
**
***************************************************************************/
/*
* $Log: x.c,v $
* Revision 1.1.1.1 1995/01/11 00:03:04 alanb
* New CVS source tree, Mosaic 2.5 beta 4
*
* Revision 2.5 1994/12/29 23:40:42 alanb
* I'm committing with a new symbolic revision number.
*
* Revision 1.1.1.1 1994/12/28 21:37:32 alanb
*
* Revision 1.1.1.1 1993/07/04 00:03:16 marca
* Mosaic for X version 2 distribution
*
* Revision 1.1 1993/01/18 21:50:54 marca
* I think I got it now.
*
* Revision 1.4 92/05/05 22:27:50 jplevyak
* Corrected X interface code.
*
* Revision 1.3 1992/05/04 22:05:55 jplevyak
* Declare DTMaddInput external
*
* Revision 1.2 1992/04/30 20:25:27 jplevyak
* Changed Version to 2.3.
*
* Revision 1.1 1992/04/29 22:20:16 jplevyak
* Initial revision
*
*/
#include <X11/Intrinsic.h>
#include "arch.h"
#include "dtmint.h"
#include "debug.h"
#if XtInputReadMask != (1L<<0)
Balk - you must change the definition in dtm.c near
the function dtm_set_Xcallback
#endif
#ifdef DTM_PROTOTYPES
void dtm_handle_new_in( caddr_t client_data, int * fd, XtInputId * id)
#else
void dtm_handle_new_in( client_data, fd, id )
caddr_t client_data;
int * fd;
XtInputId * id;
#endif
{
int p = (int) client_data;
DTMPORT * pp = DTMpt[p];
dtm_accept_read_connections( pp, FALSE );
}
#ifdef DTM_PROTOTYPES
void dtm_handle_new_out( caddr_t client_data, int * fd, XtInputId * id)
#else
void dtm_handle_new_out( client_data, fd, id )
caddr_t client_data;
int * fd;
XtInputId * id;
#endif
{
int p = (int) client_data;
DTMPORT * pp = DTMpt[p];
int p_ext = p;
dtm_map_port_external( &p_ext );
pp->Xcallback( pp->Xcallback_data, &p_ext, id );
}
#ifdef DTM_PROTOTYPES
/*
STATIC FUNCTION PROTOTYPES
*/
#endif
/*
DTMaddInput()
Add X style input handlers for DTM ports. Currently only
read ports are handled.
condition
The read/write portions of the condition value are ignored
in favor of the Read/Write quality of the port. Any operating-
system-dependant options should be included here.
proc
The user must provide an X style callback which will be called
when data has arrived at an input port. New connections are
automatically handled.
*/
#ifdef DTM_PROTOTYPES
int DTMaddInput( int p_ext, caddr_t condition,
XtInputCallbackProc proc, caddr_t client_data )
#else
int DTMaddInput( p_ext, condition, proc, client_data )
int p_ext;
caddr_t condition;
XtInputCallbackProc proc;
caddr_t client_data;
#endif
{
reg DTMPORT *pp;
reg Inport *inp;
reg int p;
DTMerrno = DTMNOERR;
CHECK_ERR( p = dtm_map_port_internal( p_ext ));
pp = DTMpt[p];
pp->Xcallback_data = client_data;
pp->Xcallback = proc;
pp->XaddInput = (XtInputCallbackProc) XtAddInput;
pp->XremoveInput = (XtInputCallbackProc) XtRemoveInput;
if ( pp->porttype == INPORTTYPE ) {
/*
Set up callback for new connections
*/
XtAddInput( pp->sockfd, XtInputReadMask, dtm_handle_new_in,
(caddr_t) p );
FOR_EACH_IN_PORT( inp, pp ) {
inp->XinputId = XtAddInput( inp->fd, XtInputReadMask,
dtm_handle_in, (caddr_t) p );
}
} else {
XtAddInput( pp->sockfd, XtInputReadMask, dtm_handle_new_out,
(caddr_t) p );
}
return DTM_OK;
}