extern char *BC;
extern int ospeed;
-extern int tgetent __P((char *, char *));
-extern int tgetflag __P((char *));
-extern int tgetnum __P((char *));
-extern char *tgetstr __P((char *, char **));
+extern int tgetent(char *, const char *);
+extern int tgetflag(char *);
+extern int tgetnum(char *);
+extern char *tgetstr(char *, char **);
-extern int tputs __P((char *, int, void (*outc)(int)));
-extern char *tgoto __P((char *, int, int));
-extern char * tparam(char *, char *, int, int, int, int, int); /* VARARGS */
+extern int tputs __P((const char *, int, int (*outc)(int)));
+extern char *tgoto __P((const char *, int, int));
#endif /* _TERMCAP_H */
-/* termcap - print termcap settings Author: Terrence Holm */
+/*
+ * termcap.c V1.1 20/7/87 agc Joypace Ltd
+ *
+ * Copyright Joypace Ltd, London, UK, 1987. All rights reserved.
+ * This file may be freely distributed provided that this notice
+ * remains attached.
+ *
+ * A public domain implementation of the termcap(3) routines.
+ *
+ *
+ *
+ * Klamer Schutte V1.2 Nov. 1988
+ *
+ * - Can match multiple terminal names [tgetent]
+ * - Removal of **area assignments [tgetstr]
+ *
+ * Terrence W. Holm V1.3 May, Sep, Oct. 1988
+ *
+ * - Correct when TERM != name and TERMCAP is defined [tgetent]
+ * - Correct the comparison for the terminal name [tgetent]
+ * - Correct the value of ^x escapes [tgetstr]
+ * - Added %r to reverse row/column [tgoto]
+ * - Fixed end of definition test [tgetnum/flag/str]
+ *
+ * Terrence W. Holm V1.4 Jan. 1989
+ *
+ * - Incorporated Klamer's V1.2 fixes into V1.3
+ * - Added %d, (old %d is now %2) [tgoto]
+ * - Allow '#' comments in definition file [tgetent]
+ *
+ * FIXME:
+ * - support the use of some kind of < 1024 byte buffer
+ * interface
+ * - avoid the use of stdio (state machine search for either
+ * [start of file]name: or \nname:)
+ */
#include <termcap.h>
#include <stdio.h>
int tgetent(char *bp, char *name)
{
FILE *fp;
- char *file;
+ const char *file;
char *term;
short len = strlen(name);
else if (*file != '/')
if ((term = getenv("TERM")) != (char *) NULL
&& strcmp(term, name) == 0) {
- *bp = '\0';
- strncat(bp, file, 1023);
+ strlcpy(bp, file, 1023);
return (1);
} else
file = "/etc/termcap";