diff options
-rwxr-xr-x | release/picobsd/build/clean | 3 | ||||
-rwxr-xr-x | release/picobsd/build/populate | 14 | ||||
-rw-r--r-- | release/picobsd/dial/mfs.tree/mfs.mtree | 4 | ||||
-rw-r--r-- | release/picobsd/tinyware/help/help.c | 163 |
4 files changed, 124 insertions, 60 deletions
diff --git a/release/picobsd/build/clean b/release/picobsd/build/clean index 52684636db63..6c170825e15f 100755 --- a/release/picobsd/build/clean +++ b/release/picobsd/build/clean @@ -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 ======================" diff --git a/release/picobsd/build/populate b/release/picobsd/build/populate index b54b7c9f9c7c..3d73a84dc53d 100755 --- a/release/picobsd/build/populate +++ b/release/picobsd/build/populate @@ -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 diff --git a/release/picobsd/dial/mfs.tree/mfs.mtree b/release/picobsd/dial/mfs.tree/mfs.mtree index d5ecdba76fe3..9e0318a62b38 100644 --- a/release/picobsd/dial/mfs.tree/mfs.mtree +++ b/release/picobsd/dial/mfs.tree/mfs.mtree @@ -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 diff --git a/release/picobsd/tinyware/help/help.c b/release/picobsd/tinyware/help/help.c index fda11a60bb63..ed390324f3c4 100644 --- a/release/picobsd/tinyware/help/help.c +++ b/release/picobsd/tinyware/help/help.c @@ -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> + +int display(FILE *, const char *); + +static int cnt, crt=-1; -void -display(char *fname) +int +main(int argc, char *argv[]) { + register int i, s; FILE *fd; - DIR *dirp; - struct dirent *d; - char buf[100],junk[5],c, *dot; - int i; + struct ttysize ts; - snprintf(buf,99,"/help/%s.hlp",fname); - if((fd=fopen(buf,"r"))==NULL) { - printf("No help available for '%s'.\n",fname); + if (!(fd=fopen("/help.a", "r"))) { + (void)fputs("Couldn't open help archive.\n", stderr); 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; - } + cnt=0; + if (ioctl(fileno(stdout), TIOCGWINSZ, &ts)>=0) { + crt=ts.ts_lines-1; } - 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; - } + 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; } - closedir(dirp); - printf("\n"); } - return; + (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 -main(int argc, char *argv[]) +display(FILE *fd, const char *fname) { - if(argc==1) { - display("help"); - } else { - display(argv[1]); + 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++; } - exit(0); + return 0; } |