summaryrefslogtreecommitdiff
path: root/src/termcap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/termcap.c')
-rw-r--r--src/termcap.c149
1 files changed, 19 insertions, 130 deletions
diff --git a/src/termcap.c b/src/termcap.c
index 9b4a7f657f6..4ad0cee6264 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -18,56 +18,20 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* Emacs config.h may rename various library functions such as malloc. */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
-#ifdef emacs
-
#include <setjmp.h>
-#include <lisp.h> /* xmalloc is here */
-/* Get the O_* definitions for open et al. */
#include <sys/file.h>
-#ifdef HAVE_FCNTL_H
#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#else /* not emacs */
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#include <string.h>
-#else
-char *getenv ();
-char *malloc ();
-char *realloc ();
-#endif
-
-/* Do this after the include, in case string.h prototypes bcopy. */
-#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
-#define bcopy(s, d, n) memcpy ((d), (s), (n))
-#endif
-
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#endif /* not emacs */
+#include "lisp.h"
#ifndef NULL
#define NULL (char *) 0
#endif
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-
/* BUFSIZE is the initial size allocated for the buffer
for reading the termcap file.
It is not a limit.
@@ -89,37 +53,6 @@ int bufsize = 128;
#define TERMCAP_FILE "/etc/termcap"
#endif
-#ifndef emacs
-static void
-memory_out ()
-{
- write (2, "virtual memory exhausted\n", 25);
- exit (1);
-}
-
-static char *
-xmalloc (size)
- unsigned size;
-{
- register char *tem = malloc (size);
-
- if (!tem)
- memory_out ();
- return tem;
-}
-
-static char *
-xrealloc (ptr, size)
- char *ptr;
- unsigned size;
-{
- register char *tem = realloc (ptr, size);
-
- if (!tem)
- memory_out ();
- return tem;
-}
-#endif /* not emacs */
/* Looking up capabilities in the entry already found. */
@@ -127,15 +60,14 @@ xrealloc (ptr, size)
for tgetnum, tgetflag and tgetstr to find. */
static char *term_entry;
-static char *tgetst1 ();
+static char *tgetst1 (char *ptr, char **area);
/* Search entry BP for capability CAP.
Return a pointer to the capability (in BP) if found,
0 if not found. */
static char *
-find_capability (bp, cap)
- register char *bp, *cap;
+find_capability (register char *bp, register char *cap)
{
for (; *bp; bp++)
if (bp[0] == ':'
@@ -146,8 +78,7 @@ find_capability (bp, cap)
}
int
-tgetnum (cap)
- char *cap;
+tgetnum (char *cap)
{
register char *ptr = find_capability (term_entry, cap);
if (!ptr || ptr[-1] != '#')
@@ -156,8 +87,7 @@ tgetnum (cap)
}
int
-tgetflag (cap)
- char *cap;
+tgetflag (char *cap)
{
register char *ptr = find_capability (term_entry, cap);
return ptr && ptr[-1] == ':';
@@ -169,9 +99,7 @@ tgetflag (cap)
If AREA is null, space is allocated with `malloc'. */
char *
-tgetstr (cap, area)
- char *cap;
- char **area;
+tgetstr (char *cap, char **area)
{
register char *ptr = find_capability (term_entry, cap);
if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~'))
@@ -209,9 +137,7 @@ static const char esctab[]
or NULL if PTR is NULL. */
static char *
-tgetst1 (ptr, area)
- char *ptr;
- char **area;
+tgetst1 (char *ptr, char **area)
{
register char *p, *r;
register int c;
@@ -322,7 +248,7 @@ tgetst1 (ptr, area)
cut[last_p_param].len = r - cut[last_p_param].beg;
for (i = 0, wp = ret; i <= last_p_param; wp += cut[i++].len)
- bcopy (cut[i].beg, wp, cut[i].len);
+ memcpy (wp, cut[i].beg, cut[i].len);
r = wp;
}
}
@@ -336,48 +262,20 @@ tgetst1 (ptr, area)
/* Outputting a string with padding. */
-#ifndef emacs
-short ospeed;
-/* If OSPEED is 0, we use this as the actual baud rate. */
-int tputs_baud_rate;
-#endif
-
char PC;
-#ifndef emacs
-/* Actual baud rate if positive;
- - baud rate / 100 if negative. */
-
-static const int speeds[] =
- {
- 0, 50, 75, 110, 135, 150, -2, -3, -6, -12,
- -18, -24, -48, -96, -192, -288, -384, -576, -1152
- };
-
-#endif /* not emacs */
-
void
-tputs (str, nlines, outfun)
- register char *str;
- int nlines;
- register int (*outfun) ();
+tputs (register char *str, int nlines, register int (*outfun) (/* ??? */))
{
register int padcount = 0;
register int speed;
-#ifdef emacs
extern EMACS_INT baud_rate;
speed = baud_rate;
/* For quite high speeds, convert to the smaller
units to avoid overflow. */
if (speed > 10000)
speed = - speed / 100;
-#else
- if (ospeed == 0)
- speed = tputs_baud_rate;
- else
- speed = speeds[ospeed];
-#endif
if (!str)
return;
@@ -432,10 +330,10 @@ struct termcap_buffer
/* Forward declarations of static functions. */
-static int scan_file ();
-static char *gobble_line ();
-static int compare_contin ();
-static int name_match ();
+static int scan_file (char *str, int fd, register struct termcap_buffer *bufp);
+static char *gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end);
+static int compare_contin (register char *str1, register char *str2);
+static int name_match (char *line, char *name);
#ifdef MSDOS /* MW, May 1993 */
static int
@@ -460,8 +358,7 @@ valid_filename_p (fn)
in it, and some other value otherwise. */
int
-tgetent (bp, name)
- char *bp, *name;
+tgetent (char *bp, char *name)
{
register char *termcap_name;
register int fd;
@@ -625,10 +522,7 @@ tgetent (bp, name)
or 0 if no entry is found in the file. */
static int
-scan_file (str, fd, bufp)
- char *str;
- int fd;
- register struct termcap_buffer *bufp;
+scan_file (char *str, int fd, register struct termcap_buffer *bufp)
{
register char *end;
@@ -665,8 +559,7 @@ scan_file (str, fd, bufp)
by termcap entry LINE. */
static int
-name_match (line, name)
- char *line, *name;
+name_match (char *line, char *name)
{
register char *tem;
@@ -681,8 +574,7 @@ name_match (line, name)
}
static int
-compare_contin (str1, str2)
- register char *str1, *str2;
+compare_contin (register char *str1, register char *str2)
{
register int c1, c2;
while (1)
@@ -722,10 +614,7 @@ compare_contin (str1, str2)
thing as one line. The caller decides when a line is continued. */
static char *
-gobble_line (fd, bufp, append_end)
- int fd;
- register struct termcap_buffer *bufp;
- char *append_end;
+gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end)
{
register char *end;
register int nread;
@@ -758,7 +647,7 @@ gobble_line (fd, bufp, append_end)
else
{
append_end -= bufp->ptr - buf;
- bcopy (bufp->ptr, buf, bufp->full -= bufp->ptr - buf);
+ memcpy (buf, bufp->ptr, bufp->full -= bufp->ptr - buf);
bufp->ptr = buf;
}
if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full)))