xstr.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 1999 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1999, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <stdlib.h>
/*
* xstr - extract and hash strings in a C program
*/
void onintr();
char *savestr();
char *strcat();
char *strcpy();
void cleanup(void);
char *strings = "strings";
int cflg;
int vflg;
int readstd;
int tmpfd;
int argc;
char *argv[];
{
argc--;
if (*cp == 0) {
readstd++;
continue;
}
do switch (*cp++) {
case 'c':
cflg++;
continue;
case 'v':
vflg++;
continue;
default:
"usage: xstr [ -v ] [ -c ] [ - ] [ name ... ]\n");
} while (*cp);
}
inithash();
else {
if (tmpfd == -1) {
exit(9);
}
}
if (readstd == 0)
else
readstd = 0;
};
flushsh();
if (cflg == 0)
xsdotc();
(void) cleanup();
exit(0);
}
char *name;
{
char *cp;
register int c;
register int incomm = 0;
printf("extern\tchar\txstr[];\n");
for (;;) {
(void) cleanup();
exit(3);
}
break;
}
if (linebuf[0] == '#') {
else
continue;
}
switch (c) {
case '"':
if (incomm)
goto def;
printf("(&xstr[%d])",
break;
case '\'':
if (incomm)
goto def;
putchar(c);
if (*cp)
break;
case '/':
goto def;
incomm = 1;
cp++;
printf("/*");
continue;
case '*':
incomm = 0;
cp++;
printf("*/");
continue;
}
goto def;
def:
default:
putchar(c);
break;
}
}
}
}
register char **cpp;
{
register int c, ch;
register char *tp;
while (c = *cp++) {
switch (c) {
case '"':
cp++;
goto out;
case '\\':
c = *cp++;
if (c == 0)
break;
if (c == '\n')
continue;
if (c == ch) {
c = *tp;
goto gotc;
}
if (!octdigit(c)) {
*dp++ = '\\';
break;
}
c -= '0';
break;
break;
break;
}
gotc:
*dp++ = c;
}
out:
*dp = 0;
}
octdigit(c)
char c;
{
}
inithash()
{
return;
for (;;) {
break;
}
}
char *obuf;
register int rmdr;
{
register c;
*buf++ = c;
*buf++ = 0;
}
{
tellpt++;
}
#define BUCKETS 128
struct hash {
char *hstr;
short hnew;
char *str;
int new;
{
int i;
if (i >= 0)
}
}
flushsh()
{
register int i;
for (i = 0; i < BUCKETS; i++)
new++;
else
old++;
return;
for (i = 0; i < BUCKETS; i++)
1, mesgwrit));
(void) cleanup();
exit(4);
}
}
}
}
int new;
char *str;
{
if (vflg == 0)
return;
if (!new)
else
}
register char *cp;
{
register int c;
while (c = (*cp++ & 0377))
if (c < ' ')
else if (c == 0177)
else if (c > 0200)
else
}
xsdotc()
{
for (;;) {
register int i, c;
for (i = 0; i < 8; i++) {
onintr();
}
goto out;
}
}
}
out:
}
char *
register char *cp;
{
}
Ignore(a)
char *a;
{
a = a;
}
ignorf(a)
int (*a)();
{
a = a;
}
register char *cp;
{
cp++;
return (*cp);
}
{
return (-1);
return (d);
}
void
onintr()
{
(void) cleanup();
exit(7);
}
void
cleanup(void)
{
if (strings[0] == '/') {
}
}