Ejemplo n.º 1
0
static void output_hdr( void )
/****************************/
{
    whp_fprintf( Out_file, "<HEAD>\n" );
    if( Ipf_title != NULL && Ipf_title[0] != '\0' ) {
        whp_fprintf( Out_file, "<TITLE> %s </TITLE>\n", Ipf_title );
    }
    whp_fprintf( Out_file, "</HEAD>\n" );
    whp_fprintf( Out_file, "<BODY>\n" );
}
Ejemplo n.º 2
0
static void output_hdr(
/*********************/

    void
) {
    whp_fprintf( Out_file, ":userdoc.\n" );
    if( Ipf_title != NULL && Ipf_title[0] != '\0' ) {
        whp_fprintf( Out_file, ":title.%s\n", Ipf_title );
    }
    whp_fprintf( Out_file, ":docprof toc=123456.\n" );
}
Ejemplo n.º 3
0
static void fake_hlink(
/*********************/

    FILE                        *file,
    char                        *label
) {
    if( Hyper_Brace_L == '<' ) {
        whp_fprintf( file, "<<" );
    }
    whp_fprintf( file, "%s%s%s", STR_BOLD_ON, label, STR_BOLD_OFF );
    if( Hyper_Brace_R == '>' ) {
        whp_fprintf( file, ">>" );
    }
    whp_fprintf( file, " " );
}
Ejemplo n.º 4
0
static void output_ctx_hdr( ctx_def *ctx )
/****************************************/
{
    int                         head_level;
    int                         p_skip;
    int                         i;

    head_level = ctx->head_level;
    if( head_level == 0 ) {
        /* OS/2 can't handle heading level 0 */
        head_level = 1;
    }
    head_level -= Curr_head_skip;
    if( head_level > Curr_head_level + 1 ) {
        /* you can't skip heading levels upwards in IPF. To handle this,
           you go up to the next level, and keep track of the
           skip for future heading levels. */
        p_skip = head_level - Curr_head_level - 1 ;
        head_level -= p_skip;
        Curr_head_skip += p_skip;
    } else if( head_level < Curr_head_level ) {
        head_level += Curr_head_skip;
        if( head_level > Curr_head_level ) {
            /* we moved down levels, but we're still too high! */
            Curr_head_skip = head_level - Curr_head_level;
            head_level -= Curr_head_skip;
        } else {
            Curr_head_skip = 0;
        }
    }

    Curr_head_level = head_level;

    whp_fprintf( Out_file, "\n" );

    for( i = 0; i < head_level; ++i )
        whp_fprintf( Out_file, "=" );

    whp_fprintf( Out_file, "%s", translate_str_wiki( ctx->title ) );

    for( i = 0; i < head_level; ++i )
        whp_fprintf( Out_file, "=" );

    whp_fprintf( Out_file, "\n" );

    /* browse lists are not used in wiki */
    /* nor does 'Up' topicing have any relevance */
}
Ejemplo n.º 5
0
static void ib_append_line(
/*************************/

    FILE                        *outfile,
    char                        *infnam
) {
    FILE                        *infile;
    int                         inchar;

    if( infnam[0] != '\0' ) {
        infile = fopen( infnam, "rt" );
        if( infile != NULL ) {
            for(;;) {
                inchar = fgetc( infile );

                if( inchar == EOF || inchar == '\n' ) {
                    break;
                }

                whp_fprintf( outfile, "%c", inchar );
            }
            fclose( infile );
        }
    }
}
Ejemplo n.º 6
0
static void output_end(
/*********************/

    void
) {
    whp_fprintf( Out_file, "\n" );
}
Ejemplo n.º 7
0
/* This function will do proper escaping or character substitution for
 * characters special to InfoBench and send them to the output stream.
 */
static void str_out_ib( FILE *f, char *str )
/******************************************/
{
    int         esc;

    if( str != NULL ) {
        for( ; *str != '\0'; ++str ) {
            esc = map_char_ib( *(unsigned char *)str );
            if( esc != MAP_REMOVE ) {
                if( esc != MAP_NONE ) {
                    whp_fprintf( f, "%c", esc );
                }
                whp_fwrite( str, 1, 1, f );
            }
        }
    }
}
Ejemplo n.º 8
0
static void output_ctx_hdr(
/*************************/

    ctx_def                     *ctx
) {
    ctx_def                     *temp_ctx;
    ctx_def                     *prev;      // for << button
    ctx_def                     *next;      // for >> button

    // output topic name
    whp_fprintf( Out_file, "::::\"" );
    str_out_ib( Out_file, ctx->title );
    whp_fprintf( Out_file, "\" 0 0\n" );

    // Header stuff:
    if( Do_tc_button
        || Do_idx_button
        || Do_browse
        || Do_up
        || Header_File[0] != '\0' ) {

        //beginning of header
        whp_fprintf( Out_file, ":h\n" );

        if( Do_tc_button ) {
            if( stricmp( ctx->ctx_name, "table_of_contents" ) != 0 ) {
                whp_fprintf( Out_file,
                                "%c" HB_CONTENTS "%cTable of Contents%c ",
                                Hyper_Brace_L,
                                CHR_HLINK_BREAK,
                                Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_CONTENTS );
            }
        }

        if( Do_kw_button ) {
            if( stricmp( ctx->ctx_name, "keyword_search" ) != 0 ) {
                whp_fprintf( Out_file,
                                "%c" HB_KEYWORDS "%cKeyword Search%c ",
                                Hyper_Brace_L,
                                CHR_HLINK_BREAK,
                                Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_KEYWORDS );
            }
        }

        if( Do_browse ) {
            find_browse_pair( ctx, &prev, &next );

            // << browse button
            if( prev != ctx ) {
                whp_fprintf( Out_file, "%c" HB_PREV "%c", Hyper_Brace_L,
                                CHR_HLINK_BREAK );
                str_out_ib( Out_file, prev->title );
                whp_fprintf( Out_file, "%c ", Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_PREV );
            }

            // >> browse button (relies on the find_browse_pair above)
            if( next != ctx ) {
                whp_fprintf( Out_file, "%c" HB_NEXT "%c", Hyper_Brace_L,
                                CHR_HLINK_BREAK );
                str_out_ib( Out_file, next->title );
                whp_fprintf( Out_file, "%c ", Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_NEXT );
            }
        }

        if( Do_idx_button ) {
            if( stricmp( ctx->ctx_name, "index_of_topics" ) != 0 ) {
                whp_fprintf( Out_file,
                                "%c" HB_INDEX "%cIndex of Topics%c ",
                                Hyper_Brace_L,
                                CHR_HLINK_BREAK,
                                Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_INDEX );
            }
        }

        // "Up" button
        if( Do_up ) {
            // find "parent" context
            for( temp_ctx = ctx->up_ctx; temp_ctx != NULL;
                                        temp_ctx = temp_ctx->up_ctx ) {
                if( !Remove_empty || !temp_ctx->empty ) {
                    break;
                }
            }

            // use table_of_contents if no "parent" context
            if( temp_ctx == NULL ) {
                temp_ctx = find_ctx( "table_of_contents" );
                if( temp_ctx == ctx) {
                    temp_ctx = NULL;
                }
            }

            // spit out up button stuff
            if( temp_ctx != NULL ) {
                whp_fprintf( Out_file, "%c" HB_UP "%c",
                                        Hyper_Brace_L, CHR_HLINK_BREAK );
                str_out_ib( Out_file, temp_ctx->title );
                whp_fprintf( Out_file, "%c ", Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_UP );
            }
        }
        // append user header file
        ib_append_line( Out_file, Header_File );

        // end of header
        whp_fprintf( Out_file, "\n:eh\n" );
    }
    // append user footer file
    if( Footer_File[0] != '\0' ) {
        whp_fprintf( Out_file, ":f\n" );
        ib_append_line( Out_file, Footer_File );
        whp_fprintf( Out_file, "\n:ef\n" );
    }
}
Ejemplo n.º 9
0
static void output_section_ib( section_def *section )
/***************************************************/
{
    int                         len;
    ctx_def                     *ctx;
    unsigned int                line;
    unsigned char               *label;
    int                         label_len;
    int                         ch;
    char                        *file;
    char                        *topic;
    unsigned char               *p;
    unsigned char               *end;

    p = (unsigned char *)section->section_text;
    end = p + section->section_size;
    len = 0;
    while( p + len < end ) {
        // stop when we hit a hyper-link
        if( *(p + len) != CHR_TEMP_HLINK ) {
            len++;
        } else {
            // write out the block of text we've got so far
            whp_fwrite( p, 1, len, Out_file );
            p += len + 1;

            // grab the line number
            for( len = 0; ; ++len ) {
                if( *(p + len) == CHR_TEMP_HLINK ) {
                    break;
                }
            }
            p[ len ] = '\0';
            line = atoi( (char *)p );
            p += len + 1;

            // find the length of the link label (what the user sees)
            for( len = 0; ; ++len ) {
                if( *(p + len) == CHR_HLINK_BREAK ) {
                    break;
                }
            }

            // if we're using the brace mode we strip off the "XX"
            if( Hyper_Brace_L == '<' ) {
                p += 2;
                len -= 2;
            }

            // output the label and the break
            label = p;
            label_len = len + 1;
            p += len + 1;

            // find the length of the link context
            for( len = 0; ; ++len ) {
                ch = *(p + len);
                if( ch == CHR_TEMP_HLINK || ch == CHR_HLINK_BREAK ) {
                    break;
                }
            }
            // null terminate the context name, and find the associated topic
            *(p + len) = '\0';
            topic = (char *)p;
            ctx = find_ctx( topic );

            // output the topic name that belongs to the context
            if( ctx == NULL && ch != CHR_HLINK_BREAK ) {
                warning( "Link to nonexistent context", line );
                printf( "For topic=%s\n", topic );
                whp_fwrite( label, 1, label_len - 1, Out_file );
            } else {
                // now we start writing the hyper-link
                whp_fwrite( &Hyper_Brace_L, 1, 1, Out_file );
                whp_fwrite( label, 1, label_len, Out_file );
                if( ctx != NULL ) {
                    str_out_ib( Out_file, ctx->title );
                } else {
                    str_out_ib( Out_file, topic );
                }
                if( ch == CHR_HLINK_BREAK ) {
                    /* file link. Get the file name */
                    file = (char *)(p + len + 1);
                    for( ;; ) {
                        ++len;
                        if( *(p + len) == CHR_TEMP_HLINK ) {
                            break;
                        }
                    }
                    *(p + len) = '\0';
                    whp_fprintf( Out_file, "%c%s", CHR_HLINK_BREAK, file );
                }
                whp_fwrite( &Hyper_Brace_R, 1, 1, Out_file );
            }

            // adjust the len and ctr counters appropriately
            p += len + 1;
            len = 0;
        }
    }
    // output whatever's left
    if( p < end ) {
        whp_fwrite( p, 1, end - p, Out_file );
    }
}
Ejemplo n.º 10
0
static void output_ctx_hdr(
/*************************/

    ctx_def                     *ctx
) {
    int                         head_level;
    char                        *ptr;
    keyword_def                 *key;
    keylist_def                 *keylist;
    int                         p_skip;

    head_level = ctx->head_level;
    if( head_level == 0 ) {
        /* OS/2 can't handle heading level 0 */
        head_level = 1;
    }
    head_level -= Curr_head_skip;
    if( head_level > Curr_head_level + 1 ) {
        /* you can't skip heading levels upwards in IPF. To handle this,
           you go up to the next level, and keep track of the
           skip for future heading levels. */
        p_skip = head_level - Curr_head_level - 1 ;
        head_level -= p_skip;
        Curr_head_skip += p_skip;
    } else if( head_level < Curr_head_level ) {
        head_level += Curr_head_skip;
        if( head_level > Curr_head_level ) {
            /* we moved down levels, but we're still too high! */
            Curr_head_skip = head_level - Curr_head_level;
            head_level -= Curr_head_skip;
        } else {
            Curr_head_skip = 0;
        }
    }

    Curr_head_level = head_level;

    whp_fprintf( Out_file, "\n:h%d res=%d id=%s.%s\n",
                                head_level, ctx->ctx_id, ctx->ctx_name,
                                translate_str_ipf( ctx->title ) );

    if( ctx->keylist != NULL ) {
        for( keylist = ctx->keylist; keylist != NULL;
                                            keylist = keylist->next ) {
            key = keylist->key;
            ptr = key->keyword;
            if( !key->duplicate ) {
                fputs( ":i1.", Out_file );
            } else {
                if( key->defined_ctx == ctx ) {
                    /* this is the first instance. :i1 and :i2 */
                    fprintf( Out_file, ":i1 id=%d.%s\n",
                                    key->id, translate_str_ipf( ptr ) );
                }

                if( stricmp( ptr, ctx->title ) == 0 ) {
                    /* we are about to out an index subentry whose
                       name is the same as the main index entry!
                       Skip it! */
                    continue;
                }
                fprintf( Out_file, ":i2 refid=%d.", key->id );
                ptr = ctx->title;
            }
            fputs( translate_str_ipf( ptr ), Out_file );
            fputc( '\n', Out_file );
        }
    }
    if( Real_ipf_font ) {
        /* The default font is system, which wouldn't be right */
        whp_fprintf( Out_file, ":font facename=Helv size=10x10.\n" );
    }
    /* browse lists are not used in IPF */
    /* nor does 'Up' topicing have any relevance */
}
Ejemplo n.º 11
0
static void output_end( void )
/****************************/
{
    whp_fprintf( Out_file, "</BODY>\n" );
}
Ejemplo n.º 12
0
static void output_end( void )
/****************************/
{
    whp_fprintf( Out_file, "\n:euserdoc.\n" );
}