Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libterm * Fixed Makefile to proper set includes path



details:   https://anonhg.NetBSD.org/src/rev/28a6414c2e4c
branches:  trunk
changeset: 486763:28a6414c2e4c
user:      blymn <blymn%NetBSD.org@localhost>
date:      Sun May 28 09:58:15 2000 +0000

description:
* Fixed Makefile to proper set includes path
* Added new function t_setinfo to allow setting the termcap info when
  termcap entry found.

diffstat:

 lib/libterm/Makefile      |    4 +-
 lib/libterm/shlib_version |    4 +-
 lib/libterm/termcap.3     |  100 ++++++++++++++++++++++++++++-----------------
 lib/libterm/termcap.c     |   25 ++++++++++-
 lib/libterm/termcap.h     |    3 +-
 5 files changed, 89 insertions(+), 47 deletions(-)

diffs (230 lines):

diff -r d0f2248c9119 -r 28a6414c2e4c lib/libterm/Makefile
--- a/lib/libterm/Makefile      Sun May 28 09:41:52 2000 +0000
+++ b/lib/libterm/Makefile      Sun May 28 09:58:15 2000 +0000
@@ -1,8 +1,8 @@
-#      $NetBSD: Makefile,v 1.22 2000/05/20 13:55:10 blymn Exp $
+#      $NetBSD: Makefile,v 1.23 2000/05/28 09:58:15 blymn Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/4/93
 
 LIB=   termcap
-CPPFLAGS+=-I. -DCM_N -DCM_GT -DCM_B -DCM_D
+CPPFLAGS+=-I${.CURDIR} -DCM_N -DCM_GT -DCM_B -DCM_D
 SRCS=  termcap.c tgoto.c tputs.c
 
 MAN=   termcap.3
diff -r d0f2248c9119 -r 28a6414c2e4c lib/libterm/shlib_version
--- a/lib/libterm/shlib_version Sun May 28 09:41:52 2000 +0000
+++ b/lib/libterm/shlib_version Sun May 28 09:58:15 2000 +0000
@@ -1,5 +1,5 @@
-#      $NetBSD: shlib_version,v 1.6 2000/05/20 13:55:10 blymn Exp $
+#      $NetBSD: shlib_version,v 1.7 2000/05/28 09:58:15 blymn Exp $
 #      Remember to update distrib/sets/lists/base/shl.* when changing
 #
 major=0
-minor=3
+minor=4
diff -r d0f2248c9119 -r 28a6414c2e4c lib/libterm/termcap.3
--- a/lib/libterm/termcap.3     Sun May 28 09:41:52 2000 +0000
+++ b/lib/libterm/termcap.3     Sun May 28 09:58:15 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: termcap.3,v 1.19 2000/05/20 13:55:10 blymn Exp $
+.\"    $NetBSD: termcap.3,v 1.20 2000/05/28 09:58:15 blymn Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -83,6 +83,8 @@
 .Fn t_puts "struct tinfo *info" "char *cp" "int affcnt" "void (*outc)(char, void *)" "void *args"
 .Ft void
 .Fn t_freent "char *info"
+.Ft int
+.Fn t_setinfo "struct tinfo **info" "const char *entry"
 .Sh DESCRIPTION
 These functions extract and use capabilities from a terminal capability data
 base, usually
@@ -295,6 +297,47 @@
 is no longer required any storage associated with the object can be
 released by calling
 .Fn t_freent .
+.Pp
+The functions 
+.Fn t_getnum
+and
+.Fn t_getflag
+operate in the same manner as
+.Fn tgetnum
+and
+.Fn tgetflag
+with the exception that the pointer to the termcap object is passed along
+with the id of the capability required.
+.Pp
+The function
+.Fn t_getstr
+performs the same function as 
+.Fn tgetstr
+but has a
+.Fa limit
+parameter that gives the number of characters that can be inserted in to
+the array pointed to by
+.Fa area .
+The 
+.Fa limit
+argument is updated by the 
+.Fn t_getstr
+call to give the number of characters that remain available in
+.Fa area .
+If the t_getstr call fails then 
+.Sy NULL
+will be returned and errno set to indicate the failure, ENOENT indicates
+there was no termcap entry for the given
+.Fa id ,
+E2BIG indicates the retrieved entry would have overflowed
+.Fa area .
+If t_getstr is called with 
+.Fa area
+being NULL then the size required to hold the capability string will be
+returned in
+.Fa limit
+so the caller can allocate enough storage to hold the capability.
+.Pp
 The function
 .Fn t_agetstr
 performs the same function as 
@@ -347,44 +390,9 @@
 to the desired string and calculate pointer addresses only after all
 the calls to
 .Fn t_agetstr
-have been done.  The functions 
-.Fn t_getnum
-and
-.Fn t_getflag
-operate in the same manner as
-.Fn tgetnum
-and
-.Fn tgetflag
-with the exception that the pointer to the termcap object is passed along
-with the id of the capability required.  The function
-.Fn t_getstr
-performs the same function as 
-.Fn tgetstr
-but has a
-.Fa limit
-parameter that gives the number of characters that can be inserted in to
-the array pointed to by
-.Fa area .
-The 
-.Fa limit
-argument is updated by the 
-.Fn t_getstr
-call to give the number of characters that remain available in
-.Fa area .
-If the t_getstr call fails then 
-.Sy NULL
-will be returned and errno set to indicate the failure, ENOENT indicates
-there was no termcap entry for the given
-.Fa id ,
-E2BIG indicates the retrieved entry would have overflowed
-.Fa area .
-If t_getstr is called with 
-.Fa area
-being NULL then the size required to hold the capability string will be
-returned in
-.Fa limit
-so the caller can allocate enough storage to hold the capability.  The
-function 
+have been done.
+.Pp
+The function
 .Fn t_getterm
 returns a copy of the termcap name string of the termcap entry
 associated with 
@@ -461,6 +469,20 @@
 is dependent soley on the implementation of
 .Fa outc.
 .Pp
+The
+.Fn t_setinfo
+function allows the termcap entry contained in the
+.Fa entry
+string to be inserted into the the 
+.Fa info
+structure.  Memory sufficient to hold the contents of 
+.Fa entry
+is automatically allocated.  This allows the programmer to provide a
+fail over terminal capability string if fetching the termcap entry
+from the termcap database fails.  The format of the string
+.Fa entry
+is assumed to be a valid termcap entry.
+.Pp
 NOTE: A special capability of 
 .Fa ZZ
 is added to the end of the termcap entry retrieved.  The number that follows
diff -r d0f2248c9119 -r 28a6414c2e4c lib/libterm/termcap.c
--- a/lib/libterm/termcap.c     Sun May 28 09:41:52 2000 +0000
+++ b/lib/libterm/termcap.c     Sun May 28 09:58:15 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: termcap.c,v 1.30 2000/05/20 13:55:10 blymn Exp $       */
+/*     $NetBSD: termcap.c,v 1.31 2000/05/28 09:58:15 blymn Exp $       */
 
 /*
  * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)termcap.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: termcap.c,v 1.30 2000/05/20 13:55:10 blymn Exp $");
+__RCSID("$NetBSD: termcap.c,v 1.31 2000/05/28 09:58:15 blymn Exp $");
 #endif
 #endif /* not lint */
 
@@ -73,6 +73,25 @@
 static  struct tinfo *fbuf;     /* untruncated termcap buffer */
 
 /*
+ * Set the termcap entry to the arbitrary string passed in, this can
+ * be used to provide a "dummy" termcap entry if a real one does not
+ * exist.  This function will malloc the buffer and space for the
+ * string.  If an error occurs return -1 otherwise return 0.
+ */
+int
+t_setinfo(struct tinfo **bp, const char *entry)
+{
+       if ((*bp = malloc(sizeof(struct tinfo))) == NULL)
+               return -1;
+
+       if (((*bp)->info = (char *) malloc(strlen(entry) + 1)) == NULL)
+               return -1;
+
+       strcpy((*bp)->info, entry);
+       return 0;
+}
+
+/*
  * Get an extended entry for the terminal name.  This differs from
  * tgetent only in a) the buffer is malloc'ed for the caller and
  * b) the termcap entry is not truncated to 1023 characters.
@@ -182,7 +201,7 @@
                                return (-2);
                i = cgetent(&((*bp)->info), pathvec, name);      
        }
-       
+
        /* no tc reference loop return code in libterm XXX */
        if (i == -3)
                return (-1);
diff -r d0f2248c9119 -r 28a6414c2e4c lib/libterm/termcap.h
--- a/lib/libterm/termcap.h     Sun May 28 09:41:52 2000 +0000
+++ b/lib/libterm/termcap.h     Sun May 28 09:58:15 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: termcap.h,v 1.11 2000/05/20 13:55:11 blymn Exp $       */
+/*     $NetBSD: termcap.h,v 1.12 2000/05/28 09:58:15 blymn Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -66,6 +66,7 @@
 int   t_puts    __P((struct tinfo *, const char *, int,
                     void (*)(char, void *), void *));
 void  t_freent  __P((struct tinfo *));
+int   t_setinfo(struct tinfo **, const char *);
 
 extern char PC;
 extern char *BC;



Home | Main Index | Thread Index | Old Index