summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorswallace <swallace@FreeBSD.org>1995-01-05 01:10:13 +0000
committerswallace <swallace@FreeBSD.org>1995-01-05 01:10:13 +0000
commitfa156e55d6e6bc94f99e4f36730c1b6a2fcf6fd1 (patch)
treee07343f8fe828b93dd7380ca4301afc7c8b5818a /usr.sbin/pkg_install
parent0bee6b5a11ccc4e0d6938dca1a93f1b64adb6564 (diff)
downloadFreeBSD-src-fa156e55d6e6bc94f99e4f36730c1b6a2fcf6fd1.zip
FreeBSD-src-fa156e55d6e6bc94f99e4f36730c1b6a2fcf6fd1.tar.gz
Added new function show_index() which does a 'smart' display of the index file.
Index descriptions are limited to MAXINDEXSIZE (60) chars. Any description beyond that is truncated. Also, only the first line is displayed as well. This allows pkg_info -a -I to be formated in two columns with one line per package for easy reading. Reviewed by: jkh
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/info/info.h11
-rw-r--r--usr.sbin/pkg_install/info/perform.c6
-rw-r--r--usr.sbin/pkg_install/info/show.c25
3 files changed, 37 insertions, 5 deletions
diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h
index 6feb73e..860a275 100644
--- a/usr.sbin/pkg_install/info/info.h
+++ b/usr.sbin/pkg_install/info/info.h
@@ -1,4 +1,4 @@
-/* $Id: info.h,v 1.5 1993/09/08 01:46:56 jkh Exp $ */
+/* $Id: info.h,v 1.6 1994/12/06 00:51:42 jkh Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@@ -23,6 +23,14 @@
#ifndef _INST_INFO_H_INCLUDE
#define _INST_INFO_H_INCLUDE
+#ifndef MAXINDEXSIZE
+#define MAXINDEXSIZE 60
+#endif
+
+#ifndef MAXNAMESIZE
+#define MAXNAMESIZE 20
+#endif
+
#define SHOW_COMMENT 0x0001
#define SHOW_DESC 0x0002
#define SHOW_PLIST 0x0004
@@ -46,5 +54,6 @@ extern char *CheckPkg;
extern void show_file(char *, char *);
extern void show_plist(char *, Package *, plist_t);
extern void show_files(char *, Package *);
+extern void show_index(char *, char *);
#endif /* _INST_INFO_H_INCLUDE */
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index a28f2a0..bde7b2e 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: perform.c,v 1.9 1994/10/14 05:57:49 jkh Exp $";
+static const char *rcsid = "$Id: perform.c,v 1.10 1994/12/06 00:51:45 jkh Exp $";
#endif
/*
@@ -136,8 +136,8 @@ pkg_do(char *pkg)
if (Flags & SHOW_INDEX) {
char fname[FILENAME_MAX];
- sprintf(fname, "%s\t", pkg);
- show_file(fname, COMMENT_FNAME);
+ sprintf(fname, "%-19s ", pkg);
+ show_index(fname, COMMENT_FNAME);
}
else {
/* Start showing the package contents */
diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c
index 93efd0e..e9a6cc8 100644
--- a/usr.sbin/pkg_install/info/show.c
+++ b/usr.sbin/pkg_install/info/show.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: show.c,v 1.3 1993/09/08 01:46:59 jkh Exp $";
+static const char *rcsid = "$Id: show.c,v 1.4 1994/12/06 00:51:46 jkh Exp $";
#endif
/*
@@ -45,6 +45,29 @@ show_file(char *title, char *fname)
printf("\n"); /* just in case */
}
+void
+show_index(char *title, char *fname)
+{
+ FILE *fp;
+ char line[MAXINDEXSIZE+2];
+ int i,n;
+
+ if (!Quiet)
+ printf("%s%s", InfoPrefix, title);
+ fp = fopen(fname, "r");
+ if (!fp) {
+ whinge("show_file: Can't open '%s' for reading.", fname);
+ return;
+ }
+ if(fgets(line, MAXINDEXSIZE+1, fp)) {
+ if(line[MAXINDEXSIZE-1] != '\n')
+ line[MAXINDEXSIZE] = '\n';
+ line[MAXINDEXSIZE+1] = 0;
+ fputs(line, stdout);
+ }
+ fclose(fp);
+}
+
/* Show a packing list item type. If type is -1, show all */
void
show_plist(char *title, Package *plist, plist_t type)
OpenPOWER on IntegriCloud