1*0Sstevel@tonic-gate 2*0Sstevel@tonic-gate// Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3*0Sstevel@tonic-gate// Use is subject to license terms. 4*0Sstevel@tonic-gate// 5*0Sstevel@tonic-gate// CDDL HEADER START 6*0Sstevel@tonic-gate// 7*0Sstevel@tonic-gate// The contents of this file are subject to the terms of the 8*0Sstevel@tonic-gate// Common Development and Distribution License, Version 1.0 only 9*0Sstevel@tonic-gate// (the "License"). You may not use this file except in compliance 10*0Sstevel@tonic-gate// with the License. 11*0Sstevel@tonic-gate// 12*0Sstevel@tonic-gate// You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 13*0Sstevel@tonic-gate// or http://www.opensolaris.org/os/licensing. 14*0Sstevel@tonic-gate// See the License for the specific language governing permissions 15*0Sstevel@tonic-gate// and limitations under the License. 16*0Sstevel@tonic-gate// 17*0Sstevel@tonic-gate// When distributing Covered Code, include this CDDL HEADER in each 18*0Sstevel@tonic-gate// file and include the License file at usr/src/OPENSOLARIS.LICENSE. 19*0Sstevel@tonic-gate// If applicable, add the following below this CDDL HEADER, with the 20*0Sstevel@tonic-gate// fields enclosed by brackets "[]" replaced with your own identifying 21*0Sstevel@tonic-gate// information: Portions Copyright [yyyy] [name of copyright owner] 22*0Sstevel@tonic-gate// 23*0Sstevel@tonic-gate// CDDL HEADER END 24*0Sstevel@tonic-gate// 25*0Sstevel@tonic-gate// ident "%Z%%M% %I% %E% SMI" 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate// 28*0Sstevel@tonic-gate// eucJP to SJIS 29*0Sstevel@tonic-gate// 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate#include <sys/errno.h> 33*0Sstevel@tonic-gate#define SS2 0x008e 34*0Sstevel@tonic-gate#define SS3 0x008f 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gateeucJP%SJIS { 37*0Sstevel@tonic-gate operation init { 38*0Sstevel@tonic-gate cs = 0; 39*0Sstevel@tonic-gate offset = 0; 40*0Sstevel@tonic-gate }; 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate direction { 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate condition { 45*0Sstevel@tonic-gate cs == 2; 46*0Sstevel@tonic-gate } operation { 47*0Sstevel@tonic-gate output = input[0]; 48*0Sstevel@tonic-gate cs = 0; 49*0Sstevel@tonic-gate discard; 50*0Sstevel@tonic-gate }; 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate condition { 53*0Sstevel@tonic-gate cs == 1; 54*0Sstevel@tonic-gate } operation { 55*0Sstevel@tonic-gate var_input = input[0] & 0x7f; 56*0Sstevel@tonic-gate var_input = var_input + offset; 57*0Sstevel@tonic-gate if (var_input >= 0x7f) { 58*0Sstevel@tonic-gate var_input = var_input + 0x01; 59*0Sstevel@tonic-gate } 60*0Sstevel@tonic-gate output = var_input; 61*0Sstevel@tonic-gate cs = 0; 62*0Sstevel@tonic-gate discard; 63*0Sstevel@tonic-gate }; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate condition { 66*0Sstevel@tonic-gate between 0x00 ... 0x7f ; 67*0Sstevel@tonic-gate } operation { 68*0Sstevel@tonic-gate if ( outputsize < 1 ) { 69*0Sstevel@tonic-gate error E2BIG; 70*0Sstevel@tonic-gate } 71*0Sstevel@tonic-gate output = input[0]; 72*0Sstevel@tonic-gate discard; 73*0Sstevel@tonic-gate }; 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate condition { 76*0Sstevel@tonic-gate between SS2 ... SS2 ; 77*0Sstevel@tonic-gate } operation { 78*0Sstevel@tonic-gate // Note this, in the .c file check is made 79*0Sstevel@tonic-gate // against ileft > 0 , but it's since the 80*0Sstevel@tonic-gate // ileft is already decremented. 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate if ( inputsize > 1 ) { 83*0Sstevel@tonic-gate if ( ( input[1] >= 0xa1 ) && ( input[1] <= 0xfe )) { 84*0Sstevel@tonic-gate if (outputsize < 1 ) { 85*0Sstevel@tonic-gate error E2BIG; 86*0Sstevel@tonic-gate } 87*0Sstevel@tonic-gate cs = 2; 88*0Sstevel@tonic-gate } else { 89*0Sstevel@tonic-gate error EILSEQ; 90*0Sstevel@tonic-gate } 91*0Sstevel@tonic-gate } else { 92*0Sstevel@tonic-gate error EINVAL; 93*0Sstevel@tonic-gate } 94*0Sstevel@tonic-gate }; 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate condition { 97*0Sstevel@tonic-gate between 0xa1 ... 0xfe; 98*0Sstevel@tonic-gate } operation { 99*0Sstevel@tonic-gate if ( inputsize > 1 ) { 100*0Sstevel@tonic-gate if ( ( input[1] >= 0xa1 ) && ( input[1] <= 0xfe)) { 101*0Sstevel@tonic-gate if ( outputsize < 2 ) { 102*0Sstevel@tonic-gate error E2BIG; 103*0Sstevel@tonic-gate } 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate cs = 1; 106*0Sstevel@tonic-gate var_input = input[0] & 0x7f; 107*0Sstevel@tonic-gate if ( var_input & 0x01) { 108*0Sstevel@tonic-gate offset = 0x1f; 109*0Sstevel@tonic-gate } else { 110*0Sstevel@tonic-gate offset = 0x7d; 111*0Sstevel@tonic-gate } 112*0Sstevel@tonic-gate var_input = ((var_input - 0x21 ) >> 1) + 0x81; 113*0Sstevel@tonic-gate if ( var_input > 0x9f ) { 114*0Sstevel@tonic-gate var_input = var_input + 0x40; 115*0Sstevel@tonic-gate } 116*0Sstevel@tonic-gate output = var_input; 117*0Sstevel@tonic-gate discard; 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate } else { 120*0Sstevel@tonic-gate error EINVAL; 121*0Sstevel@tonic-gate } 122*0Sstevel@tonic-gate } else { 123*0Sstevel@tonic-gate error EILSEQ; 124*0Sstevel@tonic-gate } 125*0Sstevel@tonic-gate }; 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate true operation { 128*0Sstevel@tonic-gate error EILSEQ; 129*0Sstevel@tonic-gate }; 130*0Sstevel@tonic-gate }; 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate} 133