xref: /csrg-svn/lib/libc/locale/none.c (revision 61136)
160473Sbostic /*-
2*61136Sbostic  * Copyright (c) 1993
3*61136Sbostic  *	The Regents of the University of California.  All rights reserved.
460473Sbostic  *
560473Sbostic  * This code is derived from software contributed to Berkeley by
660473Sbostic  * Paul Borman at Krystal Technologies.
760473Sbostic  *
860473Sbostic  * %sccs.include.redist.c%
960473Sbostic  */
1060473Sbostic 
1160473Sbostic #if defined(LIBC_SCCS) && !defined(lint)
12*61136Sbostic static char sccsid[] = "@(#)none.c	8.1 (Berkeley) 06/04/93";
1360473Sbostic #endif /* LIBC_SCCS and not lint */
1460473Sbostic 
1560473Sbostic #include <stddef.h>
1660473Sbostic #include <stdio.h>
1760473Sbostic #include <rune.h>
1860473Sbostic #include <errno.h>
1960473Sbostic #include <stdlib.h>
2060473Sbostic 
2160473Sbostic rune_t	_none_sgetrune __P((const char *, size_t, char const **));
2260473Sbostic int	_none_sputrune __P((rune_t, char *, size_t, char **));
2360473Sbostic 
2460473Sbostic int
_none_init(rl)2560473Sbostic _none_init(rl)
2660473Sbostic 	_RuneLocale *rl;
2760473Sbostic {
2860473Sbostic 	rl->sgetrune = _none_sgetrune;
2960473Sbostic 	rl->sputrune = _none_sputrune;
3060473Sbostic 	_CurrentRuneLocale = rl;
3160473Sbostic 	__mb_cur_max = 1;
3260473Sbostic 	return(0);
3360473Sbostic }
3460473Sbostic 
3560473Sbostic rune_t
_none_sgetrune(string,n,result)3660473Sbostic _none_sgetrune(string, n, result)
3760473Sbostic 	const char *string;
3860473Sbostic 	size_t n;
3960473Sbostic 	char const **result;
4060473Sbostic {
4160473Sbostic 	int c;
4260473Sbostic 
4360473Sbostic 	if (n < 1) {
4460473Sbostic 		if (result)
4560473Sbostic 			*result = string;
4660473Sbostic 		return(_INVALID_RUNE);
4760473Sbostic 	}
4860473Sbostic 	if (result)
4960473Sbostic 		*result = string + 1;
5060473Sbostic 	return(*string & 0xff);
5160473Sbostic }
5260473Sbostic 
5360473Sbostic int
_none_sputrune(c,string,n,result)5460473Sbostic _none_sputrune(c, string, n, result)
5560473Sbostic 	rune_t c;
5660473Sbostic 	char *string, **result;
5760473Sbostic 	size_t n;
5860473Sbostic {
5960473Sbostic 	if (n >= 1) {
6060473Sbostic 		if (string)
6160473Sbostic 			*string = c;
6260473Sbostic 		if (result)
6360473Sbostic 			*result = string + 1;
6460473Sbostic 	} else if (result)
6560473Sbostic 		*result = (char *)0;
6660473Sbostic 	return(1);
6760473Sbostic }
68