cmd3.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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 1985-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* 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
*
* Still more user commands.
*/
static int diction(const void *a, const void *b);
static int reply2sender(void);
static char origprevfile[PATHSIZE];
/*
* Process a shell escape by saving signals, ignoring signals,
* and forking a sh -c
*/
int
{
printf("!\n");
return(0);
}
static int
{
void (*sig[2])(int);
register int t;
register pid_t p;
char *Shell;
return(-1);
p = vfork();
if (p == 0) {
sigchild();
_exit(1);
}
while (wait(0) != p)
;
if (p == (pid_t)-1)
perror("fork");
return(0);
}
/*
* Fork an interactive shell.
*/
int
#ifdef __cplusplus
dosh(char *)
#else
/* ARGSUSED */
dosh(char *s)
#endif
{
void (*sig[2])(int);
register int t;
register pid_t p;
char *Shell;
p = vfork();
if (p == 0) {
sigchild();
_exit(1);
}
while (wait(0) != p)
;
if (p == (pid_t)-1)
perror("fork");
putchar('\n');
return(0);
}
/*
* Expand the shell escape by expanding unescaped !'s into the
* last issued command where possible.
*/
static int
{
register int n;
int changed = 0;
n = BUFSIZ;
while (*cp) {
return(-1);
}
changed++;
cp++;
continue;
}
if (--n <= 1)
goto overf;
*cp2++ = '!';
cp += 2;
changed++;
}
if (--n <= 1)
goto overf;
}
*cp2 = 0;
if (changed) {
}
return(0);
}
/*
* Print out a nice help message from some file or another.
*/
int
help(void)
{
register c;
register FILE *f;
return(1);
}
putchar(c);
fclose(f);
return(0);
}
/*
* Change user's working directory.
*/
int
{
register char *cp;
;
if (*cp == '\0')
else
return(1);
return(1);
}
}
return(1);
}
/*
* Convert previously relative names to absolute names.
*/
}
if (mailname[0] != '/') {
}
return(0);
}
/*
* Two versions of reply. Reply to all names in message or reply
* to only sender of message, depending on setting of "replyall".
*/
int
{
if (reply2sender())
else
}
int
{
if (reply2sender())
else
}
int
{
}
static int
{
if (msgvec[1] != 0) {
"Sorry, can't reply to multiple messages at once\n"));
return(1);
}
} else
#ifdef OPTIM
/* rcv = netrename(rcv); */
#endif /* OPTIM */
/*
* Delete my name from the reply list,
* and with it, all my alternate names.
*/
if (returnaddr && *returnaddr)
if (altnames != 0)
if (reply2)
else
}
if (returnaddr && *returnaddr)
if (altnames != 0)
}
return(0);
}
void
{
register int folderize;
if (useauthor) {
if (folderize)
*recf++ = '+';
if (*bp=='!')
else
break;
}
}
*cp = '\0';
*recfile = '\0';
/* now strip off any Internet host names */
*cp = '\0';
} else {
*recf++ = '+';
sz--;
}
} else
*recf = '\0';
}
}
/*
* Modify the subject we are replying to to begin with Re: if
* it does not already.
*/
static char *
{
char sbuf[10];
register char *newsubj;
return(NOSTR);
sbuf[3] = 0;
return(subj);
return(newsubj);
}
/*
* Preserve the named messages, so that they will be sent
* back to the system mailbox.
*/
int
{
if (edit) {
return(1);
}
}
return(0);
}
/*
* Mark all given messages as unread.
*/
int
{
register int *ip;
}
return(0);
}
/*
* Print the size of each message.
*/
int
{
}
return(0);
}
/*
* Quit quickly. If we are sourcing, just pop the input level
* by returning an error.
*/
int
rexit(int e)
{
if (sourcing)
return(1);
if (!edit)
Verhogen();
/* NOTREACHED */
return (0); /* shut up lint and CC */
}
/*
* Set or display a variable value. Syntax is similar to that
* of csh.
*/
int
{
int errs, h, s;
for (h = 0, s = 1; h < HSHSIZE; h++)
s++;
*p = NOSTR;
else
printf("%s\n", *p);
return(0);
}
errs = 0;
*cp2 = '\0';
if (*cp == '\0')
cp = "";
else
cp++;
errs++;
continue;
}
}
return(errs);
}
/*
* Unset a bunch of variable values.
*/
int
{
register int errs;
register char **ap;
errs = 0;
return(errs);
}
/*
* Add users to a group.
*/
int
{
register int h;
int s;
for (h = 0, s = 1; h < HSHSIZE; h++)
s++;
*p = NOSTR;
printgroup(*p);
return(0);
}
printgroup(*argv);
return(0);
}
panic("Failed to allocate memory for group");
}
}
/*
* Insert names from the command list into the group.
* Who cares if there are duplicates? They get tossed
* later anyway.
*/
panic("Failed to allocate memory for group");
}
}
return(0);
}
/*
* Remove users from a group.
*/
int
{
register int h;
printf("Must specify alias or group to remove\n");
return(1);
}
/*
* Remove names on the command list from the group list.
*/
/* remove from list */
/* free each member of gorup */
}
break;
}
}
}
return(0);
}
/*
* Sort the passed string vecotor into ascending dictionary
* order.
*/
static void
{
register char **ap;
;
return;
}
/*
* Do a dictionary order comparison of the arguments from
* qsort.
*/
static int
diction(const void *a, const void *b)
{
return(strcmp(*(char **)a, *(char **)b));
}
/*
* The do nothing command for comments.
*/
int
#ifdef __cplusplus
null(char *)
#else
/* ARGSUSED */
null(char *s)
#endif
{
return(0);
}
/*
* Print out the current edit file, if we are editing.
* Otherwise, print the name of the person who's mail
* we are reading.
*/
int
{
register char *cp;
return(0);
}
/*
* Acker's! Must switch to the new file.
* We use a funny interpretation --
* # -- gets the previous file
* % -- gets the invoker's post office box
* %user -- gets someone else's post office box
* & -- gets invoker's mbox file
* string -- reads the given file
*/
return(-1);
return(-1);
}
return(0);
}
/*
* Evaluate the string given as a new mailbox name.
* Ultimately, we want this to support a number of meta characters.
* Possibly:
* % -- for my system mail box
* %user -- for user's system mail box
* # -- for previous file
* & -- get's invoker's mbox file
* file name -- for any other file
*/
static char *
{
register char *cp;
char oldmailname[BUFSIZ];
/*
* Assume we will be in "edit file" mode, until
* proven wrong.
*/
*aedit = 1;
switch (*name) {
case '%':
*aedit = 0;
if (name[1] != 0) {
return(cp);
}
return(cp);
case '#':
if (name[1] != 0)
goto regular;
if (prevfile[0] == 0) {
return(NOSTR);
}
return(cp);
case '&':
if (name[1] == 0) {
return(cp);
}
/* Fall into . . . */
default:
if (cp[0] != '/') {
}
return(cp);
}
}
/*
* Expand file names like echo
*/
int
{
register char *cp;
int neednl = 0;
neednl++;
putchar(' ');
}
}
if (neednl)
putchar('\n');
return(0);
}
/*
* Reply to a series of messages by simply mailing to the senders
* and not messing around with the To: and Cc: lists as in normal
* reply.
*/
int
{
if (reply2sender())
else
}
int
{
if (reply2sender())
else
}
int
replysender(int *msgvec)
{
}
static int
{
register int s, *ap;
}
if (s == 0)
return(0);
*cp++ = ' ';
}
*--cp = 0;
return(0);
}
/*
* Conditional commands. These allow one to parameterize one's
* .mailrc and do some things if sending, others if receiving.
*/
int
{
register char *cp;
return(1);
}
switch (*cp) {
case 'r': case 'R':
break;
case 's': case 'S':
break;
case 't': case 'T':
break;
default:
return(1);
}
return(0);
}
/*
* Implement 'else'. This is pretty simple -- we just
* flip over the conditional flag.
*/
int
elsecmd(void)
{
switch (cond) {
case CANY:
return(1);
case CSEND:
break;
case CRCV:
break;
case CTTY:
break;
case CNOTTY:
break;
default:
break;
}
return(0);
}
/*
* End of if statement. Just set cond back to anything.
*/
int
endifcmd(void)
{
return(1);
}
return(0);
}
/*
* Set the list of alternate names.
*/
int
alternates(char **namelist)
{
register int c;
if (c == 1) {
if (altnames == 0)
return(0);
printf("\n");
return (0);
}
if (altnames != 0)
if ((altnames = (char **)
panic("Failed to allocate memory");
if ((cp = (char *)
panic("Failed to allocate memory");
}
*ap2 = 0;
return(0);
}
/*
* Figure out who to reply to.
* Return the real sender in *f.
*/
static char *
{
char *r, *rf;
r = rf;
if (f)
*f = rf;
return (r);
}
/*
* reply2sender - determine whether a "reply" command should reply to the
* sender of the messages, or to all the recipients of the
* message.
*
* With the advent of POSIX.2 compliance, this has become
* a bit more complicated, and so should be done in one
* place, for all to use.
*/
static int
reply2sender (void)
{
}