├── Makefile
├── Makefile.in
├── README
├── TODO
├── abbrev.c
├── cgibase.c
├── defs.h
├── glimpse_filters
├── hman.1
├── hman.sh
├── locales
├── en
│ ├── hman.1
│ └── man2html.1
├── fr
│ └── man2html.1
└── it
│ ├── hman.1
│ └── man2html.1
├── man2html.1
├── man2html.c
├── scripts
├── cgi-aux
│ └── man
│ │ ├── man.aux
│ │ ├── mansearch.aux
│ │ └── mansearchhelp.aux
└── cgi-bin
│ └── man
│ ├── man2html
│ ├── mansearch
│ ├── mansearchhelp
│ ├── mansec
│ └── manwhatis
└── strdefs.c
/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Generated automatically from Makefile.in by the
3 | # configure script.
4 | #
5 | CC = gcc
6 | CFLAGS += -Wall -Wstrict-prototypes -Wmissing-prototypes
7 | OBJECTS = man2html.o cgibase.o abbrev.o strdefs.o
8 | bindir = /usr/local/bin
9 | mandir = /usr/local/share/man
10 | vardir = /usr/local/var
11 | httpdir = /home/httpd
12 | cgiowner = nobody
13 | cgigroup = nobody
14 |
15 | all: man2html hman
16 |
17 | man2html: $(OBJECTS)
18 | $(CC) $(LDFLAGS) -o man2html $(OBJECTS)
19 |
20 | # man2html: ../src/version.h
21 |
22 | # This installs the man2html utility
23 | install: man2html
24 | mkdir -p $(bindir)
25 | install -m 755 man2html $(bindir)
26 | mkdir -p $(mandir)/man1
27 | install -m 644 man2html.1 $(mandir)/man1/man2html.1
28 |
29 | install-scripts: install-man-scripts install-glimpse-stuff install-hman
30 |
31 | # These are the scripts that allow pointing a browser at
32 | # http://localhost/cgi-bin/man/man2html
33 | # to work.
34 | install-man-scripts:
35 | mkdir -p $(httpdir)/cgi-bin/man
36 | mkdir -p $(httpdir)/cgi-aux/man
37 | install -m 755 scripts/cgi-bin/man/* $(httpdir)/cgi-bin/man
38 | install -m 644 scripts/cgi-aux/man/* $(httpdir)/cgi-aux/man
39 | install -d -o $(cgiowner) -g $(cgigroup) -m 775 $(vardir)/man2html
40 | # (aux was renamed to cgi-aux since aux causes problems under DOS)
41 |
42 | # If you have installed glimpse, and have compressed man pages,
43 | # then perhaps you also want these filters.
44 | install-glimpse-stuff:
45 | install -m 644 glimpse_filters $(vardir)/man2html/.glimpse_filters
46 |
47 | # In order not to have to type a long command like
48 | # netscape http://localhost/cgi-bin/man/man2html?section+topic
49 | # or
50 | # lynx lynxcgi:/home/httpd/cgi-bin/man/man2html?section+topic
51 | # it is convenient to have some shell script as a wrapper.
52 | # The script hman can be aliased to man. It uses an environment
53 | # variable MANHTMLPAGER to find out which browser you use, and
54 | # you can set MANHTMLHOST if the pages are not on localhost.
55 | hman: hman.sh
56 | rm -f hman
57 | sed -e 's,%version%,man-1.6f,' hman.sh > hman
58 |
59 | install-hman: hman
60 | install -m 555 hman $(bindir)/hman
61 | install -m 644 hman.1 $(mandir)/man1/hman.1
62 |
63 | clean:
64 | rm -f core hman man2html $(OBJECTS) *~
65 |
66 | spotless: clean
67 | rm -f Makefile
68 |
69 | $(OBJECTS): defs.h
70 |
--------------------------------------------------------------------------------
/Makefile.in:
--------------------------------------------------------------------------------
1 | CC = @CC@
2 | CFLAGS += -Wall -Wstrict-prototypes -Wmissing-prototypes
3 | OBJECTS = man2html.o cgibase.o abbrev.o strdefs.o
4 | bindir = $(DESTDIR)$(PREFIX)/usr/bin
5 | mandir = $(DESTDIR)$(PREFIX)@mandir@
6 | vardir = $(DESTDIR)$(PREFIX)/var
7 | httpdir = $(DESTDIR)$(PREFIX)/home/httpd
8 | cgiowner = nobody
9 | cgigroup = nobody
10 |
11 | all: man2html hman
12 |
13 | man2html: $(OBJECTS)
14 | $(CC) $(LDFLAGS) -o man2html $(OBJECTS)
15 |
16 | # man2html: ../src/version.h
17 |
18 | # This installs the man2html utility
19 | install: man2html
20 | mkdir -p $(bindir)
21 | install -m 755 man2html $(bindir)
22 | mkdir -p $(mandir)/man1
23 | install -m 644 man2html.1 $(mandir)/man1/man2html.@man1ext@
24 |
25 | install-scripts: install-man-scripts install-glimpse-stuff install-hman
26 |
27 | # These are the scripts that allow pointing a browser at
28 | # http://localhost/cgi-bin/man/man2html
29 | # to work.
30 | install-man-scripts:
31 | mkdir -p $(httpdir)/cgi-bin/man
32 | mkdir -p $(httpdir)/cgi-aux/man
33 | install -m 755 scripts/cgi-bin/man/* $(httpdir)/cgi-bin/man
34 | install -m 644 scripts/cgi-aux/man/* $(httpdir)/cgi-aux/man
35 | install -d -o $(cgiowner) -g $(cgigroup) -m 775 $(vardir)/man2html
36 | # (aux was renamed to cgi-aux since aux causes problems under DOS)
37 |
38 | # If you have installed glimpse, and have compressed man pages,
39 | # then perhaps you also want these filters.
40 | install-glimpse-stuff:
41 | install -m 644 glimpse_filters $(vardir)/man2html/.glimpse_filters
42 |
43 | # In order not to have to type a long command like
44 | # netscape http://localhost/cgi-bin/man/man2html?section+topic
45 | # or
46 | # lynx lynxcgi:/home/httpd/cgi-bin/man/man2html?section+topic
47 | # it is convenient to have some shell script as a wrapper.
48 | # The script hman can be aliased to man. It uses an environment
49 | # variable MANHTMLPAGER to find out which browser you use, and
50 | # you can set MANHTMLHOST if the pages are not on localhost.
51 | hman: hman.sh
52 | rm -f hman
53 | sed -e 's,%version%,@version@,' hman.sh > hman
54 |
55 | install-hman: hman
56 | install -m 555 hman $(bindir)/hman
57 | install -m 644 hman.1 $(mandir)/man1/hman.@man1ext@
58 |
59 | clean:
60 | rm -f core hman man2html $(OBJECTS) *~
61 |
62 | spotless: clean
63 | rm -f Makefile
64 |
65 | $(OBJECTS): defs.h
66 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | This directory contains the following.
2 |
3 | 1. man2html
4 |
5 | This is a pure manroff -> html converter.
6 | No manpath search etc.
7 |
8 | Call: man2html [-l | -H host.domain:port] [filename]
9 |
10 | The contents of FILENAME (or STDIN, in case FILENAME is "-" or absent)
11 | are converted from man-style nroff to html, and printed on STDOUT.
12 |
13 | With "-l" URLs of the form "lynxcgi:/home/httpd/cgi-bin/..." are generated.
14 | With "-H host" we make URLs of the form "http://host/cgi-bin/...".
15 | The default is "http://localhost/cgi-bin/...".
16 |
17 | 2. A collection of scripts
18 |
19 | This part is not installed by "make install" of the global Makefile.
20 | There are security considerations: it is very unlikely that these
21 | scripts (still in alpha) are secure, so for the time being they
22 | should only be used where security is not a major concern.
23 |
24 | If you are not afraid, or are not running a httpd, do
25 | "make install-scripts" in this directory.
26 | This does three things: install man stuff, install glimpse stuff,
27 | and install user interface stuff.
28 |
29 | 2A. man stuff
30 |
31 | This first part (that can be done separately with "make install-man-scripts")
32 | puts various scripts under /home/httpd/cgi-bin and /home/httpd/cgi-aux
33 | in a subdirectory man.
34 | It will create a directory /var/man2html to hold the indices.
35 | (This directory should be writable by the cgi scripts;
36 | probably that means that the owner should be nobody.
37 | Choose a group and add all non-httpd users that should be
38 | able to write this directory to that group.)
39 |
40 | Structure of the collection of scripts:
41 | man2html is the main script.
42 | It uses man.aux when called without arguments.
43 | It uses manwhatis when asked for an index of manpages+descriptions.
44 | It uses mansec when asked for a compact index of manpages.
45 | It uses mansearch when asked for a glimpse search.
46 | In its turn mansearch uses mansearch.aux when called
47 | without arguments. It uses mansearchhelp (which uses
48 | mansearchhelp.aux) when asked for help.
49 |
50 | 2B. glimpse stuff
51 | The second part (that can be done separately with
52 | "make install-glimpse-stuff") installs .glimpse_filters
53 | in /var/man2html, in order to tell glimpse what decompressors to use.
54 |
55 | 2C. user interface stuff
56 | The third part (that can be done separately with "make install-hman")
57 | installs a user interface to these scripts in /usr/bin/hman.
58 | Now people can say
59 | alias man=/usr/bin/hman
60 | and have a man that uses a html browser.
61 | The browser is chosen via environment variables - look at the script.
62 |
63 | 3. Glimpse.
64 |
65 | For the glimpse part, I quote Michael Hamilton:
66 | ----------------------------------------------------------------------
67 | To use the Glimpse full text searching, you will need to install
68 | glimpse in /usr/bin. Redhat rpm users can get glimpse from
69 |
70 | ftp://ftp.redhat.com/pub/contrib/i386/glimpse-4.0-6.i386.rpm
71 |
72 | The glimpse home ftp site is cs.arizona.edu. N.B. glimpse is not
73 | freely redistributable for commercial use, I'd be very interested in a
74 | more liberal alternative. Having installed glimpse, you will need to
75 | build a glimpse index in /var/man2html. This doesn't take too long -
76 | about 3 minutes on my 486DX2/66 16MB machine. As root do:
77 |
78 | /usr/bin/glimpseindex -z -H /var/man2html /usr/man/man* /usr/X11R6/man/man* \
79 | /usr/local/man/man* /opt/man/man*
80 | chmod ugo+r /var/man2html/.glimpse*
81 |
82 | The -z option causes glimpse to apply any filters (for decompression etc)
83 | specified in /var/man2html/.glimpse_filters.
84 |
85 | This could be set up as a cron job in /etc/crontab, e.g. (the following
86 | must be all on one line):
87 |
88 | 21 04 * * 1 root /usr/bin/glimpseindex -z -H /var/man2html /usr/man/man*
89 | /usr/X11R6/man/man* /usr/local/man/man* /opt/man/man* ;
90 | chmod +r /var/man2html/.glimpse*
91 | --------------------------------------------------------------------------
92 |
--------------------------------------------------------------------------------
/TODO:
--------------------------------------------------------------------------------
1 | There are still many problems with man2html.
2 | Partly these are caused by the imprecise definition
3 | of the man file format. (And the many buggy man pages.)
4 | Partly by the incomplete implementation of the man/doc macro packages.
5 | Partly by the imperfect emulation of troff.
6 | Partly by the variation between various browsers in the
7 | accepted html.
8 | Partly just because man2html is buggy.
9 |
10 | Of course in reality a man2html converter must contain
11 | large parts of the troff source, so that it can be fed
12 | with the defining macro packages and always do the right thing.
13 |
14 | On a RedHat 5.0 system:
15 | - /usr/man/mann/DirDlg.n is not formatted correctly.
16 | (It does not start with .TH)
17 | - bug_readline@prep.ai.mit.edu does not generate
18 | a mailto: link. It should generate
19 | nroff and troff",
31 | "INDEX", "Global Index",
32 | "CPG", "C Programmer's Guide",
33 | "CREF", "C Reference Manual",
34 | "ASSY", "Assembly Language Reference",
35 | "PUL", "Programming Utilities and Libraries",
36 | "DEBUG", "Debugging Tools",
37 | "NETP", "Network Programming",
38 | "DRIVER", "Writing Device Drivers",
39 | "STREAMS", "STREAMS Programming",
40 | "SBDK", "SBus Developer's Kit",
41 | "WDDS", "Writing Device Drivers for the SBus",
42 | "FPOINT", "Floating-Point Programmer's Guide",
43 | "SVPG", "SunView 1 Programmer's Guide",
44 | "SVSPG", "SunView 1 System Programmer's Guide",
45 | "PIXRCT", "Pixrect Reference Manual",
46 | "CGI", "SunCGI Reference Manual",
47 | "CORE", "SunCore Reference Manual",
48 | "4ASSY", "Sun-4 Assembly Language Reference",
49 | "SARCH", "SPARC Architecture Manual",
50 | "KR", "The C Programming Language",
51 | 0, 0 };
52 |
53 | char *lookup_abbrev (char *s)
54 | {
55 | int i=0;
56 |
57 | if (!s)
58 | return "";
59 | while (abbrev_list[i] && strcmp(s, abbrev_list[i]))
60 | i = i+2;
61 | return abbrev_list[i] ? abbrev_list[i+1] : s;
62 | }
63 |
--------------------------------------------------------------------------------
/cgibase.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Here are the routines of man2html that output a HREF string.
3 | */
4 |
5 | #include "); else {
1816 | out_html(NEWLINE);
1817 | NEWLINE[0]='\n';
1818 | }
1819 | curpos=0;
1820 | c=skip_till_newline(c);
1821 | break;
1822 | case V('s','o'):
1823 | {
1824 | FILE *f;
1825 | struct stat stbuf;
1826 | int l; char *buf;
1827 | char *name = NULL;
1828 |
1829 | curpos=0;
1830 | c += j; /* skip .so part and whitespace */
1831 | if (*c == '/') {
1832 | h = c;
1833 | } else { /* .so man3/cpow.3 -> ../man3/cpow.3 */
1834 | h = c-3;
1835 | h[0] = '.';
1836 | h[1] = '.';
1837 | h[2] = '/';
1838 | }
1839 | while (*c != '\n') c++;
1840 | while (c[-1] == ' ') c--;
1841 | while (*c != '\n') *c++ = 0;
1842 | *c = 0;
1843 | scan_troff(h,1, &name);
1844 | if (name[3] == '/') h=name+3; else h=name;
1845 | l = 0;
1846 | if (stat(h, &stbuf)!=-1) l=stbuf.st_size;
1847 | buf = (char*) xmalloc((l+4)*sizeof(char));
1848 | #if NOCGI
1849 | if (!out_length) {
1850 | char *t,*s;
1851 | t=strrchr(fname, '/');
1852 | if (!t) t=fname;
1853 | fprintf(stderr, "ln -s %s.html %s.html\n", h, t);
1854 | s=strrchr(t, '.');if (!s) s=t;
1855 | printf("
\n"
83 | "This document was created by\n"
84 | "man2html,\n"
85 | "using the manual pages.
\n"
86 | "%s\n";
87 |
88 | #define TIMEFORMAT "%T GMT, %B %d, %Y"
89 | #define TIMEBUFSZ 500
90 |
91 | void print_sig()
92 | {
93 | char timebuf[TIMEBUFSZ];
94 | struct tm *timetm;
95 | time_t clock;
96 |
97 | timebuf[0] = 0;
98 | #ifdef TIMEFORMAT
99 | sprintf(timebuf, "Time: ");
100 | clock=time(NULL);
101 | timetm=gmtime(&clock);
102 | strftime(timebuf+6, TIMEBUFSZ-6, TIMEFORMAT, timetm);
103 | timebuf[TIMEBUFSZ-1] = 0;
104 | #endif
105 | //printf(signature, cgibase, man2htmlpath, timebuf);
106 | printf(signature, timebuf);
107 | }
108 |
109 | void
110 | include_file_html(char *g) {
111 | printf("%s>", g,g);
112 | }
113 |
114 | void
115 | man_page_html(char *sec, char *h) {
116 | if (current_html_style) {
117 | if (!h)
118 | printf(""
119 | "Return to Main Contents");
120 | else
121 | printf("%s",
122 | h, h);
123 | } else if (relat_html_style) {
124 | if (!h)
125 | printf(""
126 | "Return to Main Contents");
127 | else
128 | printf("%s",
129 | sec, h, sec, h);
130 | } else {
131 | if (!h)
132 | printf("Return to Main Contents",
133 | cgibase, man2htmlpath);
134 | else if (!sec)
135 | printf("%s",
136 | cgibase, man2htmlpath, sep, h, h);
137 | else
138 | printf("%s",
139 | cgibase, man2htmlpath, sep, sec, h, h);
140 | }
141 | }
142 |
143 | void
144 | ftp_html(char *f) {
145 | printf("%s", f, f);
146 | }
147 |
148 | void
149 | www_html(char *f) {
150 | printf("%s", f, f);
151 | }
152 |
153 | void
154 | mailto_html(char *g) {
155 | printf("%s", g, g);
156 | }
157 |
158 | void
159 | url_html(char *g) {
160 | printf("%s", g, g);
161 | }
162 |
--------------------------------------------------------------------------------
/defs.h:
--------------------------------------------------------------------------------
1 | extern int nroff;
2 | extern int local_lynx;
3 |
4 | typedef struct STRDEF STRDEF;
5 | struct STRDEF {
6 | int nr,slen;
7 | char *st;
8 | STRDEF *next;
9 | };
10 |
11 | typedef struct INTDEF INTDEF;
12 | struct INTDEF {
13 | int nr;
14 | int val;
15 | int incr;
16 | INTDEF *next;
17 | };
18 |
19 | extern STRDEF *chardef, *strdef, *defdef;
20 | extern INTDEF *intdef;
21 |
22 | #define V(A,B) ((A)*256+(B))
23 |
24 | #include \n", "
\n", "", "" };
356 |
357 | static inline void
358 | dl_begin(void) {
359 | if (itemdepth < SIZE(dl_set) && dl_set[itemdepth] == noDL) {
360 | out_html(dl_open[DL]);
361 | dl_set[itemdepth]=DL;
362 | }
363 | out_html("", "
" };
355 | static char *dl_close[4] = { "", "
\n");
390 | itemdepth--;
391 | }
392 | }
393 |
394 | static inline void
395 | dl_down(void) {
396 | while (itemdepth)
397 | dl_endlevel();
398 | dl_end();
399 | }
400 |
401 | static inline int
402 | dl_type(int type) {
403 | return (itemdepth < SIZE(dl_set) && dl_set[itemdepth] == type);
404 | }
405 |
406 | static inline void
407 | dl_newlevel_type(int type) {
408 | itemdepth++;
409 | if (itemdepth < SIZE(dl_set)) {
410 | dl_set[itemdepth]=type;
411 | out_html(dl_open[type]);
412 | }
413 | }
414 |
415 | static inline void
416 | dl_endlevel_type(void) {
417 | if (itemdepth) {
418 | if (itemdepth < SIZE(dl_set))
419 | out_html(dl_close[dl_set[itemdepth]]);
420 | itemdepth--;
421 | }
422 | }
423 | /* --------------------------------------------------------------- */
424 | /* This stuff is broken.
425 | It generates
426 |
"; curpos=0;
647 | case 'b':
648 | case 'v':
649 | case 'x':
650 | case 'o':
651 | case 'L':
652 | case 'h':
653 | c++;
654 | i=*c;
655 | c++;
656 | exoutputp=output_possible;
657 | exskipescape=skip_escape;
658 | output_possible=0;
659 | skip_escape=1;
660 | while (*c != i)
661 | if (*c==escapesym) c=scan_escape(c+1);
662 | else c++;
663 | output_possible=exoutputp;
664 | skip_escape=exskipescape;
665 | break;
666 | case 'c': no_newline_output=1; break;
667 | case '{': newline_for_fun++; h="";break;
668 | case '}': if (newline_for_fun) newline_for_fun--; h="";break;
669 | case 'p': h="
\n";curpos=0; break;
670 | case 't': h="\t";curpos=(curpos+8)&0xfff8; break;
671 | case '<': h="<";curpos++; break;
672 | case '>': h=">";curpos++; break;
673 | case '\\': if (single_escape) { c--; break;}
674 | default: b[0]=*c; b[1]=0; h=b; curpos++; break;
675 | }
676 | c++;
677 | if (!skip_escape) out_html(h);
678 | return c;
679 | }
680 |
681 | typedef struct TABLEITEM TABLEITEM;
682 |
683 | struct TABLEITEM {
684 | char *contents;
685 | int size,align,valign,colspan,rowspan,font,vleft,vright,space,width;
686 | TABLEITEM *next;
687 | };
688 |
689 | static TABLEITEM emptyfield = {NULL,0,0,0,1,1,0,0,0,0,0,NULL};
690 | typedef struct TABLEROW TABLEROW;
691 |
692 | struct TABLEROW {
693 | TABLEITEM *first;
694 | TABLEROW *prev, *next;
695 | };
696 |
697 | static char *tableopt[]= { "center", "expand", "box", "allbox", "doublebox",
698 | "tab", "linesize", "delim", NULL };
699 | static int tableoptl[] = { 6,6,3,6,9,3,8,5,0};
700 |
701 |
702 | static void clear_table(TABLEROW *table)
703 | {
704 | TABLEROW *tr1,*tr2;
705 | TABLEITEM *ti1,*ti2;
706 |
707 | tr1=table;
708 | while (tr1->prev) tr1=tr1->prev;
709 | while (tr1) {
710 | ti1=tr1->first;
711 | while (ti1) {
712 | ti2=ti1->next;
713 | if (ti1->contents) free(ti1->contents);
714 | free(ti1);
715 | ti1=ti2;
716 | }
717 | tr2=tr1;
718 | tr1=tr1->next;
719 | free(tr2);
720 | }
721 | }
722 |
723 | char *scan_expression(char *c, int *result);
724 |
725 | static char *scan_format(char *c, TABLEROW **result, int *maxcol)
726 | {
727 | TABLEROW *layout, *currow;
728 | TABLEITEM *curfield;
729 | int i,j;
730 | if (*result) {
731 | clear_table(*result);
732 | }
733 | layout= currow=(TABLEROW*) xmalloc(sizeof(TABLEROW));
734 | currow->next=currow->prev=NULL;
735 | currow->first=curfield=(TABLEITEM*) xmalloc(sizeof(TABLEITEM));
736 | *curfield=emptyfield;
737 | while (*c && *c!='.') {
738 | switch (*c) {
739 | case 'C': case 'c': case 'N': case 'n':
740 | case 'R': case 'r': case 'A': case 'a':
741 | case 'L': case 'l': case 'S': case 's':
742 | case '^': case '_':
743 | if (curfield->align) {
744 | curfield->next=(TABLEITEM*)xmalloc(sizeof(TABLEITEM));
745 | curfield=curfield->next;
746 | *curfield=emptyfield;
747 | }
748 | curfield->align=toupper(*c);
749 | c++;
750 | break;
751 | case 'i': case 'I': case 'B': case 'b':
752 | curfield->font = toupper(*c);
753 | c++;
754 | break;
755 | case 'f': case 'F':
756 | c++;
757 | curfield->font = toupper(*c);
758 | c++;
759 | if (!isspace(*c)) c++;
760 | break;
761 | case 't': case 'T': curfield->valign='t'; c++; break;
762 | case 'p': case 'P':
763 | c++;
764 | i=j=0;
765 | if (*c=='+') { j=1; c++; }
766 | if (*c=='-') { j=-1; c++; }
767 | while (isdigit(*c)) i=i*10+(*c++)-'0';
768 | if (j) curfield->size= i*j; else curfield->size=j-10;
769 | break;
770 | case 'v': case 'V':
771 | case 'w': case 'W':
772 | // c=scan_expression(c+2,&curfield->width);
773 | c++;
774 | if (*c == '(') {
775 | c=scan_expression(c+1,&curfield->width);
776 | } else {
777 | i=0;
778 | while (isdigit(*c)) i=i*10+(*c++)-'0';
779 | curfield->width=i;
780 | }
781 | break;
782 | case '|':
783 | if (curfield->align) curfield->vleft++;
784 | else curfield->vright++;
785 | c++;
786 | break;
787 | case 'e': case 'E':
788 | c++;
789 | break;
790 | case '0': case '1': case '2': case '3': case '4':
791 | case '5': case '6': case '7': case '8': case '9':
792 | i=0;
793 | while (isdigit(*c)) i=i*10+(*c++)-'0';
794 | curfield->space=i;
795 | break;
796 | case ',': case '\n':
797 | currow->next=(TABLEROW*)xmalloc(sizeof(TABLEROW));
798 | currow->next->prev=currow;
799 | currow=currow->next;
800 | currow->next=NULL;
801 | curfield=currow->first=(TABLEITEM*)xmalloc(sizeof(TABLEITEM));
802 | *curfield=emptyfield;
803 | c++;
804 | break;
805 | default:
806 | c++;
807 | break;
808 | }
809 | }
810 | if (*c=='.') while (*c++!='\n');
811 | *maxcol=0;
812 | currow=layout;
813 | while (currow) {
814 | curfield=layout->first;
815 | i=0;
816 | while (curfield) {
817 | i++;
818 | curfield=curfield->next;
819 | }
820 | if (i>*maxcol) *maxcol=i;
821 | currow=currow->next;
822 | }
823 | *result=layout;
824 | return c;
825 | }
826 |
827 | static TABLEROW *
828 | next_row(TABLEROW *tr)
829 | {
830 | if (tr->next) {
831 | tr=tr->next;
832 | if (!tr->next) next_row(tr);
833 | return tr;
834 | } else {
835 | TABLEITEM *ti, *ti2;
836 | tr->next=(TABLEROW*)xmalloc(sizeof(TABLEROW));
837 | tr->next->prev=tr;
838 | ti=tr->first;
839 | tr=tr->next;
840 | tr->next=NULL;
841 | if (ti) tr->first=ti2=(TABLEITEM*) xmalloc(sizeof(TABLEITEM));
842 | else tr->first=ti2=NULL;
843 | while (ti!=ti2) {
844 | *ti2=*ti;
845 | ti2->contents=NULL;
846 | if ((ti=ti->next)) {
847 | ti2->next=(TABLEITEM*) xmalloc(sizeof(TABLEITEM));
848 | }
849 | ti2=ti2->next;
850 | }
851 | return tr;
852 | }
853 | }
854 |
855 | char itemreset[20]="\\fR\\s0";
856 |
857 | static char *
858 | scan_table(char *c) {
859 | char *h;
860 | char *g;
861 | int center=0, expand=0, box=0, border=0, linesize=1;
862 | int i,j,maxcol=0, finished=0;
863 | int oldfont, oldsize,oldfillout;
864 | char itemsep='\t';
865 | TABLEROW *layout=NULL, *currow;
866 | TABLEITEM *curfield;
867 | while (*c++!='\n'); /* skip TS */
868 | h=c;
869 | if (*h=='.') return c-1;
870 | oldfont=current_font;
871 | oldsize=current_size;
872 | oldfillout=fillout;
873 | out_html(change_to_font(0));
874 | out_html(change_to_size(0));
875 | if (!fillout) {
876 | fillout=1;
877 | out_html("");
878 | }
879 | while (*h && *h!='\n') h++;
880 | if (h[-1]==';') {
881 | /* scan table options */
882 | while (c
");
1122 | if (center) out_html("");
1055 | out_html("
");
1121 | if (box==2) out_html("\n");
1062 | currow=layout;
1063 | while (currow) {
1064 | j=0;
1065 | out_html("
");
1120 | out_html("");
1066 | curfield=currow->first;
1067 | while (curfield) {
1068 | if (curfield->align!='S' && curfield->align!='^') {
1069 | out_html(" \n");
1117 | currow=currow->next;
1118 | }
1119 | if (box && !border) out_html("align) {
1071 | case 'N':
1072 | curfield->space+=4;
1073 | case 'R':
1074 | out_html(" ALIGN=right");
1075 | break;
1076 | case 'C':
1077 | out_html(" ALIGN=center");
1078 | default:
1079 | break;
1080 | }
1081 | if (!curfield->valign && curfield->rowspan>1)
1082 | out_html(" VALIGN=center");
1083 | if (curfield->colspan>1) {
1084 | char buf[5];
1085 | out_html(" COLSPAN=");
1086 | sprintf(buf, "%i", curfield->colspan);
1087 | out_html(buf);
1088 | }
1089 | if (curfield->rowspan>1) {
1090 | char buf[5];
1091 | out_html(" ROWSPAN=");
1092 | sprintf(buf, "%i", curfield->rowspan);
1093 | out_html(buf);
1094 | }
1095 | j=j+curfield->colspan;
1096 | out_html(">");
1097 | if (curfield->size) out_html(change_to_size(curfield->size));
1098 | if (curfield->font) out_html(change_to_font(curfield->font));
1099 | switch (curfield->align) {
1100 | case '=': out_html(" ");
1113 | }
1114 | curfield=curfield->next;
1115 | }
1116 | out_html("
"); break;
1101 | case '_': out_html("
"); break;
1102 | default:
1103 | if (curfield->contents) out_html(curfield->contents);
1104 | break;
1105 | }
1106 | if (curfield->space)
1107 | for (i=0; i
");
1112 | out_html("");
1125 | fillout=oldfillout;
1126 | out_html(change_to_size(oldsize));
1127 | out_html(change_to_font(oldfont));
1128 | return c;
1129 | }
1130 |
1131 | char *scan_expression(char *c, int *result) {
1132 | int value=0,value2,sign=1,opex=0;
1133 | char oper='c';
1134 |
1135 | if (*c=='!') {
1136 | c=scan_expression(c+1, &value);
1137 | value= (!value);
1138 | } else if (*c=='n') {
1139 | c++;
1140 | value=nroff;
1141 | } else if (*c=='t') {
1142 | c++;
1143 | value=1-nroff;
1144 | } else if (*c=='\'' || *c=='"' || *c<' ' || (*c=='\\' && c[1]=='(')) {
1145 | /* ?string1?string2?
1146 | ** test if string1 equals string2.
1147 | */
1148 | char *st1=NULL, *st2=NULL, *h;
1149 | char *tcmp=NULL;
1150 | char sep;
1151 | sep=*c;
1152 | if (sep=='\\') {
1153 | tcmp=c;
1154 | c=c+3;
1155 | }
1156 | c++;
1157 | h=c;
1158 | while (*c!= sep && (!tcmp || strncmp(c,tcmp,4))) c++;
1159 | *c='\n';
1160 | scan_troff(h, 1, &st1);
1161 | *c=sep;
1162 | if (tcmp) c=c+3;
1163 | c++;
1164 | h=c;
1165 | while (*c!=sep && (!tcmp || strncmp(c,tcmp,4))) c++;
1166 | *c='\n';
1167 | scan_troff(h,1,&st2);
1168 | *c=sep;
1169 | if (!st1 && !st2) value=1;
1170 | else if (!st1 || !st2) value=0;
1171 | else value=(!strcmp(st1, st2));
1172 | if (st1) free(st1);
1173 | if (st2) free(st2);
1174 | if (tcmp) c=c+3;
1175 | c++;
1176 | } else {
1177 | while (*c && !isspace(*c) && *c!=')') {
1178 | opex=0;
1179 | switch (*c) {
1180 | case '(':
1181 | c=scan_expression(c+1, &value2);
1182 | value2=sign*value2;
1183 | opex=1;
1184 | break;
1185 | case '.':
1186 | case '0': case '1':
1187 | case '2': case '3':
1188 | case '4': case '5':
1189 | case '6': case '7':
1190 | case '8': case '9': {
1191 | int num=0,denum=1;
1192 | value2=0;
1193 | while (isdigit(*c)) value2=value2*10+((*c++)-'0');
1194 | if (*c=='.') {
1195 | c++;
1196 | while (isdigit(*c)) {
1197 | num=num*10+((*c++)-'0');
1198 | denum=denum*10;
1199 | }
1200 | }
1201 | if (isalpha(*c)) {
1202 | /* scale indicator */
1203 | switch (*c) {
1204 | case 'i': /* inch -> 10pt */
1205 | value2=value2*10+(num*10+denum/2)/denum;
1206 | num=0;
1207 | break;
1208 | default:
1209 | break;
1210 | }
1211 | c++;
1212 | }
1213 | value2=value2+(num+denum/2)/denum;
1214 | value2=sign*value2;
1215 | opex=1;
1216 | break;
1217 | }
1218 | case '\\':
1219 | c=scan_escape(c+1);
1220 | value2=intresult*sign;
1221 | if (isalpha(*c)) c++; /* scale indicator */
1222 | opex=1;
1223 | break;
1224 | case '-':
1225 | if (oper) { sign=-1; c++; break; }
1226 | case '>':
1227 | case '<':
1228 | case '+':
1229 | case '/':
1230 | case '*':
1231 | case '%':
1232 | case '&':
1233 | case '=':
1234 | case ':':
1235 | if (c[1]=='=') oper=(*c++) +16; else oper=*c;
1236 | c++;
1237 | break;
1238 | default: c++; break;
1239 | }
1240 | if (opex) {
1241 | sign=1;
1242 | switch (oper) {
1243 | case 'c': value=value2; break;
1244 | case '-': value=value-value2; break;
1245 | case '+': value=value+value2; break;
1246 | case '*': value=value*value2; break;
1247 | case '/': if (value2) value=value/value2; break;
1248 | case '%': if (value2) value=value%value2; break;
1249 | case '<': value=(value
\n");
1720 | }
1721 | curpos=0;
1722 | fillout=1;
1723 | c=skip_till_newline(c);
1724 | break;
1725 | case V('f','t'):
1726 | c=c+j;
1727 | if (*c == '\n') {
1728 | out_html(change_to_font(0));
1729 | } else {
1730 | if (*c == escapesym) {
1731 | int fn;
1732 | c=scan_expression(c, &fn);
1733 | c--;
1734 | out_html(change_to_font(fn));
1735 | } else {
1736 | out_html(change_to_font(*c));
1737 | c++;
1738 | }
1739 | }
1740 | c=skip_till_newline(c);
1741 | break;
1742 | case V('e','l'):
1743 | /* .el anything : else part of if else */
1744 | if (ifelseval) {
1745 | c=c+j;
1746 | c[-1]='\n';
1747 | c=scan_troff(c,1,NULL);
1748 | } else
1749 | c=skip_till_newline(c+j);
1750 | break;
1751 | case V('i','e'):
1752 | /* .ie c anything : then part of if else */
1753 | case V('i','f'):
1754 | /* .if c anything
1755 | * .if !c anything
1756 | * .if N anything
1757 | * .if !N anything
1758 | * .if 'string1'string2' anything
1759 | * .if !'string1'string2' anything
1760 | */
1761 | c=c+j;
1762 | c=scan_expression(c, &i);
1763 | ifelseval=!i;
1764 | if (i) {
1765 | *c='\n';
1766 | c++;
1767 | c=scan_troff(c,1,NULL);
1768 | } else
1769 | c=skip_till_newline(c);
1770 | break;
1771 | case V('i','g'): /* .ig: ignore until .. */
1772 | {
1773 | char *endwith="..\n";
1774 | i=3;
1775 | c=c+j;
1776 | while (*c == ' ') c++;
1777 | if (*c == escapesym && c[1] == '"')
1778 | while (*c != '\n') c++;
1779 | if (*c!='\n') { /* .ig yy: ignore until .yy, then call .yy */
1780 | endwith=c-1;i=1;
1781 | c[-1]='.';
1782 | while (*c && *c!='\n') c++,i++;
1783 | }
1784 | c++;
1785 | while (*c && strncmp(c,endwith,i))
1786 | while (*c && *c++!='\n');
1787 | while (*c && *c++!='\n');
1788 | break;
1789 | }
1790 | case V('n','f'):
1791 | if (fillout) {
1792 | out_html(change_to_font(0));
1793 | out_html(change_to_size('0'));
1794 | out_html("\n");
1489 | mip += 5;
1490 | }
1491 | }
1492 | subs = level;
1493 |
1494 | scan_troff(item, 1, &c);
1495 | manidx_need(100 + strlen(c));
1496 | sprintf(manidx+mip, "
\n");
1649 | curpos=0;
1650 | c=c+j;
1651 | if (c[0] == escapesym) { c=scan_escape(c+1); }
1652 | c=skip_till_newline(c);break;
1653 | case V('c','2'):
1654 | c=c+j;
1655 | if (*c!='\n') { nobreaksym=*c; }
1656 | else nobreaksym='\'';
1657 | c=skip_till_newline(c);
1658 | break;
1659 | case V('c','c'):
1660 | c=c+j;
1661 | if (*c!='\n') { controlsym=*c; }
1662 | else controlsym='.';
1663 | c=skip_till_newline(c);
1664 | break;
1665 | case V('c','e'):
1666 | c=c+j;
1667 | if (*c == '\n') { i=1; }
1668 | else {
1669 | i=0;
1670 | while ('0'<=*c && *c<='9') {
1671 | i=i*10+*c-'0';
1672 | c++;
1673 | }
1674 | }
1675 | c=skip_till_newline(c);
1676 | /* center next i lines */
1677 | if (i>0) {
1678 | out_html("
", 4)) {
1683 | out_html(line);
1684 | out_html("
\n");
1685 | i--;
1686 | }
1687 | }
1688 | out_html("\n");
1795 | }
1796 | curpos=0;
1797 | fillout=0;
1798 | c=skip_till_newline(c);
1799 | break;
1800 | case V('p','s'):
1801 | c=c+j;
1802 | if (*c == '\n') {
1803 | out_html(change_to_size('0'));
1804 | } else {
1805 | j=0;i=0;
1806 | if (*c == '-') { j= -1;c++; } else if (*c == '+') { j=1;c++;}
1807 | c=scan_expression(c, &i);
1808 | if (!j) { j=1; if (i>5) i=i-10; }
1809 | out_html(change_to_size(i*j));
1810 | }
1811 | c=skip_till_newline(c);
1812 | break;
1813 | case V('s','p'):
1814 | c=c+j;
1815 | if (fillout) out_html("
"
1868 | "man2html: unable to open or read file\n");
1869 | out_html(h);
1870 | out_html("
\n");
1871 | } else {
1872 | i=fread(buf+1,1,l,f);
1873 | fclose(f);
1874 | buf[0]=buf[l]='\n';
1875 | buf[l+1]=buf[l+2]=0;
1876 | scan_troff(buf+1,0,NULL);
1877 | }
1878 | if (buf) free(buf);
1879 | }
1880 | *c++='\n';
1881 | break;
1882 | }
1883 | case V('t','a'):
1884 | c=c+j;
1885 | j=0;
1886 | while (*c!='\n') {
1887 | sl=scan_expression(c, &tabstops[j]);
1888 | if (*c == '-' || *c == '+') tabstops[j]+=tabstops[j-1];
1889 | c=sl;
1890 | while (*c == ' ' || *c == '\t') c++;
1891 | if (j+1 < SIZE(tabstops))
1892 | j++;
1893 | }
1894 | maxtstop=j;
1895 | curpos=0;
1896 | break;
1897 | case V('t','i'):
1898 | #if 0
1899 | dl_down();
1900 | #endif
1901 | out_html("
\n");
1902 | c=c+j;
1903 | c=scan_expression(c, &j);
1904 | for (i=0; i
\n"); else { 2020 | out_html(NEWLINE); 2021 | NEWLINE[0]='\n'; 2022 | } 2023 | curpos=0; 2024 | c=skip_till_newline(c); 2025 | break; 2026 | case V('H','P'): 2027 | dl_begin(); 2028 | still_dd=1; 2029 | c=skip_till_newline(c); 2030 | curpos=0; 2031 | break; 2032 | case V('P','D'): 2033 | c=skip_till_newline(c); 2034 | break; 2035 | case V('R','s'): /* BSD mandoc */ 2036 | case V('R','S'): 2037 | sl = fill_words(c+j, wordlist, SIZE(wordlist), &words, '\n'); 2038 | j = 1; 2039 | if (words>0) scan_expression(wordlist[0], &j); 2040 | if (j>=0) { 2041 | dl_newlevel(); 2042 | c=skip_till_newline(c); 2043 | curpos=0; 2044 | break; 2045 | } 2046 | case V('R','e'): /* BSD mandoc */ 2047 | case V('R','E'): 2048 | dl_endlevel(); 2049 | c=skip_till_newline(c); 2050 | curpos=0; 2051 | break; 2052 | case V('S','B'): 2053 | out_html(change_to_size(-1)); 2054 | out_html(change_to_font('B')); 2055 | c=scan_troff(c+j, 1, NULL); 2056 | out_html(change_to_font('R')); 2057 | out_html(change_to_size('0')); 2058 | break; 2059 | case V('S','M'): 2060 | c=c+j; 2061 | if (*c == '\n') c++; 2062 | out_html(change_to_size(-1)); 2063 | trans_char(c,'"','\a'); 2064 | c=scan_troff(c,1,NULL); 2065 | out_html(change_to_size('0')); 2066 | break; 2067 | case V('S','s'): /* BSD mandoc */ 2068 | mandoc_command = 1; 2069 | case V('S','S'): 2070 | mode=1; 2071 | goto sh_below; 2072 | case V('S','h'): /* BSD mandoc */ 2073 | mandoc_command = 1; 2074 | case V('S','H'): 2075 | sh_below: 2076 | c=c+j; 2077 | if (*c == '\n') c++; 2078 | dl_down(); 2079 | out_html(change_to_font(0)); 2080 | out_html(change_to_size(0)); 2081 | if (!fillout) { 2082 | fillout=1; 2083 | out_html(""); 2084 | } 2085 | trans_char(c,'"', '\a'); 2086 | add_to_index(mode, c); 2087 | out_html(" \n
\n"); else { 2291 | out_html(NEWLINE); 2292 | NEWLINE[0]='\n'; 2293 | } 2294 | curpos=0; 2295 | c=skip_till_newline(c); 2296 | break; 2297 | } 2298 | case V('E','l'): /* BSD mandoc */ 2299 | c=c+j; 2300 | dl_endlevel_type(); 2301 | if (fillout) out_html("
\n"); else { 2302 | out_html(NEWLINE); 2303 | NEWLINE[0]='\n'; 2304 | } 2305 | curpos=0; 2306 | c=skip_till_newline(c); 2307 | break; 2308 | case V('I','t'): /* BSD mandoc */ 2309 | c=c+j; 2310 | if (dl_type(DL)) { 2311 | out_html("
"); 2378 | out_html(change_to_font('L')); 2379 | if (*c == '\n') c++; 2380 | c=scan_troff_mandoc(c, 1, NULL); 2381 | out_html(change_to_font('R')); 2382 | out_html(""); 2383 | if (fillout) curpos++; else curpos=0; 2384 | break; 2385 | case V('B','d'): /* BSD mandoc */ 2386 | { /* Seems like a kind of example/literal mode */ 2387 | char *nl, t=0 /* just for gcc */; 2388 | c=c+j; 2389 | nl = strchr(c,'\n'); 2390 | if (nl) { 2391 | t = *nl; 2392 | *nl = 0; 2393 | } 2394 | out_html(NEWLINE); 2395 | mandoc_bd_options = 0; /* Remember options for terminating Bl */ 2396 | if (strstr(c, "-offset indent")) { 2397 | mandoc_bd_options |= BD_INDENT; 2398 | out_html("
\n"); 2399 | } 2400 | if (strstr(c, "-literal") || strstr(c, "-unfilled")) { 2401 | if (fillout) { 2402 | mandoc_bd_options |= BD_LITERAL; 2403 | out_html(change_to_font(0)); 2404 | out_html(change_to_size('0')); 2405 | out_html("\n"); 2425 | curpos=0; 2426 | fillout=1; 2427 | c=skip_till_newline(c); 2428 | break; 2429 | case V('B','e'): /* BSD mandoc */ 2430 | c=c+j; 2431 | if (fillout) out_html("\n"); 2406 | } 2407 | curpos=0; 2408 | fillout=0; 2409 | } 2410 | if (nl) 2411 | *nl = t; 2412 | c=skip_till_newline(c); 2413 | break; 2414 | } 2415 | case V('E','d'): /* BSD mandoc */ 2416 | if (mandoc_bd_options & BD_LITERAL) { 2417 | if (!fillout) { 2418 | out_html(change_to_font(0)); 2419 | out_html(change_to_size('0')); 2420 | out_html("\n"); 2421 | } 2422 | } 2423 | if (mandoc_bd_options & BD_INDENT) 2424 | out_html("
"); else { 2432 | out_html(NEWLINE); 2433 | NEWLINE[0]='\n'; 2434 | } 2435 | curpos=0; 2436 | c=skip_till_newline(c); 2437 | break; 2438 | case V('X','r'): /* BSD mandoc */ 2439 | { 2440 | /* Translate xyz 1 to xyz(1) 2441 | * Allow for multiple spaces. Allow the section to be missing. 2442 | */ 2443 | char buff[100]; 2444 | char *bufptr; 2445 | trans_char(c,'"','\a'); 2446 | bufptr = buff; 2447 | c = c+j; 2448 | if (*c == '\n') c++; /* Skip spaces */ 2449 | while (isspace(*c) && *c != '\n') c++; 2450 | while (isalnum(*c) && bufptr < buff + SIZE(buff)-4) { 2451 | /* Copy the xyz part */ 2452 | *bufptr++ = *c++; 2453 | } 2454 | while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ 2455 | if (isdigit(*c)) { /* Convert the number if there is one */ 2456 | *bufptr++ = '('; 2457 | while (isalnum(*c) && bufptr < buff + SIZE(buff)-3) { 2458 | *bufptr++ = *c++; 2459 | } 2460 | *bufptr++ = ')'; 2461 | } 2462 | while (*c != '\n' && bufptr < buff + SIZE(buff)-2) { 2463 | /* Copy the remainder */ 2464 | if (!isspace(*c)) { 2465 | *bufptr++ = *c; 2466 | } 2467 | c++; 2468 | } 2469 | *bufptr++ = '\n'; 2470 | *bufptr = 0; 2471 | scan_troff_mandoc(buff, 1, NULL); 2472 | out_html(NEWLINE); 2473 | if (fillout) curpos++; else curpos=0; 2474 | } 2475 | break; 2476 | case V('F','l'): /* BSD mandoc */ 2477 | trans_char(c,'"','\a'); 2478 | c=c+j; 2479 | out_html("-"); 2480 | if (*c!='\n') { 2481 | out_html(change_to_font('B')); 2482 | c=scan_troff_mandoc(c, 1, NULL); 2483 | out_html(change_to_font('R')); 2484 | } 2485 | out_html(NEWLINE); 2486 | if (fillout) curpos++; else curpos=0; 2487 | break; 2488 | case V('P','a'): /* BSD mandoc */ 2489 | case V('P','f'): /* BSD mandoc */ 2490 | trans_char(c,'"','\a'); 2491 | c=c+j; 2492 | if (*c == '\n') c++; 2493 | c=scan_troff_mandoc(c, 1, NULL); 2494 | out_html(NEWLINE); 2495 | if (fillout) curpos++; else curpos=0; 2496 | break; 2497 | case V('P','p'): /* BSD mandoc */ 2498 | if (fillout) out_html("
\n"); else {
2499 | out_html(NEWLINE);
2500 | NEWLINE[0]='\n';
2501 | }
2502 | curpos=0;
2503 | c=skip_till_newline(c);
2504 | break;
2505 | case V('D','q'): /* BSD mandoc */
2506 | trans_char(c,'"','\a');
2507 | c=c+j;
2508 | if (*c == '\n') c++;
2509 | out_html("``");
2510 | c=scan_troff_mandoc(c, 1, NULL);
2511 | out_html("''");
2512 | out_html(NEWLINE);
2513 | if (fillout) curpos++; else curpos=0;
2514 | break;
2515 | case V('O','p'): /* BSD mandoc */
2516 | trans_char(c,'"','\a');
2517 | c=c+j;
2518 | if (*c == '\n') c++;
2519 | out_html(change_to_font('R'));
2520 | out_html("[");
2521 | c=scan_troff_mandoc(c, 1, NULL);
2522 | out_html(change_to_font('R'));
2523 | out_html("]");
2524 | out_html(NEWLINE);
2525 | if (fillout) curpos++; else curpos=0;
2526 | break;
2527 | case V('O','o'): /* BSD mandoc */
2528 | trans_char(c,'"','\a');
2529 | c=c+j;
2530 | if (*c == '\n') c++;
2531 | out_html(change_to_font('R'));
2532 | out_html("[");
2533 | c=scan_troff_mandoc(c, 1, NULL);
2534 | if (fillout) curpos++; else curpos=0;
2535 | break;
2536 | case V('O','c'): /* BSD mandoc */
2537 | trans_char(c,'"','\a');
2538 | c=c+j;
2539 | c=scan_troff_mandoc(c, 1, NULL);
2540 | out_html(change_to_font('R'));
2541 | out_html("]");
2542 | if (fillout) curpos++; else curpos=0;
2543 | break;
2544 | case V('P','q'): /* BSD mandoc */
2545 | trans_char(c,'"','\a');
2546 | c=c+j;
2547 | if (*c == '\n') c++;
2548 | out_html("(");
2549 | c=scan_troff_mandoc(c, 1, NULL);
2550 | out_html(")");
2551 | out_html(NEWLINE);
2552 | if (fillout) curpos++; else curpos=0;
2553 | break;
2554 | case V('Q','l'): /* BSD mandoc */
2555 | { /* Single quote first word in the line */
2556 | char *sp;
2557 | trans_char(c,'"','\a');
2558 | c=c+j;
2559 | if (*c == '\n') c++;
2560 | sp = c;
2561 | do { /* Find first whitespace after the
2562 | * first word that isn't a mandoc macro
2563 | */
2564 | while (*sp && isspace(*sp)) sp++;
2565 | while (*sp && !isspace(*sp)) sp++;
2566 | } while (*sp && isupper(*(sp-2)) && islower(*(sp-1)));
2567 |
2568 | /* Use a newline to mark the end of text to
2569 | * be quoted
2570 | */
2571 | if (*sp) *sp = '\n';
2572 | out_html("`"); /* Quote the text */
2573 | c=scan_troff_mandoc(c, 1, NULL);
2574 | out_html("'");
2575 | out_html(NEWLINE);
2576 | if (fillout) curpos++; else curpos=0;
2577 | break;
2578 | }
2579 | case V('S','q'): /* BSD mandoc */
2580 | trans_char(c,'"','\a');
2581 | c=c+j;
2582 | if (*c == '\n') c++;
2583 | out_html("`");
2584 | c=scan_troff_mandoc(c, 1, NULL);
2585 | out_html("'");
2586 | out_html(NEWLINE);
2587 | if (fillout) curpos++; else curpos=0;
2588 | break;
2589 | case V('A','r'): /* BSD mandoc */
2590 | /* parse one line in italics */
2591 | out_html(change_to_font('I'));
2592 | trans_char(c,'"','\a');
2593 | c=c+j;
2594 | if (*c == '\n') { /* An empty Ar means "file ..." */
2595 | out_html("file ...");
2596 | } else {
2597 | c=scan_troff_mandoc(c, 1, NULL);
2598 | }
2599 | out_html(change_to_font('R'));
2600 | out_html(NEWLINE);
2601 | if (fillout) curpos++; else curpos=0;
2602 | break;
2603 | case V('A','d'): /* BSD mandoc */
2604 | case V('E','m'): /* BSD mandoc */
2605 | case V('V','a'): /* BSD mandoc */
2606 | /* parse one line in italics */
2607 | out_html(change_to_font('I'));
2608 | trans_char(c,'"','\a');
2609 | c=c+j;
2610 | if (*c == '\n') c++;
2611 | c=scan_troff_mandoc(c, 1, NULL);
2612 | out_html(change_to_font('R'));
2613 | out_html(NEWLINE);
2614 | if (fillout) curpos++; else curpos=0;
2615 | break;
2616 | case V('N','d'): /* BSD mandoc */
2617 | trans_char(c,'"','\a');
2618 | c=c+j;
2619 | if (*c == '\n') c++;
2620 | out_html(" - ");
2621 | c=scan_troff_mandoc(c, 1, NULL);
2622 | out_html(NEWLINE);
2623 | if (fillout) curpos++; else curpos=0;
2624 | break;
2625 | case V('N','m'): /* BSD mandoc */
2626 | {
2627 | static char *mandoc_name = 0;
2628 | trans_char(c,'"','\a');
2629 | c=c+j;
2630 | if (mandoc_synopsis) {
2631 | /*
2632 | * Break lines only in the Synopsis.
2633 | * The Synopsis section seems to be treated
2634 | * as a special case - Bummer!
2635 | */
2636 | static int count = 0; /* Don't break on the first Nm */
2637 | if (count) {
2638 | out_html("
42 |
56 |
65 |
14 |
30 | The index uses the Glimpse
31 | (glimpse(1))
32 | text indexing system. Many of the glimpse
33 | options, regular expressions, and wildcards are valid:
34 | see the help page for a summary.
35 |
36 |
39 | Glimpse
40 | was developed by Udi Manber and Burra Gopal of the University of
41 | Arizona, and Sun Wu of the National Chung-Cheng University, Taiwan.
42 | You may contact the authors at
43 | glimpse@cs.arizona.edu
44 |
45 | The Manual Page text search interface was created for Linux by
46 |
47 | Michael Hamilton.
48 |
49 |
50 |
--------------------------------------------------------------------------------
/scripts/cgi-aux/man/mansearchhelp.aux:
--------------------------------------------------------------------------------
1 | Content-type: text/html
2 |
3 |
4 |
16 |
18 | The full text index uses the Glimpse text indexing system.
19 | The
20 | glimpse(1)
21 | manual page documents glimpse in full. This summary documents those
22 | features of glimpse that are valid when searching through the manual pages.
23 |
24 |
104 |
241 |
242 | As was mentioned in the section on PATTERNS above, some characters
243 | serve as meta characters for glimpse and need to be
244 | preceded by '\' to search for them. The most common
245 | examples are the characters '.' (which stands for a wild card),
246 | and '*' (the Kleene closure).
247 | So, "glimpse ab.de" will match abcde, but "glimpse ab\.de"
248 | will not, and "glimpse ab*de" will not match ab*de, but
249 | "glimpse ab\*de" will.
250 | The meta character - is translated automatically to a hyphen
251 | unless it appears between [] (in which case it denotes a range of
252 | characters).
253 |
254 |
255 | The index of glimpse stores all patterns in lower case.
256 | When glimpse searches the index it first converts
257 | all patterns to lower case, finds the appropriate files,
258 | and then searches the actual files using the original
259 | patterns.
260 | So, for example, glimpse ABCXYZ will first find all
261 | files containing abcxyz in any combination of lower and upper
262 | cases, and then searches these files directly, so only the
263 | right cases will be found.
264 | One problem with this approach is discovering misspellings
265 | that are caused by wrong cases.
266 | For example, glimpse -B abcXYZ will first search the
267 | index for the best match to abcxyz (because the pattern is
268 | converted to lower case); it will find that there are matches
269 | with no errors, and will go to those files to search them
270 | directly, this time with the original upper cases.
271 | If the closest match is, say AbcXYZ, glimpse may miss it,
272 | because it doesn't expect an error.
273 | Another problem is speed. If you search for "ATT", it will look
274 | at the index for "att". Unless you use -w to match the whole word,
275 | glimpse may have to search all files containing, for example, "Seattle"
276 | which has "att" in it.
277 |
278 |
279 | There is no size limit for simple patterns and simple patterns
280 | within Boolean expressions.
281 | More complicated patterns, such as regular expressions,
282 | are currently limited to approximately 30 characters.
283 | Lines are limited to 1024 characters.
284 | Records are limited to 48K, and may be truncated if they are larger
285 | than that.
286 | The limit of record length can be
287 | changed by modifying the parameter Max_record in agrep.h.
288 |
289 |
290 | Glimpseindex does not index words of size > 64.
291 |
292 |
293 | 1 match found."
184 | }
185 | else {
186 | print " " mcount " matches found."
187 | }
188 | print "";
189 | print "";
190 | exit;
191 | }' "$@"
192 |
193 |
--------------------------------------------------------------------------------
/scripts/cgi-bin/man/mansearchhelp:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | MAN2HTML=/usr/bin/man2html
3 | MANSH=/home/httpd/cgi-aux/man/mansearchhelp.aux
4 |
5 | # Do we need lynxcgi URLs? For the moment our criterion is
6 | # 1) HTTP_USER_AGENT=Lynx* and 2) HTTP_HOST is unset.
7 | AGENT="${HTTP_USER_AGENT-unknown}"
8 | case "$AGENT" in
9 | Lynx*|lynx*)
10 | HH="${HTTP_HOST-nohh}"
11 | ;;
12 | *)
13 | HH=nolynx
14 | ;;
15 | esac
16 |
17 | SERVER="${SERVER_NAME-localhost}"
18 | case "$HH" in
19 | nohh)
20 | CG="lynxcgi:/home/httpd/cgi-bin/man"
21 | ;;
22 | *)
23 | CG="http://$SERVER/cgi-bin/man"
24 | ;;
25 | esac
26 |
27 | if [ -r $MANSH ]; then
28 | sed s#%cg#$CG#g $MANSH
29 | else
30 | $MAN2HTML -E "man2html: cannot open $MANSH"
31 | fi
32 | exit 0
33 |
--------------------------------------------------------------------------------
/scripts/cgi-bin/man/mansec:
--------------------------------------------------------------------------------
1 | #!/usr/bin/awk -f
2 | #
3 | # Generate an index into a manual section by using find.
4 | # Michael Hamilton Manual pages found under " man_path "." > cache_tmp;
118 |
119 | # Find any man[1-8]/filenames
120 | while ((("find " man_path " -follow -type f -printf '%f\n' | sort -f ") | getline manpage) > 0) {
121 | # Check for new letter of alphabet
122 | letter = tolower(substr(manpage,1,1));
123 | if (letter != last_letter) {
124 | last_letter = letter;
125 | letter_index[++num_letters] = letter;
126 | # Start a new alphabetic heading
127 | print " " > cache_tmp;
146 |
147 | # Print out alphabetic quick index and other links
148 | for (i = 1; i <= num_letters; i++) {
149 | print "" toupper(letter_index[i]) "" > cache_tmp;
150 | }
151 |
152 | print " Other sections:" > cache_tmp;
156 | for (i=1; i<=num_sections; i++) {
157 | if (i != section) { # Dont print an entry for the section we are in
158 | print "" i ". " sec_name[i] " " > cache_tmp;
159 | }
160 | }
161 | print " " > cache_tmp;
162 | # Print out the accumulated index entries
163 | while ((getline < buffer_tmp) > 0) print > cache_tmp;
164 | print " " > cache_tmp;
165 | # Print out alphabetic quick index and other links
166 | for (i = 1; i <= num_letters; i++) {
167 | print "" toupper(letter_index[i]) "" > cache_tmp;
168 | }
169 | print " Return to Main Contents" > cache_tmp;
171 | print " Other sections:" > cache_tmp;
172 | for (i=1; i<=num_sections; i++) {
173 | if (i != section) { # Dont print an entry for the section we are in
174 | print "" i ". " sec_name[i] " " > cache_tmp;
175 | }
176 | }
177 | print "\n" > cache_tmp;
178 | system("/bin/mv " cache_tmp " " cache);
179 | system("/bin/rm -f " buffer_tmp);
180 | }
181 | system("/bin/cat " cache);
182 | exit;
183 | }
184 |
--------------------------------------------------------------------------------
/scripts/cgi-bin/man/manwhatis:
--------------------------------------------------------------------------------
1 | #!/usr/bin/awk -f
2 | #
3 | # Generate a whatis index into the manual pages by using find to
4 | # locate all the whatis files.
5 | # Michael Hamilton " > cache_tmp;
121 |
122 | # Note that sort sometimes lives in /bin and sometimes in /usr/bin
123 | sort_cmd = "sort -f >> " sort_tmp;
124 |
125 | while ( (extract_cmd | getline) > 0 ) {
126 | if (bracket_pos = index($0, "(")) {
127 | sec_full_num = substr($0, bracket_pos + 1, index($0, ")") - bracket_pos - 1);
128 | names = substr($0, 1, bracket_pos - 2);
129 | # Get rid of blanks and commas.
130 | n = split(names, name_list, " *, *");
131 | description = substr($0, bracket_pos + length(sec_full_num) + 2);
132 | # Get rid of AT&T
133 | gsub("&", "\&", description);
134 | # Generate a entry for each name
135 | for (i = 1; i <= n; i++) {
136 | print name_list[i] " " sec_full_num " " name_list[1] " / " description | sort_cmd;
137 | }
138 | }
139 | }
140 | close(extract_cmd);
141 | close(sort_cmd);
142 |
143 | while ((getline < sort_tmp) > 0) {
144 |
145 | letter = tolower(substr($1,1,1));
146 | if (letter != last_letter) {
147 | if (last_letter) {
148 | print " " > buffer_tmp;
149 | }
150 | last_letter = letter;
151 | letter_index[++num_letters] = letter;
152 | # Terminate list, start a new one
153 |
154 | print " " > buffer_tmp;
167 | close(buffer_tmp);
168 |
169 | system("/bin/rm " sort_tmp);
170 |
171 | # Print out alphabetic quick index and other links
172 | for (i = 1; i <= num_letters; i++) {
173 | print "" toupper(letter_index[i]) "" > cache_tmp;
174 | }
175 | print " Other sections:" > cache_tmp;
179 | for (i=1; i<=num_sections; i++) {
180 | if (i != section) { # Dont print an entry for the section we are in
181 | print "" i ". " sec_name[i] " " > cache_tmp;
182 | }
183 | }
184 | print " " > cache_tmp;
185 | # Print out the accumulated contents entries
186 | while ((getline < buffer_tmp) > 0) print > cache_tmp;
187 | print " " > cache_tmp;
188 |
189 | for (i = 1; i <= num_letters; i++) {
190 | print "" toupper(letter_index[i]) "" > cache_tmp;
191 | }
192 | print " Return to Main Contents" > cache_tmp;
194 |
195 | print " Other sections:" > cache_tmp;
196 | for (i=1; i<=num_sections; i++) {
197 | if (i != section) { # Dont print an entry for the section we are in
198 | print "" i ". " sec_name[i] " " > cache_tmp;
199 | }
200 | }
201 | print "" > cache_tmp;
202 | print "" > cache_tmp;
203 | system("/bin/mv " cache_tmp " " cache);
204 | system("/bin/rm " buffer_tmp);
205 | }
206 | system("/bin/cat " cache);
207 | exit;
208 | }
209 |
--------------------------------------------------------------------------------
/strdefs.c:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 |
3 | #ifndef NULL
4 | #define NULL ((void *) 0)
5 | #endif
6 |
7 | int nroff = 1;
8 |
9 | #define NROFF (-666)
10 | #define TROFF (-667)
11 |
12 | STRDEF *chardef, *strdef, *defdef;
13 | INTDEF *intdef;
14 |
15 | static INTDEF standardint[] = {
16 | { V('n',' '), NROFF, 0, NULL },
17 | { V('t',' '), TROFF, 0, NULL },
18 | { V('o',' '), 1, 0, NULL },
19 | { V('e',' '), 0, 0, NULL },
20 | { V('.','l'), 70, 0, NULL },
21 | { V('.','$'), 0, 0, NULL },
22 | { V('.','A'), NROFF, 0, NULL },
23 | { V('.','T'), TROFF, 0, NULL },
24 | { V('.','V'), 1, 0, NULL }, /* the me package tests for this */
25 | { 0, 0, 0, NULL } };
26 |
27 | static STRDEF standardstring[] = {
28 | { V('R',' '), 1, "®", NULL },
29 | { V('l','q'), 2, "``", NULL },
30 | { V('r','q'), 2, "''", NULL },
31 | { 0, 0, NULL, NULL}
32 | };
33 |
34 |
35 | static STRDEF standardchar[] = {
36 | { V('*','*'), 1, "*", NULL }, /* math star */
37 | { V('*','A'), 1, "A", NULL },
38 | { V('*','B'), 1, "B", NULL },
39 | { V('*','C'), 2, "Xi", NULL },
40 | { V('*','D'), 5, "Delta", NULL },
41 | { V('*','E'), 1, "E", NULL },
42 | { V('*','F'), 3, "Phi", NULL },
43 | { V('*','G'), 5, "Gamma", NULL },
44 | { V('*','H'), 5, "Theta", NULL },
45 | { V('*','I'), 1, "I", NULL },
46 | { V('*','K'), 1, "K", NULL },
47 | { V('*','L'), 6, "Lambda", NULL },
48 | { V('*','M'), 1, "M", NULL },
49 | { V('*','N'), 1, "N", NULL },
50 | { V('*','O'), 1, "O", NULL },
51 | { V('*','P'), 2, "Pi", NULL },
52 | { V('*','Q'), 3, "Psi", NULL },
53 | { V('*','R'), 1, "P", NULL },
54 | { V('*','S'), 5, "Sigma", NULL },
55 | { V('*','T'), 1, "T", NULL },
56 | { V('*','U'), 1, "Y", NULL },
57 | { V('*','W'), 5, "Omega", NULL },
58 | { V('*','X'), 1, "X", NULL },
59 | { V('*','Y'), 1, "H", NULL },
60 | { V('*','Z'), 1, "Z", NULL },
61 | { V('*','a'), 5, "alpha", NULL },
62 | { V('*','b'), 4, "beta", NULL },
63 | { V('*','c'), 2, "xi", NULL },
64 | { V('*','d'), 5, "delta", NULL },
65 | { V('*','e'), 7, "epsilon", NULL },
66 | { V('*','f'), 3, "phi", NULL },
67 | { V('*','g'), 5, "gamma", NULL },
68 | { V('*','h'), 5, "theta", NULL },
69 | { V('*','i'), 4, "iota", NULL },
70 | { V('*','k'), 5, "kappa", NULL },
71 | { V('*','l'), 6, "lambda", NULL },
72 | { V('*','m'), 1, "µ", NULL },
73 | { V('*','n'), 2, "nu", NULL },
74 | { V('*','o'), 1, "o", NULL },
75 | { V('*','p'), 2, "pi", NULL },
76 | { V('*','q'), 3, "psi", NULL },
77 | { V('*','r'), 3, "rho", NULL },
78 | { V('*','s'), 5, "sigma", NULL },
79 | { V('*','t'), 3, "tau", NULL },
80 | { V('*','u'), 7, "upsilon", NULL },
81 | { V('*','w'), 5, "omega", NULL },
82 | { V('*','x'), 3, "chi", NULL },
83 | { V('*','y'), 3, "eta", NULL },
84 | { V('*','z'), 4, "zeta", NULL },
85 | { V('+','-'), 1, "±", NULL },
86 | { V('1','2'), 1, "½", NULL },
87 | { V('1','4'), 1, "¼", NULL },
88 | { V('3','4'), 1, "¾", NULL },
89 | { V('F','i'), 3, "ffi", NULL },
90 | { V('F','l'), 3, "ffl", NULL },
91 | { V('a','a'), 1, "´", NULL },
92 | { V('a','p'), 1, "~", NULL },
93 | { V('b','r'), 1, "|", NULL },
94 | { V('b','u'), 1, "*", NULL }, /* bullet */
95 | { V('b','v'), 1, "|", NULL },
96 | { V('c','i'), 1, "o", NULL }, /* circle */
97 | { V('c','o'), 1, "©", NULL },
98 | { V('c','t'), 1, "¢", NULL },
99 | { V('d','e'), 1, "°", NULL },
100 | { V('d','g'), 1, "+", NULL }, /* dagger */
101 | { V('d','i'), 1, "÷", NULL },
102 | { V('e','m'), 3, "---", NULL }, /* em dash */
103 | { V('e','n'), 1, "-", NULL }, /* en dash */
104 | { V('e','q'), 1, "=", NULL },
105 | { V('e','s'), 1, "Ø", NULL },
106 | { V('f','f'), 2, "ff", NULL },
107 | { V('f','i'), 2, "fi", NULL },
108 | { V('f','l'), 2, "fl", NULL },
109 | { V('f','m'), 1, "´", NULL },
110 | { V('g','a'), 1, "`", NULL },
111 | { V('h','y'), 1, "-", NULL },
112 | { V('l','c'), 2, "|¯", NULL },
113 | { V('i','f'), 8, "Infinity", NULL }, /* infinity sign */
114 | { V('i','s'), 8, "Integral", NULL }, /* integral sign */
115 | { V('l','f'), 2, "|_", NULL },
116 | { V('l','k'), 1, "{", NULL },
117 | { V('m','i'), 1, "-", NULL },
118 | { V('m','u'), 1, "×", NULL },
119 | { V('n','o'), 1, "¬", NULL },
120 | { V('o','r'), 1, "|", NULL },
121 | { V('p','d'), 1, "d", NULL }, /* partial derivative */
122 | { V('p','l'), 1, "+", NULL },
123 | { V('r','c'), 2, "¯|", NULL },
124 | { V('r','f'), 2, "_|", NULL },
125 | { V('r','g'), 1, "®", NULL },
126 | { V('r','k'), 1, "}", NULL },
127 | { V('r','n'), 1, "¯", NULL },
128 | { V('r','u'), 1, "_", NULL },
129 | { V('s','c'), 1, "§", NULL },
130 | { V('s','l'), 1, "/", NULL },
131 | { V('s','q'), 2, "[]", NULL },
132 | { V('t','s'), 1, "s", NULL }, /* should be terminal sigma */
133 | { V('u','l'), 1, "_", NULL },
134 | { V('>','='), 1, ">", NULL },
135 | { V('<','='), 1, "<", NULL },
136 | { 0, 0, NULL, NULL }
137 | };
138 |
139 | void stdinit(void) {
140 | STRDEF *stdf;
141 | int i;
142 |
143 | stdf = &standardchar[0];
144 | i = 0;
145 | while (stdf->nr) {
146 | if (stdf->st) stdf->st = xstrdup(stdf->st);
147 | stdf->next = &standardchar[i];
148 | stdf = stdf->next;
149 | i++;
150 | }
151 | chardef=&standardchar[0];
152 |
153 | stdf=&standardstring[0];
154 | i=0;
155 | while (stdf->nr) {
156 | /* waste a little memory, and make a copy, to avoid
157 | the segfault when we free non-malloced memory */
158 | if (stdf->st) stdf->st = xstrdup(stdf->st);
159 | stdf->next = &standardstring[i];
160 | stdf = stdf->next;
161 | i++;
162 | }
163 | strdef=&standardstring[0];
164 |
165 | intdef=&standardint[0];
166 | i=0;
167 | while (intdef->nr) {
168 | if (intdef->nr == NROFF) intdef->nr = nroff; else
169 | if (intdef->nr == TROFF) intdef->nr = !nroff;
170 | intdef->next = &standardint[i];
171 | intdef = intdef->next;
172 | i++;
173 | }
174 | intdef = &standardint[0];
175 | defdef = NULL;
176 | }
177 |
--------------------------------------------------------------------------------
");
2639 | } else {
2640 | char *end, t=0 /* just for gcc */;
2641 | end = strchr(c, '\n');
2642 | if (end) {
2643 | t = *end;
2644 | *end = 0;
2645 | }
2646 | if (mandoc_name)
2647 | free(mandoc_name);
2648 | mandoc_name = xstrdup(c);
2649 | if (end)
2650 | *end = t;
2651 | }
2652 | count++;
2653 | }
2654 | out_html(change_to_font('B'));
2655 | while (*c == ' ' || *c == '\t') c++;
2656 | if (*c == '\n') {
2657 | /*
2658 | * If Nm has no argument, use one from an earlier
2659 | * Nm command that did have one. Hope there aren't
2660 | * too many commands that do this.
2661 | */
2662 | if (mandoc_name)
2663 | out_html(mandoc_name);
2664 | } else {
2665 | c=scan_troff_mandoc(c, 1, NULL);
2666 | }
2667 | out_html(change_to_font('R'));
2668 | out_html(NEWLINE);
2669 | if (fillout) curpos++; else curpos=0;
2670 | break;
2671 | }
2672 | case V('C','d'): /* BSD mandoc */
2673 | case V('C','m'): /* BSD mandoc */
2674 | case V('I','c'): /* BSD mandoc */
2675 | case V('M','s'): /* BSD mandoc */
2676 | case V('O','r'): /* BSD mandoc */
2677 | case V('S','y'): /* BSD mandoc */
2678 | /* parse one line in bold */
2679 | out_html(change_to_font('B'));
2680 | trans_char(c,'"','\a');
2681 | c=c+j;
2682 | if (*c == '\n') c++;
2683 | c=scan_troff_mandoc(c, 1, NULL);
2684 | out_html(change_to_font('R'));
2685 | out_html(NEWLINE);
2686 | if (fillout) curpos++; else curpos=0;
2687 | break;
2688 | case V('D','v'): /* BSD mandoc */
2689 | case V('E','v'): /* BSD mandoc */
2690 | case V('F','r'): /* BSD mandoc */
2691 | case V('L','i'): /* BSD mandoc */
2692 | case V('N','o'): /* BSD mandoc */
2693 | case V('N','s'): /* BSD mandoc */
2694 | case V('T','n'): /* BSD mandoc */
2695 | case V('n','N'): /* BSD mandoc */
2696 | trans_char(c,'"','\a');
2697 | c=c+j;
2698 | if (*c == '\n') c++;
2699 | out_html(change_to_font('B'));
2700 | c=scan_troff_mandoc(c, 1, NULL);
2701 | out_html(change_to_font('R'));
2702 | out_html(NEWLINE);
2703 | if (fillout) curpos++; else curpos=0;
2704 | break;
2705 | case V('%','A'): /* BSD mandoc biblio stuff */
2706 | case V('%','D'):
2707 | case V('%','N'):
2708 | case V('%','O'):
2709 | case V('%','P'):
2710 | case V('%','Q'):
2711 | case V('%','V'):
2712 | c=c+j;
2713 | if (*c == '\n') c++;
2714 | c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */
2715 | if (fillout) curpos++; else curpos=0;
2716 | break;
2717 | case V('%','B'):
2718 | case V('%','J'):
2719 | case V('%','R'):
2720 | case V('%','T'):
2721 | c=c+j;
2722 | out_html(change_to_font('I'));
2723 | if (*c == '\n') c++;
2724 | c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */
2725 | out_html(change_to_font('R'));
2726 | if (fillout) curpos++; else curpos=0;
2727 | break;
2728 | /* ----- end of BSD mandoc stuff ----- */
2729 |
2730 | default:
2731 | /* search macro database of self-defined macros */
2732 | owndef = defdef;
2733 | while (owndef && owndef->nr!=i) owndef=owndef->next;
2734 | if (owndef) {
2735 | char **oldargument;
2736 | int deflen;
2737 | int onff;
2738 | sl=fill_words(c+j, wordlist, SIZE(wordlist), &words, '\n');
2739 | c=sl+1;
2740 | *sl=0;
2741 | for (i=1; i
");
2942 | curpos=0;
2943 | }
2944 | usenbsp=fillout;
2945 | if (usenbsp) out_html(" "); else intbuff[ibp++]=' ';
2946 | } else if (*h > 31 && *h < 127) {
2947 | intbuff[ibp++]=*h;
2948 | } else if (((unsigned char)(*h)) > 127) {
2949 | #ifdef NO_8BIT
2950 | intbuff[ibp++]='&';
2951 | intbuff[ibp++]='#';
2952 | intbuff[ibp++]='0'+((unsigned char)(*h))/100;
2953 | intbuff[ibp++]='0'+(((unsigned char)(*h))%100)/10;
2954 | intbuff[ibp++]='0'+((unsigned char)(*h))%10;
2955 | intbuff[ibp++]=';';
2956 | #else
2957 | intbuff[ibp++]=*h;
2958 | #endif
2959 | }
2960 | curpos++;
2961 | break;
2962 | }
2963 | if (ibp>480) FLUSHIBP;
2964 | h++;
2965 | }
2966 | }
2967 | FLUSHIBP;
2968 | if (buffer) buffer[buffpos]=0;
2969 | if (san && *h) h++;
2970 | newline_for_fun=exnewline_for_fun;
2971 | if (result) {
2972 | *result = buffer;
2973 | buffer=exbuffer;
2974 | buffpos=exbuffpos;
2975 | buffmax=exbuffmax;
2976 | scaninbuff=exscaninbuff;
2977 | }
2978 | return h;
2979 | }
2980 |
2981 | static char *scan_troff_mandoc(char *c, int san, char **result) {
2982 | char *ret, *end = c;
2983 | int oldval = mandoc_line;
2984 | mandoc_line = 1;
2985 | while (*end && *end != '\n') {
2986 | end++;
2987 | }
2988 |
2989 | if (end > c + 2
2990 | && ispunct(*(end - 1))
2991 | && isspace(*(end - 2)) && *(end - 2) != '\n') {
2992 | /*
2993 | * Don't format lonely punctuation. E.g. in "xyz ," format
2994 | * the xyz and then append the comma removing the space.
2995 | */
2996 | *(end - 2) = '\n';
2997 | ret = scan_troff(c, san, result);
2998 | *(end - 2) = *(end - 1);
2999 | *(end - 1) = ' ';
3000 | } else {
3001 | ret = scan_troff(c, san, result);
3002 | }
3003 | mandoc_line = oldval;
3004 | return ret;
3005 | }
3006 |
3007 | STRDEF *foundpages=NULL;
3008 |
3009 | static void
3010 | error_page(char *s, char *t, ...) {
3011 | va_list p;
3012 |
3013 | printf("%s
\n", s, s);
3015 | va_start(p, t);
3016 | vfprintf(stdout, t, p);
3017 | va_end(p);
3018 | printf("\n");
3019 | exit(0);
3020 | }
3021 |
3022 | char *
3023 | xstrdup(const char *s) {
3024 | char *p = strdup(s);
3025 | if (p == NULL)
3026 | error_page("Out of memory",
3027 | "Sorry, out of memory, aborting...\n");
3028 | return p;
3029 | }
3030 |
3031 | void *
3032 | xmalloc(size_t size) {
3033 | void *p = malloc(size);
3034 | if (p == NULL)
3035 | error_page("Out of memory",
3036 | "Sorry, out of memory, aborting...\n");
3037 | return p;
3038 | }
3039 |
3040 | void *
3041 | xrealloc(void *ptr, size_t size) {
3042 | void *p = realloc(ptr,size);
3043 | if (p == NULL)
3044 | error_page("Out of memory",
3045 | "Sorry, out of memory, aborting...\n");
3046 | return p;
3047 | }
3048 |
3049 | static void
3050 | usage(void) {
3051 | error_page("man2html: bad invocation",
3052 | "Call: man2html [-l|-h host.domain:port] [-p|-q] [filename]\n"
3053 | "or: man2html -r [filename]\n"
3054 | "or: man2html -c [filename]\n");
3055 | }
3056 |
3057 | static void
3058 | goto_dir(char *path, char **dir, char **name) {
3059 | char *s, *t, *u;
3060 |
3061 | s = xstrdup(path);
3062 | t = strrchr(s, '/');
3063 | if (t) {
3064 | *t = 0;
3065 | u = strrchr(s, '/');
3066 | *t = '/';
3067 | if (u) {
3068 | *u = 0;
3069 | if (chdir(s) == 0) {
3070 | if (dir)
3071 | *dir = s;
3072 | if (name)
3073 | *name = u+1;
3074 | }
3075 | #if 0
3076 | else /* complain or not - this need not be fatal */
3077 | error_page("Error", "man2html: could not chdir to %s", s);
3078 | #endif
3079 | }
3080 | }
3081 | }
3082 |
3083 | /*
3084 | * Call: man2html [-l] [filename]
3085 | *
3086 | * The contents of FILENAME (or STDIN, in case FILENAME is "-" or absent)
3087 | * are converted from man-style nroff to html, and printed on STDOUT.
3088 | *
3089 | * Possible errors are reflected in the output. The return status is 0.
3090 | */
3091 | int
3092 | main(int argc, char **argv) {
3093 | FILE *f;
3094 | struct stat stbuf;
3095 | int l, c;
3096 | char *buf, *filename, *fnam = NULL;
3097 |
3098 | #ifdef __CYGWIN__
3099 | int opterr;
3100 |
3101 | extern int optind;
3102 | extern char *optarg;
3103 | #endif
3104 |
3105 | // printf("Content-type: text/html\n\n");
3106 |
3107 | opterr = 0; /* no stderr error messages */
3108 | while ((c = getopt (argc, argv, "D:E:hH:lL:M:pqrc?vVf")) != -1) {
3109 | switch(c) {
3110 | case 'D':
3111 | goto_dir(optarg, 0, 0); break;
3112 | case 'E':
3113 | error_page("Error", "%s", optarg); break;
3114 | case 'h':
3115 | set_cgibase("localhost"); break;
3116 | case 'H':
3117 | set_cgibase(optarg); break;
3118 | case 'l':
3119 | set_lynxcgibase("/home/httpd"); break;
3120 | case 'L':
3121 | set_lynxcgibase(optarg); break;
3122 | case 'M':
3123 | set_man2htmlpath(optarg); break;
3124 | case 'p':
3125 | set_separator('/'); break;
3126 | case 'q':
3127 | set_separator('?'); break;
3128 | case 'r':
3129 | set_relative_html_links(); break;
3130 | case 'c':
3131 | set_current_html_links(); break;
3132 | case 'v':
3133 | case 'V':
3134 | error_page("Version", "%s from man-%s", argv[0], version);
3135 | exit(0);
3136 | case '?':
3137 | default:
3138 | usage();
3139 | case 'f': /* It is rumoured that some other
3140 | incarnation of man2html uses this flag;
3141 | ignore when given for compatibility. */
3142 | /* case 'F': this will assign a format for man_page_html() */
3143 | break;
3144 | }
3145 | }
3146 |
3147 | /* Find filename */
3148 | if (argc == optind+1)
3149 | fnam = argv[optind];
3150 | else if (argc != optind)
3151 | usage();
3152 |
3153 | filename = fnam;
3154 | directory = 0;
3155 |
3156 | /* Open input file */
3157 | if (!fnam || !strcmp(fnam, "-")) {
3158 | f = stdin;
3159 | fname = "(stdin)";
3160 | } else {
3161 | /* do a chdir() first, to get .so expansion right */
3162 | goto_dir(fnam, &directory, &fnam);
3163 |
3164 | f = fopen(fnam, "r");
3165 | if (f == NULL)
3166 | error_page("File not found", "Could not open %s\n", filename);
3167 | fname = fnam;
3168 | }
3169 |
3170 | /* Read entire file into buf[1..l] */
3171 | #define XTRA 5
3172 | /* buf has 1 extra byte at the start, and XTRA extra bytes at the end */
3173 | if (f == stdin) {
3174 | int sz = 1024;
3175 | int ct = 1, tot = 0;
3176 | char *p = NULL;
3177 |
3178 | clearerr(stdin);
3179 | while (ct > 0) {
3180 | tot += ct;
3181 | if (feof(stdin))
3182 | break;
3183 | sz = 2*sz+tot;
3184 | p = xrealloc(p, sz);
3185 | ct = fread(p+tot,1,sz-tot-XTRA,stdin);
3186 | }
3187 |
3188 | buf = p;
3189 | l = tot-1;
3190 | } else {
3191 | int ct;
3192 |
3193 | l = 0;
3194 | if (fstat(fileno(f), &stbuf) != -1)
3195 | l = stbuf.st_size;
3196 | buf = (char *) xmalloc((l+1+XTRA)*sizeof(char));
3197 | ct = fread(buf+1,1,l,f);
3198 | if (ct < l)
3199 | l = ct;
3200 | fclose(f);
3201 | }
3202 |
3203 | buf[0] = '\n';
3204 | buf[l+1] = '\n';
3205 | buf[l+2] = buf[l+3] = 0;
3206 |
3207 | #ifdef MAKEINDEX
3208 | idxfile = fopen(INDEXFILE, "a");
3209 | #endif
3210 | stdinit();
3211 |
3212 | scan_troff(buf+1,0,NULL);
3213 | dl_down();
3214 | out_html(change_to_font(0));
3215 | out_html(change_to_size(0));
3216 | if (!fillout) {
3217 | fillout=1;
3218 | out_html("");
3219 | }
3220 | out_html(NEWLINE);
3221 | if (output_possible) {
3222 | /* for mosaic users */
3223 | printf("
\n Index
\n\n");
3224 | manidx[mip]=0;
3225 | printf("%s", manidx);
3226 | if (subs) printf("
\n");
3227 | printf("\n");
3228 | print_sig();
3229 | printf("\n\n");
3230 | } else {
3231 | if (!filename)
3232 | filename = fname;
3233 | if (*filename == '/')
3234 | error_page("Invalid Manpage",
3235 | "The requested file %s is not a valid (unformatted) "
3236 | "man page.\nIf the file is a formatted manpage, "
3237 | "you could try to load the\n"
3238 | "plain file.\n",
3239 | filename, filename);
3240 | else
3241 | error_page("Invalid Manpage",
3242 | "The requested file %s is not a valid (unformatted) "
3243 | "man page.", filename);
3244 | }
3245 | if (idxfile)
3246 | fclose(idxfile);
3247 | if (buf)
3248 | free(buf);
3249 | return 0;
3250 | }
3251 |
--------------------------------------------------------------------------------
/scripts/cgi-aux/man/man.aux:
--------------------------------------------------------------------------------
1 | Content-type: text/html
2 |
3 |
4 |
5 | Manual Pages - Main Contents
11 |
12 |
13 | Name and Section lookup
14 |
21 |
26 |
27 |
28 |
29 | Index of pages by name and description
30 | Sections:
31 | 1. User Commands;
32 | 2. System Calls;
33 | 3. Library Functions;
34 | 4. Special Files;
35 | 5. File Formats;
36 | 6. Games;
37 | 7. Miscellany;
38 | 8. Administration and Privileged Commands;
39 | l. Postgresql Commands;
40 | n. Tcl Commands.
41 |
43 | Index of pages by name only
44 | 1. User Commands;
45 | 2. System Calls;
46 | 3. Library Functions;
47 | 4. Special Files;
48 | 5. File Formats;
49 | 6. Games;
50 | 7. Miscellany;
51 | 8. Administration and Privileged Commands;
52 | l. Postgresql Commands;
53 | n. Tcl Commands;
54 | All Sections.
55 |
57 |
58 | Manual Pages full text search
59 |
60 |
61 | Search the full text of the Manual Pages.
62 |
63 |
64 |
66 |
67 | The original man2html program and scripts are due to
68 |
69 | Richard Verhoeven and
70 |
71 | Michael Hamilton.
72 | This version is from man-1.6f maintained by
73 | Federico Lucifredi.
74 |
75 |
76 |
--------------------------------------------------------------------------------
/scripts/cgi-aux/man/mansearch.aux:
--------------------------------------------------------------------------------
1 | Content-type: text/html
2 |
3 |
4 |
5 | Manual Pages - Text Search
11 |
12 | Return to Main Contents
13 |
20 |
27 |
28 |
29 |
37 |
38 | Manual Pages - Search Help
11 |
12 | Perform another search
13 |
14 | Return to Main Contents
15 |
17 |
25 |
26 | Search Options
27 |
28 | The following search options must be at the start of the search string.
29 |
30 |
31 |
32 |
102 |
103 |
105 |
106 | Patterns
107 |
108 | Glimpse
109 | supports a large variety of patterns, including simple
110 | strings, strings with classes of characters, sets of strings,
111 | wild cards, and regular expressions (see LIMITATIONS).
112 |
113 |
114 |
226 |
227 |
228 |
229 | Limitations
230 |
231 | The index of glimpse is word based. A pattern that contains more than
232 | one word cannot be found in the index. The way glimpse overcomes this
233 | weakness is by splitting any multi-word pattern into its set of words
234 | and looking for all of them in the index.
235 | For example, glimpse 'linear programming' will first consult the index
236 | to find all files containing both linear and programming,
237 | and then apply agrep to find the combined pattern.
238 | This is usually an effective solution, but it can be slow for
239 | cases where both words are very common, but their combination is not.
240 |
294 |
295 |
296 |
--------------------------------------------------------------------------------
/scripts/cgi-bin/man/man2html:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # man2html cgi script - uses /usr/bin/man2html to format man pages
3 | # auxiliary text files in /home/httpd/cgi-aux/man
4 | # aeb@cwi.nl - 980109
5 |
6 | MAN2HTML="/usr/bin/man2html"
7 | MANX="/home/httpd/cgi-aux/man/man.aux"
8 |
9 | # Do we need lynxcgi URLs? For the moment our criterion is
10 | # 1) HTTP_USER_AGENT=Lynx* and 2) HTTP_HOST is unset.
11 | AGENT="${HTTP_USER_AGENT-unknown}"
12 |
13 | case "$AGENT" in
14 | Lynx*|lynx*)
15 | HH="${HTTP_HOST-nohh}"
16 | SED="s/%lynx //"
17 | ;;
18 | *)
19 | HH=nolynx
20 | SED="/%lynx/d"
21 | ;;
22 | esac
23 |
24 | SERVER="${SERVER_NAME-localhost}"
25 | case "$HH" in
26 | nohh)
27 | LL="-l"
28 | CG="lynxcgi:/home/httpd/cgi-bin/man"
29 | ;;
30 | *)
31 | LL="-H$SERVER"
32 | CG="http://$SERVER/cgi-bin/man"
33 | ;;
34 | esac
35 |
36 | # Find the required page - expect to be called with "man2html [sec] page".
37 | # There may a prefixed "-M manpath" option.
38 | if [ $# -ge 2 -a x"$1" = x-M ]; then
39 | MANPATH="$2"
40 | export MANPATH
41 | shift; shift
42 | MP=" using the given MANPATH"
43 | else
44 | MP=""
45 | fi
46 |
47 | # If no arguments given, show a start page.
48 | if [ $# = 0 ]; then
49 | if [ -r $MANX ]; then
50 | cat $MANX | sed "s#%cg#$CG#g; $SED"
51 | else
52 | "$MAN2HTML" -E "man2html: cannot open $MANX"
53 | fi
54 | exit 0
55 | fi
56 |
57 | if [ $# -gt 2 ]; then
58 | "$MAN2HTML" -E "man2html: bad invocation: too many arguments"
59 | exit 0
60 | fi
61 |
62 | # A single argument may be an explicitly give path name
63 | # Otherwise, ask man where to find it
64 | if [ $# = 1 ]; then
65 | case "$1" in
66 | /*)
67 | PAGE="$1"
68 | ;;
69 | *)
70 | PAGE=`man -w -c "$@" 2>/dev/null`
71 | ;;
72 | esac
73 | else
74 | PAGE=`man -w -c "$@" 2>/dev/null`
75 | fi
76 |
77 | if [ x"$PAGE" = x ]; then
78 | complaint="man2html: cannot find a page"
79 | if [ $# = 1 ]; then
80 | "$MAN2HTML" -E "$complaint for $1$MP"
81 | else
82 | "$MAN2HTML" -E "$complaint for $2 in section $1$MP"
83 | fi
84 | exit 0
85 | fi
86 |
87 | if [ -r "$PAGE" ]
88 | then
89 | case "$PAGE" in
90 | *.gz)
91 | zcat "$PAGE" | "$MAN2HTML" "$LL" -D "$PAGE"
92 | ;;
93 | *.bz2)
94 | bzcat "$PAGE" | "$MAN2HTML" "$LL" -D "$PAGE"
95 | ;;
96 | *)
97 | "$MAN2HTML" "$LL" "$PAGE"
98 | ;;
99 | esac
100 | elif [ -r "$PAGE".gz ]
101 | then
102 | zcat "$PAGE".gz | "$MAN2HTML" "$LL" -D "$PAGE"
103 | elif [ -r "$PAGE".bz2 ]
104 | then
105 | bzcat "$PAGE".bz2 | "$MAN2HTML" "$LL" -D "$PAGE"
106 | else
107 | "$MAN2HTML" -E "Strange... Cannot find (or read) $PAGE."
108 | fi
109 | exit 0
110 |
--------------------------------------------------------------------------------
/scripts/cgi-bin/man/mansearch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Interface to a glimpse search of the man pages.
4 | # Michael Hamilton Manual Pages - Search Results
";
101 | print "Target text: " options " " string "
";
102 |
103 | print "";
104 | print "Perform another search";
105 | print "
";
106 | print "";
107 | print "Return to Main Contents";
108 | print "";
109 |
110 | print "
";
111 |
112 | print "";
113 | # Unless you like being hacked, the single
114 | # forward quotes are most important.
115 | cmd = glimpse_cmd " " options " " quote string quote " 2>/dev/null" ;
116 |
117 | while ((cmd | getline matchline) > 0) {
118 | if (split(matchline, part, ": ") == 1) {
119 | continue;
120 | }
121 | else {
122 | fullname = part[1];
123 | }
124 |
125 | if (fullname == "glimpse") {
126 | print "
";
140 | print "Location: " dirname "
";
141 | print "";
142 | }
143 | }
144 | else {
145 | filename = fullname;
146 | }
147 |
148 | if (match(filename, /\.[^.]+$/)) {
149 | ref = substr(filename, 1, RSTART - 1) "+" substr(filename, RSTART + 1);
150 | }
151 | else {
152 | ref = filename;
153 | }
154 | print "
";
179 | if (mcount == 0) {
180 | print "No matches found.";
181 | }
182 | else if (mcount == 1) {
183 | print "
\n
\nManual Pages - Page Names
" > cache_tmp;
103 | print "Section " section ": " sec_name[section] "
" > cache_tmp;
104 |
105 | "hostname" | getline hostname;
106 | "date" | getline date;
107 | print hostname " (" date ")" > cache_tmp;
108 |
109 | if (section != "all") {
110 | sec_sub_dir = "/man" section;
111 | }
112 | else {
113 | sec_sub_dir = "/man*";
114 | }
115 | gsub(" ", sec_sub_dir " ", man_path);
116 |
117 | print " ", toupper(letter), "
" > buffer_tmp;
128 | # Print out alphabetic quick index and other links
129 | }
130 | # Split page.n into "page" and "n" and generate an entry
131 | sub(/[.]([zZ]|(gz))$/, "", manpage);
132 | match(manpage, /[.][^.]+$/);
133 | title = substr(manpage, 1, RSTART - 1);
134 | if (section != "all") {
135 | print "", title, "(", substr(manpage, RSTART + 1), ")" > buffer_tmp;
136 | }
137 | else {
138 | sec = substr(manpage, RSTART + 1)
139 | print "", title, "(", sec, ")" > buffer_tmp;
140 | }
141 | }
142 |
143 | close(buffer_tmp);
144 |
145 | print "
" > cache_tmp;
153 | print "Return to Main Contents" > cache_tmp;
154 |
155 | print "
" > cache_tmp;
170 | print "Manual Pages - Names and Descriptions
" > cache_tmp;
94 | print "Section " section ": " sec_name[section] "
" > cache_tmp;
95 | "hostname" | getline hostname;
96 | "date" | getline date;
97 | print hostname " (" date ")" > cache_tmp;
98 | # Find out the man path
99 | "man -w" | getline;
100 | $1 = $1 ":";
101 | gsub(":", " ", $1);
102 |
103 | find_cmd = "find " man_path " -maxdepth 1 -name whatis -printf '%p '";
104 | find_cmd | getline whatis_files;
105 | close(find_cmd);
106 |
107 | if (whatis_files == "") {
108 | print "Content-type: text/html\n\n";
109 | print "";
110 | print "
Manual pages referenced in " whatis_files " ", toupper(letter), "
\n" > buffer_tmp ;
155 | }
156 | # Generate a
" > cache_tmp;
176 | print "Return to Main Contents" > cache_tmp;
177 |
178 | print "
" > cache_tmp;
193 | print "