/programs/media/unrtf/Makefile |
---|
0,0 → 1,31 |
CC = kos32-gcc |
LD = kos32-ld |
SDK_DIR = $(abspath ../../../contrib/sdk) |
CFLAGS = -c -fno-ident -O2 -fomit-frame-pointer -fno-ident -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 |
LDFLAGS = -static -S -nostdlib -T $(SDK_DIR)/sources/newlib/app.lds --image-base 0 |
INCLUDES = -I $(SDK_DIR)/sources/newlib/libc/include |
LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib |
# Only selected |
SRC = convert.c word.c error.c main.c hash.c \ |
parse.c malloc.c attr.c util.c \ |
output.c html.c text.c vt.c ps.c latex.c wpml.c |
# All .c files |
# SRC = $(notdir $(wildcard *.c)) |
OBJECTS = $(patsubst %.c, %.o, $(SRC)) |
default: $(patsubst %.c,%.o,$(SRC)) |
kos32-ld $(LDFLAGS) $(LIBPATH) --subsystem console -o unrtf $(OBJECTS) -lgcc -lc.dll |
objcopy unrtf -O binary |
%.o : %.c Makefile $(SRC) |
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $< |
clean: |
rm *.o |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/attr.c |
---|
0,0 → 1,620 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: attr |
* Author name: Zach Smith |
* Create date: 01 Aug 01 |
* Purpose: Character attribute stack. |
*---------------------------------------------------------------------- |
* Changes: |
* 01 Aug 01, tuorfa@yahoo.com: moved code over from convert.c |
* 06 Aug 01, tuorfa@yahoo.com: added several font attributes. |
* 18 Sep 01, tuorfa@yahoo.com: added AttrStack (stack of stacks) paradigm |
* 22 Sep 01, tuorfa@yahoo.com: added comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include <stdlib.h> |
#include "malloc.h" |
#include "defs.h" |
#include "error.h" |
#include "attr.h" |
#include "main.h" |
extern void starting_body(); |
extern void starting_text(); |
extern int simulate_allcaps; |
extern int simulate_smallcaps; |
#define MAX_ATTRS (1000) |
/* For each RTF text block (the text within braces) we must keep |
* an AttrStack which is a stack of attributes and their optional |
* parameter. Since RTF text blocks are nested, these make up a |
* stack of stacks. And, since RTF text blocks inherit attributes |
* from parent blocks, all new AttrStacks do the same from |
* their parent AttrStack. |
*/ |
typedef struct _stack { |
unsigned char attr_stack [MAX_ATTRS]; |
char *attr_stack_params [MAX_ATTRS]; |
int tos; |
struct _stack *next; |
} |
AttrStack; |
static AttrStack *stack_of_stacks = NULL; |
static AttrStack *stack_of_stacks_top = NULL; |
/*======================================================================== |
* Name: attr_express_begin |
* Purpose: Print the HTML for beginning an attribute. |
* Args: Attribute number, optional string parameter. |
* Returns: None. |
*=======================================================================*/ |
void |
attr_express_begin (int attr, char* param) { |
switch(attr) |
{ |
case ATTR_BOLD: |
printf (op->bold_begin); |
break; |
case ATTR_ITALIC: |
printf (op->italic_begin); |
break; |
/* Various underlines, they all resolve to HTML's <u> */ |
case ATTR_THICK_UL: |
case ATTR_WAVE_UL: |
case ATTR_DASH_UL: |
case ATTR_DOT_UL: |
case ATTR_DOT_DASH_UL: |
case ATTR_2DOT_DASH_UL: |
case ATTR_WORD_UL: |
case ATTR_UNDERLINE: |
printf (op->underline_begin); |
break; |
case ATTR_DOUBLE_UL: |
printf (op->dbl_underline_begin); |
break; |
case ATTR_FONTSIZE: |
op_begin_std_fontsize (op, atoi (param)); |
break; |
case ATTR_FONTFACE: |
printf (op->font_begin,param); |
break; |
case ATTR_FOREGROUND: |
printf (op->foreground_begin, param); |
break; |
case ATTR_BACKGROUND: |
if (!simple_mode) |
printf (op->foreground_begin,param); |
break; |
case ATTR_SUPER: |
printf (op->superscript_begin); |
break; |
case ATTR_SUB: |
printf (op->subscript_begin); |
break; |
case ATTR_STRIKE: |
printf (op->strikethru_begin); |
break; |
case ATTR_DBL_STRIKE: |
printf (op->dbl_strikethru_begin); |
break; |
case ATTR_EXPAND: |
printf (op->expand_begin, param); |
break; |
case ATTR_OUTLINE: |
printf (op->outline_begin); |
break; |
case ATTR_SHADOW: |
printf (op->shadow_begin); |
break; |
case ATTR_EMBOSS: |
printf (op->emboss_begin); |
break; |
case ATTR_ENGRAVE: |
printf (op->engrave_begin); |
break; |
case ATTR_CAPS: |
if (op->simulate_all_caps) |
simulate_allcaps = TRUE; |
break; |
case ATTR_SMALLCAPS: |
if (op->simulate_small_caps) |
simulate_smallcaps = TRUE; |
else { |
if (op->small_caps_begin) |
printf (op->small_caps_begin); |
} |
break; |
} |
} |
/*======================================================================== |
* Name: attr_express_end |
* Purpose: Print HTML to complete an attribute. |
* Args: Attribute number. |
* Returns: None. |
*=======================================================================*/ |
void |
attr_express_end (int attr, char *param) |
{ |
switch(attr) |
{ |
case ATTR_BOLD: |
printf (op->bold_end); |
break; |
case ATTR_ITALIC: |
printf (op->italic_end); |
break; |
/* Various underlines, they all resolve to HTML's </u> */ |
case ATTR_THICK_UL: |
case ATTR_WAVE_UL: |
case ATTR_DASH_UL: |
case ATTR_DOT_UL: |
case ATTR_DOT_DASH_UL: |
case ATTR_2DOT_DASH_UL: |
case ATTR_WORD_UL: |
case ATTR_UNDERLINE: |
printf (op->underline_end); |
break; |
case ATTR_DOUBLE_UL: |
printf (op->dbl_underline_end); |
break; |
case ATTR_FONTSIZE: |
op_end_std_fontsize (op, atoi (param)); |
break; |
case ATTR_FONTFACE: |
printf (op->font_end); |
break; |
case ATTR_FOREGROUND: |
printf (op->foreground_end); |
break; |
case ATTR_BACKGROUND: |
if (!simple_mode) |
printf (op->background_end); |
break; |
case ATTR_SUPER: |
printf (op->superscript_end); |
break; |
case ATTR_SUB: |
printf (op->subscript_end); |
break; |
case ATTR_STRIKE: |
printf (op->strikethru_end); |
break; |
case ATTR_DBL_STRIKE: |
printf (op->dbl_strikethru_end); |
break; |
case ATTR_OUTLINE: |
printf (op->outline_end); |
break; |
case ATTR_SHADOW: |
printf (op->shadow_end); |
break; |
case ATTR_EMBOSS: |
printf (op->emboss_end); |
break; |
case ATTR_ENGRAVE: |
printf (op->engrave_end); |
break; |
case ATTR_EXPAND: |
printf (op->expand_end); |
break; |
case ATTR_CAPS: |
if (op->simulate_all_caps) |
simulate_allcaps = FALSE; |
break; |
case ATTR_SMALLCAPS: |
if (op->simulate_small_caps) |
simulate_smallcaps = FALSE; |
else { |
if (op->small_caps_end) |
printf (op->small_caps_end); |
} |
break; |
} |
} |
/*======================================================================== |
* Name: attr_push |
* Purpose: Pushes an attribute onto the current attribute stack. |
* Args: Attribute number, optional string parameter. |
* Returns: None. |
*=======================================================================*/ |
void |
attr_push(int attr, char* param) |
{ |
AttrStack *stack = stack_of_stacks_top; |
if (!stack) { |
warning_handler ("no stack to push attribute onto"); |
return; |
} |
if (stack->tos>=MAX_ATTRS) { fprintf (stderr,"Too many attributes!\n"); return; } |
/* Make sure it's understood we're in the <body> section. */ |
/* KLUDGE */ |
starting_body(); |
starting_text(); |
++stack->tos; |
stack->attr_stack [stack->tos]=attr; |
if (param) |
stack->attr_stack_params [stack->tos]=my_strdup(param); |
else |
stack->attr_stack_params [stack->tos]=NULL; |
attr_express_begin (attr, param); |
} |
/*======================================================================== |
* Name: attrstack_copy_all |
* Purpose: Routine to copy all attributes from one stack to another. |
* Args: Two stacks. |
* Returns: None. |
*=======================================================================*/ |
void |
attrstack_copy_all (AttrStack *src, AttrStack *dest) |
{ |
int i; |
int total; |
CHECK_PARAM_NOT_NULL(src); |
CHECK_PARAM_NOT_NULL(dest); |
total = src->tos + 1; |
for (i=0; i<total; i++) |
{ |
int attr=src->attr_stack [i]; |
char *param=src->attr_stack_params [i]; |
dest->attr_stack[i] = attr; |
if (param) |
dest->attr_stack_params[i] = my_strdup (param); |
else |
dest->attr_stack_params[i] = NULL; |
} |
dest->tos = src->tos; |
} |
/*======================================================================== |
* Name: attrstack_unexpress_all |
* Purpose: Routine to un-express all attributes heretofore applied, |
* without removing any from the stack. |
* Args: Stack whost contents should be unexpressed. |
* Returns: None. |
* Notes: This is needed by attrstack_push, but also for \cell, which |
* often occurs within a brace group, yet HTML uses <td></td> |
* which clear attribute info within that block. |
*=======================================================================*/ |
void |
attrstack_unexpress_all (AttrStack *stack) |
{ |
int i; |
CHECK_PARAM_NOT_NULL(stack); |
i=stack->tos; |
while (i>=0) |
{ |
int attr=stack->attr_stack [i]; |
char *param=stack->attr_stack_params [i]; |
attr_express_end (attr, param); |
i--; |
} |
} |
/*======================================================================== |
* Name: attrstack_push |
* Purpose: Creates a new attribute stack, pushes it onto the stack |
* of stacks, performs inheritance from previous stack. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
attrstack_push () |
{ |
AttrStack *new_stack; |
AttrStack *prev_stack; |
new_stack = (AttrStack*) my_malloc (sizeof (AttrStack)); |
bzero ((void*) new_stack, sizeof (AttrStack)); |
prev_stack = stack_of_stacks_top; |
if (!stack_of_stacks) { |
stack_of_stacks = new_stack; |
} else { |
stack_of_stacks_top->next = new_stack; |
} |
stack_of_stacks_top = new_stack; |
new_stack->tos = -1; |
if (prev_stack) { |
attrstack_unexpress_all (prev_stack); |
attrstack_copy_all (prev_stack, new_stack); |
attrstack_express_all (); |
} |
} |
/*======================================================================== |
* Name: attr_pop |
* Purpose: Removes and undoes the effect of the top attribute of |
* the current AttrStack. |
* Args: The top attribute's number, for verification. |
* Returns: Success/fail flag. |
*=======================================================================*/ |
int |
attr_pop (int attr) |
{ |
AttrStack *stack = stack_of_stacks_top; |
if (!stack) { |
warning_handler ("no stack to pop attribute from"); |
return FALSE; |
} |
if(stack->tos>=0 && stack->attr_stack[stack->tos]==attr) |
{ |
char *param = stack->attr_stack_params [stack->tos]; |
attr_express_end (attr, param); |
if (param) my_free(param); |
stack->tos--; |
return TRUE; |
} |
else |
return FALSE; |
} |
/*======================================================================== |
* Name: attr_read |
* Purpose: Reads but leaves in place the top attribute of the top |
* attribute stack. |
* Args: None. |
* Returns: Attribute number. |
*=======================================================================*/ |
int |
attr_read() { |
AttrStack *stack = stack_of_stacks_top; |
if (!stack) { |
warning_handler ("no stack to read attribute from"); |
return FALSE; |
} |
if(stack->tos>=0) |
{ |
int attr = stack->attr_stack [stack->tos]; |
return attr; |
} |
else |
return ATTR_NONE; |
} |
/*======================================================================== |
* Name: attr_drop_all |
* Purpose: Undoes all attributes that an AttrStack contains. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
attr_drop_all () |
{ |
AttrStack *stack = stack_of_stacks_top; |
if (!stack) { |
warning_handler ("no stack to drop all attributes from"); |
return; |
} |
while (stack->tos>=0) |
{ |
char *param=stack->attr_stack_params [stack->tos]; |
if (param) my_free(param); |
stack->tos--; |
} |
} |
/*======================================================================== |
* Name: attrstack_drop |
* Purpose: Removes the top AttrStack from the stack of stacks, undoing |
* all attributes that it had in it. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
attrstack_drop () |
{ |
AttrStack *stack = stack_of_stacks_top; |
AttrStack *prev_stack; |
if (!stack) { |
warning_handler ("no attr-stack to drop"); |
return; |
} |
attr_pop_all (); |
prev_stack = stack_of_stacks; |
while(prev_stack && prev_stack->next && prev_stack->next != stack) |
prev_stack = prev_stack->next; |
if (prev_stack) { |
stack_of_stacks_top = prev_stack; |
prev_stack->next = NULL; |
} else { |
stack_of_stacks_top = NULL; |
stack_of_stacks = NULL; |
} |
my_free ((void*) stack); |
attrstack_express_all (); |
} |
/*======================================================================== |
* Name: attr_pop_all |
* Purpose: Routine to undo all attributes heretofore applied, |
* also reversing the order in which they were applied. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
attr_pop_all() |
{ |
AttrStack *stack = stack_of_stacks_top; |
if (!stack) { |
warning_handler ("no stack to pop from"); |
return; |
} |
while (stack->tos>=0) { |
int attr=stack->attr_stack [stack->tos]; |
char *param=stack->attr_stack_params [stack->tos]; |
attr_express_end (attr,param); |
if (param) my_free(param); |
stack->tos--; |
} |
} |
/*======================================================================== |
* Name: attrstack_express_all |
* Purpose: Routine to re-express all attributes heretofore applied. |
* Args: None. |
* Returns: None. |
* Notes: This is needed by attrstack_push, but also for \cell, which |
* often occurs within a brace group, yet HTML uses <td></td> |
* which clear attribute info within that block. |
*=======================================================================*/ |
void |
attrstack_express_all() { |
AttrStack *stack = stack_of_stacks_top; |
int i; |
if (!stack) { |
warning_handler ("no stack to pop from"); |
return; |
} |
i=0; |
while (i<=stack->tos) |
{ |
int attr=stack->attr_stack [i]; |
char *param=stack->attr_stack_params [i]; |
attr_express_begin (attr, param); |
i++; |
} |
} |
/*======================================================================== |
* Name: attr_pop_dump |
* Purpose: Routine to un-express all attributes heretofore applied. |
* Args: None. |
* Returns: None. |
* Notes: This is needed for \cell, which often occurs within a |
* brace group, yet HTML uses <td></td> which clear attribute |
* info within that block. |
*=======================================================================*/ |
void |
attr_pop_dump() { |
AttrStack *stack = stack_of_stacks_top; |
int i; |
if (!stack) return; |
i=stack->tos; |
while (i>=0) |
{ |
int attr=stack->attr_stack [i]; |
attr_pop (attr); |
i--; |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/attr.h |
---|
0,0 → 1,88 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: attr |
* Author name: Zach Smith |
* Create date: 1 Aug 2001 |
* Purpose: Definitions for attribute stack module. |
*---------------------------------------------------------------------- |
* Changes: |
* 01 Aug 01, tuorfa@yahoo.com: moved code over from convert.c |
* 06 Aug 01, tuorfa@yahoo.com: added several attributes |
* 18 Sep 01, tuorfa@yahoo.com: updates for AttrStack paradigm |
*--------------------------------------------------------------------*/ |
enum { |
ATTR_NONE=0, |
ATTR_BOLD, ATTR_ITALIC, |
ATTR_UNDERLINE, ATTR_DOUBLE_UL, ATTR_WORD_UL, |
ATTR_THICK_UL, ATTR_WAVE_UL, |
ATTR_DOT_UL, ATTR_DASH_UL, ATTR_DOT_DASH_UL, ATTR_2DOT_DASH_UL, |
ATTR_FONTSIZE, ATTR_STD_FONTSIZE, |
ATTR_FONTFACE, |
ATTR_FOREGROUND, ATTR_BACKGROUND, |
ATTR_CAPS, |
ATTR_SMALLCAPS, |
ATTR_SHADOW, |
ATTR_OUTLINE, |
ATTR_EMBOSS, |
ATTR_ENGRAVE, |
ATTR_SUPER, ATTR_SUB, |
ATTR_STRIKE, |
ATTR_DBL_STRIKE, |
ATTR_EXPAND, |
/* ATTR_CONDENSE */ |
}; |
extern void attr_push_core (int attr, char* param); |
extern void attr_pop_core (int attr); |
extern void attr_push(int attr, char* param); |
extern void attrstack_push(); |
extern void attrstack_drop(); |
extern void attrstack_express_all(); |
extern int attr_pop(int attr); |
extern int attr_read(); |
extern void attr_drop_all (); |
extern void attr_pop_all(); |
extern void attr_pop_dump(); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/bcount.c |
---|
0,0 → 1,45 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Program name: bcount |
* Author name: Zach Smith |
* Create date: 15 Oct 00 |
* Purpose: Counts the number of opening and closing braces while |
* reading from stdin. |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
main (){ |
int n1,n2; |
int ch; |
n1=n2=0; |
while (EOF!=(ch=getchar())) { |
if (ch=='}') ++n1; |
if (ch=='{') ++n2; |
} |
printf ("{=%d, }=%d\n", n2,n1); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/convert.c |
---|
0,0 → 1,2880 |
/*=========================================================================== |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
===========================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: convert |
* Author name: Zach Smith |
* Create date: 24 Jul 01 |
* Purpose: Performs conversion from RTF to other formats. |
*---------------------------------------------------------------------- |
* Changes: |
* 24 Jul 01, tuorfa@yahoo.com: moved code over from word.c |
* 24 Jul 01, tuorfa@yahoo.com: fixed color table reference numbering. |
* 30 Jul 01, tuorfa@yahoo.com: moved hex convert to util.c |
* 30 Jul 01, tuorfa@yahoo.com: moved special expr tables to special.c |
* 30 Jul 01, tuorfa@yahoo.com: moved attribute stack to attr.c |
* 31 Jul 01, tuorfa@yahoo.com: began addition of hash of rtf commands |
* 01 Aug 01, tuorfa@yahoo.com: finished bulk of rtf command hash |
* 03 Aug 01, tuorfa@yahoo.com: removed no-op hash entries to save space |
* 03 Aug 01, tuorfa@yahoo.com: code to ignore rest of groups for \*, etc |
* 03 Aug 01, tuorfa@yahoo.com: fixed para-alignnot being cleared by \pard |
* 03 Aug 01, tuorfa@yahoo.com: added support for \keywords group |
* 03 Aug 01, tuorfa@yahoo.com: added dummy funcs for header/footer |
* 03 Aug 01, tuorfa@yahoo.com: began addition of hyperlink support |
* 04 Aug 01, tuorfa@yahoo.com: fixed debug string printing |
* 05 Aug 01, tuorfa@yahoo.com: added support for hyperlink data with \field |
* 06 Aug 01, tuorfa@yahoo.com: added support for several font attributes |
* 08 Aug 01, gommer@gmx.net: bugfix for picture storing mechanism |
* 08 Sep 01, tuorfa@yahoo.com: added use of PROGRAM_NAME |
* 11 Sep 01, tuorfa@yahoo.com: added support for JPEG and PNG pictures |
* 19 Sep 01, tuorfa@yahoo.com: added output personality support |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
* 23 Sep 01, tuorfa@yahoo.com: fixed translation of \'XX expressions |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <ctype.h> |
#include <string.h> |
#include "defs.h" |
#include "parse.h" |
#include "util.h" |
#include "malloc.h" |
#include "main.h" |
#include "error.h" |
#include "word.h" |
#include "hash.h" |
#include "convert.h" |
#include "attr.h" |
/* |
#define BINARY_ATTRS |
*/ |
static int charset_type=CHARSET_ANSI; |
/* Nested tables aren't supported. |
*/ |
static int coming_pars_that_are_tabular = 0; |
static int within_table = FALSE; |
static int have_printed_row_begin=FALSE; |
static int have_printed_cell_begin=FALSE; |
static int have_printed_row_end=FALSE; |
static int have_printed_cell_end=FALSE; |
/* Previously in word_print_core function |
*/ |
static int total_chars_this_line=0; /* for simulating \tab */ |
/* Paragraph alignment (kludge) |
*/ |
enum { |
ALIGN_LEFT=0, |
ALIGN_RIGHT, |
ALIGN_CENTER, |
ALIGN_JUSTIFY |
}; |
/* This value is set by attr_push and attr_pop |
*/ |
int simulate_smallcaps; |
int simulate_allcaps; |
/* Most pictures must be written to files. */ |
enum { |
PICT_UNKNOWN=0, |
PICT_WM, |
PICT_MAC, |
PICT_PM, |
PICT_DI, |
PICT_WB, |
PICT_JPEG, |
PICT_PNG, |
}; |
static int within_picture=FALSE; |
static int picture_file_number=1; |
static char picture_path[255]; |
static int picture_width; |
static int picture_height; |
static int picture_bits_per_pixel=1; |
static int picture_type=PICT_UNKNOWN; |
static int picture_wmetafile_type; |
static char *picture_wmetafile_type_str; |
static int have_printed_body=FALSE; |
static int within_header=TRUE; |
static char *hyperlink_base = NULL; |
void starting_body(); |
void starting_text(); |
static int banner_printed=FALSE; |
/*======================================================================== |
* Name: print_banner |
* Purpose: Writes program-identifying text to the output stream. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
print_banner () { |
if (!banner_printed) { |
printf (op->comment_begin); |
printf ("Translation from RTF performed by "); |
printf ("%s, version ", PROGRAM_NAME); |
printf ("%s", PROGRAM_VERSION); |
printf (op->comment_end); |
printf (op->comment_begin); |
printf ("For information about this marvellous program,"); |
printf (op->comment_end); |
printf (op->comment_begin); |
printf ("please go to %s", PROGRAM_WEBSITE); |
printf (op->comment_end); |
} |
banner_printed=TRUE; |
} |
/*======================================================================== |
* Name: starting_body |
* Purpose: Switches output stream for writing document contents. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
starting_body () |
{ |
if (!have_printed_body) { |
if (!inline_mode) { |
printf (op->header_end); |
printf (op->body_begin); |
} |
within_header=FALSE; |
have_printed_body=TRUE; |
} |
} |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
static char *month_strings[12]= { |
#ifdef ENGLISH |
"January","February","March","April","May","June","July","August", |
"September","October","November","December" |
#endif |
#ifdef FRANCAIS |
"Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre", |
"Octobre","Novembre","Decembre" |
#endif |
#ifdef ITALIANO |
"Ianuario","Febbraio","Marzo","Aprile","Maggio","Iuno", |
"Luglio","Agusto","Settembre","Ottobre","Novembre","Dicembre" |
#endif |
#ifdef ESPANOL |
"?","Febraio","Marzo","Abril","Mayo","?","?","Agosto", |
"Septiembre","Octubre","Noviembre","Diciembre" |
#endif |
#ifdef DEUTCH |
"?","?","?","?","?","?","?","?", |
"?","?","?","?" |
#endif |
}; |
/*======================================================================== |
* Name: word_dump_date |
* Purpose: Extracts date from an RTF input stream, writes it to |
* output stream. |
* Args: Word*, buffered RTF stream |
* Returns: None. |
*=======================================================================*/ |
void |
word_dump_date (Word *w) |
{ |
int year=0, month=0, day=0, hour=0, minute=0; |
CHECK_PARAM_NOT_NULL(w); |
while (w) { |
char *s = word_string (w); |
if (*s == '\\') { |
++s; |
if (!strncmp (s, "yr", 2) && isdigit(s[2])) { |
year = atoi (&s[2]); |
} |
else if (!strncmp (s, "mo", 2) && isdigit(s[2])) { |
month= atoi (&s[2]); |
} |
else if (!strncmp (s, "dy", 2) && isdigit(s[2])) { |
day= atoi (&s[2]); |
} |
else if (!strncmp (s, "min", 3) && isdigit(s[3])) { |
minute= atoi (&s[3]); |
} |
else if (!strncmp (s, "hr", 2) && isdigit(s[2])) { |
hour= atoi (&s[2]); |
} |
} |
w=w->next; |
} |
if (year && month && day) { |
printf ("%d %s %d ", day, month_strings[month-1], year); |
} |
if (hour && minute) { |
printf ("%02d:%02d ", hour, minute); |
} |
} |
/*-------------------------------------------------------------------*/ |
typedef struct { |
int num; |
char *name; |
} FontEntry; |
#define MAX_FONTS (256) |
static FontEntry font_table[MAX_FONTS]; |
static int total_fonts=0; |
/*======================================================================== |
* Name: lookup_fontname |
* Purpose: Fetches the name of a font from the already-read font table. |
* Args: Font#. |
* Returns: Font name. |
*=======================================================================*/ |
char* |
lookup_fontname (int num) { |
int i; |
if (total_fonts) |
for(i=0;i<total_fonts;i++) { |
if (font_table[i].num==num) |
return font_table[i].name; |
} |
return NULL; |
} |
/*======================================================================== |
* Name: process_font_table |
* Purpose: Processes the font table of an RTF file. |
* Args: Tree of words. |
* Returns: None. |
*=======================================================================*/ |
void |
process_font_table (Word *w) |
{ |
Word *w2; |
CHECK_PARAM_NOT_NULL(w); |
while(w) { |
int num; |
char name[255]; |
char *tmp; |
if ((w2=w->child)) { |
tmp = word_string (w2); |
if (!strncmp("\\f",tmp,2)) { |
num = atoi (&tmp[2]); |
name[0]=0; |
w2=w2->next; |
while(w2) { |
tmp = word_string (w2); |
if (tmp && tmp[0] != '\\') |
strcat(name,tmp); |
w2=w2->next; |
} |
/* Chop the gall-derned semicolon. */ |
if ((tmp=strchr(name,';'))) |
*tmp=0; |
font_table[total_fonts].num=num; |
font_table[total_fonts].name=my_strdup(name); |
total_fonts++; |
} |
} |
w=w->next; |
} |
printf (op->comment_begin); |
printf ("font table contains %d fonts total",total_fonts); |
printf (op->comment_end); |
if (debug_mode) { |
int i; |
printf (op->comment_begin); |
printf ("font table dump: \n"); |
for (i=0; i<total_fonts; i++) { |
printf (" font %d = %s\n", font_table[i].num, |
font_table[i].name); |
} |
printf (op->comment_end); |
} |
} |
/*======================================================================== |
* Name: process_index_entry |
* Purpose: Processes an index entry of an RTF file. |
* Args: Tree of words. |
* Returns: None. |
*=======================================================================*/ |
void |
process_index_entry (Word *w) |
{ |
Word *w2; |
CHECK_PARAM_NOT_NULL(w); |
while(w) { |
if ((w2=w->child)) { |
char *str = word_string (w2); |
if (debug_mode && str) { |
printf (op->comment_begin); |
printf ("index entry word: %s ", str); |
printf (op->comment_end); |
} |
} |
w=w->next; |
} |
} |
/*======================================================================== |
* Name: process_toc_entry |
* Purpose: Processes an index entry of an RTF file. |
* Args: Tree of words, flag to say whether to include a page#. |
* Returns: None. |
*=======================================================================*/ |
void |
process_toc_entry (Word *w, int include_page_num) |
{ |
Word *w2; |
CHECK_PARAM_NOT_NULL(w); |
while(w) { |
if ((w2=w->child)) { |
char *str = word_string (w2); |
if (debug_mode && str) { |
printf (op->comment_begin); |
printf ("toc %s entry word: %s ", |
include_page_num ? "page#":"no page#", |
str); |
printf (op->comment_end); |
} |
} |
w=w->next; |
} |
} |
/*======================================================================== |
* Name: process_info_group |
* Purpose: Processes the \info group of an RTF file. |
* Args: Tree of words. |
* Returns: None. |
*=======================================================================*/ |
void |
process_info_group (Word *w) |
{ |
Word *child; |
CHECK_PARAM_NOT_NULL(w); |
while(w) { |
child = w->child; |
if (child) { |
Word *w2; |
char *s; |
s = word_string(child); |
if (!inline_mode) { |
if (!strcmp("\\title", s)) { |
printf (op->document_title_begin); |
w2=child->next; |
while (w2) { |
char *s2 = word_string(w2); |
if (s2[0] != '\\') |
printf ("%s", s2); |
w2=w2->next; |
} |
printf (op->document_title_end); |
} |
else if (!strcmp("\\keywords", s)) { |
printf (op->document_keywords_begin); |
w2=child->next; |
while (w2) { |
char *s2 = word_string(w2); |
if (s2[0] != '\\') |
printf ("%s,", s2); |
w2=w2->next; |
} |
printf (op->document_keywords_end); |
} |
else if (!strcmp("\\author", s)) { |
printf (op->document_author_begin); |
w2=child->next; |
while (w2) { |
char *s2 = word_string(w2); |
if (s2[0] != '\\') |
printf ("%s", s2); |
w2=w2->next; |
} |
printf (op->document_author_end); |
} |
else if (!strcmp("\\comment", s)) { |
printf (op->comment_begin); |
printf ("comments: "); |
w2=child->next; |
while (w2) { |
char *s2 = word_string(w2); |
if (s2[0] != '\\') |
printf ("%s", s2); |
w2=w2->next; |
} |
printf (op->comment_end); |
} |
else if (!strncmp("\\nofpages", s, 9)) { |
printf (op->comment_begin); |
printf ("total pages: %s",&s[9]); |
printf (op->comment_end); |
} |
else if (!strncmp("\\nofwords", s, 9)) { |
printf (op->comment_begin); |
printf ("total words: %s",&s[9]); |
printf (op->comment_end); |
} |
else if (!strncmp("\\nofchars", s, 9) && isdigit(s[9])) { |
printf (op->comment_begin); |
printf ("total chars: %s",&s[9]); |
printf (op->comment_end); |
} |
else if (!strcmp("\\creatim", s)) { |
printf (op->comment_begin); |
printf ("creaton date: "); |
if (child->next) word_dump_date (child->next); |
printf (op->comment_end); |
} |
else if (!strcmp("\\printim", s)) { |
printf (op->comment_begin); |
printf ("last printed: "); |
if (child->next) word_dump_date (child->next); |
printf (op->comment_end); |
} |
else if (!strcmp("\\buptim", s)) { |
printf (op->comment_begin); |
printf ("last backup: "); |
if (child->next) word_dump_date (child->next); |
printf (op->comment_end); |
} |
else if (!strcmp("\\revtim", s)) { |
printf (op->comment_begin); |
printf ("revision date: "); |
if (child->next) word_dump_date (child->next); |
printf (op->comment_end); |
} |
} |
/* Irregardless of whether we're in inline mode, |
* we want to process the following. |
*/ |
if (!strcmp("\\hlinkbase", s)) { |
char *linkstr = NULL; |
printf (op->comment_begin); |
printf ("hyperlink base: "); |
if (child->next) { |
Word *nextword = child->next; |
if (nextword) |
linkstr=word_string (nextword); |
} |
if (linkstr) |
printf ("%s", linkstr); |
else |
printf ("(none)"); |
printf (op->comment_end); |
/* Store the pointer, it will remain good. */ |
hyperlink_base = linkstr; |
} |
} |
w = w->next; |
} |
} |
/*-------------------------------------------------------------------*/ |
/* RTF color table colors are RGB */ |
typedef struct { |
unsigned char r,g,b; |
} Color; |
#define MAX_COLORS (256) |
static Color color_table[MAX_COLORS]; |
static int total_colors=0; |
/*======================================================================== |
* Name: process_color_table |
* Purpose: Processes the color table of an RTF file. |
* Args: Tree of words. |
* Returns: None. |
*=======================================================================*/ |
void |
process_color_table (Word *w) |
{ |
int r,g,b; |
CHECK_PARAM_NOT_NULL(w); |
/* Sometimes, RTF color tables begin with a semicolon, |
* i.e. an empty color entry. This seems to indicate that color 0 |
* will not be used, so here I set it to black. |
*/ |
r=g=b=0; |
while(w) { |
char *s = word_string (w); |
#if 0 |
printf (op->comment_begin); |
printf ("found this color table word: %s", word_string(w)); |
printf (op->comment_end); |
#endif |
if(!strncmp("\\red",s,4)) { |
r = atoi(&s[4]); |
while(r>255) r>>=8; |
} |
else if(!strncmp("\\green",s,6)) { |
g = atoi(&s[6]); |
while(g>255) g>>=8; |
} |
else if(!strncmp("\\blue",s,5)) { |
b = atoi(&s[5]); |
while(b>255) b>>=8; |
} |
else |
/* If we find the semicolon which denotes the end of |
* a color entry then store the color, even if we don't |
* have all of it. |
*/ |
if (!strcmp (";", s)) { |
color_table[total_colors].r = r; |
color_table[total_colors].g = g; |
color_table[total_colors++].b = b; |
if (debug_mode) { |
printf (op->comment_begin); |
printf ("storing color entry %d: %02x%02x%02x", |
total_colors-1, r,g,b); |
printf (op->comment_end); |
} |
r=g=b=0; |
} |
w=w->next; |
} |
if (debug_mode) { |
printf (op->comment_begin); |
printf ("color table had %d entries -->\n", total_colors); |
printf (op->comment_end); |
} |
} |
/*======================================================================== |
* Name: cmd_cf |
* Purpose: Executes the \cf command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_cf (Word *w, int align, char has_param, short num) { |
char str[40]; |
if (!has_param || num>=total_colors) { |
warning_handler ("font color change attempted is invalid"); |
} |
else |
{ |
sprintf (str,"#%02x%02x%02x", |
color_table[num].r, |
color_table[num].g, |
color_table[num].b); |
attr_push(ATTR_FOREGROUND,str); |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_cb |
* Purpose: Executes the \cb command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_cb (Word *w, int align, char has_param, short num) { |
char str[40]; |
if (!has_param || num>=total_colors) { |
warning_handler ("font color change attempted is invalid"); |
} |
else |
{ |
sprintf (str,"#%02x%02x%02x", |
color_table[num].r, |
color_table[num].g, |
color_table[num].b); |
attr_push(ATTR_BACKGROUND,str); |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_fs |
* Purpose: Executes the \fs command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_fs (Word *w, int align, char has_param, short points) { |
char str[20]; |
if (!has_param) return FALSE; |
/* Note, fs20 means 10pt */ |
points /= 2; |
sprintf (str,"%d",points); |
attr_push(ATTR_FONTSIZE,str); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_field |
* Purpose: Interprets fields looking for hyperlinks. |
* Comment: Because hyperlinks are put in \field groups, |
* we must interpret all \field groups, which is |
* slow and laborious. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_field (Word *w, int align, char has_param, short num) { |
Word *child; |
CHECK_PARAM_NOT_NULL(w); |
while(w) { |
child = w->child; |
if (child) { |
Word *w2; |
char *s; |
s = word_string(child); |
if (!strcmp("\\*", s)) { |
w2=child->next; |
while (w2) { |
char *s2 = word_string(w2); |
if (s2 && !strcmp("\\fldinst", s2)) { |
Word *w3; |
w3=w2->next; |
while (w3 && !w3->child) { |
w3=w3->next; |
} |
if (w3) w3=w3->child; |
while (w3) { |
char *s3=word_string(w3); |
if (s3 && !strcmp("HYPERLINK",s3)) { |
Word *w4; |
char *s4; |
w4=w3->next; |
while (w4 && !strcmp(" ", word_string(w4))) |
w4=w4->next; |
if (w4) { |
s4=word_string(w4); |
printf (op->hyperlink_begin); |
printf ("%s", s4); |
printf (op->hyperlink_end); |
return TRUE; |
} |
} |
w3=w3->next; |
} |
} |
w2=w2->next; |
} |
} |
} |
w=w->next; |
} |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_f |
* Purpose: Executes the \f command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_f (Word *w, int align, char has_param, short num) { |
char *name; |
/* no param exit early XX */ |
if (!has_param) |
return FALSE; |
name = lookup_fontname(num); |
if(!name) { |
printf (op->comment_begin); |
printf ("invalid font number %d",num); |
printf (op->comment_end); |
} else { |
attr_push(ATTR_FONTFACE,name); |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_highlight |
* Purpose: Executes the \cf command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_highlight (Word *w, int align, char has_param, short num) |
{ |
char str[40]; |
if (!has_param || num>=total_colors) { |
warning_handler ("font background color change attempted is invalid"); |
} |
else |
{ |
sprintf (str,"#%02x%02x%02x", |
color_table[num].r, |
color_table[num].g, |
color_table[num].b); |
attr_push(ATTR_BACKGROUND,str); |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_tab |
* Purpose: Executes the \tab command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_tab (Word *w, int align, char has_param, short param) |
{ |
/* Tab presents a genuine problem |
* since some output formats don't have |
* an equivalent. As a kludge fix, I shall |
* assume the font is fixed width and that |
* the tabstops are 8 characters apart. |
*/ |
int need= 8-(total_chars_this_line%8); |
total_chars_this_line += need; |
while(need>0) { |
printf (op->forced_space); |
need--; |
} |
printf ("\n"); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_plain |
* Purpose: Executes the \plain command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_plain (Word *w, int align, char has_param, short param) { |
attr_pop_all(); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_fnil |
* Purpose: Executes the \fnil command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_fnil (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_FONTFACE,FONTNIL_STR); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_froman |
* Purpose: Executes the \froman command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_froman (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_FONTFACE,FONTROMAN_STR); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_fswiss |
* Purpose: Executes the \fswiss command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_fswiss (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_FONTFACE,FONTSWISS_STR); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_fmodern |
* Purpose: Executes the \fmodern command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_fmodern (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_FONTFACE,FONTMODERN_STR); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_fscript |
* Purpose: Executes the \fscript command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_fscript (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_FONTFACE,FONTSCRIPT_STR); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_fdecor |
* Purpose: Executes the \fdecor command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_fdecor (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_FONTFACE,FONTDECOR_STR); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_ftech |
* Purpose: Executes the \ftech command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_ftech (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_FONTFACE,FONTTECH_STR); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_expand |
* Purpose: Executes the \expand command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_expand (Word *w, int align, char has_param, short param) { |
char str[10]; |
if (has_param) { |
sprintf (str, "%d", param/4); |
if (!param) |
attr_pop(ATTR_EXPAND); |
else |
attr_push(ATTR_EXPAND, str); |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_emboss |
* Purpose: Executes the \embo command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_emboss (Word *w, int align, char has_param, short param) { |
char str[10]; |
if (has_param && !param) |
attr_pop(ATTR_EMBOSS); |
else |
{ |
sprintf (str, "%d", param); |
attr_push(ATTR_EMBOSS, str); |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_engrave |
* Purpose: Executes the \impr command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_engrave (Word *w, int align, char has_param, short param) { |
char str[10]; |
if (has_param && !param) |
attr_pop(ATTR_ENGRAVE); |
else |
{ |
sprintf (str, "%d", param); |
attr_push(ATTR_ENGRAVE, str); |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_caps |
* Purpose: Executes the \caps command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_caps (Word *w, int align, char has_param, short param) { |
if (has_param && !param) |
attr_pop(ATTR_CAPS); |
else |
attr_push(ATTR_CAPS,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_scaps |
* Purpose: Executes the \scaps command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_scaps (Word *w, int align, char has_param, short param) { |
if (has_param && !param) |
attr_pop(ATTR_SMALLCAPS); |
else |
attr_push(ATTR_SMALLCAPS,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_bullet |
* Purpose: Executes the \bullet command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_bullet (Word *w, int align, char has_param, short param) { |
printf (op->chars.bullet); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_ldblquote |
* Purpose: Executes the \ldblquote command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_ldblquote (Word *w, int align, char has_param, short param) { |
printf (op->chars.left_dbl_quote); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_rdblquote |
* Purpose: Executes the \rdblquote command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_rdblquote (Word *w, int align, char has_param, short param) { |
printf (op->chars.right_dbl_quote); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_lquote |
* Purpose: Executes the \lquote command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_lquote (Word *w, int align, char has_param, short param) { |
printf (op->chars.left_quote); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_nonbreaking_space |
* Purpose: Executes the nonbreaking space command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_nonbreaking_space (Word *w, int align, char has_param, short param) { |
printf (op->chars.nonbreaking_space); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_nonbreaking_hyphen |
* Purpose: Executes the nonbreaking hyphen command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_nonbreaking_hyphen (Word *w, int align, char has_param, short param) { |
printf (op->chars.nonbreaking_hyphen); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_optional_hyphen |
* Purpose: Executes the optional hyphen command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_optional_hyphen (Word *w, int align, char has_param, short param) { |
printf (op->chars.optional_hyphen); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_emdash |
* Purpose: Executes the \emdash command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_emdash (Word *w, int align, char has_param, short param) { |
printf (op->chars.emdash); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_endash |
* Purpose: Executes the \endash command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_endash (Word *w, int align, char has_param, short param) { |
printf (op->chars.endash); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_rquote |
* Purpose: Executes the \rquote command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_rquote (Word *w, int align, char has_param, short param) { |
printf (op->chars.right_quote); |
++total_chars_this_line; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_par |
* Purpose: Executes the \par command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_par (Word *w, int align, char has_param, short param) { |
printf (op->line_break); |
total_chars_this_line = 0; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_line |
* Purpose: Executes the \line command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_line (Word *w, int align, char has_param, short param) { |
printf (op->line_break); |
total_chars_this_line = 0; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_page |
* Purpose: Executes the \page command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_page (Word *w, int align, char has_param, short param) { |
printf (op->page_break); |
total_chars_this_line = 0; /* \tab */ |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_intbl |
* Purpose: Executes the \intbl command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_intbl (Word *w, int align, char has_param, short param) { |
++coming_pars_that_are_tabular; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_ulnone |
* Purpose: Executes the \ulnone command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_ulnone (Word *w, int align, char has_param, short param) { |
int attr, more=TRUE; |
#ifdef BINARY_ATTRS |
attr_remove_underlining(); |
#else |
do { |
attr = attr_read(); |
if (attr==ATTR_UNDERLINE || |
attr==ATTR_DOT_UL || |
attr==ATTR_DASH_UL || |
attr==ATTR_DOT_DASH_UL || |
attr==ATTR_2DOT_DASH_UL || |
attr==ATTR_WORD_UL || |
attr==ATTR_WAVE_UL || |
attr==ATTR_THICK_UL || |
attr==ATTR_DOUBLE_UL) |
{ |
if (!attr_pop(ATTR_UNDERLINE)) |
; |
} else |
more=FALSE; |
} while(more); |
#endif |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_ul |
* Purpose: Executes the \ul command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_ul (Word *w, int align, char has_param, short param) { |
if (has_param && param == 0) { |
cmd_ulnone (w, align, has_param, param); |
} else { |
attr_push (ATTR_UNDERLINE,NULL); |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_uld |
* Purpose: Executes the \uld command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_uld (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_DOUBLE_UL,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_uldb |
* Purpose: Executes the \uldb command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_uldb (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_DOT_UL,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_uldash |
* Purpose: Executes the \uldash command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_uldash (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_DASH_UL,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_uldashd |
* Purpose: Executes the \cmd_uldashd command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_uldashd (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_DOT_DASH_UL,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_uldashdd |
* Purpose: Executes the \uldashdd command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_uldashdd (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_2DOT_DASH_UL,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_ulw |
* Purpose: Executes the \ulw command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_ulw (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_WORD_UL,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_ulth |
* Purpose: Executes the \ulth command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_ulth (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_THICK_UL,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_ulwave |
* Purpose: Executes the \ulwave command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_ulwave (Word *w, int align, char has_param, short param) { |
attr_push(ATTR_WAVE_UL,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_strike |
* Purpose: Executes the \strike command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_strike (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_STRIKE); |
else |
attr_push(ATTR_STRIKE,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_strikedl |
* Purpose: Executes the \strikedl command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_strikedl (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_DBL_STRIKE); |
else |
attr_push(ATTR_DBL_STRIKE,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_striked |
* Purpose: Executes the \striked command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_striked (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_DBL_STRIKE); |
else |
attr_push(ATTR_DBL_STRIKE,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_rtf |
* Purpose: Executes the \rtf command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_rtf (Word *w, int align, char has_param, short param) { |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_up |
* Purpose: Executes the \up command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_up (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_SUPER); |
else |
attr_push(ATTR_SUPER,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_dn |
* Purpose: Executes the \dn command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_dn (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_SUB); |
else |
attr_push(ATTR_SUB,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_nosupersub |
* Purpose: Executes the \nosupersub command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_nosupersub (Word *w, int align, char has_param, short param) { |
attr_pop(ATTR_SUPER); |
attr_pop(ATTR_SUB); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_super |
* Purpose: Executes the \super command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_super (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_SUPER); |
else |
attr_push(ATTR_SUPER,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_sub |
* Purpose: Executes the \sub command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_sub (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_SUB); |
else |
attr_push(ATTR_SUB,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_shad |
* Purpose: Executes the \shad command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_shad (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_SHADOW); |
else |
attr_push(ATTR_SHADOW,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_b |
* Purpose: Executes the \b command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int |
cmd_b (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) { |
attr_pop(ATTR_BOLD); |
} |
else |
attr_push(ATTR_BOLD,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_i |
* Purpose: Executes the \i command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_i (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_ITALIC); |
else |
attr_push(ATTR_ITALIC,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_s |
* Purpose: Executes the \s command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_s (Word *w, int align, char has_param, short param) { |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_sect |
* Purpose: Executes the \sect command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_sect (Word *w, int align, char has_param, short param) { |
/* XX kludge */ |
printf (op->paragraph_begin); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_shp |
* Purpose: Executes the \shp command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_shp (Word *w, int align, char has_param, short param) { |
printf (op->comment_begin); |
printf ("Drawn Shape (ignored--not implemented yet)"); |
printf (op->comment_begin); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_outl |
* Purpose: Executes the \outl command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_outl (Word *w, int align, char has_param, short param) { |
if (has_param && param==0) |
attr_pop(ATTR_OUTLINE); |
else |
attr_push(ATTR_OUTLINE,NULL); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_ansi |
* Purpose: Executes the \ansi command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_ansi (Word *w, int align, char has_param, short param) { |
charset_type = CHARSET_ANSI; |
printf (op->comment_begin); |
printf ("document uses ANSI character set"); |
printf (op->comment_end); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_pc |
* Purpose: Executes the \pc command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_pc (Word *w, int align, char has_param, short param) { |
charset_type = CHARSET_CP437 ; |
printf (op->comment_begin); |
printf ("document uses PC codepage 437 character set"); |
printf (op->comment_end); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_pca |
* Purpose: Executes the \pca command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_pca (Word *w, int align, char has_param, short param) { |
charset_type = CHARSET_CP850; |
printf (op->comment_begin); |
printf ("document uses PC codepage 850 character set"); |
printf (op->comment_end); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_mac |
* Purpose: Executes the \mac command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_mac (Word *w, int align, char has_param, short param) { |
charset_type = CHARSET_MAC; |
printf (op->comment_begin); |
printf ("document uses Macintosh character set"); |
printf (op->comment_end); |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_colortbl |
* Purpose: Executes the \colortbl command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_colortbl (Word *w, int align, char has_param, short param) { |
if (w->next) { |
process_color_table(w->next); |
} |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_fonttbl |
* Purpose: Executes the \fonttbl command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_fonttbl (Word *w, int align, char has_param, short param) { |
if (w->next) { |
process_font_table(w->next); |
} |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_header |
* Purpose: Executes the \header command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_header (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_headerl |
* Purpose: Executes the \headerl command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_headerl (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_headerr |
* Purpose: Executes the \headerr command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_headerr (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_headerf |
* Purpose: Executes the \headerf command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_headerf (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_footer |
* Purpose: Executes the \footer command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_footer (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_footerl |
* Purpose: Executes the \footerl command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_footerl (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_footerr |
* Purpose: Executes the \footerr command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_footerr (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_footerf |
* Purpose: Executes the \footerf command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_footerf (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_ignore |
* Purpose: Dummy function to get rid of subgroups |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_ignore (Word *w, int align, char has_param, short param) { |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_info |
* Purpose: Executes the \info command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_info (Word *w, int align, char has_param, short param) { |
process_info_group (w->next); |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_pict |
* Purpose: Executes the \pict command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_pict (Word *w, int align, char has_param, short param) { |
within_picture=TRUE; |
picture_width = picture_height = 0; |
picture_type = PICT_WB; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_bin |
* Purpose: Executes the \bin command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_bin (Word *w, int align, char has_param, short param) { |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_macpict |
* Purpose: Executes the \macpict command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_macpict (Word *w, int align, char has_param, short param) { |
picture_type = PICT_MAC; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_jpegblip |
* Purpose: Executes the \jpegblip command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_jpegblip (Word *w, int align, char has_param, short param) { |
picture_type = PICT_JPEG; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_pngblip |
* Purpose: Executes the \pngblip command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_pngblip (Word *w, int align, char has_param, short param) { |
picture_type = PICT_PNG; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_pnmetafile |
* Purpose: Executes the \pnmetafile command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_pnmetafile (Word *w, int align, char has_param, short param) { |
picture_type = PICT_PM; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_wmetafile |
* Purpose: Executes the \wmetafile command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_wmetafile (Word *w, int align, char has_param, short param) { |
picture_type = PICT_WM; |
if (within_picture && has_param) { |
picture_wmetafile_type=param; |
switch(param) { |
case 1: picture_wmetafile_type_str="MM_TEXT"; break; |
case 2: picture_wmetafile_type_str="MM_LOMETRIC"; break; |
case 3: picture_wmetafile_type_str="MM_HIMETRIC"; break; |
case 4: picture_wmetafile_type_str="MM_LOENGLISH"; break; |
case 5: picture_wmetafile_type_str="MM_HIENGLISH"; break; |
case 6: picture_wmetafile_type_str="MM_TWIPS"; break; |
case 7: picture_wmetafile_type_str="MM_ISOTROPIC"; break; |
case 8: picture_wmetafile_type_str="MM_ANISOTROPIC"; break; |
default: picture_wmetafile_type_str="default:MM_TEXT"; break; |
} |
} |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_wbmbitspixel |
* Purpose: Executes the \wbmbitspixel command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_wbmbitspixel (Word *w, int align, char has_param, short param) { |
if (within_picture && has_param) |
picture_bits_per_pixel = param; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_picw |
* Purpose: Executes the \picw command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_picw (Word *w, int align, char has_param, short param) { |
if (within_picture && has_param) |
picture_width = param; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_pich |
* Purpose: Executes the \pich command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_pich (Word *w, int align, char has_param, short param) { |
if (within_picture && has_param) |
picture_height = param; |
return FALSE; |
} |
/*======================================================================== |
* Name: cmd_xe |
* Purpose: Executes the \xe (index entry) command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_xe (Word *w, int align, char has_param, short param) { |
process_index_entry (w); |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_tc |
* Purpose: Executes the \tc (TOC entry) command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_tc (Word *w, int align, char has_param, short param) { |
process_toc_entry (w, TRUE); |
return TRUE; |
} |
/*======================================================================== |
* Name: cmd_tcn |
* Purpose: Executes the \tcn (TOC entry, no page #) command. |
* Args: Word, paragraph align info, and numeric param if any. |
* Returns: Flag, true only if rest of Words on line should be ignored. |
*=======================================================================*/ |
static int cmd_tcn (Word *w, int align, char has_param, short param) { |
process_toc_entry (w, FALSE); |
return TRUE; |
} |
typedef struct { |
char *name; |
int (*func)(Word*,int,char,short); |
char *debug_print; |
} |
HashItem; |
static HashItem hashArray_other [] = { |
{ "*", cmd_ignore, NULL }, |
{ "-", cmd_optional_hyphen, "optional hyphen" }, |
{ "_", cmd_nonbreaking_hyphen, "nonbreaking hyphen" }, |
{ "~", cmd_nonbreaking_space, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_a [] = { |
{ "ansi", &cmd_ansi , NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_b [] = { |
{ "b", &cmd_b, NULL }, |
{ "bullet", &cmd_bullet, NULL }, |
{ "bin", &cmd_bin, "picture is binary" }, |
#if 0 |
{ "bgbdiag", NULL, NULL }, |
{ "bgcross", NULL, NULL }, |
{ "bgdcross", NULL, NULL }, |
{ "bgfdiag", NULL, NULL }, |
{ "bghoriz", NULL, NULL }, |
{ "bgkbdiag", NULL, NULL }, |
{ "bgkcross", NULL, NULL }, |
{ "bgkdcross", NULL, NULL }, |
{ "bgkfdiag", NULL, NULL }, |
{ "bgkhoriz", NULL, NULL }, |
{ "bgkvert", NULL, NULL }, |
{ "bgvert", NULL, NULL }, |
{ "brdrcf", NULL, NULL }, |
{ "brdrdb", NULL, NULL }, |
{ "brdrdot", NULL, NULL }, |
{ "brdrhair", NULL, NULL }, |
{ "brdrs", NULL, NULL }, |
{ "brdrsh", NULL, NULL }, |
{ "brdrth", NULL, NULL }, |
{ "brdrw", NULL, NULL }, |
#endif |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_c [] = { |
{ "caps", &cmd_caps, NULL }, |
{ "cb", cmd_cb, NULL }, |
{ "cf", cmd_cf, NULL }, |
{ "colortbl", &cmd_colortbl, "color table" }, |
{ "cols", NULL, "columns (not implemented)" }, |
{ "column", NULL, "column break (not implemented)" }, |
#if 0 |
{ "cbpat", NULL, NULL }, |
{ "cellx", NULL, NULL }, |
{ "cfpat", NULL, NULL }, |
{ "cgrid", NULL, NULL }, |
{ "clbgbcross", NULL, NULL }, |
{ "clbgbdiag", NULL, NULL }, |
{ "clbgbkbdiag", NULL, NULL }, |
{ "clbgbkcross", NULL, NULL }, |
{ "clbgbkdcross", NULL, NULL }, |
{ "clbgbkfdiag", NULL, NULL }, |
{ "clbgbkhor", NULL, NULL }, |
{ "clbgbkvert", NULL, NULL }, |
{ "clbgdcross", NULL, NULL }, |
{ "clbgfdiag", NULL, NULL }, |
{ "clbghoriz", NULL, NULL }, |
{ "clbgvert", NULL, NULL }, |
{ "clbrdrb", NULL, NULL }, |
{ "clbrdrl", NULL, NULL }, |
{ "clbrdrr", NULL, NULL }, |
{ "clbrdrt", NULL, NULL }, |
{ "clcbpat", NULL, NULL }, |
{ "clcfpat", NULL, NULL }, |
{ "clmgf", NULL, NULL }, |
{ "clmrg", NULL, NULL }, |
{ "clshdng", NULL, NULL }, |
#endif |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_d [] = { |
{ "dn", &cmd_dn, NULL }, |
#if 0 |
{ "dibitmap", NULL, NULL }, |
#endif |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_e [] = { |
{ "emdash", cmd_emdash, NULL }, |
{ "endash", cmd_endash, NULL }, |
{ "embo", &cmd_emboss, NULL }, |
{ "expand", &cmd_expand, NULL }, |
{ "expnd", &cmd_expand, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_f [] = { |
{ "f", cmd_f, NULL }, |
{ "fdecor", cmd_fdecor, NULL }, |
{ "fmodern", cmd_fmodern, NULL }, |
{ "fnil", cmd_fnil, NULL }, |
{ "fonttbl", cmd_fonttbl, "font table" }, |
{ "froman", cmd_froman, NULL }, |
{ "fs", cmd_fs, NULL }, |
{ "fscript", cmd_fscript, NULL }, |
{ "fswiss", cmd_fswiss, NULL }, |
{ "ftech", cmd_ftech, NULL }, |
{ "field", cmd_field, NULL }, |
{ "footer", cmd_footer, NULL }, |
{ "footerf", cmd_footerf, NULL }, |
{ "footerl", cmd_footerl, NULL }, |
{ "footerr", cmd_footerr, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_h [] = { |
{ "highlight", &cmd_highlight, NULL }, |
{ "header", cmd_header, NULL }, |
{ "headerf", cmd_headerf, NULL }, |
{ "headerl", cmd_headerl, NULL }, |
{ "headerr", cmd_headerr, NULL }, |
{ "hl", cmd_ignore, "hyperlink within object" }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_i [] = { |
{ "i", &cmd_i, NULL }, |
{ "info", &cmd_info, NULL }, |
{ "intbl", &cmd_intbl, NULL }, |
{ "impr", &cmd_engrave, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_j [] = { |
{ "jpegblip", &cmd_jpegblip, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_l [] = { |
{ "ldblquote", &cmd_ldblquote, NULL }, |
{ "line", &cmd_line, NULL }, |
{ "lquote", &cmd_lquote, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_m [] = { |
{ "mac", &cmd_mac , NULL }, |
{ "macpict", &cmd_macpict, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_n [] = { |
{ "nosupersub", &cmd_nosupersub, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_o [] = { |
{ "outl", &cmd_outl, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_p [] = { |
{ "page", &cmd_page, NULL }, |
{ "par", &cmd_par, NULL }, |
{ "pc", &cmd_pc , NULL }, |
{ "pca", &cmd_pca , NULL }, |
{ "pich", &cmd_pich, NULL }, |
{ "pict", &cmd_pict, "picture" }, |
{ "picw", &cmd_picw, NULL }, |
{ "plain", &cmd_plain, NULL }, |
{ "pngblip", &cmd_pngblip, NULL }, |
{ "pnmetafile", &cmd_pnmetafile, NULL }, |
#if 0 |
{ "piccropb", NULL, NULL }, |
{ "piccropl", NULL, NULL }, |
{ "piccropr", NULL, NULL }, |
{ "piccropt", NULL, NULL }, |
{ "pichgoal", NULL, NULL }, |
{ "pichgoal", NULL, NULL }, |
{ "picscaled", NULL, NULL }, |
{ "picscalex", NULL, NULL }, |
{ "picwgoal", NULL, NULL }, |
#endif |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_r [] = { |
{ "rdblquote", &cmd_rdblquote, NULL }, |
{ "rquote", &cmd_rquote, NULL }, |
{ "rtf", &cmd_rtf, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_s [] = { |
{ "s", cmd_s, "style" }, |
{ "sect", &cmd_sect, "section break"}, |
{ "scaps", &cmd_scaps, NULL }, |
{ "super", &cmd_super, NULL }, |
{ "sub", &cmd_sub, NULL }, |
{ "shad", &cmd_shad, NULL }, |
{ "strike", &cmd_strike, NULL }, |
{ "striked", &cmd_striked, NULL }, |
{ "strikedl", &cmd_strikedl, NULL }, |
{ "stylesheet", &cmd_ignore, "style sheet" }, |
{ "shp", cmd_shp, "drawn shape" }, |
#if 0 |
{ "shading", NULL, NULL }, |
#endif |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_t [] = { |
{ "tab", &cmd_tab, NULL }, |
{ "tc", cmd_tc, "TOC entry" }, |
{ "tcn", cmd_tcn, "TOC entry" }, |
#if 0 |
{ "tcf", NULL , NULL }, |
{ "tcl", NULL , NULL }, |
{ "trgaph", NULL , NULL }, |
{ "trleft", NULL , NULL }, |
{ "trowd", NULL , NULL }, |
{ "trqc", NULL , NULL }, |
{ "trql", NULL , NULL }, |
{ "trqr", NULL , NULL }, |
{ "trrh", NULL , NULL }, |
#endif |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_u [] = { |
{ "ul", &cmd_ul, NULL }, |
{ "up", &cmd_up, NULL }, |
{ "uld", &cmd_uld, NULL }, |
{ "uldash", &cmd_uldash, NULL }, |
{ "uldashd", &cmd_uldashd, NULL }, |
{ "uldashdd", &cmd_uldashdd, NULL }, |
{ "uldb", &cmd_uldb, NULL }, |
{ "ulnone", &cmd_ulnone, NULL }, |
{ "ulth", &cmd_ulth, NULL }, |
{ "ulw", &cmd_ulw, NULL }, |
{ "ulwave", &cmd_ulwave, NULL }, |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_w [] = { |
{ "wbmbitspixel", &cmd_wbmbitspixel, NULL }, |
{ "wmetafile", &cmd_wmetafile, NULL }, |
#if 0 |
{ "wbitmap", NULL, NULL }, |
{ "wbmplanes", NULL, NULL }, |
{ "wbmwidthbytes", NULL, NULL }, |
#endif |
{ NULL, NULL, NULL} |
}; |
static HashItem hashArray_x [] = { |
{ "xe", cmd_xe, "index entry" }, |
{ NULL, NULL, NULL} |
}; |
static HashItem *hash [26] = { |
hashArray_a, |
hashArray_b, |
hashArray_c, |
hashArray_d, |
hashArray_e, |
hashArray_f, |
NULL, |
hashArray_h, |
hashArray_i, |
hashArray_j, |
NULL, |
hashArray_l, |
hashArray_m, |
hashArray_n, |
hashArray_o, |
hashArray_p, |
NULL, |
hashArray_r, |
hashArray_s, |
hashArray_t, |
hashArray_u, |
NULL, |
hashArray_w, |
hashArray_x, |
NULL, NULL |
}; |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
/*-------------------------------------------------------------------*/ |
/*======================================================================== |
* Name: |
* Purpose: |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
print_with_special_exprs (char *s) { |
int ch; |
int state; |
enum { SMALL=0, BIG=1 }; |
CHECK_PARAM_NOT_NULL(s); |
if (simulate_smallcaps) { |
if (*s >= 'a' && *s <= 'z') { |
state=SMALL; |
printf (op->smaller_begin); |
} |
else |
state=BIG; |
} |
while ((ch=*s)) { |
char *post_trans = NULL; |
if (simulate_allcaps || simulate_smallcaps) |
ch = toupper (ch); |
if (ch >= 0x20 && ch < 0x80) { |
post_trans = op_translate_char (op, charset_type, ch); |
printf ("%s",post_trans); |
} |
s++; |
if (simulate_smallcaps) { |
ch = *s; |
if (ch >= 'a' && ch <= 'z') { |
if (state==BIG) |
printf (op->smaller_begin); |
state=SMALL; |
} |
else |
{ |
if (state==SMALL) |
printf (op->smaller_end); |
state=BIG; |
} |
} |
} |
} |
/*======================================================================== |
* Name: |
* Purpose: |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
static void |
begin_table() |
{ |
within_table=TRUE; |
have_printed_row_begin = FALSE; |
have_printed_cell_begin = FALSE; |
have_printed_row_end = FALSE; |
have_printed_cell_end = FALSE; |
attrstack_push(); |
starting_body(); |
printf (op->table_begin); |
} |
/*======================================================================== |
* Name: |
* Purpose: |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
end_table () |
{ |
if (within_table) { |
if (!have_printed_cell_end) { |
attr_pop_dump(); |
printf (op->table_cell_end); |
} |
if (!have_printed_row_end) { |
printf (op->table_row_end); |
} |
printf (op->table_end); |
within_table=FALSE; |
have_printed_row_begin = FALSE; |
have_printed_cell_begin = FALSE; |
have_printed_row_end = FALSE; |
have_printed_cell_end = FALSE; |
} |
} |
/*======================================================================== |
* Name: |
* Purpose: |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
starting_text() { |
if (within_table) { |
if (!have_printed_row_begin) { |
printf (op->table_row_begin); |
have_printed_row_begin=TRUE; |
have_printed_row_end=FALSE; |
have_printed_cell_begin=FALSE; |
} |
if (!have_printed_cell_begin) { |
printf (op->table_cell_begin); |
attrstack_express_all(); |
have_printed_cell_begin=TRUE; |
have_printed_cell_end=FALSE; |
} |
} |
} |
/*======================================================================== |
* Name: |
* Purpose: |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
static void |
starting_paragraph_align (int align) |
{ |
if (within_header && align != ALIGN_LEFT) |
starting_body(); |
switch (align) |
{ |
case ALIGN_CENTER: |
printf (op->center_begin); |
break; |
case ALIGN_LEFT: |
break; |
case ALIGN_RIGHT: |
printf (op->align_right_begin); |
break; |
case ALIGN_JUSTIFY: |
printf (op->align_right_begin); |
break; |
} |
} |
/*======================================================================== |
* Name: |
* Purpose: |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
static void |
ending_paragraph_align (int align) |
{ |
switch (align) { |
case ALIGN_CENTER: |
printf (op->center_end); |
break; |
case ALIGN_LEFT: |
// printf (op->align_left_end); |
break; |
case ALIGN_RIGHT: |
printf (op->align_right_end); |
break; |
case ALIGN_JUSTIFY: |
printf (op->justify_end); |
break; |
} |
} |
/*======================================================================== |
* Name: |
* Purpose: Recursive routine to produce the output in the target |
* format given on a tree of words. |
* Args: Word* (the tree). |
* Returns: None. |
*=======================================================================*/ |
static void |
word_print_core (Word *w) |
{ |
char *s; |
FILE *f=NULL; |
int is_cell_group=FALSE; |
int paragraph_begined=FALSE; |
int paragraph_align=ALIGN_LEFT; |
CHECK_PARAM_NOT_NULL(w); |
if (!coming_pars_that_are_tabular && within_table) { |
end_table(); |
} |
else if (coming_pars_that_are_tabular && !within_table) { |
begin_table(); |
} |
/* Mark our place in the stack */ |
attrstack_push(); |
while (w) { |
s = word_string (w); |
if (s) { |
/*--Ignore whitespace in header--------------------*/ |
if (*s==' ' && within_header) { |
/* no op */ |
} |
else |
/*--Handle word -----------------------------------*/ |
if (s[0] != '\\') |
{ |
starting_body(); |
starting_text(); |
if (!paragraph_begined) { |
starting_paragraph_align (paragraph_align); |
paragraph_begined=TRUE; |
} |
/*----------------------------------------*/ |
if (within_picture) { |
starting_body(); |
if (!f) { |
char *ext=NULL; |
switch (picture_type) { |
case PICT_WB: ext="bmp"; break; |
case PICT_WM: ext="wmf"; break; |
case PICT_MAC: ext="pict"; break; |
case PICT_JPEG: ext="jpg"; break; |
case PICT_PNG: ext="png"; break; |
case PICT_DI: ext="dib"; break; /* Device independent bitmap=??? */ |
case PICT_PM: ext="pmm"; break; /* OS/2 metafile=??? */ |
} |
sprintf (picture_path, "pict%03d.%s", |
picture_file_number++,ext); |
f=fopen(picture_path,"w"); |
} |
if (s[0]!=' ') { |
char *s2; |
printf (op->comment_begin); |
printf ("picture data found, "); |
if (picture_wmetafile_type_str) { |
printf ("WMF type is %s, ", |
picture_wmetafile_type_str); |
} |
printf ("picture dimensions are %d by %d, depth %d", |
picture_width, picture_height, picture_bits_per_pixel); |
printf (op->comment_end); |
if (picture_width && picture_height && picture_bits_per_pixel) { |
s2=s; |
while (*s2) { |
unsigned int tmp,value; |
tmp=tolower(*s2++); |
if (tmp>'9') tmp-=('a'-10); |
else tmp-='0'; |
value=16*tmp; |
tmp=tolower(*s2++); |
if (tmp>'9') tmp-=('a'-10); |
else tmp-='0'; |
value+=tmp; |
fprintf (f,"%c", value); |
} |
} |
} |
} |
/*----------------------------------------*/ |
else { |
total_chars_this_line += strlen(s); |
if (op->word_begin) |
printf (op->word_begin); |
print_with_special_exprs (s); |
if (op->word_end) |
printf (op->word_end); |
} |
/*---Handle RTF keywords---------------------------*/ |
} else { |
int done=FALSE; |
s++; |
/*----Paragraph alignment----------------------------------------------------*/ |
if (!strcmp ("ql", s)) |
paragraph_align = ALIGN_LEFT; |
else if (!strcmp ("qr", s)) |
paragraph_align = ALIGN_RIGHT; |
else if (!strcmp ("qj", s)) |
paragraph_align = ALIGN_JUSTIFY; |
else if (!strcmp ("qc", s)) |
paragraph_align = ALIGN_CENTER; |
else if (!strcmp ("pard", s)) |
{ |
/* Clear out all font attributes. |
*/ |
attr_pop_all(); |
if(coming_pars_that_are_tabular) { |
--coming_pars_that_are_tabular; |
} |
/* Clear out all paragraph attributes. |
*/ |
ending_paragraph_align(paragraph_align); |
paragraph_align = ALIGN_LEFT; |
paragraph_begined = FALSE; |
} |
/*----Table keywords---------------------------------------------------------*/ |
else |
if (!strcmp (s, "cell")) { |
is_cell_group=TRUE; |
if (!have_printed_cell_begin) { |
/* Need this with empty cells */ |
printf (op->table_cell_begin); |
attrstack_express_all(); |
} |
attr_pop_dump(); |
printf (op->table_cell_end); |
have_printed_cell_begin = FALSE; |
have_printed_cell_end=TRUE; |
} |
else if (!strcmp (s, "row")) { |
if (within_table) { |
printf (op->table_row_end); |
have_printed_row_begin = FALSE; |
have_printed_row_end=TRUE; |
} else { |
if (debug_mode) { |
printf (op->comment_begin); |
printf ("end of table row"); |
printf (op->comment_end); |
} |
} |
} |
/*----Special chars---------------------------------------------------------*/ |
else if (*s == '\'') { |
/* \'XX is a hex char code expression */ |
int ch = h2toi (&s[1]); |
char *s2; |
s2 = op_translate_char (op, charset_type, ch); |
if (!s2 || !*s2) { |
printf (op->comment_begin); |
printf("char 0x%02x",ch); |
printf (op->comment_end); |
} else { |
if (op->word_begin) |
printf (op->word_begin); |
printf ("%s", s2); |
if (op->word_end) |
printf (op->word_end); |
} |
} |
else |
/*----Search the RTF command hash-------------------------------------------*/ |
{ |
int ch; |
int index=0; |
int have_param=FALSE, param=0; |
HashItem *hip; |
char *p; |
int match; |
/* Look for a parameter */ |
p=s; |
while(*p && (!isdigit(*p) && *p!='-')) p++; |
if (*p && (isdigit(*p) || *p=='-')) { |
have_param=TRUE; |
param=atoi (p); |
} |
/* Generate a hash index |
*/ |
ch = tolower (*s); |
if (ch>='a' && ch<='z') |
hip = hash [ch-'a']; |
else |
hip = hashArray_other; |
if (!hip) { |
if (debug_mode) { |
printf (op->comment_begin); |
printf ("unfamiliar rtf command: %s", s); |
printf (op->comment_begin); |
} |
} |
else |
{ |
while (!done) { |
match=FALSE; |
if (have_param) { |
int len=p-s; |
if (!hip[index].name[len] && !strncmp (s, hip[index].name, len)) |
match=TRUE; |
} |
else |
match = !strcmp(s, hip[index].name); |
if (match) { |
#if 0 |
char *always; |
#endif |
char *debug; |
int terminate_group; |
if (hip[index].func) { |
terminate_group = hip[index].func (w,paragraph_align, have_param, param); |
if (terminate_group) |
while(w) w=w->next; |
} |
debug=hip[index].debug_print; |
#if 0 |
always=hip[index].always_print; |
if (always) |
printf ("%s", always); |
#endif |
if (debug && debug_mode) { |
printf (op->comment_begin); |
printf ("%s", debug); |
printf (op->comment_end); |
} |
done=TRUE; |
} |
else |
{ |
index++; |
if (!hip[index].name) |
done=TRUE; |
} |
} |
} |
if (!match) { |
if (debug_mode) { |
printf (op->comment_begin); |
printf ("unfamiliar rtf command: %s", s); |
printf (op->comment_end); |
} |
} |
} |
} |
/*-------------------------------------------------------------------------*/ |
} else { |
Word *child; |
child = w->child; |
if (!paragraph_begined) { |
starting_paragraph_align (paragraph_align); |
paragraph_begined=TRUE; |
} |
if (child) |
word_print_core (child); |
} |
if (w) |
w = w->next; |
} |
if (within_picture) { |
if(f) { |
fclose(f); |
printf (op->imagelink_begin); |
printf ("%s", picture_path); |
printf (op->imagelink_end); |
within_picture=FALSE; |
} |
} |
/* Undo font attributes UNLESS we're doing table cells |
* since they would appear between </td> and </tr>. |
*/ |
if (!is_cell_group) |
attr_pop_all(); |
else |
attr_drop_all(); |
/* Undo paragraph alignment |
*/ |
if (paragraph_begined) |
ending_paragraph_align (paragraph_align); |
attrstack_drop(); |
} |
/*======================================================================== |
* Name: |
* Purpose: |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
word_print (Word *w) |
{ |
CHECK_PARAM_NOT_NULL (w); |
if (!inline_mode) { |
printf (op->document_begin); |
printf (op->header_begin); |
} |
print_banner (); |
within_header=TRUE; |
have_printed_body=FALSE; |
within_table=FALSE; |
simulate_allcaps=FALSE; |
word_print_core (w); |
end_table(); |
if (!inline_mode) { |
printf (op->body_end); |
printf (op->document_end); |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/convert.h |
---|
0,0 → 1,51 |
/*=========================================================================== |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
===========================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: convert |
* Author name: Zach Smith |
* Create date: 19 Sep 2001 |
* Purpose: Definitions for the conversion module |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _CONVERT |
enum { |
CHARSET_ANSI=1, |
CHARSET_MAC, |
CHARSET_CP437, |
CHARSET_CP850 |
}; |
#ifndef _WORD |
#include "word.h" |
#endif |
extern void word_print (Word*); |
#define _CONVERT |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/defs.h |
---|
0,0 → 1,66 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: defs.h |
* Author name: Zach Smith |
* Create date: 1 Sept 2000 |
* Purpose: Basic definitions plus externs for UnRTF |
*---------------------------------------------------------------------- |
* Changes: |
* 21 Oct 00, tuorfa@yahoo.com: moved program version to this file |
* 08 Apr 01, tuorfa@yahoo.com: updated usage info. |
* 08 Sep 01, tuorfa@yahoo.com: added PROGRAM_NAME. |
* 19 Sep 01, tuorfa@yahoo.com: added PROGRAM_WEBSITE. |
*--------------------------------------------------------------------*/ |
#define PROGRAM_VERSION "0.18.1" |
#define PROGRAM_NAME "UnRTF" |
#define PROGRAM_WEBSITE "http://www.geocities.com/tuorfa" |
/* Select the language for reporting of file creation/modificaton dates */ |
#define ENGLISH |
#if 0 |
#define FRANCAIS |
#define ITALIANO |
#endif |
#define TRUE (1) |
#define FALSE (0) |
#define USAGE "unrtf [--version] [--help] [--nopict|-n] [--html] [--text] [--vt] [--latex] [--ps] [--wpml] [-t html|text|vt|latex|ps|wpml] <filename>" |
/* Default names for RTF's default fonts */ |
#define FONTNIL_STR "Times,TimesRoman,TimesNewRoman" |
#define FONTROMAN_STR "Times,Palatino" |
#define FONTSWISS_STR "Helvetica,Arial" |
#define FONTMODERN_STR "Courier,Verdana" |
#define FONTSCRIPT_STR "Cursive,ZapfChancery" |
#define FONTDECOR_STR "ZapfChancery" |
#define FONTTECH_STR "Symbol" |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/error.c |
---|
0,0 → 1,89 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: error |
* Author name: Zach Smith |
* Create date: 01 Sep 00 |
* Purpose: Management of errors and warnings, when reporting |
* the source code file/line is not necessary. |
*---------------------------------------------------------------------- |
* Changes |
* 10 Oct 00, tuorfa@yahoo.com: added usage() |
* 15 Oct 00, tuorfa@yahoo.com: improved output readability |
* 22 Sep 01, tuorfa@yahoo.com: removed mention of line number in handlers |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include "defs.h" |
#include "main.h" |
/*======================================================================== |
* Name: usage |
* Purpose: Prints usage information and exits with an error. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
usage () |
{ |
fprintf (stdout, "Usage: %s\n", USAGE); |
exit(0); |
} |
/*======================================================================== |
* Name: error_handler |
* Purpose: Prints error message and other useful info, then exits. |
* Args: Message. |
* Returns: None. |
*=======================================================================*/ |
void |
error_handler (char* message) |
{ |
fprintf (stderr, "Error: %s\n", message); |
exit(10); |
} |
/*======================================================================== |
* Name: warning_handler |
* Purpose: Prints useful info to stderr, but doesn't exit. |
* Args: Message. |
* Returns: None. |
*=======================================================================*/ |
void |
warning_handler (char* message) |
{ |
fprintf (stderr, "Warning: %s\n", message); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/error.h |
---|
0,0 → 1,45 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: error.h |
* Author name: Zach Smith |
* Create date: 1 Sept 2000 |
* Purpose: Macros to be executed at the start of a function, |
* when reporting source code file/line is useful. |
*---------------------------------------------------------------------- |
* Changes |
*--------------------------------------------------------------------*/ |
#include <stdlib.h> |
#define CHECK_PARAM_NOT_NULL(XX) { if ((XX)==NULL) { fprintf (stderr, "internal error: null pointer param in %s at %d\n", __FILE__, __LINE__); exit (1); }} |
#define CHECK_MALLOC_SUCCESS(XX) { if ((XX)==NULL) { fprintf (stderr, "internal error: cannot allocate memory in %s at %d\n", __FILE__, __LINE__); exit (1); }} |
extern void usage(void); |
extern void error_handler (char*); |
extern void warning_handler (char*); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/hash.c |
---|
0,0 → 1,197 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: hash |
* Author name: Zach Smith |
* Create date: 01 Sep 00 |
* Purpose: Word-hash management. Words are put into a hash and an |
* identifier is returned. This is used to save us from |
* doing multiple mallocs for recurring strings such as |
* 'the' and \par. This is not a big issue under Unix, |
* but it is under other OSes and anyway, waste not want not. |
*---------------------------------------------------------------------- |
* Changes: |
* 08 Apr 01, tuorfa@yahoo.com: check for out of memory after malloc. |
* 21 Apr 01, tuorfa@yahoo.com: signed to conversion unsigned bug |
* 03 Aug 01, tuorfa@yahoo.com: fixes for using 16-bit compiler |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "error.h" |
#include "main.h" |
#include "malloc.h" |
typedef struct _hi { |
struct _hi *next; |
char *str; |
unsigned long value; |
} |
HashItem; |
/* Index by first char of string */ |
static HashItem *hash[256]; |
static unsigned long hash_length[256]; |
static unsigned long hash_value=0; |
/*======================================================================== |
* Name: hash_init |
* Purpose: Clear the hash table. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
hash_init () |
{ |
int i; |
for (i=0; i<256; i++) { |
hash[i]=NULL; |
hash_length[i]=0; |
} |
} |
/*======================================================================== |
* Name: hash_stats |
* Purpose: Prints to stderr the number of words stored. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
void |
hash_stats () |
{ |
int i; |
unsigned long total=0; |
for (i=0; i<256; i++) { |
total += hash_length[i]; |
} |
fprintf (stderr,"%lu words were hashed.\n", total); |
} |
/*======================================================================== |
* Name: hashitem_new |
* Purpose: Creates a new linked list item for the hash table. |
* Args: String. |
* Returns: HashItem. |
*=======================================================================*/ |
static HashItem * |
hashitem_new (char *str) |
{ |
HashItem *hi; |
unsigned long i; |
hi=(HashItem*) my_malloc(sizeof(HashItem)); |
if (!hi) |
error_handler ("out of memory"); |
memset ((void*)hi, 0, sizeof (HashItem)); |
hi->str = my_strdup(str); |
i = *str; |
if (i=='\\') i=str[1]; |
i <<= 24; |
hi->value = i | (hash_value++ & 0xffffff); |
hi->next = NULL; |
#if 0 |
if (debug_mode) { |
printf ("<!-- storing val %08lx str %s -->\n", |
hi->value, hi->str); |
} |
#endif |
return hi; |
} |
/*======================================================================== |
* Name: hash_get_index |
* Purpose: Given a string, returns the "index" i.e. the word identifier. |
* Args: String. |
* Returns: Index. |
*=======================================================================*/ |
unsigned long |
hash_get_index (char *str) |
{ |
unsigned short index; |
HashItem *hi; |
char ch; |
ch = *str; |
if (ch=='\\' && *(str+1)) |
ch = *(str+1); |
index = (unsigned) ch; |
hi = hash[index]; |
while (hi) { |
if (!strcmp(hi->str,str)) |
return hi->value; |
hi=hi->next; |
} |
/* not in hash */ |
hi = hashitem_new (str); |
hi->next = hash[index]; |
hash [index] = hi; |
++hash_length [index]; |
return hi->value; |
} |
/*======================================================================== |
* Name: hash_get_string |
* Purpose: Given the index (word identifier) returns the word string. |
* Args: Index. |
* Returns: String, or NULL if not found. |
*=======================================================================*/ |
char* |
hash_get_string (unsigned long value) |
{ |
int index; |
HashItem *hi; |
index = value >> 24; |
hi = hash[index]; |
while (hi) { |
if (hi->value == value) |
return hi->str; |
hi=hi->next; |
} |
warning_handler ("word not in hash"); |
return NULL; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/hash.h |
---|
0,0 → 1,40 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: hash.h |
* Author name: Zach Smith |
* Create date: 1 Sept 2000 |
* Purpose: Definitions for the hash module. |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
extern void hash_init (void); |
extern void hash_stats (void); |
extern unsigned long hash_get_index (char *); |
extern char* hash_get_string (unsigned long ); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/html.c |
---|
0,0 → 1,537 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: html |
* Author name: Zach Smith |
* Create date: 18 Sep 01 |
* Purpose: HTML-specific output module |
*---------------------------------------------------------------------- |
* Changes: |
* 01 Aug 01, tuorfa@yahoo.com: code moved over from convert.c |
* 03 Aug 01, tuorfa@yahoo.com: removed null entries to save space |
* 08 Aug 01, tuorfa@yahoo.com, gommer@gmx.net: fixed/added some ANSI chars |
* 18 Sep 01, tuorfa@yahoo.com: moved character sets into html.c etc |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "malloc.h" |
#include "defs.h" |
#include "error.h" |
#include "main.h" |
#include "output.h" |
static char* ascii [96] = { |
/* 0x20 */ " ", "!", "\"", "#", "$", "%", "&", "'", |
/* 0x28 */ "(", ")", "*", "+", ",", "-", ".", "/", |
/* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7", |
/* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?", |
/* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G", |
/* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O", |
/* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W", |
/* 0x58 */ "X", "Y", "Z", "[", "\\", "]", "^", "_", |
/* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g", |
/* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o", |
/* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w", |
/* 0x78 */ "x", "y", "z", "{", "|", "}", "~", "", |
}; |
static char* ansi [] = { |
/* 0x82 */ "‚", "ƒ", |
"„", "…", "†", "‡", |
"ˆ", "‰", "Š", "‹", |
"Œ", NULL, NULL, NULL, |
/* 0x90 */ NULL,"`","'","``","''","•","–","—", |
/* 0x98 */ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, |
/* 0xa0 */ " ","¡","¢","£","¤","¥","¦","§", |
/* 0xa8 */ "¨","©","ª","«","¬","­","®","¯", |
/* 0xb0 */ "°", "±","²","³","´","µ","¶","·", |
/* 0xb8 */ "¸","¹", "º","»", "¼", "½","¾","¿", |
/* 0xc0 */ "À","Á","Â","Ã","Ä","Å","Æ","Ç", |
/* 0xc8 */ "È","É","Ê","Ë","Ì","Í","Î","Ï", |
/* 0xd0 */ "Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×", |
/* 0xd8 */ "Ø","Ù","Ú","Û","Ü","Ý","Þ","ß", |
/* 0xe0 */ "à","á","â","ã","ä","å","æ","ç", |
/* 0xe8 */ "è","é","ê","ë","ì","í","î","ï", |
/* 0xf0 */ "ð","ñ","ò","ó","ô","õ","ö","÷", |
/* 0xf8 */ "ø","ù","ú","û","ü","ý","þ","ÿ", |
}; |
static char* mac [] = { |
/* 0xa4 */ "•", NULL,NULL,NULL,NULL,NULL,NULL,NULL, |
/* 0xb0 */ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, |
/* 0xc0 */ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, |
/* 0xd0 */ "—","–","“","”","&lquo;","&rquo;", |
}; |
static char* cp437 [] = { |
/* 0x80 */ "ç", |
/* 0x81 */ "ü", |
/* 0x82 */ "é", |
/* 0x83 */ "â", |
/* 0x84 */ "ä", |
/* 0x85 */ "à", |
/* 0x86 */ "å", |
/* 0x87 */ "ç", |
/* 0x88 */ "ê", |
/* 0x89 */ "ë", |
/* 0x8a */ "è", |
/* 0x8b */ "ï", |
/* 0x8c */ "î", |
/* 0x8d */ "ì", |
/* 0x8e */ "ä", |
/* 0x8f */ "å", |
/* 0x90 */ "é", |
/* 0x91 */ "æ", |
/* 0x92 */ "æ", |
/* 0x93 */ "ô", |
/* 0x94 */ "ö", |
/* 0x95 */ "ò", |
/* 0x96 */ "û", |
/* 0x97 */ "ù", |
/* 0x98 */ "ÿ", |
/* 0x99 */ "ö", |
/* 0x9a */ "ü", |
/* 0x9b */ "¢", |
/* 0x9c */ "£", |
/* 0x9d */ "¥", |
/* 0x9e */ "₧", /* peseta */ |
/* 0x9f */ "ƒ", /* small f with hook */ |
/* 0xa0 */ "á", |
/* 0xa1 */ "í", |
/* 0xa2 */ "ó", |
/* 0xa3 */ "ú", |
/* 0xa4 */ "ñ", |
/* 0xa5 */ "ñ", |
/* 0xa6 */ "ª", |
/* 0xa7 */ "¼", |
/* 0xa8 */ "¿", |
/* 0xa9 */ "⌐", /* reversed not */ |
/* 0xaa */ "¬", |
/* 0xab */ "½", |
/* 0xac */ "»", |
/* 0xad */ "¡", |
/* 0xae */ "«", |
/* 0xaf */ "º", |
/* 0xb0 */ "░", /* light shade */ |
/* 0xb1 */ "▒", /* med. shade */ |
/* 0xb2 */ "▓", /* dark shade */ |
/* 0xb3 */ "│", /* box-draw light vert. */ |
/* 0xb4 */ "┤", /* box-draw light vert. + lt. */ |
/* 0xb5 */ "╡", /* box-draw vert. sgl. + lt. dbl. */ |
/* 0xb6 */ "╢", /* box-draw vert. dbl. + lt. sgl. */ |
/* 0xb7 */ "╖", /* box-draw dn. dbl. + lt. sgl. */ |
/* 0xb8 */ "╕", /* box-draw dn. sgl. + lt. dbl. */ |
/* 0xb9 */ "╣", /* box-draw dbl. vert. + lt. */ |
/* 0xba */ "║", /* box-draw dbl. vert. */ |
/* 0xbb */ "╗", /* box-draw dbl. dn. + lt. */ |
/* 0xbc */ "╝", /* box-draw dbl. up + lt. */ |
/* 0xbd */ "╜", /* box-draw up dbl. + lt. sgl. */ |
/* 0xbe */ "╛", /* box-draw up sgl. + lt. dbl. */ |
/* 0xbf */ "┐", /* box-draw light dn. + lt. */ |
/* 0xc0 */ "└", /* box-draw light up + rt. */ |
/* 0xc1 */ "┴", /* box-draw light up + horiz. */ |
/* 0xc2 */ "┬", /* box-draw light dn. + horiz. */ |
/* 0xc3 */ "├", /* box-draw light vert. + rt. */ |
/* 0xc4 */ "─", /* box-draw light horiz. */ |
/* 0xc5 */ "┼", /* box-draw light vert. + horiz. */ |
/* 0xc6 */ "╞", /* box-draw vert. sgl. + rt. dbl. */ |
/* 0xc7 */ "╟", /* box-draw vert. dbl. + rt. sgl. */ |
/* 0xc8 */ "╚", /* box-draw dbl. up + rt. */ |
/* 0xc9 */ "╔", /* box-draw dbl. dn. + rt. */ |
/* 0xca */ "╩", /* box-draw dbl. up + horiz. */ |
/* 0xcb */ "╦", /* box-draw dbl. dn. + horiz. */ |
/* 0xcc */ "╠", /* box-draw dbl. vert. + rt. */ |
/* 0xcd */ "═", /* box-draw dbl. horiz. */ |
/* 0xce */ "╬", /* box-draw dbl. vert. + horiz. */ |
/* 0xcf */ "╧", /* box-draw up sgl. + horiz. dbl. */ |
/* 0xd0 */ "╨", /* box-draw up dbl. + horiz. sgl. */ |
/* 0xd1 */ "╤", /* box-draw dn. sgl. + horiz. dbl. */ |
/* 0xd2 */ "╥", /* box-draw dn. dbl. + horiz. sgl. */ |
/* 0xd3 */ "╙", /* box-draw up dbl. + rt. sgl. */ |
/* 0xd4 */ "╘", /* box-draw up sgl. + rt. dbl. */ |
/* 0xd5 */ "╒", /* box-draw dn. sgl. + rt. dbl. */ |
/* 0xd6 */ "╓", /* box-draw dn. dbl. + rt. sgl. */ |
/* 0xd7 */ "╫", /* box-draw vert. dbl. + horiz. sgl. */ |
/* 0xd8 */ "╪", /* box-draw vert. sgl. + horiz. dbl. */ |
/* 0xd9 */ "┘", /* box-draw light up + lt. */ |
/* 0xda */ "┌", /* box-draw light dn. + rt. */ |
/* 0xdb */ "█", /* full block */ |
/* 0xdc */ "▄", /* lower 1/2 block */ |
/* 0xdd */ "▌", /* lt. 1/2 block */ |
/* 0xde */ "▐", /* rt. 1/2 block */ |
/* 0xdf */ "▀", /* upper 1/2 block */ |
/* 0xe0 */ "α", /* greek small alpha */ |
/* 0xe1 */ "ß", |
/* 0xe2 */ "Γ", /* greek cap gamma */ |
/* 0xe3 */ "π", /* greek small pi */ |
/* 0xe4 */ "Σ", /* greek cap sigma */ |
/* 0xe5 */ "σ", /* greek small sigma */ |
/* 0xe6 */ "µ", |
/* 0xe7 */ "τ", /* greek small tau */ |
/* 0xe8 */ "Φ", /* greek cap phi */ |
/* 0xe9 */ "Θ", /* greek cap theta */ |
/* 0xea */ "Ω", /* greek cap omega */ |
/* 0xeb */ "δ", /* greek small delta */ |
/* 0xec */ "∞", /* inf. */ |
/* 0xed */ "φ", /* greek small phi */ |
/* 0xee */ "ε", /* greek small epsilon */ |
/* 0xef */ "∩", /* intersect */ |
/* 0xf0 */ "≡", /* identical */ |
/* 0xf1 */ "±", |
/* 0xf2 */ "≥", /* greater-than or equal to */ |
/* 0xf3 */ "≤", /* less-than or equal to */ |
/* 0xf4 */ "⌠", /* top 1/2 integral */ |
/* 0xf5 */ "⌡", /* bottom 1/2 integral */ |
/* 0xf6 */ "÷", |
/* 0xf7 */ "≈", /* almost = */ |
/* 0xf8 */ "+", |
/* 0xf9 */ "∙", /* bullet op */ |
/* 0xfa */ "·", |
/* 0xfb */ "√", /* sqrt */ |
/* 0xfc */ "ⁿ", /* super-script small n */ |
/* 0xfd */ "²", |
/* 0xfe */ "■", /* black square */ |
/* 0xff */ " ", |
}; |
static char* cp850 [] = { |
/* 0x80 */ "ç", |
/* 0x81 */ "ü", |
/* 0x82 */ "é", |
/* 0x83 */ "â", |
/* 0x84 */ "ä", |
/* 0x85 */ "à", |
/* 0x86 */ "å", |
/* 0x87 */ "ç", |
/* 0x88 */ "ê", |
/* 0x89 */ "ë", |
/* 0x8a */ "è", |
/* 0x8b */ "ï", |
/* 0x8c */ "î", |
/* 0x8d */ "ì", |
/* 0x8e */ "ä", |
/* 0x8f */ "å", |
/* 0x90 */ "é", |
/* 0x91 */ "æ", |
/* 0x92 */ "æ", |
/* 0x93 */ "ô", |
/* 0x94 */ "ö", |
/* 0x95 */ "ò", |
/* 0x96 */ "û", |
/* 0x97 */ "ù", |
/* 0x98 */ "ÿ", |
/* 0x99 */ "ö", |
/* 0x9a */ "ü", |
/* 0x9b */ "ø", |
/* 0x9c */ "£", |
/* 0x9d */ "ø", |
/* 0x9e */ "×", |
/* 0x9f */ "ƒ", /* small f with hook */ |
/* 0xa0 */ "á", |
/* 0xa1 */ "í", |
/* 0xa2 */ "ó", |
/* 0xa3 */ "ú", |
/* 0xa4 */ "ñ", |
/* 0xa5 */ "ñ", |
/* 0xa6 */ "ª", |
/* 0xa7 */ "¼", |
/* 0xa8 */ "¿", |
/* 0xa9 */ "®", |
/* 0xaa */ "¬", |
/* 0xab */ "½", |
/* 0xac */ "»", |
/* 0xad */ "¡", |
/* 0xae */ "«", |
/* 0xaf */ "º", |
/* 0xb0 */ "░", /* light shade */ |
/* 0xb1 */ "▒", /* med. shade */ |
/* 0xb2 */ "▓", /* dark shade */ |
/* 0xb3 */ "│", /* box-draw light vert. */ |
/* 0xb4 */ "┤", /* box-draw light vert. + lt. */ |
/* 0xb5 */ "á", |
/* 0xb6 */ "â", |
/* 0xb7 */ "à", |
/* 0xb8 */ "©", |
/* 0xb9 */ "╣", /* box-draw dbl. vert. + lt. */ |
/* 0xba */ "║", /* box-draw dbl. vert. */ |
/* 0xbb */ "╗", /* box-draw dbl. dn. + lt. */ |
/* 0xbc */ "╝", /* box-draw dbl. up + lt. */ |
/* 0xbd */ "¢", |
/* 0xbe */ "¥", |
/* 0xbf */ "┐", /* box-draw light dn. + lt. */ |
/* 0xc0 */ "└", /* box-draw light up + rt. */ |
/* 0xc1 */ "┴", /* box-draw light up + horiz. */ |
/* 0xc2 */ "┬", /* box-draw light dn. + horiz. */ |
/* 0xc3 */ "├", /* box-draw light vert. + rt. */ |
/* 0xc4 */ "─", /* box-draw light horiz. */ |
/* 0xc5 */ "┼", /* box-draw light vert. + horiz. */ |
/* 0xc6 */ "ã", |
/* 0xc7 */ "ã", |
/* 0xc8 */ "╚", /* box-draw dbl. up + rt. */ |
/* 0xc9 */ "╔", /* box-draw dbl. dn. + rt. */ |
/* 0xca */ "╩", /* box-draw dbl. up + horiz. */ |
/* 0xcb */ "╦", /* box-draw dbl. dn. + horiz. */ |
/* 0xcc */ "╠", /* box-draw dbl. vert. + rt. */ |
/* 0xcd */ "═", /* box-draw dbl. horiz. */ |
/* 0xce */ "╬", /* box-draw dbl. vert. + horiz. */ |
/* 0xcf */ "¤", |
/* 0xd0 */ "ð", |
/* 0xd1 */ "ð", |
/* 0xd2 */ "ê", |
/* 0xd3 */ "ë", |
/* 0xd4 */ "è", |
/* 0xd5 */ "ı", /* small dotless i */ |
/* 0xd6 */ "í", |
/* 0xd7 */ "î", |
/* 0xd8 */ "ï", |
/* 0xd9 */ "┘", /* box-draw light up + lt. */ |
/* 0xda */ "┌", /* box-draw light dn. + rt. */ |
/* 0xdb */ "█", /* full-block */ |
/* 0xdc */ "▄", /* lower 1/2 block */ |
/* 0xdd */ "¦", |
/* 0xde */ "ì", |
/* 0xdf */ "▀", /* upper 1/2 block */ |
/* 0xe0 */ "ó", |
/* 0xe1 */ "ß", |
/* 0xe2 */ "ô", |
/* 0xe3 */ "ò", |
/* 0xe4 */ "õ", |
/* 0xe5 */ "õ", |
/* 0xe6 */ "µ", |
/* 0xe7 */ "þ", |
/* 0xe8 */ "þ", |
/* 0xe9 */ "ú", |
/* 0xea */ "û", |
/* 0xeb */ "ù", |
/* 0xec */ "ý", |
/* 0xed */ "ý", |
/* 0xee */ "¯", |
/* 0xef */ "´", |
/* 0xf0 */ "­", |
/* 0xf1 */ "±", |
/* 0xf2 */ "‗", /* dbl. lowline */ |
/* 0xf3 */ "¾", |
/* 0xf4 */ "¶", |
/* 0xf5 */ "§", |
/* 0xf6 */ "÷", |
/* 0xf7 */ "¸", |
/* 0xf8 */ "+", |
/* 0xf9 */ "¨", |
/* 0xfa */ "·", |
/* 0xfb */ "¹", |
/* 0xfc */ "³", |
/* 0xfd */ "²", |
/* 0xfe */ "■", /* black square */ |
/* 0xff */ " ", |
}; |
/*======================================================================== |
* Name: html_init |
* Purpose: Generates the HTML output personality. |
* Args: None. |
* Returns: OutputPersonality. |
*=======================================================================*/ |
OutputPersonality * |
html_init (void) |
{ |
OutputPersonality* op; |
op = op_create(); |
op->comment_begin = "<!--- "; |
op->comment_end = " --->\n"; |
op->document_begin = "<html>\n"; |
op->document_end = "</html>\n"; |
op->header_begin = "<head>\n"; |
op->header_end = "</head>\n"; |
op->document_title_begin = "<title>"; |
op->document_title_end = "</title>\n"; |
op->document_author_begin = "<!--author: "; |
op->document_author_end = "--->\n"; |
op->document_changedate_begin = "<!--changed: "; |
op->document_changedate_end = "--->\n"; |
op->body_begin = "<body>"; |
op->body_end = "</body>\n"; |
op->paragraph_begin = "<p>"; |
op->paragraph_end = "</p>\n"; |
op->center_begin = "<center>"; |
op->center_end = "</center>\n"; |
op->justify_begin = "<div align=justify>\n"; |
op->justify_end = "</div>\n"; |
op->align_left_begin = "<div align=left>\n"; |
op->align_left_end = "</div>\n"; |
op->align_right_begin = "<div align=right>\n"; |
op->align_right_end = "</div>\n"; |
op->forced_space = " "; |
op->line_break = "<br>\n"; |
op->page_break = "<p><hr><p>\n"; |
op->hyperlink_begin = "<a href=\""; |
op->hyperlink_end = "\">hyperlink</a>"; |
op->imagelink_begin = "<img src=\""; |
op->imagelink_end = "\">"; |
op->table_begin = "<table border=2>\n"; |
op->table_end = "</table>\n"; |
op->table_row_begin = "<tr>"; |
op->table_row_end = "</tr>\n"; |
op->table_cell_begin = "<td>"; |
op->table_cell_end = "</td>\n"; |
/* Character attributes */ |
op->font_begin = "<font face=\"%s\">"; |
op->font_end = "</font>"; |
op->fontsize_begin = "<span style=\"font-size:%spt\">"; |
op->fontsize_end = "</span>"; |
op->fontsize8_begin = "<font size=1>"; |
op->fontsize8_end = "</font>"; |
op->fontsize10_begin = "<font size=2>"; |
op->fontsize10_end = "</font>"; |
op->fontsize12_begin = "<font size=3>"; |
op->fontsize12_end = "</font>"; |
op->fontsize14_begin = "<font size=4>"; |
op->fontsize14_end = "</font>"; |
op->fontsize18_begin = "<font size=5>"; |
op->fontsize18_end = "</font>"; |
op->fontsize24_begin = "<font size=6>"; |
op->fontsize24_end = "</font>"; |
op->smaller_begin = "<small>"; |
op->smaller_end = "</small>"; |
op->bigger_begin = "<big>"; |
op->bigger_end = "</big>"; |
op->foreground_begin = "<font color=\"%s\">"; |
op->foreground_end = "</font>"; |
op->background_begin = "<span style=\"background:%s\">"; |
op->background_end = "</span>"; |
op->bold_begin = "<b>"; |
op->bold_end = "</b>"; |
op->italic_begin = "<i>"; |
op->italic_end = "</i>"; |
op->underline_begin = "<u>"; |
op->underline_end = "</u>"; |
op->dbl_underline_begin = "<u>"; |
op->dbl_underline_end = "</u>"; |
op->superscript_begin = "<sup>"; |
op->superscript_end = "</sup>"; |
op->subscript_begin = "<sub>"; |
op->subscript_end = "</sub>"; |
op->strikethru_begin = "<s>"; |
op->strikethru_end = "</s>"; |
op->dbl_strikethru_begin = "<s>"; |
op->dbl_strikethru_end = "</s>"; |
op->emboss_begin="<span style=\"background:gray\"><font color=black>"; |
op->emboss_end = "</font></span>"; |
op->engrave_begin = "<span style=\"background:gray\"><font color=navyblue>"; |
op->engrave_end = "</font></span>"; |
op->shadow_begin= "<span style=\"background:gray\">"; |
op->shadow_end= "</span>"; |
op->outline_begin= "<span style=\"background:gray\">"; |
op->outline_end= "</span>"; |
op->expand_begin = "<span style=\"letter-spacing: %s\">"; |
op->expand_end = "</span>"; |
op->pointlist_begin = "<ol>\n"; |
op->pointlist_end = "</ol>\n"; |
op->pointlist_item_begin = "<li>"; |
op->pointlist_item_end = "</li>\n"; |
op->numericlist_begin = "<ul>\n"; |
op->numericlist_end = "</ul>\n"; |
op->numericlist_item_begin = "<li>"; |
op->numericlist_item_end = "</li>\n"; |
op->simulate_small_caps = TRUE; |
op->simulate_all_caps = TRUE; |
op->simulate_word_underline = TRUE; |
op->ascii_translation_table = ascii; |
op->ansi_translation_table = ansi; |
op->ansi_first_char = 0x82; |
op->ansi_last_char = 0xff; |
op->cp437_translation_table = cp437; |
op->cp437_first_char = 0x80; |
op->cp437_last_char = 0xff; |
op->cp850_translation_table = cp850; |
op->cp850_first_char = 0x80; |
op->cp850_last_char = 0xff; |
op->mac_translation_table = mac; |
op->mac_first_char = 0xa4; |
op->mac_last_char = 0xd5; |
op->chars.right_quote = "'"; |
op->chars.left_quote = "`"; |
op->chars.right_dbl_quote = "''"; |
op->chars.left_dbl_quote = "``"; |
return op; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/html.h |
---|
0,0 → 1,42 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: html |
* Author name: Zach Smith |
* Create date: 19 Sep 01 |
* Purpose: Definitions for the HTML output personality |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _HTML |
extern OutputPersonality* html_init(void); |
#define _HTML |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/latex.c |
---|
0,0 → 1,296 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: latex |
* Author name: Zach Smith |
* Create date: 18 Sep 01 |
* Purpose: LaTeX-specific output module |
*---------------------------------------------------------------------- |
* Changes: |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
* 23 Sep 01, tuorfa@yahoo.com: fixed accented characters |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "malloc.h" |
#include "defs.h" |
#include "error.h" |
#include "main.h" |
#include "output.h" |
static char* ascii [96] = { |
/* 0x20 */ " ", "!", "''", "\\#", "{\\$}", "\\%", "\\&", "'", |
/* 0x28 */ "(", ")", "{\ast}", "+", ",", "-", ".", "/", |
/* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7", |
/* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?", |
/* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G", |
/* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O", |
/* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W", |
/* 0x58 */ "X", "Y", "Z", "[", "{\\slash}", "]", "{\\caret}", "\\_", |
/* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g", |
/* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o", |
/* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w", |
/* 0x78 */ "x", "y", "z", "\\{", "$\\mid$", "\\}", "\\~{ }", "", |
}; |
static char* ansi [] = { |
/* 0x82 */ "?", "?", |
"?", "{\\ldots}", "{\\dag}", "{\\ddag}", |
"?", "?", "?", "?", |
"{\\OE}", NULL, NULL, NULL, |
/* 0x90 */ NULL,"`","'","``","''","{\\bullet}","--","---", |
/* 0x98 */ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, |
/* 0xa0 */ "\\:","?","?","{\\pounds}","?","\\Y","?","?", |
/* 0xa8 */ "?","{\\copyright}","?","?","?","?","?","?", |
/* 0xb0 */ "\\o ", "\\+- ","$^{2}$","$^{3}$","?","?","\\P ","?", |
/* 0xb8 */ "?","$^{1}$", "?","?", "\\frac{1}{4}", "\\frac{1}{2}","\\frac{3}{4}", |
"?", |
/* 0xc0 */ "\\`{A}","\\'{A}","\\o{A}", |
"\\~{A}","\\\"{A}","?","\\AE ","\\c{C}", |
/* 0xc8 */ "\\`{E}","\\'{E}","\\o{E}","\\\"{E}", |
"\\`{I}","\\'{I}","\\o{I}","\\\"{I}", |
/* 0xd0 */ "\\ETH ","\\~{N}","\\`{O}","\\'{O}", |
"\\o{O}","\\~{O}","\\\"{O}","\\mult ", |
/* 0xd8 */ "?","\\`{U}","\\'{U}","\\o{U}", |
"\\\"{U}","\\'{Y}","\\THORN","?", |
/* 0xe0 */ "\\`{a}","\\'{a}","\\o{a}", |
"\\~{a}","\\\"{a}","?","\\ae ","\\c{c}", |
/* 0xe8 */ "\\`{e}","\\'{e}","\\o{e}","\\\"{e}", |
"\\`{i}","\\'{i}","\\o{i}","\\\"{i}", |
/* 0xf0 */ "\\eth ","\\~{n}","\\`{o}","\\'{o}", |
"\\o{o}","\\~{o}","\\\"{o}","\\div ", |
/* 0xf8 */ "\\slash{o}","\\`{u}","\\'{u}","\\o{u}", |
"\\\"{u}","\\'{y}","\\thorn ","\\\"{y}", |
}; |
static char* mac [] = { |
"?", |
}; |
static char* cp437 [] = { |
"?", |
}; |
static char* cp850 [] = { |
"?", |
}; |
/*======================================================================== |
* Name: latex_init |
* Purpose: Generates the output personality for LaTeX. |
* Args: None. |
* Returns: OutputPersonality. |
*=======================================================================*/ |
OutputPersonality * |
latex_init (void) |
{ |
OutputPersonality* op; |
op = op_create(); |
op->comment_begin = "%% "; |
op->comment_end = "\n"; |
op->document_begin = "\\documentclass[11pt]{article}\n"; |
op->document_end = "\\end{document}"; |
op->header_begin = ""; |
op->header_end = ""; |
op->document_title_begin = "\\title{"; |
op->document_title_end = "}\n"; |
op->document_author_begin = "\\author{"; |
op->document_author_end = "}\n"; |
op->document_changedate_begin = "\\date{"; |
op->document_changedate_end = "}\n"; |
op->body_begin = "\n\n\\begin{document}\n\\maketitle\n"; |
op->body_end = "\\end{document}\n"; |
op->paragraph_begin = "\\par\n"; |
op->paragraph_end = ""; |
op->center_begin = "\\center{\n"; |
op->center_end = "}\n"; |
op->justify_begin = ""; |
op->justify_end = ""; |
op->align_left_begin = "\\begin{sloppy}\n"; |
op->align_left_end = "\\end{sloppy}\n"; |
op->align_right_begin = ""; |
op->align_right_end = ""; |
op->forced_space = ""; |
op->line_break = "\\par\n"; |
op->page_break = "\\pagebreak "; |
op->hyperlink_begin = ""; |
op->hyperlink_end = ""; |
op->imagelink_begin = ""; |
op->imagelink_end = ""; |
op->table_begin = "\\begin{tabular}{|lllll}\n"; |
op->table_end = "\n\\end{tabular}\n"; |
op->table_row_begin = ""; |
op->table_row_end = "\\hline \\\\\n"; |
op->table_cell_begin = ""; |
op->table_cell_end = " & "; |
/* Character attributes */ |
op->font_begin = ""; |
op->font_end = ""; |
op->fontsize_begin = ""; |
op->fontsize_end = ""; |
op->fontsize8_begin = "\\tiny{"; |
op->fontsize8_end = "}"; |
op->fontsize10_begin = "\\small{"; |
op->fontsize10_end = "}"; |
op->fontsize12_begin = "\\normalsize{"; |
op->fontsize12_end = "}"; |
op->fontsize14_begin = "{\\large "; |
op->fontsize14_end = "}"; |
op->fontsize18_begin = "{\\Large "; |
op->fontsize18_end = "}"; |
op->fontsize24_begin = "{\\LARGE "; |
op->fontsize24_end = "}"; |
op->fontsize36_begin = "{\\huge "; |
op->fontsize36_end = "}"; |
op->fontsize48_begin = "{\\Huge "; |
op->fontsize48_end = "}"; |
op->smaller_begin = ""; |
op->smaller_end = ""; |
op->bigger_begin = ""; |
op->bigger_end = ""; |
op->foreground_begin = ""; |
op->foreground_end = ""; |
op->background_begin = ""; |
op->background_end = ""; |
op->bold_begin = "{\\bf "; |
op->bold_end = "}"; |
op->italic_begin = "{\\it "; |
op->italic_end = "}"; |
op->underline_begin = ""; |
op->underline_end = "\n"; |
op->dbl_underline_begin = "{\\ul "; |
op->dbl_underline_end = "}"; |
op->pointlist_begin = "\\begin{itemize}\n"; |
op->pointlist_end = "\\end{itemize}\n"; |
op->pointlist_item_begin = "\\item "; |
op->pointlist_item_end = ""; |
op->numericlist_begin = "\\begin{enumerate}\n"; |
op->numericlist_end = "\\end{enumerate}\n"; |
op->numericlist_item_begin = "\\item "; |
op->numericlist_item_end = ""; |
op->superscript_begin = "$^{"; |
op->superscript_end = "}$"; |
op->subscript_begin = "$_{"; |
op->subscript_end = "}$"; |
op->strikethru_begin = "{"; |
op->strikethru_end = "}"; |
op->dbl_strikethru_begin = "{"; |
op->dbl_strikethru_end = "}"; |
op->emboss_begin=""; |
op->emboss_end = ""; |
op->engrave_begin = ""; |
op->engrave_end = ""; |
op->shadow_begin= ""; |
op->shadow_end= ""; |
op->small_caps_begin= "\\textsc{"; |
op->small_caps_end= "}"; |
op->outline_begin= ""; |
op->outline_end= ""; |
op->expand_begin = ""; |
op->expand_end = ""; |
op->simulate_small_caps = FALSE; |
op->simulate_all_caps = TRUE; |
op->simulate_word_underline = TRUE; |
op->ascii_translation_table = ascii; |
op->ansi_translation_table = ansi; |
op->ansi_first_char = 0x80; |
op->ansi_last_char = 0x80; |
op->cp437_translation_table = cp437; |
op->cp437_first_char = 0x80; |
op->cp437_last_char = 0x80; |
op->cp850_translation_table = cp850; |
op->cp850_first_char = 0x80; |
op->cp850_last_char = 0x80; |
op->mac_translation_table = mac; |
op->mac_first_char = 0x80; |
op->mac_last_char = 0x80; |
op->chars.right_quote = "'"; |
op->chars.left_quote = "`"; |
op->chars.right_dbl_quote = "''"; |
op->chars.left_dbl_quote = "``"; |
return op; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/latex.h |
---|
0,0 → 1,42 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: latex |
* Author name: Zach Smith |
* Create date: 19 Sep 01 |
* Purpose: Definitions for the PostScript(TM) output personality |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _LATEX |
extern OutputPersonality* latex_init(void); |
#define _LATEX |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/main.c |
---|
0,0 → 1,221 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: main.c |
* Author name: Zach Smith |
* Create date: 01 Sep 00 |
* Purpose: main() routine with file open/close. |
*---------------------------------------------------------------------- |
* Changes: |
* 14 Oct 00, tuorfa@yahoo.com: added -nopict option |
* 15 Oct 00, tuorfa@yahoo.com: added verify_file_type() |
* 08 Apr 01, tuorfa@yahoo.com: more GNU-like switches implemented |
* 24 Jul 01, tuorfa@yahoo.com: removed verify_file_type() |
* 03 Aug 01, tuorfa@yahoo.com: added --inline switch |
* 08 Sep 01, tuorfa@yahoo.com: added use of PROGRAM_NAME |
* 19 Sep 01, tuorfa@yahoo.com: addition of output personalities |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
* 23 Sep 01, tuorfa@yahoo.com: added wpml switch |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "defs.h" |
#include "error.h" |
#include "word.h" |
#include "convert.h" |
#include "parse.h" |
#include "hash.h" |
#include "malloc.h" |
#include "output.h" |
#include "html.h" |
#include "text.h" |
#include "vt.h" |
#include "ps.h" |
#include "latex.h" |
#include "wpml.h" |
int nopict_mode; /* TRUE => do not write \pict's to files */ |
int dump_mode; /* TRUE => output a dump of the word tree */ |
int debug_mode; /* TRUE => output comments within HTML */ |
int lineno; /* used for error reporting */ |
int simple_mode; /* TRUE => output HTML without SPAN/DIV tags */ |
int inline_mode; /* TRUE => output HTML without HTML/BODY/HEAD */ |
OutputPersonality *op; |
enum { |
OP_HTML, OP_TEXT, OP_LATEX, OP_PS, OP_VT, OP_WPML |
}; |
/*======================================================================== |
* Name: main |
* Purpose: Main control function. |
* Args: Args. |
* Returns: Exit code. |
*=======================================================================*/ |
int |
main (int argc, char **argv) |
{ |
FILE *f; |
Word * word; |
char *path=NULL; |
int i; |
int output_format = OP_HTML; |
nopict_mode = debug_mode = dump_mode = inline_mode = FALSE; |
if (argc<2 || argc>7) usage(); |
for (i=1; i<argc; i++) { |
if (!strcmp("--dump",argv[i])) dump_mode=TRUE; |
else if (!strcmp("-d",argv[i])) dump_mode=TRUE; |
else if (!strcmp("--debug",argv[i])) debug_mode=TRUE; |
else if (!strcmp("--simple",argv[i])) simple_mode=TRUE; |
else if (!strcmp("--html",argv[i])) output_format=OP_HTML; |
else if (!strcmp("--text",argv[i])) output_format=OP_TEXT; |
else if (!strcmp("--vt",argv[i])) output_format=OP_VT; |
else if (!strcmp("--ps",argv[i])) output_format=OP_PS; |
else if (!strcmp("--latex",argv[i])) output_format=OP_LATEX; |
else if (!strcmp("--wpml",argv[i])) output_format=OP_WPML; |
else if (!strcmp("-t",argv[i])) { |
if ((i+1)<argc && *argv[i+1]!='-') { |
i++; |
if (!strcmp ("html", argv[i])) |
output_format=OP_HTML; |
else if (!strcmp ("vt", argv[i])) |
output_format=OP_VT; |
else if (!strcmp ("text", argv[i])) |
output_format=OP_TEXT; |
else if (!strcmp ("ps", argv[i])) |
output_format=OP_PS; |
else if (!strcmp ("latex", argv[i])) |
output_format=OP_LATEX; |
else if (!strcmp ("wpml", argv[i])) |
output_format=OP_WPML; |
} |
} |
else if (!strcmp("--inline",argv[i])) inline_mode=TRUE; |
else if (!strcmp("--help",argv[i])) { |
usage(); |
exit (0); |
} |
else if (!strcmp("--version",argv[i])) { |
fprintf (stderr, "%s\n", PROGRAM_VERSION); |
exit (0); |
} |
else if (!strcmp("--nopict",argv[i])) nopict_mode=TRUE; |
else if (!strcmp("-n",argv[i])) nopict_mode=TRUE; |
else { |
if (*argv[i]=='-') usage(); |
if(path) |
usage(); |
else |
path=argv[i]; |
} |
} |
if (!path) usage(); |
switch (output_format) { |
case OP_TEXT: |
op = text_init(); |
break; |
case OP_VT: |
op = vt_init(); |
break; |
case OP_HTML: |
op = html_init(); |
break; |
case OP_PS: |
op = ps_init(); |
break; |
case OP_LATEX: |
op = latex_init(); |
break; |
case OP_WPML: |
op = wpml_init(); |
break; |
default: |
error_handler ("unknown output format"); |
} |
hash_init(); |
fprintf (stderr, "This is %s, ", PROGRAM_NAME); |
fprintf (stderr, "version %s\n", PROGRAM_VERSION); |
fprintf (stderr, "By Zach T. Smith\n"); |
if (debug_mode) fprintf (stderr, "Debug mode.\n"); |
if (dump_mode) fprintf (stderr, "Dump mode.\n"); |
f = fopen (path, "r"); |
if (!f) { |
char path2[200]; |
strcpy(path2,path); strcat(path2,".rtf"); |
f = fopen(path2, "r"); |
if(!f) |
error_handler ("cannot open input file"); |
} |
fprintf(stderr,"Processing %s...\n", path); |
lineno=0; |
word = word_read (f); |
if (dump_mode) { |
word_dump (word); |
printf ("\n"); |
} else { |
word_print (word); |
} |
fclose(f); |
fprintf(stderr,"Done.\n"); |
hash_stats(); |
if (debug_mode) { |
fprintf (stderr, "Total memory allocated %ld bytes.\n", |
total_malloced()); |
} |
/* May as well */ |
word_free (word); |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/main.h |
---|
0,0 → 1,48 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: main.h |
* Author name: Zach Smith |
* Create date: 1 Sept 2000 |
* Purpose: Externs for main.c. |
*---------------------------------------------------------------------- |
* Changes: |
* 15 Oct 00, tuorfa@yahoo.com: removed echo_mode extern |
* 19 Sep 01, tuorfa@yahoo.com: added output personality |
*--------------------------------------------------------------------*/ |
extern int lineno; |
extern int debug_mode; |
extern int simple_mode; |
extern int inline_mode; |
#ifndef _OUTPUT |
#include "output.h" |
#endif |
extern OutputPersonality *op; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/malloc.c |
---|
0,0 → 1,125 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: malloc |
* Author name: Zach Smith |
* Create date: 01 Aug 01 |
* Purpose: Memory management. Allows us to keep track of how |
* much memory is being used. |
*---------------------------------------------------------------------- |
* Changes: |
* 14 Aug 01, tuorfa@yahoo.com: added Turbo C support. |
* 16 Aug 01, Lars Unger <l.unger@tu-bs.de>: added Amiga/GCC support. |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
* 28 Sep 01, tuorfa@yahoo.com: removed Turbo C support. |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#if AMIGA |
#include <stdlib.h> |
#else |
#include <malloc.h> |
#endif |
#include "error.h" |
static unsigned long count=0; |
/*======================================================================== |
* Name: my_malloc |
* Purpose: Internal version of malloc necessary for record keeping. |
* Args: Amount. |
* Returns: Pointer. |
*=======================================================================*/ |
char * |
my_malloc (unsigned long size) { |
char *ptr; |
ptr = malloc (size); |
if (ptr) |
count += size; |
return ptr; |
} |
/*======================================================================== |
* Name: my_free |
* Purpose: Internal version of free necessary for record keeping. |
* Args: Pointer. |
* Returns: None. |
*=======================================================================*/ |
void |
my_free (char* ptr) { |
CHECK_PARAM_NOT_NULL(ptr); |
free (ptr); |
} |
/*======================================================================== |
* Name: total_malloced |
* Purpose: Returns total amount of memory thus far allocated. |
* Args: None. |
* Returns: Amount. |
*=======================================================================*/ |
unsigned long |
total_malloced (void) { |
return count; |
} |
/*======================================================================== |
* Name: my_strdup |
* Purpose: Internal version of strdup necessary for record keeping. |
* Args: String. |
* Returns: String. |
*=======================================================================*/ |
char * |
my_strdup (char *src) { |
unsigned long len; |
char *ptr; |
CHECK_PARAM_NOT_NULL(src); |
len = strlen(src); |
ptr = my_malloc (len+1); |
if (!ptr) |
error_handler ("out of memory in strdup()"); |
strcpy (ptr, src); |
return ptr; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/malloc.h |
---|
0,0 → 1,38 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: malloc |
* Author name: Zach Smith |
* Create date: 1 Aug 2001 |
* Purpose: Definitions for memory management. |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
extern char * my_malloc (unsigned long); |
extern void my_free (char*); |
extern unsigned long total_malloced (void); |
extern char * my_strdup (char*); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/output.c |
---|
0,0 → 1,400 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: output |
* Author name: Zach Smith |
* Create date: 18 Sep 01 |
* Purpose: Generalized output module |
*---------------------------------------------------------------------- |
* Changes: |
* 22 Sep 01, tuorfa@yahoo.com: addition of functions to change font size |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "malloc.h" |
#include "defs.h" |
#include "error.h" |
#include "output.h" |
#include "main.h" |
#include "convert.h" |
/*======================================================================== |
* Name: op_create |
* Purpose: Creates a blank output personality. |
* Args: None. |
* Returns: Output personality struct. |
*=======================================================================*/ |
OutputPersonality* |
op_create () |
{ |
OutputPersonality* new_op; |
new_op = (OutputPersonality*) my_malloc (sizeof(OutputPersonality)); |
if (!new_op) |
error_handler ("cannot allocate output personality"); |
bzero ((void*) new_op, sizeof (OutputPersonality)); |
return new_op; |
} |
/*======================================================================== |
* Name: op_free |
* Purpose: Deallocates an output personality, but none of the strings |
* it points to since they are usually constants. |
* Args: OutputPersonality. |
* Returns: None. |
*=======================================================================*/ |
void |
op_free (OutputPersonality *op) |
{ |
CHECK_PARAM_NOT_NULL(op); |
my_free ((void*) op); |
} |
/*======================================================================== |
* Name: op_translate_char |
* Purpose: Performs a translation of a character in the context of |
* a given output personality. |
* Args: OutputPersonality, character set#, character. |
* Returns: String. |
*=======================================================================*/ |
char * |
op_translate_char (OutputPersonality *op, int charset, int ch) |
{ |
short start; |
char *result=NULL; |
CHECK_PARAM_NOT_NULL(op); |
if (ch >= 0x20 && ch < 0x80) { |
result = op->ascii_translation_table [ch - 0x20]; |
} |
else |
if (charset != CHARSET_ANSI && |
charset != CHARSET_MAC && |
charset != CHARSET_CP437 && |
charset != CHARSET_CP850) |
error_handler ("invalid character set value, cannot translate character"); |
else |
switch (charset) { |
case CHARSET_ANSI: |
start = op->ansi_first_char; |
if (ch >= start && |
ch <= op->ansi_last_char) |
result = op->ansi_translation_table [ch-start]; |
break; |
case CHARSET_MAC: |
start = op->mac_first_char; |
if (ch >= start && |
ch <= op->mac_last_char) |
result = op->mac_translation_table [ch-start]; |
break; |
case CHARSET_CP437: |
start = op->cp437_first_char; |
if (ch >= start && |
ch <= op->cp437_last_char) |
result = op->cp437_translation_table [ch-start]; |
break; |
case CHARSET_CP850: |
start = op->cp850_first_char; |
if (ch >= start && |
ch <= op->cp850_last_char) |
result = op->cp850_translation_table [ch-start]; |
break; |
} |
return result; |
} |
/*======================================================================== |
* Name: op_begin_std_fontsize |
* Purpose: Prints whatever is necessary to perform a change in the |
* current font size. |
* Args: OutputPersonality, desired size. |
* Returns: None. |
*=======================================================================*/ |
void |
op_begin_std_fontsize (OutputPersonality *op, int size) |
{ |
int found_std_expr = FALSE; |
CHECK_PARAM_NOT_NULL(op); |
/* Look for an exact match with a standard point size. |
*/ |
switch (size) { |
case 8: |
if (op->fontsize8_begin) { |
printf (op->fontsize8_begin); |
found_std_expr = TRUE; |
} |
break; |
case 10: |
if (op->fontsize10_begin) { |
printf (op->fontsize10_begin); |
found_std_expr = TRUE; |
} |
break; |
case 12: |
if (op->fontsize12_begin) { |
printf (op->fontsize12_begin); |
found_std_expr = TRUE; |
} |
break; |
case 14: |
if (op->fontsize14_begin) { |
printf (op->fontsize14_begin); |
found_std_expr = TRUE; |
} |
break; |
case 18: |
if (op->fontsize18_begin) { |
printf (op->fontsize18_begin); |
found_std_expr = TRUE; |
} |
break; |
case 24: |
if (op->fontsize24_begin) { |
printf (op->fontsize24_begin); |
found_std_expr = TRUE; |
} |
break; |
case 36: |
if (op->fontsize36_begin) { |
printf (op->fontsize36_begin); |
found_std_expr = TRUE; |
} |
break; |
case 48: |
if (op->fontsize48_begin) { |
printf (op->fontsize48_begin); |
found_std_expr = TRUE; |
} |
break; |
} |
/* If no exact match, try to write out a change to the |
* exact point size. |
*/ |
if (!found_std_expr) { |
if (op->fontsize_begin) { |
char expr[16]; |
sprintf (expr, "%d", size); |
printf (op->fontsize_begin, expr); |
} else { |
/* If we cannot write out a change for the exact |
* point size, we must approximate to a standard |
* size. |
*/ |
if (size<9 && op->fontsize8_begin) { |
printf (op->fontsize8_begin); |
} else |
if (size<11 && op->fontsize10_begin) { |
printf (op->fontsize10_begin); |
} else |
if (size<13 && op->fontsize12_begin) { |
printf (op->fontsize12_begin); |
} else |
if (size<16 && op->fontsize14_begin) { |
printf (op->fontsize14_begin); |
} else |
if (size<21 && op->fontsize18_begin) { |
printf (op->fontsize18_begin); |
} else |
if (size<30 && op->fontsize24_begin) { |
printf (op->fontsize24_begin); |
} else |
if (size<42 && op->fontsize36_begin) { |
printf (op->fontsize36_begin); |
} else |
if (size>40 && op->fontsize48_begin) { |
printf (op->fontsize48_begin); |
} else |
/* If we can't even produce a good approximation, |
* just try to get a font size near 12 point. |
*/ |
if (op->fontsize12_begin) |
printf (op->fontsize12_begin); |
else |
if (op->fontsize14_begin) |
printf (op->fontsize14_begin); |
else |
if (op->fontsize10_begin) |
printf (op->fontsize10_begin); |
else |
if (op->fontsize18_begin) |
printf (op->fontsize18_begin); |
else |
if (op->fontsize8_begin) |
printf (op->fontsize8_begin); |
else |
error_handler ("output personality lacks sufficient font size change capability"); |
} |
} |
} |
/*======================================================================== |
* Name: op_end_std_fontsize |
* Purpose: Prints whatever is necessary to perform a change in the |
* current font size. |
* Args: OutputPersonality, desired size. |
* Returns: None. |
*=======================================================================*/ |
void |
op_end_std_fontsize (OutputPersonality *op, int size) |
{ |
int found_std_expr = FALSE; |
CHECK_PARAM_NOT_NULL(op); |
/* Look for an exact match with a standard point size. |
*/ |
switch (size) { |
case 8: |
if (op->fontsize8_end) { |
printf (op->fontsize8_end); |
found_std_expr = TRUE; |
} |
break; |
case 10: |
if (op->fontsize10_end) { |
printf (op->fontsize10_end); |
found_std_expr = TRUE; |
} |
break; |
case 12: |
if (op->fontsize12_end) { |
printf (op->fontsize12_end); |
found_std_expr = TRUE; |
} |
break; |
case 14: |
if (op->fontsize14_end) { |
printf (op->fontsize14_end); |
found_std_expr = TRUE; |
} |
break; |
case 18: |
if (op->fontsize18_end) { |
printf (op->fontsize18_end); |
found_std_expr = TRUE; |
} |
break; |
case 24: |
if (op->fontsize24_end) { |
printf (op->fontsize24_end); |
found_std_expr = TRUE; |
} |
break; |
case 36: |
if (op->fontsize36_end) { |
printf (op->fontsize36_end); |
found_std_expr = TRUE; |
} |
break; |
case 48: |
if (op->fontsize48_end) { |
printf (op->fontsize48_end); |
found_std_expr = TRUE; |
} |
break; |
} |
/* If no exact match, try to write out a change to the |
* exact point size. |
*/ |
if (!found_std_expr) { |
if (op->fontsize_end) { |
char expr[16]; |
sprintf (expr, "%d", size); |
printf (op->fontsize_end, expr); |
} else { |
/* If we cannot write out a change for the exact |
* point size, we must approximate to a standard |
* size. |
*/ |
if (size<9 && op->fontsize8_end) { |
printf (op->fontsize8_end); |
} else |
if (size<11 && op->fontsize10_end) { |
printf (op->fontsize10_end); |
} else |
if (size<13 && op->fontsize12_end) { |
printf (op->fontsize12_end); |
} else |
if (size<16 && op->fontsize14_end) { |
printf (op->fontsize14_end); |
} else |
if (size<21 && op->fontsize18_end) { |
printf (op->fontsize18_end); |
} else |
if (size<30 && op->fontsize24_end) { |
printf (op->fontsize24_end); |
} else |
if (size<42 && op->fontsize36_end) { |
printf (op->fontsize36_end); |
} else |
if (size>40 && op->fontsize48_end) { |
printf (op->fontsize48_end); |
} else |
/* If we can't even produce a good approximation, |
* just try to get a font size near 12 point. |
*/ |
if (op->fontsize12_end) |
printf (op->fontsize12_end); |
else |
if (op->fontsize14_end) |
printf (op->fontsize14_end); |
else |
if (op->fontsize10_end) |
printf (op->fontsize10_end); |
else |
if (op->fontsize18_end) |
printf (op->fontsize18_end); |
else |
if (op->fontsize8_end) |
printf (op->fontsize8_end); |
else |
error_handler ("output personality lacks sufficient font size change capability"); |
} |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/output.h |
---|
0,0 → 1,258 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: output |
* Author name: Zach Smith |
* Create date: 18 Sep 01 |
* Purpose: Definitions for the generalized output module |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _OUTPUT |
typedef struct { |
char *comment_begin; |
char *comment_end; |
char *document_begin; |
char *document_end; |
char *header_begin; |
char *header_end; |
char *document_title_begin; |
char *document_title_end; |
char *document_keywords_begin; |
char *document_keywords_end; |
char *document_author_begin; |
char *document_author_end; |
char *document_changedate_begin; |
char *document_changedate_end; |
char *body_begin; |
char *body_end; |
char *word_begin; |
char *word_end; |
char *paragraph_begin; |
char *paragraph_end; |
char *center_begin; |
char *center_end; |
char *align_left_begin; |
char *align_left_end; |
char *align_right_begin; |
char *align_right_end; |
char *justify_begin; |
char *justify_end; |
char *forced_space; |
char *line_break; |
char *page_break; |
char *hyperlink_begin; |
char *hyperlink_end; |
char *imagelink_begin; |
char *imagelink_end; |
char *table_begin; |
char *table_end; |
char *table_row_begin; |
char *table_row_end; |
char *table_cell_begin; |
char *table_cell_end; |
/* Character attributes */ |
char *font_begin; |
char *font_end; |
char *fontsize_begin; |
char *fontsize_end; |
/* standard font sizes are optional */ |
char *fontsize8_begin; |
char *fontsize8_end; |
char *fontsize10_begin; |
char *fontsize10_end; |
char *fontsize12_begin; |
char *fontsize12_end; |
char *fontsize14_begin; |
char *fontsize14_end; |
char *fontsize18_begin; |
char *fontsize18_end; |
char *fontsize24_begin; |
char *fontsize24_end; |
char *fontsize36_begin; |
char *fontsize36_end; |
char *fontsize48_begin; |
char *fontsize48_end; |
char *smaller_begin; |
char *smaller_end; |
char *bigger_begin; |
char *bigger_end; |
char *foreground_begin; |
char *foreground_end; |
char *background_begin; |
char *background_end; |
char *bold_begin; |
char *bold_end; |
char *italic_begin; |
char *italic_end; |
char *underline_begin; |
char *underline_end; |
char *dbl_underline_begin; |
char *dbl_underline_end; |
char *superscript_begin; |
char *superscript_end; |
char *subscript_begin; |
char *subscript_end; |
char *strikethru_begin; |
char *strikethru_end; |
char *dbl_strikethru_begin; |
char *dbl_strikethru_end; |
char *emboss_begin; |
char *emboss_end; |
char *engrave_begin; |
char *engrave_end; |
char *shadow_begin; |
char *shadow_end; |
char *outline_begin; |
char *outline_end; |
char *small_caps_begin; |
char *small_caps_end; |
char *pointlist_begin; |
char *pointlist_end; |
char *pointlist_item_begin; |
char *pointlist_item_end; |
char *numericlist_begin; |
char *numericlist_end; |
char *numericlist_item_begin; |
char *numericlist_item_end; |
char *expand_begin; |
char *expand_end; |
char *toc_entry_begin; |
char *toc_entry_end; |
char *index_entry_begin; |
char *index_entry_end; |
/* XX These should really be replaced by references |
* to one of the charsets. |
*/ |
struct { |
char *bullet; |
char *left_quote; |
char *right_quote; |
char *left_dbl_quote; |
char *right_dbl_quote; |
char *nonbreaking_space; |
char *emdash; |
char *endash; |
char *lessthan; |
char *greaterthan; |
char *amp; |
char *copyright; |
char *trademark; |
char *nonbreaking_hyphen; |
char *optional_hyphen; |
} chars; |
char **ascii_translation_table; |
int simulate_small_caps : 1; |
int simulate_all_caps : 1; |
int simulate_word_underline : 1; |
char **ansi_translation_table; |
short ansi_first_char; |
short ansi_last_char; |
char **cp437_translation_table; |
short cp437_first_char; |
short cp437_last_char; |
char **cp850_translation_table; |
short cp850_first_char; |
short cp850_last_char; |
char **mac_translation_table; |
short mac_first_char; |
short mac_last_char; |
void (*write_set_foreground) (int,int,int); |
} |
OutputPersonality; |
extern OutputPersonality* op_create(void); |
extern void op_free (OutputPersonality*); |
extern char* op_translate_char (OutputPersonality*,int,int); |
extern void op_begin_std_fontsize (OutputPersonality*, int); |
extern void op_end_std_fontsize (OutputPersonality*, int); |
#define _OUTPUT |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/parse.c |
---|
0,0 → 1,444 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: parse |
* Author name: Zach Smith |
* Create date: 01 Sep 00 |
* Purpose: Parsing of the RTF file into a structure of Word objects. |
*---------------------------------------------------------------------- |
* Changes: |
* 15 Oct 00, tuorfa@yahoo.com: parse.c created with functions taken from word.c |
* 15 Oct 00, tuorfa@yahoo.com: backslash before newline is now \par |
* 08 Apr 01, tuorfa@yahoo.com: removed limit on word length |
* 03 Aug 01, tuorfa@yahoo.com: added input buffering |
* 19 Sep 01, tuorfa@yahoo.com: cleaned up read_word() |
* 22 Sep 01, tuorfa@yahoo.com: moved word_dump() to word.c |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <ctype.h> |
#include <string.h> |
#include "defs.h" |
#include "parse.h" |
#include "malloc.h" |
#include "main.h" |
#include "error.h" |
#include "word.h" |
#include "hash.h" |
/* local to getchar stuff */ |
static int ungot_char=-1; |
static int ungot_char2=-1; |
static int ungot_char3=-1; |
/*======================================================================== |
* Name: my_unget_char |
* Purpose: My own unget routine, handling up to 3 ungot characters. |
* Args: Character. |
* Returns: None. |
*=======================================================================*/ |
static void my_unget_char (int ch) |
{ |
if (ungot_char>=0 && ungot_char2>=0 && ungot_char3>=0) |
error_handler ("more than 3 ungot chars"); |
ungot_char3 = ungot_char2; |
ungot_char2 = ungot_char; |
ungot_char = ch; |
} |
static int last_returned_ch=0; |
#define READ_BUF_LEN 2048 |
static int buffer_size = 0; |
static char *read_buf = NULL; |
static int read_buf_end = 0; |
static int read_buf_index = 0; |
/*======================================================================== |
* Name: my_getchar |
* Purpose: Gets a character: either an ungot one, or a buffered one. |
* Args: Input file. |
* Returns: Character, or EOF. |
*=======================================================================*/ |
static int my_getchar (FILE* f) |
{ |
int ch; |
CHECK_PARAM_NOT_NULL(f); |
if (ungot_char>=0) { |
ch = ungot_char; |
ungot_char=ungot_char2; |
ungot_char2=ungot_char3; |
ungot_char3=-1; |
last_returned_ch = ch; |
return ch; |
} |
do { |
if (read_buf_index >= read_buf_end) { |
if (!read_buf) { |
buffer_size = READ_BUF_LEN; |
read_buf = my_malloc (buffer_size); |
if (!read_buf) { |
buffer_size /= 4; |
read_buf = my_malloc (buffer_size); |
if (!read_buf) |
error_handler ("cannot allocate read buffer"); |
} |
} |
read_buf_end = fread (read_buf, 1, buffer_size, f); |
read_buf_index = 0; |
if (!read_buf_end) |
return EOF; |
} |
ch = read_buf [read_buf_index++]; |
if (ch=='\n') { |
lineno++; |
/* Convert \(newline) into \par here */ |
if (last_returned_ch=='\\') { |
my_unget_char (' '); |
my_unget_char ('r'); |
my_unget_char ('a'); |
ch = 'p'; |
break; |
} |
} |
} |
while (ch=='\r' /* || ch=='\n' */ ); |
if (ch=='\t') ch = ' '; |
last_returned_ch = ch; |
return ch; |
} |
/* local to read_word */ |
static char *input_str = NULL; |
static unsigned long current_max_length = 1; |
/*======================================================================== |
* Name: expand_word_buffer |
* Purpose: Expands the buffer used to store an incoming word. |
* This allows us to remove the limit on word length. |
* Args: None. |
* Returns: None. |
*=======================================================================*/ |
static int |
expand_word_buffer () |
{ |
char *new_ptr; |
unsigned long old_length; |
if (!input_str) |
error_handler ("no input buffer allocated"); |
old_length = current_max_length; |
current_max_length *= 2; |
new_ptr = my_malloc (current_max_length); |
if (!new_ptr) |
error_handler ("out of memory while resizing buffer"); |
memcpy (new_ptr, input_str, old_length); |
my_free (input_str); |
input_str = new_ptr; |
return TRUE; |
} |
/*======================================================================== |
* Name: read_word |
* Purpose: The core of the parser, this reads a word. |
* Args: Input file. |
* Returns: Number of characters in the word, or zero. |
* Note: The word buffer is static and local to this file. |
*=======================================================================*/ |
static int |
read_word (FILE *f) |
{ |
int ch, ch2, ix=0; |
int have_whitespace=FALSE; |
int is_control_word=FALSE; |
int has_numeric_param=FALSE; /* if is_control_word==TRUE */ |
int need_unget=FALSE; |
CHECK_PARAM_NOT_NULL(f); |
current_max_length = 10; /* XX */ |
/* Get some storage for a word. |
*/ |
input_str = my_malloc (current_max_length); |
if (!input_str) |
error_handler("cannot allocate word storage"); |
do { |
ch = my_getchar(f); |
} |
while (ch=='\n'); |
if (ch==' ') |
{ |
/* Compress multiple space chars down to one. |
*/ |
while (ch == ' ') { |
ch = my_getchar(f); |
have_whitespace=TRUE; |
} |
if (have_whitespace) { |
my_unget_char (ch); |
input_str[0]=' '; |
input_str[1]=0; |
return 1; |
} |
} |
switch(ch) |
{ |
case EOF: |
return 0; |
case '\\': |
ch2 = my_getchar(f); |
/* Look for two-character command words. |
*/ |
switch (ch2) |
{ |
case '\n': |
strcpy (input_str, "\\par"); |
return 4; |
case '~': |
case '{': |
case '}': |
case '\\': |
case '_': |
case '-': |
input_str[0] = '\\'; |
input_str[1] = ch2; |
input_str[2] = 0; |
return 2; |
case '\'': |
/* Preserve \'## expressions (hex char exprs) for later. |
*/ |
input_str[0]='\\'; |
input_str[1]='\''; |
ix=2; |
if(ix==current_max_length) { |
if (!expand_word_buffer ()) |
error_handler("word too long"); |
} |
ch = my_getchar(f); |
input_str[ix++]=ch; |
if(ix==current_max_length) { |
if (!expand_word_buffer ()) |
error_handler("word too long"); |
} |
ch = my_getchar(f); |
input_str[ix++]=ch; |
if(ix==current_max_length) { |
if (!expand_word_buffer ()) |
error_handler("word too long"); |
} |
input_str[ix]=0; |
return ix; |
} |
is_control_word=TRUE; |
ix=1; |
input_str[0]=ch; |
ch=ch2; |
break; |
case '\t': |
/* In RTF, a tab char is the same as \tab. |
*/ |
strcpy (input_str, "\\tab"); |
return 4; |
case '{': |
case '}': |
case ';': |
input_str[0]=ch; |
input_str[1]=0; |
return 1; |
} |
while (ch!=EOF) |
{ |
/* Several chars always ends a word, and we need to save them. |
*/ |
if (ch=='\t' || ch=='{' || ch=='}' || ch=='\\') { |
need_unget=TRUE; |
break; |
} |
/* A newline always ends a command word; we don't save it. |
* A newline is ignored if this is not a command word. |
*/ |
if (ch=='\n') { |
if (is_control_word) |
break; |
ch = my_getchar(f); |
continue; |
} |
/* A semicolon always ends a command word; we do save it. |
* A semicolon never ends a regular word. |
*/ |
if (ch==';') { |
if (is_control_word) { |
need_unget=TRUE; |
break; |
} |
} |
/* In this parser, a space character terminates |
* any word, and if it does not follow a command, |
* then it is a word in itself. |
*/ |
if (ch==' ') { |
if (!is_control_word) |
need_unget=TRUE; |
break; |
} |
/* Identify a control word's numeric parameter. |
*/ |
if (is_control_word) { |
if (!has_numeric_param && (isdigit(ch) || ch=='-')) |
has_numeric_param = TRUE; |
else |
if (has_numeric_param && !isdigit(ch)) { |
if (ch!=' ') |
need_unget=TRUE; |
break; |
} |
} |
input_str[ix++] = ch; |
if (ix==current_max_length) { |
if (!expand_word_buffer ()) |
error_handler("word too long"); |
} |
ch = my_getchar (f); |
} |
if (need_unget) |
my_unget_char(ch); |
input_str[ix]=0; |
return ix; |
} |
/*======================================================================== |
* Name: word_read |
* Purpose: This is the recursive metareader which pieces together the |
* structure of Word objects. |
* Args: Input file. |
* Returns: Tree of Word objects. |
*=======================================================================*/ |
Word * |
word_read (FILE* f) { |
Word * prev_word = NULL; |
Word * first_word = NULL; |
Word * new_word = NULL; /* temp */ |
CHECK_PARAM_NOT_NULL(f); |
do { |
if (!read_word(f)) { |
return first_word; |
} |
if (input_str[0] == '{') { |
/* Process subwords */ |
#if 0 |
printf ("processing subword...\n"); |
#endif |
/* Create a dummy word to point to a sublist */ |
new_word = word_new (NULL); |
if (!new_word) |
error_handler ("cannot allocate word"); |
/* Get the sublist */ |
new_word->child = word_read (f); |
if (!new_word->hash_index && !new_word->child) |
{ |
/* printf ("unable to read children!\n"); */ |
} |
} else if (input_str[0] == '}') { |
#if 0 |
printf ("returning from word_read.\n"); |
#endif |
return first_word; |
} else { |
new_word = word_new (input_str); |
} |
if (prev_word) prev_word->next = new_word; |
if (!first_word) first_word = new_word; |
prev_word = new_word; |
/* Free up the memory allocated by read_word. |
*/ |
my_free (input_str); |
input_str = NULL; |
} |
while(1); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/parse.h |
---|
0,0 → 1,44 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: parse.h |
* Author name: Zach Smith |
* Create date: 15 Oct 2000 |
* Purpose: Definitions and externs for parse.c. |
*---------------------------------------------------------------------- |
* Changes: |
* 15 Oct 00, tuorfa@yahoo.com: parse.h created with functions taken from word.c |
*--------------------------------------------------------------------*/ |
#ifndef _WORD |
#include "word.h" |
#endif |
extern Word *word_read(FILE*); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/ps.c |
---|
0,0 → 1,610 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: ps |
* Author name: Zach Smith |
* Create date: 18 Sep 01 |
* Purpose: PostScript(TM)-specific output module |
*---------------------------------------------------------------------- |
* Changes: |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
* 23 Sep 01, tuorfa@yahoo.com: added shadow, outline, strikethru, underline |
* 23 Sep 01, tuorfa@yahoo.com: revised PS program to use ISOLatin1Encoding |
* 28 Sep 01, tuorfa@yahoo.com: added support for Helvetica,Courier,Symbol |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "malloc.h" |
#include "defs.h" |
#include "error.h" |
#include "main.h" |
#include "output.h" |
static char* |
ascii [96] = { |
/* 0x20 */ " ", "!", "\"", "#", "$", "\%", "&", "'", |
/* 0x28 */ "\\(", "\\)", "*", "+", ",", "-", ".", "/", |
/* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7", |
/* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?", |
/* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G", |
/* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O", |
/* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W", |
/* 0x58 */ "X", "Y", "Z", "\\[", "\\\\", "\\]", "^", "_", |
/* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g", |
/* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o", |
/* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w", |
/* 0x78 */ "x", "y", "z", "{", "|", "}", "~", "", |
}; |
static char* ansi [] = { |
/* 0x80 */ "\\200","\\201","\\202","\\203", |
/* 0x84 */ "\\204","\\205","\\206","\\207", |
/* 0x88 */ "\\210","\\211","\\212","\\213", |
/* 0x8c */ "\\214","\\215","\\216","\\217", |
/* 0x90 */ "\\220","\\221","\\222","\\223", |
/* 0x94 */ "\\224","\\225","\\226","\\227", |
/* 0x98 */ "\\230","\\231","\\232","\\233", |
/* 0x9c */ "\\234","\\235","\\236","\\237", |
/* 0xa0 */ "\\240","\\241","\\242","\\243", |
/* 0xa4 */ "\\244","\\245","\\246","\\247", |
/* 0xa8 */ "\\250","\\251","\\252","\\253", |
/* 0xac */ "\\254","\\255","\\256","\\257", |
/* 0xb0 */ "\\260","\\261","\\262","\\263", |
/* 0xb4 */ "\\264","\\265","\\266","\\267", |
/* 0xb8 */ "\\270","\\271","\\272","\\273", |
/* 0xbc */ "\\274","\\275","\\276","\\277", |
/* 0xc0 */ "\\300","\\301","\\302","\\303", |
/* 0xc4 */ "\\304","\\305","\\306","\\307", |
/* 0xc8 */ "\\310","\\311","\\312","\\313", |
/* 0xcc */ "\\314","\\315","\\316","\\317", |
/* 0xd0 */ "\\320","\\321","\\322","\\323", |
/* 0xd4 */ "\\324","\\325","\\326","\\327", |
/* 0xd8 */ "\\330","\\331","\\332","\\333", |
/* 0xdc */ "\\334","\\335","\\336","\\337", |
/* 0xe0 */ "\\340","\\341","\\342","\\343", |
/* 0xe4 */ "\\344","\\345","\\346","\\347", |
/* 0xe8 */ "\\350","\\351","\\352","\\353", |
/* 0xec */ "\\354","\\355","\\356","\\357", |
/* 0xf0 */ "\\360","\\361","\\362","\\363", |
/* 0xf4 */ "\\364","\\365","\\366","\\367", |
/* 0xf8 */ "\\370","\\371","\\372","\\373", |
/* 0xfc */ "\\374","\\375","\\376","\\377", |
}; |
static char* mac [] = { |
"?", |
}; |
static char* cp437 [] = { |
"?", |
}; |
static char* cp850 [] = { |
"?", |
}; |
#define PS_END "\ |
%% --------- \n\n\ |
didShowPage not { \n\ |
showpage \n\ |
} if\n\n\ |
%%%%EOF\n" |
#define PS_START "\ |
%%%%!PS\n\ |
%%--------------------------------------------------------------------------\n\ |
%% GNU UnRTF, a command-line program to convert RTF documents to other formats.\n\ |
%% Copyright (C) 2000,2001 Zachary Thayer Smith\n\ |
%%\n\ |
%% This program is free software; you can redistribute it and/or modify\n\ |
%% it under the terms of the GNU General Public License as published by\n\ |
%% the Free Software Foundation; either version 2 of the License, or\n\ |
%% (at your option) any later version.\n\ |
%%\n\ |
%% This program is distributed in the hope that it will be useful,\n\ |
%% but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ |
%% GNU General Public License for more details.\n\ |
%%\n\ |
%% You should have received a copy of the GNU General Public License\n\ |
%% along with this program; if not, write to the Free Software\n\ |
%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\ |
%%\n\ |
%% The author is reachable by electronic mail at tuorfa@yahoo.com.\n\ |
%%--------------------------------------------------------------------------\n\ |
%%%%EndComments \n\ |
%%\n\ |
%% --------- Note, this PS code is unfinished -------- \n\ |
%% --------- Note, this PS code is unfinished -------- \n\ |
%% --------- Note, this PS code is unfinished -------- \n\ |
%% --------- Note, this PS code is unfinished -------- \n\ |
%% --------- Note, this PS code is unfinished -------- \n\ |
%%\n\ |
%% ----------- Variables ------------\n\ |
/fontFamily /Times def\n\ |
/fontAscent 0 def %% ascent for current font\n\ |
/fontDescent 0 def %% descent for current font\n\ |
/lineAscent 0 def \n\ |
/lineDescent 0 def \n\ |
/pageWidthInches 8.5 def \n\ |
/pageHeightInches 11 def \n\ |
/leftMargin 20 def \n\ |
/rightMargin 20 def \n\ |
/topMargin 20 def \n\ |
/bottomMargin 20 def \n\ |
/DPI 72 def \n\ |
/pageWidth pageWidthInches DPI mul def \n\ |
/rightLimit pageWidth rightMargin sub def \n\ |
/pageHeight pageHeightInches DPI mul def \n\ |
/x 0 def \n\ |
/y 0 def \n\ |
/bold false def \n\ |
/italic false def \n\ |
/underline false def \n\ |
/overline false def \n\ |
/intercharSpace 0 def \n\ |
/strike false def \n\ |
/outline false def \n\ |
/shadow false def \n\ |
/fontSize 12 def \n\ |
/didBR false def \n\ |
/didParSkip false def \n\ |
/didShowPage false def \n\ |
%%------------------------------------------------------\n\ |
%% Set up the ISO fonts \n\ |
%% Times \n\ |
%% ----- \n\ |
/Times-Roman findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/TRomanISO exch definefont pop \n\ |
/Times-Bold findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/TBoldISO exch definefont pop \n\ |
/Times-BoldItalic findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/TBoldItalicISO exch definefont pop \n\ |
/Times-Italic findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/TItalicISO exch definefont pop \n\ |
%% Courier \n\ |
%% ----- \n\ |
/Courier-Roman findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/CRomanISO exch definefont pop \n\ |
/Courier-Bold findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/CBoldISO exch definefont pop \n\ |
/Courier-BoldItalic findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/CBoldItalicISO exch definefont pop \n\ |
/Courier-Italic findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/CItalicISO exch definefont pop \n\ |
%% Symbol \n\ |
%% ----- \n\ |
/Symbol-Roman findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/SRomanISO exch definefont pop \n\ |
/Symbol-Bold findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/SBoldISO exch definefont pop \n\ |
/Symbol-BoldItalic findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/SBoldItalicISO exch definefont pop \n\ |
/Symbol-Italic findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/SItalicISO exch definefont pop \n\ |
%% Helvetica \n\ |
%% --------- \n\ |
/Helvetica-Roman findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/HRomanISO exch definefont pop \n\ |
/Helvetica-Bold findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/HBoldISO exch definefont pop \n\ |
/Helvetica-BoldOblique findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/HBoldItalicISO exch definefont pop \n\ |
/Helvetica-Oblique findfont dup length dict begin { \n\ |
1 index /FID ne { def } { pop pop } ifelse \n\ |
} forall \n\ |
/Encoding ISOLatin1Encoding def \n\ |
currentdict end \n\ |
/HItalicISO exch definefont pop \n\ |
%% \n\ |
%% Ideally, before we can draw a line of text, we need to collect all the\n\ |
%% words that will be on it, just as I do in my Beest HTML viewer, as well\n\ |
%% as character attributes for each word. But for now, this implementation \n\ |
%% does not bother. It determines the maximize ascent and descent after\n\ |
%% drawing the text, not before. XX\n\ |
%% \n\ |
%% ----------- Functions ------------\n\ |
/updateFont { \n\ |
/f0 null def \n\ |
(Times) fontFamily eq (Times New Roman) fontFamily eq or { bold { \n\ |
italic { /TBoldItalicISO } { /TBoldISO } ifelse \n\ |
} { \n\ |
italic { /TItalicISO } { /TRomanISO } ifelse \n\ |
} \n\ |
ifelse \n\ |
} if (Helvetica) fontFamily eq (Arial) fontFamily eq or { bold { \n\ |
italic { /HBoldItalicISO } { /HBoldISO } ifelse \n\ |
} { \n\ |
italic { /HItalicISO } { /HRomanISO } ifelse \n\ |
} \n\ |
ifelse \n\ |
} if (Courier) fontFamily eq (Courier New) fontFamily eq or { bold { \n\ |
italic { /CBoldItalicISO } { /CBoldISO } ifelse \n\ |
} { \n\ |
italic { /CItalicISO } { /CRomanISO } ifelse \n\ |
} \n\ |
ifelse \n\ |
} if (Symbol) fontFamily eq { bold { \n\ |
italic { /SBoldItalicISO } { /SBoldISO } ifelse \n\ |
} { \n\ |
italic { /SItalicISO } { /SRomanISO } ifelse \n\ |
} \n\ |
ifelse \n\ |
} if findfont /f0 exch def \n\ |
/bboxBottom f0 /FontBBox get 1 get 1000 div fontSize mul -1 mul def \n\ |
/bboxTop f0 /FontBBox get 3 get 1000 div fontSize mul def \n\ |
f0 fontSize scalefont setfont \n\ |
lineAscent bboxTop lt { /lineAscent bboxTop def } if \n\ |
lineDescent bboxBottom lt { /lineDescent bboxBottom def } if \n\ |
/fontAscent bboxTop def \n\ |
/fontDescent bboxBottom def \n\ |
} def\n\ |
/FS { \n\ |
/fontSize exch def updateFont \n\ |
} def \n\ |
/F { \n\ |
/fontFamily exch def updateFont \n\ |
} def \n\ |
/resetX { \n\ |
/x leftMargin def\n\ |
} def \n\ |
/resetY { \n\ |
/y pageHeight topMargin sub def \n\ |
} def \n\ |
/BR { \n\ |
/oldx x def \n\ |
/y y lineAscent lineDescent add sub def \n\ |
resetX \n\ |
y bottomMargin lt { \n\ |
showpage \n\ |
/didShowPage true \n\ |
resetY \n\ |
} if \n\ |
oldx 0 eq didBR and { /didParSkip true def } if \n\ |
/didBR true def \n\ |
% /lineAscent 0 def \n\ |
% /lineDescent 0 def \n\ |
} def \n\ |
/P { \n\ |
didParSkip not { BR } if \n\ |
didParSkip not { BR } if \n\ |
} \n\ |
def \n\ |
/acharpath { \n\ |
/acstr exch def pop /acsp exch def newpath str { /ch exch def 1 string 0 ch put false charpath acsp 0 rmoveto } forall} def \n\ |
/A { \n\ |
/str exch def \n\ |
/w str stringwidth pop \n\ |
str length intercharSpace mul add \n\ |
def \n\ |
x w add rightLimit ge { BR } if \n\ |
x y moveto \n\ |
outline { \n\ |
shadow { \n\ |
1 -0.1 0 { \n\ |
/offset exch def \n\ |
offset setgray \n\ |
x offset 3 mul add y offset 3 mul sub moveto intercharSpace 0 str acharpath \n\ |
%% str false charpath \n\ |
fontSize 30 div setlinewidth stroke \n\ |
} for \n\ |
0 setgray \n\ |
} { \n\ |
intercharSpace 0 str acharpath \n\ |
%% str false charpath \n\ |
fontSize 30 div setlinewidth stroke \n\ |
} ifelse \n\ |
} { \n\ |
shadow { \n\ |
1 -0.1 0 { \n\ |
/offset exch def \n\ |
offset setgray \n\ |
x offset 3 mul add y offset 3 mul sub moveto intercharSpace 0 str ashow \n\ |
%% str show \n\ |
} for \n\ |
0 setgray } { \n\ |
intercharSpace 0 str ashow \n\ |
%% str show \n\ |
} ifelse \n\ |
} ifelse \n\ |
strike { \n\ |
newpath fontSize 20 div setlinewidth \n\ |
x y fontAscent 0.32 mul add dup /y2 exch def moveto \n\ |
x w add y2 lineto stroke \n\ |
} if \n\ |
underline { \n\ |
newpath fontSize 20 div setlinewidth \n\ |
x y fontAscent 0.2 mul sub dup /y2 exch def moveto \n\ |
x w add y2 lineto stroke \n\ |
} if \n\ |
overline { \n\ |
%% I don't think RTF supports this, but it can be used later. \n\ |
newpath fontSize 20 div setlinewidth \n\ |
x y fontAscent 1.2 mul add dup /y2 exch def moveto \n\ |
x w add y2 lineto stroke \n\ |
} if \n\ |
/x x w add def \n\ |
/didBR false def \n\ |
/didShowPage false def \n\ |
} def \n\ |
\n\ |
%% These are only binary for now \n\ |
/X1 { /intercharSpace exch def } def\n\ |
/X0 { /intercharSpace 0 def } def\n\ |
/O1 { /outline false def } def\n\ |
/O0 { /outline false def } def\n\ |
/H1 { /shadow true def } def\n\ |
/H0 { /shadow false def } def\n\ |
/S1 { /strike true def } def\n\ |
/S0 { /strike false def } def\n\ |
/B1 { /bold true def updateFont } def\n\ |
/B0 { /bold false def updateFont } def\n\ |
/I1 { /italic true def updateFont } def\n\ |
/I0 { /italic false def updateFont } def\n\ |
/U1 { /underline true def } def\n\ |
/U0 { /underline false def } def\n\ |
updateFont \n\ |
resetX resetY \n\ |
\n\ |
" |
/*======================================================================== |
* Name: ps_init |
* Purpose: Generates an OutputPersonality object for the PostScript(TM) |
* format. |
* Args: None. |
* Returns: OutputPersonality. |
*=======================================================================*/ |
OutputPersonality * |
ps_init (void) |
{ |
OutputPersonality* op; |
op = op_create(); |
op->comment_begin = "%% "; |
op->comment_end = "\n"; |
op->word_begin = "("; |
op->word_end = ")A "; |
op->document_begin = PS_START; |
op->document_end = PS_END; |
op->header_begin = "%% header begin\n"; |
op->header_end = "%% header end\n"; |
op->document_title_begin = "%%%%Title: "; |
op->document_title_end = "\n"; |
op->document_author_begin = "%%%%Creator: "; |
op->document_author_end = "\n"; |
op->document_changedate_begin = "%% CHANGED: "; |
op->document_changedate_end = "\n"; |
op->body_begin = "\n\n%% ---------- Document Body ------------\n"; |
op->body_end = "\n"; |
op->paragraph_begin = "P "; |
op->paragraph_end = "\n"; |
op->center_begin = ""; |
op->center_end = ""; |
op->justify_begin = ""; |
op->justify_end = ""; |
op->align_left_begin = ""; |
op->align_left_end = ""; |
op->align_right_begin = ""; |
op->align_right_end = ""; |
op->forced_space = " "; |
op->line_break = "BR\n"; |
op->page_break = "\n"; |
op->hyperlink_begin = "U1("; |
op->hyperlink_end = ")A U0 "; |
op->imagelink_begin = ""; |
op->imagelink_end = ""; |
op->table_begin = "\n% TABLE BEGINS (not implemented)\nP\n(TABLE)A BR\n"; |
op->table_end = "\n% TABLE ENDS (not implemented)\nP\n"; |
op->table_row_begin = "( )A "; |
op->table_row_end = "( |)A BR\n"; |
op->table_cell_begin = "( | )A "; |
op->table_cell_end = ""; |
/* Character attributes */ |
op->font_begin = "(%s) F "; |
op->font_end = ""; |
op->fontsize_begin = "%s FS "; |
op->fontsize_end = ""; |
op->smaller_begin = ""; |
op->smaller_end = ""; |
op->bigger_begin = ""; |
op->bigger_end = ""; |
op->foreground_begin = ""; |
op->foreground_end = ""; |
op->background_begin = ""; |
op->background_end = ""; |
op->bold_begin = "B1 "; |
op->bold_end = "B0 "; |
op->italic_begin = "I1 "; |
op->italic_end = "I0 "; |
op->underline_begin = "U1 "; |
op->underline_end = "U0 "; |
op->dbl_underline_begin = "U1 "; |
op->dbl_underline_end = "U0 "; |
op->superscript_begin = ""; |
op->superscript_end = ""; |
op->subscript_begin = ""; |
op->subscript_end = ""; |
op->strikethru_begin = "S1 "; |
op->strikethru_end = "S0 "; |
op->dbl_strikethru_begin = "S1 "; |
op->dbl_strikethru_end = "S0 "; |
op->emboss_begin=""; |
op->emboss_end = ""; |
op->engrave_begin = ""; |
op->engrave_end = ""; |
op->shadow_begin= "H1 "; |
op->shadow_end= "H0 "; |
op->outline_begin= "O1 "; |
op->outline_end= "O0 "; |
op->expand_begin = "%s X1 "; |
op->expand_end = "X0 "; |
op->simulate_small_caps = TRUE; |
op->simulate_all_caps = TRUE; |
op->simulate_word_underline = TRUE; |
op->ascii_translation_table = ascii; |
op->ansi_translation_table = ansi; |
op->ansi_first_char = 0x80; |
op->ansi_last_char = 0xff; |
op->cp437_translation_table = cp437; |
op->cp437_first_char = 0x80; |
op->cp437_last_char = 0x80; |
op->cp850_translation_table = cp850; |
op->cp850_first_char = 0x80; |
op->cp850_last_char = 0x80; |
op->mac_translation_table = mac; |
op->mac_first_char = 0x80; |
op->mac_last_char = 0x80; |
op->chars.right_quote = "'"; |
op->chars.left_quote = "`"; |
op->chars.right_dbl_quote = "''"; |
op->chars.left_dbl_quote = "``"; |
return op; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/ps.h |
---|
0,0 → 1,42 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: ps |
* Author name: Zach Smith |
* Create date: 19 Sep 01 |
* Purpose: Definitions for the PostScript(TM) output personality |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _PS |
extern OutputPersonality* ps_init(void); |
#define _PS |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/text.c |
---|
0,0 → 1,262 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: text |
* Author name: Zach Smith |
* Create date: 19 Sep 01 |
* Purpose: Plain text output module |
*---------------------------------------------------------------------- |
* Changes: |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "malloc.h" |
#include "defs.h" |
#include "error.h" |
#include "main.h" |
#include "output.h" |
static char* |
ascii_translation_table [96] = { |
/* 0x20 */ " ", "!", "\"", "#", "$", "%", "&", "'", |
/* 0x28 */ "(", ")", "*", "+", ",", "-", ".", "/", |
/* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7", |
/* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?", |
/* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G", |
/* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O", |
/* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W", |
/* 0x58 */ "X", "Y", "Z", "[", "\\", "]", "^", "_", |
/* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g", |
/* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o", |
/* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w", |
/* 0x78 */ "x", "y", "z", "{", "|", "}", "~", "", |
}; |
static char* |
upper_translation_table [128] = { |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
}; |
/*======================================================================== |
* Name: text_init |
* Purpose: Generates an output personality for the plain text format. |
* Args: None. |
* Returns: OutputPersonality. |
*=======================================================================*/ |
OutputPersonality * |
text_init (void) |
{ |
OutputPersonality* text_op; |
text_op = op_create(); |
text_op->comment_begin = "### "; |
text_op->comment_end = "\n"; |
text_op->document_begin = ""; |
text_op->document_end = ""; |
text_op->header_begin = ""; |
text_op->header_end = ""; |
text_op->document_title_begin = "\nTITLE: "; |
text_op->document_title_end = "\n"; |
text_op->document_author_begin = "\nAUTHOR: "; |
text_op->document_author_end = "\n"; |
text_op->document_changedate_begin = "\nDATE: "; |
text_op->document_changedate_end = "\n"; |
text_op->body_begin = "\n-----------------\n"; |
text_op->body_end = ""; |
text_op->paragraph_begin = ""; |
text_op->paragraph_end = "\n"; |
text_op->center_begin = ""; |
text_op->center_end = ""; |
text_op->justify_begin = ""; |
text_op->justify_end = ""; |
text_op->align_left_begin = ""; |
text_op->align_left_end = ""; |
text_op->align_right_begin = ""; |
text_op->align_right_end = ""; |
text_op->forced_space = " "; |
text_op->line_break = "\n"; |
text_op->page_break = "\n"; |
text_op->hyperlink_begin = ""; |
text_op->hyperlink_end = ""; |
text_op->imagelink_begin = ""; |
text_op->imagelink_end = ""; |
text_op->table_begin = "\n"; |
text_op->table_end = "\n"; |
text_op->table_row_begin = ""; |
text_op->table_row_end = "\n"; |
text_op->table_cell_begin = "\t"; |
text_op->table_cell_end = ""; |
/* Character attributes */ |
text_op->font_begin = ""; |
text_op->font_end = ""; |
text_op->fontsize_begin = ""; |
text_op->fontsize_end = ""; |
text_op->fontsize8_begin = ""; |
text_op->fontsize8_end = ""; |
text_op->fontsize10_begin = ""; |
text_op->fontsize10_end = ""; |
text_op->fontsize12_begin = ""; |
text_op->fontsize12_end = ""; |
text_op->fontsize14_begin = ""; |
text_op->fontsize14_end = ""; |
text_op->fontsize18_begin = ""; |
text_op->fontsize18_end = ""; |
text_op->fontsize24_begin = ""; |
text_op->fontsize24_end = ""; |
text_op->smaller_begin = ""; |
text_op->smaller_end = ""; |
text_op->bigger_begin = ""; |
text_op->bigger_end = ""; |
text_op->foreground_begin = ""; |
text_op->foreground_end = ""; |
text_op->background_begin = ""; |
text_op->background_end = ""; |
text_op->bold_begin = ""; |
text_op->bold_end = ""; |
text_op->italic_begin = ""; |
text_op->italic_end = ""; |
text_op->underline_begin = ""; |
text_op->underline_end = ""; |
text_op->dbl_underline_begin = ""; |
text_op->dbl_underline_end = ""; |
text_op->superscript_begin = ""; |
text_op->superscript_end = ""; |
text_op->subscript_begin = ""; |
text_op->subscript_end = ""; |
text_op->strikethru_begin = ""; |
text_op->strikethru_end = ""; |
text_op->dbl_strikethru_begin = ""; |
text_op->dbl_strikethru_end = ""; |
text_op->emboss_begin=""; |
text_op->emboss_end = ""; |
text_op->engrave_begin = ""; |
text_op->engrave_end = ""; |
text_op->shadow_begin= ""; |
text_op->shadow_end= ""; |
text_op->outline_begin= ""; |
text_op->outline_end= ""; |
text_op->expand_begin = ""; |
text_op->expand_end = ""; |
text_op->pointlist_begin = "\n"; |
text_op->pointlist_end = "\n"; |
text_op->pointlist_item_begin = " * "; |
text_op->pointlist_item_end = "\n"; |
text_op->numericlist_begin = "\n"; |
text_op->numericlist_end = "\n"; |
text_op->numericlist_item_begin = " # "; |
text_op->numericlist_item_end = "\n"; |
text_op->simulate_small_caps = TRUE; |
text_op->simulate_all_caps = TRUE; |
text_op->simulate_word_underline = TRUE; |
text_op->ascii_translation_table = ascii_translation_table; |
text_op->ansi_translation_table = upper_translation_table; |
text_op->ansi_first_char = 0x80; |
text_op->ansi_last_char = 0xff; |
text_op->cp437_translation_table = upper_translation_table; |
text_op->cp437_first_char = 0x80; |
text_op->cp437_last_char = 0xff; |
text_op->cp850_translation_table = upper_translation_table; |
text_op->cp850_first_char = 0x80; |
text_op->cp850_last_char = 0xff; |
text_op->mac_translation_table = upper_translation_table; |
text_op->mac_first_char = 0x80; |
text_op->mac_last_char = 0xff; |
text_op->chars.right_quote = "'"; |
text_op->chars.left_quote = "`"; |
text_op->chars.right_dbl_quote = "''"; |
text_op->chars.left_dbl_quote = "``"; |
return text_op; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/text.h |
---|
0,0 → 1,42 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: text |
* Author name: Zach Smith |
* Create date: 19 Sep 01 |
* Purpose: Definitions for the plain text output personality |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _TEXT |
extern OutputPersonality* text_init(void); |
#define _TEXT |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/util.c |
---|
0,0 → 1,64 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: util |
* Author name: Zach Smith |
* Create date: 01 Aug 01 |
* Purpose: Utility functions. |
*---------------------------------------------------------------------- |
* Changes: |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdlib.h> |
#include <ctype.h> |
/*======================================================================== |
* Name: h2toi |
* Purpose: Converts a 2-digit hexadecimal value to an unsigned integer. |
* Args: String. |
* Returns: Integer. |
*=======================================================================*/ |
/* Convert a two-char hexadecimal expression to an integer */ |
int |
h2toi (char *s) { |
int tmp; |
int ch; |
tmp = tolower(*s++); |
if (tmp>'9') tmp-=('a'-10); |
else tmp-='0'; |
ch=16*tmp; |
tmp = tolower(*s++); |
if (tmp>'9') tmp-=('a'-10); |
else tmp-='0'; |
ch+=tmp; |
return ch; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/util.h |
---|
0,0 → 1,34 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: util |
* Author name: Zach Smith |
* Create date: 1 Aug 2001 |
* Purpose: Definitions for util module. |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
extern int h2toi (char *); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/vt.c |
---|
0,0 → 1,262 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: vt |
* Author name: Zach Smith |
* Create date: 19 Sep 01 |
* Purpose: text output with VT100 escape codes module |
*---------------------------------------------------------------------- |
* Changes: |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "malloc.h" |
#include "defs.h" |
#include "error.h" |
#include "main.h" |
#include "output.h" |
static char* |
ascii_translation_table [96] = { |
/* 0x20 */ " ", "!", "\"", "#", "$", "%", "&", "'", |
/* 0x28 */ "(", ")", "*", "+", ",", "-", ".", "/", |
/* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7", |
/* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?", |
/* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G", |
/* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O", |
/* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W", |
/* 0x58 */ "X", "Y", "Z", "[", "\\", "]", "^", "_", |
/* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g", |
/* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o", |
/* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w", |
/* 0x78 */ "x", "y", "z", "{", "|", "}", "~", "", |
}; |
static char* |
upper_translation_table [128] = { |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
}; |
/*======================================================================== |
* Name: vt_init |
* Purpose: Generates an output personality for the VT100 text format. |
* Args: None. |
* Returns: OutputPersonality. |
*=======================================================================*/ |
OutputPersonality * |
vt_init (void) |
{ |
OutputPersonality* vt_op; |
vt_op = op_create(); |
vt_op->comment_begin = "### "; |
vt_op->comment_end = "\n"; |
vt_op->document_begin = ""; |
vt_op->document_end = ""; |
vt_op->header_begin = ""; |
vt_op->header_end = ""; |
vt_op->document_title_begin = "\nTITLE: "; |
vt_op->document_title_end = "\n"; |
vt_op->document_author_begin = "\nAUTHOR: "; |
vt_op->document_author_end = "\n"; |
vt_op->document_changedate_begin = "\nDATE: "; |
vt_op->document_changedate_end = "\n"; |
vt_op->body_begin = "\n-----------------\n"; |
vt_op->body_end = ""; |
vt_op->paragraph_begin = ""; |
vt_op->paragraph_end = "\n"; |
vt_op->center_begin = ""; |
vt_op->center_end = ""; |
vt_op->justify_begin = ""; |
vt_op->justify_end = ""; |
vt_op->align_left_begin = ""; |
vt_op->align_left_end = ""; |
vt_op->align_right_begin = ""; |
vt_op->align_right_end = ""; |
vt_op->forced_space = " "; |
vt_op->line_break = "\n"; |
vt_op->page_break = "\n"; |
vt_op->hyperlink_begin = ""; |
vt_op->hyperlink_end = ""; |
vt_op->imagelink_begin = ""; |
vt_op->imagelink_end = ""; |
vt_op->table_begin = "\n"; |
vt_op->table_end = "\n"; |
vt_op->table_row_begin = ""; |
vt_op->table_row_end = "\n"; |
vt_op->table_cell_begin = "\t"; |
vt_op->table_cell_end = ""; |
/* Character attributes */ |
vt_op->font_begin = ""; |
vt_op->font_end = ""; |
vt_op->fontsize_begin = ""; |
vt_op->fontsize_end = ""; |
vt_op->fontsize8_begin = ""; |
vt_op->fontsize8_end = ""; |
vt_op->fontsize10_begin = ""; |
vt_op->fontsize10_end = ""; |
vt_op->fontsize12_begin = ""; |
vt_op->fontsize12_end = ""; |
vt_op->fontsize14_begin = ""; |
vt_op->fontsize14_end = ""; |
vt_op->fontsize18_begin = ""; |
vt_op->fontsize18_end = ""; |
vt_op->fontsize24_begin = ""; |
vt_op->fontsize24_end = ""; |
vt_op->smaller_begin = ""; |
vt_op->smaller_end = ""; |
vt_op->bigger_begin = ""; |
vt_op->bigger_end = ""; |
vt_op->foreground_begin = ""; |
vt_op->foreground_end = ""; |
vt_op->background_begin = ""; |
vt_op->background_end = ""; |
vt_op->bold_begin = "\033[7m"; |
vt_op->bold_end = "\033[m"; |
vt_op->italic_begin = "\033[7m"; |
vt_op->italic_end = "\033[m"; |
vt_op->underline_begin = "\033[4m"; |
vt_op->underline_end = "\033[m"; |
vt_op->dbl_underline_begin = ""; |
vt_op->dbl_underline_end = ""; |
vt_op->superscript_begin = ""; |
vt_op->superscript_end = ""; |
vt_op->subscript_begin = ""; |
vt_op->subscript_end = ""; |
vt_op->strikethru_begin = ""; |
vt_op->strikethru_end = ""; |
vt_op->dbl_strikethru_begin = ""; |
vt_op->dbl_strikethru_end = ""; |
vt_op->emboss_begin=""; |
vt_op->emboss_end = ""; |
vt_op->engrave_begin = ""; |
vt_op->engrave_end = ""; |
vt_op->shadow_begin= ""; |
vt_op->shadow_end= ""; |
vt_op->outline_begin= ""; |
vt_op->outline_end= ""; |
vt_op->expand_begin = ""; |
vt_op->expand_end = ""; |
vt_op->pointlist_begin = "\n"; |
vt_op->pointlist_end = "\n"; |
vt_op->pointlist_item_begin = " * "; |
vt_op->pointlist_item_end = "\n"; |
vt_op->numericlist_begin = "\n"; |
vt_op->numericlist_end = "\n"; |
vt_op->numericlist_item_begin = " # "; |
vt_op->numericlist_item_end = "\n"; |
vt_op->simulate_small_caps = TRUE; |
vt_op->simulate_all_caps = TRUE; |
vt_op->simulate_word_underline = TRUE; |
vt_op->ascii_translation_table = ascii_translation_table; |
vt_op->ansi_translation_table = upper_translation_table; |
vt_op->ansi_first_char = 0x80; |
vt_op->ansi_last_char = 0xff; |
vt_op->cp437_translation_table = upper_translation_table; |
vt_op->cp437_first_char = 0x80; |
vt_op->cp437_last_char = 0xff; |
vt_op->cp850_translation_table = upper_translation_table; |
vt_op->cp850_first_char = 0x80; |
vt_op->cp850_last_char = 0xff; |
vt_op->mac_translation_table = upper_translation_table; |
vt_op->mac_first_char = 0x80; |
vt_op->mac_last_char = 0xff; |
vt_op->chars.right_quote = "'"; |
vt_op->chars.left_quote = "`"; |
vt_op->chars.right_dbl_quote = "''"; |
vt_op->chars.left_dbl_quote = "``"; |
return vt_op; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/vt.h |
---|
0,0 → 1,42 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: vt |
* Author name: Zach Smith |
* Create date: 19 Sep 01 |
* Purpose: Definitions for the VT text output personality |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _VT |
extern OutputPersonality* vt_init(void); |
#define _VT |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/word.c |
---|
0,0 → 1,205 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: word |
* Author name: Zach Smith |
* Create date: 01 Sep 00 |
* Purpose: Management of Word objects, which contain strings |
* as well as other Words. |
*---------------------------------------------------------------------- |
* Changes: |
* 14 Oct 00, tuorfa@yahoo.com: fixed \fs bug (# is 2X the point size). |
* 14 Oct 00, tuorfa@yahoo.com: fixed table data printing. |
* 14 Oct 00, tuorfa@yahoo.com: protection against null entries in \info |
* 14 Oct 00, tuorfa@yahoo.com: fixed printing of <body> again |
* 14 Oct 00, tuorfa@yahoo.com: fixed closure of tables |
* 15 Oct 00, tuorfa@yahoo.com: fixed font attributes preceding <tr><td> |
* 15 Oct 00, tuorfa@yahoo.com: attributes now continue if >1 \cell in group |
* 15 Oct 00, tuorfa@yahoo.com: fixed font-size bug, lack of </head> |
* 7 Nov 00, tuorfa@yahoo.com: fixed \'## translatin bug |
* 8 Apr 01, tuorfa@yahoo.com: added check for out of memory after malloc |
* 21 Apr 01, tuorfa@yahoo.com: bug fixes regarding author, date |
* 21 Apr 01, tuorfa@yahoo.com: added paragraph alignment |
* 21 Apr 01, tuorfa@yahoo.com: fix for words getting lost after \par |
* 24 Jul 01, tuorfa@yahoo.com: moved conversion code to convert.c |
* 22 Sep 01, tuorfa@yahoo.com: moved word_dump to here from parse.c |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <ctype.h> |
#include <string.h> |
#include "defs.h" |
#include "parse.h" |
#include "malloc.h" |
#include "main.h" |
#include "error.h" |
#include "word.h" |
#include "hash.h" |
/* For word_dump */ |
static int indent_level=0; |
/*======================================================================== |
* Name: word_string |
* Purpose: Obtains the string of a Word object. This involves accessing |
* the Word hash. |
* Args: Word*. |
* Returns: String. |
*=======================================================================*/ |
char * |
word_string (Word *w) { |
char *str; |
CHECK_PARAM_NOT_NULL(w); |
if (w->hash_index) str = hash_get_string (w->hash_index); |
else str = NULL; |
return str; |
} |
/*======================================================================== |
* Name: word_new |
* Purpose: Instantiates a new Word object. |
* Args: String. |
* Returns: Word*. |
*=======================================================================*/ |
Word * |
word_new (char *str) { |
Word * w; |
w = (Word *) my_malloc(sizeof(Word)); |
if (!w) |
error_handler ("out of memory"); |
memset ((void*) w, 0, sizeof(Word)); |
if (!w) error_handler ("cannot allocate a Word"); |
if (str) w->hash_index = hash_get_index (str); |
else w->hash_index = 0; |
return w; |
} |
/*======================================================================== |
* Name: word_free |
* Purpose: Deallocates a Word object. |
* Args: Word. |
* Returns: None. |
*=======================================================================*/ |
void word_free (Word *w) { |
Word *prev; |
Word *w2; |
CHECK_PARAM_NOT_NULL(w); |
while (w) { |
w2 = w->child; |
if (w2) |
word_free(w2); |
prev = w; |
w = w->next; |
my_free ((char*) prev); |
} |
} |
/*======================================================================== |
* Name: print_indentation |
* Purpose: Prints padding for the word_dump routine. |
* Args: Identation level. |
* Returns: None. |
*=======================================================================*/ |
static void |
print_indentation (int level) |
{ |
int i; |
if (level) { |
for (i=0;i<level;i+=2) |
printf (". "); |
} else { |
printf ("\n-----------------------------------------------------------------------\n\n"); |
} |
} |
/*======================================================================== |
* Name: word_dump |
* Purpose: Recursive diagnostic routine to print out a tree of words. |
* Args: Word tree. |
* Returns: None. |
*=======================================================================*/ |
void |
word_dump (Word *w) |
{ |
char *s; |
CHECK_PARAM_NOT_NULL(w); |
printf ("\n"); |
indent_level += 2; |
print_indentation (indent_level); |
while (w) { |
s = word_string (w); |
if (s) { |
printf ("\"%s\" ", s); |
} else { |
if (w->child) { |
word_dump (w->child); |
printf ("\n"); |
print_indentation (indent_level); |
} |
else |
warning_handler ("Word object has no string and no children"); |
} |
w = w->next; |
} |
indent_level -= 2; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/word.h |
---|
0,0 → 1,57 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: word.h |
* Author name: Zach Smith |
* Create date: 1 Sept 2000 |
* Purpose: Definitions for Word class. |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _WORD |
#define _WORD |
typedef struct _w { |
unsigned long hash_index; |
struct _w * next; |
struct _w * child; |
} |
Word; |
extern Word* word_new (char*); |
extern void word_free (Word*); |
extern Word* word_read (FILE*); |
extern char* word_string (Word*); |
extern void word_dump (Word*); |
extern void word_print_html (Word*); |
#define _WORD |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/wpml.c |
---|
0,0 → 1,270 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: wpml |
* Author name: Zach Smith |
* Create date: 19 Sep 01 |
* Purpose: WPML output module |
* Note: WPML is my own format; it is a work-in-progress |
*---------------------------------------------------------------------- |
* Changes: |
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks |
*--------------------------------------------------------------------*/ |
#include <stdio.h> |
#include <string.h> |
#include "malloc.h" |
#include "defs.h" |
#include "error.h" |
#include "main.h" |
#include "output.h" |
static char* |
ascii_translation_table [96] = { |
/* 0x20 */ " ", "!", "\"", "#", "$", "%", "&", "'", |
/* 0x28 */ "(", ")", "*", "+", ",", "-", ".", "/", |
/* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7", |
/* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?", |
/* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G", |
/* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O", |
/* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W", |
/* 0x58 */ "X", "Y", "Z", "[", "\\", "]", "^", "_", |
/* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g", |
/* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o", |
/* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w", |
/* 0x78 */ "x", "y", "z", "{", "|", "}", "~", "", |
}; |
static char* |
upper_translation_table [128] = { |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
"?", "?", "?", "?", "?", "?", "?", "?", |
}; |
/*======================================================================== |
* Name: wpml_init |
* Purpose: Generates an output personality for the WPML format. |
* Args: None. |
* Returns: OutputPersonality. |
*=======================================================================*/ |
OutputPersonality * |
wpml_init (void) |
{ |
OutputPersonality* wpml_op; |
wpml_op = op_create(); |
wpml_op->comment_begin = "<!--"; |
wpml_op->comment_end = "-->\n"; |
wpml_op->document_begin = "<WPML>"; |
wpml_op->document_end = "</WPML>"; |
wpml_op->header_begin = "<HEAD>"; |
wpml_op->header_end = "</HEAD>"; |
wpml_op->document_title_begin = "<TITLE>"; |
wpml_op->document_title_end = "</TITLE>"; |
wpml_op->document_author_begin = "<AUTHOR>"; |
wpml_op->document_author_end = "</AUTHOR>\n"; |
wpml_op->document_changedate_begin = "<DATE>"; |
wpml_op->document_changedate_end = "</DATE>\n"; |
wpml_op->body_begin = "\n<BODY>\n"; |
wpml_op->body_end = "</BODY>"; |
wpml_op->paragraph_begin = "<LINE>"; |
wpml_op->paragraph_end = "</LINE>\n"; |
wpml_op->center_begin = ""; |
wpml_op->center_end = ""; |
wpml_op->justify_begin = ""; |
wpml_op->justify_end = ""; |
wpml_op->align_left_begin = ""; |
wpml_op->align_left_end = ""; |
wpml_op->align_right_begin = ""; |
wpml_op->align_right_end = ""; |
wpml_op->forced_space = " "; |
wpml_op->line_break = "\n"; |
wpml_op->page_break = "\n"; |
wpml_op->hyperlink_begin = ""; |
wpml_op->hyperlink_end = ""; |
wpml_op->imagelink_begin = ""; |
wpml_op->imagelink_end = ""; |
wpml_op->table_begin = "<TABLE>\n"; |
wpml_op->table_end = "</TABLE>\n"; |
wpml_op->table_row_begin = "<TABLEROW>"; |
wpml_op->table_row_end = "</TABLEROW>\n"; |
wpml_op->table_cell_begin = "<TABLECELL>"; |
wpml_op->table_cell_end = "</TABLECELL>"; |
/* Character attributes */ |
/* XX: WPML will require that all elements that are now |
* character attribute strings be converted to functions, |
* so that a complete font description can be written |
* each time an attribute begins or ends. |
*/ |
wpml_op->font_begin = "<FONT=\"%s\"/>"; |
wpml_op->font_end = ""; |
wpml_op->fontsize_begin = ""; |
wpml_op->fontsize_end = ""; |
wpml_op->fontsize8_begin = ""; |
wpml_op->fontsize8_end = ""; |
wpml_op->fontsize10_begin = ""; |
wpml_op->fontsize10_end = ""; |
wpml_op->fontsize12_begin = ""; |
wpml_op->fontsize12_end = ""; |
wpml_op->fontsize14_begin = ""; |
wpml_op->fontsize14_end = ""; |
wpml_op->fontsize18_begin = ""; |
wpml_op->fontsize18_end = ""; |
wpml_op->fontsize24_begin = ""; |
wpml_op->fontsize24_end = ""; |
wpml_op->smaller_begin = ""; |
wpml_op->smaller_end = ""; |
wpml_op->bigger_begin = ""; |
wpml_op->bigger_end = ""; |
wpml_op->foreground_begin = ""; |
wpml_op->foreground_end = ""; |
wpml_op->background_begin = ""; |
wpml_op->background_end = ""; |
wpml_op->bold_begin = ""; |
wpml_op->bold_end = ""; |
wpml_op->italic_begin = ""; |
wpml_op->italic_end = ""; |
wpml_op->underline_begin = ""; |
wpml_op->underline_end = ""; |
wpml_op->dbl_underline_begin = ""; |
wpml_op->dbl_underline_end = ""; |
wpml_op->superscript_begin = ""; |
wpml_op->superscript_end = ""; |
wpml_op->subscript_begin = ""; |
wpml_op->subscript_end = ""; |
wpml_op->strikethru_begin = ""; |
wpml_op->strikethru_end = ""; |
wpml_op->dbl_strikethru_begin = ""; |
wpml_op->dbl_strikethru_end = ""; |
wpml_op->emboss_begin=""; |
wpml_op->emboss_end = ""; |
wpml_op->engrave_begin = ""; |
wpml_op->engrave_end = ""; |
wpml_op->shadow_begin= ""; |
wpml_op->shadow_end= ""; |
wpml_op->outline_begin= ""; |
wpml_op->outline_end= ""; |
wpml_op->expand_begin = ""; |
wpml_op->expand_end = ""; |
wpml_op->pointlist_begin = "\n"; |
wpml_op->pointlist_end = "\n"; |
wpml_op->pointlist_item_begin = ""; |
wpml_op->pointlist_item_end = "\n"; |
wpml_op->numericlist_begin = "\n"; |
wpml_op->numericlist_end = "\n"; |
wpml_op->numericlist_item_begin = ""; |
wpml_op->numericlist_item_end = "\n"; |
wpml_op->simulate_small_caps = TRUE; |
wpml_op->simulate_all_caps = TRUE; |
wpml_op->simulate_word_underline = TRUE; |
wpml_op->ascii_translation_table = ascii_translation_table; |
wpml_op->ansi_translation_table = upper_translation_table; |
wpml_op->ansi_first_char = 0x80; |
wpml_op->ansi_last_char = 0xff; |
wpml_op->cp437_translation_table = upper_translation_table; |
wpml_op->cp437_first_char = 0x80; |
wpml_op->cp437_last_char = 0xff; |
wpml_op->cp850_translation_table = upper_translation_table; |
wpml_op->cp850_first_char = 0x80; |
wpml_op->cp850_last_char = 0xff; |
wpml_op->mac_translation_table = upper_translation_table; |
wpml_op->mac_first_char = 0x80; |
wpml_op->mac_last_char = 0xff; |
wpml_op->chars.right_quote = "'"; |
wpml_op->chars.left_quote = "`"; |
wpml_op->chars.right_dbl_quote = "''"; |
wpml_op->chars.left_dbl_quote = "``"; |
return wpml_op; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/media/unrtf/wpml.h |
---|
0,0 → 1,42 |
/*============================================================================= |
GNU UnRTF, a command-line program to convert RTF documents to other formats. |
Copyright (C) 2000,2001 Zachary Thayer Smith |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
The author is reachable by electronic mail at tuorfa@yahoo.com. |
=============================================================================*/ |
/*---------------------------------------------------------------------- |
* Module name: wpml |
* Author name: Zach Smith |
* Create date: 22 Sep 01 |
* Purpose: Definitions for the WPML output personality |
*---------------------------------------------------------------------- |
* Changes: |
*--------------------------------------------------------------------*/ |
#ifndef _WPML |
extern OutputPersonality* wpml_init(void); |
#define _WPML |
#endif |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |