#ifndef lint
#endif
/*
* Copyright (c) 2001,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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <idn/logmacro.h>
#include <idn/filemapper.h>
#define SUPPORT_VERSIONING
typedef struct ucsbuf {
unsigned long *ucs;
} ucsbuf_t;
struct idn__filemapper {
};
static void ucsbuf_init(ucsbuf_t *b);
static void ucsbuf_free(ucsbuf_t *b);
idn_result_t r;
WARNING(("idn__filemapper_create: cannot open %-.100s\n",
file));
return (idn_nofile);
}
return (idn_nomemory);
return (r);
}
if (r == idn_success) {
} else {
}
return (r);
}
void
TRACE(("idn__filemapper_destroy()\n"));
}
{
idn_result_t r = idn_success;
TRACE(("idn__filemapper_map(from=\"%s\")\n",
/* Initialize temporary buffer. */
ucsbuf_init(&ub);
while (*from != '\0') {
/* Try mapping. */
switch (r) {
case idn_buffer_overflow:
/* Temporary buffer too small. Enlarge and retry. */
break;
continue;
case idn_nomapping:
/* There is no mapping. */
r = idn_success;
/* fallthrough */
case idn_success:
r = idn_buffer_overflow;
goto ret;
}
break;
default:
goto ret;
}
from++;
}
ret:
ucsbuf_free(&ub);
if (r == idn_success) {
/* Terminate with NUL. */
if (tolen == 0)
return (idn_buffer_overflow);
*to = '\0';
}
return (r);
}
static void
b->size = UCSBUF_LOCAL_SIZE;
b->len = 0;
}
static idn_result_t
unsigned long *newbuf;
b->size *= 2;
return (idn_nomemory);
} else {
return (idn_nomemory);
}
return (idn_success);
}
static idn_result_t
idn_result_t r;
r = ucsbuf_grow(b);
if (r != idn_success)
return (r);
}
return (idn_success);
}
static void
}
static idn_result_t
idn_result_t r = idn_success;
int lineno = 0;
ucsbuf_init(&ub);
char *p = line;
lineno++;
while (isspace((unsigned char)*p))
p++;
if (*p == '\0' || *p == '#')
continue;
#ifdef SUPPORT_VERSIONING
/* Skip version tag. */
continue;
#endif
switch (r) {
case idn_success:
break;
case idn_buffer_overflow:
break;
goto again;
case idn_invalid_syntax:
WARNING(("syntax error in file \"%-.100s\" line %d: "
/* fall through */
default:
ucsbuf_free(&ub);
return (r);
}
}
ucsbuf_free(&ub);
return (r);
}
static idn_result_t
unsigned long v;
idn_result_t r = idn_success;
for (;;) {
return (idn_invalid_syntax);
if ((r = ucsbuf_append(b, v)) != idn_success)
return (r);
if (b->len == 1) {
if (*p != ';')
return (idn_invalid_syntax);
p++;
while (isspace((unsigned char)*p))
p++;
}
if (*p == ';' || *p == '#' || *p == '\0')
return (r);
}
return (r);
}
static char *
char *end;
/* Skip leading space */
while (isspace((unsigned char)*p))
p++;
/* Skip optional 'U+' */
p += 2;
if (end == p) {
INFO(("idn__filemapper_create: UCS code point expected\n"));
return (NULL);
}
p = end;
/* Skip trailing space */
while (isspace((unsigned char)*p))
p++;
return p;
}
}
void
}
}