/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 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>
#include <stdlib.h>
#include <string.h>
/*
* mailx -- a modified version of a University of California at Berkeley
* mail program
*
* Message list handling.
*/
static void scaninit(void);
/*
* Process message operand list.
* Convert the user string of message numbers and
* store the numbers into vector.
*
* Returns the count of messages picked up or -1 on error.
*/
int
{
register int *ip;
return (-1);
/*
* Check for first message number and make sure it is
* at the beginning of the vector.
*/
}
/*
* Add marked messages to vector and skip first
* message number because it is already at the
* beginning of the vector
*/
continue;
}
}
/*
* Check to see if string is an integer
*
* Returns 1 if is an integer and 0 if it is not
*/
static int
{
/* check for empty string */
result = 0;
return (result);
}
i = 0;
while (buf[i] != '\0') {
result = 0;
break;
}
i++;
}
return (result);
}
/*
* Process msglist operand list.
* Convert the user string of message numbers and
* store the numbers into vector.
*
* Returns the count of messages picked up or -1 on error.
*/
int
{
register int *ip;
return (-1);
}
/*
* Mark all messages that the user wanted from the command
* line in the message structure. Return 0 on success, -1
* on error.
*/
/*
* Bit values for colon modifiers.
*/
/*
* The following table describes the letters which can follow
* the colon and gives the corresponding modifier bit.
*/
static struct coltab {
} coltab[] = {
0, 0, 0, 0
};
static int lastcolmod;
static int
{
register char **np;
register int i;
colmod = 0;
for (i = 1; i <= msgCount; i++)
unmark(i);
mc = 0;
scaninit();
star = 0;
other = 0;
beg = 0;
switch (tok) {
case TNUMBER:
if (star) {
return (-1);
}
mc++;
other++;
if (beg != 0) {
return (-1);
mark(i);
beg = 0;
break;
}
return (-1);
beg = 0;
}
break;
case TSTRING:
if (beg != 0) {
"Non-numeric second argument\n"));
return (-1);
}
other++;
if (lexstring[0] == ':') {
if (colresult == 0) {
"Unknown colon modifier \"%s\"\n"),
return (-1);
}
}
else
break;
case TDASH:
case TPLUS:
case TDOLLAR:
case TUP:
case TDOT:
if (lexnumber == -1)
return (-1);
goto number;
case TSTAR:
if (other) {
"Can't mix \"*\" with anything\n"));
return (-1);
}
star++;
break;
}
}
lastcolmod = colmod;
mc = 0;
if (star) {
for (i = 0; i < msgCount; i++)
mark(i+1);
mc++;
}
if (mc == 0) {
return (-1);
}
return (0);
}
/*
* If no numbers were given, mark all of the messages,
* so that we can unmark any whose sender was not selected
* if any user names were given.
*/
for (i = 1; i <= msgCount; i++)
mark(i);
/*
* If any names were given, go through and eliminate any
* messages whose senders were not requested.
*/
for (i = 1; i <= msgCount; i++) {
if (**np == '/') {
mc++;
break;
}
} else {
mc++;
break;
}
}
if (mc == 0)
unmark(i);
}
/*
* Make sure we got some decent messages.
*/
mc = 0;
for (i = 1; i <= msgCount; i++)
mc++;
break;
}
if (mc == 0) {
namelist[0]);
printf("}\n");
return (-1);
}
}
/*
* If any colon modifiers were given, go through and
* unmark any messages which do not satisfy the modifiers.
*/
if (colmod != 0) {
for (i = 1; i <= msgCount; i++) {
unmark(i);
}
break;
printf("\n");
return (-1);
}
}
return (0);
}
/*
* Turn the character after a colon modifier into a bit
* value.
*/
static int
{
if (col == 0)
return (lastcolmod);
return (0);
}
/*
* Check the passed message number for legality and proper flags.
*/
static int
{
return (-1);
}
return (-1);
}
return (0);
}
/*
* Scan out the list of string arguments, shell style
* for a RAWLIST.
*/
int
{
register char **last;
while (*cp != '\0') {
cp++;
quotec = 0;
while (*cp != '\0') {
if (quotec) {
quotec = 0;
cp++;
} else
} else {
if (*cp == '\\') {
cp++;
} else {
"Trailing \\; ignoring\n"));
break;
}
}
break;
else
}
}
*cp2 = '\0';
break;
" excess discarded\n"));
break;
}
}
}
/*
* scan out a single lexical item and return its token number,
* updating the string pointer passed **p. Also, store the value
* of the number or string scanned in lexnumber or lexstring as
* appropriate. In any event, store the scanned `thing' in lexstring.
*/
static struct lex {
char l_char;
char l_token;
} singles[] = {
'$', TDOLLAR,
'.', TDOT,
'^', TUP,
'*', TSTAR,
'-', TDASH,
'+', TPLUS,
'(', TOPEN,
')', TCLOSE,
0, 0
};
static int
{
register char c;
int quotec;
if (regretp >= 0) {
return (regretstack[regretp--]);
}
c = *cp++;
/*
* strip away leading white space.
*/
while (any(c, " \t"))
c = *cp++;
/*
* If no characters remain, we are at end of line,
* so report that.
*/
if (c == '\0') {
return (TEOL);
}
/*
* If the leading character is a digit, scan
* the number and convert it on the fly.
* Return TNUMBER when done.
*/
if (isdigit(c)) {
lexnumber = 0;
while (isdigit(c)) {
*cp2++ = c;
c = *cp++;
}
*cp2 = '\0';
return (TNUMBER);
}
/*
* Check for single character tokens; return such
* if found.
*/
lexstring[0] = c;
}
/*
* We've got a string! Copy all the characters
* of the string into lexstring, until we see
* a null, space, or tab.
* If the lead character is a " or ', save it
* and scan until you get another.
*/
quotec = 0;
if (any(c, "'\"")) {
quotec = c;
c = *cp++;
}
while (c != '\0') {
if (quotec == 0 && c == '\\') {
if (*cp != '\0') {
c = *cp++;
} else {
"ignoring\n"));
}
}
if (c == quotec) {
cp++;
break;
}
break;
*cp2++ = c;
c = *cp++;
}
if (quotec && c == 0)
*cp2 = '\0';
return (TSTRING);
}
/*
* Unscan the named token by pushing it onto the regret stack.
*/
static void
{
panic("Too many regrets");
}
/*
* Reset all the scanner global variables.
*/
static void
scaninit(void)
{
regretp = -1;
}
/*
* Find the first message whose flags & m == f and return
* its message number.
*/
int
first(int f, int m)
{
register int mesg;
f &= MDELETED;
m &= MDELETED;
return (mesg);
mesg++;
}
return (mesg);
mesg--;
}
return (NULL);
}
/*
* See if the passed name sent the passed message number. Return true
* if so.
*/
static int
{
}
/*
* See if the given string matches inside the subject field of the
* given message. For the purpose of the scan, we ignore case differences.
* If it does, return true. The string search argument is assumed to
* have the form "/search-string." If it is of the form "/," we use the
* previous search string.
*/
static int
{
str++;
else
/*
* Now look, ignoring case, for the word in the string.
*/
return (0);
while (*cp2) {
if (*cp == 0)
return (1);
}
}
return (*cp == 0);
}
/*
* Mark the named message by setting its mark bit.
*/
static void
{
register int i;
i = mesg;
if (i < 1 || i > msgCount)
panic("Bad message number to mark");
}
/*
* Unmark the named message.
*/
static void
{
register int i;
i = mesg;
if (i < 1 || i > msgCount)
panic("Bad message number to unmark");
}
/*
* Return the message number corresponding to the passed meta character.
*/
static int
{
register int c, m;
c = meta;
switch (c) {
case '^':
/*
* First 'good' message left.
*/
return (-1);
case '+':
/*
* Next 'good' message left.
*/
return (-1);
case '-':
/*
* Previous 'good' message.
*/
return (-1);
case '$':
/*
* Last 'good message left.
*/
return (-1);
case '.':
/*
* Current message.
*/
return (-1);
}
return (m);
default:
return (-1);
}
}