/* Copyright (c) 1979 Regents of the University of California */
* Return a pointer to a dynamic copy of the argument.
register char *cp
, *cp2
, *top
;
for (cp
= str
; *cp
; cp
++)
top
= salloc(cp
-str
+ 1);
for (cp
= str
, cp2
= top
; *cp
; cp
++)
* Copy the name from the passed header line into the passed
* name buffer. Null pad the name buffer.
for (cp
= linebuf
+ 5, cp2
= nbuf
; *cp
!= ' ' && cp2
-nbuf
< 8; cp
++)
* Announce a fatal error and die.
* Catch stdio errors and report them more nicely.
* Print a string on diagnostic output.
* Touch the named message by setting its MTOUCH flag.
* Touched messages have the effect of not being sent
* back to the system mailbox on exit.
if (mesg
>= 1 && mesg
<= msgCount
)
message
[mesg
-1].m_flag
|= MTOUCH
;
* Test to see if the passed file name is a directory.
if (stat(name
, &sbuf
) < 0)
return((sbuf
.st_mode
& S_IFMT
) == S_IFDIR
);
* Compute the size in characters of the passed message
register struct message
*mp
;
* Count the number of arguments in the given string raw list.
for (ap
= argv
; *ap
!= NOSTR
; ap
++)
* Given a file address, determine the
* block number it represents.
* Take a file address, and determine
* its offset in the current block.
* Determine if the passed file is actually a tty, via a call to
* gtty. This is not totally reliable, but . . .
* Return the desired header line from the passed message
* pointer (or NOSTR if the desired header field is not available.
while (readline(ibuf
, linebuf
) > 0 && hfc
< HDRFIELDS
) {
while (raise(*cp
++) == raise(*cp2
++))
if (*--cp
== ':' && *--cp2
== '\0') {
* The following code deals with input stacking to do source
* commands. All but the current file pointer are saved on
static int ssp
= -1; /* Top of file stack */
static FILE *sstack
[_NFILE
]; /* Saved input files */
* Pushdown current input file and switch to a new one.
* Set the global flag "sourcing" so that others will realize
* that they are no longer reading from a tty (in all probability).
if ((fi
= fopen(name
, "r")) == NULL
) {
printf("Too much \"sourcing\" going on.\n");
* Source a file, but do nothing if the file cannot be opened.
if ((f
= open(name
, 0)) < 0)
* Pop the current input back to the previous level.
* Update the "sourcing" flag as appropriate.
printf("\"Source\" stack over-pop.\n");
* Touch the indicated file.
* This is nifty for the shell.
if ((f
= open(name
, 0)) < 0)
* Examine the passed line buffer and
* return true if it is all blanks and tabs.
for (cp
= linebuf
; *cp
; cp
++)
* Fetch the sender's name from the passed message.
register struct message
*mp
;
static char namebuf
[NAMESIZE
];
if (readline(ibuf
, linebuf
) <= 0)
for (cp
= linebuf
; *cp
!= ' '; cp
++)
for (cp2
= namebuf
; *cp
&& !any(*cp
, " \t") &&
cp2
-namebuf
< NAMESIZE
-1; *cp2
++ = *cp
++)