Sophie

Sophie

distrib > * > 2010.0 > * > by-pkgid > bb2b3181a15385f4d6701135404d7ec7 > files > 62

drakx-autoinstall-doc-10.0.3-6mdv2010.0.noarch.rpm

/*
 *      File:   so_split.h
 *      Date:   2004-02-21
 *
 *      Local Definitions and declaritions for the
 *      Open/Star Office to HTML Spliting program: so_split
 *
 *      Copyright 2001,2002,2003,2004 David Eastcott <david@eastcott.net>
 *      Released under terms of GPL
 *
 */

#ifndef _SO_SPLIT_H_
#define _SO_SPLIT_H_

// #define DEBUG 1

//      Constants and the like
#define BUFFER_SIZE             2048                    // size of input line buffer
#define FILE_NAME_SIZE          1024                    // max size for a file name
#define TITLE_NAME_SIZE         64                      // max size for a document title

#define HEAD_FILE               "HEAD.HEAD"             // file contaning the original html HEAD info
#define TITLE_FILE              "title.html"            // where we are going to put the TITLE information
#define TOC_FILE                "index.html"            // name of the file containing the table of contents

#define TITLE_SECTION_ID        1               // ID for Title section
#define TOC_SECTION_ID          2               // ID for Table of Contents section
#define BODY_SECTION_ID         3               // base ID for remaining sections

#ifndef FALSE
#define FALSE                   0
#endif

#ifndef TRUE
#define TRUE                    1
#endif

#define FORWARD                 FALSE
#define BACKWARD                TRUE

#define ANCHOR_TAG_NAME         "<A NAME=\""
#define ANCHOR_TAG_NAME_END     "\">"
#define ANCHOR_TAG_END          "</A>"

#define BODY_TAG                "<BODY>"
#define BODY_TAG_OPEN           "<BODY"
#define BODY_TAG_END            "</BODY>"

#define DIV_TAG_END             "</DIV>"
#define DIV_TAG_END_OPEN        "</DIV"

#define HEAD_TAG_END            "</HEAD>"
#define HEADER_1_TAG            "<H1"
#define HEADER_1_TAG_END        "</H1>"
#define HEADER_2_TAG            "<H2"
#define HEADER_2_TAG_END        "</H2>"
#define HEADER_TAG_END_OPEN     "</H"

#define HREF_TAG                "<A HREF=\""
#define HREF_TAG_END            "\">"

#define PARA_TAG                "<P>"
#define PARA_TAG_OPEN           "<P"
#define PARA_TAG_END            "</P>"

#define TABLE_TAG               "<TABLE>"
#define TABLE_TAG_END           "</TABLE>"
#define TABLE_ROW_TAG           "<TR>"
#define TABLE_ROW_TAG_END       "</TR>"
#define TABLE_CELL_TAG          "<TD>"
#define TABLE_CELL_TAG_END      "</TD>"

#define TITLE_TAG               "<TITLE>"

#define TOC_DIV_TAG             "<DIV ID=\"Table"


//      Structures
typedef struct section_info {                           // the master section structure

        struct section_info     *pfwd;                                  // next in the chain
        struct section_info     *prvs;                                  // previous in the chain
        int                     section_id;                             // section number
        int                     sub_section_id;                         // sub-section number
        char                    section_id_name[FILE_NAME_SIZE+1];      // temp filename to use for section
        char                    title[FILE_NAME_SIZE+1];                // title for file
        char                    filename[FILE_NAME_SIZE+1];             // place to hold file name

} SECTION_INFO;

typedef struct  symbol_table    {                       // symbol table entry

        struct  symbol_table    *pfwd;                                  // next symbol
        char                     name[TITLE_NAME_SIZE+1];               // Anchor NAME=Attribute
        char                     name_text[TITLE_NAME_SIZE+1];          // Anchor Text
        SECTION_INFO             *section_info;                         // Section containing data

} SYMBOL_TABLE;

typedef struct  symbol_queue    {                       // symbol table chain control variables

        SYMBOL_TABLE    *head;                                          // head of the chain
        SYMBOL_TABLE    *tail;                                          // last entry of chain

} SYMBOL_QUEUE;

//      Static Data

char    *usage = {"Usage: cvt -s | -t <html source file> [<target directory>]\n"};

char    *Split_Section_Title = { "Anatomy of the 'auto_inst.cfg' File" };

char    *head_leader[] = {
        "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n",
        "<TR><TH COLSPAN=\"3\" ALIGN=\"CENTER\">\n",
        "TITLE",
        "</TH></TR><TR>\n",
        "<TD WIDTH=\"10%\" ALIGN=\"LEFT\" VALIGN=\"BOTTOM\">\n",
        "PREV",         // "<a href="<previous file>">Prev</a></td>
        "<TD WIDTH=\"80%\" ALIGN=\"CENTER\" VALIGN=\"BOTTOM\"></TD>\n",
        "<TD WIDTH=\"10%\" ALIGN=\"RIGHT\" VALIGN=\"BOTTOM\">\n",
        "NEXT",         // "<a href="<next file>">Next</a></td>
        "</TR></TABLE><HR ALIGN=\"LEFT\" WIDTH=\"100%\">\n",
	NULL
};

char    *end_leader[] = {
        "<HR ALIGN=\"LEFT\" WIDTH=\"100%\">\n",
        "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n",
        "<TR><TD WIDTH=\"33%\" ALIGN=\"LEFT\" VALIGN=\"TOP\">",
        "PREV",                          // <a href="previous file name"></a></td>
        "<TD WIDTH=\"34%\" ALIGN=\"CENTER\" VALIGN=\"TOP\">",
        "<A HREF=\"index.html\">Home</A></TD>\n",
        "<TD WIDTH=\"33%\" ALIGN=\"RIGHT\" VALIGN=\"TOP\">",
        "NEXT",                         // <a href="next file name"></a></td>
        "</TR>\n",
        "<TR><TD WIDTH=\"33%\" ALIGN=\"LEFT\" VALIGN=\"TOP\">",
        "PREVIOUS_SECTION",
        "</TD>\n",
        "<TD WIDTH=\"34%\" ALIGN=\"CENTER\" VALIGN=\"TOP\">&nbsp;</TD>\n",
        "<TD WIDTH=\"33%\" ALIGN=\"RIGHT\" VALIGN=\"TOP\">",
        "NEXT_SECTION",
        "</TD></TR></TABLE>\n",
        NULL
};

//      start of body stuff
char *head_lines[] = {

        "<BODY ",
        "BGCOLOR=\"#FFFFFF\" ",
        "TEXT=\"#000000\" ",
        "LINK=\"#0000FF\" ",
        "VLINK=\"#840084\" ",
        "ALINK=\"#0000FF\">\n",
        NULL,
};



//      Function Prototypes
static  void    add_end_file( FILE *pout );
static  void    add_end_leader( FILE *pout, SECTION_INFO *section_info );
static  void    add_head_file( FILE *pout );
static  void    add_head_leader( FILE *pout, SECTION_INFO *section_info );
static  void    add_to_queue ( SECTION_INFO **section_info_queue, SECTION_INFO *section_info );
static  void    add_to_symbols( SYMBOL_TABLE *symbol, SYMBOL_QUEUE *symbol_queue );
static  void    adjust_href( char *line_buffer, SECTION_INFO *section_info, SYMBOL_QUEUE *symbol_queue );
static  void    build_symbol_table( char *line_buffer, SECTION_INFO **section_info_queue, SYMBOL_QUEUE *symbol_queue );
static  void    get_head( FILE *pin, char *line_buffer );
static  void    get_html_field( FILE *pin, FILE *pout, char *line_buffer, char *position, char *token_buffer, char *end_tag );
static  void    get_section_title( char *line_buffer, SECTION_INFO *section_info, char *end_tag, FILE *pin, FILE *pout );
static  void    get_title_section( FILE *pin, char *line_buffer, SECTION_INFO **section_info_queue );
static  void    get_toc_section( FILE *pin, char *line_buffer, SECTION_INFO **section_info_queue );
static  void    make_adjusted_html( char *line_buffer, SECTION_INFO **section_info_queue, SYMBOL_QUEUE *symbol_queue );
static  void    make_html( char *line_buffer, SECTION_INFO **section_info_queue, SYMBOL_QUEUE *symbol_queue );
static  char    *move_past_token( int direction, char *buffer );
static  void    my_memmove( char *dest, char *src, int count );
static  char    *move_past_tokens( char *position );
static  void    split_source( FILE *pin, char *line_buffer, SECTION_INFO **section_info_queue );
static  void    strip_tail_white_space( char *token_buffer );

static  int     split_main( int argc, char *argv[] );
static  int     toc_main( int argc, char *argv[] );
        int     main( int argc, char *argv[]  );

#endif /* end of ifndef _SO_SPLIT_H_ */