Change the way the help files are stored, and save ca. 30kB on the
"dial" floppy. Submitted by: Eric P. Scott <eps@sirius.com>
This commit is contained in:
parent
d449215303
commit
06f84d5212
@ -1,7 +1,7 @@
|
||||
#! /bin/sh -
|
||||
|
||||
#
|
||||
# $Id: clean,v 1.2 1998/09/03 10:40:27 abial Exp $
|
||||
# $Id: clean,v 1.3 1998/09/04 19:38:57 abial Exp $
|
||||
#
|
||||
set -e
|
||||
|
||||
@ -22,6 +22,7 @@ rm -f kernel kernel.kz fs.PICOBSD picobsd.bin *.o *core *.db
|
||||
rm -f picobsd.bin
|
||||
cd ..
|
||||
rm -f custom
|
||||
rm -rf help/tmp_hlp
|
||||
for j in $list
|
||||
do
|
||||
echo "===================== $0 $j started ======================"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id: populate,v 1.2 1998/09/03 10:16:03 abial Exp $
|
||||
# $Id: populate,v 1.3 1998/09/04 08:08:05 abial Exp $
|
||||
#
|
||||
|
||||
pwd=`pwd`
|
||||
@ -33,10 +33,16 @@ if [ "${TYPE}" = "dial" ]
|
||||
then
|
||||
cp ../lang/login.${LANGUAGE} /mnt/stand/login
|
||||
cp ../lang/dialup.${LANGUAGE} /mnt/stand/dialup
|
||||
(cd ../../help; for i in `ls *.hlp.${LANGUAGE}`;\
|
||||
(cd ../../help;\
|
||||
rm -rf tmp_hlp;\
|
||||
mkdir tmp_hlp;\
|
||||
for i in `ls *.hlp.${LANGUAGE}`;\
|
||||
do \
|
||||
cp $i /mnt/help/`basename $i .${LANGUAGE}`;\
|
||||
done)
|
||||
cp $i tmp_hlp/`basename $i .hlp.${LANGUAGE}`;\
|
||||
done;\
|
||||
cd tmp_hlp;\
|
||||
ar -cru help.a *;\
|
||||
cp help.a /mnt/help.a)
|
||||
elif [ "${TYPE}" != "router" ]
|
||||
then
|
||||
cp ../../build/kvm_kernel.db /mnt/var/db/kvm_kernel.db
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: mfs.mtree,v 1.1.1.1 1998/08/27 17:38:42 abial Exp $
|
||||
# $Id: mfs.mtree,v 1.2 1998/08/31 12:32:30 abial Exp $
|
||||
#
|
||||
/set type=dir uname=root gname=wheel mode=0755
|
||||
.
|
||||
@ -9,8 +9,6 @@
|
||||
..
|
||||
etc
|
||||
..
|
||||
help
|
||||
..
|
||||
mnt
|
||||
..
|
||||
mnt1
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 1998 Andrzej Bialecki
|
||||
* Copyright (c) 1998 Eric P. Scott <eps@sirius.com>
|
||||
* Copyright (c) 1998 Andrzej Bialecki <abial@nask.pl>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -23,75 +24,133 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: help.c,v 1.1.1.1 1998/07/14 07:30:53 abial Exp $
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <ar.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
void
|
||||
display(char *fname)
|
||||
{
|
||||
FILE *fd;
|
||||
DIR *dirp;
|
||||
struct dirent *d;
|
||||
char buf[100],junk[5],c, *dot;
|
||||
int i;
|
||||
|
||||
snprintf(buf,99,"/help/%s.hlp",fname);
|
||||
if((fd=fopen(buf,"r"))==NULL) {
|
||||
printf("No help available for '%s'.\n",fname);
|
||||
exit(1);
|
||||
}
|
||||
printf("\n");
|
||||
i=0;
|
||||
while(!feof(fd)) {
|
||||
if(fgets(buf,99,fd)==NULL) continue;
|
||||
if(i<23) {
|
||||
printf("%s",buf);
|
||||
i++;
|
||||
} else {
|
||||
printf("[7mPress Enter to continue[m");
|
||||
fgets(junk,5,stdin);
|
||||
printf("%s",buf);
|
||||
i=0;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
i=0;
|
||||
if(strcmp(fname,"help")==0) {
|
||||
printf("The following help items are available:\n\n");
|
||||
dirp=opendir("/help/.");
|
||||
while((d=readdir(dirp))!=NULL) {
|
||||
if(d->d_name[0]=='.') continue;
|
||||
if((dot=strchr(d->d_name,'.'))!=NULL) {
|
||||
*dot='\0';
|
||||
}
|
||||
printf("%-13s",d->d_name);
|
||||
i++;
|
||||
if(i>5) {
|
||||
printf("\n");
|
||||
i=0;
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
printf("\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
int display(FILE *, const char *);
|
||||
|
||||
static int cnt, crt=-1;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
if(argc==1) {
|
||||
display("help");
|
||||
} else {
|
||||
display(argv[1]);
|
||||
register int i, s;
|
||||
FILE *fd;
|
||||
struct ttysize ts;
|
||||
|
||||
if (!(fd=fopen("/help.a", "r"))) {
|
||||
(void)fputs("Couldn't open help archive.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
cnt=0;
|
||||
if (ioctl(fileno(stdout), TIOCGWINSZ, &ts)>=0) {
|
||||
crt=ts.ts_lines-1;
|
||||
}
|
||||
if (crt<3) crt=23;
|
||||
s=display(fd, argc>1 ? argv[1] : "help");
|
||||
if (s<0) s=0;
|
||||
else for (i=2;i<argc;) {
|
||||
rewind(fd);
|
||||
s|=display(fd, argv[i++]);
|
||||
if (s<0) {
|
||||
s=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
(void)fclose(fd);
|
||||
exit(s);
|
||||
}
|
||||
|
||||
int
|
||||
more(void)
|
||||
{
|
||||
char buf[8];
|
||||
|
||||
(void)fflush(stdout);
|
||||
(void)fputs("\033[7mPress Enter to continue\033[m", stderr);
|
||||
(void)fflush(stderr);
|
||||
cnt=0;
|
||||
if (fgets(buf, sizeof buf, stdin)) return 0;
|
||||
(void)fputc('\n', stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
display(FILE *fd, const char *fname)
|
||||
{
|
||||
register char *p;
|
||||
register int c, n, o;
|
||||
struct ar_hdr ar;
|
||||
char aname[20];
|
||||
|
||||
if (!fgets(aname, sizeof aname, fd)) {
|
||||
return 1;
|
||||
}
|
||||
if (strncmp(aname, ARMAG, SARMAG)) return 1;
|
||||
(void)sprintf(aname, "%-16.16s", fname);
|
||||
for (;;) {
|
||||
if (fread((void *)&ar, sizeof ar, 1, fd)!=1) return 1;
|
||||
if (strncmp(ar.ar_fmag, ARFMAG, 2)) return 1;
|
||||
n=0;
|
||||
p=ar.ar_size;
|
||||
do {
|
||||
if ((c=(int)(*p++-'0'))<0||c>9) break;
|
||||
n*=10; n+=c;
|
||||
} while (p<&ar.ar_size[sizeof ar.ar_size]);
|
||||
if (!strncmp(ar.ar_name, aname, 16)) break;
|
||||
if (fseek(fd, (long)n, SEEK_CUR)<0) return 1;
|
||||
if ((n&1)&&fgetc(fd)!='\n') return 1;
|
||||
}
|
||||
if (cnt>=crt&&more()) return -1;
|
||||
(void)fputc('\n', stdout);
|
||||
cnt++;
|
||||
o=0; while (o<n&&(c=fgetc(fd))!=EOF) {
|
||||
per:
|
||||
o++;
|
||||
(void)fputc(c, stdout);
|
||||
if (c!='\n') continue;
|
||||
if (++cnt<crt) continue;
|
||||
if (o>=n||(c=fgetc(fd))==EOF) break;
|
||||
if (more()) return -1;
|
||||
goto per;
|
||||
}
|
||||
if (cnt>=crt&&more()) return -1;
|
||||
(void)fputc('\n', stdout);
|
||||
cnt++;
|
||||
if (!strcmp(fname, "help")) {
|
||||
rewind(fd);
|
||||
(void)fgets(aname, sizeof aname, fd);
|
||||
if (cnt>=crt&&more()) return -1;
|
||||
(void)fputs("The following help items are available:\n",
|
||||
stdout);
|
||||
cnt++;
|
||||
o=0;
|
||||
while (fread((void *)&ar, sizeof ar, 1, fd)==1) {
|
||||
if (strncmp(ar.ar_fmag, ARFMAG, 2)) break;
|
||||
if ((o%6)==0) {
|
||||
(void)fputc('\n', stdout);
|
||||
if (++cnt>=crt&&more()) return -1;
|
||||
}
|
||||
(void)printf("%.13s", ar.ar_name);
|
||||
++o;
|
||||
n=0;
|
||||
p=ar.ar_size;
|
||||
do {
|
||||
if ((c=(int)(*p++-'0'))<0||c>9) break;
|
||||
n*=10; n+=c;
|
||||
} while (p<&ar.ar_size[sizeof ar.ar_size]);
|
||||
if (fseek(fd, (long)n, SEEK_CUR)<0) break;
|
||||
if ((n&1)&&fgetc(fd)!='\n') break;
|
||||
}
|
||||
if (cnt>=crt&&more()) return -1;
|
||||
(void)fputc('\n', stdout);
|
||||
cnt++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user