Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. /*=============================================================================
  3.    GNU UnRTF, a command-line program to convert RTF documents to other formats.
  4.    Copyright (C) 2000,2001 Zachary Thayer Smith
  5.  
  6.    This program is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2 of the License, or
  9.    (at your option) any later version.
  10.  
  11.    This program is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with this program; if not, write to the Free Software
  18.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.  
  20.    The author is reachable by electronic mail at tuorfa@yahoo.com.
  21. =============================================================================*/
  22.  
  23.  
  24. /*----------------------------------------------------------------------
  25.  * Module name:    text
  26.  * Author name:    Zach Smith
  27.  * Create date:    19 Sep 01
  28.  * Purpose:        Plain text output module
  29.  *----------------------------------------------------------------------
  30.  * Changes:
  31.  * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
  32.  *--------------------------------------------------------------------*/
  33.  
  34.  
  35. #include <stdio.h>
  36. #include <string.h>
  37. #include "malloc.h"
  38. #include "defs.h"
  39. #include "error.h"
  40. #include "main.h"
  41. #include "output.h"
  42.  
  43.  
  44. static char*
  45. ascii_translation_table [96] = {
  46.         /* 0x20 */ " ", "!", "\"", "#", "$", "%", "&", "'",
  47.         /* 0x28 */ "(", ")", "*", "+", ",", "-", ".", "/",
  48.         /* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7",
  49.         /* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?",
  50.         /* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G",
  51.         /* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O",
  52.         /* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W",
  53.         /* 0x58 */ "X", "Y", "Z", "[", "\\", "]", "^", "_",
  54.         /* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g",
  55.         /* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o",
  56.         /* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w",
  57.         /* 0x78 */ "x", "y", "z", "{", "|", "}", "~", "",
  58. };
  59.  
  60. static char*
  61. upper_translation_table [128] = {
  62.         "?", "?", "?", "?", "?", "?", "?", "?",
  63.         "?", "?", "?", "?", "?", "?", "?", "?",
  64.         "?", "?", "?", "?", "?", "?", "?", "?",
  65.         "?", "?", "?", "?", "?", "?", "?", "?",
  66.         "?", "?", "?", "?", "?", "?", "?", "?",
  67.         "?", "?", "?", "?", "?", "?", "?", "?",
  68.         "?", "?", "?", "?", "?", "?", "?", "?",
  69.         "?", "?", "?", "?", "?", "?", "?", "?",
  70.         "?", "?", "?", "?", "?", "?", "?", "?",
  71.         "?", "?", "?", "?", "?", "?", "?", "?",
  72.         "?", "?", "?", "?", "?", "?", "?", "?",
  73.         "?", "?", "?", "?", "?", "?", "?", "?",
  74.         "?", "?", "?", "?", "?", "?", "?", "?",
  75.         "?", "?", "?", "?", "?", "?", "?", "?",
  76.         "?", "?", "?", "?", "?", "?", "?", "?",
  77.         "?", "?", "?", "?", "?", "?", "?", "?",
  78. };
  79.  
  80.  
  81.  
  82. /*========================================================================
  83.  * Name:        text_init
  84.  * Purpose:     Generates an output personality for the plain text format.
  85.  * Args:        None.
  86.  * Returns:     OutputPersonality.
  87.  *=======================================================================*/
  88.  
  89. OutputPersonality *
  90. text_init (void)
  91. {
  92.         OutputPersonality* text_op;
  93.  
  94.         text_op = op_create();
  95.  
  96.         text_op->comment_begin = "### ";
  97.         text_op->comment_end = "\n";
  98.  
  99.         text_op->document_begin = "";
  100.         text_op->document_end = "";
  101.  
  102.         text_op->header_begin = "";
  103.         text_op->header_end = "";
  104.  
  105.         text_op->document_title_begin = "\nTITLE: ";
  106.         text_op->document_title_end = "\n";
  107.  
  108.         text_op->document_author_begin = "\nAUTHOR: ";
  109.         text_op->document_author_end = "\n";
  110.  
  111.         text_op->document_changedate_begin = "\nDATE: ";
  112.         text_op->document_changedate_end = "\n";
  113.  
  114.         text_op->body_begin = "\n-----------------\n";
  115.         text_op->body_end = "";
  116.  
  117.         text_op->paragraph_begin = "";
  118.         text_op->paragraph_end = "\n";
  119.  
  120.         text_op->center_begin = "";
  121.         text_op->center_end = "";
  122.  
  123.         text_op->justify_begin = "";
  124.         text_op->justify_end = "";
  125.  
  126.         text_op->align_left_begin = "";
  127.         text_op->align_left_end = "";
  128.  
  129.         text_op->align_right_begin = "";
  130.         text_op->align_right_end = "";
  131.  
  132.         text_op->forced_space = " ";
  133.         text_op->line_break = "\n";
  134.         text_op->page_break = "\n";
  135.  
  136.         text_op->hyperlink_begin = "";
  137.         text_op->hyperlink_end = "";
  138.  
  139.         text_op->imagelink_begin = "";
  140.         text_op->imagelink_end = "";
  141.  
  142.         text_op->table_begin = "\n";
  143.         text_op->table_end = "\n";
  144.  
  145.         text_op->table_row_begin = "";
  146.         text_op->table_row_end = "\n";
  147.  
  148.         text_op->table_cell_begin = "\t";
  149.         text_op->table_cell_end = "";
  150.  
  151.         /* Character attributes */
  152.         text_op->font_begin = "";
  153.         text_op->font_end = "";
  154.  
  155.         text_op->fontsize_begin = "";
  156.         text_op->fontsize_end = "";
  157.  
  158.         text_op->fontsize8_begin = "";
  159.         text_op->fontsize8_end = "";
  160.         text_op->fontsize10_begin = "";
  161.         text_op->fontsize10_end = "";
  162.         text_op->fontsize12_begin = "";
  163.         text_op->fontsize12_end = "";
  164.         text_op->fontsize14_begin = "";
  165.         text_op->fontsize14_end = "";
  166.         text_op->fontsize18_begin = "";
  167.         text_op->fontsize18_end = "";
  168.         text_op->fontsize24_begin = "";
  169.         text_op->fontsize24_end = "";
  170.  
  171.         text_op->smaller_begin = "";
  172.         text_op->smaller_end = "";
  173.  
  174.         text_op->bigger_begin = "";
  175.         text_op->bigger_end = "";
  176.  
  177.         text_op->foreground_begin = "";
  178.         text_op->foreground_end = "";
  179.  
  180.         text_op->background_begin = "";
  181.         text_op->background_end = "";
  182.  
  183.         text_op->bold_begin = "";
  184.         text_op->bold_end = "";
  185.  
  186.         text_op->italic_begin = "";
  187.         text_op->italic_end = "";
  188.  
  189.         text_op->underline_begin = "";
  190.         text_op->underline_end = "";
  191.  
  192.         text_op->dbl_underline_begin = "";
  193.         text_op->dbl_underline_end = "";
  194.  
  195.         text_op->superscript_begin = "";
  196.         text_op->superscript_end = "";
  197.  
  198.         text_op->subscript_begin = "";
  199.         text_op->subscript_end = "";
  200.  
  201.         text_op->strikethru_begin = "";
  202.         text_op->strikethru_end = "";
  203.  
  204.         text_op->dbl_strikethru_begin = "";
  205.         text_op->dbl_strikethru_end = "";
  206.  
  207.         text_op->emboss_begin="";
  208.         text_op->emboss_end = "";
  209.  
  210.         text_op->engrave_begin = "";
  211.         text_op->engrave_end = "";
  212.  
  213.         text_op->shadow_begin= "";
  214.         text_op->shadow_end= "";
  215.  
  216.         text_op->outline_begin= "";
  217.         text_op->outline_end= "";
  218.  
  219.         text_op->expand_begin = "";
  220.         text_op->expand_end = "";
  221.  
  222.         text_op->pointlist_begin = "\n";
  223.         text_op->pointlist_end = "\n";
  224.         text_op->pointlist_item_begin = "  * ";
  225.         text_op->pointlist_item_end = "\n";
  226.  
  227.         text_op->numericlist_begin = "\n";
  228.         text_op->numericlist_end = "\n";
  229.         text_op->numericlist_item_begin = "  # ";
  230.         text_op->numericlist_item_end = "\n";
  231.  
  232.         text_op->simulate_small_caps = TRUE;
  233.         text_op->simulate_all_caps = TRUE;
  234.         text_op->simulate_word_underline = TRUE;
  235.  
  236.         text_op->ascii_translation_table = ascii_translation_table;
  237.  
  238.         text_op->ansi_translation_table = upper_translation_table;
  239.         text_op->ansi_first_char = 0x80;
  240.         text_op->ansi_last_char = 0xff;
  241.  
  242.         text_op->cp437_translation_table = upper_translation_table;
  243.         text_op->cp437_first_char = 0x80;
  244.         text_op->cp437_last_char = 0xff;
  245.  
  246.         text_op->cp850_translation_table = upper_translation_table;
  247.         text_op->cp850_first_char = 0x80;
  248.         text_op->cp850_last_char = 0xff;
  249.  
  250.         text_op->mac_translation_table = upper_translation_table;
  251.         text_op->mac_first_char = 0x80;
  252.         text_op->mac_last_char = 0xff;
  253.  
  254.         text_op->chars.right_quote = "'";
  255.         text_op->chars.left_quote = "`";
  256.         text_op->chars.right_dbl_quote = "''";
  257.         text_op->chars.left_dbl_quote = "``";
  258.  
  259.         return text_op;
  260. }
  261.  
  262.  
  263.