/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "sfdchdr.h"
#if _PACKAGE_ast
#include <ast_tty.h>
#include <signal.h>
#endif
/*
* a simple but fast more style pager discipline
* if on sfstdout then sfstdin ops reset the page state
*
* Glenn Fowler
* AT&T Research
*
* @(#)$Id: sfdcmore (AT&T Research) 1998-06-25 $
*/
typedef struct
{
} More_t;
/*
* more read
* we assume line-at-a-time input
*/
#if __STD_C
#else
Sfio_t* f;
void* buf;
size_t n;
#endif
{
}
/*
* output label on wfd and return next char on rfd with no echo
* return < -1 is -(signal + 1)
*/
#if __STD_C
#else
char* label;
#endif
{
register int r;
int n;
#ifdef TCSADRAIN
unsigned char c;
if (!label)
n = 0;
{
r = -1;
r = -(SIGINT + 1);
r = -(SIGQUIT + 1);
else if (c == '\r')
r = '\n';
else
r = c;
}
if (n)
{
while (n-- > 0)
}
#else
register char* s;
#endif
return r;
}
/*
* more write
*/
#if __STD_C
#else
Sfio_t* f;
register size_t n;
#endif
{
register char* b;
register char* s;
register char* e;
register ssize_t w;
register int r;
return n;
w = 0;
b = (char*)buf;
s = b;
e = s + n;
{
{
if (s >= e)
return n;
if (*s == '\n')
b = s + 1;
break;
}
s = b;
w += b - (char*)buf;
}
while (s < e)
{
switch (*s++)
{
case '\t':
/*FALLTHROUGH*/
default:
continue;
/*FALLTHROUGH*/
case '\n':
continue;
break;
case '\b':
continue;
case '\r':
continue;
}
b = s;
if (r == '/' || r == 'n')
{
if (r == '/')
{
{
}
}
{
goto match;
}
}
switch (r)
{
case '\n':
case '\r':
break;
case ' ':
break;
default:
return n;
}
}
if (s > b)
return w;
}
/*
* remove the discipline on close
*/
#if __STD_C
#else
Sfio_t* f;
int type;
#endif
{
{
{
sfdisc(f, SF_POPDISC);
}
{
sfdisc(f, SF_POPDISC);
}
else
}
{
}
return 0;
}
/*
* push the more discipline on f
* if prompt==0 then a default ansi prompt is used
* if rows==0 or cols==0 then they are deterimined from the tty
* if f==sfstdout then input on sfstdin also resets the state
*/
#if __STD_C
#else
Sfio_t* f;
char* prompt;
int rows;
int cols;
#endif
{
size_t n;
/*
* this is a writeonly discipline for interactive io
*/
return -1;
if (!prompt)
prompt = "\033[7m More\033[m";
return -1;
{
#if _PACKAGE_ast
#endif
if (!rows)
rows = 24;
if (!cols)
cols = 80;
}
{
return -1;
}
if (f == sfstdout)
{
{
sfdisc(f, SF_POPDISC);
return -1;
}
{
sfdisc(f, SF_POPDISC);
return -1;
}
}
return 0;
}