< prev index next >

src/java.desktop/share/native/liblcms/cmsnamed.c

Print this page

 212 static
 213 cmsUInt16Number strTo16(const char str[3])
 214 {
 215     const cmsUInt8Number* ptr8;
 216     cmsUInt16Number n;
 217 
 218     // For non-existent strings
 219     if (str == NULL) return 0;
 220     ptr8 = (const cmsUInt8Number*)str;
 221     n = (cmsUInt16Number)(((cmsUInt16Number)ptr8[0] << 8) | ptr8[1]);
 222 
 223     return n;
 224 }
 225 
 226 static
 227 void strFrom16(char str[3], cmsUInt16Number n)
 228 {
 229     str[0] = (char)(n >> 8);
 230     str[1] = (char)n;
 231     str[2] = (char)0;




































 232 




























































































 233 }
 234 
 235 // Add an ASCII entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61)
 236 // In the case the user explicitly sets an empty string, we force a \0
 237 cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
 238 {
 239     cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString);
 240     wchar_t* WStr;
 241     cmsBool  rc;
 242     cmsUInt16Number Lang  = strTo16(LanguageCode);
 243     cmsUInt16Number Cntry = strTo16(CountryCode);
 244 
 245     if (mlu == NULL) return FALSE;
 246 
 247     // len == 0 would prevent operation, so we set a empty string pointing to zero
 248     if (len == 0)
 249     {
 250         len = 1;

 251     }
 252 
 253     WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, len,  sizeof(wchar_t));
 254     if (WStr == NULL) return FALSE;
 255 
 256     for (i=0; i < len; i++)
 257         WStr[i] = (wchar_t) ASCIIString[i];
 258 
 259     rc = AddMLUBlock(mlu, len  * sizeof(wchar_t), WStr, Lang, Cntry);
 260 
 261     _cmsFree(mlu ->ContextID, WStr);
 262     return rc;
 263 
 264 }
 265 

































 266 // We don't need any wcs support library
 267 static
 268 cmsUInt32Number mywcslen(const wchar_t *s)
 269 {
 270     const wchar_t *p;
 271 
 272     p = s;
 273     while (*p)
 274         p++;
 275 
 276     return (cmsUInt32Number)(p - s);
 277 }
 278 
 279 // Add a wide entry. Do not add any \0 terminator (ICC1v43_2010-12.pdf page 61)
 280 cmsBool  CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString)
 281 {
 282     cmsUInt16Number Lang  = strTo16(Language);
 283     cmsUInt16Number Cntry = strTo16(Country);
 284     cmsUInt32Number len;
 285 

 384                 if (len != NULL) *len = v ->Len;
 385 
 386                 return (wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v -> StrW);        // Found exact match
 387             }
 388         }
 389     }
 390 
 391     // No string found. Return First one
 392     if (Best == -1)
 393         Best = 0;
 394 
 395     v = mlu ->Entries + Best;
 396 
 397     if (UsedLanguageCode != NULL) *UsedLanguageCode = v ->Language;
 398     if (UsedCountryCode  != NULL) *UsedCountryCode = v ->Country;
 399 
 400     if (len != NULL) *len   = v ->Len;
 401 
 402     if (v->StrW + v->Len > mlu->PoolSize) return NULL;
 403 
 404     return(wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v ->StrW);
 405 }
 406 
 407 
 408 // Obtain an ASCII representation of the wide string. Setting buffer to NULL returns the len
 409 cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
 410                                        const char LanguageCode[3], const char CountryCode[3],
 411                                        char* Buffer, cmsUInt32Number BufferSize)
 412 {
 413     const wchar_t *Wide;
 414     cmsUInt32Number  StrLen = 0;
 415     cmsUInt32Number ASCIIlen, i;
 416 
 417     cmsUInt16Number Lang  = strTo16(LanguageCode);
 418     cmsUInt16Number Cntry = strTo16(CountryCode);
 419 
 420     // Sanitize
 421     if (mlu == NULL) return 0;
 422 
 423     // Get WideChar
 424     Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
 425     if (Wide == NULL) return 0;
 426 
 427     ASCIIlen = StrLen / sizeof(wchar_t);
 428 
 429     // Maybe we want only to know the len?
 430     if (Buffer == NULL) return ASCIIlen + 1; // Note the zero at the end
 431 
 432     // No buffer size means no data
 433     if (BufferSize <= 0) return 0;
 434 
 435     // Some clipping may be required
 436     if (BufferSize < ASCIIlen + 1)
 437         ASCIIlen = BufferSize - 1;
 438 
 439     // Precess each character
 440     for (i=0; i < ASCIIlen; i++) {
 441 
 442         if (Wide[i] == 0)
 443             Buffer[i] = 0;


 444         else
 445             Buffer[i] = (char) Wide[i];
 446     }
 447 
 448     // We put a termination "\0"
 449     Buffer[ASCIIlen] = 0;
 450     return ASCIIlen + 1;
 451 }
 452 








































 453 // Obtain a wide representation of the MLU, on depending on current locale settings
 454 cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
 455                                       const char LanguageCode[3], const char CountryCode[3],
 456                                       wchar_t* Buffer, cmsUInt32Number BufferSize)
 457 {
 458     const wchar_t *Wide;
 459     cmsUInt32Number  StrLen = 0;
 460 
 461     cmsUInt16Number Lang  = strTo16(LanguageCode);
 462     cmsUInt16Number Cntry = strTo16(CountryCode);
 463 
 464     // Sanitize
 465     if (mlu == NULL) return 0;
 466 
 467     Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
 468     if (Wide == NULL) return 0;
 469 
 470     // Maybe we want only to know the len?
 471     if (Buffer == NULL) return StrLen + sizeof(wchar_t);
 472 
 473   // No buffer size means no data
 474     if (BufferSize <= 0) return 0;
 475 
 476     // Some clipping may be required
 477     if (BufferSize < StrLen + sizeof(wchar_t))
 478         StrLen = BufferSize - + sizeof(wchar_t);
 479 
 480     memmove(Buffer, Wide, StrLen);
 481     Buffer[StrLen / sizeof(wchar_t)] = 0;
 482 
 483     return StrLen + sizeof(wchar_t);
 484 }
 485 
 486 
 487 // Get also the language and country
 488 CMSAPI cmsBool CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
 489                                               const char LanguageCode[3], const char CountryCode[3],
 490                                               char ObtainedLanguage[3], char ObtainedCountry[3])
 491 {
 492     const wchar_t *Wide;
 493 
 494     cmsUInt16Number Lang  = strTo16(LanguageCode);
 495     cmsUInt16Number Cntry = strTo16(CountryCode);
 496     cmsUInt16Number ObtLang, ObtCode;
 497 
 498     // Sanitize

 826     Seq -> n        = n;
 827 
 828     if (Seq -> seq == NULL) {
 829         _cmsFree(ContextID, Seq);
 830         return NULL;
 831     }
 832 
 833     for (i=0; i < n; i++) {
 834         Seq -> seq[i].Manufacturer = NULL;
 835         Seq -> seq[i].Model        = NULL;
 836         Seq -> seq[i].Description  = NULL;
 837     }
 838 
 839     return Seq;
 840 }
 841 
 842 void CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq)
 843 {
 844     cmsUInt32Number i;
 845 
 846     for (i=0; i < pseq ->n; i++) {
 847         if (pseq ->seq[i].Manufacturer != NULL) cmsMLUfree(pseq ->seq[i].Manufacturer);
 848         if (pseq ->seq[i].Model != NULL) cmsMLUfree(pseq ->seq[i].Model);
 849         if (pseq ->seq[i].Description != NULL) cmsMLUfree(pseq ->seq[i].Description);







 850     }
 851 
 852     if (pseq ->seq != NULL) _cmsFree(pseq ->ContextID, pseq ->seq);
 853     _cmsFree(pseq -> ContextID, pseq);
 854 }
 855 
 856 cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq)
 857 {
 858     cmsSEQ *NewSeq;
 859     cmsUInt32Number i;
 860 
 861     if (pseq == NULL)
 862         return NULL;
 863 
 864     NewSeq = (cmsSEQ*) _cmsMalloc(pseq -> ContextID, sizeof(cmsSEQ));
 865     if (NewSeq == NULL) return NULL;
 866 
 867 
 868     NewSeq -> seq      = (cmsPSEQDESC*) _cmsCalloc(pseq ->ContextID, pseq ->n, sizeof(cmsPSEQDESC));
 869     if (NewSeq ->seq == NULL) goto Error;
 870 
 871     NewSeq -> ContextID = pseq ->ContextID;
 872     NewSeq -> n        = pseq ->n;

 212 static
 213 cmsUInt16Number strTo16(const char str[3])
 214 {
 215     const cmsUInt8Number* ptr8;
 216     cmsUInt16Number n;
 217 
 218     // For non-existent strings
 219     if (str == NULL) return 0;
 220     ptr8 = (const cmsUInt8Number*)str;
 221     n = (cmsUInt16Number)(((cmsUInt16Number)ptr8[0] << 8) | ptr8[1]);
 222 
 223     return n;
 224 }
 225 
 226 static
 227 void strFrom16(char str[3], cmsUInt16Number n)
 228 {
 229     str[0] = (char)(n >> 8);
 230     str[1] = (char)n;
 231     str[2] = (char)0;
 232 }
 233 
 234 
 235 // Convert from UTF8 to wchar, returns len.
 236 static
 237 cmsUInt32Number decodeUTF8(wchar_t* out, const char* in)
 238 {
 239     cmsUInt32Number codepoint = 0;
 240     cmsUInt32Number size = 0;
 241 
 242     while (*in)
 243     {
 244         cmsUInt8Number ch = (cmsUInt8Number) *in;
 245 
 246         if (ch <= 0x7f)
 247         {
 248             codepoint = ch;
 249         }
 250         else if (ch <= 0xbf)
 251         {
 252             codepoint = (codepoint << 6) | (ch & 0x3f);
 253         }
 254         else if (ch <= 0xdf)
 255         {
 256             codepoint = ch & 0x1f;
 257         }
 258         else if (ch <= 0xef)
 259         {
 260             codepoint = ch & 0x0f;
 261         }
 262         else
 263         {
 264             codepoint = ch & 0x07;
 265         }
 266 
 267         in++;
 268 
 269         if (((*in & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
 270         {
 271             if (sizeof(wchar_t) > 2)
 272             {
 273                 if (out) *out++ = (wchar_t) codepoint;
 274                 size++;
 275             }
 276             else
 277                 if (codepoint > 0xffff)
 278                 {
 279                     if (out)
 280                     {
 281                         *out++ = (wchar_t)(0xd800 + (codepoint >> 10));
 282                         *out++ = (wchar_t)(0xdc00 + (codepoint & 0x03ff));
 283                         size += 2;
 284                     }
 285                 }
 286                 else
 287                     if (codepoint < 0xd800 || codepoint >= 0xe000)
 288                     {
 289                         if (out) *out++ = (wchar_t) codepoint;
 290                         size++;
 291                     }
 292         }
 293     }
 294 
 295     return size;
 296 }
 297 
 298 // Convert from wchar_t to UTF8
 299 static
 300 cmsUInt32Number encodeUTF8(char* out, const wchar_t* in, cmsUInt32Number max_wchars, cmsUInt32Number max_chars)
 301 {
 302     cmsUInt32Number codepoint = 0;
 303     cmsUInt32Number size = 0;
 304     cmsUInt32Number len_w = 0;
 305 
 306     while (*in && len_w < max_wchars)
 307     {
 308         if (*in >= 0xd800 && *in <= 0xdbff)
 309             codepoint = ((*in - 0xd800) << 10) + 0x10000;
 310         else
 311         {
 312             if (*in >= 0xdc00 && *in <= 0xdfff)
 313                 codepoint |= *in - 0xdc00;
 314             else
 315                 codepoint = *in;
 316 
 317             if (codepoint <= 0x7f)
 318             {
 319                 if (out && (size + 1 < max_chars)) *out++ = (char)codepoint;
 320                 size++;
 321             }
 322 
 323             else if (codepoint <= 0x7ff)
 324             {
 325                 if (out && (max_chars > 0) && (size + 2 < max_chars))
 326                 {
 327                     *out++ = (char)(cmsUInt32Number)(0xc0 | ((codepoint >> 6) & 0x1f));
 328                     *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
 329                 }
 330                 size += 2;
 331             }
 332             else if (codepoint <= 0xffff)
 333             {
 334                 if (out && (max_chars > 0) && (size + 3 < max_chars))
 335                 {
 336                     *out++ = (char)(cmsUInt32Number)(0xe0 | ((codepoint >> 12) & 0x0f));
 337                     *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 6) & 0x3f));
 338                     *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
 339                 }
 340                 size += 3;
 341             }
 342             else
 343             {
 344                 if (out && (max_chars > 0) && (size + 4 < max_chars))
 345                 {
 346                     *out++ = (char)(cmsUInt32Number)(0xf0 | ((codepoint >> 18) & 0x07));
 347                     *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 12) & 0x3f));
 348                     *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 6) & 0x3f));
 349                     *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
 350                 }
 351                 size += 4;
 352             }
 353 
 354             codepoint = 0;
 355         }
 356 
 357         in++; len_w++;
 358     }
 359 
 360     return size;
 361 }
 362 
 363 // Add an ASCII entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61)
 364 // In the case the user explicitly sets an empty string, we force a \0
 365 cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
 366 {
 367     cmsUInt32Number i, len = (cmsUInt32Number)strlen(ASCIIString);
 368     wchar_t* WStr;
 369     cmsBool  rc;
 370     cmsUInt16Number Lang = strTo16(LanguageCode);
 371     cmsUInt16Number Cntry = strTo16(CountryCode);
 372 
 373     if (mlu == NULL) return FALSE;
 374 
 375     // len == 0 would prevent operation, so we set a empty string pointing to zero
 376     if (len == 0)
 377     {
 378         wchar_t empty = 0;
 379         return AddMLUBlock(mlu, sizeof(wchar_t), &empty, Lang, Cntry);
 380     }
 381 
 382     WStr = (wchar_t*)_cmsCalloc(mlu->ContextID, len, sizeof(wchar_t));
 383     if (WStr == NULL) return FALSE;
 384 
 385     for (i = 0; i < len; i++)
 386         WStr[i] = (wchar_t)ASCIIString[i];
 387 
 388     rc = AddMLUBlock(mlu, len * sizeof(wchar_t), WStr, Lang, Cntry);
 389 
 390     _cmsFree(mlu->ContextID, WStr);
 391     return rc;
 392 
 393 }
 394 
 395 // Add an UTF8 entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61)
 396 // In the case the user explicitly sets an empty string, we force a \0
 397 cmsBool CMSEXPORT cmsMLUsetUTF8(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* UTF8String)
 398 {
 399     cmsUInt32Number UTF8len;
 400     wchar_t* WStr;
 401     cmsBool  rc;
 402     cmsUInt16Number Lang  = strTo16(LanguageCode);
 403     cmsUInt16Number Cntry = strTo16(CountryCode);
 404 
 405     if (mlu == NULL) return FALSE;
 406 
 407     if (*UTF8String == '\0')
 408     {
 409         wchar_t empty = 0;
 410         return AddMLUBlock(mlu, sizeof(wchar_t), &empty, Lang, Cntry);
 411     }
 412 
 413     // Len excluding terminator 0
 414     UTF8len = decodeUTF8(NULL, UTF8String);
 415 
 416     // Get space for dest
 417     WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, UTF8len,  sizeof(wchar_t));
 418     if (WStr == NULL) return FALSE;
 419 
 420     decodeUTF8(WStr, UTF8String);
 421 
 422     rc = AddMLUBlock(mlu, UTF8len  * sizeof(wchar_t), WStr, Lang, Cntry);
 423 
 424     _cmsFree(mlu ->ContextID, WStr);
 425     return rc;
 426 }
 427 
 428 // We don't need any wcs support library
 429 static
 430 cmsUInt32Number mywcslen(const wchar_t *s)
 431 {
 432     const wchar_t *p;
 433 
 434     p = s;
 435     while (*p)
 436         p++;
 437 
 438     return (cmsUInt32Number)(p - s);
 439 }
 440 
 441 // Add a wide entry. Do not add any \0 terminator (ICC1v43_2010-12.pdf page 61)
 442 cmsBool  CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString)
 443 {
 444     cmsUInt16Number Lang  = strTo16(Language);
 445     cmsUInt16Number Cntry = strTo16(Country);
 446     cmsUInt32Number len;
 447 

 546                 if (len != NULL) *len = v ->Len;
 547 
 548                 return (wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v -> StrW);        // Found exact match
 549             }
 550         }
 551     }
 552 
 553     // No string found. Return First one
 554     if (Best == -1)
 555         Best = 0;
 556 
 557     v = mlu ->Entries + Best;
 558 
 559     if (UsedLanguageCode != NULL) *UsedLanguageCode = v ->Language;
 560     if (UsedCountryCode  != NULL) *UsedCountryCode = v ->Country;
 561 
 562     if (len != NULL) *len   = v ->Len;
 563 
 564     if (v->StrW + v->Len > mlu->PoolSize) return NULL;
 565 
 566     return (wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v ->StrW);
 567 }
 568 
 569 
 570 // Obtain an ASCII representation of the wide string. Setting buffer to NULL returns the len
 571 cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
 572                                        const char LanguageCode[3], const char CountryCode[3],
 573                                        char* Buffer, cmsUInt32Number BufferSize)
 574 {
 575     const wchar_t *Wide;
 576     cmsUInt32Number  StrLen = 0;
 577     cmsUInt32Number ASCIIlen, i;
 578 
 579     cmsUInt16Number Lang  = strTo16(LanguageCode);
 580     cmsUInt16Number Cntry = strTo16(CountryCode);
 581 
 582     // Sanitize
 583     if (mlu == NULL) return 0;
 584 
 585     // Get WideChar
 586     Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
 587     if (Wide == NULL) return 0;
 588 
 589     ASCIIlen = StrLen / sizeof(wchar_t);
 590 
 591     // Maybe we want only to know the len?
 592     if (Buffer == NULL) return ASCIIlen + 1; // Note the zero at the end
 593 
 594     // No buffer size means no data
 595     if (BufferSize <= 0) return 0;
 596 
 597     // Some clipping may be required
 598     if (BufferSize < ASCIIlen + 1)
 599         ASCIIlen = BufferSize - 1;
 600 
 601     // Precess each character
 602     for (i=0; i < ASCIIlen; i++) {
 603 
 604         wchar_t wc = Wide[i];
 605 
 606         if (wc < 0xff)
 607             Buffer[i] = (char)wc;
 608         else
 609             Buffer[i] = '?';
 610     }
 611 
 612     // We put a termination "\0"
 613     Buffer[ASCIIlen] = 0;
 614     return ASCIIlen + 1;
 615 }
 616 
 617 
 618 // Obtain a UTF8 representation of the wide string. Setting buffer to NULL returns the len
 619 cmsUInt32Number CMSEXPORT cmsMLUgetUTF8(const cmsMLU* mlu,
 620                                        const char LanguageCode[3], const char CountryCode[3],
 621                                        char* Buffer, cmsUInt32Number BufferSize)
 622 {
 623     const wchar_t *Wide;
 624     cmsUInt32Number  StrLen = 0;
 625     cmsUInt32Number UTF8len;
 626 
 627     cmsUInt16Number Lang  = strTo16(LanguageCode);
 628     cmsUInt16Number Cntry = strTo16(CountryCode);
 629 
 630     // Sanitize
 631     if (mlu == NULL) return 0;
 632 
 633     // Get WideChar
 634     Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
 635     if (Wide == NULL) return 0;
 636 
 637     UTF8len = encodeUTF8(NULL, Wide, StrLen / sizeof(wchar_t), BufferSize);
 638 
 639     // Maybe we want only to know the len?
 640     if (Buffer == NULL) return UTF8len + 1; // Note the zero at the end
 641 
 642     // No buffer size means no data
 643     if (BufferSize <= 0) return 0;
 644 
 645     // Some clipping may be required
 646     if (BufferSize < UTF8len + 1)
 647         UTF8len = BufferSize - 1;
 648 
 649     // Process it
 650     encodeUTF8(Buffer, Wide, StrLen / sizeof(wchar_t), BufferSize);
 651 
 652     // We put a termination "\0"
 653     Buffer[UTF8len] = 0;
 654     return UTF8len + 1;
 655 }
 656 
 657 // Obtain a wide representation of the MLU, on depending on current locale settings
 658 cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
 659                                       const char LanguageCode[3], const char CountryCode[3],
 660                                       wchar_t* Buffer, cmsUInt32Number BufferSize)
 661 {
 662     const wchar_t *Wide;
 663     cmsUInt32Number  StrLen = 0;
 664 
 665     cmsUInt16Number Lang  = strTo16(LanguageCode);
 666     cmsUInt16Number Cntry = strTo16(CountryCode);
 667 
 668     // Sanitize
 669     if (mlu == NULL) return 0;
 670 
 671     Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
 672     if (Wide == NULL) return 0;
 673 
 674     // Maybe we want only to know the len?
 675     if (Buffer == NULL) return StrLen + sizeof(wchar_t);
 676 
 677     // Invalid buffer size means no data
 678     if (BufferSize < sizeof(wchar_t)) return 0;
 679 
 680     // Some clipping may be required
 681     if (BufferSize < StrLen + sizeof(wchar_t))
 682         StrLen = BufferSize - sizeof(wchar_t);
 683 
 684     memmove(Buffer, Wide, StrLen);
 685     Buffer[StrLen / sizeof(wchar_t)] = 0;
 686 
 687     return StrLen + sizeof(wchar_t);
 688 }
 689 
 690 
 691 // Get also the language and country
 692 CMSAPI cmsBool CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
 693                                               const char LanguageCode[3], const char CountryCode[3],
 694                                               char ObtainedLanguage[3], char ObtainedCountry[3])
 695 {
 696     const wchar_t *Wide;
 697 
 698     cmsUInt16Number Lang  = strTo16(LanguageCode);
 699     cmsUInt16Number Cntry = strTo16(CountryCode);
 700     cmsUInt16Number ObtLang, ObtCode;
 701 
 702     // Sanitize

1030     Seq -> n        = n;
1031 
1032     if (Seq -> seq == NULL) {
1033         _cmsFree(ContextID, Seq);
1034         return NULL;
1035     }
1036 
1037     for (i=0; i < n; i++) {
1038         Seq -> seq[i].Manufacturer = NULL;
1039         Seq -> seq[i].Model        = NULL;
1040         Seq -> seq[i].Description  = NULL;
1041     }
1042 
1043     return Seq;
1044 }
1045 
1046 void CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq)
1047 {
1048     cmsUInt32Number i;
1049 
1050     if (pseq == NULL)
1051         return;
1052 
1053     if (pseq ->seq != NULL) {
1054         for (i=0; i < pseq ->n; i++) {
1055             if (pseq ->seq[i].Manufacturer != NULL) cmsMLUfree(pseq ->seq[i].Manufacturer);
1056             if (pseq ->seq[i].Model != NULL) cmsMLUfree(pseq ->seq[i].Model);
1057             if (pseq ->seq[i].Description != NULL) cmsMLUfree(pseq ->seq[i].Description);
1058         }
1059 
1060         _cmsFree(pseq ->ContextID, pseq ->seq);
1061     }
1062 

1063     _cmsFree(pseq -> ContextID, pseq);
1064 }
1065 
1066 cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq)
1067 {
1068     cmsSEQ *NewSeq;
1069     cmsUInt32Number i;
1070 
1071     if (pseq == NULL)
1072         return NULL;
1073 
1074     NewSeq = (cmsSEQ*) _cmsMalloc(pseq -> ContextID, sizeof(cmsSEQ));
1075     if (NewSeq == NULL) return NULL;
1076 
1077 
1078     NewSeq -> seq      = (cmsPSEQDESC*) _cmsCalloc(pseq ->ContextID, pseq ->n, sizeof(cmsPSEQDESC));
1079     if (NewSeq ->seq == NULL) goto Error;
1080 
1081     NewSeq -> ContextID = pseq ->ContextID;
1082     NewSeq -> n        = pseq ->n;
< prev index next >