asa.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctype.h>
#include <limits.h>
#include <locale.h>
#include <nl_types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#define FF '\f'
#define NL '\n'
#define NUL '\0'
static void usage(void);
static FILE *get_next_file(int, char *, char *[], int);
static void finish(int need_a_newline);
int estatus = 0; /* exit status */
int i; /* argv index */
int
{
int c;
int form_feeds = 0;
int need_a_newline = 0;
FILE *f;
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'f':
form_feeds = 1;
break;
case '?':
usage();
}
}
i = optind;
if (argc <= i) {
f = stdin;
} else {
}
need_a_newline = 0;
for (;;) {
/* interpret the first character in the line */
c = getc(f);
switch (c) {
case EOF:
if (i >= argc)
if (need_a_newline) {
need_a_newline = 0;
}
if (form_feeds)
continue;
case NL:
if (need_a_newline)
need_a_newline = 1;
continue;
case '+':
if (need_a_newline)
(void) putchar('\r');
break;
case '0':
if (need_a_newline)
break;
case '1':
if (need_a_newline)
break;
case ' ':
default:
if (need_a_newline)
break;
}
need_a_newline = 0;
for (;;) {
c = getc(f);
if (c == NL) {
need_a_newline = 1;
break;
} else if (c == EOF) {
if (i >= argc)
if (form_feeds) {
need_a_newline = 0;
break;
}
} else {
(void) putchar(c);
}
}
}
/* NOTREACHED */
return (0);
}
static void
usage(void)
{
exit(1);
}
static void
{
if (ferror(f)) {
if (filename) {
"asa: read error on file %s\n"), filename);
} else {
"asa: read error on standard input\n"));
}
perror("");
estatus = 1;
}
(void) fclose(f);
}
static FILE *
{
FILE *f;
f = stdin;
} else {
/*
* Process each file operand. If unsuccessful, affect the
* exit status and continue processing the next operand.
*/
perror("");
estatus = 1;
if (++i < argc) {
f = stdin;
break;
} else {
}
} else {
}
}
}
++i;
return (f);
}
static void
finish(int need_a_newline)
{
if (need_a_newline)
}