1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 /* 27 * Copyright 2010 Nexenta Systems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31 #ifndef _MSE_H 32 #define _MSE_H 33 34 #include "lint.h" 35 #include <stdio.h> 36 #include <wchar.h> 37 #include <string.h> 38 #include "stdiom.h" 39 40 typedef enum { 41 _NO_MODE, /* not bound */ 42 _BYTE_MODE, /* Byte orientation */ 43 _WC_MODE /* Wide orientation */ 44 } _IOP_orientation_t; 45 46 /* 47 * DESCRIPTION: 48 * This function gets the pointer to the mbstate_t structure associated 49 * with the specified iop. 50 * 51 * RETURNS: 52 * If the associated mbstate_t found, the pointer to the mbstate_t is 53 * returned. Otherwise, (mbstate_t *)NULL is returned. 54 */ 55 #ifdef _LP64 56 #define _getmbstate(iop) (&(iop)->_state) 57 #else 58 extern mbstate_t *_getmbstate(FILE *); 59 #endif 60 61 /* 62 * DESCRIPTION: 63 * This function/macro gets the orientation bound to the specified iop. 64 * 65 * RETURNS: 66 * _WC_MODE if iop has been bound to Wide orientation 67 * _BYTE_MODE if iop has been bound to Byte orientation 68 * _NO_MODE if iop has been bound to neither Wide nor Byte 69 */ 70 extern _IOP_orientation_t _getorientation(FILE *); 71 72 /* 73 * DESCRIPTION: 74 * This function/macro sets the orientation to the specified iop. 75 * 76 * INPUT: 77 * flag may take one of the following: 78 * _WC_MODE Wide orientation 79 * _BYTE_MODE Byte orientation 80 * _NO_MODE Unoriented 81 */ 82 extern void _setorientation(FILE *, _IOP_orientation_t); 83 84 /* 85 * From page 32 of XSH5 86 * Once a wide-character I/O function has been applied 87 * to a stream without orientation, the stream becomes 88 * wide-orientated. Similarly, once a byte I/O function 89 * has been applied to a stream without orientation, 90 * the stream becomes byte-orientated. Only a call to 91 * the freopen() function or the fwide() function can 92 * otherwise alter the orientation of a stream. 93 */ 94 95 #define _SET_ORIENTATION_BYTE(iop) \ 96 { \ 97 if (GET_NO_MODE(iop)) \ 98 _setorientation(iop, _BYTE_MODE); \ 99 } 100 101 #endif /* _MSE_H */ 102