summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Crozat <fcrozat@mandrakesoft.com>2001-03-03 01:25:34 +0000
committerGene Ragan <gzr@src.gnome.org>2001-03-03 01:25:34 +0000
commit881b1aff0cd61ea302400decc661e0c920b4deae (patch)
tree92ad6fad94b97013dd1e62c196b381ef0262b999
parentbc5bc3f2ffa4ba7417aa2f4ddb4be78b5d606425 (diff)
downloadyelp-881b1aff0cd61ea302400decc661e0c920b4deae.tar.gz
reviewed by: Gene Z. Ragan <gzr@eazel.com>
2001-03-02 Frederic Crozat <fcrozat@mandrakesoft.com> reviewed by: Gene Z. Ragan <gzr@eazel.com> Fixed bug 7276, No support for bzipped man and info pages -- problem for Mandrake Note that the coding style of these files is not the same as the rest of the Nautilus source code. * components/help/converters/gnome-info2html2/Makefile.am: * components/help/converters/gnome-info2html2/main.c: (main): * components/help/converters/gnome-man2html2/Makefile.am: * components/help/converters/gnome-man2html2/gnome-man2html.c: (read_man_page): * components/help/hyperbola-filefmt.c: (extract_secnum_from_filename), (man_name_without_suffix), (fmt_man_populate_tree_for_subdir):
-rw-r--r--src/info2html/Makefile.am2
-rw-r--r--src/info2html/main.c38
-rw-r--r--src/man2html/Makefile.am2
-rw-r--r--src/man2html/yelp-man2html.c40
4 files changed, 76 insertions, 6 deletions
diff --git a/src/info2html/Makefile.am b/src/info2html/Makefile.am
index 0db75f6e..65ede631 100644
--- a/src/info2html/Makefile.am
+++ b/src/info2html/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = \
$(GNOME_CFLAGS)
LDADD = \
- $(GNOME_LIBS) $(Z_LIBS)
+ $(GNOME_LIBS) $(Z_LIBS) $(BZ_LIBS)
bin_PROGRAMS = gnome-info2html2
diff --git a/src/info2html/main.c b/src/info2html/main.c
index ddbc2501..dac861ff 100644
--- a/src/info2html/main.c
+++ b/src/info2html/main.c
@@ -6,6 +6,9 @@
#include <string.h>
#include <gnome.h>
#include <zlib.h>
+#ifdef HAVE_LIBBZ2
+#include <bzlib.h>
+#endif
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -43,6 +46,10 @@ int
main(int argc, char **argv)
{
gzFile f = NULL;
+#ifdef HAVE_LIBBZ2
+ BZFILE *bf=NULL;
+#endif
+ int bz = 0;
char line[250];
poptContext ctx;
int result;
@@ -95,9 +102,16 @@ main(int argc, char **argv)
break;
ext = ".gz";
sprintf(buf, "%s/%s.info.gz", dirs[i], args[0]);
-
if(file_exists(buf))
break;
+#ifdef HAVE_LIBBZ2
+ ext = ".bz2";
+ sprintf(buf, "%s/%s.info.bz2", dirs[i], args[0]);
+ if(file_exists(buf)) {
+ bz = 1;
+ break;
+ }
+#endif
}
if(i >= ndirs) {
printf ("<HTML><HEAD><TITLE>Document not found</TITLE>\n"
@@ -156,6 +170,28 @@ main(int argc, char **argv)
/* No need to store all nodes, etc since we let web server */
/* handle resolving tags! */
for (;1 || !foundit || !requested_nodename;) {
+#ifdef HAVE_LIBBZ2
+ if(bz && !bf) {
+ if(args && args[curarg])
+ {
+ bf = bzopen(args[curarg++], "r");
+ if(!f)
+ break;
+ num_files_left = args[curarg]?1:0;
+ for(work_line_number = 0, bzread(bf, line, sizeof(line)); *line != INFO_COOKIE;
+ bzread(bf, line, sizeof(line)), work_line_number++)
+ /**/ ;
+ }
+ else
+ break;
+ }
+ if(!bzread(bf, line, sizeof(line)))
+ {
+ bzclose(bf);
+ bf = NULL;
+ continue;
+ }
+#endif
if(!f) {
if(args && args[curarg])
{
diff --git a/src/man2html/Makefile.am b/src/man2html/Makefile.am
index eae368b3..004bee0f 100644
--- a/src/man2html/Makefile.am
+++ b/src/man2html/Makefile.am
@@ -5,7 +5,7 @@ INCLUDES = \
-I$(top_srcdir)/intl -I$(top_builddir)/intl
-LDADD = $(Z_LIBS)
+LDADD = $(Z_LIBS) $(BZ_LIBS)
bin_PROGRAMS = gnome-man2html2
diff --git a/src/man2html/yelp-man2html.c b/src/man2html/yelp-man2html.c
index 665d7340..b2afe3e1 100644
--- a/src/man2html/yelp-man2html.c
+++ b/src/man2html/yelp-man2html.c
@@ -136,6 +136,9 @@
#include <errno.h>
#include <fcntl.h>
#include <zlib.h>
+#ifdef HAVE_LIBBZ2
+#include <bzlib.h>
+#endif
static char *URLbasename = NULL;
@@ -364,6 +367,9 @@ static STRDEF standardchar[] = {
static char escapesym='\\', nobreaksym='\'', controlsym='.', fieldsym=0, padsym=0;
static gzFile infh = NULL;
+#ifdef HAVE_LIBBZ2
+static BZFILE * inbfh = NULL;
+#endif
static char *buffer=NULL;
static int buffpos=0, buffmax=0;
static int scaninbuff=0;
@@ -430,7 +436,12 @@ static char
int bytes;
/* input from stdin */
- bytes = gzread(infh, buf, sizeof(buf));
+#ifdef HAVE_LIBBZ2
+ if (inbfh)
+ bytes = bzread(inbfh, buf, sizeof(buf));
+ else
+#endif
+ bytes = gzread(infh, buf, sizeof(buf));
while (bytes > 0) {
if (!man_buf) {
man_buf = malloc(bytes+1);
@@ -442,6 +453,11 @@ static char
memcpy(man_buf+buf_size, buf, bytes);
buf_size += bytes;
+#ifdef HAVE_LIBBZ2
+ if (inbfh)
+ bytes = bzread(inbfh, buf, sizeof(buf));
+ else
+#endif
bytes = gzread(infh, buf, sizeof(buf));
}
@@ -3683,8 +3699,17 @@ main(int argc, char **argv)
infh = gzdopen(0, "r");
else
{
+#ifdef HAVE_LIBBZ2
+ if (strstr(infile,".bz2"))
+ inbfh = bzopen(infile, "r");
+ else
+#endif
infh = gzopen(infile, "r");
+#ifdef HAVE_LIBBZ2
+ if(!infh && !inbfh)
+#else
if(!infh)
+#endif
{
FILE *fh;
char cmdline[512], *ctmp, output[512];
@@ -3709,12 +3734,21 @@ main(int argc, char **argv)
i = strlen(output) - 1;
while(isspace(output[i])) output[i--] = '\0';
- if(output[0])
+ if (output[0]) {
+#ifdef HAVE_LIBBZ2
+ if(strstr(output,".bz2"))
+ inbfh = bzopen(output, "r");
+ else
+#endif
infh = gzopen(output, "r");
-
+ }
}
}
+#ifdef HAVE_LIBBZ2
+ if(!infh && !inbfh) {
+#else
if(!infh) {
+#endif
printf("<HTML><HEAD><TITLE>Document not found</TITLE>\n"
"</HEAD><BODY>The document \"%s\" couldn't be found. It may have been removed from your system.\n"
"</BODY></HTML>\n", infile);