chromium/third_party/pdfium/third_party/lcms/src/cmscgats.c

//---------------------------------------------------------------------------------
//
//  Little Color Management System
//  Copyright (c) 1998-2023 Marti Maria Saguer
//
// 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.
//
//---------------------------------------------------------------------------------
//

#include "lcms2_internal.h"


// IT8.7 / CGATS.17-200x handling -----------------------------------------------------------------------------


#define MAXID
#define MAXSTR
#define MAXTABLES
#define MAXINCLUDE

#define DEFAULT_DBL_FORMAT

#ifdef CMS_IS_WINDOWS_
//sunliang.liu modified 2010426 for wince error
# ifndef _WIN32_WCE
#   include <io.h>
# endif
#define DIR_CHAR
#else
#define DIR_CHAR
#endif


// Symbols
SYMBOL;


// How to write the value
WRITEMODE;

// Linked list of variable names
KEYVALUE;


// Linked list of memory chunks (Memory sink)
OWNEDMEM;

// Suballocator
SUBALLOCATOR;

// Table. Each individual table can hold properties and rows & cols
TABLE;

// File stream being parsed
FILECTX;

//Very simple string 
string;


// This struct hold all information about an open IT8 handler.
cmsIT8;


// The stream for save operations
SAVESTREAM;


// ------------------------------------------------------ cmsIT8 parsing routines


// A keyword
KEYWORD;

// The keyword->symbol translation table. Sorting is required.
static const KEYWORD TabKeys[] =;

#define NUMKEYS

// Predefined properties

// A property
PROPERTY;

static PROPERTY PredefinedProperties[] =;

#define NUMPREDEFINEDPROPS


// Predefined sample types on dataset
static const char* PredefinedSampleID[] =;   // The average of the standard deviations of L*, a* and b*. It is
                          // used to derive an estimate of the chi-squared parameter which is
                          // recommended as the predictor of the variability of dE

#define NUMPREDEFINEDSAMPLEID

//Forward declaration of some internal functions
static void* AllocChunk(cmsIT8* it8, cmsUInt32Number size);

static
string* StringAlloc(cmsIT8* it8, int max)
{}

static
void StringClear(string* s)
{}

static
void StringAppend(string* s, char c)
{}

static
char* StringPtr(string* s)
{}

static
void StringCat(string* s, const char* c)
{}


// Checks whatever c is a separator
static
cmsBool isseparator(int c)
{}

// Checks whatever c is a valid identifier char
static
cmsBool ismiddle(int c)
{}

// Checks whatsever c is a valid identifier middle char.
static
cmsBool isidchar(int c)
{}

// Checks whatsever c is a valid identifier first char.
static
cmsBool isfirstidchar(int c)
{}

// Guess whether the supplied path looks like an absolute path
static
cmsBool isabsolutepath(const char *path)
{}


// Makes a file path based on a given reference path
// NOTE: this function doesn't check if the path exists or even if it's legal
static
cmsBool BuildAbsolutePath(const char *relPath, const char *basePath, char *buffer, cmsUInt32Number MaxLen)
{}


// Make sure no exploit is being even tried
static
const char* NoMeta(const char* str)
{}

// Syntax error
static
cmsBool SynError(cmsIT8* it8, const char *Txt, ...)
{}

// Check if current symbol is same as specified. issue an error else.
static
cmsBool Check(cmsIT8* it8, SYMBOL sy, const char* Err)
{}

// Read Next character from stream
static
void NextCh(cmsIT8* it8)
{}


// Try to see if current identifier is a keyword, if so return the referred symbol
static
SYMBOL BinSrchKey(const char *id)
{}


// 10 ^n
static
cmsFloat64Number xpow10(int n)
{}


//  Reads a Real number, tries to follow from integer number
static
void ReadReal(cmsIT8* it8, cmsInt32Number inum)
{}

// Parses a float number
// This can not call directly atof because it uses locale dependent
// parsing, while CCMX files always use . as decimal separator
static
cmsFloat64Number ParseFloatNumber(const char *Buffer)
{}


// Reads a string, special case to avoid infinite resursion on .include
static
void InStringSymbol(cmsIT8* it8)
{}

// Reads next symbol
static
void InSymbol(cmsIT8* it8)
{}

// Checks end of line separator
static
cmsBool CheckEOLN(cmsIT8* it8)
{}

// Skip a symbol

static
void Skip(cmsIT8* it8, SYMBOL sy)
{}


// Skip multiple EOLN
static
void SkipEOLN(cmsIT8* it8)
{}


// Returns a string holding current value
static
cmsBool GetVal(cmsIT8* it8, char* Buffer, cmsUInt32Number max, const char* ErrorTitle)
{}

// ---------------------------------------------------------- Table

static
TABLE* GetTable(cmsIT8* it8)
{}

// ---------------------------------------------------------- Memory management


// Frees an allocator and owned memory
void CMSEXPORT cmsIT8Free(cmsHANDLE hIT8)
{}


// Allocates a chunk of data, keep linked list
static
void* AllocBigBlock(cmsIT8* it8, cmsUInt32Number size)
{}


// Suballocator.
static
void* AllocChunk(cmsIT8* it8, cmsUInt32Number size)
{}


// Allocates a string
static
char *AllocString(cmsIT8* it8, const char* str)
{}

// Searches through linked list

static
cmsBool IsAvailableOnList(KEYVALUE* p, const char* Key, const char* Subkey, KEYVALUE** LastPtr)
{}



// Add a property into a linked list
static
KEYVALUE* AddToList(cmsIT8* it8, KEYVALUE** Head, const char *Key, const char *Subkey, const char* xValue, WRITEMODE WriteAs)
{}

static
KEYVALUE* AddAvailableProperty(cmsIT8* it8, const char* Key, WRITEMODE as)
{}


static
KEYVALUE* AddAvailableSampleID(cmsIT8* it8, const char* Key)
{}


static
void AllocTable(cmsIT8* it8)
{}


cmsInt32Number CMSEXPORT cmsIT8SetTable(cmsHANDLE  IT8, cmsUInt32Number nTable)
{}



// Init an empty container
cmsHANDLE  CMSEXPORT cmsIT8Alloc(cmsContext ContextID)
{}


const char* CMSEXPORT cmsIT8GetSheetType(cmsHANDLE hIT8)
{}

cmsBool CMSEXPORT cmsIT8SetSheetType(cmsHANDLE hIT8, const char* Type)
{}

cmsBool CMSEXPORT cmsIT8SetComment(cmsHANDLE hIT8, const char* Val)
{}

// Sets a property
cmsBool CMSEXPORT cmsIT8SetPropertyStr(cmsHANDLE hIT8, const char* Key, const char *Val)
{}

cmsBool CMSEXPORT cmsIT8SetPropertyDbl(cmsHANDLE hIT8, const char* cProp, cmsFloat64Number Val)
{}

cmsBool CMSEXPORT cmsIT8SetPropertyHex(cmsHANDLE hIT8, const char* cProp, cmsUInt32Number Val)
{}

cmsBool CMSEXPORT cmsIT8SetPropertyUncooked(cmsHANDLE hIT8, const char* Key, const char* Buffer)
{}

cmsBool CMSEXPORT cmsIT8SetPropertyMulti(cmsHANDLE hIT8, const char* Key, const char* SubKey, const char *Buffer)
{}

// Gets a property
const char* CMSEXPORT cmsIT8GetProperty(cmsHANDLE hIT8, const char* Key)
{}


cmsFloat64Number CMSEXPORT cmsIT8GetPropertyDbl(cmsHANDLE hIT8, const char* cProp)
{}

const char* CMSEXPORT cmsIT8GetPropertyMulti(cmsHANDLE hIT8, const char* Key, const char *SubKey)
{}

// ----------------------------------------------------------------- Datasets

// A safe atoi that returns 0 when NULL input is given
static
cmsInt32Number satoi(const char* b)
{}


static
cmsBool AllocateDataFormat(cmsIT8* it8)
{}

static
const char *GetDataFormat(cmsIT8* it8, int n)
{}

static
cmsBool SetDataFormat(cmsIT8* it8, int n, const char *label)
{}


cmsBool CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE  h, int n, const char *Sample)
{}

// Convert to binary
static
const char* satob(const char* v)
{}


static
cmsBool AllocateDataSet(cmsIT8* it8)
{}

static
char* GetData(cmsIT8* it8, int nSet, int nField)
{}

static
cmsBool SetData(cmsIT8* it8, int nSet, int nField, const char *Val)
{}


// --------------------------------------------------------------- File I/O


// Writes a string to file
static
void WriteStr(SAVESTREAM* f, const char *str)
{}


// Write formatted

static
void Writef(SAVESTREAM* f, const char* frm, ...)
{}

// Writes full header
static
void WriteHeader(cmsIT8* it8, SAVESTREAM* fp)
{}


// Writes the data format
static
void WriteDataFormat(SAVESTREAM* fp, cmsIT8* it8)
{}


// Writes data array
static
void WriteData(SAVESTREAM* fp, cmsIT8* it8)
{}



// Saves whole file
cmsBool CMSEXPORT cmsIT8SaveToFile(cmsHANDLE hIT8, const char* cFileName)
{}


// Saves to memory
cmsBool CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number* BytesNeeded)
{}


// -------------------------------------------------------------- Higher level parsing

static
cmsBool DataFormatSection(cmsIT8* it8)
{}



static
cmsBool DataSection (cmsIT8* it8)
{}




static
cmsBool HeaderSection(cmsIT8* it8)
{}


static
void ReadType(cmsIT8* it8, char* SheetTypePtr)
{}


static
cmsBool ParseIT8(cmsIT8* it8, cmsBool nosheet)
{}



// Init useful pointers

static
void CookPointers(cmsIT8* it8)
{}

// Try to infere if the file is a CGATS/IT8 file at all. Read first line
// that should be something like some printable characters plus a \n
// returns 0 if this is not like a CGATS, or an integer otherwise. This integer is the number of words in first line?
static
int IsMyBlock(const cmsUInt8Number* Buffer, cmsUInt32Number n)
{}


static
cmsBool IsMyFile(const char* FileName)
{}

// ---------------------------------------------------------- Exported routines


cmsHANDLE  CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, const void *Ptr, cmsUInt32Number len)
{}


cmsHANDLE  CMSEXPORT cmsIT8LoadFromFile(cmsContext ContextID, const char* cFileName)
{}

int CMSEXPORT cmsIT8EnumDataFormat(cmsHANDLE hIT8, char ***SampleNames)
{}


cmsUInt32Number CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyNames)
{}

cmsUInt32Number CMSEXPORT cmsIT8EnumPropertyMulti(cmsHANDLE hIT8, const char* cProp, const char ***SubpropertyNames)
{}

static
int LocatePatch(cmsIT8* it8, const char* cPatch)
{}


static
int LocateEmptyPatch(cmsIT8* it8)
{}

static
int LocateSample(cmsIT8* it8, const char* cSample)
{}


int CMSEXPORT cmsIT8FindDataFormat(cmsHANDLE hIT8, const char* cSample)
{}



const char* CMSEXPORT cmsIT8GetDataRowCol(cmsHANDLE hIT8, int row, int col)
{}


cmsFloat64Number CMSEXPORT cmsIT8GetDataRowColDbl(cmsHANDLE hIT8, int row, int col)
{}


cmsBool CMSEXPORT cmsIT8SetDataRowCol(cmsHANDLE hIT8, int row, int col, const char* Val)
{}


cmsBool CMSEXPORT cmsIT8SetDataRowColDbl(cmsHANDLE hIT8, int row, int col, cmsFloat64Number Val)
{}



const char* CMSEXPORT cmsIT8GetData(cmsHANDLE hIT8, const char* cPatch, const char* cSample)
{}


cmsFloat64Number CMSEXPORT cmsIT8GetDataDbl(cmsHANDLE  it8, const char* cPatch, const char* cSample)
{}



cmsBool CMSEXPORT cmsIT8SetData(cmsHANDLE hIT8, const char* cPatch, const char* cSample, const char *Val)
{}


cmsBool CMSEXPORT cmsIT8SetDataDbl(cmsHANDLE hIT8, const char* cPatch,
                                   const char* cSample,
                                   cmsFloat64Number Val)
{}

// Buffer should get MAXSTR at least

const char* CMSEXPORT cmsIT8GetPatchName(cmsHANDLE hIT8, int nPatch, char* buffer)
{}

int CMSEXPORT cmsIT8GetPatchByName(cmsHANDLE hIT8, const char *cPatch)
{}

cmsUInt32Number CMSEXPORT cmsIT8TableCount(cmsHANDLE hIT8)
{}

// This handles the "LABEL" extension.
// Label, nTable, Type

int CMSEXPORT cmsIT8SetTableByLabel(cmsHANDLE hIT8, const char* cSet, const char* cField, const char* ExpectedType)
{}


cmsBool CMSEXPORT cmsIT8SetIndexColumn(cmsHANDLE hIT8, const char* cSample)
{}


void CMSEXPORT cmsIT8DefineDblFormat(cmsHANDLE hIT8, const char* Formatter)
{}