cmd2.c revision 6c83d09f819e9de7126c8539546eca2e276df44a
/*
* 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 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "rcv.h"
#include <locale.h>
/*
* mailx -- a modified version of a University of California at Berkeley
* mail program
*
* More user commands.
*/
static int igshow(void);
static int igcomp(const void *l, const void *r);
static int retshow(void);
/* flags for savemsglist() */
/*
* If any arguments were given, go to the next applicable argument
* following dot, otherwise, go to the next applicable message.
* If given as first command with no arguments, print first message.
*/
int
{
/*
* If some messages were supplied, find the
* first applicable one following dot using
* wrap around.
*/
/*
* Find the first message in the supplied
* message list which follows dot.
*/
break;
do {
goto hitit;
}
ip2++;
return(1);
}
/*
* If this is the first command, select message 1.
* Note that this must exist for us to get here at all.
*/
if (!sawcom)
goto hitit;
/*
* Just find the next good message after dot, no
* wraparound.
*/
break;
return(0);
}
/*
* Print dot.
*/
}
/*
* Save a message in a file. Mark the message as saved
* so we can discard when the user quits.
*/
int
{
}
/*
* Copy a message to a file without affected its saved-ness
*/
int
{
}
/*
* If mark is true, mark the message "saved."
*/
static int
{
int f, *msgvec;
if (f==-1)
return(1);
if (!f) {
return(1);
}
}
return(1);
return(1);
return(0);
}
int
{
}
int
{
}
/*
* by the sender of the first message in the msglist.
*/
static int
{
register char *from;
#ifdef notdef
#else
#endif
if (*recfile != '\0')
return(0);
}
int
{
}
int
{
}
/*
* Put the indicated messages at the end of the passed file name.
*/
static int
{
char *file;
int f, *msgvec;
if (f==-1)
return(1);
if (!f) {
return(1);
}
}
return(1);
return(1);
return(0);
}
/*
* save a message list in a file.
* if wr set, doing "write" instead
* of "save" or "copy" so don't put
* out header.
*/
static int wr_linecount; /* count of lines written */
static int wr_charcount; /* char count of lines written */
static int wr_inlines; /* count of lines read */
static long wr_maxlines; /* total lines in message */
static int wr_inhead; /* in header of message */
static void
{
char *disp;
flush();
disp = "[Appended]";
else
disp = "[New file]";
perror("");
return;
}
bnry = 0;
else if (flag & S_NOIGNORE)
mflag = 0;
else
bnry = 1;
}
wr_linecount = 0;
wr_charcount = 0;
if (flag & S_NOHEADER) {
wr_inhead = 1;
wr_inlines = 0;
} else {
}
if (t < 0) {
return;
}
lc += wr_linecount;
cc += wr_charcount;
}
if (!bnry) {
} else {
}
}
static int
{
wr_linecount++;
}
static int
{
/*
* If this is a header line or
* the last line, don't write it out. Since we may add a
* "Status" line the line count may be off by one so insist
* that the last line is blank before we skip it.
*/
wr_inlines++;
if (wr_inhead) {
wr_inhead = 0;
return(0);
}
return(0);
wr_linecount++;
}
/*
* Write the indicated messages at the end of the passed
* file name, minus header and trailing blank line.
*/
int
{
register char *file;
int f, *msgvec;
return(1);
if (f==-1)
return(1);
return(1);
if (!f) {
return(1);
}
}
return(1);
return(0);
}
/*
* Snarf the file from the end of the command line and
* return a pointer to it. If there is no file attached,
* just return NOSTR. Put a null in front of the file
* name so that the message list processing won't see it,
* unless the file name is the only thing on the line, in
* which case, return 0 in the reference flag variable.
*/
/*
* The following definitions are used to characterize the syntactic
* category of the preceding character in the following parse procedure.
* The variable pc_type assumes these values.
*/
char *
{
register char *p; /* utility pointer */
register char qc; /* quotation character to match */
register unsigned int pc_type; /* preceding character type */
register char *tok_beg; /* beginning of last token */
register char *tok_end; /* end of last token */
char *line_beg; /* beginning of line, after */
/* leading whitespace */
/*
* Skip leading whitespace.
*/
line_beg++) {
/* empty body */
}
if (!*line_beg) {
if (erf) {
}
*flag = 0;
return(NOSTR);
}
/*
* Process line from left-to-right, 1 char at a time.
*/
*p != '\0'; ) {
if (any(*p, " \t")) {
/* This character is a DELIMITER */
tok_end = p - 1;
}
p++;
/* This character is a QUOTE character */
/* embedded quotation symbols are simply */
/* token characters. */
p++;
continue;
}
/* Search for the matching QUOTE character */
*p != '\0' && *p != qc;
p++) {
p++;
}
}
if (*p == '\0') {
"%c.\n"), qc);
*flag = -1;
return(NOSTR);
}
tok_end = p;
p++;
} else {
/* This character should be a TOKEN character */
tok_beg = p;
}
} else {
" at \"%s\".\n"), p);
*flag = -1;
return(NOSTR);
}
if (*p == '\\' && *++p == '\0') {
"end of line.\n"));
*flag = -1;
return(NOSTR);
}
p++;
}
}
tok_end = p - 1;
}
*flag = 0;
} else {
*flag = 1;
}
return(tok_beg);
} else {
if (erf) {
}
*flag = 0;
return(NOSTR);
}
}
/*
* Delete messages, then type the new dot.
*/
int
{
int list[2];
int lastdot;
list[0]++;
}
return(0);
}
else {
return(0);
}
}
/*
* Delete the indicated messages.
* Set dot to some nice place afterwards.
*/
int
{
int last;
}
return(0);
}
else {
return(-1);
}
}
/*
* Following can't happen -- it keeps lint happy
*/
return(-1);
}
/*
* Undelete the indicated messages.
*/
int
{
if (mesg == 0)
return(0);
}
return(0);
}
/*
* Add the given header fields to the retained list.
* If no arguments, print the current list of retained fields.
*/
int
{
register int h;
char **ap;
return(retshow());
continue;
panic("Couldn't allocate memory");
}
panic("Couldn't allocate memory");
}
nretained++;
}
return(0);
}
/*
* Print out all currently retained fields.
*/
static int
retshow(void)
{
register int h, count;
count = 0;
for (h = 0; h < HSHSIZE; h++)
count++;
if (count == 0) {
return(0);
}
for (h = 0; h < HSHSIZE; h++)
*ap = 0;
return(0);
}
/*
* Remove a list of fields from the retain list.
*/
int
unretfield(char *list[])
{
register int h, count = 0;
for (h = 0; h < HSHSIZE; h++) {
while (ig1) {
count++;
}
}
if (count == 0)
"No fields currently being retained.\n"));
nretained = 0;
return 0;
}
else
nretained--;
break;
}
}
return 0;
}
/*
* Add the given header fields to the ignored list.
* If no arguments, print the current list of ignored fields.
*/
int
{
register int h;
char **ap;
return(igshow());
continue;
panic("Couldn't allocate memory");
}
sizeof (char))) == NULL) {
panic("Couldn't allocate memory");
}
}
return(0);
}
/*
* Print out all currently ignored fields.
*/
static int
igshow(void)
{
register int h, count;
count = 0;
for (h = 0; h < HSHSIZE; h++)
count++;
if (count == 0) {
return(0);
}
for (h = 0; h < HSHSIZE; h++)
*ap = 0;
return(0);
}
/*
* Compare two names for sorting ignored field list.
*/
static int
igcomp(const void *l, const void *r)
{
return(strcmp(*(char **)l, *(char **)r));
}
/*
* Remove a list of fields from the ignore list.
*/
int
{
register int h, count = 0;
for (h = 0; h < HSHSIZE; h++) {
while (ig1) {
count++;
}
}
if (count == 0)
return 0;
}
else
break;
}
}
return 0;
}