#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 <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <idn/logmacro.h>
#include <idn/mapselector.h>
struct idn_mapselector {
int reference_count;
};
/*
* Maximum length of a top level domain name. (e.g. `com', `jp', ...)
*/
static void string_ascii_tolower(char *string);
const unsigned long *
idn_mapselector_getnotld(void) {
return (notld);
}
const unsigned long *
idn_mapselector_getdefaulttld(void) {
return (defaulttld);
}
idn_mapselector_initialize(void) {
idn_result_t r;
TRACE(("idn_mapselector_initialize()\n"));
r = idn_mapper_initialize();
return (r);
}
idn_result_t r;
TRACE(("idn_mapselector_create()\n"));
r = idn_nomemory;
goto ret;
}
if (r != idn_success)
goto ret;
r = idn_success;
ret:
if (r != idn_success) {
}
return (r);
}
void
TRACE(("idn_mapselector_destroy()\n"));
ctx->reference_count--;
if (ctx->reference_count <= 0) {
TRACE(("idn_mapselector_destroy(): "
"the object is destroyed\n"));
} else {
TRACE(("idn_mapselector_destroy(): "
"update reference count (%d->%d)\n",
}
}
void
TRACE(("idn_mapselector_incrref()\n"));
TRACE(("idn_mapselector_incrref: update reference count (%d->%d)\n",
ctx->reference_count++;
}
idn_result_t r;
if (tld[0] == '.')
tld++;
ERROR(("idn_mapselector_add: "
"invalid TLD \"%-.100s\"\n", tld));
r = idn_invalid_name;
goto ret;
}
}
ERROR(("idn_mapselector_add: "
"too long TLD \"%-.100s\"\n", tld));
r = idn_invalid_name;
goto ret;
}
!= idn_success) {
r = idn_mapper_create(&mapper);
if (r != idn_success)
goto ret;
if (r != idn_success)
goto ret;
}
ret:
return (r);
}
const char **scheme_names, int nschemes) {
idn_result_t r;
int i;
TRACE(("idn_mapselector_addall(tld=%s, nschemes=%d)\n",
for (i = 0; i < nschemes; i++) {
if (r != idn_success)
goto ret;
scheme_names++;
}
r = idn_success;
ret:
return (r);
}
idn_result_t r;
if (tld[0] == '.')
tld++;
return (NULL);
}
return (NULL);
if (r != idn_success)
return (NULL);
return (mapper);
}
idn_result_t r;
TRACE(("idn_mapselector_map(from=\"%s\", tld=\"%s\", tolen=%d)\n",
(int)tolen));
if (tld[0] == '.')
tld++;
r = idn_invalid_name;
goto ret;
}
}
r = idn_invalid_name;
goto ret;
}
/*
* Get mapper for the TLD.
*/
!= idn_success) {
}
/*
* Map.
* If default mapper has not been registered, copy the string.
*/
TRACE(("idn_mapselector_map(): no mapper\n"));
r = idn_buffer_overflow;
goto ret;
}
} else {
if (r != idn_success)
goto ret;
}
r = idn_success;
ret:
if (r == idn_success) {
TRACE(("idn_mapselector_map(): succcess (to=\"%s\")\n",
} else {
}
return (r);
}
idn_result_t r;
TRACE(("idn_mapselector_map2(from=\"%s\", tld=\"%s\")\n",
if (r == idn_buffer_overflow) {
r = idn_invalid_name;
goto ret;
} else if (r != idn_success) {
goto ret;
}
ret:
if (r == idn_success) {
TRACE(("idn_mapselector_map2(): success (to=\"%s\")\n",
} else {
}
return (r);
}
static void
unsigned char *p;
for (p = (unsigned char *) string; *p != '\0'; p++) {
if ('A' <= *p && *p <= 'Z')
*p = *p - 'A' + 'a';
}
}