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:    wpml
  26.  * Author name:    Zach Smith
  27.  * Create date:    19 Sep 01
  28.  * Purpose:        WPML output module
  29.  * Note:           WPML is my own format; it is a work-in-progress
  30.  *----------------------------------------------------------------------
  31.  * Changes:
  32.  * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
  33.  *--------------------------------------------------------------------*/
  34.  
  35.  
  36. #include <stdio.h>
  37. #include <string.h>
  38. #include "malloc.h"
  39. #include "defs.h"
  40. #include "error.h"
  41. #include "main.h"
  42. #include "output.h"
  43.  
  44.  
  45. static char*
  46. ascii_translation_table [96] = {
  47.         /* 0x20 */ " ", "!", "\"", "#", "$", "%", "&", "'",
  48.         /* 0x28 */ "(", ")", "*", "+", ",", "-", ".", "/",
  49.         /* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7",
  50.         /* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?",
  51.         /* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G",
  52.         /* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O",
  53.         /* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W",
  54.         /* 0x58 */ "X", "Y", "Z", "[", "\\", "]", "^", "_",
  55.         /* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g",
  56.         /* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o",
  57.         /* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w",
  58.         /* 0x78 */ "x", "y", "z", "{", "|", "}", "~", "",
  59. };
  60.  
  61. static char*
  62. upper_translation_table [128] = {
  63.         "?", "?", "?", "?", "?", "?", "?", "?",
  64.         "?", "?", "?", "?", "?", "?", "?", "?",
  65.         "?", "?", "?", "?", "?", "?", "?", "?",
  66.         "?", "?", "?", "?", "?", "?", "?", "?",
  67.         "?", "?", "?", "?", "?", "?", "?", "?",
  68.         "?", "?", "?", "?", "?", "?", "?", "?",
  69.         "?", "?", "?", "?", "?", "?", "?", "?",
  70.         "?", "?", "?", "?", "?", "?", "?", "?",
  71.         "?", "?", "?", "?", "?", "?", "?", "?",
  72.         "?", "?", "?", "?", "?", "?", "?", "?",
  73.         "?", "?", "?", "?", "?", "?", "?", "?",
  74.         "?", "?", "?", "?", "?", "?", "?", "?",
  75.         "?", "?", "?", "?", "?", "?", "?", "?",
  76.         "?", "?", "?", "?", "?", "?", "?", "?",
  77.         "?", "?", "?", "?", "?", "?", "?", "?",
  78.         "?", "?", "?", "?", "?", "?", "?", "?",
  79. };
  80.  
  81.  
  82.  
  83. /*========================================================================
  84.  * Name:        wpml_init
  85.  * Purpose:     Generates an output personality for the WPML format.
  86.  * Args:        None.
  87.  * Returns:     OutputPersonality.
  88.  *=======================================================================*/
  89.  
  90. OutputPersonality *
  91. wpml_init (void)
  92. {
  93.         OutputPersonality* wpml_op;
  94.  
  95.         wpml_op = op_create();
  96.  
  97.         wpml_op->comment_begin = "<!--";
  98.         wpml_op->comment_end = "-->\n";
  99.  
  100.         wpml_op->document_begin = "<WPML>";
  101.         wpml_op->document_end = "</WPML>";
  102.  
  103.         wpml_op->header_begin = "<HEAD>";
  104.         wpml_op->header_end = "</HEAD>";
  105.  
  106.         wpml_op->document_title_begin = "<TITLE>";
  107.         wpml_op->document_title_end = "</TITLE>";
  108.  
  109.         wpml_op->document_author_begin = "<AUTHOR>";
  110.         wpml_op->document_author_end = "</AUTHOR>\n";
  111.  
  112.         wpml_op->document_changedate_begin = "<DATE>";
  113.         wpml_op->document_changedate_end = "</DATE>\n";
  114.  
  115.         wpml_op->body_begin = "\n<BODY>\n";
  116.         wpml_op->body_end = "</BODY>";
  117.  
  118.         wpml_op->paragraph_begin = "<LINE>";
  119.         wpml_op->paragraph_end = "</LINE>\n";
  120.  
  121.         wpml_op->center_begin = "";
  122.         wpml_op->center_end = "";
  123.  
  124.         wpml_op->justify_begin = "";
  125.         wpml_op->justify_end = "";
  126.  
  127.         wpml_op->align_left_begin = "";
  128.         wpml_op->align_left_end = "";
  129.  
  130.         wpml_op->align_right_begin = "";
  131.         wpml_op->align_right_end = "";
  132.  
  133.         wpml_op->forced_space = " ";
  134.         wpml_op->line_break = "\n";
  135.         wpml_op->page_break = "\n";
  136.  
  137.         wpml_op->hyperlink_begin = "";
  138.         wpml_op->hyperlink_end = "";
  139.  
  140.         wpml_op->imagelink_begin = "";
  141.         wpml_op->imagelink_end = "";
  142.  
  143.         wpml_op->table_begin = "<TABLE>\n";
  144.         wpml_op->table_end = "</TABLE>\n";
  145.  
  146.         wpml_op->table_row_begin = "<TABLEROW>";
  147.         wpml_op->table_row_end = "</TABLEROW>\n";
  148.  
  149.         wpml_op->table_cell_begin = "<TABLECELL>";
  150.         wpml_op->table_cell_end = "</TABLECELL>";
  151.  
  152.         /* Character attributes */
  153.  
  154.         /* XX: WPML will require that all elements that are now
  155.          * character attribute strings be converted to functions,
  156.          * so that a complete font description can be written
  157.          * each time an attribute begins or ends.
  158.          */
  159.  
  160.         wpml_op->font_begin = "<FONT=\"%s\"/>";
  161.         wpml_op->font_end = "";
  162.  
  163.         wpml_op->fontsize_begin = "";
  164.         wpml_op->fontsize_end = "";
  165.  
  166.         wpml_op->fontsize8_begin = "";
  167.         wpml_op->fontsize8_end = "";
  168.         wpml_op->fontsize10_begin = "";
  169.         wpml_op->fontsize10_end = "";
  170.         wpml_op->fontsize12_begin = "";
  171.         wpml_op->fontsize12_end = "";
  172.         wpml_op->fontsize14_begin = "";
  173.         wpml_op->fontsize14_end = "";
  174.         wpml_op->fontsize18_begin = "";
  175.         wpml_op->fontsize18_end = "";
  176.         wpml_op->fontsize24_begin = "";
  177.         wpml_op->fontsize24_end = "";
  178.  
  179.         wpml_op->smaller_begin = "";
  180.         wpml_op->smaller_end = "";
  181.  
  182.         wpml_op->bigger_begin = "";
  183.         wpml_op->bigger_end = "";
  184.  
  185.         wpml_op->foreground_begin = "";
  186.         wpml_op->foreground_end = "";
  187.  
  188.         wpml_op->background_begin = "";
  189.         wpml_op->background_end = "";
  190.  
  191.         wpml_op->bold_begin = "";
  192.         wpml_op->bold_end = "";
  193.  
  194.         wpml_op->italic_begin = "";
  195.         wpml_op->italic_end = "";
  196.  
  197.         wpml_op->underline_begin = "";
  198.         wpml_op->underline_end = "";
  199.  
  200.         wpml_op->dbl_underline_begin = "";
  201.         wpml_op->dbl_underline_end = "";
  202.  
  203.         wpml_op->superscript_begin = "";
  204.         wpml_op->superscript_end = "";
  205.  
  206.         wpml_op->subscript_begin = "";
  207.         wpml_op->subscript_end = "";
  208.  
  209.         wpml_op->strikethru_begin = "";
  210.         wpml_op->strikethru_end = "";
  211.  
  212.         wpml_op->dbl_strikethru_begin = "";
  213.         wpml_op->dbl_strikethru_end = "";
  214.  
  215.         wpml_op->emboss_begin="";
  216.         wpml_op->emboss_end = "";
  217.  
  218.         wpml_op->engrave_begin = "";
  219.         wpml_op->engrave_end = "";
  220.  
  221.         wpml_op->shadow_begin= "";
  222.         wpml_op->shadow_end= "";
  223.  
  224.         wpml_op->outline_begin= "";
  225.         wpml_op->outline_end= "";
  226.  
  227.         wpml_op->expand_begin = "";
  228.         wpml_op->expand_end = "";
  229.  
  230.         wpml_op->pointlist_begin = "\n";
  231.         wpml_op->pointlist_end = "\n";
  232.         wpml_op->pointlist_item_begin = "";
  233.         wpml_op->pointlist_item_end = "\n";
  234.  
  235.         wpml_op->numericlist_begin = "\n";
  236.         wpml_op->numericlist_end = "\n";
  237.         wpml_op->numericlist_item_begin = "";
  238.         wpml_op->numericlist_item_end = "\n";
  239.  
  240.         wpml_op->simulate_small_caps = TRUE;
  241.         wpml_op->simulate_all_caps = TRUE;
  242.         wpml_op->simulate_word_underline = TRUE;
  243.  
  244.         wpml_op->ascii_translation_table = ascii_translation_table;
  245.  
  246.         wpml_op->ansi_translation_table = upper_translation_table;
  247.         wpml_op->ansi_first_char = 0x80;
  248.         wpml_op->ansi_last_char = 0xff;
  249.  
  250.         wpml_op->cp437_translation_table = upper_translation_table;
  251.         wpml_op->cp437_first_char = 0x80;
  252.         wpml_op->cp437_last_char = 0xff;
  253.  
  254.         wpml_op->cp850_translation_table = upper_translation_table;
  255.         wpml_op->cp850_first_char = 0x80;
  256.         wpml_op->cp850_last_char = 0xff;
  257.  
  258.         wpml_op->mac_translation_table = upper_translation_table;
  259.         wpml_op->mac_first_char = 0x80;
  260.         wpml_op->mac_last_char = 0xff;
  261.  
  262.         wpml_op->chars.right_quote = "'";
  263.         wpml_op->chars.left_quote = "`";
  264.         wpml_op->chars.right_dbl_quote = "''";
  265.         wpml_op->chars.left_dbl_quote = "``";
  266.  
  267.         return wpml_op;
  268. }
  269.  
  270.  
  271.