start adding triumf mud-file-format support. For a few days musrfit will be a bit frail.
This commit is contained in:
parent
dc367a89a5
commit
dcb77c2e48
37
configure.ac
37
configure.ac
@ -1,5 +1,5 @@
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT(musrfit, 0.5.1, andreas.suter@psi.ch)
|
||||
AC_INIT(musrfit, 0.5.2, andreas.suter@psi.ch)
|
||||
AC_CONFIG_AUX_DIR(admin)
|
||||
|
||||
dnl -----------------------------------------------
|
||||
@ -10,11 +10,12 @@ MUSR_PROGRAM_NAME=musrfit
|
||||
MUSR_LIBRARY_NAME=PMusr
|
||||
LEM_LIBRARY_NAME=TLemRunHeader
|
||||
PSIBIN_LIBRARY_NAME=Class_MuSR_PSI
|
||||
MUD_LIBRARY_NAME=mud
|
||||
|
||||
#release versioning
|
||||
MUSR_MAJOR_VERSION=0
|
||||
MUSR_MINOR_VERSION=5
|
||||
MUSR_MICRO_VERSION=1
|
||||
MUSR_MICRO_VERSION=2
|
||||
|
||||
#release versioning
|
||||
LEM_MAJOR_VERSION=1
|
||||
@ -26,6 +27,11 @@ PSIBIN_MAJOR_VERSION=0
|
||||
PSIBIN_MINOR_VERSION=0
|
||||
PSIBIN_MICRO_VERSION=0
|
||||
|
||||
#release versioning
|
||||
MUD_MAJOR_VERSION=0
|
||||
MUD_MINOR_VERSION=0
|
||||
MUD_MICRO_VERSION=0
|
||||
|
||||
#API version
|
||||
MUSR_API_VERSION=MUSR_MAJOR_VERSION.MUSR_MINOR_VERSION
|
||||
AC_SUBST(MUSR_API_VERSION)
|
||||
@ -36,9 +42,13 @@ AC_SUBST(LEM_API_VERSION)
|
||||
PSIBIN_API_VERSION=PSIBIN_MAJOR_VERSION.PSIBIN_MINOR_VERSION
|
||||
AC_SUBST(PSIBIN_API_VERSION)
|
||||
|
||||
MUD_API_VERSION=MUD_MAJOR_VERSION.MUD_MINOR_VERSION
|
||||
AC_SUBST(MUD_API_VERSION)
|
||||
|
||||
#shared library versioning
|
||||
LEM_LIBRARY_VERSION=1:5:0
|
||||
PSIBIN_LIBRARY_VERSION=0:0:0
|
||||
MUD_LIBRARY_VERSION=0:0:0
|
||||
MUSR_LIBRARY_VERSION=0:5:0
|
||||
# | | |
|
||||
# +------+ | +---+
|
||||
@ -55,17 +65,24 @@ MUSR_LIBRARY_VERSION=0:5:0
|
||||
AC_SUBST(MUSR_LIBRARY_VERSION)
|
||||
AC_SUBST(LEM_LIBRARY_VERSION)
|
||||
AC_SUBST(PSIBIN_LIBRARY_VERSION)
|
||||
AC_SUBST(MUD_LIBRARY_VERSION)
|
||||
|
||||
PACKAGE=$MUSR_PROGRAM_NAME
|
||||
AC_SUBST(MUSR_LIBRARY_NAME)
|
||||
AC_SUBST(LEM_LIBRARY_NAME)
|
||||
AC_SUBST(PSIBIN_LIBRARY_NAME)
|
||||
AC_SUBST(MUD_LIBRARY_NAME)
|
||||
|
||||
PSIBIN_VERSION=$PSIBIN_MAJOR_VERSION.$PSIBIN_MINOR_VERSION.$PSIBIN_MICRO_VERSION
|
||||
PSIBIN_RELEASE=$PSIBIN_MAJOR_VERSION.$PSIBIN_MINOR_VERSION
|
||||
AC_SUBST(PSIBIN_RELEASE)
|
||||
AC_SUBST(PSIBIN_VERSION)
|
||||
|
||||
MUD_VERSION=$MUD_MAJOR_VERSION.$MUD_MINOR_VERSION.$MUD_MICRO_VERSION
|
||||
MUD_RELEASE=$MUD_MAJOR_VERSION.$MUD_MINOR_VERSION
|
||||
AC_SUBST(MUD_RELEASE)
|
||||
AC_SUBST(MUD_VERSION)
|
||||
|
||||
LEM_VERSION=$LEM_MAJOR_VERSION.$LEM_MINOR_VERSION.$LEM_MICRO_VERSION
|
||||
LEM_RELEASE=$LEM_MAJOR_VERSION.$LEM_MINOR_VERSION
|
||||
AC_SUBST(LEM_RELEASE)
|
||||
@ -241,7 +258,7 @@ AC_CHECK_FILE([${ROOTINCDIR}/../include/Minuit2/MnMinimize.h], AC_MSG_RESULT([Mi
|
||||
|
||||
|
||||
dnl -----------------------------------------------
|
||||
dnl Set some paths and flags for PMusr and TLemRunHeader and Class_MuSR_PSI
|
||||
dnl Set some paths and flags for PMusr, TLemRunHeader, Class_MuSR_PSI and mud
|
||||
dnl -----------------------------------------------
|
||||
|
||||
SRCDIR="$(pwd)"
|
||||
@ -252,6 +269,12 @@ PSIBIN_CFLAGS="-I${PSIBIN_SRCDIR}"
|
||||
AC_SUBST(PSIBIN_LIBS)
|
||||
AC_SUBST(PSIBIN_CFLAGS)
|
||||
|
||||
MUD_SRCDIR="${SRCDIR}/src/external/mud/src"
|
||||
MUD_LIBS="-L${MUD_SRCDIR} -l${MUD_LIBRARY_NAME}"
|
||||
MUD_CFLAGS="-I${MUD_SRCDIR}"
|
||||
AC_SUBST(MUD_LIBS)
|
||||
AC_SUBST(MUD_CFLAGS)
|
||||
|
||||
LEM_SRCDIR="${SRCDIR}/src/external/TLemRunHeader"
|
||||
LEM_LIBS="-L${LEM_SRCDIR} -l${LEM_LIBRARY_NAME}"
|
||||
LEM_CFLAGS="-I${LEM_SRCDIR}"
|
||||
@ -271,6 +294,7 @@ dnl -----------------------------------------------
|
||||
LOCAL_BIN_CXXFLAGS="-Wall -Wno-trigraphs"
|
||||
LOCAL_LIB_CXXFLAGS="${LOCAL_BIN_CXXFLAGS}"
|
||||
LOCAL_PSIBIN_LIB_CXXFLAGS="${LOCAL_LIB_CXXFLAGS}"
|
||||
LOCAL_MUD_LIB_CXXFLAGS="${LOCAL_LIB_CXXFLAGS}"
|
||||
LOCAL_BIN_LDFLAGS=
|
||||
LOCAL_LIB_LDFLAGS=
|
||||
|
||||
@ -279,6 +303,7 @@ case "$host" in
|
||||
LOCAL_BIN_CXXFLAGS="${LOCAL_BIN_CXXFLAGS}"
|
||||
LOCAL_LIB_CXXFLAGS="${LOCAL_BIN_CXXFLAGS} -D_DLL"
|
||||
LOCAL_PSIBIN_LIB_CXXFLAGS="${LOCAL_LIB_CXXFLAGS} -D_WIN32GCC"
|
||||
LOCAL_MUD_LIB_CXXFLAGS="${LOCAL_LIB_CXXFLAGS}"
|
||||
LOCAL_BIN_LDFLAGS="${LOCAL_BIN_LDFLAGS} -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
|
||||
LOCAL_LIB_LDFLAGS="-no-undefined ${LOCAL_BIN_LDFLAGS} -Wl,--export-all-symbols"
|
||||
;;
|
||||
@ -287,6 +312,7 @@ esac
|
||||
AC_SUBST(LOCAL_BIN_CXXFLAGS)
|
||||
AC_SUBST(LOCAL_LIB_CXXFLAGS)
|
||||
AC_SUBST(LOCAL_PSIBIN_LIB_CXXFLAGS)
|
||||
AC_SUBST(LOCAL_MUD_LIB_CXXFLAGS)
|
||||
AC_SUBST(LOCAL_BIN_LDFLAGS)
|
||||
AC_SUBST(LOCAL_LIB_LDFLAGS)
|
||||
|
||||
@ -325,5 +351,8 @@ AC_CONFIG_FILES([Makefile \
|
||||
src/external/TLemRunHeader/TLemRunHeader.pc \
|
||||
src/external/MuSR_software/Makefile \
|
||||
src/external/MuSR_software/Class_MuSR_PSI/Makefile \
|
||||
src/external/MuSR_software/Class_MuSR_PSI/Class_MuSR_PSI.pc])
|
||||
src/external/MuSR_software/Class_MuSR_PSI/Class_MuSR_PSI.pc \
|
||||
src/external/mud/Makefile \
|
||||
src/external/mud/src/Makefile \
|
||||
src/external/mud/src/mud.pc])
|
||||
AC_OUTPUT
|
||||
|
@ -65,7 +65,7 @@ dict_cpp_sources = \
|
||||
include_HEADERS = $(h_sources)
|
||||
noinst_HEADERS = $(h_linkdef) $(dict_h_sources)
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/include $(PSIBIN_CFLAGS) $(LEM_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS)
|
||||
INCLUDES = -I$(top_srcdir)/src/include $(PSIBIN_CFLAGS) $(MUD_CFLAGS) $(LEM_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS)
|
||||
AM_CXXFLAGS = $(LOCAL_LIB_CXXFLAGS)
|
||||
|
||||
BUILT_SOURCES = $(dict_cpp_sources) $(dict_h_sources)
|
||||
@ -78,7 +78,7 @@ CLEANFILES = *Dict.cpp *Dict.h *~ core
|
||||
lib_LTLIBRARIES = libPMusr.la
|
||||
|
||||
libPMusr_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources)
|
||||
libPMusr_la_LIBADD = $(PSIBIN_LIBS) $(LEM_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS)
|
||||
libPMusr_la_LIBADD = $(PSIBIN_LIBS) $(MUD_LIBS) $(LEM_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS)
|
||||
libPMusr_la_LDFLAGS = -version-info $(MUSR_LIBRARY_VERSION) -release $(MUSR_RELEASE) $(AM_LDFLAGS)
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
@ -46,6 +46,8 @@ using namespace std;
|
||||
|
||||
#include "TLemRunHeader.h"
|
||||
#include "MuSR_td_PSI_bin.h"
|
||||
#include "mud.h"
|
||||
|
||||
#include "PRunDataHandler.h"
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -917,8 +919,6 @@ bool PRunDataHandler::ReadWkmFile()
|
||||
*/
|
||||
bool PRunDataHandler::ReadPsiBinFile()
|
||||
{
|
||||
// cout << endl << "PRunDataHandler::ReadPsiBinFile(): Sorry, not yet implemented ...";
|
||||
|
||||
MuSR_td_PSI_bin psiBin;
|
||||
int status;
|
||||
bool success;
|
||||
@ -1044,8 +1044,25 @@ bool PRunDataHandler::ReadPsiBinFile()
|
||||
*/
|
||||
bool PRunDataHandler::ReadMudFile()
|
||||
{
|
||||
cout << endl << "PRunDataHandler::ReadMudFile(): Sorry, not yet implemented ...";
|
||||
Int_t fh;
|
||||
UINT32 type;
|
||||
|
||||
fh = MUD_openRead((char *)fRunPathName.Data(), &type);
|
||||
if (fh == -1) {
|
||||
cerr << endl << "**ERROR** Couldn't open mud-file " << fRunPathName.Data() << ", sorry.";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// read necessary header information
|
||||
// STILL MISSING
|
||||
|
||||
// read histograms
|
||||
// STILL MISSING
|
||||
|
||||
MUD_closeRead(fh);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
2
src/external/Makefile.am
vendored
2
src/external/Makefile.am
vendored
@ -1 +1 @@
|
||||
SUBDIRS = TLemRunHeader MuSR_software
|
||||
SUBDIRS = TLemRunHeader MuSR_software mud
|
||||
|
1
src/external/mud/Makefile.am
vendored
Normal file
1
src/external/mud/Makefile.am
vendored
Normal file
@ -0,0 +1 @@
|
||||
SUBDIRS = src
|
843
src/external/mud/mud_friendly.html
vendored
Normal file
843
src/external/mud/mud_friendly.html
vendored
Normal file
@ -0,0 +1,843 @@
|
||||
<html><head><!--
|
||||
$Log: mud_friendly.html,v $
|
||||
Revision 1.4 2007/11/14 14:10:58 asnd
|
||||
Fixed removerf; Changed (recent) outputToFile by closeWriteFile
|
||||
|
||||
Revision 1.3 2007/06/21 03:13:20 asnd
|
||||
Added removerf program to extras
|
||||
|
||||
Revision 1.2 2005/06/21 01:27:40 asnd
|
||||
Adjust documentation
|
||||
|
||||
Revision 1.1 2003/11/25 16:15:01 asnd
|
||||
Add to CVS
|
||||
|
||||
--><title>MUD Data Format - Programmer's Guide</title></head><body alink="#ff0000" bgcolor="white" link="#0000ff" text="#000000" vlink="#000080">
|
||||
<hr>
|
||||
<h1>MUD Data Format - Programmer's Guide</h1>
|
||||
<hr>
|
||||
|
||||
Quick jump to:<br>
|
||||
<b>
|
||||
<a href="#INTRO"> Introduction</a><br>
|
||||
<a href="#READING"> Reading a data file</a><br>
|
||||
<a href="#WRITING"> Writing a data file</a><br>
|
||||
<a href="#MISC"> Miscellaneous routines</a><br>
|
||||
<a href="#EXAMPLES"> Examples</a><br>
|
||||
</b>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><a name="INTRO">Introduction</a></h2>
|
||||
<p>
|
||||
Routines begin with <code>MUD_</code> for applications written in
|
||||
C and <code>fMUD_</code> for applications written in Fortran.
|
||||
This document refers to all routines as <code>MUD_*</code>, but all
|
||||
descriptions apply equally (unless stated otherwise)
|
||||
to the Fortran equivalents, <code>fMUD_*</code>.
|
||||
The MUD file's data structures can be accessed directly using
|
||||
routines in both C and Fortran, but this document is concerned
|
||||
with the higher level "friendly" interface.
|
||||
|
||||
</p><p>
|
||||
Routines come generally under two categories: those to
|
||||
read a file (<code>MUD_*Read</code>, <code>MUD_get*</code>,
|
||||
see <a href="#READING">Reading a data file</a>)
|
||||
and those to write a file (<code>MUD_*Write</code>, <code>MUD_set*</code>,
|
||||
see <a href="#WRITING">Writing a data file</a>).
|
||||
Each routine for performing some aspect of reading the file
|
||||
has an equivalent for writing. There is a seperate routine for
|
||||
each item to be read/written.
|
||||
A file may be opened for reading, writing, or both (modification).
|
||||
If you are programming in C, you may also need to use the
|
||||
routine <code>MUD_pack</code>
|
||||
(see <a href="#MISC">Miscellaneous routines</a>).
|
||||
|
||||
</p><h3>Prototype declarations</h3>
|
||||
<p>
|
||||
The prototype declarations listed in this file are intended to
|
||||
give guidance to programming applications. The prototypes are
|
||||
declared in the include files:
|
||||
<a href="http://cmms.triumf.ca/mud/mud.h">mud.h</a> (C),
|
||||
<a href="http://cmms.triumf.ca/mud/mud.finc">mud.finc</a> (Vax Fortran),
|
||||
<a href="http://cmms.triumf.ca/mud/mud.f90">mud.f90</a> (Fortran 90+),
|
||||
<a href="http://cmms.triumf.ca/mud/mud.f77">mud.f77</a> (Fortran 77).
|
||||
|
||||
</p><p>
|
||||
For C, the type <code>UINT32</code> is also defined in mud.h. It is used
|
||||
to ensure a 32-bit (4-byte) unsigned integer across architectures. The type
|
||||
<code>REAL64</code> declares 64-bit (8-byte) floating-point. (Other data
|
||||
types will undoubtedly be used in the future as new MUD sections are
|
||||
added.) Strings for the C routines are zero-terminated.
|
||||
|
||||
</p><p>
|
||||
In the Fortran prototypes displayed below, the parameters are named
|
||||
according to their type:
|
||||
</p><pre>i_ = integer*4
|
||||
c_ = character*n
|
||||
d_ = double precision (real*8)
|
||||
</pre>
|
||||
Parameters of type "?" indicate an array that may be
|
||||
of several different types. Parameters ending in "(?)" indicate
|
||||
an array of unknown size. It is left to the programmer to ensure
|
||||
that the type and size of the arrays passed to these routines is
|
||||
sensible. Fortran character strings are returned padded with spaces.
|
||||
|
||||
<h3>Common parameters</h3>
|
||||
|
||||
All routines except <code>MUD_open*</code> and <code>MUD_pack</code>
|
||||
return a boolean status value (0 for failure, 1 for success).
|
||||
The <code>MUD_open*</code> routines return a file handle, or -1 for
|
||||
failure. <code>MUD_pack</code> returns the number of bytes in the
|
||||
resultant array.
|
||||
|
||||
<p>
|
||||
The file handle, <code>fh</code>, is a small integer returned by
|
||||
<code>MUD_open*</code>, and must be passed to other routines.
|
||||
|
||||
</p><p>
|
||||
The <code>MUD_get</code><i>-string</i> functions (for C) take
|
||||
an integer parameter (<code>strdim</code>) specifying the maximum
|
||||
acceptable string length. The returned string will have no more
|
||||
than <code>strdim-1</code> significant characters (plus the
|
||||
null terminator). The Fortran routines have no need for an
|
||||
explicit length parameter (the dimensioned length is passed
|
||||
implicitly).
|
||||
|
||||
</p><p>
|
||||
Many routines take an integer parameter ("<code>num</code>") indicating
|
||||
which of many instances is to be dealt with. For example, which
|
||||
histogram.
|
||||
|
||||
</p><h3>A note on time</h3>
|
||||
<p>
|
||||
All measures of time (single values or arrays) are stored in
|
||||
32 bit integers as the number of seconds since
|
||||
00:00:00 GMT, January 1, 1970.
|
||||
This is the same as is returned by the standard C library
|
||||
function <code>time</code> and stored in the C type
|
||||
definition <code>time_t</code>.
|
||||
|
||||
</p><h3>Platforms supported</h3>
|
||||
<p>
|
||||
The MUD library of routines has been written so that
|
||||
data files may be used on all supported platforms. All
|
||||
non-portable issues (byte ordering, floating-point
|
||||
representation) are handled by the library.
|
||||
The library has been built on the following platforms:
|
||||
</p><ul>
|
||||
<li>PC/Linux</li>
|
||||
<li>PC/Windows XP</li>
|
||||
<li>IBM PC/DOS (Borland C++ 3.1 - 16 bit) (no Fortran routines)</li>
|
||||
<li>VAX/VMS</li>
|
||||
<li>Alpha/VMS</li>
|
||||
<li>SGI</li>
|
||||
<li>Sun Solaris</li>
|
||||
</ul>
|
||||
and should build easily on many others.
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><a name="READING">Reading a data file</a></h2>
|
||||
<p>
|
||||
|
||||
</p><h3>Opening and closing a data file for reading</h3>
|
||||
<p>
|
||||
Opening the file is the first thing that must be done
|
||||
when reading a file, and closing is the last.
|
||||
The open routine returns a file handle, or -1 for failure.
|
||||
The file handle is passed to all of the other routines
|
||||
(parameter <code>fh</code>) to specify the file for reading.
|
||||
The file type is passed back in <code>pType</code>. Valid file types
|
||||
include (defined in the include file):
|
||||
<code>MUD_FMT_GEN_ID</code>,
|
||||
<code>MUD_FMT_TRI_TD_ID</code> (TD-MuSR),
|
||||
<code>MUD_FMT_TRI_TI_ID</code> (I-MuSR).
|
||||
The close routine returns a boolean status.
|
||||
</p><p>
|
||||
Note that, in the present implementation, the <em>entire file</em>
|
||||
is read into memory by the <code>MUD_openRead</code> (or
|
||||
<code>MUD_openReadWrite</code>) operation. Any subsequent "get"
|
||||
operation is a simple look-up in the MUD structure. The file handle
|
||||
is an index selecting among loaded MUD structures. The
|
||||
<code>MUD_closeRead</code> operation closes the file and releases the
|
||||
memory used to hold the MUD structure. This method provides fast
|
||||
access to the various items of data, but can require a lot of memory
|
||||
for very large MUD files, and might be inefficient for, say, listing
|
||||
the run titles for a series of runs. An obvious optimization not made
|
||||
at present is to directly map the file to (virtual) memory in
|
||||
operating systems that allow that.
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_openRead( char* filename, UINT32* pType );
|
||||
int MUD_closeRead( int fh );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_openRead( c_filename, i_Type )
|
||||
integer*4 fMUD_closeRead( i_fh )
|
||||
</pre>
|
||||
</p><p>
|
||||
See <a href="#WRITING">below</a> for a description of <code>MUD_openReadWrite</code>, which
|
||||
is almost identical to <code>MUD_openRead</code>.
|
||||
|
||||
<h3>Reading the Run Description</h3>
|
||||
<p>
|
||||
The routine <code>MUD_getRunDesc</code> returns the run description
|
||||
type in <code>pType</code>. Valid types are (defined in the include
|
||||
file):
|
||||
<code>MUD_SEC_GEN_RUN_DESC_ID</code> (TD-MuSR),
|
||||
<code>MUD_SEC_TRI_TI_RUN_DESC_ID</code> (I-MuSR).
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_getRunDesc( int fh, UINT32* pType );
|
||||
int MUD_getExptNumber( int fh, UINT32* pExptNumber );
|
||||
int MUD_getRunNumber( int fh, UINT32* pRunNumber );
|
||||
int MUD_getElapsedSec( int fh, UINT32* pElapsedSec );
|
||||
int MUD_getTimeBegin( int fh, UINT32* TimeBegin );
|
||||
int MUD_getTimeEnd( int fh, UINT32* TimeEnd );
|
||||
int MUD_getTitle( int fh, char* title, int strdim );
|
||||
int MUD_getLab( int fh, char* lab, int strdim );
|
||||
int MUD_getArea( int fh, char* area, int strdim );
|
||||
int MUD_getMethod( int fh, char* method, int strdim );
|
||||
int MUD_getApparatus( int fh, char* apparatus, int strdim );
|
||||
int MUD_getInsert( int fh, char* insert, int strdim );
|
||||
int MUD_getSample( int fh, char* sample, int strdim );
|
||||
int MUD_getOrient( int fh, char* orient, int strdim );
|
||||
int MUD_getDas( int fh, char* das, int strdim );
|
||||
int MUD_getExperimenter( int fh, char* experimenter, int strdim );
|
||||
Not in I-MuSR:
|
||||
int MUD_getTemperature( int fh, char* temperature, int strdim );
|
||||
int MUD_getField( int fh, char* field, int strdim );
|
||||
I-MuSR only:
|
||||
int MUD_getSubtitle( int fh, char* subtitle, int strdim );
|
||||
int MUD_getComment1( int fh, char* comment1, int strdim );
|
||||
int MUD_getComment2( int fh, char* comment2, int strdim );
|
||||
int MUD_getComment3( int fh, char* comment3, int strdim );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_getRunDesc( i_fh, i_Type )
|
||||
integer*4 fMUD_getExptNumber( i_fh, i_ExptNumber )
|
||||
integer*4 fMUD_getRunNumber( i_fh, i_RunNumber )
|
||||
integer*4 fMUD_getElapsedSec( i_fh, i_ElapsedSec )
|
||||
integer*4 fMUD_getTimeBegin( i_fh, i_TimeBegin )
|
||||
integer*4 fMUD_getTimeEnd( i_fh, i_TimeEnd )
|
||||
integer*4 fMUD_getTitle( i_fh, c_title )
|
||||
integer*4 fMUD_getLab( i_fh, c_lab )
|
||||
integer*4 fMUD_getArea( i_fh, c_area )
|
||||
integer*4 fMUD_getMethod( i_fh, c_method )
|
||||
integer*4 fMUD_getApparatus( i_fh, c_apparatus )
|
||||
integer*4 fMUD_getInsert( i_fh, c_insert )
|
||||
integer*4 fMUD_getSample( i_fh, c_sample )
|
||||
integer*4 fMUD_getOrient( i_fh, c_orient )
|
||||
integer*4 fMUD_getDas( i_fh, c_das )
|
||||
integer*4 fMUD_getExperimenter( i_fh, c_experimenter )
|
||||
Not in I-MuSR:
|
||||
integer*4 fMUD_getTemperature( i_fh, c_temperature )
|
||||
integer*4 fMUD_getField( i_fh, c_field )
|
||||
I-MuSR only:
|
||||
integer*4 fMUD_getSubtitle( i_fh, c_subtitle )
|
||||
integer*4 fMUD_getComment1( i_fh, c_comment1 )
|
||||
integer*4 fMUD_getComment2( i_fh, c_comment2 )
|
||||
integer*4 fMUD_getComment3( i_fh, c_comment3 )
|
||||
</pre>
|
||||
|
||||
<h3>Reading the Comments</h3>
|
||||
<p>
|
||||
The routine <code>MUD_getComments</code> returns the type of the comment group
|
||||
in <code>pType</code> and the number of comments in <code>pNum</code>.
|
||||
The only valid type is (defined in the include file):
|
||||
<code>MUD_GRP_CMT_ID</code>.
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_getComments( int fh, UINT32* pType, UINT32* pNum );
|
||||
int MUD_getCommentPrev( int fh, int num, UINT32* pPrev );
|
||||
int MUD_getCommentNext( int fh, int num, UINT32* pNext );
|
||||
int MUD_getCommentTime( int fh, int num, UINT32* pTime );
|
||||
int MUD_getCommentAuthor( int fh, int num, char* author, int strdim );
|
||||
int MUD_getCommentTitle( int fh, int num, char* title, int strdim );
|
||||
int MUD_getCommentBody( int fh, int num, char* body, int strdim );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_getComments( i_fh, i_Type, i_Num )
|
||||
integer*4 fMUD_getCommentPrev( i_fh, i_num, i_Prev )
|
||||
integer*4 fMUD_getCommentNext( i_fh, i_num, i_Next )
|
||||
integer*4 fMUD_getCommentTime( i_fh, i_num, i_Time )
|
||||
integer*4 fMUD_getCommentAuthor( i_fh, i_num, c_author )
|
||||
integer*4 fMUD_getCommentTitle( i_fh, i_num, c_title )
|
||||
integer*4 fMUD_getCommentBody( i_fh, i_num, c_body )
|
||||
</pre>
|
||||
|
||||
<h3>Reading the Histograms</h3>
|
||||
<p>
|
||||
The routine <code>MUD_getHists</code> returns the type of the histogram group
|
||||
in <code>pType</code> and the number of histograms in <code>pNum</code>.
|
||||
Valid types are (defined in the include file):
|
||||
<code>MUD_GRP_GEN_HIST_ID</code>,
|
||||
<code>MUD_GRP_TRI_TD_HIST_ID</code> (TD-MuSR),
|
||||
<code>MUD_GRP_TRI_TI_HIST_ID</code> (I-MuSR).
|
||||
|
||||
</p><p>
|
||||
The routine <code>MUD_getHistSecondsPerBin</code> stands out
|
||||
because it does not retrieve a separate item of data, but duplicates
|
||||
the function of <code>MUD_getHistFsPerBin</code>. Cases have
|
||||
arisen where the histogram bin size was not exactly represented
|
||||
as an integer number of femtoseconds, so scaled or coded values
|
||||
were saved. <code>MUD_getHistSecondsPerBin</code> is intended to
|
||||
always return the correct time per bin (in seconds).
|
||||
|
||||
</p><p>
|
||||
Note that the routine <code>MUD_getHistData</code> returns
|
||||
the entire (unpacked) array in <code>pData</code>. For C
|
||||
usage, it might be desireable to be returned a pointer to
|
||||
the array using <code>MUD_getHistpData</code>. In this case,
|
||||
it is left to the programmer to unpack the array if necessary.
|
||||
Note that a value of 0 (zero) in <code>pBytesPerBin</code>
|
||||
indicates a packed array. Arrays that are returned already
|
||||
unpacked by <code>MUD_getHistData</code> always have 4 bytes per bin.
|
||||
Make sure that your array <code>pData</code> is large enough.
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_getHists( int fh, UINT32* pType, UINT32* pNum );
|
||||
int MUD_getHistType( int fh, int num, UINT32* pType );
|
||||
int MUD_getHistNumBytes( int fh, int num, UINT32* pNumBytes );
|
||||
int MUD_getHistNumBins( int fh, int num, UINT32* pNumBins );
|
||||
int MUD_getHistBytesPerBin( int fh, int num, UINT32* pBytesPerBin );
|
||||
int MUD_getHistFsPerBin( int fh, int num, UINT32* pFsPerBin );
|
||||
int MUD_getHistT0_Ps( int fh, int num, UINT32* pT0_ps );
|
||||
int MUD_getHistT0_Bin( int fh, int num, UINT32* pT0_bin );
|
||||
int MUD_getHistGoodBin1( int fh, int num, UINT32* pGoodBin1 );
|
||||
int MUD_getHistGoodBin2( int fh, int num, UINT32* pGoodBin2 );
|
||||
int MUD_getHistBkgd1( int fh, int num, UINT32* pBkgd1 );
|
||||
int MUD_getHistBkgd2( int fh, int num, UINT32* pBkgd2 );
|
||||
int MUD_getHistNumEvents( int fh, int num, UINT32* pNumEvents );
|
||||
int MUD_getHistTitle( int fh, int num, char* title, int strdim );
|
||||
|
||||
int MUD_getHistSecondsPerBin( int fh, int num, REAL64* pSecondsPerBin );
|
||||
|
||||
int MUD_getHistData( int fh, int num, void* pData );
|
||||
int MUD_getHistpData( int fh, int num, void** ppData );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_getHists( i_fh, i_Type, i_Num )
|
||||
integer*4 fMUD_getHistType( i_fh, i_num, i_Type )
|
||||
integer*4 fMUD_getHistNumBytes( i_fh, i_num, i_NumBytes )
|
||||
integer*4 fMUD_getHistNumBins( i_fh, i_num, i_NumBins )
|
||||
integer*4 fMUD_getHistBytesPerBin( i_fh, i_num, i_BytesPerBin )
|
||||
integer*4 fMUD_getHistFsPerBin( i_fh, i_num, i_FsPerBin )
|
||||
integer*4 fMUD_getHistT0_Ps( i_fh, i_num, i_T0_ps )
|
||||
integer*4 fMUD_getHistT0_Bin( i_fh, i_num, i_T0_bin )
|
||||
integer*4 fMUD_getHistGoodBin1( i_fh, i_num, i_GoodBin1 )
|
||||
integer*4 fMUD_getHistGoodBin2( i_fh, i_num, i_GoodBin2 )
|
||||
integer*4 fMUD_getHistBkgd1( i_fh, i_num, i_Bkgd1 )
|
||||
integer*4 fMUD_getHistBkgd2( i_fh, i_num, i_Bkgd2 )
|
||||
integer*4 fMUD_getHistNumEvents( i_fh, i_num, i_NumEvents )
|
||||
integer*4 fMUD_getHistTitle( i_fh, i_num, c_title )
|
||||
|
||||
integer*4 fMUD_getHistSecondsPerBin( i_fh, i_num, d_SecondsPerBin )
|
||||
|
||||
integer*4 fMUD_getHistData( i_fh, i_num, ?_pData(?) )
|
||||
</pre>
|
||||
|
||||
<h3>Reading the Scalers</h3>
|
||||
<p>
|
||||
The routine <code>MUD_getScalers</code> returns the type
|
||||
of the scaler group
|
||||
in <code>pType</code> and the number of scalers in <code>pNum</code>.
|
||||
Valid types are (defined in the include file):
|
||||
<code>MUD_GRP_GEN_SCALER_ID</code>,
|
||||
<code>MUD_GRP_TRI_TD_SCALER_ID</code> (TD-MuSR).
|
||||
<code>MUD_getScalerLabel</code> gives the scaler label for a particular
|
||||
numbered scaler, and <code>MUD_getScalerCounts</code> gives
|
||||
an array of two 4-byte integers: the scaler total, and the most recent
|
||||
increment (rate).
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_getScalers( int fh, UINT32* pType, UINT32* pNum );
|
||||
int MUD_getScalerLabel( int fh, int num, char* label, int strdim );
|
||||
int MUD_getScalerCounts( int fh, int num, UINT32* pCounts );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_getScalers( i_fh, i_Type, i_Num )
|
||||
integer*4 fMUD_getScalerLabel( i_fh, i_num, c_label )
|
||||
integer*4 fMUD_getScalerCounts( i_fh, i_num, i_Counts(2) )
|
||||
</pre>
|
||||
|
||||
<h3>Reading the Independent Variables</h3>
|
||||
<p>
|
||||
The routine <code>MUD_getIndVars</code> returns the type
|
||||
of the independent variable group
|
||||
in <code>pType</code> and the number of independent
|
||||
variables in <code>pNum</code>.
|
||||
Valid types are (defined in the include file):
|
||||
<code>MUD_GRP_GEN_IND_VAR_ID</code> (TD-MuSR),
|
||||
<code>MUD_GRP_GEN_IND_VAR_ARR_ID</code> (I-MuSR).
|
||||
The type <code>MUD_GRP_GEN_IND_VAR_ID</code> has statistics
|
||||
data only. The type <code>MUD_GRP_GEN_IND_VAR_ARR_ID</code> has
|
||||
statistics data, history data and possibly time data (time that
|
||||
the data point was taken, in seconds since 00:00 Jan. 1, 1970).
|
||||
|
||||
</p><p>
|
||||
For history data, the data type is returned in <code>pDataType</code>,
|
||||
with values of 1 for integer, 2 for real and 3 for string.
|
||||
The number of history data points is returned in <code>pNumData</code>.
|
||||
The element size <code>pElemSize</code> is in bytes per element.
|
||||
The boolean value <code>pHasTime</code> indicates whether or not there
|
||||
is time data.
|
||||
It might be desireable to receive a pointer to the array data,
|
||||
using <code>MUD_getIndVarpData</code> and
|
||||
<code>MUD_getIndVarpTimeData</code>. In this case, it is up to
|
||||
the programmer to unpack the data (if necessary).
|
||||
Note that time data is never packed.
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_getIndVars( int fh, UINT32* pType, UINT32* pNum );
|
||||
int MUD_getIndVarLow( int fh, int num, double* pLow );
|
||||
int MUD_getIndVarHigh( int fh, int num, double* pHigh );
|
||||
int MUD_getIndVarMean( int fh, int num, double* pMean );
|
||||
int MUD_getIndVarStddev( int fh, int num, double* pStddev );
|
||||
int MUD_getIndVarSkewness( int fh, int num, double* pSkewness );
|
||||
int MUD_getIndVarName( int fh, int num, char* name, int strdim );
|
||||
int MUD_getIndVarDescription( int fh, int num, char* description, int strdim );
|
||||
int MUD_getIndVarUnits( int fh, int num, char* units, int strdim );
|
||||
For MUD_GRP_GEN_IND_VAR_ARR_ID groups:
|
||||
int MUD_getIndVarNumData( int fh, int num, UINT32* pNumData );
|
||||
int MUD_getIndVarElemSize( int fh, int num, UINT32* pElemSize );
|
||||
int MUD_getIndVarDataType( int fh, int num, UINT32* pDataType );
|
||||
int MUD_getIndVarHasTime( int fh, int num, UINT32* pHasTime );
|
||||
int MUD_getIndVarData( int fh, int num, void* pData );
|
||||
int MUD_getIndVarpData( int fh, int num, void** ppData );
|
||||
int MUD_getIndVarTimeData( int fh, int num, UINT32* pTimeData );
|
||||
int MUD_getIndVarpTimeData( int fh, int num, UINT32** ppTimeData );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_getIndVars( i_fh, i_Type, i_Num )
|
||||
integer*4 fMUD_getIndVarLow( i_fh, i_num, real*8 pLow )
|
||||
integer*4 fMUD_getIndVarHigh( i_fh, i_num, real*8 pHigh )
|
||||
integer*4 fMUD_getIndVarMean( i_fh, i_num, real*8 pMean )
|
||||
integer*4 fMUD_getIndVarStddev( i_fh, i_num, real*8 pStddev )
|
||||
integer*4 fMUD_getIndVarSkewness( i_fh, i_num, real*8 pSkewness )
|
||||
integer*4 fMUD_getIndVarName( i_fh, i_num, c_name )
|
||||
integer*4 fMUD_getIndVarDescription( i_fh, i_num, c_description )
|
||||
integer*4 fMUD_getIndVarUnits( i_fh, i_num, c_units )
|
||||
For MUD_GRP_GEN_IND_VAR_ARR_ID groups:
|
||||
integer*4 fMUD_getIndVarNumData( i_fh, i_num, i_NumData )
|
||||
integer*4 fMUD_getIndVarElemSize( i_fh, i_num, i_ElemSize )
|
||||
integer*4 fMUD_getIndVarDataType( i_fh, i_num, i_DataType )
|
||||
integer*4 fMUD_getIndVarHasTime( i_fh, i_num, i_HasTime )
|
||||
integer*4 fMUD_getIndVarData( i_fh, i_num, ?_pData(?) )
|
||||
integer*4 fMUD_getIndVarTimeData( i_fh, i_num, i_TimeData(?) )
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><a name="WRITING">Writing a data file</a></h2>
|
||||
<p>
|
||||
|
||||
</p><h3>Opening and closing a file for writing</h3>
|
||||
<p>
|
||||
Writing a data file can be handled in three different ways,
|
||||
where the best choice depends on the origin of the data.
|
||||
</p><p>
|
||||
If the data does not come from a MUD file, but will be
|
||||
written to one, then the destination file should first be
|
||||
opened with <code>MUD_openWrite</code>, all the data should
|
||||
be inserted using the <code>MUD_set...</code> functions, and
|
||||
then the file should be closed by <code>MUD_closeWrite</code>.
|
||||
The open routine returns a file handle (or -1 for failure)
|
||||
which is passed to all of the other routines
|
||||
(parameter <code>fh</code>) to specify the file for writing.
|
||||
The file type is defined by <code>type</code>. Valid file types
|
||||
include (defined in the include file):
|
||||
<code>MUD_FMT_GEN_ID</code>,
|
||||
<code>MUD_FMT_TRI_TD_ID</code> (TD-MuSR),
|
||||
<code>MUD_FMT_TRI_TI_ID</code> (I-MuSR).
|
||||
The close routine returns a boolean status.
|
||||
Note that, in the present implementation, the file on disk is
|
||||
indeed opened by <code>MUD_openWrite</code>,
|
||||
but nothing is written to it until <code>MUD_closeWrite</code>
|
||||
writes out the entire MUD structure.
|
||||
</p><p>
|
||||
To modify an existing MUD file, it should be opened with
|
||||
<code>MUD_openReadWrite</code>, which is the same as
|
||||
<code>MUD_openRead</code> except for the file-access mode.
|
||||
There is <em>no</em> corresponding <code>MUD_closeReadWrite</code>
|
||||
function! Use <code>MUD_closeWrite</code> to re-write the
|
||||
MUD file, or <code>MUD_closeRead</code> to close the file,
|
||||
abandoning any changes that were made.
|
||||
</p><p>
|
||||
To write modifications of an existing MUD file to a different
|
||||
file, access the original data beginning with <code>MUD_openRead</code>,
|
||||
modify the data (<code>MUD_set...</code>), then write the altered data using
|
||||
<code>MUD_closeWriteFile</code> specifying the new file name to write.
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_openWrite( char* filename, UINT32 type );
|
||||
int MUD_openReadWrite( char* filename, UINT32* pType );
|
||||
int MUD_closeWrite( int fh );
|
||||
int MUD_closeWriteFile( int fh, char* filename );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_openWrite( c_filename, i_type )
|
||||
integer*4 fMUD_openReadWrite( c_filename, i_Type )
|
||||
integer*4 fMUD_closeWrite( i_fh )
|
||||
integer*4 fMUD_closeWriteFile( i_fh, c_filename )
|
||||
</pre>
|
||||
|
||||
<h3>Writing the Run Description</h3>
|
||||
<p>
|
||||
The routine <code>MUD_setRunDesc</code> initializes a run description
|
||||
section of type <code>type</code>. This must be done before specifying
|
||||
any of the other parts of the run description.
|
||||
Valid types are (defined in the include file):
|
||||
<code>MUD_SEC_GEN_RUN_DESC_ID</code> (TD-MuSR),
|
||||
<code>MUD_SEC_TRI_TI_RUN_DESC_ID</code> (I-MuSR).
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_setRunDesc( int fh, UINT32 type );
|
||||
int MUD_setExptNumber( int fh, UINT32 exptNumber );
|
||||
int MUD_setRunNumber( int fh, UINT32 runNumber );
|
||||
int MUD_setElapsedSec( int fh, UINT32 elapsedSec );
|
||||
int MUD_setTimeBegin( int fh, UINT32 timeBegin );
|
||||
int MUD_setTimeEnd( int fh, UINT32 timeEnd );
|
||||
int MUD_setTitle( int fh, char* title );
|
||||
int MUD_setLab( int fh, char* lab );
|
||||
int MUD_setArea( int fh, char* area );
|
||||
int MUD_setMethod( int fh, char* method );
|
||||
int MUD_setApparatus( int fh, char* apparatus );
|
||||
int MUD_setInsert( int fh, char* insert );
|
||||
int MUD_setSample( int fh, char* sample );
|
||||
int MUD_setOrient( int fh, char* orient );
|
||||
int MUD_setDas( int fh, char* das );
|
||||
int MUD_setExperimenter( int fh, char* experimenter );
|
||||
Not in I-MuSR:
|
||||
int MUD_setTemperature( int fh, char* temperature );
|
||||
int MUD_setField( int fh, char* field );
|
||||
I-MuSR only:
|
||||
int MUD_setSubtitle( int fh, char* subtitle );
|
||||
int MUD_setComment1( int fh, char* comment1 );
|
||||
int MUD_setComment2( int fh, char* comment2 );
|
||||
int MUD_setComment3( int fh, char* comment3 );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_setRunDesc( i_fh, i_type )
|
||||
integer*4 fMUD_setExptNumber( i_fh, i_exptNumber )
|
||||
integer*4 fMUD_setRunNumber( i_fh, i_runNumber )
|
||||
integer*4 fMUD_setElapsedSec( i_fh, i_elapsedSec )
|
||||
integer*4 fMUD_setTimeBegin( i_fh, i_timeBegin )
|
||||
integer*4 fMUD_setTimeEnd( i_fh, i_timeEnd )
|
||||
integer*4 fMUD_setTitle( i_fh, c_title )
|
||||
integer*4 fMUD_setLab( i_fh, c_lab )
|
||||
integer*4 fMUD_setArea( i_fh, c_area )
|
||||
integer*4 fMUD_setMethod( i_fh, c_method )
|
||||
integer*4 fMUD_setApparatus( i_fh, c_apparatus )
|
||||
integer*4 fMUD_setInsert( i_fh, c_insert )
|
||||
integer*4 fMUD_setSample( i_fh, c_sample )
|
||||
integer*4 fMUD_setOrient( i_fh, c_orient )
|
||||
integer*4 fMUD_setDas( i_fh, c_das )
|
||||
integer*4 fMUD_setExperimenter( i_fh, c_experimenter )
|
||||
Not in I-MuSR:
|
||||
integer*4 fMUD_setTemperature( i_fh, c_temperature )
|
||||
integer*4 fMUD_setField( i_fh, c_field )
|
||||
I-MuSR only:
|
||||
integer*4 fMUD_setSubtitle( i_fh, c_subtitle )
|
||||
integer*4 fMUD_setComment1( i_fh, c_comment1 )
|
||||
integer*4 fMUD_setComment2( i_fh, c_comment2 )
|
||||
integer*4 fMUD_setComment3( i_fh, c_comment3 )
|
||||
</pre>
|
||||
|
||||
<h3>Writing the Comments</h3>
|
||||
<p>
|
||||
The routine <code>MUD_setComments</code> initializes a comment group
|
||||
of type <code>type</code> with <code>num</code> comments.
|
||||
This must be done before defining the comments.
|
||||
The only valid type is (defined in the include file):
|
||||
<code>MUD_GRP_CMT_ID</code>.
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_setComments( int fh, UINT32 type, UINT32 num );
|
||||
int MUD_setCommentPrev( int fh, int num, UINT32 prev );
|
||||
int MUD_setCommentNext( int fh, int num, UINT32 next );
|
||||
int MUD_setCommentTime( int fh, int num, UINT32 time );
|
||||
int MUD_setCommentAuthor( int fh, int num, char* author );
|
||||
int MUD_setCommentTitle( int fh, int num, char* title );
|
||||
int MUD_setCommentBody( int fh, int num, char* body );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_setComments( i_fh, i_type, i_num )
|
||||
integer*4 fMUD_setCommentPrev( i_fh, i_num, i_rev )
|
||||
integer*4 fMUD_setCommentNext( i_fh, i_num, i_next )
|
||||
integer*4 fMUD_setCommentTime( i_fh, i_num, i_time )
|
||||
integer*4 fMUD_setCommentAuthor( i_fh, i_num, c_author )
|
||||
integer*4 fMUD_setCommentTitle( i_fh, i_num, c_title )
|
||||
integer*4 fMUD_setCommentBody( i_fh, i_num, c_body )
|
||||
</pre>
|
||||
|
||||
<h3>Writing the Histograms</h3>
|
||||
<p>
|
||||
The routine <code>MUD_setHists</code> initializes a histogram group
|
||||
of type <code>type</code> with <code>num</code> histograms.
|
||||
This must be done before defining the histograms.
|
||||
Valid types are (defined in the include file):
|
||||
<code>MUD_GRP_GEN_HIST_ID</code>,
|
||||
<code>MUD_GRP_TRI_TD_HIST_ID</code> (TD-MuSR),
|
||||
<code>MUD_GRP_TRI_TI_HIST_ID</code> (I-MuSR).
|
||||
Note that you pass an array of 32 bit integers to the
|
||||
routine <code>MUD_setHistData</code>. This routine will
|
||||
pack the array, if necessary, depending on the previous definition
|
||||
of <code>bytesPerBin</code>.
|
||||
Note that a value of 0 (zero) in <code>bytesPerBin</code>
|
||||
indicates a packed array.
|
||||
|
||||
</p><p>
|
||||
For C usage, it might be desireable to pass a pointer to
|
||||
the array using <code>MUD_setHistpData</code>. In this case,
|
||||
it is left to the programmer to pack the array (if necessary).
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_setHists( int fh, UINT32 type, UINT32 num );
|
||||
int MUD_setHistType( int fh, int num, UINT32 type );
|
||||
int MUD_setHistNumBytes( int fh, int num, UINT32 numBytes );
|
||||
int MUD_setHistNumBins( int fh, int num, UINT32 numBins );
|
||||
int MUD_setHistBytesPerBin( int fh, int num, UINT32 bytesPerBin );
|
||||
int MUD_setHistFsPerBin( int fh, int num, UINT32 fsPerBin );
|
||||
int MUD_setHistT0_Ps( int fh, int num, UINT32 t0_ps );
|
||||
int MUD_setHistT0_Bin( int fh, int num, UINT32 t0_bin );
|
||||
int MUD_setHistGoodBin1( int fh, int num, UINT32 goodBin1 );
|
||||
int MUD_setHistGoodBin2( int fh, int num, UINT32 goodBin2 );
|
||||
int MUD_setHistBkgd1( int fh, int num, UINT32 bkgd1 );
|
||||
int MUD_setHistBkgd2( int fh, int num, UINT32 bkgd2 );
|
||||
int MUD_setHistNumEvents( int fh, int num, UINT32 numEvents );
|
||||
int MUD_setHistTitle( int fh, int num, char* title );
|
||||
|
||||
int MUD_setHistSecondsPerBin( int fh, int num, REAL64 secondsPerBin );
|
||||
|
||||
int MUD_setHistData( int fh, int num, void* pData );
|
||||
int MUD_setHistpData( int fh, int num, void* pData );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_setHists( i_fh, i_type, i_num )
|
||||
integer*4 fMUD_setHistType( i_fh, i_num, i_type )
|
||||
integer*4 fMUD_setHistNumBytes( i_fh, i_num, i_numBytes )
|
||||
integer*4 fMUD_setHistNumBins( i_fh, i_num, i_numBins )
|
||||
integer*4 fMUD_setHistBytesPerBin( i_fh, i_num, i_bytesPerBin )
|
||||
integer*4 fMUD_setHistFsPerBin( i_fh, i_num, i_fsPerBin )
|
||||
integer*4 fMUD_setHistT0_Ps( i_fh, i_num, i_t0_ps )
|
||||
integer*4 fMUD_setHistT0_Bin( i_fh, i_num, i_t0_bin )
|
||||
integer*4 fMUD_setHistGoodBin1( i_fh, i_num, i_goodBin1 )
|
||||
integer*4 fMUD_setHistGoodBin2( i_fh, i_num, i_goodBin2 )
|
||||
integer*4 fMUD_setHistBkgd1( i_fh, i_num, i_bkgd1 )
|
||||
integer*4 fMUD_setHistBkgd2( i_fh, i_num, i_bkgd2 )
|
||||
integer*4 fMUD_setHistNumEvents( i_fh, i_num, i_numEvents )
|
||||
integer*4 fMUD_setHistTitle( i_fh, i_num, c_title )
|
||||
|
||||
integer*4 fMUD_setHistSecondsPerBin( i_fh, i_num, d_secondsPerBin )
|
||||
|
||||
integer*4 fMUD_setHistData( i_fh, i_num, ?_pData(?) )
|
||||
</pre>
|
||||
|
||||
<h3>Writing the Scalers</h3>
|
||||
<p>
|
||||
The routine <code>MUD_setScalers</code> intializes a scaler group
|
||||
of type <code>type</code> with <code>num</code> scalers.
|
||||
Valid types are (defined in the include file):
|
||||
<code>MUD_GRP_GEN_SCALER_ID</code>,
|
||||
<code>MUD_GRP_TRI_TD_SCALER_ID</code> (TD-MuSR).
|
||||
Note that scaler counts are passed in a four byte integer
|
||||
array of two elements. The least significant half of the counts
|
||||
is passed in the first element of the array, and the most
|
||||
significant half in the second element.
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_setScalers( int fh, UINT32 type, UINT32 num );
|
||||
int MUD_setScalerLabel( int fh, int num, char* label );
|
||||
int MUD_setScalerCounts( int fh, int num, UINT32* pCounts );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_setScalers( i_fh, i_type, i_num )
|
||||
integer*4 fMUD_setScalerLabel( i_fh, i_num, c_label )
|
||||
integer*4 fMUD_setScalerCounts( i_fh, i_num, i_Counts(2) )
|
||||
</pre>
|
||||
|
||||
<h3>Writing the Independent Variables</h3>
|
||||
<p>
|
||||
The routine <code>MUD_setIndVars</code> initializes a
|
||||
independent variable group
|
||||
of type <code>type</code> with <code>num</code>
|
||||
independent variables.
|
||||
Valid types are (defined in the include file):
|
||||
<code>MUD_GRP_GEN_IND_VAR_ID</code> (TD-MuSR),
|
||||
<code>MUD_GRP_GEN_IND_VAR_ARR_ID</code> (I-MuSR).
|
||||
The type <code>MUD_GRP_GEN_IND_VAR_ID</code> has statistics
|
||||
data only. The type <code>MUD_GRP_GEN_IND_VAR_ARR_ID</code> has
|
||||
statistics data, history data and possibly time data (time that
|
||||
the data point was taken, in seconds since 00:00 Jan. 1, 1970).
|
||||
|
||||
</p><p>
|
||||
For history data, the data type is specified in <code>dataType</code>,
|
||||
with values of 1 for integer, 2 for real and 3 for string.
|
||||
The number of history data points is set in <code>numData</code>.
|
||||
The element size <code>elemSize</code> is in bytes per element.
|
||||
It might be desireable to pass a pointer to the array data,
|
||||
using <code>MUD_setIndVarpData</code> and
|
||||
<code>MUD_setIndVarpTimeData</code>. In this case, it is up to
|
||||
the programmer to pack the data (if necessary).
|
||||
Note that time data is never packed.
|
||||
|
||||
</p><pre>C routines:
|
||||
int MUD_setIndVars( int fh, UINT32 type, UINT32 num );
|
||||
int MUD_setIndVarLow( int fh, int num, double low );
|
||||
int MUD_setIndVarHigh( int fh, int num, double high );
|
||||
int MUD_setIndVarMean( int fh, int num, double mean );
|
||||
int MUD_setIndVarStddev( int fh, int num, double stddev );
|
||||
int MUD_setIndVarSkewness( int fh, int num, double skewness );
|
||||
int MUD_setIndVarName( int fh, int num, char* name );
|
||||
int MUD_setIndVarDescription( int fh, int num, char* description );
|
||||
int MUD_setIndVarUnits( int fh, int num, char* units );
|
||||
For MUD_GRP_GEN_IND_VAR_ARR_ID groups:
|
||||
int MUD_setIndVarNumData( int fh, int num, UINT32 numData );
|
||||
int MUD_setIndVarElemSize( int fh, int num, UINT32 elemSize );
|
||||
int MUD_setIndVarDataType( int fh, int num, UINT32 dataType );
|
||||
int MUD_setIndVarHasTime( int fh, int num, UINT32 hasTime );
|
||||
int MUD_setIndVarData( int fh, int num, void* pData );
|
||||
int MUD_setIndVarTimeData( int fh, int num, UINT32* pTimeData );
|
||||
int MUD_setIndVarpData( int fh, int num, void* pData );
|
||||
int MUD_setIndVarpTimeData( int fh, int num, UINT32* pTimeData );
|
||||
|
||||
Fortran routines:
|
||||
integer*4 fMUD_setIndVars( i_fh, i_type, i_num )
|
||||
integer*4 fMUD_setIndVarLow( i_fh, i_num, real*8 low )
|
||||
integer*4 fMUD_setIndVarHigh( i_fh, i_num, real*8 high )
|
||||
integer*4 fMUD_setIndVarMean( i_fh, i_num, real*8 mean )
|
||||
integer*4 fMUD_setIndVarStddev( i_fh, i_num, real*8 stddev )
|
||||
integer*4 fMUD_setIndVarSkewness( i_fh, i_num, real*8 skewness )
|
||||
integer*4 fMUD_setIndVarName( i_fh, i_num, c_name )
|
||||
integer*4 fMUD_setIndVarDescription( i_fh, i_num, c_description )
|
||||
integer*4 fMUD_setIndVarUnits( i_fh, i_num, c_units )
|
||||
For MUD_GRP_GEN_IND_VAR_ARR_ID groups:
|
||||
integer*4 fMUD_setIndVarNumData( i_fh, i_num, i_numData )
|
||||
integer*4 fMUD_setIndVarElemSize( i_fh, i_num, i_elemSize )
|
||||
integer*4 fMUD_setIndVarDataType( i_fh, i_num, i_dataType )
|
||||
integer*4 fMUD_setIndVarHasTime( i_fh, i_num, i_hasTime )
|
||||
integer*4 fMUD_setIndVarData( i_fh, i_num, ?_pData(?) )
|
||||
integer*4 fMUD_setIndVarTimeData( i_fh, i_num, i_TimeData(?) )
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><a name="MISC">Miscellaneous routines</a></h2>
|
||||
<p>
|
||||
|
||||
</p><h3>Packing/unpacking Integer Histograms</h3>
|
||||
<p>
|
||||
MUD_pack is used to pack or unpack integer histogram data. This
|
||||
routine is not necessary when using the routines
|
||||
<code>MUD_getData</code>, <code>MUD_getIndVarData</code>, or their
|
||||
<code>set</code> equivalents, which do the packing/unpacking
|
||||
internally if necessary. This is always the case for Fortran access.
|
||||
<code>MUD_pack</code> may be necessary when using the routines
|
||||
<code>MUD_getpData</code>, <code>MUD_getIndVarpData</code>, or their
|
||||
<code>set</code> equivalents. Valid bin sizes are: 0, 1, 2, 4 (bytes
|
||||
per bin). Note that a packed array is indicated by a bin size of 0
|
||||
(zero). <code>num</code> is the number of bins. You must make sure
|
||||
that <code>outArray</code> has enough space for the resultant array.
|
||||
|
||||
</p><pre>C routine:
|
||||
int MUD_pack( int num, int inBinSize, void* inArray, int outBinSize, void* outArray );
|
||||
|
||||
Fortran routine:
|
||||
integer*4 fMUD_pack( i_num, i_inBinSize, ?_inArray(?), i_outBinSize, ?_outArray(?) )
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><a name="EXAMPLES">Examples</a></h2>
|
||||
<p>
|
||||
|
||||
</p><h3>Fortran Test</h3>
|
||||
(works with g77)
|
||||
<p>
|
||||
</p><pre> implicit none
|
||||
include 'mud.f77'
|
||||
|
||||
integer*4 idat(102400)
|
||||
|
||||
character*64 fname
|
||||
integer*4 stat, fmtid
|
||||
integer*4 fh, pType
|
||||
integer*4 RunNumber
|
||||
character*80 RunTitle
|
||||
integer*4 htype,hnum,nh
|
||||
integer*4 nbins,nt1
|
||||
integer*4 i,is,type,num
|
||||
real*8 seconds
|
||||
character*10 scl,hnam(16)
|
||||
integer*4 sclval(2)
|
||||
|
||||
write(*,100)
|
||||
100 format( ' Enter mud file name: ',$ )
|
||||
read(*,200,end=999) fname
|
||||
200 format(a)
|
||||
|
||||
fmtid=1234
|
||||
fh = fMUD_openRead( fname, fmtid )
|
||||
write (*,*) 'After open, fh = ',fh
|
||||
write (*,*) 'format id =', fmtid,'; TRI_TD = ',MUD_FMT_TRI_TD_ID
|
||||
|
||||
if (fMUD_getRunDesc(fh,pType) .eq. 0) goto 666
|
||||
|
||||
if (fMUD_getRunNumber(fh,RunNumber) .eq. 0) goto 666
|
||||
if (fMUD_getTitle(fh,RunTitle) .eq. 0) goto 666
|
||||
|
||||
write(*,300) RunNumber,RunTitle(:66)
|
||||
300 format(' Run',I6,1x,A)
|
||||
|
||||
if (fMUD_gethists(fh,htype,nh) .eq. 0) goto 666
|
||||
do 333 i=1,nh
|
||||
if (fMUD_gethisttitle(fh,i,hnam(i)) .eq. 0) goto 666
|
||||
333 continue
|
||||
write(*,*) 'There are ',nh,' histograms:'
|
||||
write(*,*) (hnam(i),i=1,nh)
|
||||
|
||||
hnum = 1
|
||||
if (fMUD_gethistnumbins(fh,hnum,nbins) .eq. 0) goto 666
|
||||
write(*,*) 'Histogram ',hnum,' has ',nbins,' bins'
|
||||
if (fMUD_getHistGoodBin1( fh,hnum,nt1 ) .eq. 0) goto 666
|
||||
if (nbins>102400) then
|
||||
write(*,*) 'That''s too many bins'
|
||||
else
|
||||
if (fMUD_getHistSecondsPerBin(fh,hnum,seconds) .eq. 0) goto 666
|
||||
write(*,*) seconds*1.0d9,' ns per bin'
|
||||
if (fMUD_getHistData(fh,hnum,idat) .eq. 0) goto 666
|
||||
write(*,500) nt1,(idat(i),i=nt1,nt1+39)
|
||||
500 format(' Data starting from bin',I5,':',4(/10I7))
|
||||
endif
|
||||
|
||||
if (fMUD_getScalers( fh, Type, Num ) .gt. 0 .and.
|
||||
> Type .eq. MUD_GRP_TRI_TD_SCALER_ID) then
|
||||
|
||||
write(*,*) 'There are ',Num,' scalers.'
|
||||
do i = 1, Num
|
||||
is = fMUD_getScalerLabel( fh, i, scl )
|
||||
is = fMUD_getScalerCounts( fh, i, sclval )
|
||||
write (*,*) i,' ',scl,': ',sclval(1)
|
||||
enddo
|
||||
endif
|
||||
|
||||
666 continue
|
||||
stat = fMUD_closeRead( fh )
|
||||
* write (*,*) 'After close, stat = ',stat
|
||||
|
||||
999 continue
|
||||
|
||||
end
|
||||
</pre>
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<address>
|
||||
asnd@triumf.ca, µSR Facility<br>
|
||||
suz@triumf.ca, TRIUMF Data Acquisition Group
|
||||
</address>
|
||||
|
||||
</body></html>
|
581
src/external/mud/readme
vendored
Normal file
581
src/external/mud/readme
vendored
Normal file
@ -0,0 +1,581 @@
|
||||
|
||||
MUD Data Format
|
||||
|
||||
Overview:
|
||||
|
||||
The muon data (MUD) format used at TRIUMF is an efficent framework
|
||||
for storing and retrieving muSR data. Its existing structure is
|
||||
optimized for muSR data, but the basic framework is universal and
|
||||
the definition is extensible, so it can grow to meet new demands.
|
||||
|
||||
The MUD format is characterized by the organization of data
|
||||
into Sections. The instance of each Section is defined by two
|
||||
long integers: the Type identification (secID) and a secondary
|
||||
number specifying the instance of the type (instanceID).
|
||||
The format has been designed to allow for quick implementation of
|
||||
new Section types or modifications of old types, high flexibility
|
||||
while maintaining a standard, and ease of use for the application
|
||||
programmer. Type identifiers can be assigned to new Section types
|
||||
used for applications local to a lab, but the ideal is to have
|
||||
shared data type specifications, with generally-accepted ID codes.
|
||||
To this end, ranges of secID numbers are reserved for individual
|
||||
laboratories, to prevent conflicts of local definitions.
|
||||
Additionally, there is a range for generic secIDs whose
|
||||
definitions can be collected (at TRIUMF) and distributed with
|
||||
the MUD program libraries.
|
||||
|
||||
File Contents:
|
||||
|
||||
A MUD data format file consists of sequential contiguous Sections
|
||||
in a stream file. Common to all types of MUD Section is a small
|
||||
Core structure giving Section type and instance, size, and a
|
||||
pointer to the next Section. This design, with the relative file
|
||||
position of the next Section encoded into the Core part of each
|
||||
Section, allows for traversal of the file and for the modification
|
||||
of the contents of a Section type while maintaining backwards
|
||||
compatibility with MUD file readers.
|
||||
|
||||
Sections of any combination of types may be organized into Groups.
|
||||
The Group is simply a class of MUD Section which indicates that a
|
||||
number of following Sections are to be grouped together. The Group
|
||||
provides an index of (relative file position) pointers to those
|
||||
ensuing Sections, which may be thought of as being contained within
|
||||
the Group Section. The whole MUD file is a particular case
|
||||
of a MUD group.
|
||||
|
||||
The most important MUD Sections are those that hold data, and
|
||||
the secID implies how to read that data. Not only the content
|
||||
and the organization, but also the encoding are specified by the
|
||||
definition of the Section type. Encoding includes byte order
|
||||
and floating-point format (although floating-point should be
|
||||
avoided). The MUD library includes standard routines to read
|
||||
the file's encoding into the computer's native format.
|
||||
|
||||
Copying MUD files:
|
||||
|
||||
MUD files are pure binary streams, without any record format.
|
||||
This is attractive for moving files between operating systems,
|
||||
some of which have no concept of file records. On VMS systems,
|
||||
with a rich repertoire of record types, MUD files are typically
|
||||
called "stream LF" because that is what C programs automatically
|
||||
produce, even though the correct type should be "stream". FTP
|
||||
transfer between VMS and Unix systems does not work well, because
|
||||
it usually assumes a particular record format (fixed 512 byte
|
||||
records) on the VMS end. To use FTP one should first "zip" the
|
||||
files, and transfer the zip archive. NFS works well.
|
||||
|
||||
Software Library/Applications:
|
||||
|
||||
It is intended that the data be accessed via the set of supplied
|
||||
routines for reading and writing the MUD format. There are both
|
||||
high-level (API) routines for accessing particular components of
|
||||
existing MUD Sections, and low-level routines used to implement
|
||||
the API or to read and write MUD files directly. If such
|
||||
low-level access is desired, inspection of the (C language) source
|
||||
code (which is not extensive) should reveal the necessary
|
||||
information.
|
||||
|
||||
Defining New Types:
|
||||
|
||||
The specification of a Section type includes the following four
|
||||
steps:
|
||||
|
||||
1. Definition of a structure in C, and optionally a
|
||||
corresponding structure in Fortran (see Example 1)
|
||||
|
||||
2. Writing one C subroutine that handles the specifics of
|
||||
the I/O, etc., in a brief and well-defined manner
|
||||
(Example 2).
|
||||
|
||||
3. Adding an entry to the C subroutine that dynamically
|
||||
creates instances of each Section.
|
||||
|
||||
4. Reserving the unique 32-bit integer identifier(s) for
|
||||
the new type.
|
||||
|
||||
and optionally,
|
||||
|
||||
5. Adding the corresponding "friendly" API functions.
|
||||
|
||||
The Section definition and its ID should be contributed to the
|
||||
centralized library (maintained at TRIUMF), allowing all MUD-aware
|
||||
applications to understand them.
|
||||
|
||||
Applications may be written in C or Fortran and linked to the MUD
|
||||
library, although the natural language is C for low-level access.
|
||||
In C, the Sections may be written from a linked list of
|
||||
structures. Routines are available for the creation of Sections and
|
||||
maintaining the list. In both languages, the entire file may be
|
||||
read into a linked list, and then search routines are used to access
|
||||
specific Sections of the list (see Example 3). Alternatively, the
|
||||
I/O of each Section may be done separately, also in both languages
|
||||
(see Example 4). Access to individual Sections in the data file
|
||||
may be sequential or pseudo-direct. The pseudo-direct access
|
||||
involves the call to a routine with the request for a Section of a
|
||||
certain ID; the routine then searches the file from the current
|
||||
position for the requested Section and positions the file pointer
|
||||
to the beginning of this Section.
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Example 1. Sample MUD format structure (in C; from mud.h)
|
||||
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 ID;
|
||||
UINT32 prevReplyID;
|
||||
UINT32 nextReplyID;
|
||||
TIME time;
|
||||
char* author;
|
||||
char* title;
|
||||
char* comment;
|
||||
} MUD_SEC_CMT;
|
||||
|
||||
|
||||
The same structure for (VAX) Fortran (from mud.finc)
|
||||
|
||||
structure /MUD_SEC_CMT/
|
||||
record /MUD_CORE/ core
|
||||
|
||||
integer*4 ID
|
||||
integer*4 prevReplyID
|
||||
integer*4 nextReplyID
|
||||
integer*4 time
|
||||
integer*4 pcsAuthor
|
||||
integer*4 pcsTitle
|
||||
integer*4 pcsComment
|
||||
end structure
|
||||
|
||||
The same structure for Fortran 90/95 (from mud.f90)
|
||||
|
||||
type MUD_SEC_CMT
|
||||
sequence
|
||||
type(MUD_CORE) core
|
||||
|
||||
integer*4 ID
|
||||
integer*4 prevReplyID
|
||||
integer*4 nextReplyID
|
||||
integer*4 time
|
||||
integer*4 pcsAuthor
|
||||
integer*4 pcsTitle
|
||||
integer*4 pcsComment
|
||||
end type
|
||||
|
||||
Note that the Fortran structures are identical to the C structure,
|
||||
including the use of pointers to strings. Subroutines are provided
|
||||
for conversion between these pointers and ordinary Fortran character
|
||||
variables (see Example 4, fMUD_ctofString).
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Example 2. Subroutine to handle the type in Example 1:
|
||||
|
||||
|
||||
int
|
||||
MUD_SEC_CMT_proc( op, pBuf, pMUD )
|
||||
MUD_OPT op;
|
||||
BUF* pBuf;
|
||||
MUD_SEC_CMT* pMUD;
|
||||
{
|
||||
int size;
|
||||
char tempStr1[32];
|
||||
|
||||
switch( op )
|
||||
{
|
||||
case MUD_FREE:
|
||||
_free( pMUD->author );
|
||||
_free( pMUD->title );
|
||||
_free( pMUD->comment );
|
||||
break;
|
||||
case MUD_DECODE:
|
||||
decode_4( pBuf, &pMUD->ID );
|
||||
decode_4( pBuf, &pMUD->prevReplyID );
|
||||
decode_4( pBuf, &pMUD->nextReplyID );
|
||||
decode_4( pBuf, &pMUD->time );
|
||||
decode_str( pBuf, &pMUD->author );
|
||||
decode_str( pBuf, &pMUD->title );
|
||||
decode_str( pBuf, &pMUD->comment );
|
||||
break;
|
||||
case MUD_ENCODE:
|
||||
encode_4( pBuf, &pMUD->ID );
|
||||
encode_4( pBuf, &pMUD->prevReplyID );
|
||||
encode_4( pBuf, &pMUD->nextReplyID );
|
||||
encode_4( pBuf, &pMUD->time );
|
||||
encode_str( pBuf, &pMUD->author );
|
||||
encode_str( pBuf, &pMUD->title );
|
||||
encode_str( pBuf, &pMUD->comment );
|
||||
break;
|
||||
case MUD_GET_SIZE:
|
||||
size = 3*sizeof( UINT32 );
|
||||
size += 1*sizeof( TIME );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->author );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->title );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->comment );
|
||||
return( size );
|
||||
case MUD_SHOW:
|
||||
printf( " MUD_SEC_CMT: \n" );
|
||||
printf( " number:[%ld], prevReply:[%ld], nextReply:[%ld]\n",
|
||||
pMUD->ID, pMUD->prevReplyID, pMUD->nextReplyID );
|
||||
strcpy( tempStr1, ctime( (time_t*)&pMUD->time ) );
|
||||
tempStr1[strlen(tempStr1)-1] = '\0';
|
||||
printf( " time:[%s]\n", tempStr1 );
|
||||
if( pMUD->author ) printf( " author:\"%s\"\n", pMUD->author );
|
||||
if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title );
|
||||
if( pMUD->comment ) printf( " comment:\"%s\"\n", pMUD->comment );
|
||||
break;
|
||||
case MUD_HEADS:
|
||||
printf( "Comment number %ld. ", pMUD->ID );
|
||||
if( pMUD->prevReplyID > 0 )
|
||||
printf(" Re: #%ld. ", pMUD->prevReplyID );
|
||||
if( pMUD->nextReplyID > 0 )
|
||||
printf(" Next: #%ld.", pMUD->nextReplyID );
|
||||
printf( "\n" );
|
||||
strcpy( tempStr1, ctime( (time_t*)&pMUD->time ) );
|
||||
tempStr1[strlen(tempStr1)-1] = '\0';
|
||||
if( pMUD->author ) printf( " author: %s, time: %s\n", pMUD->author, tempStr1 );
|
||||
if( pMUD->title ) printf( " title: %s\n", pMUD->title );
|
||||
if( pMUD->comment ) printf( "%s\n", pMUD->comment );
|
||||
break;
|
||||
}
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Example 3. Sample C application:
|
||||
|
||||
/*
|
||||
* mud_test.c
|
||||
*/
|
||||
|
||||
#include 'mud.h'
|
||||
|
||||
int
|
||||
main( void )
|
||||
{
|
||||
FILE* fin;
|
||||
FILE* fout;
|
||||
MUD_SEC* pMUD_head = NULL;
|
||||
MUD_SEC_GEN_RUN_DESC* pMUD_desc;
|
||||
MUD_SEC_GEN_HIST* pMUD_hist;
|
||||
char* filename = "006663.mud";
|
||||
|
||||
/*
|
||||
* Read an MUD format file into a linked list
|
||||
*/
|
||||
fin = MUD_openInput( filename );
|
||||
if( fin == NULL ) exit( 0 );
|
||||
|
||||
MUD_readFile( fin, &pMUD_head );
|
||||
|
||||
fclose( fin );
|
||||
|
||||
/*
|
||||
* Access the (header for) the third histogram in the TD histogram group
|
||||
*/
|
||||
pMUD_hist = MUD_search( pMUD_head, MUD_SEC_GROUP_ID, MUD_GRP_TRI_TD_HIST_ID,
|
||||
MUD_SEC_GEN_HIST_HDR_ID, 3,
|
||||
0 );
|
||||
printf( "Number of bins: %d\n", pMUD_hist->nBins )
|
||||
|
||||
/*
|
||||
* Add a run description section (#2) to the list
|
||||
*/
|
||||
pMUD_desc = MUD_new( MUD_SEC_GEN_RUN_DESC_ID, 2 );
|
||||
MUD_add( &pMUD_head, pMUD_desc );
|
||||
|
||||
/*
|
||||
.
|
||||
.
|
||||
.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* Write an MUD format file
|
||||
*/
|
||||
fout = MUD_openOutput( filename );
|
||||
if( fout == NULL ) exit( 0 );
|
||||
|
||||
MUD_writeFile( fout, pMUD_head, MUD_FMT_ALL_ID );
|
||||
|
||||
fclose( fout );
|
||||
|
||||
/*
|
||||
* Free the linked list
|
||||
*/
|
||||
MUD_free( pMUD_head );
|
||||
}
|
||||
|
||||
/*
|
||||
* end mud_test.c
|
||||
*/
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Example 4. Sample Fortran applications:
|
||||
|
||||
Modern Fortran:
|
||||
~~~~~~~~~~~~~~~
|
||||
program mud_test_fortran
|
||||
implicit none
|
||||
|
||||
include 'mud.f90'
|
||||
|
||||
integer, parameter :: i4 = selected_int_kind(9) ! integer*4
|
||||
|
||||
integer(kind=i4) status
|
||||
integer(kind=i4) i
|
||||
character(len=32) filename
|
||||
integer(kind=i4) fileHandle
|
||||
character(len=20) title
|
||||
|
||||
type(MUD_SEC_GEN_HIST_HDR) MUD_hist_hdr(8)
|
||||
|
||||
|
||||
!
|
||||
! Open an MUD format file
|
||||
!
|
||||
filename = '001234.msr'
|
||||
|
||||
fileHandle = fMUD_openInput( filename )
|
||||
if (fileHandle .eq. 0) then
|
||||
write (*,*) 'Could not open file ',filename,
|
||||
+ ' (',fileHandle,')'
|
||||
stop
|
||||
endif
|
||||
write (*,*) 'Opened file ', filename
|
||||
|
||||
!
|
||||
! Position the file before the first histogram of the
|
||||
! TD histogram group
|
||||
!
|
||||
status = fMUD_fseek( fileHandle,
|
||||
+ MUD_SEC_GRP_ID, MUD_GRP_TRI_TD_HIST_ID,
|
||||
+ 0, 0 )
|
||||
if( status .eq. -1 ) then
|
||||
write (*,*) 'Failed to find histogram group! status=',status
|
||||
goto 999
|
||||
endif
|
||||
!
|
||||
! Read the histogram headers
|
||||
!
|
||||
|
||||
do i=1,8 ! we dimensioned MUD_hist_hdr(8)
|
||||
|
||||
status = fMUD_fseek( fileHandle,
|
||||
+ MUD_SEC_GEN_HIST_HDR_ID, i,
|
||||
+ 0)
|
||||
!
|
||||
! If no more histograms, then we are finished:
|
||||
!
|
||||
if (status .eq. -1 ) exit
|
||||
|
||||
status = fMUD_read( fileHandle, MUD_hist_hdr(i) )
|
||||
|
||||
!
|
||||
! Access the histogram title
|
||||
!
|
||||
if (status.eq.1) then
|
||||
call fMUD_ctofString( title, MUD_hist_hdr(i)%pcsTitle )
|
||||
write (*,*) 'histogram ',i,' title = "',trim(title),'"'
|
||||
else
|
||||
write (*,*) 'Failed to read header for histogram',i
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
999 continue
|
||||
|
||||
call fMUD_close( fileHandle )
|
||||
|
||||
end program mud_test_fortran
|
||||
|
||||
|
||||
|
||||
Sample for VAX Fortran:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
program mud_test_fortran
|
||||
implicit none
|
||||
|
||||
include 'mud.finc'
|
||||
|
||||
integer*4 status
|
||||
integer*4 i
|
||||
character*32 filename
|
||||
integer*4 fileHandle
|
||||
character*20 title
|
||||
|
||||
record /MUD_SEC_GEN_HIST_HDR/ MUD_hist_hdr(8)
|
||||
|
||||
|
||||
!
|
||||
! Open an MUD format file
|
||||
!
|
||||
filename = '001234.msr'
|
||||
|
||||
fileHandle = fMUD_openInput( filename )
|
||||
if (fileHandle .eq. 0) then
|
||||
write (*,*) 'Could not open file ',filename,
|
||||
> ' (',fileHandle,')'
|
||||
stop
|
||||
endif
|
||||
write (*,*) 'Opened file ', filename
|
||||
|
||||
!
|
||||
! Position the file before the first histogram of the
|
||||
! TD histogram group
|
||||
!
|
||||
status = fMUD_fseek( fileHandle,
|
||||
+ MUD_SEC_GRP_ID, MUD_GRP_TRI_TD_HIST_ID,
|
||||
+ 0, 0 )
|
||||
if( status .eq. -1 ) then
|
||||
write (*,*) 'Failed to find histogram group! status=',status
|
||||
goto 999
|
||||
endif
|
||||
!
|
||||
! Read the histogram headers
|
||||
!
|
||||
|
||||
do i=1,8 ! we dimensioned MUD_hist_hdr(8)
|
||||
|
||||
status = fMUD_fseek( fileHandle,
|
||||
+ MUD_SEC_GEN_HIST_HDR_ID, i,
|
||||
+ 0)
|
||||
!
|
||||
! If no more histograms, then we are finished:
|
||||
!
|
||||
if (status .eq. -1 ) goto 999
|
||||
|
||||
status = fMUD_read( fileHandle, MUD_hist_hdr(i) )
|
||||
|
||||
!
|
||||
! Access the histogram title
|
||||
!
|
||||
if (status.eq.1) then
|
||||
call fMUD_ctofString( title, MUD_hist_hdr(i).pcsTitle )
|
||||
write (*,*) 'histogram ',i,' title = "',title,'"'
|
||||
else
|
||||
write (*,*) 'Failed to read header for histogram',i
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
999 continue
|
||||
|
||||
call fMUD_close( fileHandle )
|
||||
|
||||
end ! program mud_test_fortran
|
||||
|
||||
|
||||
Sample for old (but extended) Fortran77 (g77):
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
program mud_test_fortran
|
||||
|
||||
include 'mud.f77'
|
||||
|
||||
integer*4 status
|
||||
integer*4 i
|
||||
character*32 filename
|
||||
integer*4 fileHandle
|
||||
character*20 title
|
||||
|
||||
integer*4 MUD_hist_hdr
|
||||
|
||||
* Hist header structure, implemented as a common block.
|
||||
* All hist header elements are named hh_... The core elements
|
||||
* are named hh_c_...
|
||||
|
||||
integer*4 hh_c_pNext !* pointer to next section *
|
||||
integer*4 hh_c_size
|
||||
integer*4 hh_c_secID !* Ident of section type *
|
||||
integer*4 hh_c_instanceID
|
||||
integer*4 hh_c_sizeof
|
||||
integer*4 hh_c_proc
|
||||
!
|
||||
integer*4 hh_histType
|
||||
integer*4 hh_nBytes
|
||||
integer*4 hh_nBins
|
||||
integer*4 hh_bytesPerBin
|
||||
integer*4 hh_fsPerBin
|
||||
integer*4 hh_t0_ps
|
||||
integer*4 hh_t0_bin
|
||||
integer*4 hh_goodBin1
|
||||
integer*4 hh_goodBin2
|
||||
integer*4 hh_bkgd1
|
||||
integer*4 hh_bkgd2
|
||||
integer*4 hh_nEvents
|
||||
integer*4 hh_pcsTitle
|
||||
|
||||
|
||||
common /cmn_hdr/
|
||||
+ hh_c_pNext, hh_c_size, hh_c_secID, hh_c_instanceID,
|
||||
+ hh_c_sizeof, hh_c_proc,
|
||||
+ hh_histType, hh_nBytes, hh_nBins, hh_bytesPerBin,
|
||||
+ hh_fsPerBin, hh_t0_ps, hh_t0_bin, hh_goodBin1, hh_goodBin2,
|
||||
+ hh_bkgd1, hh_bkgd2, hh_nEvents, hh_pcsTitle
|
||||
|
||||
equivalence(hh_c_pNext,MUD_hist_hdr)
|
||||
|
||||
!
|
||||
! Open an MUD format file
|
||||
!
|
||||
filename = '001234.msr'
|
||||
|
||||
fileHandle = fMUD_openInput( filename )
|
||||
if (fileHandle .eq. 0) then
|
||||
write (*,*) 'Could not open file ',filename,
|
||||
> ' (',fileHandle,')'
|
||||
stop
|
||||
endif
|
||||
write (*,*) 'Opened file ', filename
|
||||
|
||||
!
|
||||
! Position the file before the first histogram of the
|
||||
! TD histogram group
|
||||
!
|
||||
status = fMUD_fseek( fileHandle,
|
||||
+ MUD_SEC_GRP_ID, MUD_GRP_TRI_TD_HIST_ID,
|
||||
+ 0 )
|
||||
if( status .eq. -1 ) then
|
||||
write (*,*) 'Failed to find histogram group! status=',status
|
||||
goto 999
|
||||
endif
|
||||
!
|
||||
! Read the histogram headers
|
||||
!
|
||||
do i=1,16
|
||||
|
||||
status = fMUD_fseek( fileHandle,
|
||||
+ MUD_SEC_GEN_HIST_HDR_ID, i,
|
||||
+ 0 )
|
||||
|
||||
if (status .eq. -1 ) goto 999
|
||||
|
||||
status = fMUD_read( fileHandle, MUD_hist_hdr )
|
||||
|
||||
!
|
||||
! Access the histogram title
|
||||
!
|
||||
if (status.eq.1) then
|
||||
call fMUD_ctofString( title, hh_pcsTitle )
|
||||
write (*,*) ' histogram title = <', title, '>'
|
||||
else
|
||||
write (*,*) ' Failed to read header for histogram',i
|
||||
endif
|
||||
|
||||
end do
|
||||
|
||||
999 continue
|
||||
call fMUD_close( fileHandle )
|
||||
stop
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
27
src/external/mud/src/Makefile.am
vendored
Normal file
27
src/external/mud/src/Makefile.am
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
## Process this file with automake to create Makefile.in
|
||||
|
||||
h_sources = mud.h
|
||||
cpp_sources = mud_all.c \
|
||||
mud.c \
|
||||
mud_encode.c \
|
||||
mud_friendly.c \
|
||||
mud_gen.c \
|
||||
mud_new.c \
|
||||
mud_tri_ti.c
|
||||
|
||||
include_HEADERS = mud.h
|
||||
|
||||
INCLUDES = -I.
|
||||
AM_CXXFLAGS = $(LOCAL_MUD_LIB_CXXFLAGS)
|
||||
|
||||
AM_LDFLAGS = $(LOCAL_LIB_LDFLAGS)
|
||||
CLEANFILES = *~ core
|
||||
|
||||
lib_LTLIBRARIES = libmud.la
|
||||
|
||||
libmud_la_SOURCES = $(h_sources) $(cpp_sources)
|
||||
libmud_la_LDFLAGS = $(AM_LDFLAGS)
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = mud.pc
|
||||
|
1062
src/external/mud/src/mud.c
vendored
Normal file
1062
src/external/mud/src/mud.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
683
src/external/mud/src/mud.h
vendored
Normal file
683
src/external/mud/src/mud.h
vendored
Normal file
@ -0,0 +1,683 @@
|
||||
#ifndef _MUD_H_
|
||||
#define _MUD_H_
|
||||
/*
|
||||
* v1.2
|
||||
*
|
||||
* revisions:
|
||||
* 01-mar-2000 DJA add UNKNOWN section, with no ID
|
||||
* 11-oct-2000 DJA add MUD_FMT_RAL_ID; MUD_setSizes
|
||||
* 22-Apr-2003 DJA add MUD_openReadWrite, MUD_openInOut
|
||||
*/
|
||||
|
||||
/*
|
||||
* FORMAT IDs - Must be unique!
|
||||
* format of ID is: 0xLLFFSSSS
|
||||
* where: LL = lab identifier
|
||||
* FF = format identifier
|
||||
* RR = revision
|
||||
* SS = section identifier
|
||||
*/
|
||||
|
||||
/*
|
||||
* Lab identifiers
|
||||
*/
|
||||
#define MUD_LAB_ALL_ID (0x01000000)
|
||||
#define MUD_LAB_TRI_ID (0x02000000)
|
||||
#define MUD_LAB_RAL_ID (0x03000000)
|
||||
#define MUD_LAB_PSI_ID (0x04000000)
|
||||
/*
|
||||
* Format identifiers
|
||||
*/
|
||||
#define MUD_FMT_ALL_ID (MUD_LAB_ALL_ID|0x00010000)
|
||||
#define MUD_FMT_GEN_ID (MUD_LAB_ALL_ID|0x00020000)
|
||||
#define MUD_FMT_TRI_TD_ID (MUD_LAB_TRI_ID|0x00010000)
|
||||
#define MUD_FMT_TRI_TI_ID (MUD_LAB_TRI_ID|0x00020000)
|
||||
|
||||
/*
|
||||
* ALL Format identifiers
|
||||
*/
|
||||
#define MUD_SEC_ID (MUD_FMT_ALL_ID|0x00000001)
|
||||
#define MUD_SEC_FIXED_ID (MUD_FMT_ALL_ID|0x00000002)
|
||||
#define MUD_SEC_GRP_ID (MUD_FMT_ALL_ID|0x00000003)
|
||||
#define MUD_SEC_EOF_ID (MUD_FMT_ALL_ID|0x00000004)
|
||||
#define MUD_SEC_CMT_ID (MUD_FMT_ALL_ID|0x00000005)
|
||||
|
||||
#define MUD_GRP_CMT_ID MUD_SEC_CMT_ID
|
||||
/*
|
||||
* GEN Format identifiers
|
||||
*/
|
||||
#define MUD_SEC_GEN_RUN_DESC_ID (MUD_FMT_GEN_ID|0x00000001)
|
||||
#define MUD_SEC_GEN_HIST_HDR_ID (MUD_FMT_GEN_ID|0x00000002)
|
||||
#define MUD_SEC_GEN_HIST_DAT_ID (MUD_FMT_GEN_ID|0x00000003)
|
||||
#define MUD_SEC_GEN_SCALER_ID (MUD_FMT_GEN_ID|0x00000004)
|
||||
#define MUD_SEC_GEN_IND_VAR_ID (MUD_FMT_GEN_ID|0x00000005)
|
||||
#define MUD_SEC_GEN_ARRAY_ID (MUD_FMT_GEN_ID|0x00000007)
|
||||
|
||||
#define MUD_GRP_GEN_HIST_ID (MUD_FMT_GEN_ID|0x00000002)
|
||||
#define MUD_GRP_GEN_SCALER_ID (MUD_FMT_GEN_ID|0x00000004)
|
||||
#define MUD_GRP_GEN_IND_VAR_ID (MUD_FMT_GEN_ID|0x00000005)
|
||||
#define MUD_GRP_GEN_IND_VAR_ARR_ID (MUD_FMT_GEN_ID|0x00000006)
|
||||
/*
|
||||
* TRI_TD Format identifiers
|
||||
*/
|
||||
#define MUD_SEC_TRI_TD_HIST_ID (MUD_FMT_TRI_TD_ID|0x00000002)
|
||||
|
||||
|
||||
#define MUD_GRP_TRI_TD_HIST_ID (MUD_FMT_TRI_TD_ID|0x00000002)
|
||||
#define MUD_GRP_TRI_TD_SCALER_ID (MUD_FMT_TRI_TD_ID|0x00000004)
|
||||
/*
|
||||
* TRI_TI Format identifiers
|
||||
*/
|
||||
#define MUD_SEC_TRI_TI_RUN_DESC_ID (MUD_FMT_TRI_TI_ID|0x00000001)
|
||||
#define MUD_SEC_TRI_TI_HIST_ID (MUD_FMT_TRI_TI_ID|0x00000002)
|
||||
|
||||
#define MUD_GRP_TRI_TI_HIST_ID MUD_SEC_TRI_TI_HIST_ID
|
||||
/*
|
||||
* RAL Format identifiers
|
||||
*/
|
||||
#define MUD_SEC_RAL_RUN_DESC_ID (MUD_FMT_RAL_ID|0x00000001)
|
||||
#define MUD_SEC_RAL_HIST_ID (MUD_FMT_RAL_ID|0x00000002)
|
||||
|
||||
#define MUD_GRP_RAL_HIST_ID MUD_SEC_RAL_HIST_ID
|
||||
/*
|
||||
* Add new format identifiers above this comment
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* MUD types
|
||||
*/
|
||||
typedef int STATUS;
|
||||
typedef char INT8;
|
||||
typedef unsigned char UINT8;
|
||||
typedef short INT16;
|
||||
typedef unsigned short UINT16;
|
||||
#ifdef __alpha
|
||||
typedef int INT32;
|
||||
typedef unsigned int UINT32;
|
||||
#else
|
||||
typedef long INT32;
|
||||
typedef unsigned long UINT32;
|
||||
#endif /* __alpha */
|
||||
typedef float REAL32;
|
||||
typedef double REAL64;
|
||||
typedef UINT32 TIME;
|
||||
#ifndef BOOL_DEFINED
|
||||
#define BOOL_DEFINED
|
||||
typedef UINT32 BOOL;
|
||||
#endif
|
||||
#if (defined(__alpha)&&defined(vms)) || defined(__BORLANDC__) || defined(__TURBOC__)
|
||||
typedef char* caddr_t;
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif /* !FALSE */
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif /* !TRUE */
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif /* !NULL */
|
||||
|
||||
#define SUCCESS 1
|
||||
#define FAILURE 0
|
||||
#ifndef _success
|
||||
#define _success(s) (s&1)
|
||||
#endif
|
||||
#ifndef _failure
|
||||
#define _failure(s) !(s&1)
|
||||
#endif
|
||||
/* avoid redefinitions if c_utils.h already included */
|
||||
/*#ifdef linux
|
||||
#include "c_utils.h"
|
||||
#else
|
||||
*/
|
||||
/*
|
||||
* c_utils.h, Defines for C utilities
|
||||
*/
|
||||
#if defined(vms) || defined(__MSDOS__)
|
||||
#define bcopy( b1, b2, len ) memcpy(b2,b1,len)
|
||||
#define bzero( b, len ) memset(b,(char)0,len)
|
||||
#endif /* vms || __MSDOS__ */
|
||||
#ifndef _C_UTILS_H_ /* conflict with c_utils.h */
|
||||
#define _max( a, b ) ( ( (a) > (b) ) ? (a) : (b) )
|
||||
#define _min( a, b ) ( ( (a) < (b) ) ? (a) : (b) )
|
||||
#define _strlen( s ) ((s!=NULL)?strlen(s):0)
|
||||
#define _swap32( l ) (((UINT32)l>>16)+((UINT32)l<<16))
|
||||
#define _swap16( s ) (((UINT16)s>>8)+((UINT16)s<<8))
|
||||
#endif
|
||||
#define _free(objp) if(objp!=NULL){free(objp);objp=NULL;}
|
||||
#define _roundUp( n, r ) ( (r) * (int)( ((n)+(r)-1) / (r) ) )
|
||||
|
||||
#define zalloc( n ) memset((void*)malloc(n),0,n)
|
||||
#if defined(vms) || (defined(mips)&&!defined(__sgi)) || (defined(__MSDOS__)&&defined(__STDC__))
|
||||
#define strdup( s ) strcpy((char*)malloc(strlen(s)+1),s)
|
||||
#endif /* vms || mips&&!sgi */
|
||||
/*#endif */
|
||||
typedef int (*MUD_PROC)();
|
||||
|
||||
typedef enum {
|
||||
MUD_ENCODE = 0,
|
||||
MUD_DECODE = 1,
|
||||
MUD_FREE = 2,
|
||||
MUD_GET_SIZE = 3,
|
||||
MUD_SHOW = 4,
|
||||
MUD_HEADS = 5
|
||||
} MUD_OPT;
|
||||
|
||||
typedef enum {
|
||||
MUD_ONE = 1,
|
||||
MUD_ALL = 2,
|
||||
MUD_GRP = 3
|
||||
} MUD_IO_OPT;
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct _MUD_SEC* pNext; /* pointer to next section */
|
||||
UINT32 size; /* total size occupied by the section */
|
||||
UINT32 secID; /* Ident of section type */
|
||||
UINT32 instanceID; /* Instance ID of section type */
|
||||
UINT32 sizeOf; /* sizeof struct (used for FORTRAN) */
|
||||
MUD_PROC proc; /* section handling procedure */
|
||||
} MUD_CORE;
|
||||
|
||||
|
||||
typedef struct _MUD_INDEX {
|
||||
struct _MUD_INDEX* pNext; /* pointer to next section */
|
||||
UINT32 offset; /* offset from end of group section */
|
||||
UINT32 secID; /* Ident of section type */
|
||||
UINT32 instanceID; /* Instance ID of section type */
|
||||
} MUD_INDEX;
|
||||
|
||||
|
||||
typedef struct _SEEK_ENTRY {
|
||||
struct _SEEK_ENTRY* pNext;
|
||||
UINT32 secID;
|
||||
UINT32 instanceID;
|
||||
} SEEK_ENTRY;
|
||||
|
||||
|
||||
/*
|
||||
* (Normally) for internal use only
|
||||
*/
|
||||
typedef struct {
|
||||
caddr_t buf;
|
||||
int pos;
|
||||
unsigned int size;
|
||||
} BUF;
|
||||
|
||||
|
||||
typedef struct _MUD_SEC {
|
||||
MUD_CORE core;
|
||||
} MUD_SEC;
|
||||
|
||||
/* the stub of a section used when we hit an unknown section type */
|
||||
typedef struct _MUD_SEC_UNKNOWN {
|
||||
MUD_CORE core;
|
||||
} MUD_SEC_UNKNOWN;
|
||||
|
||||
|
||||
/* First section of all MUD format files */
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 fileSize;
|
||||
UINT32 formatID;
|
||||
} MUD_SEC_FIXED;
|
||||
|
||||
|
||||
/* Generalized group section */
|
||||
typedef struct _MUD_SEC_GRP {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 num; /* number of group members */
|
||||
UINT32 memSize;
|
||||
MUD_INDEX* pMemIndex;
|
||||
MUD_SEC* pMem; /* pointer to list of group members */
|
||||
INT32 pos;
|
||||
struct _MUD_SEC_GRP* pParent;
|
||||
} MUD_SEC_GRP;
|
||||
|
||||
|
||||
/* Section indicating EOF */
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
} MUD_SEC_EOF;
|
||||
|
||||
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 ID;
|
||||
UINT32 prevReplyID;
|
||||
UINT32 nextReplyID;
|
||||
TIME time;
|
||||
char* author;
|
||||
char* title;
|
||||
char* comment;
|
||||
} MUD_SEC_CMT;
|
||||
|
||||
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 exptNumber;
|
||||
UINT32 runNumber;
|
||||
TIME timeBegin;
|
||||
TIME timeEnd;
|
||||
UINT32 elapsedSec;
|
||||
char* title;
|
||||
char* lab;
|
||||
char* area;
|
||||
char* method;
|
||||
char* apparatus;
|
||||
char* insert;
|
||||
char* sample;
|
||||
char* orient;
|
||||
char* das;
|
||||
char* experimenter;
|
||||
char* temperature;
|
||||
char* field;
|
||||
} MUD_SEC_GEN_RUN_DESC;
|
||||
|
||||
/* Generic histogram header structure */
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 histType;
|
||||
UINT32 nBytes;
|
||||
UINT32 nBins;
|
||||
UINT32 bytesPerBin;
|
||||
UINT32 fsPerBin;
|
||||
UINT32 t0_ps;
|
||||
UINT32 t0_bin;
|
||||
UINT32 goodBin1;
|
||||
UINT32 goodBin2;
|
||||
UINT32 bkgd1;
|
||||
UINT32 bkgd2;
|
||||
UINT32 nEvents;
|
||||
char* title;
|
||||
} MUD_SEC_GEN_HIST_HDR;
|
||||
|
||||
|
||||
/* Generic (packed,integer) histogram data structure */
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 nBytes;
|
||||
caddr_t pData; /* pointer to the histogram data */
|
||||
} MUD_SEC_GEN_HIST_DAT;
|
||||
|
||||
|
||||
/* Generic (packed) array data structure */
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 num; /* number of elements */
|
||||
UINT32 elemSize; /* size of element in bytes */
|
||||
UINT32 type; /* 1=integer, 2=real, 3=string */
|
||||
BOOL hasTime; /* TRUE if there is time data */
|
||||
UINT32 nBytes; /* bytes in pData - needed for packing */
|
||||
caddr_t pData; /* pointer to the array data */
|
||||
TIME* pTime; /* pointer to time data */
|
||||
} MUD_SEC_GEN_ARRAY;
|
||||
|
||||
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 counts[2];
|
||||
char* label;
|
||||
} MUD_SEC_GEN_SCALER;
|
||||
|
||||
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
double low;
|
||||
double high;
|
||||
double mean;
|
||||
double stddev;
|
||||
double skewness;
|
||||
char* name;
|
||||
char* description;
|
||||
char* units;
|
||||
} MUD_SEC_GEN_IND_VAR;
|
||||
|
||||
|
||||
typedef struct {
|
||||
MUD_CORE core;
|
||||
|
||||
UINT32 exptNumber;
|
||||
UINT32 runNumber;
|
||||
TIME timeBegin;
|
||||
TIME timeEnd;
|
||||
UINT32 elapsedSec;
|
||||
char* title;
|
||||
char* lab;
|
||||
char* area;
|
||||
char* method;
|
||||
char* apparatus;
|
||||
char* insert;
|
||||
char* sample;
|
||||
char* orient;
|
||||
char* das;
|
||||
char* experimenter;
|
||||
char* subtitle;
|
||||
char* comment1;
|
||||
char* comment2;
|
||||
char* comment3;
|
||||
} MUD_SEC_TRI_TI_RUN_DESC;
|
||||
|
||||
|
||||
#define MUD_pNext( pM ) (((MUD_SEC*)pM)->core.pNext)
|
||||
#define MUD_sizeOf( pM ) (((MUD_SEC*)pM)->core.sizeOf)
|
||||
#define MUD_size( pM ) (((MUD_SEC*)pM)->core.size)
|
||||
#define MUD_secID( pM ) (((MUD_SEC*)pM)->core.secID)
|
||||
#define MUD_instanceID( pM ) (((MUD_SEC*)pM)->core.instanceID)
|
||||
|
||||
|
||||
#if defined(__MSDOS__) || defined(__i386__) || defined(vax) || defined(__alpha) || (defined(__mips)&&!defined(__sgi))
|
||||
#define MUD_LITTLE_ENDIAN 1
|
||||
#else
|
||||
#define MUD_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#define _swap2bytes(s) ((s>>8)+(s<<8))
|
||||
#define _swap4bytes(l) ((l>>24)+(l<<24)+((l&0xff0000)>>8)+((l&0xff00)<<8))
|
||||
|
||||
#define bdecode_obj( b, p, s ) bcopy( b, p, s )
|
||||
#define bencode_obj( b, p, s ) bcopy( p, b, s )
|
||||
#define bdecode_1( b, p ) bcopy( b, p, 1 )
|
||||
#define bencode_1( b, p ) bcopy( p, b, 1 )
|
||||
|
||||
#define _decode_obj( b, p, s ) bcopy( &b->buf[b->pos], p, s );\
|
||||
b->pos+=s, b->size+=s
|
||||
#define _encode_obj( b, p, s ) bcopy( p, &b->buf[b->pos], s );\
|
||||
b->pos+=s, b->size+=s
|
||||
|
||||
#define decode_2( b, p ) bdecode_2(&b->buf[b->pos],p);\
|
||||
b->pos+=2, b->size+=2
|
||||
#define encode_2( b, p ) bencode_2(&b->buf[b->pos],p);\
|
||||
b->pos+=2, b->size+=2
|
||||
|
||||
#define decode_4( b, p ) bdecode_4(&b->buf[b->pos],p);\
|
||||
b->pos+=4, b->size+=4
|
||||
#define encode_4( b, p ) bencode_4(&b->buf[b->pos],p);\
|
||||
b->pos+=4, b->size+=4
|
||||
|
||||
#define decode_8( b, p ) bdecode_8(&b->buf[b->pos],p);\
|
||||
b->pos+=8, b->size+=8
|
||||
#define encode_8( b, p ) bencode_8(&b->buf[b->pos],p);\
|
||||
b->pos+=8, b->size+=8
|
||||
|
||||
#define decode_packed( b, p, n ) bdecode_packed(&b->buf[b->pos],p,n);\
|
||||
b->pos+=n, b->size+=n
|
||||
#define encode_packed( b, p, n ) bencode_packed(&b->buf[b->pos],p,n);\
|
||||
b->pos+=n, b->size+=n
|
||||
|
||||
#define _buf_pos( b ) b->pos
|
||||
#define _buf_addr( b ) &b->buf[b->pos]
|
||||
#define _set_buf_pos( b, pos ) b->pos = pos
|
||||
#define _incr_buf_pos( b, incr ) b->pos += incr
|
||||
|
||||
typedef UINT16 MUD_STR_LEN_TYPE;
|
||||
typedef UINT16 MUD_VAR_BIN_LEN_TYPE;
|
||||
typedef UINT8 MUD_VAR_BIN_SIZ_TYPE;
|
||||
|
||||
|
||||
#undef _ANSI_ARGS_
|
||||
#if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus)
|
||||
#define _ANSI_ARGS_(x) x
|
||||
#else
|
||||
#define _ANSI_ARGS_(x) ()
|
||||
#define NO_STDARG
|
||||
#endif /* STDC */
|
||||
|
||||
|
||||
/* mud.c */
|
||||
FILE *MUD_openInput _ANSI_ARGS_(( char *inFile ));
|
||||
FILE *MUD_openOutput _ANSI_ARGS_(( char *outFile ));
|
||||
FILE *MUD_openInOut _ANSI_ARGS_(( char *inFile ));
|
||||
void decode_str _ANSI_ARGS_(( BUF *pB , char **ps ));
|
||||
void encode_str _ANSI_ARGS_(( BUF *pB , char **ps ));
|
||||
void MUD_free _ANSI_ARGS_(( void* pMUD ));
|
||||
BOOL MUD_encode _ANSI_ARGS_(( BUF *pBuf , void* pMUD , MUD_IO_OPT io_opt ));
|
||||
void* MUD_decode _ANSI_ARGS_(( BUF *pBuf ));
|
||||
int MUD_getSize _ANSI_ARGS_(( void* pMUD ));
|
||||
void MUD_show _ANSI_ARGS_(( void* pMUD , MUD_IO_OPT io_opt ));
|
||||
void MUD_heads _ANSI_ARGS_(( void* pMUD , MUD_IO_OPT io_opt ));
|
||||
BOOL MUD_writeEnd _ANSI_ARGS_(( FILE *fout ));
|
||||
BOOL MUD_writeFile _ANSI_ARGS_(( FILE *fout , void* pMUD_head ));
|
||||
BOOL MUD_write _ANSI_ARGS_(( FILE *fout , void* pMUD , MUD_IO_OPT io_opt ));
|
||||
BOOL MUD_writeGrpStart _ANSI_ARGS_(( FILE *fout , MUD_SEC_GRP *pMUD_parentGrp , MUD_SEC_GRP *pMUD_grp , int numMems ));
|
||||
void addIndex _ANSI_ARGS_(( MUD_SEC_GRP *pMUD_grp , void* pMUD ));
|
||||
BOOL MUD_writeGrpMem _ANSI_ARGS_(( FILE *fout , MUD_SEC_GRP *pMUD_grp , void* pMUD ));
|
||||
BOOL MUD_writeGrpEnd _ANSI_ARGS_(( FILE *fout , MUD_SEC_GRP *pMUD_grp ));
|
||||
void* MUD_readFile _ANSI_ARGS_(( FILE *fin ));
|
||||
void* MUD_read _ANSI_ARGS_(( FILE *fin , MUD_IO_OPT io_opt ));
|
||||
UINT32 MUD_setSizes _ANSI_ARGS_(( void* pMUD ));
|
||||
MUD_SEC* MUD_peekCore _ANSI_ARGS_(( FILE *fin ));
|
||||
void* MUD_search _ANSI_ARGS_(( void* pMUD_head , ...));
|
||||
int MUD_fseek _ANSI_ARGS_(( FILE *fio , ...));
|
||||
MUD_SEC *fseekNext _ANSI_ARGS_(( FILE *fio , MUD_SEC_GRP *pMUD_parent , UINT32 secID , UINT32 instanceID ));
|
||||
int MUD_fseekFirst _ANSI_ARGS_(( FILE *fio ));
|
||||
void MUD_add _ANSI_ARGS_(( void** ppMUD_head , void* pMUD_new ));
|
||||
int MUD_totSize _ANSI_ARGS_(( void* pMUD ));
|
||||
void MUD_addToGroup _ANSI_ARGS_(( MUD_SEC_GRP *pMUD_grp , void* pMUD ));
|
||||
void MUD_assignCore _ANSI_ARGS_(( MUD_SEC *pMUD1 , MUD_SEC *pMUD2 ));
|
||||
int MUD_CORE_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC *pMUD ));
|
||||
int MUD_INDEX_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_INDEX *pMUD ));
|
||||
|
||||
/* mud_encode.c */
|
||||
void bdecode_2 _ANSI_ARGS_(( void *b , void *p ));
|
||||
void bencode_2 _ANSI_ARGS_(( void *b , void *p ));
|
||||
void bdecode_4 _ANSI_ARGS_(( void *b , void *p ));
|
||||
void bencode_4 _ANSI_ARGS_(( void *b , void *p ));
|
||||
void bdecode_8 _ANSI_ARGS_(( void *b , void *p ));
|
||||
void bencode_8 _ANSI_ARGS_(( void *b , void *p ));
|
||||
void decode_str _ANSI_ARGS_(( BUF *pB , char **ps ));
|
||||
void encode_str _ANSI_ARGS_(( BUF *pB , char **ps ));
|
||||
void bencode_float _ANSI_ARGS_(( char *buf , float *fp ));
|
||||
void encode_float _ANSI_ARGS_(( BUF *pBuf , float *fp ));
|
||||
void bdecode_float _ANSI_ARGS_(( char *buf , float *fp ));
|
||||
void decode_float _ANSI_ARGS_(( BUF *pBuf , float *fp ));
|
||||
void bencode_double _ANSI_ARGS_(( char *buf , double *dp ));
|
||||
void encode_double _ANSI_ARGS_(( BUF *pBuf , double *fp ));
|
||||
void bdecode_double _ANSI_ARGS_(( char *buf , double *dp ));
|
||||
void decode_double _ANSI_ARGS_(( BUF *pBuf , double *fp ));
|
||||
|
||||
/* mud_new.c */
|
||||
MUD_SEC *MUD_new _ANSI_ARGS_(( UINT32 secID , UINT32 instanceID ));
|
||||
|
||||
/* mud_all.c */
|
||||
int MUD_SEC_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC *pMUD ));
|
||||
int MUD_SEC_EOF_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_EOF *pMUD ));
|
||||
int MUD_SEC_FIXED_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_FIXED *pMUD ));
|
||||
int MUD_SEC_GRP_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_GRP *pMUD ));
|
||||
int MUD_SEC_CMT_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_CMT *pMUD ));
|
||||
int MUD_SEC_UNKNOWN_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_UNKNOWN *pMUD ));
|
||||
|
||||
/* mud_gen.c */
|
||||
int MUD_SEC_GEN_RUN_DESC_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_GEN_RUN_DESC *pMUD ));
|
||||
int MUD_SEC_GEN_HIST_HDR_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_GEN_HIST_HDR *pMUD ));
|
||||
int MUD_SEC_GEN_HIST_DAT_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_GEN_HIST_DAT *pMUD ));
|
||||
int MUD_SEC_GEN_SCALER_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_GEN_SCALER *pMUD ));
|
||||
int MUD_SEC_GEN_IND_VAR_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_GEN_IND_VAR *pMUD ));
|
||||
int MUD_SEC_GEN_ARRAY_proc _ANSI_ARGS_(( MUD_OPT op, BUF *pBuf, MUD_SEC_GEN_ARRAY *pMUD ));
|
||||
int MUD_SEC_GEN_HIST_pack _ANSI_ARGS_(( int num , int inBinSize , void* inHist , int outBinSize , void* outHist ));
|
||||
int MUD_SEC_GEN_HIST_unpack _ANSI_ARGS_(( int num , int inBinSize , void* inHist , int outBinSize , void* outHist ));
|
||||
|
||||
/* mud_tri_ti.c */
|
||||
int MUD_SEC_TRI_TI_RUN_DESC_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_TRI_TI_RUN_DESC *pMUD ));
|
||||
|
||||
/* gmf_time.c */
|
||||
void GMF_MKTIME _ANSI_ARGS_(( time_t* out , INT32* input ));
|
||||
void GMF_TIME _ANSI_ARGS_(( time_t* out ));
|
||||
void GMF_LOCALTIME _ANSI_ARGS_(( time_t* in , INT32 *out ));
|
||||
|
||||
/* mud_friendly.c */
|
||||
int MUD_openRead _ANSI_ARGS_(( char* filename, UINT32* pType ));
|
||||
int MUD_openWrite _ANSI_ARGS_(( char* filename, UINT32 type ));
|
||||
int MUD_openReadWrite _ANSI_ARGS_(( char* filename, UINT32* pType ));
|
||||
int MUD_closeRead _ANSI_ARGS_(( int fd ));
|
||||
int MUD_closeWrite _ANSI_ARGS_(( int fd ));
|
||||
int MUD_closeWriteFile _ANSI_ARGS_(( int fd, char* outfile ));
|
||||
|
||||
int MUD_getRunDesc _ANSI_ARGS_(( int fd, UINT32* pType ));
|
||||
int MUD_getExptNumber _ANSI_ARGS_(( int fd, UINT32* pExptNumber ));
|
||||
int MUD_getRunNumber _ANSI_ARGS_(( int fd, UINT32* pRunNumber ));
|
||||
int MUD_getElapsedSec _ANSI_ARGS_(( int fd, UINT32* pElapsedSec ));
|
||||
int MUD_getTimeBegin _ANSI_ARGS_(( int fd, UINT32* TimeBegin ));
|
||||
int MUD_getTimeEnd _ANSI_ARGS_(( int fd, UINT32* TimeEnd ));
|
||||
int MUD_getTitle _ANSI_ARGS_(( int fd, char* title, int strdim ));
|
||||
int MUD_getLab _ANSI_ARGS_(( int fd, char* lab, int strdim ));
|
||||
int MUD_getArea _ANSI_ARGS_(( int fd, char* area, int strdim ));
|
||||
int MUD_getMethod _ANSI_ARGS_(( int fd, char* method, int strdim ));
|
||||
int MUD_getApparatus _ANSI_ARGS_(( int fd, char* apparatus, int strdim ));
|
||||
int MUD_getInsert _ANSI_ARGS_(( int fd, char* insert, int strdim ));
|
||||
int MUD_getSample _ANSI_ARGS_(( int fd, char* sample, int strdim ));
|
||||
int MUD_getOrient _ANSI_ARGS_(( int fd, char* orient, int strdim ));
|
||||
int MUD_getDas _ANSI_ARGS_(( int fd, char* das, int strdim ));
|
||||
int MUD_getExperimenter _ANSI_ARGS_(( int fd, char* experimenter, int strdim ));
|
||||
int MUD_getTemperature _ANSI_ARGS_(( int fd, char* temperature, int strdim ));
|
||||
int MUD_getField _ANSI_ARGS_(( int fd, char* field, int strdim ));
|
||||
int MUD_getSubtitle _ANSI_ARGS_(( int fd, char* subtitle, int strdim ));
|
||||
int MUD_getComment1 _ANSI_ARGS_(( int fd, char* comment1, int strdim ));
|
||||
int MUD_getComment2 _ANSI_ARGS_(( int fd, char* comment2, int strdim ));
|
||||
int MUD_getComment3 _ANSI_ARGS_(( int fd, char* comment3, int strdim ));
|
||||
|
||||
int MUD_setRunDesc _ANSI_ARGS_(( int fd, UINT32 type ));
|
||||
int MUD_setExptNumber _ANSI_ARGS_(( int fd, UINT32 exptNumber ));
|
||||
int MUD_setRunNumber _ANSI_ARGS_(( int fd, UINT32 runNumber ));
|
||||
int MUD_setElapsedSec _ANSI_ARGS_(( int fd, UINT32 elapsedSec ));
|
||||
int MUD_setTimeBegin _ANSI_ARGS_(( int fd, UINT32 timeBegin ));
|
||||
int MUD_setTimeEnd _ANSI_ARGS_(( int fd, UINT32 timeEnd ));
|
||||
int MUD_setTitle _ANSI_ARGS_(( int fd, char* title ));
|
||||
int MUD_setLab _ANSI_ARGS_(( int fd, char* lab ));
|
||||
int MUD_setArea _ANSI_ARGS_(( int fd, char* area ));
|
||||
int MUD_setMethod _ANSI_ARGS_(( int fd, char* method ));
|
||||
int MUD_setApparatus _ANSI_ARGS_(( int fd, char* apparatus ));
|
||||
int MUD_setInsert _ANSI_ARGS_(( int fd, char* insert ));
|
||||
int MUD_setSample _ANSI_ARGS_(( int fd, char* sample ));
|
||||
int MUD_setOrient _ANSI_ARGS_(( int fd, char* orient ));
|
||||
int MUD_setDas _ANSI_ARGS_(( int fd, char* das ));
|
||||
int MUD_setExperimenter _ANSI_ARGS_(( int fd, char* experimenter ));
|
||||
int MUD_setTemperature _ANSI_ARGS_(( int fd, char* temperature ));
|
||||
int MUD_setField _ANSI_ARGS_(( int fd, char* field ));
|
||||
int MUD_setSubtitle _ANSI_ARGS_(( int fd, char* subtitle ));
|
||||
int MUD_setComment1 _ANSI_ARGS_(( int fd, char* comment1 ));
|
||||
int MUD_setComment2 _ANSI_ARGS_(( int fd, char* comment2 ));
|
||||
int MUD_setComment3 _ANSI_ARGS_(( int fd, char* comment3 ));
|
||||
|
||||
int MUD_getComments _ANSI_ARGS_(( int fd, UINT32* pType, UINT32* pNum ));
|
||||
int MUD_getCommentPrev _ANSI_ARGS_(( int fd, int num, UINT32* pPrev ));
|
||||
int MUD_getCommentNext _ANSI_ARGS_(( int fd, int num, UINT32* pNext ));
|
||||
int MUD_getCommentTime _ANSI_ARGS_(( int fd, int num, UINT32* pTime ));
|
||||
int MUD_getCommentAuthor _ANSI_ARGS_(( int fd, int num, char* author, int strdim ));
|
||||
int MUD_getCommentTitle _ANSI_ARGS_(( int fd, int num, char* title, int strdim ));
|
||||
int MUD_getCommentBody _ANSI_ARGS_(( int fd, int num, char* body, int strdim ));
|
||||
|
||||
int MUD_setComments _ANSI_ARGS_(( int fd, UINT32 type, UINT32 num ));
|
||||
int MUD_setCommentPrev _ANSI_ARGS_(( int fd, int num, UINT32 prev ));
|
||||
int MUD_setCommentNext _ANSI_ARGS_(( int fd, int num, UINT32 next ));
|
||||
int MUD_setCommentTime _ANSI_ARGS_(( int fd, int num, UINT32 time ));
|
||||
int MUD_setCommentAuthor _ANSI_ARGS_(( int fd, int num, char* author ));
|
||||
int MUD_setCommentTitle _ANSI_ARGS_(( int fd, int num, char* title ));
|
||||
int MUD_setCommentBody _ANSI_ARGS_(( int fd, int num, char* body ));
|
||||
|
||||
int MUD_getHists _ANSI_ARGS_(( int fd, UINT32* pType, UINT32* pNum ));
|
||||
int MUD_getHistType _ANSI_ARGS_(( int fd, int num, UINT32* pType ));
|
||||
int MUD_getHistNumBytes _ANSI_ARGS_(( int fd, int num, UINT32* pNumBytes ));
|
||||
int MUD_getHistNumBins _ANSI_ARGS_(( int fd, int num, UINT32* pNumBins ));
|
||||
int MUD_getHistBytesPerBin _ANSI_ARGS_(( int fd, int num, UINT32* pBytesPerBin ));
|
||||
int MUD_getHistFsPerBin _ANSI_ARGS_(( int fd, int num, UINT32* pFsPerBin ));
|
||||
int MUD_getHistSecondsPerBin _ANSI_ARGS_(( int fd, int num, REAL64* pSecondsPerBin ));
|
||||
int MUD_getHistT0_Ps _ANSI_ARGS_(( int fd, int num, UINT32* pT0_ps ));
|
||||
int MUD_getHistT0_Bin _ANSI_ARGS_(( int fd, int num, UINT32* pT0_bin ));
|
||||
int MUD_getHistGoodBin1 _ANSI_ARGS_(( int fd, int num, UINT32* pGoodBin1 ));
|
||||
int MUD_getHistGoodBin2 _ANSI_ARGS_(( int fd, int num, UINT32* pGoodBin2 ));
|
||||
int MUD_getHistBkgd1 _ANSI_ARGS_(( int fd, int num, UINT32* pBkgd1 ));
|
||||
int MUD_getHistBkgd2 _ANSI_ARGS_(( int fd, int num, UINT32* pBkgd2 ));
|
||||
int MUD_getHistNumEvents _ANSI_ARGS_(( int fd, int num, UINT32* pNumEvents ));
|
||||
int MUD_getHistTitle _ANSI_ARGS_(( int fd, int num, char* title, int strdim ));
|
||||
int MUD_getHistData _ANSI_ARGS_(( int fd, int num, void* pData ));
|
||||
int MUD_getHistpData _ANSI_ARGS_(( int fd, int num, void** ppData ));
|
||||
int MUD_getHistTimeData _ANSI_ARGS_(( int fd, int num, UINT32* pTimeData ));
|
||||
int MUD_getHistpTimeData _ANSI_ARGS_(( int fd, int num, UINT32** ppTimeData ));
|
||||
|
||||
int MUD_setHists _ANSI_ARGS_(( int fd, UINT32 type, UINT32 num ));
|
||||
int MUD_setHistType _ANSI_ARGS_(( int fd, int num, UINT32 type ));
|
||||
int MUD_setHistNumBytes _ANSI_ARGS_(( int fd, int num, UINT32 numBytes ));
|
||||
int MUD_setHistNumBins _ANSI_ARGS_(( int fd, int num, UINT32 numBins ));
|
||||
int MUD_setHistBytesPerBin _ANSI_ARGS_(( int fd, int num, UINT32 bytesPerBin ));
|
||||
int MUD_setHistFsPerBin _ANSI_ARGS_(( int fd, int num, UINT32 fsPerBin ));
|
||||
int MUD_setHistSecondsPerBin _ANSI_ARGS_(( int fd, int num, REAL64 secondsPerBin ));
|
||||
int MUD_setHistT0_Ps _ANSI_ARGS_(( int fd, int num, UINT32 t0_ps ));
|
||||
int MUD_setHistT0_Bin _ANSI_ARGS_(( int fd, int num, UINT32 t0_bin ));
|
||||
int MUD_setHistGoodBin1 _ANSI_ARGS_(( int fd, int num, UINT32 goodBin1 ));
|
||||
int MUD_setHistGoodBin2 _ANSI_ARGS_(( int fd, int num, UINT32 goodBin2 ));
|
||||
int MUD_setHistBkgd1 _ANSI_ARGS_(( int fd, int num, UINT32 bkgd1 ));
|
||||
int MUD_setHistBkgd2 _ANSI_ARGS_(( int fd, int num, UINT32 bkgd2 ));
|
||||
int MUD_setHistNumEvents _ANSI_ARGS_(( int fd, int num, UINT32 numEvents ));
|
||||
int MUD_setHistTitle _ANSI_ARGS_(( int fd, int num, char* title ));
|
||||
int MUD_setHistData _ANSI_ARGS_(( int fd, int num, void* pData ));
|
||||
int MUD_setHistpData _ANSI_ARGS_(( int fd, int num, void* pData ));
|
||||
int MUD_setHistTimeData _ANSI_ARGS_(( int fd, int num, UINT32* pTimeData ));
|
||||
int MUD_setHistpTimeData _ANSI_ARGS_(( int fd, int num, UINT32* pTimeData ));
|
||||
|
||||
int MUD_pack _ANSI_ARGS_(( int num, int inBinSize, void* inArray, int outBinSize, void* outArray ));
|
||||
int MUD_unpack _ANSI_ARGS_(( int num, int inBinSize, void* inArray, int outBinSize, void* outArray ));
|
||||
|
||||
int MUD_getScalers _ANSI_ARGS_(( int fd, UINT32* pType, UINT32* pNum ));
|
||||
int MUD_getScalerLabel _ANSI_ARGS_(( int fd, int num, char* label, int strdim ));
|
||||
int MUD_getScalerCounts _ANSI_ARGS_(( int fd, int num, UINT32* pCounts ));
|
||||
|
||||
int MUD_setScalers _ANSI_ARGS_(( int fd, UINT32 type, UINT32 num ));
|
||||
int MUD_setScalerLabel _ANSI_ARGS_(( int fd, int num, char* label ));
|
||||
int MUD_setScalerCounts _ANSI_ARGS_(( int fd, int num, UINT32* pCounts ));
|
||||
|
||||
int MUD_getIndVars _ANSI_ARGS_(( int fd, UINT32* pType, UINT32* pNum ));
|
||||
int MUD_getIndVarLow _ANSI_ARGS_(( int fd, int num, double* pLow ));
|
||||
int MUD_getIndVarHigh _ANSI_ARGS_(( int fd, int num, double* pHigh ));
|
||||
int MUD_getIndVarMean _ANSI_ARGS_(( int fd, int num, double* pMean ));
|
||||
int MUD_getIndVarStddev _ANSI_ARGS_(( int fd, int num, double* pStddev ));
|
||||
int MUD_getIndVarSkewness _ANSI_ARGS_(( int fd, int num, double* pSkewness ));
|
||||
int MUD_getIndVarName _ANSI_ARGS_(( int fd, int num, char* name, int strdim ));
|
||||
int MUD_getIndVarDescription _ANSI_ARGS_(( int fd, int num, char* description, int strdim ));
|
||||
int MUD_getIndVarUnits _ANSI_ARGS_(( int fd, int num, char* units, int strdim ));
|
||||
int MUD_getIndVarNumData _ANSI_ARGS_(( int fd, int num, UINT32* pNumData ));
|
||||
int MUD_getIndVarElemSize _ANSI_ARGS_(( int fd, int num, UINT32* pElemSize ));
|
||||
int MUD_getIndVarDataType _ANSI_ARGS_(( int fd, int num, UINT32* pDataType ));
|
||||
int MUD_getIndVarHasTime _ANSI_ARGS_(( int fd, int num, UINT32* pHasTime ));
|
||||
int MUD_getIndVarData _ANSI_ARGS_(( int fd, int num, void* pData ));
|
||||
int MUD_getIndVarTimeData _ANSI_ARGS_(( int fd, int num, UINT32* pTimeData ));
|
||||
int MUD_getIndVarpData _ANSI_ARGS_(( int fd, int num, void** ppData ));
|
||||
int MUD_getIndVarpTimeData _ANSI_ARGS_(( int fd, int num, UINT32** ppTimeData ));
|
||||
|
||||
int MUD_setIndVars _ANSI_ARGS_(( int fd, UINT32 type, UINT32 num ));
|
||||
int MUD_setIndVarLow _ANSI_ARGS_(( int fd, int num, double low ));
|
||||
int MUD_setIndVarHigh _ANSI_ARGS_(( int fd, int num, double high ));
|
||||
int MUD_setIndVarMean _ANSI_ARGS_(( int fd, int num, double mean ));
|
||||
int MUD_setIndVarStddev _ANSI_ARGS_(( int fd, int num, double stddev ));
|
||||
int MUD_setIndVarSkewness _ANSI_ARGS_(( int fd, int num, double skewness ));
|
||||
int MUD_setIndVarName _ANSI_ARGS_(( int fd, int num, char* name ));
|
||||
int MUD_setIndVarDescription _ANSI_ARGS_(( int fd, int num, char* description ));
|
||||
int MUD_setIndVarUnits _ANSI_ARGS_(( int fd, int num, char* units ));
|
||||
int MUD_setIndVarNumData _ANSI_ARGS_(( int fd, int num, UINT32 numData ));
|
||||
int MUD_setIndVarElemSize _ANSI_ARGS_(( int fd, int num, UINT32 elemSize ));
|
||||
int MUD_setIndVarDataType _ANSI_ARGS_(( int fd, int num, UINT32 dataType ));
|
||||
int MUD_setIndVarHasTime _ANSI_ARGS_(( int fd, int num, UINT32 hasTime ));
|
||||
int MUD_setIndVarData _ANSI_ARGS_(( int fd, int num, void* pData ));
|
||||
int MUD_setIndVarTimeData _ANSI_ARGS_(( int fd, int num, UINT32* pTimeData ));
|
||||
int MUD_setIndVarpData _ANSI_ARGS_(( int fd, int num, void* pData ));
|
||||
int MUD_setIndVarpTimeData _ANSI_ARGS_(( int fd, int num, UINT32* pTimeData ));
|
||||
|
||||
#endif /* _MUD_H_ */
|
||||
|
10
src/external/mud/src/mud.pc.in
vendored
Normal file
10
src/external/mud/src/mud.pc.in
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: mud
|
||||
Description: C shared library providing the triumf mud format functions
|
||||
Version: @MUD_VERSION@
|
||||
Libs: -L${libdir} -l@MUD_LIBRARY_NAME@
|
||||
Cflags: -I${includedir}
|
262
src/external/mud/src/mud_all.c
vendored
Normal file
262
src/external/mud/src/mud_all.c
vendored
Normal file
@ -0,0 +1,262 @@
|
||||
/*
|
||||
* mud_all.c -- procedures for MUD_FMT_ALL sections
|
||||
*
|
||||
* Revision history:
|
||||
* v1.00 15-Feb-1994 [T. Whidden] Initial version
|
||||
* v1.10 17-Feb-1994 [T. Whidden] Groups with member index
|
||||
* v1.2a 01-Mar-2000 DA Proc for unknown sections
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include "mud.h"
|
||||
|
||||
|
||||
int
|
||||
MUD_SEC_proc( op, pBuf, pMUD )
|
||||
MUD_OPT op;
|
||||
BUF* pBuf;
|
||||
MUD_SEC* pMUD;
|
||||
{
|
||||
int size;
|
||||
|
||||
switch( op )
|
||||
{
|
||||
case MUD_FREE:
|
||||
break;
|
||||
case MUD_DECODE:
|
||||
break;
|
||||
case MUD_ENCODE:
|
||||
break;
|
||||
case MUD_GET_SIZE:
|
||||
return( 0 );
|
||||
case MUD_SHOW:
|
||||
printf( " MUD_SEC: \n" );
|
||||
break;
|
||||
case MUD_HEADS:
|
||||
break;
|
||||
}
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
MUD_SEC_EOF_proc( op, pBuf, pMUD )
|
||||
MUD_OPT op;
|
||||
BUF* pBuf;
|
||||
MUD_SEC_EOF* pMUD;
|
||||
{
|
||||
int size;
|
||||
|
||||
switch( op )
|
||||
{
|
||||
case MUD_FREE:
|
||||
break;
|
||||
case MUD_DECODE:
|
||||
break;
|
||||
case MUD_ENCODE:
|
||||
break;
|
||||
case MUD_GET_SIZE:
|
||||
return( 0 );
|
||||
case MUD_SHOW:
|
||||
printf( " MUD_EOF: \n" );
|
||||
break;
|
||||
case MUD_HEADS:
|
||||
break;
|
||||
}
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
MUD_SEC_FIXED_proc( op, pBuf, pMUD )
|
||||
MUD_OPT op;
|
||||
BUF* pBuf;
|
||||
MUD_SEC_FIXED* pMUD;
|
||||
{
|
||||
int size;
|
||||
|
||||
switch( op )
|
||||
{
|
||||
case MUD_FREE:
|
||||
break;
|
||||
case MUD_DECODE:
|
||||
decode_4( pBuf, &pMUD->fileSize );
|
||||
decode_4( pBuf, &pMUD->formatID );
|
||||
break;
|
||||
case MUD_ENCODE:
|
||||
encode_4( pBuf, &pMUD->fileSize );
|
||||
encode_4( pBuf, &pMUD->formatID );
|
||||
break;
|
||||
case MUD_GET_SIZE:
|
||||
size = 2*sizeof( UINT32 );
|
||||
return( size );
|
||||
case MUD_SHOW:
|
||||
printf( " MUD_SEC_FIXED: fileSize=[%ld], formatID=[0x%08lX]\n",
|
||||
pMUD->fileSize, pMUD->formatID );
|
||||
break;
|
||||
case MUD_HEADS:
|
||||
break;
|
||||
}
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
MUD_SEC_GRP_proc( op, pBuf, pMUD )
|
||||
MUD_OPT op;
|
||||
BUF* pBuf;
|
||||
MUD_SEC_GRP* pMUD;
|
||||
{
|
||||
int size;
|
||||
int i;
|
||||
MUD_INDEX** ppMUD_index;
|
||||
MUD_INDEX* pMUD_index;
|
||||
|
||||
switch( op )
|
||||
{
|
||||
case MUD_FREE:
|
||||
MUD_INDEX_proc( MUD_FREE, NULL, pMUD->pMemIndex );
|
||||
MUD_free( pMUD->pMem );
|
||||
break;
|
||||
case MUD_DECODE:
|
||||
decode_4( pBuf, &pMUD->num );
|
||||
decode_4( pBuf, &pMUD->memSize );
|
||||
ppMUD_index = &pMUD->pMemIndex;
|
||||
for( i = 0; i < pMUD->num; i++ )
|
||||
{
|
||||
pMUD_index = (MUD_INDEX*)zalloc( sizeof( MUD_INDEX ) );
|
||||
MUD_INDEX_proc( MUD_DECODE, pBuf, pMUD_index );
|
||||
*ppMUD_index = pMUD_index;
|
||||
ppMUD_index = &(*ppMUD_index)->pNext;
|
||||
}
|
||||
break;
|
||||
case MUD_ENCODE:
|
||||
encode_4( pBuf, &pMUD->num );
|
||||
encode_4( pBuf, &pMUD->memSize );
|
||||
|
||||
for( pMUD_index = pMUD->pMemIndex;
|
||||
pMUD_index != NULL;
|
||||
pMUD_index = pMUD_index->pNext )
|
||||
MUD_INDEX_proc( MUD_ENCODE, pBuf, pMUD_index );
|
||||
break;
|
||||
case MUD_GET_SIZE:
|
||||
size = 2*sizeof( UINT32 );
|
||||
size += pMUD->num*MUD_INDEX_proc( MUD_GET_SIZE, NULL, NULL );
|
||||
return( size );
|
||||
case MUD_SHOW:
|
||||
printf( " MUD_SEC_GRP: num=[%ld], memSize=%ld\n",
|
||||
pMUD->num, pMUD->memSize );
|
||||
for( pMUD_index = pMUD->pMemIndex;
|
||||
pMUD_index != NULL;
|
||||
pMUD_index = pMUD_index->pNext )
|
||||
MUD_INDEX_proc( MUD_SHOW, NULL, pMUD_index );
|
||||
break;
|
||||
case MUD_HEADS:
|
||||
for( pMUD_index = pMUD->pMemIndex;
|
||||
pMUD_index != NULL;
|
||||
pMUD_index = pMUD_index->pNext )
|
||||
MUD_INDEX_proc( MUD_HEADS, NULL, pMUD_index );
|
||||
break;
|
||||
}
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
MUD_SEC_CMT_proc( op, pBuf, pMUD )
|
||||
MUD_OPT op;
|
||||
BUF* pBuf;
|
||||
MUD_SEC_CMT* pMUD;
|
||||
{
|
||||
int size;
|
||||
char tempStr1[32];
|
||||
|
||||
switch( op )
|
||||
{
|
||||
case MUD_FREE:
|
||||
_free( pMUD->author );
|
||||
_free( pMUD->title );
|
||||
_free( pMUD->comment );
|
||||
break;
|
||||
case MUD_DECODE:
|
||||
decode_4( pBuf, &pMUD->ID );
|
||||
decode_4( pBuf, &pMUD->prevReplyID );
|
||||
decode_4( pBuf, &pMUD->nextReplyID );
|
||||
decode_4( pBuf, &pMUD->time );
|
||||
decode_str( pBuf, &pMUD->author );
|
||||
decode_str( pBuf, &pMUD->title );
|
||||
decode_str( pBuf, &pMUD->comment );
|
||||
break;
|
||||
case MUD_ENCODE:
|
||||
encode_4( pBuf, &pMUD->ID );
|
||||
encode_4( pBuf, &pMUD->prevReplyID );
|
||||
encode_4( pBuf, &pMUD->nextReplyID );
|
||||
encode_4( pBuf, &pMUD->time );
|
||||
encode_str( pBuf, &pMUD->author );
|
||||
encode_str( pBuf, &pMUD->title );
|
||||
encode_str( pBuf, &pMUD->comment );
|
||||
break;
|
||||
case MUD_GET_SIZE:
|
||||
size = 3*sizeof( UINT32 );
|
||||
size += 1*sizeof( TIME );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->author );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->title );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->comment );
|
||||
return( size );
|
||||
case MUD_SHOW:
|
||||
printf( " MUD_SEC_CMT: \n" );
|
||||
printf( " number:[%ld], prevReply:[%ld], nextReply:[%ld]\n",
|
||||
pMUD->ID, pMUD->prevReplyID, pMUD->nextReplyID );
|
||||
strcpy( tempStr1, ctime( (time_t*)&pMUD->time ) );
|
||||
tempStr1[strlen(tempStr1)-1] = '\0';
|
||||
printf( " time:[%s]\n", tempStr1 );
|
||||
if( pMUD->author ) printf( " author:\"%s\"\n", pMUD->author );
|
||||
if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title );
|
||||
if( pMUD->comment ) printf( " comment:\"%s\"\n", pMUD->comment );
|
||||
break;
|
||||
case MUD_HEADS:
|
||||
printf( "Comment number %ld. ", pMUD->ID );
|
||||
if( pMUD->prevReplyID > 0 )
|
||||
printf(" Re: #%ld. ", pMUD->prevReplyID );
|
||||
if( pMUD->nextReplyID > 0 )
|
||||
printf(" Next: #%ld.", pMUD->nextReplyID );
|
||||
printf( "\n" );
|
||||
strcpy( tempStr1, ctime( (time_t*)&pMUD->time ) );
|
||||
tempStr1[strlen(tempStr1)-1] = '\0';
|
||||
if( pMUD->author ) printf( " author: %s, time: %s\n", pMUD->author, tempStr1 );
|
||||
if( pMUD->title ) printf( " title: %s\n", pMUD->title );
|
||||
if( pMUD->comment ) printf( "%s\n", pMUD->comment );
|
||||
break;
|
||||
}
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
MUD_SEC_UNKNOWN_proc( op, pBuf, pMUD )
|
||||
MUD_OPT op;
|
||||
BUF* pBuf;
|
||||
MUD_SEC_UNKNOWN* pMUD;
|
||||
{
|
||||
int size;
|
||||
|
||||
switch( op )
|
||||
{
|
||||
case MUD_FREE:
|
||||
break;
|
||||
case MUD_DECODE:
|
||||
break;
|
||||
case MUD_ENCODE:
|
||||
break;
|
||||
case MUD_GET_SIZE:
|
||||
return( 0 );
|
||||
case MUD_SHOW:
|
||||
printf( " UNKNOWN MUD SECTION: [] \n" );
|
||||
break;
|
||||
case MUD_HEADS:
|
||||
break;
|
||||
}
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
|
480
src/external/mud/src/mud_encode.c
vendored
Normal file
480
src/external/mud/src/mud_encode.c
vendored
Normal file
@ -0,0 +1,480 @@
|
||||
/*
|
||||
* mud_encode.c -- encode/decode
|
||||
*
|
||||
* Float stuff adapted from Sun RPC xdr_float.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mud.h"
|
||||
|
||||
|
||||
void
|
||||
bdecode_2( b, p )
|
||||
void* b;
|
||||
void* p;
|
||||
{
|
||||
#ifdef MUD_BIG_ENDIAN
|
||||
UINT16 i;
|
||||
bcopy( b, &i, 2 );
|
||||
i = _swap2bytes(i);
|
||||
bcopy( &i, p, 2 );
|
||||
#else
|
||||
bcopy( b, p, 2 );
|
||||
#endif /* MUD_BIG_ENDIAN */
|
||||
}
|
||||
|
||||
void
|
||||
bencode_2( b, p )
|
||||
void* b;
|
||||
void* p;
|
||||
{
|
||||
#ifdef MUD_BIG_ENDIAN
|
||||
UINT16 i;
|
||||
bcopy( p, &i, 2 );
|
||||
#ifdef DEBUG
|
||||
printf( "bencode_2: got %04X,", i );
|
||||
#endif
|
||||
i = _swap2bytes(i);
|
||||
#ifdef DEBUG
|
||||
printf( "coded %04X\n", i );
|
||||
#endif
|
||||
bcopy( &i, b, 2 );
|
||||
#else
|
||||
bcopy( p, b, 2 );
|
||||
#endif /* MUD_BIG_ENDIAN */
|
||||
}
|
||||
|
||||
void
|
||||
bdecode_4( b, p )
|
||||
void* b;
|
||||
void* p;
|
||||
{
|
||||
#ifdef MUD_BIG_ENDIAN
|
||||
UINT32 i;
|
||||
bcopy( b, &i, 4 );
|
||||
i = _swap4bytes(i);
|
||||
bcopy( &i, p, 4 );
|
||||
#else
|
||||
bcopy( b, p, 4 );
|
||||
#endif /* MUD_BIG_ENDIAN */
|
||||
}
|
||||
|
||||
void
|
||||
bencode_4( b, p )
|
||||
void* b;
|
||||
void* p;
|
||||
{
|
||||
#ifdef MUD_BIG_ENDIAN
|
||||
UINT32 i;
|
||||
bcopy( p, &i, 4 );
|
||||
i = _swap4bytes(i);
|
||||
bcopy( &i, b, 4 );
|
||||
#else
|
||||
bcopy( p, b, 4 );
|
||||
#endif /* MUD_BIG_ENDIAN */
|
||||
}
|
||||
|
||||
void
|
||||
bdecode_8( b, p )
|
||||
void* b;
|
||||
void* p;
|
||||
{
|
||||
#ifdef MUD_BIG_ENDIAN
|
||||
UINT32 i[2], i2[2];
|
||||
bcopy( b, i, 8 );
|
||||
i2[1] = _swap4bytes(i[0]);
|
||||
i2[0] = _swap4bytes(i[1]);
|
||||
bcopy( i2, p, 8 );
|
||||
#else
|
||||
bcopy( b, p, 8 );
|
||||
#endif /* MUD_BIG_ENDIAN */
|
||||
}
|
||||
|
||||
void
|
||||
bencode_8( b, p )
|
||||
void* b;
|
||||
void* p;
|
||||
{
|
||||
#ifdef MUD_BIG_ENDIAN
|
||||
UINT32 i[2], i2[2];
|
||||
bcopy( p, i, 8 );
|
||||
i2[1] = _swap4bytes(i[0]);
|
||||
i2[0] = _swap4bytes(i[1]);
|
||||
bcopy( i2, b, 8 );
|
||||
#else
|
||||
bcopy( p, b, 8 );
|
||||
#endif /* MUD_BIG_ENDIAN */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
decode_str( pB, ps )
|
||||
BUF* pB;
|
||||
char** ps;
|
||||
{
|
||||
MUD_STR_LEN_TYPE len;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "buf pos = %d\n", pB->pos );
|
||||
printf( "decoding string length...\n" );
|
||||
#endif /* DEBUG */
|
||||
bdecode_2( (void*)&(pB->buf[pB->pos]), (void*)&len );
|
||||
#ifdef DEBUG
|
||||
printf( "string len %d\n", len );
|
||||
#endif /* DEBUG */
|
||||
pB->pos += 2;
|
||||
pB->size += 2;
|
||||
if( *ps == NULL ) *ps = (char*)zalloc( len+1 );
|
||||
strncpy( *ps, &pB->buf[pB->pos], len );
|
||||
pB->pos += len;
|
||||
pB->size += len;
|
||||
#ifdef DEBUG
|
||||
printf( "string:\"%s\"\n", *ps );
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
encode_str( pB, ps )
|
||||
BUF* pB;
|
||||
char** ps;
|
||||
{
|
||||
MUD_STR_LEN_TYPE len;
|
||||
|
||||
len = _strlen( *ps );
|
||||
bencode_2( (void*)&pB->buf[pB->pos], (void*)&len );
|
||||
pB->pos += 2;
|
||||
pB->size += 2;
|
||||
strncpy( &pB->buf[pB->pos], *ps, len );
|
||||
pB->pos += len;
|
||||
pB->size += len;
|
||||
}
|
||||
|
||||
|
||||
#ifndef VMS
|
||||
|
||||
#ifdef MUD_LITTLE_ENDIAN
|
||||
struct ieee_single {
|
||||
unsigned int mantissa2 : 16;
|
||||
unsigned int mantissa1 : 7;
|
||||
unsigned int exp : 8;
|
||||
unsigned int sign : 1;
|
||||
};
|
||||
struct vax_single {
|
||||
unsigned int mantissa1 : 7;
|
||||
unsigned int exp : 8;
|
||||
unsigned int sign : 1;
|
||||
unsigned int mantissa2 : 16;
|
||||
};
|
||||
static struct sgl_limits {
|
||||
struct vax_single s;
|
||||
struct ieee_single ieee;
|
||||
} sgl_limits[2] = {
|
||||
{{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */
|
||||
{ 0x0, 0x0, 0xff, 0x0 }}, /* Max IEEE */
|
||||
{{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */
|
||||
{ 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */
|
||||
};
|
||||
#else
|
||||
struct ieee_single {
|
||||
unsigned int sign : 1;
|
||||
unsigned int exp : 8;
|
||||
unsigned int mantissa1 : 7;
|
||||
unsigned int mantissa2 : 16;
|
||||
};
|
||||
struct vax_single {
|
||||
unsigned int mantissa2 : 16;
|
||||
unsigned int sign : 1;
|
||||
unsigned int exp : 8;
|
||||
unsigned int mantissa1 : 7;
|
||||
};
|
||||
static struct sgl_limits {
|
||||
struct vax_single s;
|
||||
struct ieee_single ieee;
|
||||
} sgl_limits[2] = {
|
||||
{{ 0xffff, 0x0, 0xff, 0x7f }, /* Max Vax */
|
||||
{ 0x0, 0xff, 0x0, 0x0 }}, /* Max IEEE */
|
||||
{{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */
|
||||
{ 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */
|
||||
};
|
||||
#endif /* ENDIAN */
|
||||
|
||||
#define VAX_SNG_BIAS 0x81
|
||||
#define IEEE_SNG_BIAS 0x7f
|
||||
|
||||
#endif /* !VMS */
|
||||
|
||||
void
|
||||
bencode_float( buf, fp )
|
||||
char* buf;
|
||||
float* fp;
|
||||
{
|
||||
#ifndef VMS
|
||||
struct ieee_single is;
|
||||
struct vax_single vs;
|
||||
struct sgl_limits *lim;
|
||||
int i;
|
||||
UINT16 sa[2], sb[2];
|
||||
#endif /* !VMS */
|
||||
|
||||
#ifdef VMS
|
||||
bencode_4( buf, fp );
|
||||
#else
|
||||
is = *((struct ieee_single*)fp);
|
||||
|
||||
for( i = 0, lim = sgl_limits;
|
||||
i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
|
||||
i++, lim++)
|
||||
{
|
||||
if( ( is.mantissa1 == lim->ieee.mantissa1 ) &&
|
||||
( is.mantissa2 == lim->ieee.mantissa2 ) &&
|
||||
( is.exp == lim->ieee.exp ) )
|
||||
{
|
||||
vs = lim->s;
|
||||
goto shipit;
|
||||
}
|
||||
}
|
||||
vs.exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
|
||||
vs.mantissa2 = is.mantissa2;
|
||||
vs.mantissa1 = is.mantissa1;
|
||||
shipit:
|
||||
vs.sign = is.sign;
|
||||
bencode_4( (void*)buf, (void*)&vs );
|
||||
#endif /* VMS */
|
||||
}
|
||||
|
||||
void
|
||||
encode_float( pBuf, fp )
|
||||
BUF* pBuf;
|
||||
float* fp;
|
||||
{
|
||||
bencode_float( &(pBuf->buf[pBuf->pos]), fp );
|
||||
pBuf->pos += 4;
|
||||
pBuf->size += 4;
|
||||
}
|
||||
|
||||
void
|
||||
bdecode_float( buf, fp )
|
||||
char* buf;
|
||||
float* fp;
|
||||
{
|
||||
#ifndef VMS
|
||||
struct ieee_single *isp;
|
||||
struct vax_single vs;
|
||||
struct sgl_limits *lim;
|
||||
int i;
|
||||
#endif /* !VMS */
|
||||
|
||||
#ifdef VMS
|
||||
bdecode_4( (void*)buf, (void*)fp );
|
||||
#else
|
||||
bdecode_4( (void*)buf, (void*)&vs );
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "man1:%d man2:%d exp:%d sign:%d\n",
|
||||
vs.mantissa1, vs.mantissa2, vs.exp, vs.sign );
|
||||
#endif /* DEBUG */
|
||||
|
||||
isp = (struct ieee_single*)fp;
|
||||
for( i = 0, lim = sgl_limits;
|
||||
i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
|
||||
i++, lim++ )
|
||||
{
|
||||
if( ( vs.mantissa2 == lim->s.mantissa2 ) &&
|
||||
( vs.exp == lim->s.exp ) &&
|
||||
( vs.mantissa1 == lim->s.mantissa1 ) )
|
||||
{
|
||||
*isp = lim->ieee;
|
||||
goto shipit;
|
||||
}
|
||||
}
|
||||
isp->exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
|
||||
isp->mantissa1 = vs.mantissa1;
|
||||
isp->mantissa2 = vs.mantissa2;
|
||||
shipit:
|
||||
isp->sign = vs.sign;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
decode_float( pBuf, fp )
|
||||
BUF* pBuf;
|
||||
float* fp;
|
||||
{
|
||||
bdecode_float( &(pBuf->buf[pBuf->pos]), fp );
|
||||
pBuf->pos += 4;
|
||||
pBuf->size += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine works on Suns (Sky / 68000's) and Vaxen.
|
||||
*/
|
||||
|
||||
#ifndef VMS
|
||||
|
||||
#ifdef MUD_LITTLE_ENDIAN
|
||||
struct ieee_double {
|
||||
unsigned int mantissa4 : 16;
|
||||
unsigned int mantissa3 : 16;
|
||||
unsigned int mantissa2 : 16;
|
||||
unsigned int mantissa1 : 4;
|
||||
unsigned int exp : 11;
|
||||
unsigned int sign : 1;
|
||||
};
|
||||
struct vax_double {
|
||||
unsigned int mantissa1 : 7;
|
||||
unsigned int exp : 8;
|
||||
unsigned int sign : 1;
|
||||
unsigned int mantissa2 : 16;
|
||||
unsigned int mantissa3 : 16;
|
||||
unsigned int mantissa4 : 16;
|
||||
};
|
||||
static struct dbl_limits {
|
||||
struct vax_double d;
|
||||
struct ieee_double ieee;
|
||||
} dbl_limits[2] = {
|
||||
{{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */
|
||||
{ 0x0, 0x0, 0x0, 0x0, 0x7ff, 0x0 }}, /* Max IEEE */
|
||||
{{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */
|
||||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */
|
||||
};
|
||||
#else
|
||||
struct ieee_double {
|
||||
unsigned int sign : 1;
|
||||
unsigned int exp : 11;
|
||||
unsigned int mantissa1 : 4;
|
||||
unsigned int mantissa2 : 16;
|
||||
unsigned int mantissa3 : 16;
|
||||
unsigned int mantissa4 : 16;
|
||||
};
|
||||
struct vax_double {
|
||||
unsigned int mantissa4 : 16;
|
||||
unsigned int mantissa3 : 16;
|
||||
unsigned int mantissa2 : 16;
|
||||
unsigned int sign : 1;
|
||||
unsigned int exp : 8;
|
||||
unsigned int mantissa1 : 7;
|
||||
};
|
||||
static struct dbl_limits {
|
||||
struct vax_double d;
|
||||
struct ieee_double ieee;
|
||||
} dbl_limits[2] = {
|
||||
{{ 0xffff, 0xffff, 0xffff, 0x0, 0xff, 0x7f }, /* Max Vax */
|
||||
{ 0x0, 0x7ff, 0x0, 0x0, 0x0, 0x0 }}, /* Max IEEE */
|
||||
{{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */
|
||||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */
|
||||
};
|
||||
#endif /* ENDIAN */
|
||||
|
||||
#define VAX_DBL_BIAS 0x81
|
||||
#define IEEE_DBL_BIAS 0x3ff
|
||||
#define MASK(nbits) ((1 << nbits) - 1)
|
||||
|
||||
#endif /* !VMS */
|
||||
|
||||
|
||||
void
|
||||
bencode_double( buf, dp )
|
||||
char* buf;
|
||||
double* dp;
|
||||
{
|
||||
#ifndef VMS
|
||||
struct ieee_double id;
|
||||
struct vax_double vd;
|
||||
register struct dbl_limits *lim;
|
||||
int i;
|
||||
UINT16 sa[4], sb[4];
|
||||
#endif /* !VMS */
|
||||
|
||||
#ifdef VMS
|
||||
bencode_8( buf, dp );
|
||||
#else
|
||||
id = *((struct ieee_double*)dp);
|
||||
for( i = 0, lim = dbl_limits;
|
||||
i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
|
||||
i++, lim++)
|
||||
{
|
||||
if( ( id.mantissa2 == lim->ieee.mantissa2 ) &&
|
||||
( id.mantissa1 == lim->ieee.mantissa1 ) &&
|
||||
( id.mantissa3 == lim->ieee.mantissa3 ) &&
|
||||
( id.mantissa4 == lim->ieee.mantissa4 ) &&
|
||||
( id.exp == lim->ieee.exp ) )
|
||||
{
|
||||
vd = lim->d;
|
||||
goto shipit;
|
||||
}
|
||||
}
|
||||
vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
|
||||
vd.mantissa1 = ( id.mantissa1 << 3 ) | (id.mantissa2 >> 13);
|
||||
vd.mantissa2 = (id.mantissa2 << 3) | (id.mantissa3 >> 13);
|
||||
vd.mantissa3 = (id.mantissa3 << 3) | (id.mantissa4 >> 13);
|
||||
vd.mantissa4 = (id.mantissa4 << 3);
|
||||
shipit:
|
||||
vd.sign = id.sign;
|
||||
bencode_8( buf, &vd );
|
||||
#endif /* VMS */
|
||||
}
|
||||
|
||||
void
|
||||
encode_double( pBuf, fp )
|
||||
BUF* pBuf;
|
||||
double* fp;
|
||||
{
|
||||
bencode_double( &(pBuf->buf[pBuf->pos]), fp );
|
||||
pBuf->pos += 8;
|
||||
pBuf->size += 8;
|
||||
}
|
||||
|
||||
void
|
||||
bdecode_double( buf, dp )
|
||||
char* buf;
|
||||
double* dp;
|
||||
{
|
||||
#ifndef VMS
|
||||
struct ieee_double id, *idp;
|
||||
struct vax_double vd;
|
||||
register struct dbl_limits *lim;
|
||||
int i;
|
||||
UINT16 sa[4], sb[4];
|
||||
#endif /* !VMS */
|
||||
|
||||
#ifdef VMS
|
||||
bdecode_8( buf, dp );
|
||||
#else
|
||||
bdecode_8( buf, &vd );
|
||||
idp = (struct ieee_double*)dp;
|
||||
for( i = 0, lim = dbl_limits;
|
||||
i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
|
||||
i++, lim++)
|
||||
{
|
||||
if( ( vd.mantissa4 == lim->d.mantissa4 ) &&
|
||||
( vd.mantissa3 == lim->d.mantissa3 ) &&
|
||||
( vd.mantissa2 == lim->d.mantissa2 ) &&
|
||||
( vd.mantissa1 == lim->d.mantissa1 ) &&
|
||||
( vd.exp == lim->d.exp ) )
|
||||
{
|
||||
*idp = lim->ieee;
|
||||
goto shipit;
|
||||
}
|
||||
}
|
||||
idp->exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
|
||||
idp->mantissa1 = vd.mantissa1 >> 3;
|
||||
idp->mantissa2 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3);
|
||||
idp->mantissa3 = (vd.mantissa2 << 13) | (vd.mantissa3 >> 3);
|
||||
idp->mantissa4 = (vd.mantissa3 << 13) | (vd.mantissa4 >> 3);
|
||||
shipit:
|
||||
idp->sign = vd.sign;
|
||||
#endif /* VMS */
|
||||
}
|
||||
|
||||
void
|
||||
decode_double( pBuf, fp )
|
||||
BUF* pBuf;
|
||||
double* fp;
|
||||
{
|
||||
bdecode_double( &(pBuf->buf[pBuf->pos]), fp );
|
||||
pBuf->pos += 8;
|
||||
pBuf->size += 8;
|
||||
}
|
||||
|
1829
src/external/mud/src/mud_friendly.c
vendored
Normal file
1829
src/external/mud/src/mud_friendly.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1077
src/external/mud/src/mud_gen.c
vendored
Normal file
1077
src/external/mud/src/mud_gen.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
127
src/external/mud/src/mud_new.c
vendored
Normal file
127
src/external/mud/src/mud_new.c
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* mud_new.c -- Procedure for mallocing and initializing a new MUD section.
|
||||
* This routine is used for _all_ section types, and so a
|
||||
* CASE entry must be added for each unique type.
|
||||
*
|
||||
* Revision history:
|
||||
* v1.0 26-Jan-1994 [TW] Initial version
|
||||
* v1.0a 08-Feb-1994 [TW] Added sizeOf to core
|
||||
* v1.0b 15-Feb-1994 [TW] Split ...GEN_HIST to ...GEN_HIST_HDR
|
||||
* and ...GEN_HIST_DAT
|
||||
* v1.0c 25-Apr-1994 [TW] Added CAMP sections
|
||||
* v1.1 21-Feb-1996 TW Remove CAMP sections, add GEN_ARRAY
|
||||
* v1.2a 01-Mar-2000 DA Add handling of unidentified sections (don't quit)
|
||||
*/
|
||||
|
||||
#include "mud.h"
|
||||
|
||||
|
||||
MUD_SEC*
|
||||
MUD_new( secID, instanceID )
|
||||
UINT32 secID;
|
||||
UINT32 instanceID;
|
||||
{
|
||||
MUD_SEC* pMUD_new;
|
||||
MUD_PROC proc;
|
||||
int sizeOf;
|
||||
|
||||
switch( secID )
|
||||
{
|
||||
case MUD_SEC_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC ) );
|
||||
proc = MUD_SEC_proc;
|
||||
sizeOf = sizeof( MUD_SEC );
|
||||
break;
|
||||
case MUD_SEC_FIXED_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_FIXED ) );
|
||||
proc = MUD_SEC_FIXED_proc;
|
||||
sizeOf = sizeof( MUD_SEC_FIXED );
|
||||
break;
|
||||
case MUD_SEC_GRP_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GRP ) );
|
||||
proc = MUD_SEC_GRP_proc;
|
||||
sizeOf = sizeof( MUD_SEC_GRP );
|
||||
break;
|
||||
case MUD_SEC_EOF_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_EOF ) );
|
||||
proc = MUD_SEC_EOF_proc;
|
||||
sizeOf = sizeof( MUD_SEC_EOF );
|
||||
break;
|
||||
case MUD_SEC_CMT_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CMT ) );
|
||||
proc = MUD_SEC_CMT_proc;
|
||||
sizeOf = sizeof( MUD_SEC_CMT );
|
||||
break;
|
||||
case MUD_SEC_GEN_RUN_DESC_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_RUN_DESC ) );
|
||||
proc = MUD_SEC_GEN_RUN_DESC_proc;
|
||||
sizeOf = sizeof( MUD_SEC_GEN_RUN_DESC );
|
||||
break;
|
||||
case MUD_SEC_GEN_HIST_HDR_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_HIST_HDR ) );
|
||||
proc = MUD_SEC_GEN_HIST_HDR_proc;
|
||||
sizeOf = sizeof( MUD_SEC_GEN_HIST_HDR );
|
||||
break;
|
||||
case MUD_SEC_GEN_HIST_DAT_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_HIST_DAT ) );
|
||||
proc = MUD_SEC_GEN_HIST_DAT_proc;
|
||||
sizeOf = sizeof( MUD_SEC_GEN_HIST_DAT );
|
||||
break;
|
||||
case MUD_SEC_GEN_SCALER_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_SCALER ) );
|
||||
proc = MUD_SEC_GEN_SCALER_proc;
|
||||
sizeOf = sizeof( MUD_SEC_GEN_SCALER );
|
||||
break;
|
||||
case MUD_SEC_GEN_IND_VAR_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_IND_VAR ) );
|
||||
proc = MUD_SEC_GEN_IND_VAR_proc;
|
||||
sizeOf = sizeof( MUD_SEC_GEN_IND_VAR );
|
||||
break;
|
||||
case MUD_SEC_GEN_ARRAY_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_ARRAY ) );
|
||||
proc = MUD_SEC_GEN_ARRAY_proc;
|
||||
sizeOf = sizeof( MUD_SEC_GEN_ARRAY );
|
||||
break;
|
||||
case MUD_SEC_TRI_TI_RUN_DESC_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_TRI_TI_RUN_DESC ) );
|
||||
proc = MUD_SEC_TRI_TI_RUN_DESC_proc;
|
||||
sizeOf = sizeof( MUD_SEC_TRI_TI_RUN_DESC );
|
||||
break;
|
||||
/*
|
||||
case MUD_SEC_CAMP_NUM_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_NUM ) );
|
||||
proc = MUD_SEC_CAMP_NUM_proc;
|
||||
sizeOf = sizeof( MUD_SEC_CAMP_NUM );
|
||||
break;
|
||||
case MUD_SEC_CAMP_STR_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_STR ) );
|
||||
proc = MUD_SEC_CAMP_STR_proc;
|
||||
sizeOf = sizeof( MUD_SEC_CAMP_STR );
|
||||
break;
|
||||
case MUD_SEC_CAMP_SEL_ID:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_SEL ) );
|
||||
proc = MUD_SEC_CAMP_SEL_proc;
|
||||
sizeOf = sizeof( MUD_SEC_CAMP_SEL );
|
||||
break;
|
||||
*/
|
||||
|
||||
/* add action for unknown */
|
||||
default:
|
||||
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_UNKNOWN ) );
|
||||
proc = MUD_SEC_UNKNOWN_proc;
|
||||
sizeOf = sizeof( MUD_SEC_UNKNOWN );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if( pMUD_new == NULL ) return( NULL );
|
||||
|
||||
pMUD_new->core.sizeOf = sizeOf;
|
||||
pMUD_new->core.secID = secID;
|
||||
pMUD_new->core.instanceID = instanceID;
|
||||
pMUD_new->core.proc = proc;
|
||||
|
||||
return( pMUD_new );
|
||||
}
|
||||
|
||||
|
170
src/external/mud/src/mud_tri_ti.c
vendored
Normal file
170
src/external/mud/src/mud_tri_ti.c
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* mud_tri_ti.c -- procedures for MUD_FMT_TRI_TI sections
|
||||
*
|
||||
* Revision history:
|
||||
* v1.0 26-Jan-1994 [T. Whidden] Initial version
|
||||
* v1.0a 14-Apr-1994 [T. Whidden] operator -> experimenter
|
||||
* v1.0b 22-Apr-1994 [T. Whidden] rename TI to TRI_TI
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include "mud.h"
|
||||
|
||||
|
||||
int
|
||||
MUD_SEC_TRI_TI_RUN_DESC_proc( op, pBuf, pMUD )
|
||||
MUD_OPT op;
|
||||
BUF* pBuf;
|
||||
MUD_SEC_TRI_TI_RUN_DESC* pMUD;
|
||||
{
|
||||
int size;
|
||||
char tempStr1[32];
|
||||
char tempStr2[32];
|
||||
|
||||
switch( op )
|
||||
{
|
||||
case MUD_FREE:
|
||||
_free( pMUD->title );
|
||||
_free( pMUD->lab );
|
||||
_free( pMUD->area );
|
||||
_free( pMUD->method );
|
||||
_free( pMUD->apparatus );
|
||||
_free( pMUD->insert );
|
||||
_free( pMUD->sample );
|
||||
_free( pMUD->orient );
|
||||
_free( pMUD->das );
|
||||
_free( pMUD->experimenter );
|
||||
_free( pMUD->subtitle );
|
||||
_free( pMUD->comment1 );
|
||||
_free( pMUD->comment2 );
|
||||
_free( pMUD->comment3 );
|
||||
break;
|
||||
case MUD_DECODE:
|
||||
decode_4( pBuf, &pMUD->exptNumber );
|
||||
decode_4( pBuf, &pMUD->runNumber );
|
||||
decode_4( pBuf, &pMUD->timeBegin );
|
||||
decode_4( pBuf, &pMUD->timeEnd );
|
||||
decode_4( pBuf, &pMUD->elapsedSec );
|
||||
decode_str( pBuf, &pMUD->title );
|
||||
decode_str( pBuf, &pMUD->lab );
|
||||
decode_str( pBuf, &pMUD->area );
|
||||
decode_str( pBuf, &pMUD->method );
|
||||
decode_str( pBuf, &pMUD->apparatus );
|
||||
decode_str( pBuf, &pMUD->insert );
|
||||
decode_str( pBuf, &pMUD->sample );
|
||||
decode_str( pBuf, &pMUD->orient );
|
||||
decode_str( pBuf, &pMUD->das );
|
||||
decode_str( pBuf, &pMUD->experimenter );
|
||||
decode_str( pBuf, &pMUD->subtitle );
|
||||
decode_str( pBuf, &pMUD->comment1 );
|
||||
decode_str( pBuf, &pMUD->comment2 );
|
||||
decode_str( pBuf, &pMUD->comment3 );
|
||||
break;
|
||||
case MUD_ENCODE:
|
||||
encode_4( pBuf, &pMUD->exptNumber );
|
||||
encode_4( pBuf, &pMUD->runNumber );
|
||||
encode_4( pBuf, &pMUD->timeBegin );
|
||||
encode_4( pBuf, &pMUD->timeEnd );
|
||||
encode_4( pBuf, &pMUD->elapsedSec );
|
||||
encode_str( pBuf, &pMUD->title );
|
||||
encode_str( pBuf, &pMUD->lab );
|
||||
encode_str( pBuf, &pMUD->area );
|
||||
encode_str( pBuf, &pMUD->method );
|
||||
encode_str( pBuf, &pMUD->apparatus );
|
||||
encode_str( pBuf, &pMUD->insert );
|
||||
encode_str( pBuf, &pMUD->sample );
|
||||
encode_str( pBuf, &pMUD->orient );
|
||||
encode_str( pBuf, &pMUD->das );
|
||||
encode_str( pBuf, &pMUD->experimenter );
|
||||
encode_str( pBuf, &pMUD->subtitle );
|
||||
encode_str( pBuf, &pMUD->comment1 );
|
||||
encode_str( pBuf, &pMUD->comment2 );
|
||||
encode_str( pBuf, &pMUD->comment3 );
|
||||
break;
|
||||
case MUD_GET_SIZE:
|
||||
size = 5*sizeof( UINT32 );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->title );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->lab );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->area );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->method );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->apparatus );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->insert );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->sample );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->orient );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->das );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->experimenter );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->subtitle );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->comment1 );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->comment2 );
|
||||
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->comment3 );
|
||||
return( size );
|
||||
case MUD_SHOW:
|
||||
printf( " MUD_SEC_TRI_TI_RUN_DESC: expt:[%ld], run:[%ld]\n",
|
||||
pMUD->exptNumber, pMUD->runNumber );
|
||||
strcpy( tempStr1, ctime( (time_t*)&pMUD->timeBegin ) );
|
||||
tempStr1[strlen(tempStr1)-1] = '\0';
|
||||
strcpy( tempStr2, ctime( (time_t*)&pMUD->timeEnd ) );
|
||||
tempStr2[strlen(tempStr2)-1] = '\0';
|
||||
printf( " timeBegin:[%s]\n", tempStr1 );
|
||||
printf( " timeEnd:[%s]\n", tempStr2 );
|
||||
printf( " elapsedSec:[%ld]\n", pMUD->elapsedSec );
|
||||
if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title );
|
||||
if( pMUD->lab ) printf( " lab:\"%s\"\n", pMUD->lab );
|
||||
if( pMUD->area ) printf( " area:\"%s\"\n", pMUD->area );
|
||||
if( pMUD->method ) printf( " method:\"%s\"\n", pMUD->method );
|
||||
if( pMUD->apparatus )
|
||||
printf( " apparatus:\"%s\"\n", pMUD->apparatus );
|
||||
if( pMUD->insert ) printf( " insert:\"%s\"\n", pMUD->insert );
|
||||
if( pMUD->sample ) printf( " sample:\"%s\"\n", pMUD->sample );
|
||||
if( pMUD->orient ) printf( " orient:\"%s\"\n", pMUD->orient );
|
||||
if( pMUD->das ) printf( " das:\"%s\"\n", pMUD->das );
|
||||
if( pMUD->experimenter )
|
||||
printf( " experimenter:\"%s\"\n", pMUD->experimenter );
|
||||
if( pMUD->subtitle )
|
||||
printf( " subtitle:\"%s\"\n", pMUD->subtitle );
|
||||
if( pMUD->comment1 )
|
||||
printf( " comment1:\"%s\"\n", pMUD->comment1 );
|
||||
if( pMUD->comment2 )
|
||||
printf( " comment2:\"%s\"\n", pMUD->comment2 );
|
||||
if( pMUD->comment3 )
|
||||
printf( " comment3:\"%s\"\n", pMUD->comment3 );
|
||||
break;
|
||||
case MUD_HEADS:
|
||||
printf( "Run number: %ld\n", pMUD->runNumber );
|
||||
printf( " exper num: %ld\n", pMUD->exptNumber );
|
||||
if( pMUD->experimenter )
|
||||
printf( " operator: %s\n", pMUD->experimenter );
|
||||
if( pMUD->method )
|
||||
printf( " method: %s\n", pMUD->method );
|
||||
strcpy( tempStr1, ctime( (time_t*)&pMUD->timeBegin ) );
|
||||
tempStr1[strlen(tempStr1)-1] = '\0';
|
||||
strcpy( tempStr2, ctime( (time_t*)&pMUD->timeEnd ) );
|
||||
tempStr2[strlen(tempStr2)-1] = '\0';
|
||||
printf( " began: %s\n ended: %s\n",
|
||||
tempStr1, tempStr2 );
|
||||
printf( " elapsed: %ld:%.2d:%.2d (%ld seconds)\n",
|
||||
(pMUD->elapsedSec/3600), ((pMUD->elapsedSec%3600)/60), (pMUD->elapsedSec%60),
|
||||
pMUD->elapsedSec );
|
||||
if( pMUD->title ) printf( " title: %s\n", pMUD->title );
|
||||
if( pMUD->sample ) printf( " sample: %s\n", pMUD->sample );
|
||||
if( pMUD->orient ) printf( " orient: %s\n", pMUD->orient );
|
||||
if( pMUD->subtitle )
|
||||
printf( " subtitle: %s\n", pMUD->subtitle );
|
||||
if( pMUD->lab ) printf( " lab: %s\n", pMUD->lab );
|
||||
if( pMUD->area ) printf( " area: %s\n", pMUD->area );
|
||||
if( pMUD->das ) printf( " das: %s\n", pMUD->das );
|
||||
if( pMUD->apparatus )
|
||||
printf( " apparatus: %s\n", pMUD->apparatus );
|
||||
if( pMUD->insert ) printf( " insert: %s\n", pMUD->insert );
|
||||
if( pMUD->comment1 )
|
||||
printf( " comment1: %s\n", pMUD->comment1 );
|
||||
if( pMUD->comment2 )
|
||||
printf( " comment2: %s\n", pMUD->comment2 );
|
||||
if( pMUD->comment3 )
|
||||
printf( " comment3: %s\n", pMUD->comment3 );
|
||||
break;
|
||||
}
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user