none.c revision 105233
120253Sjoerg/*- 220302Sjoerg * Copyright (c) 1993 320302Sjoerg * The Regents of the University of California. All rights reserved. 420253Sjoerg * 520253Sjoerg * This code is derived from software contributed to Berkeley by 620253Sjoerg * Paul Borman at Krystal Technologies. 720253Sjoerg * 820253Sjoerg * Redistribution and use in source and binary forms, with or without 920302Sjoerg * modification, are permitted provided that the following conditions 1020253Sjoerg * are met: 1120253Sjoerg * 1. Redistributions of source code must retain the above copyright 1220253Sjoerg * notice, this list of conditions and the following disclaimer. 1320253Sjoerg * 2. Redistributions in binary form must reproduce the above copyright 1420302Sjoerg * notice, this list of conditions and the following disclaimer in the 1520253Sjoerg * documentation and/or other materials provided with the distribution. 1620253Sjoerg * 3. All advertising materials mentioning features or use of this software 1720302Sjoerg * must display the following acknowledgement: 1820253Sjoerg * This product includes software developed by the University of 1920253Sjoerg * California, Berkeley and its contributors. 2020253Sjoerg * 4. Neither the name of the University nor the names of its contributors 2120253Sjoerg * may be used to endorse or promote products derived from this software 2220253Sjoerg * without specific prior written permission. 2320253Sjoerg * 2420253Sjoerg * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2520253Sjoerg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2620253Sjoerg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2730259Scharnier * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2830259Scharnier * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2950479Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3030259Scharnier * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3130259Scharnier * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3230259Scharnier * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3330259Scharnier * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3430259Scharnier * SUCH DAMAGE. 3520253Sjoerg */ 3620253Sjoerg 3720253Sjoerg#if defined(LIBC_SCCS) && !defined(lint) 3830259Scharnierstatic char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93"; 3920253Sjoerg#endif /* LIBC_SCCS and not lint */ 4020253Sjoerg#include <sys/cdefs.h> 4130259Scharnier__FBSDID("$FreeBSD: head/lib/libc/locale/none.c 105233 2002-10-16 11:37:38Z tjr $"); 4220253Sjoerg 4320253Sjoerg#include <limits.h> 44219408Sjkim#include <stddef.h> 4520253Sjoerg#include <stdio.h> 4620253Sjoerg#include <rune.h> 4720253Sjoerg#include <stdlib.h> 48285430Sbapt 49285430Sbaptrune_t _none_sgetrune(const char *, size_t, char const **); 5020253Sjoergint _none_sputrune(rune_t, char *, size_t, char **); 51285430Sbapt 52285430Sbaptint 53285430Sbapt_none_init(rl) 54285430Sbapt _RuneLocale *rl; 55285430Sbapt{ 56285430Sbapt rl->sgetrune = _none_sgetrune; 5720253Sjoerg rl->sputrune = _none_sputrune; 58285430Sbapt _CurrentRuneLocale = rl; 59285430Sbapt __mb_cur_max = 1; 60285430Sbapt return(0); 61285430Sbapt} 6230259Scharnier 63285430Sbaptrune_t 64285430Sbapt_none_sgetrune(string, n, result) 65285430Sbapt const char *string; 66285430Sbapt size_t n; 67285430Sbapt char const **result; 6820253Sjoerg{ 69285430Sbapt if (n < 1) { 70285430Sbapt if (result) 7120253Sjoerg *result = string; 72285430Sbapt return(_INVALID_RUNE); 73285430Sbapt } 74285430Sbapt if (result) 75285430Sbapt *result = string + 1; 76285430Sbapt return(*string & 0xff); 77285430Sbapt} 7820253Sjoerg 79285430Sbaptint 80285430Sbapt_none_sputrune(c, string, n, result) 81285430Sbapt rune_t c; 8220253Sjoerg char *string, **result; 83285430Sbapt size_t n; 84285430Sbapt{ 85285430Sbapt if (n >= 1) { 8620253Sjoerg if (string) { 87285430Sbapt if (c < 0 || c > UCHAR_MAX) { 88285430Sbapt if (result) 8920253Sjoerg *result = NULL; 90285430Sbapt return (0); 91285430Sbapt } 92285430Sbapt *string = c; 93285430Sbapt } 9420253Sjoerg if (result) 95285430Sbapt *result = string + 1; 96285430Sbapt } else if (result) 97285430Sbapt *result = (char *)0; 98285430Sbapt return(1); 99285430Sbapt} 100285430Sbapt