", outfile); font = 0; } else if (!strncmp(line, ".TP ", 4)) { /* * Grab list... */ fputs(end_fonts[font], outfile); if (blist) { fputs("\n\n", outfile); blist = 0; } if (!list) fputs("
\n", outfile); } else if (!strncmp(line, ".Ve", 3) || !strncmp(line, ".fi", 3)) { /* * End preformatted... */ if (pre) { pre = 0; fputs("\n", outfile); } } else if (!strncmp(line, ".IP \\(bu", 8)) { /* * Bullet list... */ if (blist) fputs("\n", outfile); else { fputs("
", outfile);
for (lineptr = line + 4; isspace(*lineptr); lineptr ++);
if (*lineptr == '\"')
{
strmove(line, lineptr + 1);
if ((lineptr = strchr(line, '\"')) != NULL)
*lineptr = '\0';
}
else
{
strmove(line, lineptr);
if ((lineptr = strchr(line, ' ')) != NULL)
*lineptr = '\0';
}
/*
* Process the text as if it was in-line...
*/
post = "\n
\n
";
goto process_text;
}
else if (!strncmp(line, ".\\}", 3))
{
/*
* Ignore close block...
*/
}
else if (!strncmp(line, ".ie", 3) || !strncmp(line, ".if", 3) ||
!strncmp(line, ".el", 3))
{
/*
* If/else - ignore...
*/
if (strchr(line, '{') != NULL)
{
/*
* Skip whole block...
*/
while (fgets(line, sizeof(line), infile))
{
linenum ++;
if (strchr(line, '}') != NULL)
break;
}
}
}
#if 0
else if (!strncmp(line, ". ", 4))
{
/*
* Grab ...
*/
}
#endif /* 0 */
else if (!strncmp(line, ".B ", 3))
{
/*
* Grab bold text...
*/
fprintf(outfile, "%s%s%s", end_fonts[font], line + 3,
start_fonts[font]);
}
else if (!strncmp(line, ".I ", 3))
{
/*
* Grab italic text...
*/
fprintf(outfile, "%s%s%s", end_fonts[font], line + 3,
start_fonts[font]);
}
else if (strncmp(line, ".\\\"", 3))
{
/*
* Unknown...
*/
if ((lineptr = strchr(line, ' ')) != NULL)
*lineptr = '\0';
else if ((lineptr = strchr(line, '\n')) != NULL)
*lineptr = '\0';
fprintf(stderr, "mantohtml: Unknown man page command \'%s\' on line %d!\n",
line, linenum);
}
/*
* Skip continuation lines...
*/
lineptr = line + strlen(line) - 2;
if (lineptr >= line && *lineptr == '\\')
{
while (fgets(line, sizeof(line), infile))
{
linenum ++;
lineptr = line + strlen(line) - 2;
if (lineptr < line || *lineptr != '\\')
break;
}
}
}
else
{
/*
* Process man page text...
*/
process_text:
for (lineptr = line; *lineptr; lineptr ++)
{
if (!strncmp(lineptr, "http://", 7))
{
/*
* Embed URL...
*/
for (endptr = lineptr + 7;
*endptr && !isspace(*endptr & 255);
endptr ++);
endchar = *endptr;
*endptr = '\0';
fprintf(outfile, "%s", lineptr, lineptr);
*endptr = endchar;
lineptr = endptr - 1;
}
else if (!strncmp(lineptr, "\\fI", 3) &&
(endptr = strstr(lineptr, "\\fR")) != NULL &&
(paren = strchr(lineptr, '(')) != NULL &&
paren < endptr)
{
/*
* Link to man page?
*/
char manfile[1024], /* Man page filename */
manurl[1024]; /* Man page URL */
/*
* See if the man file is available locally...
*/
lineptr += 3;
endchar = *paren;
*paren = '\0';
snprintf(manfile, sizeof(manfile), "%s.man", lineptr);
snprintf(manurl, sizeof(manurl), "man-%s.html?TOPIC=Man+Pages",
lineptr);
*paren = endchar;
endchar = *endptr;
*endptr = '\0';
if (access(manfile, 0))
{
/*
* Not a local man page, just do it italic...
*/
fputs("", outfile);
while (*lineptr)
putc_entity(*lineptr++, outfile);
fputs("", outfile);
}
else
{
/*
* Local man page, do a link...
*/
fprintf(outfile, "", manurl);
while (*lineptr)
putc_entity(*lineptr++, outfile);
fputs("", outfile);
}
*endptr = endchar;
lineptr = endptr + 2;
}
else if (*lineptr == '\\')
{
lineptr ++;
if (!*lineptr)
break;
else if (isdigit(lineptr[0]) && isdigit(lineptr[1]) &&
isdigit(lineptr[2]))
{
fprintf(outfile, "%d;", ((lineptr[0] - '0') * 8 +
lineptr[1] - '0') * 8 +
lineptr[2] - '0');
lineptr += 2;
}
else if (*lineptr == '&')
continue;
else if (*lineptr == 's')
{
while (lineptr[1] == '-' || isdigit(lineptr[1]))
lineptr ++;
}
else if (*lineptr == '*')
{
lineptr += 2;
}
else if (*lineptr != 'f')
putc_entity(*lineptr, outfile);
else
{
lineptr ++;
if (!*lineptr)
break;
else
{
fputs(end_fonts[font], outfile);
switch (*lineptr)
{
default : /* Regular */
font = 0;
break;
case 'B' : /* Bold */
case 'b' :
font = 1;
break;
case 'I' : /* Italic */
case 'i' :
font = 2;
break;
}
fputs(start_fonts[font], outfile);
}
}
}
else
putc_entity(*lineptr, outfile);
}
if (post)
{
fputs(post, outfile);
post = NULL;
}
}
}
fprintf(outfile, "%s\n", end_fonts[font]);
if (blist)
{
fputs("\n\n", outfile);
}
if (list)
{
if (list == 1)
fputs("\n", outfile);
else if (list)
fputs("