17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57257d1braf * Common Development and Distribution License (the "License").
67257d1braf * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217257d1braf
227c478bdstevel@tonic-gate/*
237257d1braf * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bdstevel@tonic-gate * Use is subject to license terms.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
274297a3bGarrett D'Amore/*
284297a3bGarrett D'Amore * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
294297a3bGarrett D'Amore * Use is subject to license terms.
304297a3bGarrett D'Amore */
317c478bdstevel@tonic-gate
327257d1braf#include "lint.h"
337c478bdstevel@tonic-gate#include "mtlib.h"
347c478bdstevel@tonic-gate#include "mbstatet.h"
357c478bdstevel@tonic-gate#include "file64.h"
367c478bdstevel@tonic-gate#include <sys/types.h>
377c478bdstevel@tonic-gate#include <stdio.h>
387c478bdstevel@tonic-gate#include <wchar.h>
397c478bdstevel@tonic-gate#include <thread.h>
407c478bdstevel@tonic-gate#include <synch.h>
417c478bdstevel@tonic-gate#include <stdlib.h>
427c478bdstevel@tonic-gate#include <string.h>
437c478bdstevel@tonic-gate#include "libc.h"
447c478bdstevel@tonic-gate#include "stdiom.h"
457c478bdstevel@tonic-gate#include "mse.h"
467c478bdstevel@tonic-gate
477c478bdstevel@tonic-gate/*
487c478bdstevel@tonic-gate * DESCRIPTION:
497c478bdstevel@tonic-gate * This function/macro gets the orientation bound to the specified iop.
507c478bdstevel@tonic-gate *
517c478bdstevel@tonic-gate * RETURNS:
527c478bdstevel@tonic-gate * _WC_MODE	if iop has been bound to Wide orientation
537c478bdstevel@tonic-gate * _BYTE_MODE	if iop has been bound to Byte orientation
547c478bdstevel@tonic-gate * _NO_MODE	if iop has been bound to neither Wide nor Byte
557c478bdstevel@tonic-gate */
567c478bdstevel@tonic-gate_IOP_orientation_t
577c478bdstevel@tonic-gate_getorientation(FILE *iop)
587c478bdstevel@tonic-gate{
597c478bdstevel@tonic-gate	if (GET_BYTE_MODE(iop))
607c478bdstevel@tonic-gate		return (_BYTE_MODE);
617c478bdstevel@tonic-gate	else if (GET_WC_MODE(iop))
627c478bdstevel@tonic-gate		return (_WC_MODE);
637c478bdstevel@tonic-gate
647c478bdstevel@tonic-gate	return (_NO_MODE);
657c478bdstevel@tonic-gate}
667c478bdstevel@tonic-gate
677c478bdstevel@tonic-gate/*
687c478bdstevel@tonic-gate * DESCRIPTION:
697c478bdstevel@tonic-gate * This function/macro sets the orientation to the specified iop.
707c478bdstevel@tonic-gate *
717c478bdstevel@tonic-gate * INPUT:
727c478bdstevel@tonic-gate * flag may take one of the following:
737c478bdstevel@tonic-gate *	_WC_MODE	Wide orientation
747c478bdstevel@tonic-gate *	_BYTE_MODE	Byte orientation
757c478bdstevel@tonic-gate *	_NO_MODE	Unoriented
767c478bdstevel@tonic-gate */
777c478bdstevel@tonic-gatevoid
787c478bdstevel@tonic-gate_setorientation(FILE *iop, _IOP_orientation_t mode)
797c478bdstevel@tonic-gate{
807c478bdstevel@tonic-gate	switch (mode) {
817c478bdstevel@tonic-gate	case _NO_MODE:
827c478bdstevel@tonic-gate		CLEAR_BYTE_MODE(iop);
837c478bdstevel@tonic-gate		CLEAR_WC_MODE(iop);
847c478bdstevel@tonic-gate		break;
857c478bdstevel@tonic-gate	case _BYTE_MODE:
867c478bdstevel@tonic-gate		CLEAR_WC_MODE(iop);
877c478bdstevel@tonic-gate		SET_BYTE_MODE(iop);
887c478bdstevel@tonic-gate		break;
897c478bdstevel@tonic-gate	case _WC_MODE:
907c478bdstevel@tonic-gate		CLEAR_BYTE_MODE(iop);
917c478bdstevel@tonic-gate		SET_WC_MODE(iop);
927c478bdstevel@tonic-gate		break;
937c478bdstevel@tonic-gate	}
947c478bdstevel@tonic-gate}
95