0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// This file is available under and governed by the GNU General Public 0N/A// License version 2 only, as published by the Free Software Foundation. 0N/A// However, the following notice accompanied the original version of this 2693N/A//--------------------------------------------------------------------------------- 2693N/A// Little Color Management System 6271N/A// Copyright (c) 1998-2012 Marti Maria Saguer 0N/A// Permission is hereby granted, free of charge, to any person obtaining 0N/A// a copy of this software and associated documentation files (the "Software"), 0N/A// to deal in the Software without restriction, including without limitation 0N/A// the rights to use, copy, modify, merge, publish, distribute, sublicense, 0N/A// and/or sell copies of the Software, and to permit persons to whom the Software 0N/A// is furnished to do so, subject to the following conditions: 0N/A// The above copyright notice and this permission notice shall be included in 0N/A// all copies or substantial portions of the Software. 0N/A// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 0N/A// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 0N/A// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 0N/A// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 0N/A// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 0N/A// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 0N/A// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2693N/A//--------------------------------------------------------------------------------- 2693N/A// IT8.7 / CGATS.17-200x handling ----------------------------------------------------------------------------- 0N/A// How to write the value 0N/A// Linked list of variable names 1002N/A char*
Subkey;
// If key is a dictionary, points to the subkey name 0N/A// Linked list of memory chunks (Memory sink) 0N/A// Table. Each individual table can hold properties and rows & cols 2693N/A// This struct hold all information about an open IT8 handler. 0N/A // Memory management 0N/A // Parser state machine 0N/A int ch;
// Current character 0N/A // Allowed keywords & datasets. They have visibility on whole stream 0N/A int lineno;
// line counter for error reporting 2693N/A// The stream for save operations 2693N/A// ------------------------------------------------------ cmsIT8 parsing routines 0N/A// The keyword->symbol translation table. Sorting is required. 0N/A// Predefined properties 1002N/A {
"ORIGINATOR",
WRITE_STRINGIFY},
// Required - Identifies the specific system, organization or individual that created the data file. 1002N/A {
"FILE_DESCRIPTOR",
WRITE_STRINGIFY},
// Required - Describes the purpose or contents of the data file. 1002N/A {
"DIFFUSE_GEOMETRY",
WRITE_STRINGIFY},
// The diffuse geometry used. Allowed values are "sphere" or "opal". 1002N/A {
"PROD_DATE",
WRITE_STRINGIFY},
// Identifies year and month of production of the target in the form yyyy:mm. 1002N/A {
"MATERIAL",
WRITE_STRINGIFY},
// Identifies the material on which the target was produced using a code 0N/A // uniquely identifying th e material. This is intend ed to be used for IT8.7 0N/A // physical targets only (i.e . IT8.7/1 a nd IT8.7/2). 1002N/A {
"INSTRUMENTATION",
WRITE_STRINGIFY},
// Used to report the specific instrumentation used (manufacturer and 0N/A // model number) to generate the data reported. This data will often 0N/A // provide more information about the particular data collected than an 0N/A // extensive list of specific details. This is particularly important for 0N/A // spectral data or data derived from spectrophotometry. 1002N/A {
"MEASUREMENT_SOURCE",
WRITE_STRINGIFY},
// Illumination used for spectral measurements. This data helps provide 0N/A // a guide to the potential for issues of paper fluorescence, etc. 1002N/A {
"PRINT_CONDITIONS",
WRITE_STRINGIFY},
// Used to define the characteristics of the printed sheet being reported. 0N/A // Where standard conditions have been defined (e.g., SWOP at nominal) 0N/A // named conditions may suffice. Otherwise, detailed information is 1002N/A // measurement. Allowed values are �black�, �white�, or {"na". 2693N/A // below properties are new in recent specs: 1002N/A {
"MEASUREMENT_GEOMETRY",
WRITE_STRINGIFY},
// The type of measurement, either reflection or transmission, should be indicated 1002N/A // along with details of the geometry and the aperture size and shape. For example, 1002N/A // for transmission measurements it is important to identify 0/diffuse, diffuse/0, 1002N/A // opal or integrating sphere, etc. For reflection it is important to identify 0/45, 1002N/A // 45/0, sphere (specular included or excluded), etc. 1002N/A {
"FILTER",
WRITE_STRINGIFY},
// Identifies the use of physical filter(s) during measurement. Typically used to 1002N/A // denote the use of filters such as none, D65, Red, Green or Blue. 1002N/A {
"POLARIZATION",
WRITE_STRINGIFY},
// Identifies the use of a physical polarization filter during measurement. Allowed 1002N/A // values are {"yes�, �white�, �none� or �na�. 1002N/A {
"WEIGHTING_FUNCTION",
WRITE_PAIR},
// Indicates such functions as: the CIE standard observer functions used in the 1002N/A // calculation of various data parameters (2 degree and 10 degree), CIE standard 1002N/A // illuminant functions used in the calculation of various data parameters (e.g., D50, 1002N/A // D65, etc.), density status response, etc. If used there shall be at least one 1002N/A // name-value pair following the WEIGHTING_FUNCTION tag/keyword. The first attribute 1002N/A // in the set shall be {"name" and shall identify the particular parameter used. 1002N/A // The second shall be {"value" and shall provide the value associated with that name. 1002N/A // For ASCII data, a string containing the Name and Value attribute pairs shall follow 1002N/A // the weighting function keyword. A semi-colon separates attribute pairs from each 1002N/A // other and within the attribute the name and value are separated by a comma. 1002N/A {
"COMPUTATIONAL_PARAMETER",
WRITE_PAIR},
// Parameter that is used in computing a value from measured data. Name is the name 1002N/A // of the calculation, parameter is the name of the parameter used in the calculation 1002N/A // and value is the value of the parameter. 1002N/A {
"TARGET_TYPE",
WRITE_STRINGIFY},
// The type of target being measured, e.g. IT8.7/1, IT8.7/3, user defined, etc. 0N/A// Predefined sample types on dataset 1002N/A "SAMPLE_ID",
// Identifies sample that data represents 1002N/A "STRING",
// Identifies label, or other non-machine readable value. 1002N/A // Value must begin and end with a " symbol 0N/A "CMYK_C",
// Cyan component of CMYK data expressed as a percentage 0N/A "CMYK_M",
// Magenta component of CMYK data expressed as a percentage 0N/A "CMYK_Y",
// Yellow component of CMYK data expressed as a percentage 0N/A "CMYK_K",
// Black component of CMYK data expressed as a percentage 0N/A "D_RED",
// Red filter density 0N/A "D_GREEN",
// Green filter density 0N/A "D_BLUE",
// Blue filter density 0N/A "D_VIS",
// Visual filter density 0N/A "D_MAJOR_FILTER",
// Major filter d ensity 0N/A "RGB_R",
// Red component of RGB data 0N/A "RGB_G",
// Green component of RGB data 0N/A "RGB_B",
// Blue com ponent of RGB data 0N/A "SPECTRAL_NM",
// Wavelength of measurement expressed in nanometers 0N/A "XYZ_X",
// X component of tristimulus data 0N/A "XYZ_Y",
// Y component of tristimulus data 0N/A "XYZ_Z",
// Z component of tristimulus data 0N/A "XYY_X" // x component of chromaticity data 0N/A "XYY_Y",
// y component of chromaticity data 0N/A "XYY_CAPY",
// Y component of tristimulus data 0N/A "LAB_L",
// L* component of Lab data 0N/A "LAB_A",
// a* component of Lab data 0N/A "LAB_B",
// b* component of Lab data 0N/A "LAB_C",
// C*ab component of Lab data 0N/A "LAB_H",
// hab component of Lab data 2693N/A "LAB_DE_94",
// CIE dE using CIE 94 2693N/A "LAB_DE_CMC",
// dE using CMC 0N/A "LAB_DE_2000",
// CIE dE using CIE DE 2000 0N/A "MEAN_DE",
// Mean Delta E (LAB_DE) of samples compared to batch average 0N/A // (Used for data files for ANSI IT8.7/1 and IT8.7/2 targets) 0N/A "STDEV_X",
// Standard deviation of X (tristimulus data) 0N/A "STDEV_Y",
// Standard deviation of Y (tristimulus data) 0N/A "STDEV_Z",
// Standard deviation of Z (tristimulus data) 0N/A "STDEV_L",
// Standard deviation of L* 1002N/A "STDEV_A",
// Standard deviation of a* 0N/A "STDEV_B",
// Standard deviation of b* 0N/A "STDEV_DE",
// Standard deviation of CIE dE 0N/A "CHI_SQD_PAR"};
// The average of the standard deviations of L*, a* and b*. It is 0N/A // used to derive an estimate of the chi-squared parameter which is 0N/A // recommended as the predictor of the variability of dE 1002N/A//Forward declaration of some internal functions 0N/A// Checks if c is a separator 0N/A return (c ==
' ') || (c ==
'\t') || (c ==
'\r');
0N/A// Checks whatever if c is a valid identifier char 0N/A return (!
isseparator(c) && (c !=
'#') && (c !=
'\"') && (c !=
'\'') && (c >
32) && (c <
127));
0N/A// Checks whatsever if c is a valid identifier middle char. 0N/A// Checks whatsever if c is a valid identifier first char. 2693N/A// Guess whether the supplied path looks like an absolute path 1002N/A// Makes a file path based on a given reference path 1002N/A// NOTE: this function doesn't check if the path exists or even if it's legal 2693N/A // No need to assure zero terminator over here 1002N/A// Make sure no exploit is being even tried 1002N/A return "**** CORRUPTED FORMAT STRING ***";
1002N/A// Check if current symbol is same as specified. issue an error else. 0N/A// Read Next character from stream 0N/A it8 ->
ch =
' ';
// Whitespace to be ignored 0N/A// Try to see if current identifier is a keyword, if so return the referred symbol 0N/A// Reads a Real number, tries to follow from integer number 2693N/A // Exponent, example 34.00E+20 6271N/A// This can not call directly atof because it uses locale dependant 6271N/A// parsing, while CCMX files always use . as decimal separator 6271N/A // Exponent, example 34.00E+20 0N/A else // Is a number? 0N/A if (
it8->
ch ==
'0') {
// 0xnnnn (Hexa) or 0bnnnn (Binary) 0N/A // Special case. Numbers followed by letters are taken as identifiers 0N/A // EOF marker -- ignore it 0N/A // Eof stream markers 0N/A // Handle the include special token 2693N/A // TODO: how to manage out-of-memory conditions? 0N/A// Checks end of line separator 0N/A// Skip multiple EOLN 0N/A// Returns a string holding current value 0N/A// ---------------------------------------------------------- Table 0N/A// ---------------------------------------------------------- Memory management 0N/A// Frees an allocator and owned memory 0N/A// Allocates a chunk of data, keep linked list 0N/A// Allocates a string 0N/A// Searches through linked list 0N/A if (*
Key !=
'#') {
// Comments are ignored 0N/A// Add a property into a linked list 2693N/A // Check if property is already in list 2693N/A // This may work for editing properties 1002N/A // return SynError(it8, "duplicate key <%s>", Key); 1002N/A // Keep the container in our list 1002N/A // If Subkey is not null, then last is the last property with the same key, 1002N/A // but not necessarily is the last property in the list, so we need to move 0N/A// Init an empty container 0N/A // Initialize predefined properties & data 0N/A// ----------------------------------------------------------------- Datasets 0N/A SynError(
it8,
"AllocateDataFormat: Unable to allocate dataFormat array");
0N/A if (t ->
Data)
return;
// Already allocated 0N/A// --------------------------------------------------------------- File I/O 0N/A// Writes a string to file 1002N/A else {
// Or to a memory block? 1002N/A if (f ->
Base) {
// Am I just counting the bytes? 0N/A// Writes full header 0N/A// Writes the data format 0N/A // If value contains whitespace, enclose within quote 0N/A// -------------------------------------------------------------- Higer level parsing 0N/A // Check for data completion. 1002N/A // chop the string as a list of "subkey, value" pairs, using ';' as a separator 1002N/A // identify token pair boundary 1002N/A // for each pair, split the subkey and the value 1002N/A // gobble the spaces before the coma, and the coma itself 1002N/A // gobble any space at the right 1002N/A // trim the strings from the left 0N/A // First line is a very special case. 6271N/A // Read sheet type if present. We only support identifier and string. 6271N/A // <ident> <eoln> is a type string 6271N/A // anything else, is not a type string 6271N/A // May be a type sheet or may be a prop value statement. We cannot use insymbol in 6271N/A // If a newline is found, then this is a type string 6271N/A // It is not. Just continue 0N/A// Init usefull pointers 0N/A // "LABEL" is an extension. It keeps references to forward tables 0N/A // Search for table references... 0N/A // This is the label, search for a table containing 0N/A // Available, keep type and table 0N/A// Try to infere if the file is a CGATS/IT8 file at all. Read first line 0N/A// that should be something like some printable characters plus a \n 6271N/A// returns 0 if this is not like a CGATS, or an integer otherwise. This integer is the number of words in first line? 6271N/A if (n <
10)
return 0;
// Too small 0N/A for (i =
1; i < n; i++) {
0N/A// ---------------------------------------------------------- Exported routines 0N/A // Pass#1 - count properties 0N/A // Pass#2 - Fill pointers 1002N/A // Pass#1 - count properties 0N/A // SynError(it8, "Couldn't find patch '%s'\n", cPatch); 1002N/A// Buffer should get MAXSTR at least 0N/A// This handles the "LABEL" extension. 0N/A// Label, nTable, Type