jdk/src/share/native/sun/java2d/cmm/lcms/cmserr.c
author prr
Tue, 24 Mar 2009 09:14:02 -0700
changeset 2394 404cbe399601
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6821031: Upgrade OpenJDK's LittleCMS version to 1.18 Reviewed-by: bae, igor
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
// This file is available under and governed by the GNU General Public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
// License version 2 only, as published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
// However, the following notice accompanied the original version of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
// file:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
//  Little cms
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
    32
//  Copyright (C) 1998-2007 Marti Maria
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
// Permission is hereby granted, free of charge, to any person obtaining
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
// a copy of this software and associated documentation files (the "Software"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
// to deal in the Software without restriction, including without limitation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
// and/or sell copies of the Software, and to permit persons to whom the Software
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
// is furnished to do so, subject to the following conditions:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
// The above copyright notice and this permission notice shall be included in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
// all copies or substantial portions of the Software.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#include "lcms.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
// As a rule, only the functions visible from API can signal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
// errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
void cdecl cmsSignalError(int ErrorCode, const char *ErrorText, ...);
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
    60
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
int  LCMSEXPORT cmsErrorAction(int lAbort);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
void LCMSEXPORT cmsSetErrorHandler(cmsErrorHandlerFunction Fn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
// ******************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
static int nDoAbort = LCMS_ERROR_ABORT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
static cmsErrorHandlerFunction UserErrorHandler = (cmsErrorHandlerFunction) NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
int LCMSEXPORT cmsErrorAction(int nAction)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
       int nOld = nDoAbort;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
       nDoAbort = nAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
       return nOld;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
void LCMSEXPORT cmsSetErrorHandler(cmsErrorHandlerFunction Fn)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
       UserErrorHandler = Fn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
// Default error handler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
void cmsSignalError(int ErrorCode, const char *ErrorText, ...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
       va_list args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
       if (nDoAbort == LCMS_ERROR_IGNORE) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        va_start(args, ErrorText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        if (UserErrorHandler != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            char Buffer[1024];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   100
            vsnprintf(Buffer, 1023, ErrorText, args);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            va_end(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            if (UserErrorHandler(ErrorCode, Buffer)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#if defined( __CONSOLE__ ) || defined( NON_WINDOWS )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
              fprintf(stderr, "lcms: Error #%d; ", ErrorCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
              vfprintf(stderr, ErrorText, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
              fprintf(stderr, "\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
              va_end(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
              if (nDoAbort == LCMS_ERROR_ABORT) exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
              {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
              char Buffer1[1024];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
              char Buffer2[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   122
              snprintf(Buffer1,  767, "Error #%x; ", ErrorCode);
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   123
              vsnprintf(Buffer2, 255, ErrorText, args);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
              strcat(Buffer1, Buffer2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
              MessageBox(NULL, Buffer1, "Little cms",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                                          MB_OK|MB_ICONSTOP|MB_TASKMODAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
              va_end(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
              if (nDoAbort == LCMS_ERROR_ABORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#ifdef __BORLANDC__
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                    _cexit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                  FatalAppExit(0, "lcms is terminating application");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
}