< prev index next >

src/share/native/sun/java2d/cmm/lcms/cmsnamed.c

Print this page

        

*** 28,38 **** // 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, --- 28,38 ---- // file: // //--------------------------------------------------------------------------------- // // Little Color Management System ! // Copyright (c) 1998-2016 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,
*** 119,129 **** // Grows a entry table for a MLU. Each time this function is called, table size is multiplied times two. static cmsBool GrowMLUtable(cmsMLU* mlu) { ! int AllocatedEntries; _cmsMLUentry *NewPtr; // Sanity check if (mlu == NULL) return FALSE; --- 119,129 ---- // Grows a entry table for a MLU. Each time this function is called, table size is multiplied times two. static cmsBool GrowMLUtable(cmsMLU* mlu) { ! cmsUInt32Number AllocatedEntries; _cmsMLUentry *NewPtr; // Sanity check if (mlu == NULL) return FALSE;
*** 145,155 **** // Search for a specific entry in the structure. Language and Country are used. static int SearchMLUEntry(cmsMLU* mlu, cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode) { ! int i; // Sanity check if (mlu == NULL) return -1; // Iterate whole table --- 145,155 ---- // Search for a specific entry in the structure. Language and Country are used. static int SearchMLUEntry(cmsMLU* mlu, cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode) { ! cmsUInt32Number i; // Sanity check if (mlu == NULL) return -1; // Iterate whole table
*** 205,223 **** mlu ->UsedEntries++; return TRUE; } ! // Add an ASCII entry. cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString) { ! cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString)+1; wchar_t* WStr; cmsBool rc; ! cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode); ! cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode); if (mlu == NULL) return FALSE; WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, len, sizeof(wchar_t)); if (WStr == NULL) return FALSE; --- 205,250 ---- mlu ->UsedEntries++; return TRUE; } + // Convert from a 3-char code to a cmsUInt16Number. It is done inthis way because some + // compilers don't properly align beginning of strings ! static ! cmsUInt16Number strTo16(const char str[3]) ! { ! cmsUInt16Number n = ((cmsUInt16Number) str[0] << 8) | str[1]; ! ! return n; // Always big endian in this case ! } ! ! static ! void strFrom16(char str[3], cmsUInt16Number n) ! { ! // Assiming this would be aligned ! union { ! ! cmsUInt16Number n; ! char str[2]; ! ! } c; ! ! c.n = n; // Always big endian in this case ! ! str[0] = c.str[0]; str[1] = c.str[1]; str[2] = 0; ! ! } ! ! // Add an ASCII entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61) cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString) { ! cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString); wchar_t* WStr; cmsBool rc; ! cmsUInt16Number Lang = strTo16(LanguageCode); ! cmsUInt16Number Cntry = strTo16(CountryCode); if (mlu == NULL) return FALSE; WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, len, sizeof(wchar_t)); if (WStr == NULL) return FALSE;
*** 243,264 **** 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) { ! cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) Language); ! cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) Country); cmsUInt32Number len; if (mlu == NULL) return FALSE; if (WideString == NULL) return FALSE; ! len = (cmsUInt32Number) (mywcslen(WideString) + 1) * sizeof(wchar_t); return AddMLUBlock(mlu, len, WideString, Lang, Cntry); } // Duplicating a MLU is as easy as copying all members cmsMLU* CMSEXPORT cmsMLUdup(const cmsMLU* mlu) --- 270,290 ---- p++; return (cmsUInt32Number)(p - s); } ! // Add a wide entry. Do not add any \0 terminator (ICC1v43_2010-12.pdf page 61) cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString) { ! cmsUInt16Number Lang = strTo16(Language); ! cmsUInt16Number Cntry = strTo16(Country); cmsUInt32Number len; if (mlu == NULL) return FALSE; if (WideString == NULL) return FALSE; ! len = (cmsUInt32Number) (mywcslen(WideString)) * sizeof(wchar_t); return AddMLUBlock(mlu, len, WideString, Lang, Cntry); } // Duplicating a MLU is as easy as copying all members cmsMLU* CMSEXPORT cmsMLUdup(const cmsMLU* mlu)
*** 325,336 **** const wchar_t* _cmsMLUgetWide(const cmsMLU* mlu, cmsUInt32Number *len, cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode, cmsUInt16Number* UsedLanguageCode, cmsUInt16Number* UsedCountryCode) { ! int i; ! int Best = -1; _cmsMLUentry* v; if (mlu == NULL) return NULL; if (mlu -> AllocatedEntries <= 0) return NULL; --- 351,362 ---- const wchar_t* _cmsMLUgetWide(const cmsMLU* mlu, cmsUInt32Number *len, cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode, cmsUInt16Number* UsedLanguageCode, cmsUInt16Number* UsedCountryCode) { ! cmsUInt32Number i; ! cmsInt32Number Best = -1; _cmsMLUentry* v; if (mlu == NULL) return NULL; if (mlu -> AllocatedEntries <= 0) return NULL;
*** 377,388 **** { const wchar_t *Wide; cmsUInt32Number StrLen = 0; cmsUInt32Number ASCIIlen, i; ! cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode); ! cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode); // Sanitize if (mlu == NULL) return 0; // Get WideChar --- 403,414 ---- { const wchar_t *Wide; cmsUInt32Number StrLen = 0; cmsUInt32Number ASCIIlen, i; ! cmsUInt16Number Lang = strTo16(LanguageCode); ! cmsUInt16Number Cntry = strTo16(CountryCode); // Sanitize if (mlu == NULL) return 0; // Get WideChar
*** 421,432 **** wchar_t* Buffer, cmsUInt32Number BufferSize) { const wchar_t *Wide; cmsUInt32Number StrLen = 0; ! cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode); ! cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode); // Sanitize if (mlu == NULL) return 0; Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL); --- 447,458 ---- wchar_t* Buffer, cmsUInt32Number BufferSize) { const wchar_t *Wide; cmsUInt32Number StrLen = 0; ! cmsUInt16Number Lang = strTo16(LanguageCode); ! cmsUInt16Number Cntry = strTo16(CountryCode); // Sanitize if (mlu == NULL) return 0; Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
*** 454,478 **** const char LanguageCode[3], const char CountryCode[3], char ObtainedLanguage[3], char ObtainedCountry[3]) { const wchar_t *Wide; ! cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode); ! cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode); cmsUInt16Number ObtLang, ObtCode; // Sanitize if (mlu == NULL) return FALSE; Wide = _cmsMLUgetWide(mlu, NULL, Lang, Cntry, &ObtLang, &ObtCode); if (Wide == NULL) return FALSE; // Get used language and code ! *(cmsUInt16Number *)ObtainedLanguage = _cmsAdjustEndianess16(ObtLang); ! *(cmsUInt16Number *)ObtainedCountry = _cmsAdjustEndianess16(ObtCode); - ObtainedLanguage[2] = ObtainedCountry[2] = 0; return TRUE; } --- 480,503 ---- const char LanguageCode[3], const char CountryCode[3], char ObtainedLanguage[3], char ObtainedCountry[3]) { const wchar_t *Wide; ! cmsUInt16Number Lang = strTo16(LanguageCode); ! cmsUInt16Number Cntry = strTo16(CountryCode); cmsUInt16Number ObtLang, ObtCode; // Sanitize if (mlu == NULL) return FALSE; Wide = _cmsMLUgetWide(mlu, NULL, Lang, Cntry, &ObtLang, &ObtCode); if (Wide == NULL) return FALSE; // Get used language and code ! strFrom16(ObtainedLanguage, ObtLang); ! strFrom16(ObtainedCountry, ObtCode); return TRUE; }
*** 491,506 **** { _cmsMLUentry *entry; if (mlu == NULL) return FALSE; ! if (idx >= (cmsUInt32Number) mlu->UsedEntries) return FALSE; entry = &mlu->Entries[idx]; ! *(cmsUInt16Number *)LanguageCode = _cmsAdjustEndianess16(entry->Language); ! *(cmsUInt16Number *)CountryCode = _cmsAdjustEndianess16(entry->Country); return TRUE; } --- 516,531 ---- { _cmsMLUentry *entry; if (mlu == NULL) return FALSE; ! if (idx >= mlu->UsedEntries) return FALSE; entry = &mlu->Entries[idx]; ! strFrom16(LanguageCode, entry->Language); ! strFrom16(CountryCode, entry->Country); return TRUE; }
< prev index next >