Remove FLP import, revert to GPLv2+ only (#2904)
This commit is contained in:
@@ -19,7 +19,6 @@ ADD_SUBDIRECTORY(DualFilter)
|
||||
ADD_SUBDIRECTORY(dynamics_processor)
|
||||
ADD_SUBDIRECTORY(Eq)
|
||||
ADD_SUBDIRECTORY(Flanger)
|
||||
ADD_SUBDIRECTORY(flp_import)
|
||||
ADD_SUBDIRECTORY(HydrogenImport)
|
||||
ADD_SUBDIRECTORY(kicker)
|
||||
ADD_SUBDIRECTORY(ladspa_browser)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
INCLUDE(BuildPlugin)
|
||||
|
||||
INCLUDE_DIRECTORIES(unrtf)
|
||||
|
||||
# Enable C++11
|
||||
ADD_DEFINITIONS(-std=c++0x)
|
||||
|
||||
IF(LMMS_BUILD_APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
ENDIF()
|
||||
|
||||
BUILD_PLUGIN(flpimport FlpImport.cpp unrtf.cpp FlpImport.h)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* FlpImport.h - support for importing FLP-files
|
||||
*
|
||||
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of LMMS - http://lmms.io
|
||||
*
|
||||
* 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 (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FLP_IMPORT_H
|
||||
#define _FLP_IMPORT_H
|
||||
|
||||
#include <QString>
|
||||
#include <QPair>
|
||||
#include <QVector>
|
||||
|
||||
#include "ImportFilter.h"
|
||||
#include "Note.h"
|
||||
|
||||
|
||||
|
||||
class instrument;
|
||||
struct FL_Channel;
|
||||
|
||||
class FlpImport : public ImportFilter
|
||||
{
|
||||
public:
|
||||
FlpImport( const QString & _file );
|
||||
virtual ~FlpImport();
|
||||
|
||||
virtual PluginView * instantiateView( QWidget * )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
virtual bool tryImport( TrackContainer* tc );
|
||||
|
||||
void processPluginParams( FL_Channel * _ch );
|
||||
|
||||
inline int readInt( int _bytes )
|
||||
{
|
||||
int c, value = 0;
|
||||
do
|
||||
{
|
||||
c = readByte();
|
||||
if( c == -1 )
|
||||
{
|
||||
return( -1 );
|
||||
}
|
||||
value = ( value << 8 ) | c;
|
||||
} while( --_bytes );
|
||||
return( value );
|
||||
}
|
||||
|
||||
inline int32_t read32LE()
|
||||
{
|
||||
int value = readByte();
|
||||
value |= readByte() << 8;
|
||||
value |= readByte() << 16;
|
||||
value |= readByte() << 24;
|
||||
return( value );
|
||||
}
|
||||
inline int32_t read16LE()
|
||||
{
|
||||
int value = readByte();
|
||||
value |= readByte() << 8;
|
||||
return( value );
|
||||
}
|
||||
|
||||
inline int32_t readID()
|
||||
{
|
||||
return( read32LE() );
|
||||
}
|
||||
|
||||
inline void skip( int _bytes )
|
||||
{
|
||||
while( _bytes > 0 )
|
||||
{
|
||||
readByte();
|
||||
--_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* unrtf.cpp - integration of UnRTF
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of LMMS - http://lmms.io
|
||||
*
|
||||
* 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 (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "lmmsconfig.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QBuffer>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
// unrtf-stuff
|
||||
#include "defs.h"
|
||||
#include "main.h"
|
||||
#include "html.h"
|
||||
#include "word.h"
|
||||
#include "hash.h"
|
||||
#include "convert.h"
|
||||
#include "attr.h"
|
||||
|
||||
|
||||
int lineno = 0;
|
||||
#define inline_mode 0
|
||||
#define debug_mode 0
|
||||
#define nopict_mode 1
|
||||
#define verbose_mode 0
|
||||
#define simple_mode 0
|
||||
#define no_remap_mode 0
|
||||
|
||||
QString outstring;
|
||||
short numchar_table;
|
||||
OutputPersonality * op = NULL;
|
||||
|
||||
|
||||
// include unrtf-source
|
||||
#include "attr.c"
|
||||
#include "convert.c"
|
||||
#include "error.c"
|
||||
#include "hash.c"
|
||||
#include "html.c"
|
||||
#include "ur_malloc.c"
|
||||
#include "output.c"
|
||||
#include "parse.c"
|
||||
#include "util.c"
|
||||
#include "word.c"
|
||||
|
||||
}
|
||||
@@ -1,677 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: attr
|
||||
* Author name: Zachary 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
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 31 Oct 07, jasp00@users.sourceforge.net: replaced deprecated conversions
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: fixed fore/background_begin error
|
||||
* and updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LMMS_HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "ur_malloc.h"
|
||||
#include "defs.h"
|
||||
#include "error.h"
|
||||
#include "attr.h"
|
||||
#include "main.h"
|
||||
|
||||
extern void starting_body();
|
||||
extern void starting_text();
|
||||
|
||||
extern QString outstring;
|
||||
|
||||
extern int simulate_allcaps;
|
||||
extern int simulate_smallcaps;
|
||||
|
||||
|
||||
#define MAX_ATTRS (10000)
|
||||
|
||||
|
||||
/* 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;
|
||||
|
||||
|
||||
void attr_clear_all()
|
||||
{
|
||||
stack_of_stacks = NULL;
|
||||
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, const char* param) {
|
||||
switch(attr)
|
||||
{
|
||||
case ATTR_BOLD:
|
||||
outstring+=QString().sprintf("%s", op->bold_begin);
|
||||
break;
|
||||
case ATTR_ITALIC:
|
||||
outstring+=QString().sprintf("%s", 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:
|
||||
outstring+=QString().sprintf("%s", op->underline_begin);
|
||||
break;
|
||||
|
||||
case ATTR_DOUBLE_UL:
|
||||
outstring+=QString().sprintf("%s", op->dbl_underline_begin);
|
||||
break;
|
||||
|
||||
case ATTR_FONTSIZE:
|
||||
op_begin_std_fontsize (op, atoi (param));
|
||||
break;
|
||||
|
||||
case ATTR_FONTFACE:
|
||||
outstring+=QString().sprintf(op->font_begin,param);
|
||||
break;
|
||||
|
||||
case ATTR_FOREGROUND:
|
||||
outstring+=QString().sprintf(op->foreground_begin, param);
|
||||
break;
|
||||
|
||||
case ATTR_BACKGROUND:
|
||||
if (!simple_mode)
|
||||
outstring+=QString().sprintf(op->background_begin,param);
|
||||
break;
|
||||
|
||||
case ATTR_SUPER:
|
||||
outstring+=QString().sprintf("%s", op->superscript_begin);
|
||||
break;
|
||||
case ATTR_SUB:
|
||||
outstring+=QString().sprintf("%s", op->subscript_begin);
|
||||
break;
|
||||
|
||||
case ATTR_STRIKE:
|
||||
outstring+=QString().sprintf("%s", op->strikethru_begin);
|
||||
break;
|
||||
|
||||
case ATTR_DBL_STRIKE:
|
||||
outstring+=QString().sprintf("%s", op->dbl_strikethru_begin);
|
||||
break;
|
||||
|
||||
case ATTR_EXPAND:
|
||||
outstring+=QString().sprintf(op->expand_begin, param);
|
||||
break;
|
||||
|
||||
case ATTR_OUTLINE:
|
||||
outstring+=QString().sprintf("%s", op->outline_begin);
|
||||
break;
|
||||
case ATTR_SHADOW:
|
||||
outstring+=QString().sprintf("%s", op->shadow_begin);
|
||||
break;
|
||||
case ATTR_EMBOSS:
|
||||
outstring+=QString().sprintf("%s", op->emboss_begin);
|
||||
break;
|
||||
case ATTR_ENGRAVE:
|
||||
outstring+=QString().sprintf("%s", 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)
|
||||
outstring+=QString().sprintf("%s", 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:
|
||||
outstring+=QString().sprintf("%s", op->bold_end);
|
||||
break;
|
||||
case ATTR_ITALIC:
|
||||
outstring+=QString().sprintf("%s", 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:
|
||||
outstring+=QString().sprintf("%s", op->underline_end);
|
||||
break;
|
||||
|
||||
case ATTR_DOUBLE_UL:
|
||||
outstring+=QString().sprintf("%s", op->dbl_underline_end);
|
||||
break;
|
||||
|
||||
case ATTR_FONTSIZE:
|
||||
op_end_std_fontsize (op, atoi (param));
|
||||
break;
|
||||
|
||||
case ATTR_FONTFACE:
|
||||
outstring+=QString().sprintf("%s", op->font_end);
|
||||
break;
|
||||
|
||||
case ATTR_FOREGROUND:
|
||||
outstring+=QString().sprintf("%s", op->foreground_end);
|
||||
break;
|
||||
case ATTR_BACKGROUND:
|
||||
if (!simple_mode)
|
||||
outstring+=QString().sprintf("%s", op->background_end);
|
||||
break;
|
||||
|
||||
case ATTR_SUPER:
|
||||
outstring+=QString().sprintf("%s", op->superscript_end);
|
||||
break;
|
||||
case ATTR_SUB:
|
||||
outstring+=QString().sprintf("%s", op->subscript_end);
|
||||
break;
|
||||
|
||||
case ATTR_STRIKE:
|
||||
outstring+=QString().sprintf("%s", op->strikethru_end);
|
||||
break;
|
||||
|
||||
case ATTR_DBL_STRIKE:
|
||||
outstring+=QString().sprintf("%s", op->dbl_strikethru_end);
|
||||
break;
|
||||
|
||||
case ATTR_OUTLINE:
|
||||
outstring+=QString().sprintf("%s", op->outline_end);
|
||||
break;
|
||||
case ATTR_SHADOW:
|
||||
outstring+=QString().sprintf("%s", op->shadow_end);
|
||||
break;
|
||||
case ATTR_EMBOSS:
|
||||
outstring+=QString().sprintf("%s", op->emboss_end);
|
||||
break;
|
||||
case ATTR_ENGRAVE:
|
||||
outstring+=QString().sprintf("%s", op->engrave_end);
|
||||
break;
|
||||
|
||||
case ATTR_EXPAND:
|
||||
outstring+=QString().sprintf("%s", 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)
|
||||
outstring+=QString().sprintf("%s", 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, const 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);
|
||||
}
|
||||
|
||||
#if 1 /* daved 0.20.2 */
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_get_param
|
||||
* Purpose: Reads an attribute from the current attribute stack.
|
||||
* Args: Attribute number
|
||||
* Returns: string.
|
||||
*=======================================================================*/
|
||||
|
||||
char *
|
||||
attr_get_param(int attr)
|
||||
{
|
||||
int i;
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
if (!stack) {
|
||||
warning_handler("No stack to get attribute from");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i=stack->tos;
|
||||
while (i>=0)
|
||||
{
|
||||
if(stack->attr_stack [i] == attr)
|
||||
{
|
||||
if(stack->attr_stack_params [i] != NULL)
|
||||
return stack->attr_stack_params [i];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* 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));
|
||||
memset ((void*) new_stack, 0, 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 ((char*) 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--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: attr
|
||||
* Author name: Zachary 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
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 31 Oct 07, jasp00@users.sourceforge.net: replaced deprecated conversions
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _ATTR
|
||||
#define _ATTR
|
||||
|
||||
|
||||
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_clear_all();
|
||||
|
||||
extern void attr_push_core (int attr, char* param);
|
||||
|
||||
extern void attr_pop_core (int attr);
|
||||
|
||||
extern void attr_push(int attr, const 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();
|
||||
|
||||
#if 1 /* daved 0.20.2 */
|
||||
|
||||
char * attr_get_param(int attr);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,60 +0,0 @@
|
||||
|
||||
/*===========================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
===========================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: convert
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 19 Sep 2001
|
||||
* Purpose: Definitions for the conversion module
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 31 Mar 05, by daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _CONVERT
|
||||
|
||||
enum {
|
||||
CHARSET_ANSI=1,
|
||||
CHARSET_MAC,
|
||||
CHARSET_CP437,
|
||||
CHARSET_CP850,
|
||||
};
|
||||
|
||||
#ifndef _WORD
|
||||
#include "word.h"
|
||||
#endif
|
||||
|
||||
extern void word_print (Word*, QString & _s);
|
||||
|
||||
#if 1 /* daved 0.19.6 - support for multiple char number->output tables */
|
||||
extern short numchar_table;
|
||||
#define FONTROMAN_TABLE 0
|
||||
#define FONTSYMBOL_TABLE 1
|
||||
#define FONTGREEK_TABLE 2
|
||||
#endif
|
||||
|
||||
#define _CONVERT
|
||||
#endif
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: defs.h
|
||||
* Author name: Zachary 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 UnRTF.
|
||||
* 19 Sep 01, tuorfa@yahoo.com: added PROGRAM_WEBSITE.
|
||||
* 09 Oct 03, daved@physiol.usyd.edu.au: changed to GNU website
|
||||
* 17 Feb 04, marcossamaral@terra.com.br: changed some information
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
* 17 Dec 07, daved@physiol.usyd.edu.au: added --noremap to usage - from
|
||||
* David Santinoli
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define PROGRAM_WEBSITE "http://www.gnu.org/software/unrtf/unrtf.html"
|
||||
|
||||
|
||||
/* Select the language for reporting of file creation/modificaton dates */
|
||||
#define ENGLISH
|
||||
#if 0
|
||||
#define FRANCAIS
|
||||
#define ITALIANO
|
||||
#define PORTUGUES /* amaral - 0.19.4 */
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef true /* daved 0.19.0 */
|
||||
#define true (1)
|
||||
#endif
|
||||
#ifndef false /* daved 0.19.0 */
|
||||
#define false (0)
|
||||
#endif
|
||||
#if 1 /* daved - 0.19.4 */
|
||||
#define SKIP_ONE_WORD 2
|
||||
#endif
|
||||
|
||||
|
||||
#define USAGE "unrtf [--version] [--verbose] [--help] [--nopict|-n] [--noremap] [--html] [--text] [--vt] [--latex] [-t html|text|vt|latex] <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"
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: error
|
||||
* Author name: Zachary 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
|
||||
* 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
|
||||
* 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 22 Aug 05, ax2groin@arbornet.org: added lineno to error_handler
|
||||
* 31 Oct 07, jasp00@users.sourceforge.net: replaced deprecated conversions
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LMMS_HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "main.h"
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: usage
|
||||
* Purpose: Prints usage information and exits with an error.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
usage ()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s\n", USAGE);
|
||||
exit(-3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: error_handler
|
||||
* Purpose: Prints error message and other useful info, then exits.
|
||||
* Args: Message.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
error_handler (const char* message)
|
||||
{
|
||||
#if 1
|
||||
fprintf(stderr, "Error (line %d): %s\n", lineno, message);
|
||||
#else
|
||||
fprintf(stderr, "Error: %s\n", message);
|
||||
#endif
|
||||
exit(10);
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: warning_handler
|
||||
* Purpose: Prints useful info to stderr, but doesn't exit.
|
||||
* Args: Message.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
warning_handler (const char* message)
|
||||
{
|
||||
fprintf(stderr, "Warning: %s\n", message);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: error.h
|
||||
* Author name: Zachary 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
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 31 Oct 07, jasp00@users.sourceforge.net: replaced deprecated conversions
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#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 (const char*);
|
||||
extern void warning_handler (const char*);
|
||||
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: hash
|
||||
* Author name: Zachary 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
|
||||
* 08 Oct 03, daved@physiol.usyd.edu.au: some type fixes
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requsted by ZT Smith
|
||||
* 06 Jan 06, marcossamaral@terra.com.br: changes hash_stats function
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LMMS_HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "main.h"
|
||||
#include "ur_malloc.h"
|
||||
|
||||
|
||||
typedef struct _hi {
|
||||
struct _hi *next;
|
||||
char *str;
|
||||
unsigned long value;
|
||||
} hashItem;
|
||||
|
||||
|
||||
/* Index by first char of string */
|
||||
static hashItem *hash2[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++) {
|
||||
hash2[i]=NULL;
|
||||
hash_length[i]=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: hash_stats
|
||||
* Purpose: Return the number of words stored. This is all words,
|
||||
* including commands to RTF, NOT the number of printed words in
|
||||
* a given document.
|
||||
* Args: None.
|
||||
* Returns: Number of words stored.
|
||||
*=======================================================================*/
|
||||
|
||||
unsigned long
|
||||
hash_stats ()
|
||||
{
|
||||
int i;
|
||||
unsigned long total=0;
|
||||
for (i=0; i<256; i++) {
|
||||
total += hash_length[i];
|
||||
}
|
||||
return(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)
|
||||
{
|
||||
#if 1 /* daved - 0.19.1 */
|
||||
unsigned short index;
|
||||
unsigned char ch;
|
||||
#else
|
||||
int index;
|
||||
char ch;
|
||||
#endif
|
||||
hashItem *hi;
|
||||
|
||||
#if 1 /* daved - 0.19.1 */
|
||||
ch = (unsigned char)*str;
|
||||
#else
|
||||
ch = *str;
|
||||
#endif
|
||||
if (ch=='\\' && *(str+1))
|
||||
ch = *(str+1);
|
||||
index = ch;
|
||||
hi = hash2[index];
|
||||
while (hi) {
|
||||
if (!strcmp(hi->str,str))
|
||||
return hi->value;
|
||||
hi=hi->next;
|
||||
}
|
||||
/* not in hash */
|
||||
hi = hashitem_new (str);
|
||||
hi->next = hash2[index];
|
||||
hash2[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 = hash2[index];
|
||||
while (hi) {
|
||||
if (hi->value == value)
|
||||
return hi->str;
|
||||
hi=hi->next;
|
||||
}
|
||||
warning_handler("Word not in hash");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: hash.h
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Sept 2000
|
||||
* Purpose: Definitions for the hash module.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 06 Jan 06, marcossamaral@terra.com.br: changes hash_stats()
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
extern void hash_init (void);
|
||||
extern unsigned long hash_stats (void);
|
||||
extern unsigned long hash_get_index (char *);
|
||||
extern char* hash_get_string (unsigned long );
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,43 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: html
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 19 Sep 01
|
||||
* Purpose: Definitions for the HTML output personality
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _HTML
|
||||
|
||||
|
||||
extern OutputPersonality* html_init(void);
|
||||
|
||||
|
||||
#define _HTML
|
||||
#endif
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: main.h
|
||||
* Author name: Zachary 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
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
extern int lineno;
|
||||
|
||||
|
||||
#ifndef _OUTPUT
|
||||
#include "output.h"
|
||||
#endif
|
||||
|
||||
extern OutputPersonality *op;
|
||||
|
||||
|
||||
@@ -1,478 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: output
|
||||
* Author name: Zachary 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
|
||||
* 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
|
||||
* 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 06 Jan 06, marcossamaral@terra.com.br: changes in STDOUT
|
||||
* 31 Oct 07, jasp00@users.sourceforge.net: replaced deprecated conversions
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
* 17 Dec 07, daved@physiol.usyd.edu.au: added support for --noremap from
|
||||
* David Santinoli
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef LMMS_HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "ur_malloc.h"
|
||||
#include "defs.h"
|
||||
#include "error.h"
|
||||
#include "output.h"
|
||||
#include "main.h"
|
||||
#include "convert.h"
|
||||
|
||||
|
||||
extern QString outstring;
|
||||
|
||||
/*========================================================================
|
||||
* 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");
|
||||
|
||||
memset ((void*) new_op, 0, 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 ((char*) 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.
|
||||
*=======================================================================*/
|
||||
|
||||
const char *
|
||||
#if 1 /* daved - 0.19.6 */
|
||||
op_translate_char (OutputPersonality *op, int charset, CodepageInfo *codepage, int ch, int ntable)
|
||||
#else
|
||||
op_translate_char (OutputPersonality *op, int charset, CodepageInfo *codepage, int ch)
|
||||
#endif
|
||||
{
|
||||
short start;
|
||||
const char *result=NULL;
|
||||
#if 1 /* daved - 0.20.5 */
|
||||
static char output_buffer[2]={ 0, 0 };
|
||||
#endif
|
||||
|
||||
CHECK_PARAM_NOT_NULL(op);
|
||||
|
||||
#if 1 /* daved - 0.20.5 */
|
||||
if (no_remap_mode == true && ch < 256)
|
||||
{
|
||||
output_buffer[0]=ch;
|
||||
result=output_buffer;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if 1 /* daved - 0.19.6 */
|
||||
/* if we are seeking a character from a symbol font we can
|
||||
be below 0x80
|
||||
*/
|
||||
if(ntable == FONTSYMBOL_TABLE)
|
||||
{
|
||||
start = op->symbol_first_char;
|
||||
|
||||
if(ch >= start && ch <= op->symbol_last_char)
|
||||
result = op->symbol_translation_table[ch - start];
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if 1 /* daved - 0.20.3 */
|
||||
if(ntable == FONTGREEK_TABLE)
|
||||
{
|
||||
start = op->greek_first_char;
|
||||
|
||||
if(ch >= start && ch <= op->greek_last_char)
|
||||
result = op->greek_translation_table[ch - start];
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
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:
|
||||
if (codepage != NULL && op->unisymbol_print != NULL && codepage->cp)
|
||||
{
|
||||
if(0)
|
||||
printf("<CODEPAGE CHAR %d>", codepage->chars[ch - 0x80]);
|
||||
if (codepage->chars[ch - 0x80]) {
|
||||
if(0)
|
||||
printf("<UNIPRINTING>");
|
||||
result = op->unisymbol_print(codepage->chars[ch - 0x80]);
|
||||
}
|
||||
}
|
||||
if(!result)
|
||||
{
|
||||
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)
|
||||
{
|
||||
size = ( size * 3 ) / 2;
|
||||
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) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize8_begin);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (op->fontsize10_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize10_begin);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (op->fontsize12_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize12_begin);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (op->fontsize14_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize14_begin);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
if (op->fontsize18_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize18_begin);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
if (op->fontsize24_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize24_begin);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 36:
|
||||
if (op->fontsize36_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize36_begin);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 48:
|
||||
if (op->fontsize48_begin) {
|
||||
outstring+=QString().sprintf("%s", 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);
|
||||
outstring+=QString().sprintf(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) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize8_begin);
|
||||
} else
|
||||
if (size<11 && op->fontsize10_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize10_begin);
|
||||
} else
|
||||
if (size<13 && op->fontsize12_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize12_begin);
|
||||
} else
|
||||
if (size<16 && op->fontsize14_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize14_begin);
|
||||
} else
|
||||
if (size<21 && op->fontsize18_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize18_begin);
|
||||
} else
|
||||
if (size<30 && op->fontsize24_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize24_begin);
|
||||
} else
|
||||
if (size<42 && op->fontsize36_begin) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize36_begin);
|
||||
} else
|
||||
if (size>40 && op->fontsize48_begin) {
|
||||
outstring+=QString().sprintf("%s", 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)
|
||||
outstring+=QString().sprintf("%s", op->fontsize12_begin);
|
||||
else
|
||||
if (op->fontsize14_begin)
|
||||
outstring+=QString().sprintf("%s", op->fontsize14_begin);
|
||||
else
|
||||
if (op->fontsize10_begin)
|
||||
outstring+=QString().sprintf("%s", op->fontsize10_begin);
|
||||
else
|
||||
if (op->fontsize18_begin)
|
||||
outstring+=QString().sprintf("%s", op->fontsize18_begin);
|
||||
else
|
||||
if (op->fontsize8_begin)
|
||||
outstring+=QString().sprintf("%s", 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) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize8_end);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (op->fontsize10_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize10_end);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (op->fontsize12_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize12_end);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (op->fontsize14_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize14_end);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
if (op->fontsize18_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize18_end);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
if (op->fontsize24_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize24_end);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 36:
|
||||
if (op->fontsize36_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize36_end);
|
||||
found_std_expr = true;
|
||||
}
|
||||
break;
|
||||
case 48:
|
||||
if (op->fontsize48_end) {
|
||||
outstring+=QString().sprintf("%s", 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);
|
||||
outstring+=QString().sprintf(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) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize8_end);
|
||||
} else
|
||||
if (size<11 && op->fontsize10_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize10_end);
|
||||
} else
|
||||
if (size<13 && op->fontsize12_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize12_end);
|
||||
} else
|
||||
if (size<16 && op->fontsize14_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize14_end);
|
||||
} else
|
||||
if (size<21 && op->fontsize18_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize18_end);
|
||||
} else
|
||||
if (size<30 && op->fontsize24_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize24_end);
|
||||
} else
|
||||
if (size<42 && op->fontsize36_end) {
|
||||
outstring+=QString().sprintf("%s", op->fontsize36_end);
|
||||
} else
|
||||
if (size>40 && op->fontsize48_end) {
|
||||
outstring+=QString().sprintf("%s", 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)
|
||||
outstring+=QString().sprintf("%s", op->fontsize12_end);
|
||||
else
|
||||
if (op->fontsize14_end)
|
||||
outstring+=QString().sprintf("%s", op->fontsize14_end);
|
||||
else
|
||||
if (op->fontsize10_end)
|
||||
outstring+=QString().sprintf("%s", op->fontsize10_end);
|
||||
else
|
||||
if (op->fontsize18_end)
|
||||
outstring+=QString().sprintf("%s", op->fontsize18_end);
|
||||
else
|
||||
if (op->fontsize8_end)
|
||||
outstring+=QString().sprintf("%s", op->fontsize8_end);
|
||||
else
|
||||
error_handler ("output personality lacks sufficient font size change capability");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,312 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: output
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 18 Sep 01
|
||||
* Purpose: Definitions for the generalized output module
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
* 31 Oct 07, jasp00@users.sourceforge.net: replaced deprecated conversions
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _OUTPUT
|
||||
|
||||
typedef struct {
|
||||
int cp;
|
||||
unsigned short chars[128];
|
||||
} CodepageInfo;
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *comment_begin;
|
||||
const char *comment_end;
|
||||
|
||||
const char *document_begin;
|
||||
const char *document_end;
|
||||
|
||||
const char *header_begin;
|
||||
const char *header_end;
|
||||
|
||||
const char *document_title_begin;
|
||||
const char *document_title_end;
|
||||
|
||||
char *document_keywords_begin;
|
||||
char *document_keywords_end;
|
||||
|
||||
const char *document_author_begin;
|
||||
const char *document_author_end;
|
||||
|
||||
const char *document_changedate_begin;
|
||||
const char *document_changedate_end;
|
||||
|
||||
const char *body_begin;
|
||||
const char *body_end;
|
||||
|
||||
char *word_begin;
|
||||
char *word_end;
|
||||
|
||||
const char *paragraph_begin;
|
||||
const char *paragraph_end;
|
||||
|
||||
const char *center_begin;
|
||||
const char *center_end;
|
||||
|
||||
const char *align_left_begin;
|
||||
const char *align_left_end;
|
||||
|
||||
const char *align_right_begin;
|
||||
const char *align_right_end;
|
||||
|
||||
const char *justify_begin;
|
||||
const char *justify_end;
|
||||
|
||||
const char *forced_space;
|
||||
const char *line_break;
|
||||
const char *page_break;
|
||||
|
||||
const char *hyperlink_begin;
|
||||
const char *hyperlink_end;
|
||||
|
||||
const char *imagelink_begin;
|
||||
const char *imagelink_end;
|
||||
|
||||
const char *table_begin;
|
||||
const char *table_end;
|
||||
|
||||
const char *table_row_begin;
|
||||
const char *table_row_end;
|
||||
|
||||
const char *table_cell_begin;
|
||||
const char *table_cell_end;
|
||||
|
||||
/* Character attributes */
|
||||
const char *font_begin;
|
||||
const char *font_end;
|
||||
|
||||
const char *fontsize_begin;
|
||||
const char *fontsize_end;
|
||||
|
||||
/* standard font sizes are optional */
|
||||
const char *fontsize8_begin;
|
||||
const char *fontsize8_end;
|
||||
|
||||
const char *fontsize10_begin;
|
||||
const char *fontsize10_end;
|
||||
|
||||
const char *fontsize12_begin;
|
||||
const char *fontsize12_end;
|
||||
|
||||
const char *fontsize14_begin;
|
||||
const char *fontsize14_end;
|
||||
|
||||
const char *fontsize18_begin;
|
||||
const char *fontsize18_end;
|
||||
|
||||
const char *fontsize24_begin;
|
||||
const char *fontsize24_end;
|
||||
|
||||
char *fontsize36_begin;
|
||||
char *fontsize36_end;
|
||||
|
||||
char *fontsize48_begin;
|
||||
char *fontsize48_end;
|
||||
|
||||
const char *smaller_begin;
|
||||
const char *smaller_end;
|
||||
|
||||
const char *bigger_begin;
|
||||
const char *bigger_end;
|
||||
|
||||
const char *foreground_begin;
|
||||
const char *foreground_end;
|
||||
|
||||
const char *background_begin;
|
||||
const char *background_end;
|
||||
|
||||
const char *bold_begin;
|
||||
const char *bold_end;
|
||||
|
||||
const char *italic_begin;
|
||||
const char *italic_end;
|
||||
|
||||
const char *underline_begin;
|
||||
const char *underline_end;
|
||||
|
||||
const char *dbl_underline_begin;
|
||||
const char *dbl_underline_end;
|
||||
|
||||
const char *superscript_begin;
|
||||
const char *superscript_end;
|
||||
|
||||
const char *subscript_begin;
|
||||
const char *subscript_end;
|
||||
|
||||
const char *strikethru_begin;
|
||||
const char *strikethru_end;
|
||||
|
||||
const char *dbl_strikethru_begin;
|
||||
const char *dbl_strikethru_end;
|
||||
|
||||
const char *emboss_begin;
|
||||
const char *emboss_end;
|
||||
|
||||
const char *engrave_begin;
|
||||
const char *engrave_end;
|
||||
|
||||
const char *shadow_begin;
|
||||
const char *shadow_end;
|
||||
|
||||
const char *outline_begin;
|
||||
const char *outline_end;
|
||||
|
||||
char *small_caps_begin;
|
||||
char *small_caps_end;
|
||||
|
||||
const char *pointlist_begin;
|
||||
const char *pointlist_end;
|
||||
|
||||
const char *pointlist_item_begin;
|
||||
const char *pointlist_item_end;
|
||||
|
||||
const char *numericlist_begin;
|
||||
const char *numericlist_end;
|
||||
|
||||
const char *numericlist_item_begin;
|
||||
const char *numericlist_item_end;
|
||||
|
||||
const char *expand_begin;
|
||||
const 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 {
|
||||
const char *bullet;
|
||||
const char *left_quote;
|
||||
const char *right_quote;
|
||||
const char *left_dbl_quote;
|
||||
const char *right_dbl_quote;
|
||||
const char *nonbreaking_space;
|
||||
const char *emdash;
|
||||
const char *endash;
|
||||
const char *lessthan;
|
||||
const char *greaterthan;
|
||||
const char *amp;
|
||||
const char *copyright;
|
||||
const char *trademark;
|
||||
char *nonbreaking_hyphen;
|
||||
char *optional_hyphen;
|
||||
} chars;
|
||||
|
||||
const char **ascii_translation_table;
|
||||
|
||||
int simulate_small_caps : 1;
|
||||
int simulate_all_caps : 1;
|
||||
int simulate_word_underline : 1;
|
||||
|
||||
const char **ansi_translation_table;
|
||||
short ansi_first_char;
|
||||
short ansi_last_char;
|
||||
const char **cp437_translation_table;
|
||||
short cp437_first_char;
|
||||
short cp437_last_char;
|
||||
const char **cp850_translation_table;
|
||||
short cp850_first_char;
|
||||
short cp850_last_char;
|
||||
const char **mac_translation_table;
|
||||
short mac_first_char;
|
||||
short mac_last_char;
|
||||
#if 1 /* daved 0.20.0 */
|
||||
unsigned int unisymbol1_first_char;
|
||||
unsigned int unisymbol1_last_char;
|
||||
const char **unisymbol1_translation_table;
|
||||
unsigned int unisymbol2_first_char;
|
||||
unsigned int unisymbol2_last_char;
|
||||
const char **unisymbol2_translation_table;
|
||||
unsigned int unisymbol3_first_char;
|
||||
unsigned int unisymbol3_last_char;
|
||||
const char **unisymbol3_translation_table;
|
||||
unsigned int unisymbol4_first_char;
|
||||
unsigned int unisymbol4_last_char;
|
||||
const char **unisymbol4_translation_table;
|
||||
#else
|
||||
#if 1 /* daved 0.19.4 unicode support */
|
||||
short unisymbol1_first_char;
|
||||
short unisymbol1_last_char;
|
||||
char **unisymbol1_translation_table;
|
||||
short unisymbol2_first_char;
|
||||
short unisymbol2_last_char;
|
||||
char **unisymbol2_translation_table;
|
||||
short unisymbol3_first_char;
|
||||
short unisymbol3_last_char;
|
||||
char **unisymbol3_translation_table;
|
||||
#endif
|
||||
#if 1 /* daved 0.19.5 more unicode support */
|
||||
short unisymbol4_first_char;
|
||||
short unisymbol4_last_char;
|
||||
char **unisymbol4_translation_table;
|
||||
#endif
|
||||
#endif
|
||||
#if 1 /* daved 0.19.5 SYMBOL font support */
|
||||
short symbol_first_char;
|
||||
short symbol_last_char;
|
||||
const char **symbol_translation_table;
|
||||
#endif
|
||||
#if 1 /* daved 0.20.3 GREEK font support */
|
||||
short greek_first_char;
|
||||
short greek_last_char;
|
||||
const char **greek_translation_table;
|
||||
#endif
|
||||
|
||||
char *(*unisymbol_print) (unsigned short);
|
||||
|
||||
void (*write_set_foreground) (int,int,int);
|
||||
}
|
||||
OutputPersonality;
|
||||
|
||||
|
||||
extern OutputPersonality* op_create(void);
|
||||
extern void op_free (OutputPersonality*);
|
||||
#if 1 /* daved - 0.19.6 */
|
||||
extern const char* op_translate_char (OutputPersonality*,int,CodepageInfo*,int, int);
|
||||
#else
|
||||
extern char* op_translate_char (OutputPersonality*,int,CodepageInfo*,int);
|
||||
#endif
|
||||
|
||||
extern void op_begin_std_fontsize (OutputPersonality*, int);
|
||||
extern void op_end_std_fontsize (OutputPersonality*, int);
|
||||
|
||||
|
||||
#define _OUTPUT
|
||||
#endif
|
||||
|
||||
@@ -1,472 +0,0 @@
|
||||
/*=============================================================================
|
||||
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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
|
||||
* 08 Sep 03, daved@physiol.usyd.edu.au: type fixes; ANSI C fixes
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LMMS_HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "parse.h"
|
||||
#include "ur_malloc.h"
|
||||
#include "main.h"
|
||||
#include "error.h"
|
||||
#include "word.h"
|
||||
#include "hash.h"
|
||||
|
||||
|
||||
|
||||
/* local to getchar stuff */
|
||||
#if 0 /* daved - 0.19.0 */
|
||||
static int ungot_char=-1;
|
||||
static int ungot_char2=-1;
|
||||
static int ungot_char3=-1;
|
||||
#else
|
||||
static int ungot_char = -1;
|
||||
static int ungot_char2 = -1;
|
||||
static int ungot_char3 = -1;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* 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 (QBuffer* f)
|
||||
{
|
||||
int ch;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(f);
|
||||
|
||||
if (ungot_char>=0) {
|
||||
ch = ungot_char;
|
||||
#if 0 /* daved - 0.19.0 */
|
||||
ungot_char=ungot_char2;
|
||||
ungot_char2=ungot_char3;
|
||||
ungot_char3=-1;
|
||||
#else
|
||||
ungot_char = ungot_char2;
|
||||
ungot_char2 = ungot_char3;
|
||||
ungot_char3 = -1;
|
||||
#endif
|
||||
last_returned_ch = ch;
|
||||
if(ch > 255)
|
||||
{
|
||||
fprintf(stderr, "returning bad ch = '%c' (0%o)\n",
|
||||
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 = f->read(read_buf, buffer_size);
|
||||
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;
|
||||
if(ch > 255)
|
||||
{
|
||||
fprintf(stderr,"returning bad ch '%c' (0%o)\n", ch, ch);
|
||||
exit(1);
|
||||
}
|
||||
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 (QBuffer*f)
|
||||
{
|
||||
#if 0 /* daved - 0.19.0 */
|
||||
int ch, ch2, ix=0;
|
||||
#else
|
||||
int ch, ch2;
|
||||
unsigned long ix=0;
|
||||
#endif
|
||||
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 (QBuffer* 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 */
|
||||
|
||||
/* 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);
|
||||
|
||||
} else if (input_str[0] == '}') {
|
||||
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);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: parse.h
|
||||
* Author name: Zachary 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
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
#ifndef _WORD
|
||||
#include "word.h"
|
||||
#endif
|
||||
|
||||
|
||||
extern Word *word_read(QBuffer*);
|
||||
|
||||
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: malloc
|
||||
* Author name: Zachary 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.
|
||||
* 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 31 Oct 07, jasp00@users.sourceforge.net: replaced deprecated conversions
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LMMS_HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "ur_malloc.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 = (char *) 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. Called at
|
||||
* the end of main() when in debug mode.
|
||||
* 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 (const 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;
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: malloc
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Aug 2001
|
||||
* Purpose: Definitions for memory management.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 31 Oct 07, jasp00@users.sourceforge.net: replaced deprecated conversions
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
extern char * my_malloc (unsigned long);
|
||||
extern void my_free (char*);
|
||||
extern unsigned long total_malloced (void);
|
||||
extern char * my_strdup (const char*);
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: util
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 01 Aug 01
|
||||
* Purpose: Utility functions.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LMMS_HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: util
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Aug 2001
|
||||
* Purpose: Definitions for util module.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
extern int h2toi (char *);
|
||||
@@ -1,217 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: word
|
||||
* Author name: Zachary 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
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 11 Jan 07, jasp00@users.sourceforge.net: optimized unsafe loop
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LMMS_HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef LMMS_HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "parse.h"
|
||||
#include "ur_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. This is only called at the end of
|
||||
* main(), after everything is processed and output complete.
|
||||
* 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)
|
||||
{
|
||||
if (level) {
|
||||
/* indent in multiples of 2 */
|
||||
level = (level >> 1) + (level & 1);
|
||||
while (level-- > 0)
|
||||
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;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: word.h
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Sept 2000
|
||||
* Purpose: Definitions for Word class.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _WORD
|
||||
#define _WORD
|
||||
|
||||
class QBuffer;
|
||||
|
||||
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 (QBuffer*);
|
||||
extern char* word_string (Word*);
|
||||
extern void word_dump (Word*);
|
||||
extern void word_print_html (Word*);
|
||||
|
||||
#define _WORD
|
||||
#endif
|
||||
Reference in New Issue
Block a user