srchtxt.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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <dirent.h>
#include <regexpr.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <unistd.h>
#define MESSAGES "/LC_MESSAGES/"
/* External functions */
extern int getopt();
extern void exit();
extern char *strecpy();
extern char *strrchr();
extern char *strchr();
/* External variables */
extern char *optarg;
extern int optind;
/* Internal functions */
static void usage();
static void prnt_str();
static int attach();
static void find_msgs();
static char *syserr();
/* Internal variables */
static char *cmdname; /* points to the name of the command */
static int lflg; /* set if locale is specified on command line */
static int mflg; /* set if message file is specified on */
/* command line */
static char *msgfile; /* points to the argument immediately */
/* following the m option */
static char *text; /* pointer to search pattern */
static int textflg; /* set if text pattern is specified on */
/* command line */
static int sflg; /* set if the s option is specified */
static char *fname; /* points to message file name */
static int msgnum; /* message number */
int
{
int ch;
char *end;
int addr;
int len;
int len1;
int fd;
char pathname[128];
char *cp;
/* find last level of path in command name */
++cmdname;
else
/* parse command line */
switch (ch) {
case 'l':
lflg++;
continue;
case 'm':
mflg++;
continue;
case 's':
sflg++;
continue;
default:
usage();
}
textflg++;
}
usage();
/* create full path name to message files */
if (!lflg)
if (textflg) {
/* compile regular expression */
"%s: ERROR: regular expression compile failed\n",
cmdname);
exit(1);
}
}
/* access message files */
if (mflg) {
usage();
len1 = 0;
} else {
}
continue;
else
break;
}
break;
}
} else { /* end if (mflg) */
exit(1);
}
continue;
continue;
}
}
}
return (0);
}
/* print usage message */
static void
usage()
{
"usage: srchtxt [-s]\n srchtxt [-s] -l locale\n"
" srchtxt [-s] [-l locale] [-m msgfile,...] [text]\n");
exit(1);
}
/*
* print string - non-graphic characters are printed as alphabetic
* escape sequences
*/
static void
char *instring;
{
char outstring[1024];
if (sflg)
else
}
/* mmap a message file to the address space */
static int
char *path;
int len;
int *fdescr;
{
int fd = -1;
return ((int)addr);
} else {
if (fd == -1)
return (-1);
}
}
/* find messages in message files */
static void
int addr;
char *regexpr;
{
int num_msgs;
char *msg;
if (textflg)
continue;
}
else
continue;
}
}
/* print description of error */
static char *
syserr()
{
}