[net.sources] DMAIL, Bug Fixes et all, Part 2 of 4

dillon@ucbvax.BERKELEY.EDU (Matt Dillon) (12/22/85)

	Thank you all for your bug reports and everything, here is, what I
hope to be, the final v1 dmail with all the bug fixes.  It comes in four
parts.  DMAIL WORKS ON 4.2 AND 4.3 SYSTEMS.  I cannot guarentee it will
work on other systems, though the code should be easy to port.

	Please make sure you get all four parts.  Do not mix this source
with the older version.

	This is part 2 of 4

				-Matt
	

#-----cut here-----cut here-----cut here-----cut here-----
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	Makefile
#	dmail.h
#	execom.h
#	dmkhelp.c
# This archive created: Sun Dec 22 12:29:46 1985
export PATH; PATH=/bin:$PATH
echo shar: extracting "'Makefile'" '(2041 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
cat << \!Funky!Stuff! > 'Makefile'

#   V1.01 (second distribution)
#
#   Written by Matthew Dillon, distribution date 17 December 1985
#
#   (C)1985 by Matthew Dillon
#
#   This code is completely original.  I declare this code to be public
#   domain.  You may have this code as long as any redistributions
#   contain this and all other files in their entirety, especially these
#   comments.
#
#   Send bug reports and other gripes 
#
#   dillon@ucb-vax.berkeley.edu         ARPA NET
#   ...!ucbvax!dillon                   USENET
#
#   INSTRUCTIONS FOR COMPILING:
#
#   (1) Set DESTDIR & HELP_DIR to some global directory accessable to
#       everybody (or whatever).  Also set HELP_CHMOD and PROG_CHMOD
#       to the right thing if you don't like the defaults.
#
#   (2) Do ONE of the following:
#       make            -defaults to internal help file
#       make external   -external help file (executable is smaller)
#
#   (3) make install
#

CC = cc

CFLAGS      = 
DEST_DIR    =	../../bin
HELP_DIR    =	/usr/public
HELP_FILE   =	${HELP_DIR}/dmail.help
HELP_CHMOD  =	644
PROG_CHMOD  =	751

OBJECTS     =	globals.o main.o do_lists.o sub.o execom.o commands.o range.o \
		load_mail.o sendmail.o set.o help.o

HEADERS     =	dmail.h execom.h


internal:	dmkhelp	${OBJECTS}
	${CC} ${CFLAGS} -o dmail ${OBJECTS}

external:	${OBJECTS}
	${CC} ${CFLAGS} -c -DHELPFILE=\"${HELP_FILE}\" help.c
	${CC} ${CFLAGS} -o dmail ${OBJECTS}

${OBJECTS}:	${HEADERS}

help.o:		dmkhelp
	./dmkhelp > .dmkout
	${CC} ${CFLAGS} -c help.c

dmkhelp:	dmail.help dmkhelp.o
	${CC} ${CFLAGS} -o dmkhelp dmkhelp.o

clean:
	rm -f *.o make.out a.out core dmail dmkhelp .dmkout tags
	rm -f shar1 shar2 shar3 shar4

install:
	cp dmail ${DEST_DIR}
	cp dmail.help ${HELP_DIR}
	chmod ${PROG_CHMOD} ${DEST_DIR}/dmail
	chmod ${HELP_CHMOD} ${HELP_DIR}/dmail.help

shar:
	shar -v README dmail.1 dmail.help nroff.out > shar1
	shar -v Makefile dmail.h execom.h dmkhelp.c > shar2
	shar -v commands.c do_lists.c execom.c globals.c help.c load_mail.c > shar3
	shar -v main.c range.c sendmail.c set.c sub.c > shar4

!Funky!Stuff!
fi # end of overwriting check
echo shar: extracting "'dmail.h'" '(2507 characters)'
if test -f 'dmail.h'
then
	echo shar: will not over-write existing file "'dmail.h'"
else
cat << \!Funky!Stuff! > 'dmail.h'
/*
 * DMAIL.H
 *
 * Distribution date   17 December 1985
 */

#define MAXTYPE      16     /* Max number of different fields remembered     */
#define EXSTART      3      /* Beginning of dynamic fields, rest are wired   */
#define MAXLIST      16     /* Maximum # list elements in SETLIST            */
#define LONGSTACK    64     /* Maximum # levels for the longjump stack       */
#define MAILMODE     0600   /* Standard mail mode for temp. files            */
#define MAXFIELDSIZE 4096   /* Maximum handlable field size (& scratch bufs) */

#define LEVEL_SET    0      /* which variable set to use                     */
#define LEVEL_ALIAS  1
#define LEVEL_MALIAS 2

#define R_INCLUDE   1       /* Include message      For DO_REPLY()  */
#define R_FORWARD   2       /* Forward message      */
#define R_REPLY     3       /* Reply to message     */
#define R_MAIL      4       /* Mail from scratch    */

#define M_RESET     0
#define M_CONT      1


#define PAGER(Puf)      _pager(Puf, 1)      /* Auto newline */
#define FPAGER(Puf)     _pager(Puf, 0)      /* output as is */
#define push_base()     (setjmp (env[1 + Longstack]) ? 1 : (++Longstack, 0))
#define pop_base()      --Longstack
#define push_break()    ++Breakstack
#define pop_break()     --Breakstack

#define ST_DELETED  0x0001  /* Status flag.. item has been deleted  */
#define ST_READ     0x0002  /* item has been read or marked         */
#define ST_STORED   0x0010  /* item has been written                */
#define ST_TAG      0x0020  /* item has been taged                  */
#define ST_SCR      0x0080  /* scratch flag to single out messages  */

#include <stdio.h>
#include <setjmp.h>

struct ENTRY {
    long fpos;
    int  no;
    int  status;
    char *from;
    char *fields[MAXTYPE];
};

static struct FIND {
    char *search;
    int  len;
    int  notnew;
};

extern char *getenv(), *malloc(), *realloc(), *next_word(), *get_field();
extern char *alloca();
extern char *get_var();

extern char *mail_file;
extern char *user_name;
extern char *output_file;
extern char *home_dir;
extern char *visual;
extern char Buf[];
extern char Puf[];
extern char *av[];
extern int  _ls, Longstack, Breakstack;
extern int  Debug;
extern int  Entries, Current;
extern int  Silence;
extern int  ac;
extern FILE *m_fi;
extern struct ENTRY *Entry;
extern struct FIND  Find[];
extern jmp_buf env[];

extern int width[], header[], Listsize;
extern int No_load_mail;

extern char *S_sendmail;
extern int S_page, S_novibreak, S_verbose, S_ask;

!Funky!Stuff!
fi # end of overwriting check
echo shar: extracting "'execom.h'" '(268 characters)'
if test -f 'execom.h'
then
	echo shar: will not over-write existing file "'execom.h'"
else
cat << \!Funky!Stuff! > 'execom.h'

/*
 * EXECOM.H
 *
 * (C) 1985 by Matthew Dillon    17 December 1985
 */

struct COMMAND {
    int  (*func)();
    int  stat;
    int  val;
    char *name;
};

extern struct COMMAND Command[];
extern char *Desc[];

#define C_NO        0x01	/* Not implimented yet */


!Funky!Stuff!
fi # end of overwriting check
echo shar: extracting "'dmkhelp.c'" '(1095 characters)'
if test -f 'dmkhelp.c'
then
	echo shar: will not over-write existing file "'dmkhelp.c'"
else
cat << \!Funky!Stuff! > 'dmkhelp.c'

/*
 * DMKHELP.C
 *
 *
 *  Matthew Dillon, 17 December 1985
 *
 *  (C) 1985  Matthew Dillon
 *
 *  Standalone C source.
 *
 *  Takes the file DMAIL.HELP (or that specified), and puts quotes and 
 * commas around each line, the output to stdout.  Used by Makefile to
 * place the help file on line (by making it a static array).  See the
 * Makefile.
 *
 */

#include <stdio.h>

#define HELPC "dmail.help"

static char buf[1024];

main(argc, argv)
char *argv[];
{
    FILE *fi;
    char *ptr;
    int len;
    register int i;

    if (argc == 1)
        fi = fopen (HELPC, "r");
    else
        fi = fopen (argv[1], "r");
    if (fi == NULL) {
        puts ("CANNOT OPEN");
        exit (1);
    }
    while (fgets (buf, 1024, fi)) {
        len = strlen(buf) - 1;
        buf[len] = '\0';
        putchar ('\"');
        for (i = 0; i < len; ++i) {
            if (buf[i] == '\"') {
                putchar ('\\');
                putchar ('\"');
            } else {
                putchar (buf[i]);
            }
        }
        puts ("\",");
    }
    puts ("NULL");
    fclose (fi);
}


!Funky!Stuff!
fi # end of overwriting check
#	End of shell archive
exit 0