/* Work-alike for termcap, plus extra features.
- Copyright (C) 1985, 86, 93, 94, 95, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1993, 1994, 1995, 2000, 2001, 2002, 2003,
+ 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+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 <lisp.h> /* xmalloc is here */
-/* Get the O_* definitions for open et al. */
+#include <setjmp.h>
#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.
#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 */
\f
/* Looking up capabilities in the entry already found. */
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] == ':'
return NULL;
}
-/* These are already defined in the System framework in Mac OS X and
- cause prebinding to fail. */
-#ifndef MAC_OSX
int
-tgetnum (cap)
- char *cap;
+tgetnum (char *cap)
{
register char *ptr = find_capability (term_entry, cap);
if (!ptr || ptr[-1] != '#')
}
int
-tgetflag (cap)
- char *cap;
+tgetflag (char *cap)
{
register char *ptr = find_capability (term_entry, cap);
return ptr && ptr[-1] == ':';
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] != '~'))
return NULL;
return tgetst1 (ptr, area);
}
-#endif /* MAC_OSX */
#ifdef IS_EBCDIC_HOST
/* Table, indexed by a character in range 0200 to 0300 with 0200 subtracted,
gives meaning of character following \, or a space if no special meaning.
Sixteen characters per line within the string. */
-static char esctab[]
+static const char esctab[]
= " \057\026 \047\014 \
\025 \015 \
\005 \013 \
gives meaning of character following \, or a space if no special meaning.
Eight characters per line within the string. */
-static char esctab[]
+static const char esctab[]
= " \007\010 \033\014 \
\012 \
\015 \011 \013 \
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;
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;
}
}
\f
/* 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
-
-/* Already defined in the System framework in Mac OS X and causes
- prebinding to fail. */
-#ifndef MAC_OSX
char PC;
-#endif /* MAC_OSX */
-#ifndef emacs
-/* Actual baud rate if positive;
- - baud rate / 100 if negative. */
-
-static int speeds[] =
- {
-#ifdef VMS
- 0, 50, 75, 110, 134, 150, -3, -6, -12, -18,
- -20, -24, -36, -48, -72, -96, -192
-#else /* not VMS */
- 0, 50, 75, 110, 135, 150, -2, -3, -6, -12,
- -18, -24, -48, -96, -192, -288, -384, -576, -1152
-#endif /* not VMS */
- };
-
-#endif /* not emacs */
-
-/* Already defined in the System framework in Mac OS X and causes
- prebinding to fail. */
-#ifndef MAC_OSX
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;
while (padcount-- > 0)
(*outfun) (PC);
}
-#endif /* MAC_OSX */
\f
/* Finding the termcap entry in the termcap data base. */
/* Forward declarations of static functions. */
-static int scan_file ();
-static char *gobble_line ();
-static int compare_contin ();
-static int name_match ();
-
-#ifdef VMS
-
-#include <rmsdef.h>
-#include <fab.h>
-#include <nam.h>
-
-static int
-valid_filename_p (fn)
- char *fn;
-{
- struct FAB fab = cc$rms_fab;
- struct NAM nam = cc$rms_nam;
- char esa[NAM$C_MAXRSS];
-
- fab.fab$l_fna = fn;
- fab.fab$b_fns = strlen(fn);
- fab.fab$l_nam = &nam;
- fab.fab$l_fop = FAB$M_NAM;
-
- nam.nam$l_esa = esa;
- nam.nam$b_ess = sizeof esa;
-
- return SYS$PARSE(&fab, 0, 0) == RMS$_NORMAL;
-}
-
-#else /* !VMS */
+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
#define valid_filename_p(fn) (*(fn) == '/')
#endif
-#endif /* !VMS */
-
/* Find the termcap entry data for terminal type NAME
and store it in the block that BP points to.
Record its address for future use.
0 if the data base is accessible but the type NAME is not defined
in it, and some other value otherwise. */
-/* Already defined in the System framework in Mac OS X and causes
- prebinding to fail. */
-#ifndef MAC_OSX
int
-tgetent (bp, name)
- char *bp, *name;
+tgetent (char *bp, char *name)
{
register char *termcap_name;
register int fd;
term_entry = bp;
return 1;
}
-#endif /* MAC_OSX */
/* Given file open on FD and buffer BUFP,
scan the file from the beginning until a line is found
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;
by termcap entry LINE. */
static int
-name_match (line, name)
- char *line, *name;
+name_match (char *line, char *name)
{
register char *tem;
}
static int
-compare_contin (str1, str2)
- register char *str1, *str2;
+compare_contin (register char *str1, register char *str2)
{
register int c1, c2;
while (1)
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;
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)))
#endif /* TEST */
-/* arch-tag: c2e8d427-2271-4fac-95fe-411857238b80
- (do not change this comment) */