Initial commit: ArgyllCMS v3.5.0 and multichannel profiling research
This commit is contained in:
37
Argyll_V3.5.0/cgats/Jamfile
Executable file
37
Argyll_V3.5.0/cgats/Jamfile
Executable file
@@ -0,0 +1,37 @@
|
||||
|
||||
# Jamfile for cgats library
|
||||
|
||||
#PREF_CCFLAGS = $(CCOPTFLAG) ; # Turn optimisation on
|
||||
PREF_CCFLAGS = $(CCDEBUGFLAG) ; # Debugging flags
|
||||
PREF_LINKFLAGS = $(LINKDEBUGFLAG) ;
|
||||
|
||||
#if stdio is not wanted in icclib:
|
||||
#DEFINES = SEPARATE_STD ;
|
||||
|
||||
#Products
|
||||
Libraries = libcgats ;
|
||||
Headers = cgats.h ;
|
||||
|
||||
#Install
|
||||
#InstallLib $(DESTDIR)$(PREFIX)/lib : $(Libraries ;
|
||||
#InstallFile $(DESTDIR)$(PREFIX)/h : $(Headers) ;
|
||||
|
||||
# Stop objects that are in more than one library from being
|
||||
# prematurely deleted:
|
||||
ObjectKeep cgats pars ;
|
||||
|
||||
# CGATS library
|
||||
Library libcgats : pars.c cgats.c ;
|
||||
|
||||
# Executable support if SEPARATED_STD
|
||||
if SEPARATE_STD in $(DEFINES) {
|
||||
Objects parsstd.c cgatsstd.c ;
|
||||
LINKOBJS = cgatsstd parsstd ; # Link all tests here with these
|
||||
}
|
||||
|
||||
# Individual stand alone test of parser
|
||||
MainVariant pars : pars.c : : STANDALONE_TEST ;
|
||||
|
||||
# Individual stand alone test of cgats i/o
|
||||
MainVariant cgats : cgats.c : : STANDALONE_TEST : : pars ;
|
||||
|
||||
22
Argyll_V3.5.0/cgats/License4.txt
Executable file
22
Argyll_V3.5.0/cgats/License4.txt
Executable file
@@ -0,0 +1,22 @@
|
||||
*************************************************************************
|
||||
Copyright (c) 1995-2021 Graeme W. Gill
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*************************************************************************
|
||||
65
Argyll_V3.5.0/cgats/Makefile
Executable file
65
Argyll_V3.5.0/cgats/Makefile
Executable file
@@ -0,0 +1,65 @@
|
||||
# UNIX style makefile, for icclib and friends.
|
||||
# "include" the right environment for your system,
|
||||
# by uncommenting the appropriate line:
|
||||
|
||||
# Microsoft C++, WinNT setup
|
||||
include Makefile.WNT
|
||||
|
||||
# Generic UNIX setup
|
||||
#include Makefile.UNIX
|
||||
|
||||
# Apple OSX
|
||||
#include Makefile.OSX
|
||||
|
||||
###############################
|
||||
|
||||
#Compile with separate stndard malloc & file io
|
||||
#CCDEFINES = $(DEFFLAG)SEPARATE_STD
|
||||
|
||||
#Set optimisation on
|
||||
CCFLAGS = $(CCFLAGSDEF) $(CCOPTFLAG) $(CCDEFINES)
|
||||
|
||||
#Set debugging on
|
||||
#CCFLAGS = $(CCFLAGSDEF) $(CCDEBUGFLAG) $(CCDEFINES)
|
||||
|
||||
STDHDRS = $(STDHDRSDEF)
|
||||
LINKFLAGS = $(LINKFLAGSDEF) $(LINKDEBUGFLAG)
|
||||
|
||||
all:: libcgats$(SUFLIB) pars$(SUFEXE) cgats$(SUFEXE)
|
||||
|
||||
|
||||
# Separate for executables
|
||||
parsstd$(SUFOBJ): parsstd.c pars.h
|
||||
$(CC) $(CCOF)parsstd$(SUFOBJ) parsstd.c
|
||||
|
||||
cgatsstd$(SUFOBJ): cgatsstd.c cgats.h pars.h
|
||||
$(CC) $(CCOF)cgatsstd$(SUFOBJ) cgatsstd.c
|
||||
|
||||
|
||||
pars$(SUFOBJ): pars.c pars.h
|
||||
$(CC) $(CCOF)pars$(SUFOBJ) pars.c
|
||||
|
||||
cgats$(SUFOBJ): cgats.c cgats.h pars.h
|
||||
$(CC) $(CCOF)cgats$(SUFOBJ) cgats.c
|
||||
|
||||
|
||||
libcgats$(SUFLIB): pars$(SUFOBJ) cgats$(SUFOBJ)
|
||||
$(LIBU) $(LIBOF)libcgats$(SUFLIB) cgats$(SUFOBJ) pars$(SUFOBJ)
|
||||
$(RANLIB) libcgats$(SUFLIB)
|
||||
|
||||
|
||||
sa_pars$(SUFOBJ): pars.c pars.h
|
||||
$(CC) $(CCOF)sa_pars$(SUFOBJ) $(DEFFLAG)STANDALONE_TEST pars.c
|
||||
|
||||
pars$(SUFEXE): sa_pars$(SUFOBJ) parsstd$(SUFOBJ)
|
||||
$(LINK) $(LINKOF)pars$(SUFEXE) sa_pars$(SUFOBJ) parsstd$(SUFOBJ) $(LINKLIBS)
|
||||
|
||||
|
||||
sa_cgats$(SUFOBJ): cgats.c cgats.h pars.h
|
||||
$(CC) $(CCOF)sa_cgats$(SUFOBJ) $(DEFFLAG)STANDALONE_TEST cgats.c
|
||||
|
||||
cgats$(SUFEXE): sa_cgats$(SUFOBJ) pars$(SUFOBJ) parsstd$(SUFOBJ) cgatsstd$(SUFOBJ)
|
||||
$(LINK) $(LINKOF)cgats$(SUFEXE) sa_cgats$(SUFOBJ) pars$(SUFOBJ) parsstd$(SUFOBJ) \
|
||||
cgatsstd$(SUFOBJ) $(LINKLIBS)
|
||||
|
||||
|
||||
38
Argyll_V3.5.0/cgats/Makefile.OSX
Executable file
38
Argyll_V3.5.0/cgats/Makefile.OSX
Executable file
@@ -0,0 +1,38 @@
|
||||
# MAC OSX, derived from UNIX setup
|
||||
|
||||
SLASH = /
|
||||
SUFLIB = .a
|
||||
SUFOBJ = .o
|
||||
SUFEXE =
|
||||
CMDSEP = ;
|
||||
|
||||
INCFLAG = -I
|
||||
DEFFLAG = -D
|
||||
UNDEFFLAG = "-u _"
|
||||
CCOPTFLAG = -O
|
||||
CCDEBUGFLAG = -g
|
||||
CCPROFFLAG =
|
||||
LINKDEBUGFLAG =
|
||||
LINKPROFFLAG =
|
||||
|
||||
STDHDRSDEF = /usr/include
|
||||
|
||||
MAKEU = make
|
||||
LIBU = ar -r
|
||||
LIBOF =
|
||||
RANLIB = ranlib
|
||||
AS = as
|
||||
CCFLAGSDEF = -DUNIX -c
|
||||
CC = cc $(CCFLAGS) $(INCFLAG)$(STDHDRS)
|
||||
CCOF = -o
|
||||
LINKFLAGSDEF = -lm
|
||||
LINKLIBS =
|
||||
LINK = cc $(LINKFLAGS) $(LINKLIBS)
|
||||
LINKOF = -o
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c $(SUFLIB) $(SUFOBJ) $(SUFEXE)
|
||||
|
||||
.c$(SUFOBJ):
|
||||
$(CC) $(CCOF)$*$(SUFOBJ) $<
|
||||
|
||||
38
Argyll_V3.5.0/cgats/Makefile.UNIX
Executable file
38
Argyll_V3.5.0/cgats/Makefile.UNIX
Executable file
@@ -0,0 +1,38 @@
|
||||
# Generic UNIX setup
|
||||
|
||||
SLASH = /
|
||||
SUFLIB = .a
|
||||
SUFOBJ = .o
|
||||
SUFEXE =
|
||||
CMDSEP = ;
|
||||
|
||||
INCFLAG = -I
|
||||
DEFFLAG = -D
|
||||
UNDEFFLAG = "-u _"
|
||||
CCOPTFLAG = -O
|
||||
CCDEBUGFLAG = -g
|
||||
CCPROFFLAG =
|
||||
LINKDEBUGFLAG =
|
||||
LINKPROFFLAG =
|
||||
|
||||
STDHDRSDEF = /usr/include
|
||||
|
||||
MAKEU = make
|
||||
LIBU = ar -r
|
||||
LIBOF = -o
|
||||
RANLIB = echo
|
||||
AS = as
|
||||
CCFLAGSDEF = -DUNIX -c
|
||||
CC = cc $(CCFLAGS) $(INCFLAG)$(STDHDRS)
|
||||
CCOF = -o
|
||||
LINKFLAGSDEF = -lm
|
||||
LINKLIBS =
|
||||
LINK = cc $(LINKFLAGS) $(LINKLIBS)
|
||||
LINKOF = -o
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c $(SUFLIB) $(SUFOBJ) $(SUFEXE)
|
||||
|
||||
.c$(SUFOBJ):
|
||||
$(CC) $(CCOF)$*$(SUFOBJ) $<
|
||||
|
||||
38
Argyll_V3.5.0/cgats/Makefile.WNT
Executable file
38
Argyll_V3.5.0/cgats/Makefile.WNT
Executable file
@@ -0,0 +1,38 @@
|
||||
# Microsoft C++, WinNT setup
|
||||
|
||||
SLASH = \
|
||||
SUFLIB = .lib
|
||||
SUFOBJ = .obj
|
||||
SUFEXE = .exe
|
||||
CMDSEP = &
|
||||
|
||||
INCFLAG = /I
|
||||
DEFFLAG = /D
|
||||
UNDEFFLAG = "/u _"
|
||||
CCOPTFLAG = /Ox /GB
|
||||
CCDEBUGFLAG = /Z7 /Od
|
||||
CCPROFFLAG = /Z7
|
||||
LINKDEBUGFLAG = /DEBUG
|
||||
LINKPROFFLAG = /PROFILE
|
||||
|
||||
STDHDRSDEF = $(MSVCNT)\include
|
||||
|
||||
MAKEU = nmake
|
||||
LIBU = lib
|
||||
LIBOF = /OUT:
|
||||
RANLIB = rem
|
||||
AS = masm386
|
||||
CCFLAGSDEF = /DNT /c
|
||||
CC = cl /nologo $(CCFLAGS) $(INCFLAG)$(STDHDRS)
|
||||
CCOF = /Fo
|
||||
LINKLIBS = $(MSVCNT)/lib/user32.lib $(MSVCNT)/lib/gdi32.lib
|
||||
LINKFLAGSDEF = /link /INCREMENTAL:NO
|
||||
LINK = link $(LINKFLAGS)
|
||||
LINKOF = /OUT:
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c $(SUFLIB) $(SUFOBJ) $(SUFEXE)
|
||||
|
||||
.c$(SUFOBJ):
|
||||
$(CC) $(CCOF)$*$(SUFOBJ) $<
|
||||
|
||||
286
Argyll_V3.5.0/cgats/Readme.txt
Executable file
286
Argyll_V3.5.0/cgats/Readme.txt
Executable file
@@ -0,0 +1,286 @@
|
||||
|
||||
CGATS file I/O library, V2.01 README file
|
||||
-----------------------------------------
|
||||
|
||||
Package contents:
|
||||
-----------------
|
||||
cgatslib.zip ZIP archive of the following files
|
||||
Readme.txt This file.
|
||||
License4.txt Important! - Permissions for use of this package.
|
||||
cgats.c CGATS Library source code.
|
||||
cgatsstd.c I/O and malloc source code.
|
||||
cgats.h CGATS Library include file. Note machine dependent defines.
|
||||
pars.c Parser source code.
|
||||
parsstd.c I/O and malloc source code.
|
||||
pars.h Parser include file. Note machine dependent defines.
|
||||
Jampfile JAM style "makefile" see <http://www.perforce.com/jam/jam.html>
|
||||
Makefile Makefile. Modify this to include one of the following rule sets.
|
||||
Makefile.WNT Makefile defines for Microsoft C++ on Windows NT
|
||||
Makefile.IBMNT Makefile defines for IBM C++ on Windows NT
|
||||
Makefile.UNIX Makefile defines for generic UNIX system
|
||||
Makefile.OSX Makefile defines for Apple MAC OSX
|
||||
|
||||
Changes:
|
||||
--------
|
||||
|
||||
Changes since V2.00
|
||||
|
||||
Removed all exit()s from code - now return error values
|
||||
from all functions.
|
||||
|
||||
Added abstract objects for File I/O and memory allocation
|
||||
to improve system compatibility.
|
||||
|
||||
Separated the implimentations of the abstract I/O and
|
||||
memory objects that ise stdio and malloc into separate
|
||||
files so that a library can be compiled without reference
|
||||
to these system calls.
|
||||
|
||||
|
||||
---------------------------------------------------------------
|
||||
DOCUMENTATION
|
||||
|
||||
This library has been implemented from the CGATS.5 Data Exchange Format
|
||||
specification, in Annex J, of the ANSI CGATS.5-1993 standard.
|
||||
See <http://www.npes.org/standards/description.htm>
|
||||
|
||||
This module attempts to make reading CGATS.5 and IT8.7 files
|
||||
easy and convenient. Since the standard is a less than clear
|
||||
on some points it is hard to know how much compatibility is
|
||||
to be expected.
|
||||
|
||||
The module supports non-standard keywords and fields automatically.
|
||||
It does not support reading of comments.
|
||||
It supports reading and writing multiple tables within one file.
|
||||
Abreviated tables may be written.
|
||||
Non-standard fields written by this module will be recognized
|
||||
correcty when read by this module (data types are written
|
||||
unambiguously - reals all have a decimal point, no non-quoted strings
|
||||
are written that could be interpreted as a real or integer), but
|
||||
there is no certainty that non-standard fields written by other
|
||||
software will be recognized corectly (e.g. - how to you tell
|
||||
whether 1234 is an integer, real, or non-quoted string ?)
|
||||
|
||||
To creat a file each element needs to be built up in turn:
|
||||
|
||||
Create an empty cgats structure:
|
||||
new_cgats().
|
||||
|
||||
A non-standard memory allocator can be specified for use
|
||||
by the cgats object by passing an object that inherits
|
||||
from the cgatsAlloc class defined in parse.h, to the
|
||||
new_cgats_al(cgatsAlloc *al) constructor.
|
||||
|
||||
|
||||
Use the module methods to:
|
||||
|
||||
|
||||
Add a user defined file identifier to augment the standard identifiers:
|
||||
add_other(cgats *p, char *osym)
|
||||
This can be used to read or write table that are compatible with CGATS.5
|
||||
syntax but have different file identifiers.
|
||||
Use a zero length string (ie. just "") for wildcard.
|
||||
Normaly returns 0, returns -ve if there was a system error,
|
||||
& sets p->errc & p->err appropriately.
|
||||
|
||||
|
||||
create an empty table entry:
|
||||
add_table(cgats *p, table_type tt, int oi)
|
||||
tt is the table type: it8_7_1, it8_7_2, it8_7_3, it8_7_4, cgats_5, cgats_X,
|
||||
tt_other or tt_none.
|
||||
cgat_X represents any "CGATS.XXX" table type.
|
||||
If tt_other is used for creating a file, then oi must be set to the index of the
|
||||
user defined table identifiers set by calls to p->add_other();
|
||||
The table type read can be identified by looking at the index
|
||||
p->t[table_number].tt, which will be set to the table type.
|
||||
If the type is cgats_X type, the type actually found will be in p->cgats_type.
|
||||
If tt == tt_other, then the "other index" value is p->t[table_numberx].oi.
|
||||
For a wildcard tt_other, the actual type found will be at p->others[oi].
|
||||
|
||||
Tables are added in turn, and are indexed from 0 in other functions.
|
||||
Returns 0 normally.
|
||||
It returns -2 if there was a system error, & sets p->errc & p->err appropriately.
|
||||
|
||||
|
||||
Suppress the writing of the file identifier string, standard keyword definitions
|
||||
and/or field definitions for a second or subsequent table:
|
||||
set_table_flags(cgats *p, int table, int sup_id, int sup_kwords, int sup_fields);
|
||||
This only makes sense if the subsequent table has the same identifier type, keywords
|
||||
and field definitions as the preceding table. Returns 0 normally.
|
||||
It returns -1 if there was an error, & sets p->errc & p->err appropriately.
|
||||
|
||||
|
||||
Add keywords and their values:
|
||||
int add_kword(cgats *p, int table, char *ksym, char *kdata, char *kcom);
|
||||
The return value is the index of the new keyword, or -1, errc & err on error.
|
||||
Any non-standard keywords will automatically be declared in the file.
|
||||
The comment is optional and NULL should be passed if no comment is to be used
|
||||
after the keyword/value pair.
|
||||
|
||||
Standard keywords are:
|
||||
ORIGINATOR System, organization or individual that created data
|
||||
DESCRIPTOR Purpose or contents of the data file
|
||||
CREATED Date of creation of the file
|
||||
MANUFACTURER Manufacturer of physical target
|
||||
PROD_DATE Year and month of physical target production yyyy:mm
|
||||
SERIAL Unique physical target serial number
|
||||
MATERIAL Material physical target was produced on
|
||||
INSTRUMENTATION Manufacturer and model number of measuring instrument
|
||||
MEASUREMENT_SOURCE Illumination used for spectral measurements
|
||||
PRINT_CONDITIONS Characteristics of printed sheet being reported
|
||||
|
||||
Standard keywords will be created automatically if necessary for a legal file format.
|
||||
|
||||
The following kewords are supplied automatically by the module,
|
||||
and cannot be used for other things:
|
||||
NUMBER_OF_FIELDS
|
||||
BEGIN_DATA_FORMAT
|
||||
END_DATA_FORMAT
|
||||
NUMBER_OF_SETS
|
||||
BEGIN_DATA
|
||||
END_DATA
|
||||
KEYWORD
|
||||
|
||||
|
||||
Add fields:
|
||||
int add_field(cgats *p, int table, char *fsym, data_type ftype);
|
||||
|
||||
The return value is the index of the new field, or return
|
||||
-1, errc & err on error, -2, errc & err on system error.
|
||||
|
||||
ftype defines the data type from: r_t, i_t, cs_t, nqcs_t.
|
||||
r_t is the real (double) type,
|
||||
i_t is the integer (int) type,
|
||||
cs_t is the character string (char*) type,
|
||||
nqcs_t is the same as cs_t except that it will be non-quoted if possible.
|
||||
Note that the type must agree with the standard type if the field is
|
||||
from the set default data format identifiers:
|
||||
|
||||
SAMPLE_ID nqcs_t Identifies sample which data represents
|
||||
STRING cs_t Identifies label, or other non-machine readable value.
|
||||
CMYK_C r_t Cyan percentage of CMYK
|
||||
CMYK_M r_t Magenta percentage of CMYK
|
||||
CMYK_Y r_t Yellow percentage of CMYK
|
||||
CMYK_K r_t Black percentage of CMYK
|
||||
D_RED r_t Red filter reflection density
|
||||
D_GREEN r_t Green filter reflection density
|
||||
D_BLUE r_t Blue filter reflection density
|
||||
D_VIS r_t Visual filter reflection density
|
||||
RGB_R r_t Red component of RGB data
|
||||
RGB_G r_t Green component of RGB data
|
||||
RGB_B r_t Blue component of RGB data
|
||||
SPECTRAL_NM r_t Wavelength of measurement in nanometers
|
||||
SPECTRAL_PCT r_t Precentage reflectance/transmittance
|
||||
XYZ_X r_t X component of tristimulus data
|
||||
XYZ_Y r_t Y component of tristimulus data
|
||||
XYZ_Z r_t Z component of tristimulus data
|
||||
XYY_X r_t x component of chromaticity data
|
||||
XYY_Y r_t y component of chromaticity data
|
||||
XYY_CAPY r_t Y component of chromaticity data
|
||||
LAB_L r_t L* component of Lab data
|
||||
LAB_A r_t a* component of Lab data
|
||||
LAB_B r_t b* component of Lab data
|
||||
LAB_C r_t C*ab component of Lab data
|
||||
LAB_H r_t hab component of Lab data
|
||||
LAB_DE r_t CIA delta E
|
||||
STDEV_X r_t Standard deviation of X (tristimulous data)
|
||||
STDEV_Y r_t Standard deviation of Y (tristimulous data)
|
||||
STDEV_Z r_t Standard deviation of Z (tristimulous data)
|
||||
STDEV_L r_t Standard deviation of L*
|
||||
STDEV_A r_t Standard deviation of a*
|
||||
STDEV_B r_t Standard deviation of b*
|
||||
STDEV_DE r_t Standard deviation of CIE delta E
|
||||
|
||||
Add a set of data:
|
||||
add_set(cgats *p, int table, ...)
|
||||
The data should be supplied as a varargs list in the appropropriate
|
||||
data format [char*, double or int].
|
||||
Returns 0 normally, -1 errc & err if parameter error,
|
||||
-2 errc & err if system error.
|
||||
|
||||
Add a set of data from union array:
|
||||
add_setarr(cgats *p, int table, cgats_set_elem *args);
|
||||
The data should be supplied as an array of cgats_set_elem unions.
|
||||
Returns 0 normally, -1 errc & err if parameter error,
|
||||
-2 errc & err if system error.
|
||||
|
||||
Write the data out to a file.
|
||||
write_name(cgats *p, char *fname);
|
||||
The method will return non-zero on an error, with an error
|
||||
description in the err location of the structure.
|
||||
|
||||
|
||||
A non-standard destination of data can be read by passing an
|
||||
object that inherits from the cgatsFile class defined in
|
||||
parse.h to the write(cgats *p, cgatsFile *fp) method.
|
||||
|
||||
To read in a data file, the cgats structure should be created
|
||||
as usual. The read method can then be called to read in the file:
|
||||
read_name(cgats *p, char *fname)
|
||||
Returns 0 normally, and -ve on an error, with an error
|
||||
description in the err location of the structure,
|
||||
and errc set with the return code.
|
||||
|
||||
A non-standard source of data can be read by passing an
|
||||
object that inherits from the cgatsFile class defined in
|
||||
parse.h to the read(cgats *p, cgatsFile *fp) method.
|
||||
|
||||
The reader will deal automaticaly with carry over of keywords
|
||||
and/or field definitions from one table to another, making each
|
||||
table appear independent once read.
|
||||
|
||||
The data is accessed by refering to the following read-only
|
||||
structure entries:
|
||||
|
||||
The number of tables will be in p->ntables
|
||||
|
||||
The number of keywords will be in p->t[table_number].nkwords
|
||||
The number of fields will be in p->t[table_number].nfields
|
||||
The number of sets will be in p->t[table_number].nsets
|
||||
|
||||
Tables, keywords, fields and sets index from 0.
|
||||
|
||||
The keywords will be in
|
||||
p->t[table_number].ksym[keyword_index]
|
||||
|
||||
The keywords character string value be in
|
||||
p->t[table_number].kdata[keyword_index]
|
||||
|
||||
The field format identifiers of each field will be in
|
||||
p->t[table_number].fsym[field_index]
|
||||
|
||||
The data type of each field will be in
|
||||
p->t[table_number].ftype[field_index]
|
||||
|
||||
A void pointer to the data of each field of each set will be in
|
||||
p->t[table_number].fdata[set_index][field_index]
|
||||
Cast the void pointet according to its type to retrieve the data.
|
||||
Alternatively the
|
||||
p->get_setarr(struct _cgats *p, int table, int set_index, cgats_set_elem *ary)
|
||||
method can be used to fill in a suitable sized cgats_set_elem array with
|
||||
the value of all the fields at a particular index. Any character string
|
||||
type will be a pointer to the data in p->t[table_number].fdata[set_index][field_index].
|
||||
|
||||
To find the index to a particular keyword, use:
|
||||
find_kword(cgats *p, int table, char *ksym)
|
||||
-1 will be returned if no match is found.
|
||||
-2 will be returned, p->errc & p->err will be set if table is out of range.
|
||||
|
||||
To find the index to a particular field, use:
|
||||
find_field(cgats *p, int table, char *fsym);
|
||||
-1 will be returned if no match is found.
|
||||
-2 will be returned, p->errc & p->err will be set if table is out of range.
|
||||
|
||||
Rather than checking the error return codes from every method,
|
||||
the first error is "sticky", and recorded in the object.
|
||||
This can be checked after a series of operations by calling
|
||||
the error(cgats *p, char **mes) method, which will return the
|
||||
error code, and (optionaly) the error message.
|
||||
|
||||
Once operations are finished, the object can be deleted by calling
|
||||
the delete method:
|
||||
del(cgats *p)
|
||||
|
||||
Graeme Gill.
|
||||
|
||||
---------------------------------------------------------------
|
||||
15
Argyll_V3.5.0/cgats/afiles
Executable file
15
Argyll_V3.5.0/cgats/afiles
Executable file
@@ -0,0 +1,15 @@
|
||||
Readme.txt
|
||||
License4.txt
|
||||
afiles
|
||||
cgats.c
|
||||
cgats.h
|
||||
pars.c
|
||||
pars.h
|
||||
parsstd.c
|
||||
cgatsstd.c
|
||||
test.txt
|
||||
Jamfile
|
||||
Makefile
|
||||
Makefile.WNT
|
||||
Makefile.UNIX
|
||||
Makefile.OSX
|
||||
2279
Argyll_V3.5.0/cgats/cgats.c
Normal file
2279
Argyll_V3.5.0/cgats/cgats.c
Normal file
File diff suppressed because it is too large
Load Diff
190
Argyll_V3.5.0/cgats/cgats.h
Normal file
190
Argyll_V3.5.0/cgats/cgats.h
Normal file
@@ -0,0 +1,190 @@
|
||||
#ifndef CGATS_H
|
||||
|
||||
/*
|
||||
* Committee for Graphics Arts Technologies Standards
|
||||
* CGATS.5 and IT8.7 family file I/O class
|
||||
* Version 2.05
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Graeme W. Gill
|
||||
* Date: 20/12/95
|
||||
*
|
||||
* Copyright 1995, 1996, 2002, 2022 Graeme W. Gill
|
||||
* All rights reserved.
|
||||
*
|
||||
* This material is licensed with an "MIT" free use license:-
|
||||
* see the License4.txt file in this directory for licensing details.
|
||||
*/
|
||||
|
||||
/* Version of cgatslib release */
|
||||
|
||||
#define CGATSLIB_VERSION 0x030200
|
||||
#define CGATSLIB_VERSION_STR "3.2.0"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "pars.h" /* We use the ASCII parsing class */
|
||||
|
||||
/* Possible table types */
|
||||
typedef enum { it8_7_1, it8_7_2, it8_7_3, it8_7_4, cgats_5, cgats_X, tt_other, tt_none } table_type;
|
||||
|
||||
/* Possible data types - real, integer, char string, non-quoted char string, no value */
|
||||
typedef enum { r_t, i_t, cs_t, nqcs_t, none_t } data_type;
|
||||
|
||||
union _cgats_set_elem {
|
||||
int i;
|
||||
double d;
|
||||
char *c;
|
||||
}; typedef union _cgats_set_elem cgats_set_elem;
|
||||
|
||||
struct _cgats_table {
|
||||
cgatsAlloc *al; /* Copy of parent memory allocator */
|
||||
table_type tt; /* Table type */
|
||||
int oi; /* other type index */
|
||||
|
||||
/* Read only */
|
||||
int nkwords; /* Number of keywords */
|
||||
int nfields; /* Number of fields of data */
|
||||
int nsets; /* Number of data sets */
|
||||
|
||||
char **ksym; /* Pointer to [nkwords] array of pointers to keyword symbols */
|
||||
char **kdata; /* Pointer to [nkwords] array of pointers to keyword values */
|
||||
|
||||
char **fsym; /* Pointer to [nfields] array of pointers to field symbols */
|
||||
data_type *ftype; /* Pointer to [nfields] array of field types */
|
||||
char ***rfdata; /* Pointer to [nsets] array of pointers */
|
||||
/* to [nfields] array of pointers to read file field text values */
|
||||
void ***fdata; /* Pointer to [nsets] array of pointers */
|
||||
/* to [nfields] array of pointers to field set values of ftype */
|
||||
/* Private */
|
||||
int nkwordsa; /* Number of keywords allocated */
|
||||
int nfieldsa; /* Number of fields allocated */
|
||||
int nsetsa; /* Number of sets allocated */
|
||||
char **kcom; /* Pointer to [nkwords] array of pointers to keyword comments */
|
||||
int ndf; /* Next data field - used by add_data_item() */
|
||||
int sup_id; /* Set to non-zero if table ID output is to be suppressed */
|
||||
int sup_kwords; /* Set to non-zero if table default keyword output is to be suppressed */
|
||||
int sup_fields; /* Set to non-zero if table field output is to be suppressed */
|
||||
}; typedef struct _cgats_table cgats_table;
|
||||
|
||||
struct _cgats {
|
||||
/* Private */
|
||||
cgatsAlloc *al; /* Memory allocator */
|
||||
int del_al; /* Flag to indicate we al->del() */
|
||||
|
||||
/* Read only Variables */
|
||||
int ntables; /* Number of tables */
|
||||
|
||||
cgats_table *t; /* Pointer to an array of ntable table structures */
|
||||
|
||||
/* Undefined CGATS table type */
|
||||
char *cgats_type;
|
||||
|
||||
/* User defined table types */
|
||||
int nothers; /* Number of other identifiers */
|
||||
char **others; /* Other file type identifiers */
|
||||
|
||||
/* Options */
|
||||
int emit_keywords; /* NZ to emit "KEYWORD" for non-standard keywords (default no) */
|
||||
|
||||
/* Public Methods */
|
||||
int (*set_cgats_type)(struct _cgats *p, const char *osym);
|
||||
/* Define the (one) variable CGATS type */
|
||||
/* Return -2, set e.c & e.m on system error */
|
||||
|
||||
int (*add_other)(struct _cgats *p, const char *osym);
|
||||
/* Add a user defined file identifier string. */
|
||||
/* Use a zero length string for wildcard. */
|
||||
/* Returns existing if already registered. */
|
||||
/* Return the oi */
|
||||
/* Return -2, set e.c & e.m on system error */
|
||||
|
||||
int (*get_oi)(struct _cgats *p, const char *osym);
|
||||
/* Return the oi of the given other type */
|
||||
/* return -ve and e.c & e.m set on error */
|
||||
|
||||
int (*read)(struct _cgats *p, cgatsFile *fp); /* Read a cgats file into structure */
|
||||
/* return -ve and e.c & e.m set on error */
|
||||
|
||||
/* NULL if SEPARATE_STD is defined: */
|
||||
int (*read_name)(struct _cgats *p, const char *filename); /* Standard file I/O */
|
||||
/* return -ve and e.c & e.m set on error */
|
||||
|
||||
int (*find_kword)(struct _cgats *p, int table, const char *ksym);
|
||||
/* Return index of the keyword, -1 on fail */
|
||||
/* -2 on illegal table index, e.c & e.m */
|
||||
int (*find_field)(struct _cgats *p, int table, const char *fsym);
|
||||
/* Return index of the field, -1 on fail */
|
||||
/* -2 on illegal table index, e.c & e.m */
|
||||
|
||||
int (*add_table)(struct _cgats *p, table_type tt, int oi);
|
||||
/* Add a new (empty) table to the structure */
|
||||
/* Return the index of the table */
|
||||
/* Return -2, set e.c & e.m on system error */
|
||||
/* if tt is tt_other, io sets the other index */
|
||||
int (*set_table_type)(struct _cgats *p, int table, table_type tt, int oi);
|
||||
/* Override the table type */
|
||||
int (*set_table_flags)(struct _cgats *p, int table, int sup_id,int sup_kwords,int sup_fields);
|
||||
/* Set or reset table output suppresion flags */
|
||||
/* Return -ve, set e.c & e.m on error */
|
||||
int (*del_table)(struct _cgats *p, int table);
|
||||
/* Delete an existing table. Return error if it doesn't exist */
|
||||
/* Note that any following tables will be shuffled down. */
|
||||
int (*add_kword)(struct _cgats *p, int table, const char *ksym, const char *kdata, const char *kcom);
|
||||
/* Add a new keyword/value pair + optional comment to the table */
|
||||
/* Return index of new keyword, or -1, e.c & e.m on error */
|
||||
int (*add_kword_at)(struct _cgats *p, int table, int pos, const char *ksym,
|
||||
const char *kdata, const char *kcom);
|
||||
/* Replace or append a new keyword/value pair + optional comment */
|
||||
int (*add_field)(struct _cgats *p, int table, const char *fsym, data_type ftype);
|
||||
/* Add a new field to the table */
|
||||
/* Return index of new field, or -1, -2, e.c & e.m on error */
|
||||
int (*add_set)(struct _cgats *p, int table, ...); /* Add a set of data */
|
||||
/* Return 0 normally, -1, -2, e.c & e.m if error */
|
||||
int (*add_setarr)(struct _cgats *p, int table, cgats_set_elem *ary); /* Add data from array */
|
||||
/* Return 0 normally, -1, -2, e.c & e.m if error */
|
||||
int (*write)(struct _cgats *p, cgatsFile *fp); /* Write structure into cgats file */
|
||||
/* return -ve and e.c & e.m set on error */
|
||||
|
||||
int (*get_setarr)(struct _cgats *p, int table, int set_index, cgats_set_elem *ary);
|
||||
/* Fill a suitable set_element with a line of data */
|
||||
/* Return 0 normally, -1, -2, e.c & e.m if error */
|
||||
/* NULL if SEPARATE_STD is defined: */
|
||||
int (*write_name)(struct _cgats *p, const char *filename); /* Standard file I/O */
|
||||
/* return -ve and e.c & e.m set on error */
|
||||
|
||||
|
||||
int (*error)(struct _cgats *p, char **mes); /* Return error code and message */
|
||||
/* for the first error, if any error */
|
||||
/* has occured since object creation. */
|
||||
void (*del)(struct _cgats *p); /* Delete the object */
|
||||
|
||||
cgats_err e; /* Error message * code */
|
||||
cgats_err fe; /* First error message * code */
|
||||
}; typedef struct _cgats cgats;
|
||||
|
||||
/* Creator */
|
||||
extern cgats *new_cgats_al(cgatsAlloc *al); /* with allocator object */
|
||||
|
||||
#ifdef COMBINED_STD
|
||||
#define CGATS_STATIC static
|
||||
#else
|
||||
#define CGATS_STATIC
|
||||
#endif
|
||||
|
||||
/* Available if SEPARATE_STD is not defined */
|
||||
extern cgats *new_cgats(void); /* Standard allocator */
|
||||
|
||||
/* Available from cgatsstd.obj SEPARATE_STD is defined: */
|
||||
CGATS_STATIC int cgats_read_name(cgats *p, const char *filename);
|
||||
CGATS_STATIC int cgats_write_name(cgats *p, const char *filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CGATS_H
|
||||
#endif /* CGATS_H */
|
||||
115
Argyll_V3.5.0/cgats/cgatsstd.c
Normal file
115
Argyll_V3.5.0/cgats/cgatsstd.c
Normal file
@@ -0,0 +1,115 @@
|
||||
|
||||
/*
|
||||
* cgats library stdio and malloc utility classes.
|
||||
* Version 2.05
|
||||
*
|
||||
* These are kept in a separate file to allow them to be
|
||||
* selectively ommitted from the cgats library.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Graeme W. Gill
|
||||
* Date: 2002/10/24
|
||||
*
|
||||
* Copyright 2002, Graeme W. Gill
|
||||
* All rights reserved.
|
||||
*
|
||||
* This material is licensed with an "MIT" free use license:-
|
||||
* see the License4.txt file in this directory for licensing details.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef COMBINED_STD
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cgats.h"
|
||||
|
||||
#ifdef NEVER /* Not sure if this is needed with some combinations */
|
||||
|
||||
/* Implimentation function - register an error */
|
||||
/* Return the error number */
|
||||
/* [Note that this is a duplicate of the one in cgats.c] */
|
||||
static int
|
||||
err(cgats *p, int errc, const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
p->e.c = errc;
|
||||
va_start(args, fmt);
|
||||
vsprintf(p->err, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
/* If this is the first registered error */
|
||||
if (p->ferrc != 0) {
|
||||
p->ferrc = p->e.c;
|
||||
strcpy(p->ferr, p->err);
|
||||
}
|
||||
|
||||
return errc;
|
||||
}
|
||||
|
||||
#endif /* NEVER */
|
||||
|
||||
#endif /* !COMBINED_STD */
|
||||
|
||||
#if defined(SEPARATE_STD) || defined(COMBINED_STD)
|
||||
|
||||
/* Create an empty cgats object, default standard allocator */
|
||||
cgats *new_cgats(void) {
|
||||
cgats *p;
|
||||
cgatsAlloc *al; /* memory allocator */
|
||||
|
||||
if ((al = new_cgatsAllocStd()) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((p = new_cgats_al(al)) == NULL) {
|
||||
al->del(al);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->del_al = 1; /* Get cgets->del to cleanup allocator */
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Read a cgats file into structure */
|
||||
/* Return non-zero if there was an error */
|
||||
/* and set p->e.c * p->err */
|
||||
CGATS_STATIC
|
||||
int
|
||||
cgats_read_name(cgats *p, const char *filename) {
|
||||
int rv;
|
||||
cgatsFile *fp;
|
||||
|
||||
p->e.c = 0;
|
||||
p->e.m[0] = '\000';
|
||||
|
||||
if ((fp = new_cgatsFileStd_name(filename, "r")) == NULL)
|
||||
return err(p,-1,"Unable to open file '%s' for reading",filename);
|
||||
rv = p->read(p, fp);
|
||||
fp->del(fp);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Write a cgats file into structure */
|
||||
/* Return -ve, errc & err if there was an error */
|
||||
CGATS_STATIC
|
||||
int
|
||||
cgats_write_name(cgats *p, const char *filename) {
|
||||
int rv;
|
||||
cgatsFile *fp;
|
||||
|
||||
if ((fp = new_cgatsFileStd_name(filename, "w")) == NULL)
|
||||
return err(p,-1,"Unable to open file '%s' for writing",filename);
|
||||
rv = p->write(p, fp);
|
||||
fp->del(fp);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif /* defined(SEPARATE_STD) || defined(COMBINED_STD) */
|
||||
670
Argyll_V3.5.0/cgats/pars.c
Normal file
670
Argyll_V3.5.0/cgats/pars.c
Normal file
@@ -0,0 +1,670 @@
|
||||
|
||||
/*
|
||||
* Simple ASCII file parsing object.
|
||||
* Used as a base for the CGATS.5 and IT8.7 family file I/O class
|
||||
*/
|
||||
|
||||
/*
|
||||
* Version 2.05
|
||||
*
|
||||
* Author: Graeme W. Gill
|
||||
* Date: 20/12/95
|
||||
*
|
||||
* Copyright 1996, 2002 Graeme W. Gill
|
||||
* All rights reserved.
|
||||
*
|
||||
* This material is licensed with an "MIT" free use license:-
|
||||
* see the License4.txt file in this directory for licensing details.
|
||||
*/
|
||||
|
||||
/*
|
||||
TTBD:
|
||||
|
||||
Should skip UTF-8 BOM (0xef 0xbb 0xbf)
|
||||
|
||||
*/
|
||||
|
||||
#define _PARS_C_ /* Turn on implimentation code */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#ifdef __sun
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define vsnprintf _vsnprintf
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifdef STANDALONE_TEST
|
||||
extern void error(const char *fmt, ...), warning(const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
#include "pars.h"
|
||||
|
||||
#undef DEBUG /* Print each token returned */
|
||||
|
||||
static void del_parse(parse *p);
|
||||
static int read_line(parse *p);
|
||||
static void reset_del(parse *p);
|
||||
static void add_del(struct _parse *p, char *t,
|
||||
char *nr, char *c, char *q);
|
||||
static char *get_token(parse *p);
|
||||
|
||||
/* Open the file, allocate and initialize the parse structure */
|
||||
/* Return pointer to parse structure. Return NULL on error */
|
||||
parse *
|
||||
new_parse_al(
|
||||
cgatsAlloc *al, /* Allocator object */
|
||||
cgatsFile *fp /* File to read from */
|
||||
) {
|
||||
parse *p;
|
||||
|
||||
if ((p = (parse *) al->calloc(al, sizeof(parse), 1)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
p->al = al; /* Heap allocator */
|
||||
|
||||
p->fp = fp;
|
||||
p->b = NULL; /* Init line buffer */
|
||||
p->bs = 0;
|
||||
p->bo = 0;
|
||||
p->tb = NULL; /* Init token buffer */
|
||||
p->tbs = 0;
|
||||
p->to = 0;
|
||||
p->line = 0;
|
||||
p->token = 0;
|
||||
p->ltflag = 0;
|
||||
p->q = 0;
|
||||
p->e.c = 0;
|
||||
p->e.m[0] = '\000';
|
||||
|
||||
/* Reset the parsing delimiters */
|
||||
reset_del(p);
|
||||
|
||||
/* Set default pointers to methods */
|
||||
p->del = del_parse;
|
||||
p->read_line = read_line;
|
||||
p->reset_del = reset_del;
|
||||
p->add_del = add_del;
|
||||
p->get_token = get_token;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* new_parse() with default malloc allocator is in parsstd.c */
|
||||
|
||||
#ifndef SEPARATE_STD
|
||||
#define COMBINED_STD
|
||||
|
||||
#include "parsstd.c"
|
||||
|
||||
#undef COMBINED_STD
|
||||
#endif /* SEPARATE_STD */
|
||||
|
||||
/* --------------------------------------------- */
|
||||
|
||||
/* size_t versions of saturating arithmatic */
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t)(-1))
|
||||
#endif
|
||||
|
||||
/* a * b */
|
||||
static size_t ssat_mul(size_t a, size_t b) {
|
||||
|
||||
if (a == 0 || b == 0)
|
||||
return 0;
|
||||
|
||||
if (a > (SIZE_MAX/b))
|
||||
return SIZE_MAX;
|
||||
else
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/* --------------------------------------------- */
|
||||
/* Memory image cgatsFile compatible class */
|
||||
/* Buffer is assumed to have been allocated by the given allocator, */
|
||||
/* and will be expanded on write. */
|
||||
|
||||
/* Get the size of the file (Only valid for memory file). */
|
||||
static size_t cgatsFileMem_get_size(cgatsFile *pp) {
|
||||
cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
|
||||
return p->end - p->start;
|
||||
}
|
||||
|
||||
/* Set current position to offset. Return 0 on success, nz on failure. */
|
||||
static int cgatsFileMem_seek(
|
||||
cgatsFile *pp,
|
||||
unsigned int offset
|
||||
) {
|
||||
cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
unsigned char *np;
|
||||
|
||||
np = p->start + offset;
|
||||
if (np < p->start || np >= p->end)
|
||||
return 1;
|
||||
p->cur = np;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read count items of size length. Return number of items successfully read. */
|
||||
static size_t cgatsFileMem_read(
|
||||
cgatsFile *pp,
|
||||
void *buffer,
|
||||
size_t size,
|
||||
size_t count
|
||||
) {
|
||||
cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
size_t len;
|
||||
|
||||
len = ssat_mul(size, count);
|
||||
if (len > (size_t)(p->end - p->cur)) { /* Too much */
|
||||
if (size > 0)
|
||||
count = (p->end - p->cur)/size;
|
||||
else
|
||||
count = 0;
|
||||
}
|
||||
len = size * count;
|
||||
if (len > 0)
|
||||
memmove(buffer, p->cur, len);
|
||||
p->cur += len;
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Read a character */
|
||||
static int cgatsFileMem_getch(
|
||||
cgatsFile *pp
|
||||
) {
|
||||
cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
int c;
|
||||
|
||||
if (p->cur < p->start || p->cur >= p->end)
|
||||
return EOF;
|
||||
|
||||
c = (int)*p->cur;
|
||||
p->cur++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Expand the memory buffer file to hold up to pointer ep */
|
||||
/* Don't expand if realloc fails */
|
||||
static void cgatsFileMem_filemem_resize(cgatsFileMem *p, unsigned char *ep) {
|
||||
size_t na, co, ce;
|
||||
unsigned char *nstart;
|
||||
|
||||
/* No need to realloc */
|
||||
if (ep <= p->aend) {
|
||||
return;
|
||||
}
|
||||
|
||||
co = p->cur - p->start; /* Current offset */
|
||||
ce = p->end - p->start; /* Current end */
|
||||
na = ep - p->start; /* new allocatd size */
|
||||
|
||||
/* Round new allocation up */
|
||||
if (na <= 1024)
|
||||
na += 1024;
|
||||
else
|
||||
na += 4096;
|
||||
|
||||
if ((nstart = p->al->realloc(p->al, p->start, na)) != NULL) {
|
||||
p->start = nstart;
|
||||
p->cur = nstart + co;
|
||||
p->end = nstart + ce;
|
||||
p->aend = nstart + na;
|
||||
}
|
||||
}
|
||||
|
||||
/* write count items of size length. Return number of items successfully written. */
|
||||
static size_t cgatsFileMem_write(
|
||||
cgatsFile *pp,
|
||||
void *buffer,
|
||||
size_t size,
|
||||
size_t count
|
||||
) {
|
||||
cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
size_t len;
|
||||
|
||||
len = ssat_mul(size, count);
|
||||
if (len > (size_t)(p->end - p->cur)) /* Try and expand buffer */
|
||||
cgatsFileMem_filemem_resize(p, p->start + len);
|
||||
|
||||
if (len > (size_t)(p->end - p->cur)) {
|
||||
if (size > 0)
|
||||
count = (p->end - p->cur)/size;
|
||||
else
|
||||
count = 0;
|
||||
}
|
||||
len = size * count;
|
||||
if (len > 0)
|
||||
memmove(p->cur, buffer, len);
|
||||
p->cur += len;
|
||||
if (p->end < p->cur)
|
||||
p->end = p->cur;
|
||||
return count;
|
||||
}
|
||||
|
||||
/* do a printf */
|
||||
static int cgatsFileMem_printf(
|
||||
cgatsFile *pp,
|
||||
const char *format,
|
||||
...
|
||||
) {
|
||||
int rv;
|
||||
va_list args;
|
||||
cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
int alen, len;
|
||||
|
||||
va_start(args, format);
|
||||
|
||||
rv = 1;
|
||||
alen = 100; /* Initial allocation for printf */
|
||||
cgatsFileMem_filemem_resize(p, p->cur + alen);
|
||||
|
||||
/* We have to use the available printf functions to resize the buffer if needed. */
|
||||
for (;rv != 0;) {
|
||||
/* vsnprintf() either returns -1 if it doesn't fit, or */
|
||||
/* returns the size-1 needed in order to fit. */
|
||||
len = vsnprintf((char *)p->cur, (p->aend - p->cur), format, args);
|
||||
|
||||
if (len > -1 && ((p->cur + len +1) <= p->aend)) /* Fitted in current allocation */
|
||||
break;
|
||||
|
||||
if (len > -1) /* vsnprintf returned needed size-1 */
|
||||
alen = len+2; /* (In case vsnprintf returned 1 less than it needs) */
|
||||
else
|
||||
alen *= 2; /* We just have to guess */
|
||||
|
||||
/* Attempt to resize */
|
||||
cgatsFileMem_filemem_resize(p, p->cur + alen);
|
||||
|
||||
/* If resize failed */
|
||||
if ((p->aend - p->cur) < alen) {
|
||||
rv = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rv != 0) {
|
||||
/* Figure out where end of printf is */
|
||||
len = strlen((char *)p->cur); /* Length excluding nul */
|
||||
p->cur += len;
|
||||
if (p->cur > p->end)
|
||||
p->end = p->cur;
|
||||
rv = len;
|
||||
}
|
||||
va_end(args);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* flush all write data out to secondary storage. Return nz on failure. */
|
||||
static int cgatsFileMem_flush(
|
||||
cgatsFile *pp
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the memory buffer. Error if not cgatsFileMem */
|
||||
static int cgatsFileMem_get_buf(
|
||||
cgatsFile *pp,
|
||||
unsigned char **buf,
|
||||
size_t *len
|
||||
) {
|
||||
cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
if (buf != NULL)
|
||||
*buf = p->start;
|
||||
if (len != NULL)
|
||||
*len = p->end - p->start;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return the filename */
|
||||
static char *cgatsFileMem_fname(
|
||||
cgatsFile *pp
|
||||
) {
|
||||
// cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
|
||||
/* Memory doesn't have a name */
|
||||
return "**Mem**";
|
||||
}
|
||||
|
||||
/* we're done with the file object, return nz on failure */
|
||||
static int cgatsFileMem_delete(
|
||||
cgatsFile *pp
|
||||
) {
|
||||
cgatsFileMem *p = (cgatsFileMem *)pp;
|
||||
cgatsAlloc *al = p->al;
|
||||
int del_al = p->del_al;
|
||||
|
||||
if (p->del_buf) /* Free the memory buffer */
|
||||
al->free(al, p->start);
|
||||
al->free(al, p); /* Free object */
|
||||
if (del_al) /* We are responsible for deleting allocator */
|
||||
al->del(al);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create a memory image file access class with allocator */
|
||||
/* Buffer is used as is. */
|
||||
cgatsFile *new_cgatsFileMem_a(
|
||||
void *base, /* Pointer to base of memory buffer */
|
||||
size_t length, /* Number of bytes in buffer */
|
||||
cgatsAlloc *al /* heap allocator */
|
||||
) {
|
||||
cgatsFileMem *p;
|
||||
|
||||
if ((p = (cgatsFileMem *) al->calloc(al, 1, sizeof(cgatsFileMem))) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
p->al = al; /* Heap allocator */
|
||||
p->get_size = cgatsFileMem_get_size;
|
||||
p->seek = cgatsFileMem_seek;
|
||||
p->read = cgatsFileMem_read;
|
||||
p->getch = cgatsFileMem_getch;
|
||||
p->write = cgatsFileMem_write;
|
||||
p->gprintf = cgatsFileMem_printf;
|
||||
p->flush = cgatsFileMem_flush;
|
||||
p->get_buf = cgatsFileMem_get_buf;
|
||||
p->fname = cgatsFileMem_fname;
|
||||
p->del = cgatsFileMem_delete;
|
||||
|
||||
p->start = (unsigned char *)base;
|
||||
p->cur = p->start;
|
||||
p->aend = p->end = p->start + length;
|
||||
|
||||
return (cgatsFile *)p;
|
||||
}
|
||||
|
||||
/* Create a memory image file access class with given allocator */
|
||||
/* and delete base when cgatsFile is deleted. */
|
||||
cgatsFile *new_cgatsFileMem_ad(void *base, size_t length, cgatsAlloc *al) {
|
||||
cgatsFile *fp;
|
||||
|
||||
if ((fp = new_cgatsFileMem_a(base, length, al)) != NULL) {
|
||||
((cgatsFileMem *)fp)->del_buf = 1;
|
||||
}
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
||||
/* --------------------------------------------- */
|
||||
/* Free up the structure (doesn't close the file) */
|
||||
static void
|
||||
del_parse(parse *p) {
|
||||
cgatsAlloc *al = p->al;
|
||||
int del_al = p->del_al;
|
||||
|
||||
if (p->b != NULL)
|
||||
al->free(al, p->b);
|
||||
if (p->tb != NULL)
|
||||
al->free(al, p->tb);
|
||||
al->free(al, p);
|
||||
|
||||
if (del_al) /* We are responsible for deleting allocator */
|
||||
al->del(al);
|
||||
}
|
||||
|
||||
|
||||
/* Read the next line from the file into the line buffer. */
|
||||
/* Return 0 if the read fails due to reaching EOF before */
|
||||
/* putting anything in the buffer. */
|
||||
/* Return -1 if there was some other sort of failure, */
|
||||
/* and the error message in parse will be valid. */
|
||||
static int
|
||||
read_line(parse *p) {
|
||||
int c;
|
||||
p->bo = 0; /* Reset pointer to the start of the line buffer */
|
||||
p->q = 0; /* Reset quoted flag */
|
||||
p->e.c = 0; /* Reset error status */
|
||||
p->e.m[0] = '\000';
|
||||
do {
|
||||
if ((c = p->fp->getch(p->fp)) == EOF) {
|
||||
if (p->bo == 0) { /* If there is nothing in the buffer */
|
||||
p->line = 0;
|
||||
#ifdef DEBUG
|
||||
printf("pars: read_line() got EOF\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
c = 0; /* Finish the line */
|
||||
}
|
||||
if (p->ltflag == 1) { /* Finished last line on '\r' */
|
||||
p->ltflag = 0;
|
||||
if (c == '\n') {
|
||||
if (p->q == 0)
|
||||
continue; /* Ignore the following '\n' */
|
||||
else
|
||||
p->line--; /* Undo double increment due to \n after \r */
|
||||
}
|
||||
/* else fall through and use character */
|
||||
} else if (p->ltflag == 2) { /* Finished last line on comment character */
|
||||
/* Suck up chars till the start of the next line */
|
||||
if (c == '\r')
|
||||
p->ltflag = 1;
|
||||
else if (c == '\n')
|
||||
p->ltflag = 0;
|
||||
continue; /* Ignore characters untill we get to the end of the line */
|
||||
}
|
||||
|
||||
if (c == '\r') {
|
||||
p->line++; /* Increment line number */
|
||||
p->ltflag = 1; /* Remember to allow 1 of '\n' before next line */
|
||||
if (p->q == 0)
|
||||
c = 0; /* Finish the line */
|
||||
} else if (p->q == 0 && (p->delf[c] & PARS_COMM) != 0) { /* Hit a comment */
|
||||
p->line++; /* Increment line number */
|
||||
p->ltflag = 2; /* Remember to flush all chars up to end of line */
|
||||
c = 0; /* Finish the line */
|
||||
} else if (c == '\n') {
|
||||
p->line++; /* Increment line number */
|
||||
if (p->q == 0)
|
||||
c = 0; /* Finish the the line */
|
||||
}
|
||||
|
||||
/* Deal with starting/stopping a quoted section */
|
||||
if ((p->delf[c] & PARS_QUOTE) != 0) {
|
||||
if (p->q == 0) /* We weren't in a quoted section */
|
||||
p->q = c; /* Start of quoted section */
|
||||
else if (c == p->q) /* If matching quote */
|
||||
p->q = 0; /* End quoted section */
|
||||
}
|
||||
|
||||
/* Can put the character in the buffer now */
|
||||
if (p->bo == p->bs) { /* Run out of buffer space */
|
||||
p->bs = (p->bs + 100) * 2; /* Expand line buffer size */
|
||||
if ((p->b = (char *) p->al->realloc(p->al, p->b, p->bs)) == NULL) {
|
||||
sprintf(p->e.m,"parse.read_line(), realloc failed!");
|
||||
return (p->e.c = -1);
|
||||
}
|
||||
}
|
||||
p->b[p->bo++] = c; /* Stash character away */
|
||||
} while (c != 0); /* Null means we've done the end of the line */
|
||||
p->to = 0; /* Reset token pointer to the start of the line buffer */
|
||||
p->q = 0; /* Reset quoted flag */
|
||||
#ifdef DEBUG
|
||||
printf("pars: read_line() got buffer '%s'\n",p->b);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Reset the delimiter character set */
|
||||
static void
|
||||
reset_del(parse *p) {
|
||||
int i;
|
||||
for (i = 0; i < 256; i++)
|
||||
p->delf[i] = 0;
|
||||
p->delf[0] = PARS_TERM;
|
||||
}
|
||||
|
||||
/* Add to the parsing characters */
|
||||
static void
|
||||
add_del(
|
||||
parse *p, /* Parse structure */
|
||||
char *t, /* Terminators */
|
||||
char *nr, /* Not Read */
|
||||
char *c, /* Comment start */
|
||||
char *q) /* Quote characters */
|
||||
{
|
||||
int i;
|
||||
if (t != NULL)
|
||||
for (i = 0; t[i] != '\000'; i++)
|
||||
p->delf[(int)t[i]] |= PARS_TERM;
|
||||
if (nr != NULL)
|
||||
for (i = 0; nr[i] != '\000'; i++)
|
||||
p->delf[(int)nr[i]] |= PARS_SKIP;
|
||||
if (c != NULL)
|
||||
for (i = 0; c[i] != '\000'; i++)
|
||||
p->delf[(int)c[i]] |= PARS_COMM;
|
||||
if (q != NULL)
|
||||
for (i = 0; q[i] != '\000'; i++)
|
||||
p->delf[(int)q[i]] |= PARS_QUOTE;
|
||||
}
|
||||
|
||||
/* Using the current token delimiter table and the current line, */
|
||||
/* parse it from the current location and return a pointer to the */
|
||||
/* null terminated token. Return NULL if there is no token found */
|
||||
/* set the parse err and e.c to non-zero if there was some other error */
|
||||
static char *
|
||||
get_token(parse *p) {
|
||||
int tbo = 0; /* Token buffer offset */
|
||||
int term = 0; /* flag to trigger token termination */
|
||||
char c;
|
||||
|
||||
p->e.c = 0; /* Reset error status */
|
||||
p->e.m[0] = '\000';
|
||||
if (p->b == NULL) {
|
||||
#ifdef DEBUG
|
||||
printf("pars: read_token() NULL buffe\n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
p->token++; /* Increment token number */
|
||||
p->q = 0;
|
||||
do {
|
||||
if (term)
|
||||
c = '\000'; /* end token */
|
||||
else if ((c = p->b[p->to++]) == '\000') /* Fetch next token */
|
||||
p->to--; /* Safety - don't pass end */
|
||||
|
||||
/* Deal with starting/stopping a quoted section */
|
||||
if ((p->delf[c] & PARS_QUOTE) != 0) {
|
||||
if (p->q == 0) /* We weren't in a quoted section */
|
||||
p->q = c; /* Start of quoted section */
|
||||
else if (c == p->q) /* If matching quote */
|
||||
p->q = 0; /* End quoted section */
|
||||
}
|
||||
|
||||
if (tbo == p->tbs) { /* Run out of buffer space */
|
||||
p->tbs = (p->tbs + 100) * 2; /* Expand token buffer size */
|
||||
if ((p->tb = (char *) p->al->realloc(p->al, p->tb, p->tbs)) == NULL) {
|
||||
sprintf(p->e.m,"parse.get_token(), realloc failed!");
|
||||
p->e.c = -1;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((p->q != 0 && (p->q != c || (p->delf[c] & PARS_SKIP) == 0))
|
||||
/* If quoted, store if trigger quite is not being skipped */
|
||||
|| (!(tbo == 0 && (p->delf[c] & PARS_TERM) != 0 && (p->delf[c] & PARS_SKIP) != 0)
|
||||
/* Skip initial non-reader terminators */
|
||||
&& (p->delf[c] & PARS_SKIP) == 0)) /* Skip non-readers */
|
||||
p->tb[tbo++] = c; /* Stash character away in token */
|
||||
|
||||
if (p->q == 0 /* If not quoted and if token is non-empty and we have a terminator */
|
||||
&& tbo != 0 && (p->delf[c] & PARS_TERM) != 0)
|
||||
term = 1; /* Finish token off next time around */
|
||||
} while (c != '\000'); /* Null means we've done the end of the token */
|
||||
p->q = 0;
|
||||
if (tbo <= 1) {
|
||||
p->token = 0;
|
||||
#ifdef DEBUG
|
||||
printf("pars: read_token() got nothing useful\n");
|
||||
#endif
|
||||
return NULL; /* Haven't read anything useful */
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("pars: read_token() returning '%s'\n",p->tb);
|
||||
#endif
|
||||
return p->tb;
|
||||
}
|
||||
|
||||
/* ========================================================== */
|
||||
/* Test code */
|
||||
|
||||
#ifdef STANDALONE_TEST
|
||||
int
|
||||
main() {
|
||||
int rc;
|
||||
parse *pp;
|
||||
cgatsFile *fp;
|
||||
|
||||
if ((fp = new_cgatsFileStd_name("test.txt", "r")) == NULL)
|
||||
error("Failed to open file 'test.txt'");
|
||||
|
||||
if ((pp = new_parse(fp)) == NULL)
|
||||
error("Failed to create parse object with file 'test.txt'");
|
||||
|
||||
/* Setup our token parsing charaters */
|
||||
pp->add_del(pp, " ,\t"," ,\t", "#", "\"");
|
||||
|
||||
for (;;) {
|
||||
char *tp;
|
||||
if ((rc = pp->read_line(pp)) == -1)
|
||||
error("%s",pp->e.m);
|
||||
if (rc == 0)
|
||||
break;
|
||||
printf("Line %d = '%s'\n",pp->line,pp->b);
|
||||
do {
|
||||
tp = pp->get_token(pp);
|
||||
if (pp->e.c != 0)
|
||||
error("%s",pp->e.m);
|
||||
if (tp != NULL)
|
||||
printf("Token %d = '%s'\n",pp->token,tp);
|
||||
} while (tp != NULL);
|
||||
}
|
||||
printf("End of File\n");
|
||||
|
||||
pp->del(pp); /* Clean up */
|
||||
fp->del(fp); /* Close the file */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Basic printf type error() and warning() routines for standalone test */
|
||||
void
|
||||
error(const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr,"chart: Error - ");
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
void
|
||||
warning(const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr,"chart: Warning - ");
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
#endif /* STANDALONE_TEST */
|
||||
/* ---------------------------------------------------------- */
|
||||
261
Argyll_V3.5.0/cgats/pars.h
Normal file
261
Argyll_V3.5.0/cgats/pars.h
Normal file
@@ -0,0 +1,261 @@
|
||||
#ifndef PARS_H
|
||||
/*
|
||||
* Simple ASCII file parsing object.
|
||||
* Used as a base for the CGATS.5 and IT8.7 family file I/O class
|
||||
*/
|
||||
|
||||
/*
|
||||
* Version 2.01
|
||||
*
|
||||
* Author: Graeme W. Gill
|
||||
* Date: 20/12/95
|
||||
*
|
||||
* Copyright 1995, 1996, 2002 Graeme W. Gill
|
||||
* All rights reserved.
|
||||
*
|
||||
* This material is licensed with an "MIT" free use license:-
|
||||
* see the License4.txt file in this directory for licensing details.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef CGATS_DEBUG_MALLOC /* Turns on partial support for filename and linenumber capture */
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - */
|
||||
#define CGATS_ERRM_LENGTH 2000 /* try and keep in sync with ICM_ERRM_SIZE */
|
||||
|
||||
typedef struct {
|
||||
int c; /* Error code */
|
||||
char m[CGATS_ERRM_LENGTH]; /* Error message */
|
||||
} cgats_err;
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/* System interface objects. The defaults can be replaced */
|
||||
/* for adaption to different system environments */
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifdef CGATS_DEBUG_MALLOC
|
||||
|
||||
/* Heap allocator class interface definition */
|
||||
#define CGATS_ALLOC_BASE \
|
||||
/* Public: */ \
|
||||
\
|
||||
void *(*dmalloc) (struct _cgatsAlloc *p, size_t size, char *file, int line); \
|
||||
void *(*dcalloc) (struct _cgatsAlloc *p, size_t num, size_t size, char *file, int line);\
|
||||
void *(*drealloc)(struct _cgatsAlloc *p, void *ptr, size_t size, char *file, int line); \
|
||||
void (*dfree) (struct _cgatsAlloc *p, void *ptr, char *file, int line); \
|
||||
\
|
||||
/* we're done with the allocator object */ \
|
||||
void (*del)(struct _cgatsAlloc *p); \
|
||||
|
||||
#if defined(_PARS_C_) || defined(_CGATS_C_) || defined(_PARSSTD_C_) /* only inside implimentation */
|
||||
#define malloc( p, size ) dmalloc( p, size, __FILE__, __LINE__ )
|
||||
#define calloc( p, num, size ) dcalloc( p, num, size, __FILE__, __LINE__ )
|
||||
#define realloc( p, ptr, size ) drealloc( p, ptr, size, __FILE__, __LINE__ )
|
||||
#define free( p, ptr ) dfree( p, ptr , __FILE__, __LINE__ )
|
||||
#endif
|
||||
|
||||
#else /* !CGATS_DEBUG_MALLOC */
|
||||
|
||||
/* Heap allocator class interface definition */
|
||||
#define CGATS_ALLOC_BASE \
|
||||
/* Public: */ \
|
||||
\
|
||||
void *(*malloc) (struct _cgatsAlloc *p, size_t size); \
|
||||
void *(*calloc) (struct _cgatsAlloc *p, size_t num, size_t size); \
|
||||
void *(*realloc)(struct _cgatsAlloc *p, void *ptr, size_t size); \
|
||||
void (*free) (struct _cgatsAlloc *p, void *ptr); \
|
||||
\
|
||||
/* we're done with the allocator object */ \
|
||||
void (*del)(struct _cgatsAlloc *p); \
|
||||
|
||||
#endif /* !CGATS_DEBUG_MALLOC */
|
||||
|
||||
/* Common heap allocator interface class */
|
||||
struct _cgatsAlloc {
|
||||
CGATS_ALLOC_BASE
|
||||
}; typedef struct _cgatsAlloc cgatsAlloc;
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/* Available when SEPARATE_STD is not defined: */
|
||||
/* Implementation of heap class based on standard system malloc */
|
||||
struct _cgatsAllocStd {
|
||||
CGATS_ALLOC_BASE
|
||||
}; typedef struct _cgatsAllocStd cgatsAllocStd;
|
||||
|
||||
/* Create a standard alloc object */
|
||||
cgatsAlloc *new_cgatsAllocStd(void);
|
||||
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/* File access class interface definition */
|
||||
#define CGATS_FILE_BASE \
|
||||
/* Public: */ \
|
||||
\
|
||||
/* Get the size of the file (Only valid for reading file). */ \
|
||||
size_t (*get_size) (struct _cgatsFile *p); \
|
||||
\
|
||||
/* Set current position to offset. Return 0 on success, nz on failure. */ \
|
||||
int (*seek) (struct _cgatsFile *p, unsigned int offset); \
|
||||
\
|
||||
/* Read count items of size length. Return number of items successfully read. */ \
|
||||
size_t (*read) (struct _cgatsFile *p, void *buffer, size_t size, size_t count); \
|
||||
\
|
||||
/* Read a single character */ \
|
||||
int (*getch) (struct _cgatsFile *p); \
|
||||
\
|
||||
/* write count items of size length. Return number of items successfully written. */ \
|
||||
size_t (*write)(struct _cgatsFile *p, void *buffer, size_t size, size_t count); \
|
||||
\
|
||||
/* printf to the file */ \
|
||||
int (*gprintf)(struct _cgatsFile *p, const char *format, ...); \
|
||||
\
|
||||
/* flush all write data out to secondary storage. Return nz on failure. */ \
|
||||
int (*flush)(struct _cgatsFile *p); \
|
||||
\
|
||||
/* return the filename if known, NULL if not */ \
|
||||
char *(*fname)(struct _cgatsFile *p); \
|
||||
\
|
||||
/* Return the memory buffer. Error if not cgatsFileMem */ \
|
||||
int (*get_buf)(struct _cgatsFile *p, unsigned char **buf, size_t *len); \
|
||||
\
|
||||
/* we're done with the file object, close & free it */ \
|
||||
/* return nz on failure */ \
|
||||
int (*del)(struct _cgatsFile *p); \
|
||||
|
||||
/* Common file interface class */
|
||||
struct _cgatsFile {
|
||||
CGATS_FILE_BASE
|
||||
}; typedef struct _cgatsFile cgatsFile;
|
||||
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/* Available when SEPARATE_STD is not defined: */
|
||||
|
||||
/* Implementation of file access class based on standard file I/O */
|
||||
struct _cgatsFileStd {
|
||||
CGATS_FILE_BASE
|
||||
|
||||
/* Private: */
|
||||
cgatsAlloc *al; /* Heap allocator */
|
||||
int del_al; /* NZ if heap allocator should be deleted */
|
||||
FILE *fp;
|
||||
int doclose; /* nz if free should close */
|
||||
char *filename; /* NULL if not known */
|
||||
|
||||
/* Private: */
|
||||
size_t size; /* Size of the file (For read) */
|
||||
|
||||
}; typedef struct _cgatsFileStd cgatsFileStd;
|
||||
|
||||
/* Create given a file name */
|
||||
cgatsFile *new_cgatsFileStd_name(const char *name, const char *mode);
|
||||
|
||||
/* Create given a (binary) FILE* */
|
||||
cgatsFile *new_cgatsFileStd_fp(FILE *fp);
|
||||
|
||||
/* Create given a file name and allocator */
|
||||
cgatsFile *new_cgatsFileStd_name_a(const char *name, const char *mode, cgatsAlloc *al);
|
||||
|
||||
/* Create given a (binary) FILE* and allocator */
|
||||
cgatsFile *new_cgatsFileStd_fp_a(FILE *fp, cgatsAlloc *al);
|
||||
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - */
|
||||
/* Implementation of file access class based on a memory image */
|
||||
/* The buffer is assumed to be allocated with the given heap allocator */
|
||||
/* Pass base = NULL, length = 0 for no initial buffer */
|
||||
|
||||
/* ~~ should ad method that returns buffer and length */
|
||||
|
||||
struct _cgatsFileMem {
|
||||
CGATS_FILE_BASE
|
||||
|
||||
/* Private: */
|
||||
cgatsAlloc *al; /* Heap allocator */
|
||||
int del_al; /* NZ if heap allocator should be deleted */
|
||||
int del_buf; /* NZ if memory file buffer should be deleted */
|
||||
unsigned char *start, *cur, *end, *aend;
|
||||
|
||||
}; typedef struct _cgatsFileMem cgatsFileMem;
|
||||
|
||||
/* Create a memory image file access class with given allocator */
|
||||
/* The buffer is not delete with the object. */
|
||||
cgatsFile *new_cgatsFileMem_a(void *base, size_t length, cgatsAlloc *al);
|
||||
|
||||
/* Create a memory image file access class with given allocator */
|
||||
/* and delete buffer when cgatsFile is deleted. */
|
||||
cgatsFile *new_cgatsFileMem_ad(void *base, size_t length, cgatsAlloc *al);
|
||||
|
||||
/* This is avalailable if SEPARATE_STD is not defined: */
|
||||
|
||||
/* Create a memory image file access class with the std allocator */
|
||||
/* The buffer is not delete with the object. */
|
||||
cgatsFile *new_cgatsFileMem(void *base, size_t length);
|
||||
|
||||
/* Create a memory image file access class with the std allocator */
|
||||
/* and delete buffer when cgatsFile is deleted. */
|
||||
cgatsFile *new_cgatsFileMem_d(void *base, size_t length);
|
||||
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
struct _parse {
|
||||
/* Public Variables */
|
||||
int line; /* Current line number */
|
||||
int token; /* Current token number */
|
||||
|
||||
/* Public Methods */
|
||||
void (*del)(struct _parse *p); /* Delete the object */
|
||||
void (*reset_del)(struct _parse *p); /* Reset the parsing delimiters */
|
||||
void (*add_del)(struct _parse *p, /* Add to the parsing delimiters */
|
||||
char *t, char *nr,
|
||||
char *c, char *q);
|
||||
int (*read_line)(struct _parse *p); /* Read in a line. Return 0 if read failed, */
|
||||
/* -1 on other error */
|
||||
char *(*get_token)(struct _parse *p); /* Return a pointer to the next token, */
|
||||
/* NULL if no tokens. set e.c NZ on other error */
|
||||
|
||||
/* Private */
|
||||
cgatsAlloc *al; /* Memory allocator */
|
||||
int del_al; /* Flag to indicate we al->del() */
|
||||
cgatsFile *fp; /* File we're dealing with */
|
||||
int ltflag; /* Last terminator flag */
|
||||
int q; /* Quote */
|
||||
char *b; /* Line buffer */
|
||||
int bs; /* Buffer size */
|
||||
int bo; /* Next buffer offset */
|
||||
int to; /* Token parsing offset into b */
|
||||
char *tb; /* Token buffer */
|
||||
int tbs; /* Token buffer size */
|
||||
char delf[256]; /* Parsing delimiter flags */
|
||||
/* Parsing flags */
|
||||
#define PARS_TERM 0x01 /* Terminates a token */
|
||||
#define PARS_SKIP 0x02 /* Character is not read */
|
||||
#define PARS_COMM 0x04 /* Character starts a comment */
|
||||
#define PARS_QUOTE 0x08 /* Character starts/ends a quoted string */
|
||||
|
||||
cgats_err e; /* Error message * code */
|
||||
|
||||
}; typedef struct _parse parse;
|
||||
|
||||
/* Creator */
|
||||
extern parse *new_parse_al(cgatsAlloc *al, cgatsFile *fp); /* With allocator class */
|
||||
|
||||
/* Available when SEPARATE_STD is not defined: */
|
||||
extern parse *new_parse(cgatsFile *fp); /* Default allocator */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define PARS_H
|
||||
#endif /* PARS_H */
|
||||
|
||||
480
Argyll_V3.5.0/cgats/parsstd.c
Normal file
480
Argyll_V3.5.0/cgats/parsstd.c
Normal file
@@ -0,0 +1,480 @@
|
||||
|
||||
/*
|
||||
* parse library stdio and malloc utility classes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Version 2.05
|
||||
*
|
||||
* Author: Graeme W. Gill
|
||||
* Date: 2002/10/24
|
||||
*
|
||||
* Copyright 2002, Graeme W. Gill
|
||||
* All rights reserved.
|
||||
*
|
||||
* This material is licensed with an "MIT" free use license:-
|
||||
* see the License4.txt file in this directory for licensing details.
|
||||
*
|
||||
* These are kept in a separate file to allow them to be
|
||||
* selectively ommitted from the cgats library.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define _PARSSTD_C_
|
||||
|
||||
#ifndef COMBINED_STD
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#ifdef __sun
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "pars.h"
|
||||
|
||||
#endif /* !COMBINED_STD */
|
||||
|
||||
#if defined(SEPARATE_STD) || defined(COMBINED_STD)
|
||||
|
||||
/* ----------------------------------------------- */
|
||||
/* Standard Heap allocator cgatsAlloc compatible class */
|
||||
/* Just call the standard system function */
|
||||
|
||||
#ifdef CGATS_DEBUG_MALLOC
|
||||
|
||||
/* Make sure that inline malloc #defines are turned off for this file */
|
||||
#undef was_debug_malloc
|
||||
#ifdef malloc
|
||||
#undef malloc
|
||||
#undef calloc
|
||||
#undef realloc
|
||||
#undef free
|
||||
#define was_debug_malloc
|
||||
#endif /* dmalloc */
|
||||
|
||||
static void *cgatsAllocStd_dmalloc(
|
||||
struct _cgatsAlloc *pp,
|
||||
size_t size,
|
||||
char *file,
|
||||
int line
|
||||
) {
|
||||
void *rv = malloc(size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void *cgatsAllocStd_dcalloc(
|
||||
struct _cgatsAlloc *pp,
|
||||
size_t num,
|
||||
size_t size,
|
||||
char *file,
|
||||
int line
|
||||
) {
|
||||
void *rv = calloc(num, size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void *cgatsAllocStd_drealloc(
|
||||
struct _cgatsAlloc *pp,
|
||||
void *ptr,
|
||||
size_t size,
|
||||
char *file,
|
||||
int line
|
||||
) {
|
||||
void *rv = realloc(ptr, size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
static void cgatsAllocStd_dfree(
|
||||
struct _cgatsAlloc *pp,
|
||||
void *ptr,
|
||||
char *file,
|
||||
int line
|
||||
) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
/* we're done with the AllocStd object */
|
||||
static void cgatsAllocStd_delete(
|
||||
cgatsAlloc *pp
|
||||
) {
|
||||
cgatsAllocStd *p = (cgatsAllocStd *)pp;
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
/* Create cgatsAllocStd */
|
||||
cgatsAlloc *new_cgatsAllocStd() {
|
||||
cgatsAllocStd *p;
|
||||
if ((p = (cgatsAllocStd *) calloc(1,sizeof(cgatsAllocStd))) == NULL)
|
||||
return NULL;
|
||||
p->dmalloc = cgatsAllocStd_dmalloc;
|
||||
p->dcalloc = cgatsAllocStd_dcalloc;
|
||||
p->drealloc = cgatsAllocStd_drealloc;
|
||||
p->dfree = cgatsAllocStd_dfree;
|
||||
p->del = cgatsAllocStd_delete;
|
||||
|
||||
return (cgatsAlloc *)p;
|
||||
}
|
||||
|
||||
#ifdef was_debug_malloc
|
||||
#undef was_debug_malloc
|
||||
#define malloc( p, size ) dmalloc( p, size, __FILE__, __LINE__ )
|
||||
#define calloc( p, num, size ) dcalloc( p, num, size, __FILE__, __LINE__ )
|
||||
#define realloc( p, ptr, size ) drealloc( p, ptr, size, __FILE__, __LINE__ )
|
||||
#define free( p, ptr ) dfree( p, ptr , __FILE__, __LINE__ )
|
||||
#endif /* was_debug_malloc */
|
||||
|
||||
#else /* !CGATS_DEBUG_MALLOC */
|
||||
|
||||
static void *cgatsAllocStd_malloc(
|
||||
struct _cgatsAlloc *pp,
|
||||
size_t size
|
||||
) {
|
||||
void *rv = malloc(size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void *cgatsAllocStd_calloc(
|
||||
struct _cgatsAlloc *pp,
|
||||
size_t num,
|
||||
size_t size
|
||||
) {
|
||||
void *rv = calloc(num, size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void *cgatsAllocStd_realloc(
|
||||
struct _cgatsAlloc *pp,
|
||||
void *ptr,
|
||||
size_t size
|
||||
) {
|
||||
void *rv = realloc(ptr, size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
static void cgatsAllocStd_free(
|
||||
struct _cgatsAlloc *pp,
|
||||
void *ptr
|
||||
) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
/* we're done with the AllocStd object */
|
||||
static void cgatsAllocStd_delete(
|
||||
cgatsAlloc *pp
|
||||
) {
|
||||
cgatsAllocStd *p = (cgatsAllocStd *)pp;
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
/* Create cgatsAllocStd */
|
||||
cgatsAlloc *new_cgatsAllocStd() {
|
||||
cgatsAllocStd *p;
|
||||
if ((p = (cgatsAllocStd *) calloc(1,sizeof(cgatsAllocStd))) == NULL)
|
||||
return NULL;
|
||||
p->malloc = cgatsAllocStd_malloc;
|
||||
p->calloc = cgatsAllocStd_calloc;
|
||||
p->realloc = cgatsAllocStd_realloc;
|
||||
p->free = cgatsAllocStd_free;
|
||||
p->del = cgatsAllocStd_delete;
|
||||
|
||||
return (cgatsAlloc *)p;
|
||||
}
|
||||
|
||||
#endif /* !CGATS_DEBUG_MALLOC */
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
/* Standard Stream file I/O cgatsFile compatible class */
|
||||
|
||||
/* Get the size of the file (Only valid for reading file. */
|
||||
static size_t cgatsFileStd_get_size(cgatsFile *pp) {
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
|
||||
return p->size;
|
||||
}
|
||||
|
||||
/* Set current position to offset. Return 0 on success, nz on failure. */
|
||||
static int cgatsFileStd_seek(
|
||||
cgatsFile *pp,
|
||||
unsigned int offset
|
||||
) {
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
|
||||
return fseek(p->fp, offset, SEEK_SET);
|
||||
}
|
||||
|
||||
/* Read count items of size length. Return number of items successfully read. */
|
||||
static size_t cgatsFileStd_read(
|
||||
cgatsFile *pp,
|
||||
void *buffer,
|
||||
size_t size,
|
||||
size_t count
|
||||
) {
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
|
||||
return fread(buffer, size, count, p->fp);
|
||||
}
|
||||
|
||||
/* Read a character */
|
||||
static int cgatsFileStd_getch(
|
||||
cgatsFile *pp
|
||||
) {
|
||||
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
|
||||
return fgetc(p->fp);
|
||||
}
|
||||
|
||||
/* write count items of size length. Return number of items successfully written. */
|
||||
static size_t cgatsFileStd_write(
|
||||
cgatsFile *pp,
|
||||
void *buffer,
|
||||
size_t size,
|
||||
size_t count
|
||||
) {
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
|
||||
return fwrite(buffer, size, count, p->fp);
|
||||
}
|
||||
|
||||
/* do a printf */
|
||||
static int cgatsFileStd_printf(
|
||||
cgatsFile *pp,
|
||||
const char *format,
|
||||
...
|
||||
) {
|
||||
int rv;
|
||||
va_list args;
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
|
||||
va_start(args, format);
|
||||
rv = vfprintf(p->fp, format, args);
|
||||
va_end(args);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* flush all write data out to secondary storage. Return nz on failure. */
|
||||
static int cgatsFileStd_flush(
|
||||
cgatsFile *pp
|
||||
) {
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
|
||||
return fflush(p->fp);
|
||||
}
|
||||
|
||||
/* Return the memory buffer. Error if not cgatsFileMem */
|
||||
static int cgatsFileStd_get_buf(
|
||||
cgatsFile *pp,
|
||||
unsigned char **buf,
|
||||
size_t *len
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* return the filename */
|
||||
static char *cgatsFileStd_fname(
|
||||
cgatsFile *pp
|
||||
) {
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
|
||||
if (p->filename != NULL)
|
||||
return p->filename;
|
||||
else
|
||||
return "**Unknown**";
|
||||
}
|
||||
|
||||
|
||||
/* we're done with the file object, return nz on failure */
|
||||
static int cgatsFileStd_delete(
|
||||
cgatsFile *pp
|
||||
) {
|
||||
int rv = 0;
|
||||
cgatsFileStd *p = (cgatsFileStd *)pp;
|
||||
cgatsAlloc *al = p->al;
|
||||
int del_al = p->del_al;
|
||||
|
||||
if (p->doclose != 0) {
|
||||
if (fclose(p->fp) != 0)
|
||||
rv = 2;
|
||||
}
|
||||
|
||||
if (p->filename != NULL)
|
||||
al->free(al, p->filename);
|
||||
|
||||
al->free(al, p); /* Free object */
|
||||
if (del_al) /* We are responsible for deleting allocator */
|
||||
al->del(al);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Create cgatsFile given a (binary) FILE* */
|
||||
cgatsFile *new_cgatsFileStd_fp(
|
||||
FILE *fp
|
||||
) {
|
||||
return new_cgatsFileStd_fp_a(fp, NULL);
|
||||
}
|
||||
|
||||
/* Create cgatsFile given a (binary) FILE* and allocator */
|
||||
cgatsFile *new_cgatsFileStd_fp_a(
|
||||
FILE *fp,
|
||||
cgatsAlloc *al /* heap allocator, NULL for default */
|
||||
) {
|
||||
cgatsFileStd *p;
|
||||
int del_al = 0;
|
||||
struct stat sbuf = { 0 };
|
||||
|
||||
if (al == NULL) { /* None provided, create default */
|
||||
if ((al = new_cgatsAllocStd()) == NULL)
|
||||
return NULL;
|
||||
del_al = 1; /* We need to delete it */
|
||||
}
|
||||
|
||||
if ((p = (cgatsFileStd *) al->calloc(al, 1, sizeof(cgatsFileStd))) == NULL) {
|
||||
if (del_al)
|
||||
al->del(al);
|
||||
return NULL;
|
||||
}
|
||||
p->al = al; /* Heap allocator */
|
||||
p->del_al = del_al; /* Flag noting whether we delete it */
|
||||
p->get_size = cgatsFileStd_get_size;
|
||||
p->seek = cgatsFileStd_seek;
|
||||
p->read = cgatsFileStd_read;
|
||||
p->getch = cgatsFileStd_getch;
|
||||
p->write = cgatsFileStd_write;
|
||||
p->gprintf = cgatsFileStd_printf;
|
||||
p->flush = cgatsFileStd_flush;
|
||||
p->get_buf = cgatsFileStd_get_buf;
|
||||
p->fname = cgatsFileStd_fname;
|
||||
p->del = cgatsFileStd_delete;
|
||||
|
||||
if (fstat(fileno(fp), &sbuf) == 0) {
|
||||
p->size = sbuf.st_size;
|
||||
} else {
|
||||
p->size = 0;
|
||||
}
|
||||
|
||||
p->fp = fp;
|
||||
p->doclose = 0;
|
||||
|
||||
return (cgatsFile *)p;
|
||||
}
|
||||
|
||||
/* Create cgatsFile given a file name */
|
||||
cgatsFile *new_cgatsFileStd_name(
|
||||
const char *name,
|
||||
const char *mode
|
||||
) {
|
||||
return new_cgatsFileStd_name_a(name, mode, NULL);
|
||||
}
|
||||
|
||||
/* Create given a file name and allocator */
|
||||
cgatsFile *new_cgatsFileStd_name_a(
|
||||
const char *name,
|
||||
const char *mode,
|
||||
cgatsAlloc *al /* heap allocator, NULL for default */
|
||||
) {
|
||||
FILE *fp;
|
||||
cgatsFile *p;
|
||||
char nmode[50];
|
||||
|
||||
strcpy(nmode, mode);
|
||||
#if !defined(O_CREAT) && !defined(_O_CREAT)
|
||||
# error "Need to #include fcntl.h!"
|
||||
#endif
|
||||
#if defined(O_BINARY) || defined(_O_BINARY)
|
||||
strcat(nmode, "b");
|
||||
#endif
|
||||
|
||||
if ((fp = fopen(name, nmode)) == NULL)
|
||||
return NULL;
|
||||
|
||||
p = new_cgatsFileStd_fp_a(fp, al);
|
||||
|
||||
if (p != NULL) {
|
||||
cgatsFileStd *pp = (cgatsFileStd *)p;
|
||||
pp->doclose = 1;
|
||||
|
||||
pp->filename = pp->al->malloc(pp->al, strlen(name) + 1);
|
||||
strcpy(pp->filename, name);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Create a memory image file access class with the std allocator */
|
||||
/* Don't free the buffer on delete */
|
||||
cgatsFile *new_cgatsFileMem(
|
||||
void *base, /* Pointer to base of memory buffer */
|
||||
size_t length /* Number of bytes in buffer */
|
||||
) {
|
||||
cgatsFile *p;
|
||||
cgatsAlloc *al; /* memory allocator */
|
||||
|
||||
if ((al = new_cgatsAllocStd()) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((p = new_cgatsFileMem_a(base, length, al)) == NULL) {
|
||||
al->del(al);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
((cgatsFileMem *)p)->del_al = 1; /* Get cgatsFileMem->del to cleanup al */
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Create a memory image file access class with the std allocator */
|
||||
/* Free buffer on delete */
|
||||
cgatsFile *new_cgatsFileMem_d(
|
||||
void *base, /* Pointer to base of memory buffer */
|
||||
size_t length /* Number of bytes in buffer */
|
||||
) {
|
||||
cgatsFile *p;
|
||||
cgatsAlloc *al; /* memory allocator */
|
||||
|
||||
if ((al = new_cgatsAllocStd()) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((p = new_cgatsFileMem_a(base, length, al)) == NULL) {
|
||||
al->del(al);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
((cgatsFileMem *)p)->del_al = 1; /* Get cgatsFileMem->del to cleanup al */
|
||||
((cgatsFileMem *)p)->del_buf = 1; /* Get cgatsFileMem->del to cleanup buffer */
|
||||
return p;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
|
||||
/* Create an empty parse object, default standard allocator */
|
||||
parse *
|
||||
new_parse(cgatsFile *fp) {
|
||||
parse *p;
|
||||
cgatsAlloc *al; /* memory allocator */
|
||||
|
||||
if ((al = new_cgatsAllocStd()) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((p = new_parse_al(al, fp)) == NULL) {
|
||||
al->del(al);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->del_al = 1; /* Get parse->del to cleanup allocator */
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
#endif /* defined(SEPARATE_STD) || defined(COMBINED_STD) */
|
||||
73
Argyll_V3.5.0/cgats/test.txt
Executable file
73
Argyll_V3.5.0/cgats/test.txt
Executable file
@@ -0,0 +1,73 @@
|
||||
CGATS.5
|
||||
|
||||
# Comment only test comment
|
||||
KEYWORD "TEST_KEY_WORD"
|
||||
TEST_KEY_WORD "try this out" # Keyword comment
|
||||
KEYWORD "TEST_KEY_WORD2"
|
||||
TEST_KEY_WORD2 "try this"" out """" huh !"
|
||||
ORIGINATOR "Not specified"
|
||||
DESCRIPTOR "Not specified"
|
||||
CREATED "November 16, 2000"
|
||||
INSTRUMENTATION "Not specified"
|
||||
MEASUREMENT_SOURCE "Not specified"
|
||||
PRINT_CONDITIONS "Not specified"
|
||||
|
||||
KEYWORD "SAMPLE_LOC"
|
||||
NUMBER_OF_FIELDS 3
|
||||
BEGIN_DATA_FORMAT
|
||||
SAMPLE_ID SAMPLE_LOC XYZ_X
|
||||
END_DATA_FORMAT
|
||||
|
||||
NUMBER_OF_SETS 22
|
||||
BEGIN_DATA
|
||||
1 A1 1.2346e-09
|
||||
2 A1 1.2346e-08
|
||||
3 A1 1.2346e-07
|
||||
4 A1 1.2346e-06
|
||||
5 A1 1.2346e-05
|
||||
6 A2 1.2346e-04
|
||||
"7 " "A#5" 1.2346e-03
|
||||
8 A5 0.012346
|
||||
9 A5 0.12346
|
||||
10 A5 0.0000
|
||||
11 A5 1.2346
|
||||
12 A5 12.346
|
||||
13 A5 123.46
|
||||
14 A5 1234.6
|
||||
16 A5 1.2346e+04
|
||||
17 A5 1.2346e+05
|
||||
18 A5 1.2346e+06
|
||||
19 A5 1.2346e+07
|
||||
20 A5 1.2346e+08
|
||||
21 A5 1.2346e+09
|
||||
22 A5 1.2346e+10
|
||||
23 A5 1.2346e+11
|
||||
END_DATA
|
||||
|
||||
|
||||
# Second Comment only test comment
|
||||
|
||||
NUMBER_OF_SETS 22
|
||||
BEGIN_DATA
|
||||
1 A4 -1.2346e-09
|
||||
2 A4 -1.2346e-08
|
||||
3 A4 -1.2346e-07
|
||||
4 A4 -1.2346e-06
|
||||
5 A4 -1.2346e-05
|
||||
6 A5 -1.2346e-04
|
||||
7 A5 -1.2346e-03
|
||||
8 A5 -0.012346
|
||||
9 A5 -0.12346
|
||||
10 A5 -1.2346
|
||||
11 A5 -12.346
|
||||
12 A5 -123.46
|
||||
13 A5 -1234.6
|
||||
14 A5 -1.2346e+04
|
||||
15 A5 -1.2346e+05
|
||||
16 A5 -1.2346e+06
|
||||
17 A5 -1.2346e+07
|
||||
18 A5 -1.2346e+08
|
||||
19 A5 -1.2346e+09
|
||||
20 A5 -1.2346e+10
|
||||
21 A5 -1.2346e+11
|
||||
E7D_DATA
|
||||
Reference in New Issue
Block a user