2 * The copyright in this software is being made available under the 2-clauses
3 * BSD License, included below. This software may be subject to other third
4 * party and contributor rights, including patent rights, and no such rights
5 * are granted under this license.
7 * Copyright (c) 2005, Herve Drolon, FreeImage Team
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include "opj_includes.h"
34 /* ==========================================================
36 ==========================================================*/
38 #ifdef OPJ_CODE_NOT_USED
41 i2a(unsigned i, char *a, unsigned r)
46 *a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % r];
51 Transforms integer i into an ascii string and stores the result in a;
52 string is encoded in the base indicated by r.
53 @param i Number to be converted
54 @param a String result
55 @param r Base of value; must be in the range 2 - 36
59 _itoa(int i, char *a, int r)
61 r = ((r < 2) || (r > 36)) ? 10 : r;
64 *i2a(-i, a + 1, r) = 0;
73 /* ----------------------------------------------------------------------- */
75 opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo,
76 opj_event_mgr_t *event_mgr, void *context)
79 opj_event_mgr_t *previous = cinfo->event_mgr;
80 cinfo->event_mgr = event_mgr;
81 cinfo->client_data = context;
88 opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt,
91 #define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
92 opj_msg_callback msg_handler = NULL;
94 opj_event_mgr_t *event_mgr = cinfo->event_mgr;
95 if (event_mgr != NULL) {
98 msg_handler = event_mgr->error_handler;
101 msg_handler = event_mgr->warning_handler;
104 msg_handler = event_mgr->info_handler;
109 if (msg_handler == NULL) {
116 if ((fmt != NULL) && (event_mgr != NULL)) {
118 int str_length/*, i, j*/; /* UniPG */
119 char message[MSG_SIZE];
120 /* initialize the optional parameter list */
122 /* parse the format string and put the result in 'message' */
123 str_length = vsnprintf(message, MSG_SIZE, fmt, arg); /* UniPG */
124 /* deinitialize the optional parameter list */
127 /* output the message to the user program */
128 if (str_length > -1 && str_length < MSG_SIZE) {
129 msg_handler(message, cinfo->client_data);