From 30de0006d013df0d1eed44e15b7a242660559318 Mon Sep 17 00:00:00 2001 From: rhlabs Date: Thu, 26 Feb 1998 00:03:11 +0000 Subject: Marc and I worked on alot today: - caching of files/images - info files only load component needed for HTML conversion, which helps since before we'd load the 1.7 megs of emacs GNU info data, now its typically a max of 64k. - entry box appears to work - moved towards a cleaner internal design for 'magic' URLs like 'info:' Tommorrow we'll implement the 'man:' magic url. Then all thats left is searching... Dr Mike --- components/help/converters/gnome-info2html2/html.c | 21 +- components/help/converters/gnome-info2html2/html.h | 2 + components/help/converters/gnome-info2html2/main.c | 233 ++++++++++++--------- 3 files changed, 145 insertions(+), 111 deletions(-) diff --git a/components/help/converters/gnome-info2html2/html.c b/components/help/converters/gnome-info2html2/html.c index c97c0cfec..f57f5d017 100644 --- a/components/help/converters/gnome-info2html2/html.c +++ b/components/help/converters/gnome-info2html2/html.c @@ -18,6 +18,8 @@ #define USE_FILE_URLS +char *BaseFilename=NULL; + /* print out the url for a info file */ char *form_info_tag_href( char *nodefile, char *nodename ) { @@ -25,21 +27,8 @@ char *form_info_tag_href( char *nodefile, char *nodename ) char *escaped_nodename; escaped_nodename = escape_html_chars( nodename ); - -#if 0 -#ifdef USE_FILE_URLS - snprintf(tmp,sizeof(tmp), - "HREF=\"../%s/%s.html\"", nodefile, escaped_nodename ); -#else - snprintf(tmp,sizeof(tmp), - "HREF=\"/cgi-bin/grab-info-file?doctype=info&" - "docname=%s&doctag=%s\"", nodefile, escaped_nodename ); -#endif -#endif -/* snprintf(tmp,sizeof(tmp),"HREF=\"info:%s#%s\"", nodefile, escaped_nodename ); */ - - snprintf(tmp,sizeof(tmp),"HREF=\"info:%s#%s\"", nodefile, escaped_nodename ); - + snprintf(tmp,sizeof(tmp),"HREF=\"info:%s#%s\"", + ((BaseFilename) ? BaseFilename : nodefile), escaped_nodename ); if (escaped_nodename) g_free(escaped_nodename); return g_strdup(tmp); @@ -796,7 +785,7 @@ void write_menu_entry_html( FILE *f, char *p, char *nodefile, char **menu_end ) } for (i=1; i<4; i++) - if (!isblank(*(realend+i)) && *(realend+i) != '\n') + if (!isspace(*(realend+i)) && *(realend+i) != '\n') { done = 1; break; diff --git a/components/help/converters/gnome-info2html2/html.h b/components/help/converters/gnome-info2html2/html.h index 8a0f56940..162829c83 100644 --- a/components/help/converters/gnome-info2html2/html.h +++ b/components/help/converters/gnome-info2html2/html.h @@ -6,6 +6,8 @@ #define HEADER_SIZE_1 "H1" #define HEADER_SIZE_2 "H2" +extern char *BaseFilename; + void dump_html_for_node( NODE *node ); void open_body_text_html( FILE *f ); diff --git a/components/help/converters/gnome-info2html2/main.c b/components/help/converters/gnome-info2html2/main.c index 398ae2afb..e40b27e84 100644 --- a/components/help/converters/gnome-info2html2/main.c +++ b/components/help/converters/gnome-info2html2/main.c @@ -11,102 +11,145 @@ #include "version.h" int -main(argc, argv) -int argc; -char **argv; +main(int argc, char **argv) { - FILE *f; - char line[250]; - - int result; - - NODE *node; - -if (!be_quiet) - printf("info2html Version %s\n",INFO2HTML_VERSION); - - if (argc == 1) - { - f = stdin; - strcpy(work_filename, "STDIN"); - } - else - { - if ((f=fopen(argv[1], "r"))==NULL) { - fprintf(stderr, "File %s not found.\n",argv[1]); - exit(1); - } - strcpy(work_filename, argv[1]); - } - - work_line_number = 0; - - - /* scan for start of real data */ - for (;1;) { - fgets(line,250,f); - if (feof(f)) - { - fprintf(stderr,"Info file had no contents\n"); - exit(1); - } - - work_line_number++; - if (*line == INFO_COOKIE) - break; - - } - - /* hack, just send to stdout for now */ - fprintf(stdout, "\n"); - - /* big loop to identify sections of info files */ - /* NEW PLAN - format on the fly */ - /* No need to store all nodes, etc since we let web server */ - /* handle resolving tags! */ - for (;1;) { - fgets(line,250,f); - if (feof(f)) - break; - - work_line_number++; - - /* found a node definition line */ - if (!strncmp(line, "File:", 5)) - { - node = alloc_node(); - result=read_node( f, line, node ); - if ( result == READ_ERR ) - { - fprintf(stderr, "Error reading the node contents\n"); - fprintf(stderr, "line was |%s|\n",line); - continue; - } - - strcpy(work_node,node->nodename); - + FILE *f; + char line[250]; + + char *requested_nodename=NULL; + int aptr; + int result; + int foundit=0; + + NODE *node; + + if (!be_quiet) + printf("info2html Version %s\n",INFO2HTML_VERSION); + + /* simplistic command line parsing for now */ + aptr = argc; + while (aptr > 2) { + if (!strcmp(argv[argc-aptr+1], "-a")) { + char *s, *t; + int len; + + requested_nodename = strdup(argv[argc-aptr+2]); + /* strip off quotes */ + for (s=requested_nodename; *s == '\"'; ) { + len = strlen( s ); + memmove(s, s+1, len); + } + + t = s + strlen(s) - 1; + while (*t == '\"') + t--; + + *(t+1) = '\0'; + + fprintf(stderr, "outputting node %s\n", + requested_nodename); + aptr -= 2; + } else if (!strcmp(argv[argc-aptr+1], "-b")) { + BaseFilename = strdup(argv[argc-aptr+2]); + fprintf(stderr, "outputting basefile %s\n", + BaseFilename); + aptr -= 2; + } + } + + if (aptr == 1) { + f = stdin; + strcpy(work_filename, "STDIN"); + } else { + if ((f=fopen(argv[argc-aptr+1], "r"))==NULL) { + fprintf(stderr, "File %s not found.\n",argv[1]); + exit(1); + } + strcpy(work_filename, argv[1]); + } + + work_line_number = 0; + + + /* scan for start of real data */ + for (;1;) { + fgets(line,250,f); + if (feof(f)) + { + fprintf(stderr,"Info file had no contents\n"); + exit(1); + } + + work_line_number++; + if (*line == INFO_COOKIE) + break; + + } + + /* hack, just send to stdout for now */ + fprintf(stdout, "\n"); + + /* big loop to identify sections of info files */ + /* NEW PLAN - format on the fly */ + /* No need to store all nodes, etc since we let web server */ + /* handle resolving tags! */ + for (;1 || !foundit || !requested_nodename;) { + fgets(line,250,f); + if (feof(f)) + break; + + work_line_number++; + + /* found a node definition line */ + if (!strncmp(line, "File:", 5)) { + node = alloc_node(); + result=read_node( f, line, node ); + if ( result == READ_ERR ) { + fprintf(stderr, "Error reading the node " + "contents\n"); + fprintf(stderr, "line was |%s|\n",line); + continue; + } + + /* see if this is the requested node name */ + if (requested_nodename && + strcmp(requested_nodename, node->nodename)) { + fprintf(stderr, "skipping ->%s<-\n", + node->nodename); + + continue; + } + + foundit = 1; + strcpy(work_node,node->nodename); + #ifdef DEBUG - printf("NEW NODE\n"); - printf("\tFile:|%s|\n\tNode:|%s|\n\tNext:|%s|\n", - node->filename, node->nodename,node->next); - printf("\tPrev:|%s|\n\tUp:|%s|\n\n", node->prev, node->up); - printf("------------------------------------------------------\n"); + printf("NEW NODE\n"); + printf("\tFile:|%s|\n\tNode:|%s|\n\tNext:|%s|\n", + node->filename, node->nodename,node->next); + printf("\tPrev:|%s|\n\tUp:|%s|\n\n", + node->prev, node->up); + printf("-------------------------------------------" + "-----------\n"); #endif - /* now lets make some html */ - /* first make sure the subdir for this info file exists */ - dump_html_for_node( node ); - - if (node) - { - if ( node->contents ) - free(node->contents); - - free(node); - } - } - else - continue; - } - fprintf(stdout, "\n"); - return 0; + /* now lets make some html */ + dump_html_for_node( node ); + + if (node) { + if ( node->contents ) + free(node->contents); + + free(node); + } + } + else + continue; + } + + if (!foundit && requested_nodename) + fprintf(stdout, "Requested node %s not found\n", + requested_nodename); + + fprintf(stdout, "\n"); + return 0; } -- cgit v1.2.1