#ifndef lint
#endif
/*
* Copyright (c) 2000,2002 Japan Network Information Center.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set forth bellow.
*
* LICENSE TERMS AND CONDITIONS
*
* The following License Terms and Conditions apply, unless a different
* license is obtained from Japan Network Information Center ("JPNIC"),
* a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
* Chiyoda-ku, Tokyo 101-0047, Japan.
*
* 1. Use, Modification and Redistribution (including distribution of any
* under this License Terms and Conditions.
*
* 2. Redistribution of source code must retain the copyright notices as they
* appear in each source code file, this License Terms and Conditions.
*
* 3. Redistribution in binary form must reproduce the Copyright Notice,
* materials provided with the distribution. For the purposes of binary
* distribution the "Copyright Notice" refers to the following language:
* "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
*
* 4. The name of JPNIC may not be used to endorse or promote products
* derived from this Software without specific prior written approval of
* JPNIC.
*
* 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <idn/logmacro.h>
#include <idn/normalizer.h>
#include <idn/unormalize.h>
typedef struct {
char *name;
struct idn_normalizer {
int nschemes;
int scheme_size;
int reference_count;
};
if (r != idn_success) \
return (r); \
}
static idn_result_t register_standard_normalizers(void);
unsigned long *to,
static struct standard_normalizer {
char *name;
} standard_normalizer[] = {
{ "unicode-form-kc", normalizer_formkc },
{ "unicode-form-kc/3.2.0", normalizer_formkc_v320 },
{ "RFC3491", normalizer_formkc_v320 },
};
idn_normalizer_initialize(void) {
idn_result_t r;
TRACE(("idn_normalizer_initialize()\n"));
if (scheme_hash != NULL) {
r = idn_success; /* already initialized */
goto ret;
}
goto ret;
scheme_hash = hash;
/* Register standard normalizers */
ret:
return (r);
}
idn_result_t r;
TRACE(("idn_normalizer_create()\n"));
r = idn_nomemory;
goto ret;
}
r = idn_success;
ret:
return (r);
}
void
TRACE(("idn_normalizer_destroy()\n"));
ctx->reference_count--;
if (ctx->reference_count <= 0) {
TRACE(("idn_normalizer_destroy(): the object is destroyed\n"));
} else {
TRACE(("idn_normalizer_destroy(): "
"update reference count (%d->%d)\n",
}
}
void
TRACE(("idn_normalizer_incrref()\n"));
TRACE(("idn_normalizer_incrref: update reference count (%d->%d)\n",
ctx->reference_count++;
}
idn_result_t r;
void *v;
ERROR(("idn_normalizer_add(): invalid scheme \"%-.30s\"\n",
scheme_name));
r = idn_invalid_name;
goto ret;
}
scheme = v;
goto ret;
}
r = idn_success;
ret:
return (r);
}
int nschemes) {
idn_result_t r;
int i;
for (i = 0; i < nschemes; i++) {
if (r != idn_success)
goto ret;
scheme_names++;
}
r = idn_success;
ret:
return (r);
}
idn_result_t r;
int idx;
int i;
TRACE(("idn_normalizer_normalize(from=\"%s\", tolen=%d)\n",
r = idn_buffer_overflow;
goto ret;
}
r = idn_success;
goto ret;
}
/*
* Normalize.
*/
i = 0;
TRACE(("idn_normalizer_normalize(): normalize %s\n",
/*
* Choose destination area to restore the result of a mapping.
*/
} else {
idx = 1;
else
idx = 0;
void *newbuf;
sizeof(long) * dstlen);
r = idn_nomemory;
goto ret;
}
}
}
/*
* Perform i-th normalization scheme.
* If buffer size is not enough, we double it and try again.
*/
dstlen *= 2;
continue;
}
if (r != idn_success)
goto ret;
i++;
}
r = idn_success;
ret:
if (r == idn_success) {
TRACE(("idn_normalizer_normalize(): success (to=\"%s\")\n",
} else {
TRACE(("idn_normalizer_normalize(): %s\n",
idn_result_tostring(r)));
}
return (r);
}
idn_result_t r;
r = idn_nomemory;
goto ret;
}
if (r != idn_success)
goto ret;
r = idn_success;
ret:
return (r);
}
static idn_result_t
} else {
sizeof(normalize_scheme_t) * new_size);
}
if (new_schemes == NULL)
return (idn_nomemory);
return (idn_success);
}
static idn_result_t
register_standard_normalizers(void) {
int i;
int failed = 0;
idn_result_t r;
standard_normalizer[i].proc);
if (r != idn_success) {
WARNING(("idn_normalizer_initialize(): "
"failed to register \"%-.100s\"\n",
standard_normalizer[i].name));
failed++;
}
}
if (failed > 0)
return (idn_failure);
else
return (idn_success);
}
/*
* Unicode Normalization Forms -- latest version
*/
static idn_result_t
}
/*
* Unicode Normalization Forms -- version 3.2.0
*/
static idn_result_t
}