/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Converts files from one char set to another
*
* Written 11/09/87 Eddy Bell
*
*/
/*
* INCLUDED and DEFINES
*/
#include <stdio.h>
#include <fcntl.h>
#include <sys/systeminfo.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
/*#include <io.h> for microsoft c 4.0 */
#define CONTENTS_ASCII 0
#ifdef _F_BIN
#else
#endif
/******************************************************************************
* INCLUDES AND DEFINES
******************************************************************************/
#ifdef UNIX_BUILD
#include <fcntl.h>
#endif
#ifdef DOS_BUILD
#include <dos.h>
#include "..\sys\dos_iso.h"
#endif
#define GLOBAL
#define LOCAL static
#define VOID int
#define BOOL int
#define FALSE 0
/******************************************************************************
* FUNCTION AND VARIABLE DECLARATIONS
******************************************************************************/
static void error();
static void usage();
/******************************************************************************
* ENTRY POINTS
******************************************************************************/
int
{
unsigned char * dos_to_iso;
int type;
#ifdef UNIX_BUILD
int kbdfd;
#endif
out_file_name = (char *)0;
/* The filename parameter is positionally dependent - it must be the
* second argument, immediately following the program name. Except
* when a char set switch is passed then the file name must be third
* argument.
*/
argv++;
out_stream = stdout;
j = 0; /* count for file names 0 -> source 1-> dest */
code_page_overide = 0;
for (i=1; i<argc; i++) {
if (*argv[0] == '-') {
argv++;
argv++;
argv++;
argv++;
argv++;
argv++;
argv++;
argv++;
} else
argv++;
continue;
}else{ /* not a command so must be filename */
switch(j){
case IN_FILE: /* open in file from cmdline */
in_file_name = *argv;
j++; /* next file name is outfile */
break;
case OUT_FILE: /* open out file from cmdline */
out_file_name = *argv;
j++;
break;
default:
usage();
}
}
argv++;
}
/* input file is specified */
if (j > 0) {
}
/* output file is secified */
if (j > 1) {
/* input and output have same name */
if (tmpfd == -1) {
error("Couldn't create output file %s.",
}
} else
if (out_stream == NULL) {
(void) unlink(out_file_name);
}
}
#ifdef _F_BIN
#endif
#ifdef UNIX_BUILD
if(!code_page_overide){
(void) unlink(out_file_name);
exit(1);
}
"get keyboard type US keyboard assumed\n");
}
}
} else {
type = 0;
}
switch(type){
case 0:
case 1: /* United States */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 2: /* Belgian French */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 3: /* Canadian French */
dos_to_iso = &dos_to_iso_cp_863[0];
break;
case 4: /* Danish */
dos_to_iso = &dos_to_iso_cp_865[0];
break;
case 5: /* German */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 6: /* Italian */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 7: /* Netherlands Dutch */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 8: /* Norwegian */
dos_to_iso = &dos_to_iso_cp_865[0];
break;
case 9: /* Portuguese */
dos_to_iso = &dos_to_iso_cp_860[0];
break;
case 10: /* Spanish */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 11: /* Swedish Finnish */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 12: /* Swiss French */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 13: /* Swiss German */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 14: /* United Kingdom */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
default:
dos_to_iso = &dos_to_iso_cp_437[0];
break;
}
}else{
switch(code_page_overide){
case CODE_PAGE_US:
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case CODE_PAGE_MULTILINGUAL:
dos_to_iso = &dos_to_iso_cp_850[0];
break;
case CODE_PAGE_PORTUGAL:
dos_to_iso = &dos_to_iso_cp_860[0];
break;
case CODE_PAGE_CANADA_FRENCH:
dos_to_iso = &dos_to_iso_cp_863[0];
break;
case CODE_PAGE_NORWAY:
dos_to_iso = &dos_to_iso_cp_865[0];
break;
}
}
#endif
#ifdef DOS_BUILD
if(!code_page_overide){
{
}
switch(type){
case 437: /* United States */
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case 850: /* Multilingual */
dos_to_iso = &dos_to_iso_cp_850[0];
break;
case 860: /* Portuguese */
dos_to_iso = &dos_to_iso_cp_860[0];
break;
case 863: /* Canadian French */
dos_to_iso = &dos_to_iso_cp_863[0];
break;
case 865: /* Danish */
dos_to_iso = &dos_to_iso_cp_865[0];
break;
default:
dos_to_iso = &dos_to_iso_cp_437[0];
break;
}
}else{
switch(code_page_overide){
case CODE_PAGE_US:
dos_to_iso = &dos_to_iso_cp_437[0];
break;
case CODE_PAGE_MULTILINGUAL:
dos_to_iso = &dos_to_iso_cp_850[0];
break;
case CODE_PAGE_PORTUGAL:
dos_to_iso = &dos_to_iso_cp_860[0];
break;
case CODE_PAGE_CANADA_FRENCH:
dos_to_iso = &dos_to_iso_cp_863[0];
break;
case CODE_PAGE_NORWAY:
dos_to_iso = &dos_to_iso_cp_865[0];
break;
}
}
#endif
/* While not EOF, read in chars and send them to out_stream
* if current char is not a CR.
*/
do {
i = 0;
out_len = 0;
switch (translate_mode){
case CONTENTS_ISO:
{
while ( i++ != num_read ){
if( *src_str == '\r'){
src_str++;
}
else{
out_len++;
}
}
}
break;
case CONTENTS_ASCII:
{
while ( i++ != num_read){
if( *src_str == '\r'){
src_str++;
continue;
}
else if ( *src_str > 127 ){
*dest_str++ = (unsigned char) ' ';
src_str++;
out_len++;
}
else{
out_len++;
}
}
}
break;
case CONTENTS_DOS:
{
while ( i++ != num_read){
if( *src_str == '\r'){
src_str++;
continue;
}
out_len++;
}
}
break;
}
out_len -= 2;
out_len -= 1;
if( out_len > 0 &&
if(same_name){
#ifdef _F_BIN
#endif
}
}
return (0);
}
char *format;
char *args;
{
exit(1);
}
void usage()
{
exit(1);
}