/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// This file is available under and governed by the GNU General Public
// License version 2 only, as published by the Free Software Foundation.
// However, the following notice accompanied the original version of this
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
// Copyright (c) 1998-2012 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,
// 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"
// Multilocalized unicode objects. That is an attempt to encapsulate i18n.
// Allocates an empty multi localizad unicode object
{
// nItems should be positive if given
// Create the container
// Create entry array
return NULL;
}
// Ok, keep indexes up to date
mlu ->UsedEntries = 0;
return mlu;
}
// Grows a mempool table for a MLU. Each time this function is called, mempool size is multiplied times two.
static
{
void *NewPtr;
// Sanity check
size = 256;
else
// Check for overflow
// Reallocate the pool
return TRUE;
}
// Grows a entry table for a MLU. Each time this function is called, table size is multiplied times two.
static
{
int AllocatedEntries;
// Sanity check
// Check for overflow
// Reallocate the memory
NewPtr = (_cmsMLUentry*)_cmsRealloc(mlu ->ContextID, mlu ->Entries, AllocatedEntries*sizeof(_cmsMLUentry));
return TRUE;
}
// Search for a specific entry in the structure. Language and Country are used.
static
{
int i;
// Sanity check
// Iterate whole table
for (i=0; i < mlu ->UsedEntries; i++) {
}
// Not found
return -1;
}
// Add a block of characters to the intended MLU. Language and country are specified.
static
{
// Sanity check
// Is there any room available?
}
// Only one ASCII string
// Check for size
}
// Set the entry
mlu ->UsedEntries++;
return TRUE;
}
// Add an ASCII entry.
cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
{
for (i=0; i < len; i++)
return rc;
}
// We don't need any wcs support library
static
{
const wchar_t *p;
p = s;
while (*p)
p++;
return (cmsUInt32Number)(p - s);
}
// Add a wide entry
cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString)
{
}
// Duplicating a MLU is as easy as copying all members
{
// Duplicating a NULL obtains a NULL
// Should never happen
goto Error;
// Sanitize...
// The MLU may be empty
}
else {
// It is not empty
}
return NewMlu;
return NULL;
}
// Free any used memory
{
if (mlu) {
}
}
// The algorithm first searches for an exact match of country and language, if not found it uses
// the Language. If none is found, first entry is used instead.
static
{
int i;
_cmsMLUentry* v;
for (i=0; i < mlu ->UsedEntries; i++) {
if (v -> Language == LanguageCode) {
if (v -> Country == CountryCode) {
}
}
}
// No string found. Return First one
if (Best == -1)
Best = 0;
}
// Obtain an ASCII representation of the wide string. Setting buffer to NULL returns the len
{
// Sanitize
// Get WideChar
// Maybe we want only to know the len?
// No buffer size means no data
if (BufferSize <= 0) return 0;
// Some clipping may be required
// Precess each character
for (i=0; i < ASCIIlen; i++) {
if (Wide[i] == 0)
Buffer[i] = 0;
else
}
// We put a termination "\0"
return ASCIIlen + 1;
}
// Obtain a wide representation of the MLU, on depending on current locale settings
{
// Sanitize
// Maybe we want only to know the len?
// No buffer size means no data
if (BufferSize <= 0) return 0;
// Some clipping may be required
}
// Get also the language and country
{
// Sanitize
// Get used language and code
return TRUE;
}
// Named color lists --------------------------------------------------------------------------------------------
// Grow the list to keep at least NumElements
static
{
if (v ->Allocated == 0)
else
// Keep a maximum color lists can grow, 100K entries seems reasonable
return FALSE;
return TRUE;
}
// Allocate a list for n elements
cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUInt32Number n, cmsUInt32Number ColorantCount, const char* Prefix, const char* Suffix)
{
v ->nColors = 0;
while (v -> Allocated < n)
v -> ColorantCount = ColorantCount;
return v;
}
// Free a list
{
}
{
NewNC= cmsAllocNamedColorList(v ->ContextID, v -> nColors, v ->ColorantCount, v ->Prefix, v ->Suffix);
// For really large tables we need this
return NewNC;
}
// Append a color to a list. List pointer may change if reallocated
const char* Name,
{
}
for (i=0; i < NamedColorList ->ColorantCount; i++)
NamedColorList ->List[NamedColorList ->nColors].DeviceColorant[i] = Colorant == NULL? 0 : Colorant[i];
for (i=0; i < 3; i++)
}
else
NamedColorList ->nColors++;
return TRUE;
}
// Returns number of elements
{
if (NamedColorList == NULL) return 0;
return NamedColorList ->nColors;
}
// Info aboout a given color
cmsBool CMSEXPORT cmsNamedColorInfo(const cmsNAMEDCOLORLIST* NamedColorList, cmsUInt32Number nColor,
char* Name,
char* Prefix,
char* Suffix,
{
if (PCS)
if (Colorant)
return TRUE;
}
// Search for a given color name (no prefix or suffix)
cmsInt32Number CMSEXPORT cmsNamedColorIndex(const cmsNAMEDCOLORLIST* NamedColorList, const char* Name)
{
int i, n;
for (i=0; i < n; i++) {
return i;
}
return -1;
}
// MPE support -----------------------------------------------------------------------------------------------------------------
static
{
}
static
{
return cmsDupNamedColorList(List);
}
static
{
cmsSignalError(NamedColorList ->ContextID, cmsERROR_RANGE, "Color %d out of range; ignored", index);
}
else {
// Named color always uses Lab
}
}
static
{
cmsSignalError(NamedColorList ->ContextID, cmsERROR_RANGE, "Color %d out of range; ignored", index);
}
else {
for (j=0; j < NamedColorList ->ColorantCount; j++)
}
}
// Named color lookup element
{
}
// Retrieve the named color list from a transform. Should be first element in the LUT
{
}
// Profile sequence description routines -------------------------------------------------------------------------------------
{
if (n == 0) return NULL;
// In a absolutely arbitrary way, I hereby decide to allow a maxim of 255 profiles linked
// in a devicelink. It makes not sense anyway and may be used for exploits, so let's close the door!
if (n > 255) return NULL;
Seq -> n = n;
return NULL;
}
for (i=0; i < n; i++) {
}
return Seq;
}
{
for (i=0; i < pseq ->n; i++) {
}
}
{
return NULL;
for (i=0; i < pseq->n; i++) {
}
return NewSeq;
return NULL;
}
// Dictionaries --------------------------------------------------------------------------------------------------------
// Dictionaries are just very simple linked lists
typedef struct _cmsDICT_struct {
} _cmsDICT;
// Allocate an empty dictionary
{
}
// Dispose resources
{
// Walk the list freeing all nodes
// Don't fall in the habitual trap...
}
}
// Duplicate a wide char string
static
{
}
// Add a new entry to the linked list
cmsBool CMSEXPORT cmsDictAddEntry(cmsHANDLE hDict, const wchar_t* Name, const wchar_t* Value, const cmsMLU *DisplayName, const cmsMLU *DisplayValue)
{
return TRUE;
}
// Duplicates an existing dictionary
{
// Walk the list freeing all nodes
if (!cmsDictAddEntry(hNew, entry ->Name, entry ->Value, entry ->DisplayName, entry ->DisplayValue)) {
return NULL;
}
}
return hNew;
}
// Get a pointer to the linked list
{
}
// Helper For external languages
{
return e ->Next;
}