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
This commit is contained in:
parent
0bee6b5a11
commit
fa156e55d6
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user