home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
telecom
/
uucp_442
/
src
/
dmail
/
do_lists.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-06
|
4KB
|
233 lines
/*
* DO_LISTS.C
*
* $Header: Beta:src/uucp/src/dmail/RCS/do_lists.c,v 1.1 90/02/02 12:03:33 dillon Exp Locker: dillon $
*
* (C) Copyright 1985-1990 by Matthew Dillon, All Rights Reserved.
*
* Global Routines: DO_SETLIST()
* DO_LIST()
* DO_SELECT()
* DO_DEFER()
*
* Static Routines: None.
*
* LIST associated commands.
*
*/
#include <stdio.h>
#include "dmail.h"
do_setlist(str)
char *str;
{
int i, fw, idx, localecho = 1;
int sac = 1;
push_break();
if (ac > sac && strcmp (av[sac], "-s") == 0) {
++sac;
localecho = 0;
}
hold_load();
if (ac > sac) {
Listsize = 0;
for (i = sac; i < ac; ++i) {
fw = atoi(av[i]);
if (fw > 4096)
fw = 4096;
if (fw < 0 || (*av[i] < '0' || *av[i] > '9'))
fw = 20;
else
++i;
if (i >= ac)
continue;
idx = get_extra_ovr (av[i]);
if (idx < 0) {
printf ("To many entries, cannot load: %s\n", av[i]);
fflush (stdout);
continue;
}
header[Listsize] = idx;
width[Listsize] = fw;
++Listsize;
}
}
nohold_load();
pop_break();
if (localecho) {
puts ("");
printf ("Entry Width Field\n\n");
for (i = 0; i < Listsize; ++i)
printf ("%-6d %-5d %s\n", i, width[i], Find[header[i]].search);
puts ("");
}
return (1);
}
/*
* Pre-position # 0 > Current article
* 1 - Read already
*/
do_rlist()
{
int num = 20;
int istart = Current, iend = Current;
short dir = 1;
short try;
char buf[64];
if (av[1])
num = atoi(av[1]);
if (num < 0) {
dir = -1;
num = -num;
}
for (try = 0; try < 2 && num; ++try, (dir = -dir)) {
int i;
if (dir < 0) {
for (i = Current; i >= 0 && num; --i) {
if (Entry[i].no && !(Entry[i].status & ST_DELETED)) {
istart = i;
--num;
}
}
} else {
for (i = Current; i < Entries && num; ++i) {
if (Entry[i].no && !(Entry[i].status & ST_DELETED)) {
iend = i;
--num;
}
}
}
}
if (istart != iend) {
sprintf(buf, "%d-%d", Entry[istart].no, Entry[iend].no);
ac = 2;
av[1] = buf;
return(do_list());
} else {
return(-1);
}
}
do_list()
{
int i, j;
static char curr[10] = { " " };
if (ac == 1) {
av[1] = "all";
++ac;
}
if (push_base()) {
push_break();
pop_base();
PAGER (-1);
pop_break();
return (-1);
}
PAGER (0);
FPAGER ("\n ");
for (j = 0; j < Listsize; ++j) {
if (width[j]) {
sprintf (Puf, "%-*.*s",
2 + width[j],
2 + width[j],
Find[header[j]].search);
FPAGER (Puf);
}
}
FPAGER ("\n");
rewind_range (1);
while (i = get_range()) {
i = indexof(i);
if (Entry[i].no && ((Entry[i].status & ST_DELETED) == 0)) {
curr[0] = (Entry[i].status & ST_TAG) ? 'T' : ' ';
curr[1] = (i == Current) ? '>' : ' ';
curr[2] = (Entry[i].status & ST_READ) ? 'r' : ' ';
curr[3] = (Entry[i].status & ST_STORED) ? 'w' : ' ';
sprintf (Puf, "%s%-3d", curr, Entry[i].no);
FPAGER (Puf);
for (j = 0; j < Listsize; ++j) {
if (width[j]) {
sprintf(Puf, " %-*.*s",
width[j],
width[j],
Entry[i].fields[header[j]]);
FPAGER (Puf);
}
}
FPAGER ("\n");
}
}
FPAGER ("\n");
PAGER (-1);
pop_base();
return (1);
}
do_select(str, mode)
char *str;
{
int ret = 1;
int localecho = 1;
int avi = 1;
int scr;
if (ac == 1)
return (1);
SelAll = 0;
if (strcmp (av[avi], "-s") == 0) {
localecho = 0;
++avi;
--ac;
}
switch (ac) {
case 2:
SelAll = 1;
if (localecho)
puts ("SELECT ALL");
ret = m_select (Nulav, mode);
break;
case 1:
break;
default:
ret = m_select (av + avi, mode);
scr = indexof(0);
if (scr > 0 && localecho)
printf ("%d Entries selected\n", Entry[scr].no);
break;
}
if (ret < 0 && localecho) {
puts ("Null field");
return (-1);
}
return (1);
}
do_defer()
{
register int i, j;
push_break();
j = 1;
for (i = 0; i < Entries; ++i) {
if (Entry[i].no)
Entry[i].no = (Entry[i].status & ST_READ) ? 0 : j++;
}
pop_break();
return (1);
}