psiconv-0.9.8/ 0000777 0001750 0001750 00000000000 10336611562 010221 5 0000000 0000000 psiconv-0.9.8/lib/ 0000777 0001750 0001750 00000000000 10336611556 010772 5 0000000 0000000 psiconv-0.9.8/lib/psiconv/ 0000777 0001750 0001750 00000000000 10336611557 012454 5 0000000 0000000 psiconv-0.9.8/lib/psiconv/image.h 0000644 0001750 0001750 00000003520 10336374727 013630 0000000 0000000 /*
image.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* This file contains definitions used internally by
generate_image.c and parse_image.c */
#ifndef PSICONV_IMAGE_H
#define PSICONV_IMAGE_H
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef psiconv_list psiconv_pixel_bytes; /* psiconv_u8 */
typedef psiconv_list psiconv_pixel_ints; /* of psiconv_u32 */
typedef struct psiconv_pixel_float_s
{
psiconv_u32 length;
float *red;
float *green;
float *blue;
} psiconv_pixel_floats_t;
extern psiconv_pixel_floats_t psiconv_palet_none, psiconv_palet_color_4,
psiconv_palet_color_8;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* def PSICONV_IMAGE_H */
psiconv-0.9.8/lib/psiconv/configuration.h 0000644 0001750 0001750 00000003634 10336374717 015422 0000000 0000000 /*
configuration.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PSICONV_CONFIG_H
#define PSICONV_CONFIG_H
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef void psiconv_error_handler_t (int kind, psiconv_u32 off,
const char *message);
typedef struct psiconv_config_s
{
int verbosity;
int colordepth;
int redbits; /* Only needed when color is used and no palet */
int greenbits; /* Only needed when color is used and no palet */
int bluebits; /* Only needed when color is used and no palet */
psiconv_bool_t color;
psiconv_error_handler_t *error_handler;
psiconv_u8 unknown_epoc_char;
psiconv_ucs2 unknown_unicode_char;
psiconv_ucs2 unicode_table[0x100];
psiconv_bool_t unicode;
} *psiconv_config;
extern psiconv_config psiconv_config_default(void);
extern void psiconv_config_read(const char *extra_config_files,
psiconv_config *config);
extern void psiconv_config_free(psiconv_config config);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PSICONV_ERROR_H */
psiconv-0.9.8/lib/psiconv/data.h 0000644 0001750 0001750 00000130125 10336374662 013457 0000000 0000000 /*
data.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* This file contains the declarations of all types that are used to
represent the Psion files. Variables of these types are written by the
parse routines, and read by the generation routines.
Mostly, the data structures reflect the file format documentation,
as included in the formats directory. When in doubt, refer there. */
#ifndef PSICONV_DATA_H
#define PSICONV_DATA_H
#include
#include
/* All types which end on _t are plain types; all other types are pointers
to structs. */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Forward declaration (for psiconv_embedded_object_section) */
typedef struct psiconv_file_s *psiconv_file;
/* Enums and simple types */
/* Floating point number representation */
typedef double psiconv_float_t;
/* The supported file types. */
typedef enum psiconv_file_type {
psiconv_unknown_file,
psiconv_word_file,
psiconv_texted_file,
psiconv_mbm_file,
psiconv_sketch_file,
psiconv_clipart_file,
psiconv_sheet_file
} psiconv_file_type_t;
/* String representation. A string is an array of UCS2 characters, terminated
by a 0. So they are just like normal C strings, except that they are built
of psiconv_ucs2 elements instead of char elements.
The psiconv_ucs2 type holds 16 bits; see unicode.h for more information. */
typedef psiconv_ucs2 *psiconv_string_t;
/* Represent lengths (in centimeters) and sizes (in points).
In the Psion file, these are identical; but we translate them to more
human-readable quantities */
typedef float psiconv_length_t; /* For offsets in centimeters */
typedef float psiconv_size_t; /* For sizes in points */
/* Represent booleans. As false is zero in the enum, you can still do things
like { if (test) ... } instead of { if (test == psiconv_bool_true) ... }.
Choose whatever style suits you best. */
typedef enum psiconv_bool
{
psiconv_bool_false,
psiconv_bool_true
} psiconv_bool_t;
/* Some kind of three-valued boolean, used at several places. */
typedef enum psiconv_triple
{
psiconv_triple_on,
psiconv_triple_off,
psiconv_triple_auto
} psiconv_triple_t;
/* Text can be in superscript or subscript or neither, but never both
superscript and subscript at once. Also, super-superscript and things
like that do not exist in the Psion world. */
typedef enum psiconv_super_sub
{ psiconv_normalscript,
psiconv_superscript,
psiconv_subscript
} psiconv_super_sub_t;
/* Horizontal justification. */
typedef enum psiconv_justify_hor
{ psiconv_justify_left,
psiconv_justify_centre,
psiconv_justify_right,
psiconv_justify_full
} psiconv_justify_hor_t;
/* Vertical justification. */
typedef enum psiconv_justify_ver
{ psiconv_justify_top,
psiconv_justify_middle,
psiconv_justify_bottom
} psiconv_justify_ver_t;
/* Borders around text fields. */
typedef enum psiconv_border_kind
{ psiconv_border_none, /* No border */
psiconv_border_solid, /* Single line */
psiconv_border_double, /* Double line */
psiconv_border_dotted, /* Dotted line: . . . . . */
psiconv_border_dashed, /* Dashed line: _ _ _ _ _ */
psiconv_border_dotdashed, /* Dotted/dashed line: _ . _ . _ */
psiconv_border_dotdotdashed /* Dotted/dashed line: . . _ . . _ */
} psiconv_border_kind_t;
/* Though each printer driver has its own fonts for printing, they are
represented on the Psion screen by a few built-in fonts. */
typedef enum psiconv_screenfont
{
psiconv_font_misc, /* Nonproportional symbols, like Wingbat? */
psiconv_font_sansserif, /* Proportional sans-serif, like Arial */
psiconv_font_nonprop, /* Nonproportional, like Courier */
psiconv_font_serif /* Proportional serifed, like Times */
} psiconv_screenfont_t;
/* The kind of tab. Note that decimal tabs are not supported by the Psion. */
typedef enum psiconv_tab_kind
{
psiconv_tab_left, /* Left tab */
psiconv_tab_centre, /* Centre tab */
psiconv_tab_right /* Right tab */
} psiconv_tab_kind_t;
/* When text has to be replaced, the kind of replacement to do
(not yet implemented!) */
typedef enum psiconv_replacement_type
{
psiconv_replace_time,
psiconv_replace_date,
psiconv_replace_pagenr,
psiconv_replace_nr_of_pages,
psiconv_replace_filename
} psiconv_replacement_type_t;
/* Here starts the struct definitions */
/* The color of a single pixel, in RGB format.
Black: 0x00 0x00 0x00
White: 0xff 0xff 0xff */
typedef struct psiconv_color_s
{
psiconv_u8 red;
psiconv_u8 green;
psiconv_u8 blue;
} * psiconv_color;
/* Complete font information: both a printer font and a corresponding screen
font to display it. */
typedef struct psiconv_font_s
{
psiconv_string_t name; /* Printer font */
psiconv_screenfont_t screenfont; /* Screen font */
} *psiconv_font;
/* Complete border information */
typedef struct psiconv_border_s
{
psiconv_border_kind_t kind; /* Border kind */
psiconv_size_t thickness; /* Set to 1/20 for non-solid lines */
psiconv_color color; /* Border color */
} *psiconv_border;
/* Complete bullet information.
The interaction of left and first line indentation and bullets is quite
complicated.
BULLET FIRST BULLET FIRST LINE NEXT LINES
None = 0 - Left+First Left
> 0 - Left+First Left
< 0 - Left+First Left
Indent Off = 0 Left Left(+Bullet) Left
> 0 Left Left+First Left
< 0 Left+First Left+First(+Bullet) Left
Indent On = 0 Left Left(+Bullet) Left
> 0 Left Left+First Left+First
< 0 Left+First Left Left
*/
typedef struct psiconv_bullet_s
{
psiconv_bool_t on; /* Whether the bullet is shown */
psiconv_size_t font_size; /* Bullet font size */
psiconv_ucs2 character; /* Bullet character */
psiconv_bool_t indent; /* Whether to indent (see above */
psiconv_color color; /* Bullet color */
psiconv_font font; /* Bullet font */
} *psiconv_bullet;
/* Complete single tab information */
typedef struct psiconv_tab_s
{
psiconv_length_t location; /* The indentation level */
psiconv_tab_kind_t kind; /* Tab kind */
} *psiconv_tab;
/* A list of tabs */
typedef psiconv_list psiconv_tab_list; /* of struct psiconv_tab_s */
/* Information about all tabs.
Normal tabs start after the rightmost extra tab */
typedef struct psiconv_all_tabs_s
{
psiconv_length_t normal; /* Normal tab distance */
psiconv_tab_list extras; /* Additional defined tabs */
} *psiconv_all_tabs;
/* Character layout.
This structure holds all layout information that can be applied on the
character level (as opposed to layouts that only apply to whole
paragraphs).
Note that at all times, this structure holds the complete layout
information; we do not use incremental layouts, unlike the Psion
file format itself. So if an italic text is also underlined, the
character_layout will have both set for that region. */
typedef struct psiconv_character_layout_s
{
psiconv_color color; /* Character color */
psiconv_color back_color; /* Background color */
psiconv_size_t font_size; /* Font size */
psiconv_bool_t italic; /* Use italics? */
psiconv_bool_t bold; /* Use bold? */
psiconv_super_sub_t super_sub; /* Use super/subscript? */
psiconv_bool_t underline; /* Underline? */
psiconv_bool_t strikethrough; /* Strike through? */
psiconv_font font; /* Character font */
} *psiconv_character_layout;
/* Paragraph layout.
This structure holds all layout information that can be applied on the
paragraph level (as opposed to layouts that also apply to single
characters).
Note that at all times, this structure holds the complete layout
information; we do not use incremental layouts, unlike the Psion
file format itself.
Linespacing is the amount of vertical space between lines. If
linespacing_exact is set, this amount is used even if that would make
text overlap; if it is not set, a greater distance is used if text would
otherwise overlap.
Several booleans determine where page breaks may be set. keep_together
forbids page breaks in the middle of the paragraph; keep_with_next
forbids page breaks between this and the next paragraph. on_next_page
forces a pagebreak before the paragraph. no_widow_protection allows
one single line of the paragraph on a page, and the rest on another page.
Sheet cell text normally does not wrap; wrap_to_fit_cell allows this. */
typedef struct psiconv_paragraph_layout_s
{
psiconv_color back_color; /* Background color */
psiconv_length_t indent_left; /* Left indentation (except first line) */
psiconv_length_t indent_right; /* Right indentation */
psiconv_length_t indent_first; /* First line left indentation */
psiconv_justify_hor_t justify_hor; /* Horizontal justification */
psiconv_justify_ver_t justify_ver; /* Vertical justification */
psiconv_size_t linespacing; /* The linespacing */
psiconv_bool_t linespacing_exact; /* Is linespacing exact or the minimum? */
psiconv_size_t space_above; /* Vertical space before the paragraph */
psiconv_size_t space_below; /* Vertical space after the paragraph */
psiconv_bool_t keep_together; /* Keep lines on one page? */
psiconv_bool_t keep_with_next; /* Disallow pagebreak after paragraph? */
psiconv_bool_t on_next_page; /* Force page break before paragraph? */
psiconv_bool_t no_widow_protection; /* Undo widow protection? */
psiconv_bool_t wrap_to_fit_cell; /* Wrap sheet cell text? */
psiconv_length_t border_distance; /* Distance to borders */
psiconv_bullet bullet; /* Bullet information */
psiconv_border left_border; /* Left border information */
psiconv_border right_border; /* Right border information */
psiconv_border top_border; /* Top border information */
psiconv_border bottom_border; /* Bottom border information */
psiconv_all_tabs tabs; /* All tab information */
} *psiconv_paragraph_layout;
/* A Header Section.
It contains the three UIDs and the checksum, and the type of file.
As the type of file uniquely defines the UIDs, and as the UIDs determine
the checksum, this is never included in a regular psiconv_file structure.
It can be used to read the header section separately, though. */
typedef struct psiconv_header_section_s
{
psiconv_u32 uid1;
psiconv_u32 uid2;
psiconv_u32 uid3;
psiconv_u32 checksum;
psiconv_file_type_t file;
} *psiconv_header_section;
/* A Section Table Section entry.
Each entry has a UID and an offset.
This is never included in a regular psiconv_file structure, as the
information is too low-level. It is used internally, though. */
typedef struct psiconv_section_table_entry_s
{
psiconv_u32 id; /* Section UID */
psiconv_u32 offset; /* Section offset within the file */
} *psiconv_section_table_entry;
/* A Section Table Section.
A list of sections and their offsets.
It is simply a list of Section Table Section Entries.
This is never included in a regular psiconv_file structure, as the
information is too low-level. It is used internally, though. */
typedef psiconv_list psiconv_section_table_section;
/* Of struct psiconv_sectiontable_entry_s */
/* An Application ID Section.
The type of file.
Never included in a regular psiconv_file structure, because it is too
low-level. You can always recover it if you know the file type. Used
internally.
The name should probably be case-insensitive. */
typedef struct psiconv_application_id_section_s
{
psiconv_u32 id; /* File type UID */
psiconv_string_t name; /* File type name */
} *psiconv_application_id_section;
/* An Object Icon Section.
The icon used for an embedded object. */
typedef struct psiconv_object_icon_section_s
{
psiconv_length_t icon_width; /* Icon width */
psiconv_length_t icon_height; /* Icon height */
psiconv_string_t icon_name; /* Icon name */
} *psiconv_object_icon_section;
/* An Object Display Section.
How an embedded icon should be displayed.
The sizes are computed after cropping or resizing; if the object is shown
as an icon, the icon sizes are used here. */
typedef struct psiconv_object_display_section_s
{
psiconv_bool_t show_icon; /* Show an icon or the whole file? */
psiconv_length_t width; /* Object display width */
psiconv_length_t height; /* Object display height */
} *psiconv_object_display_section;
/* An Embedded Object Section.
All data about an embedded object.
An object is another psiconv_file, which is embedded in the current
file. Objects can also be embedded in each other, of course. */
typedef struct psiconv_embedded_object_section_s
{
psiconv_object_icon_section icon; /* Icon information */
psiconv_object_display_section display; /* Display information */
psiconv_file object; /* The object itself */
} *psiconv_embedded_object_section;
/* Inline character-level layout information.
Information how some characters should be laid out.
Note that, though you can choose specific layouts for an object, this
will probably not affect the object's rendering.
Usually, object will be NULL, and the object_width and object_height
will be ignored.
The object sizes are the same as in the Object Display Section, so
this information seems to be redundant. */
typedef struct psiconv_in_line_layout_s
{
psiconv_character_layout layout; /* Layout information */
int length; /* Number of characters */
psiconv_embedded_object_section object; /* Embedded object or NULL */
psiconv_length_t object_width; /* Object display width */
psiconv_length_t object_height; /* Object display height */
} *psiconv_in_line_layout;
/* Inline character information for a whole line.
A list of inline character information */
typedef psiconv_list psiconv_in_line_layouts;
/* of struct psiconv_in_line_layout_s */
/* What to replace where in text. Not yet implemented!
(not yet implemented!) */
typedef struct psiconv_replacement_s
{
int offset; /* Offset in text */
int cur_len; /* Length of text to replace */
psiconv_replacement_type_t type; /* Kind of replacement */
} *psiconv_replacement;
/* A list of replacements */
typedef psiconv_list psiconv_replacements; /* of struct psiconv_replacement_s */
/* A paragraph of text.
Layout and actual paragraph text are combined here, even though
they are seperated in the Psion file format.
The base style is referred to, but the base_character and
base_paragraph have all style settings already incorporated.
The base style can be found using the psiconv_get_style function.
The in_lines are either an empty list, or they should apply to exactly
the number of characters in this paragraph */
typedef struct psiconv_paragraph_s
{
psiconv_string_t text; /* Paragraph text */
psiconv_character_layout base_character; /* Base character layout */
psiconv_paragraph_layout base_paragraph; /* Base paragraph layout */
psiconv_s16 base_style; /* Paragraph style */
psiconv_in_line_layouts in_lines; /* In-paragraph layout */
psiconv_replacements replacements; /* Replacements like the date */
} *psiconv_paragraph;
/* A collection of text paragraphs */
typedef psiconv_list psiconv_text_and_layout;
/* Of struct psiconv_paragraph_s */
/* A TextEd Section.
Text and simple layout, without styles. */
typedef struct psiconv_texted_section_s
{
psiconv_text_and_layout paragraphs;
} *psiconv_texted_section;
/* A Page Header.
All information about a page header or footer.
An explicit base paragraph and character layout is found; this is used
as a sort of base style, on which all further formatting is based */
typedef struct psiconv_page_header_s
{
psiconv_bool_t on_first_page; /* Display on first page? */
psiconv_paragraph_layout base_paragraph_layout; /* Base paragraph layout */
psiconv_character_layout base_character_layout; /* Base character layout */
psiconv_texted_section text; /* The actual text */
} *psiconv_page_header;
/* A Page Layout Section
All information about the layout of a page.
Margins, page size, the header, the footer and page numbers */
typedef struct psiconv_page_layout_section_s
{
psiconv_u32 first_page_nr; /* Page numbers start counting here */
psiconv_length_t header_dist; /* Distance of header to text */
psiconv_length_t footer_dist; /* Distance of footer to text */
psiconv_length_t left_margin; /* Left margin */
psiconv_length_t right_margin; /* Right margin */
psiconv_length_t top_margin; /* Top margin */
psiconv_length_t bottom_margin; /* Bottom margin */
psiconv_length_t page_width; /* Page width */
psiconv_length_t page_height; /* Page height */
psiconv_page_header header; /* Header information */
psiconv_page_header footer; /* Footer information */
psiconv_bool_t landscape; /* Landscape orientation? */
} * psiconv_page_layout_section;
/* A Word Status Section
Settings of the Word program.
Several whitespace and related characters can be explicitely shown.
Embedded pictures and graphs can be iconized or displayed full.
Toolbars can be shown or hidden.
Long lines can be wrapped, or you have to use scrolling.
The cursor position is the character number of the text.
Zoom level: 1000 is "normal" */
typedef struct psiconv_word_status_section_s
{
psiconv_bool_t show_tabs; /* Show tabs? */
psiconv_bool_t show_spaces; /* Show spaces? */
psiconv_bool_t show_paragraph_ends; /* Show paragraph ends? */
psiconv_bool_t show_line_breaks; /* Show line breaks */
psiconv_bool_t show_hard_minus; /* Show hard dashes? */
psiconv_bool_t show_hard_space; /* Show hard spaces? */
psiconv_bool_t show_full_pictures; /* Show embedded pictures (or iconize)? */
psiconv_bool_t show_full_graphs; /* Show embedded graphs (or iconize)? */
psiconv_bool_t show_top_toolbar; /* Show top toolbar? */
psiconv_bool_t show_side_toolbar; /* Show side toolbar? */
psiconv_bool_t fit_lines_to_screen; /* Wrap lines? */
psiconv_u32 cursor_position; /* Cursor position (character number) */
psiconv_u32 display_size; /* Zooming level */
} *psiconv_word_status_section;
/* A Word Style.
All information about a single Style.
A builtin style may not be changed in the Word program.
Outline level is zero if unused.
The name may be NULL for the normal style! */
typedef struct psiconv_word_style_s
{
psiconv_character_layout character; /* character-level layout */
psiconv_paragraph_layout paragraph; /* paragraph-level layout */
psiconv_ucs2 hotkey; /* The hotkey */
psiconv_string_t name; /* Style name */
psiconv_bool_t built_in; /* Builtin style? */
psiconv_u32 outline_level; /* Outline level */
} *psiconv_word_style;
/* A list of Word Styles */
typedef psiconv_list psiconv_word_style_list;
/* Of struct psiconv_word_style_s */
/* A Word Styles Section
All information about styles.
Note that the name of the normal style is NULL! */
typedef struct psiconv_word_styles_section_s
{
psiconv_word_style normal; /* The normal (unspecified) style */
psiconv_word_style_list styles; /* All other defined styles */
} *psiconv_word_styles_section;
/* A Word File
All information about a Word File.
Note that a section can be NULL if it is not present. */
typedef struct psiconv_word_f_s
{
psiconv_page_layout_section page_sec; /* Page layout */
psiconv_text_and_layout paragraphs; /* Text and text layout */
psiconv_word_status_section status_sec; /* Internal Word program settings */
psiconv_word_styles_section styles_sec; /* Styles */
} *psiconv_word_f;
/* A TextEd File
All information about a TextEd File.
Note that a section can be NULL if it is not present. */
typedef struct psiconv_texted_f_s
{
psiconv_page_layout_section page_sec; /* Page layout */
psiconv_texted_section texted_sec; /* Text and text layout */
} *psiconv_texted_f;
/* A Jumptable Section.
A simple list of offsets.
This is never included in a regular psiconv_file structure, as the
information is too low-level. It is used internally, though. */
typedef psiconv_list psiconv_jumptable_section; /* of psiconv_u32 */
/* A Paint Data Section
A collection of pixels.
Normalized values [0..1] for each color component.
Origin is (x,y)=(0,0), to get pixel at (X,Y) use index [Y*xsize+X] */
typedef struct psiconv_paint_data_section_s
{
psiconv_u32 xsize; /* Number of pixels in a row */
psiconv_u32 ysize; /* Number of pixels in a column */
psiconv_length_t pic_xsize; /* 0 if not specified */
psiconv_length_t pic_ysize; /* 0 if not specified */
float *red;
float *green;
float *blue;
} *psiconv_paint_data_section;
/* A collection of Paint Data Sections */
typedef psiconv_list psiconv_pictures;
/* of struct psiconv_paint_data_section_s */
/* A MBM file
All information about a MBM file
MBM files contain one or more pictures. */
typedef struct psiconv_mbm_f_s
{
psiconv_pictures sections;
} *psiconv_mbm_f;
/* Read the Psiconv file format documentation for a complete discription.
Basic idea: a picture has a certain display size. Within it, the pixel
data begins at a certain offset. Around it, there is an empty form.
The first eight values are before magnification and cuts.
Cuts are always <= 1.0; a cut of 0.0 cuts nothing away, a cut of 1.0
cuts everything away. */
typedef struct psiconv_sketch_section_s
{
psiconv_u16 displayed_xsize;
psiconv_u16 displayed_ysize;
psiconv_u16 picture_data_x_offset;
psiconv_u16 picture_data_y_offset;
psiconv_u16 form_xsize;
psiconv_u16 form_ysize;
psiconv_u16 displayed_size_x_offset;
psiconv_u16 displayed_size_y_offset;
float magnification_x; /* computed relative to first eight values */
float magnification_y; /* computed relative to first eight values */
float cut_left; /* computed relative to first eight values */
float cut_right; /* computed relative to first eight values */
float cut_top; /* computed relative to first eight values */
float cut_bottom; /* computed relative to first eight values */
psiconv_paint_data_section picture;
} *psiconv_sketch_section;
typedef struct psiconv_sketch_f_s
{
psiconv_sketch_section sketch_sec;
} *psiconv_sketch_f;
typedef struct psiconv_clipart_section_s
{
/* Perhaps later on some currently unknown stuff. */
psiconv_paint_data_section picture;
} * psiconv_clipart_section;
typedef psiconv_list psiconv_cliparts; /* of struct psiconv_clipart_section_s */
typedef struct psiconv_clipart_f_s
{
psiconv_cliparts sections;
} *psiconv_clipart_f;
typedef struct psiconv_sheet_ref_s
{
psiconv_s16 offset;
psiconv_bool_t absolute;
} psiconv_sheet_ref_t;
typedef struct psiconv_sheet_cell_reference_s
{
psiconv_sheet_ref_t row;
psiconv_sheet_ref_t column;
} psiconv_sheet_cell_reference_t;
typedef struct psiconv_sheet_cell_block_s
{
psiconv_sheet_cell_reference_t first;
psiconv_sheet_cell_reference_t last;
} psiconv_sheet_cell_block_t;
typedef enum psiconv_cell_type
{
psiconv_cell_blank,
psiconv_cell_int,
psiconv_cell_bool,
psiconv_cell_error,
psiconv_cell_float,
psiconv_cell_string
} psiconv_cell_type_t;
typedef enum psiconv_sheet_errorcode
{
psiconv_sheet_error_none,
psiconv_sheet_error_null,
psiconv_sheet_error_divzero,
psiconv_sheet_error_value,
psiconv_sheet_error_reference,
psiconv_sheet_error_name,
psiconv_sheet_error_number,
psiconv_sheet_error_notavail
} psiconv_sheet_errorcode_t;
typedef enum psiconv_sheet_numberformat_code
{
psiconv_numberformat_general,
psiconv_numberformat_fixeddecimal,
psiconv_numberformat_scientific,
psiconv_numberformat_currency,
psiconv_numberformat_percent,
psiconv_numberformat_triads,
psiconv_numberformat_boolean,
psiconv_numberformat_text,
psiconv_numberformat_date_dmm,
psiconv_numberformat_date_mmd,
psiconv_numberformat_date_ddmmyy,
psiconv_numberformat_date_mmddyy,
psiconv_numberformat_date_yymmdd,
psiconv_numberformat_date_dmmm,
psiconv_numberformat_date_dmmmyy,
psiconv_numberformat_date_ddmmmyy,
psiconv_numberformat_date_mmm,
psiconv_numberformat_date_monthname,
psiconv_numberformat_date_mmmyy,
psiconv_numberformat_date_monthnameyy,
psiconv_numberformat_date_monthnamedyyyy,
psiconv_numberformat_datetime_ddmmyyyyhhii,
psiconv_numberformat_datetime_ddmmyyyyHHii,
psiconv_numberformat_datetime_mmddyyyyhhii,
psiconv_numberformat_datetime_mmddyyyyHHii,
psiconv_numberformat_datetime_yyyymmddhhii,
psiconv_numberformat_datetime_yyyymmddHHii,
psiconv_numberformat_time_hhii,
psiconv_numberformat_time_hhiiss,
psiconv_numberformat_time_HHii,
psiconv_numberformat_time_HHiiss
} psiconv_sheet_numberformat_code_t;
typedef struct psiconv_sheet_numberformat_s
{
psiconv_sheet_numberformat_code_t code;
psiconv_u8 decimal;
} *psiconv_sheet_numberformat;
typedef struct psiconv_sheet_cell_layout_s
{
psiconv_character_layout character;
psiconv_paragraph_layout paragraph;
psiconv_sheet_numberformat numberformat;
} * psiconv_sheet_cell_layout;
typedef struct psiconv_sheet_cell_s
{
psiconv_u16 column;
psiconv_u16 row;
psiconv_cell_type_t type;
union {
psiconv_u32 dat_int;
double dat_float;
psiconv_string_t dat_string;
psiconv_bool_t dat_bool;
psiconv_sheet_errorcode_t dat_error;
} data;
psiconv_sheet_cell_layout layout;
psiconv_bool_t calculated;
psiconv_u32 ref_formula;
} *psiconv_sheet_cell;
typedef psiconv_list psiconv_sheet_cell_list;
/* Of struct psiconv_sheet_cell_s */
typedef struct psiconv_sheet_status_section_s
{
psiconv_bool_t show_graph;
psiconv_u32 cursor_row;
psiconv_u32 cursor_column;
psiconv_bool_t show_top_sheet_toolbar;
psiconv_bool_t show_side_sheet_toolbar;
psiconv_bool_t show_top_graph_toolbar;
psiconv_bool_t show_side_graph_toolbar;
psiconv_u32 sheet_display_size;
psiconv_u32 graph_display_size;
psiconv_triple_t show_horizontal_scrollbar;
psiconv_triple_t show_vertical_scrollbar;
} *psiconv_sheet_status_section;
typedef enum psiconv_formula_type
{
psiconv_formula_unknown,
psiconv_formula_op_lt,
psiconv_formula_op_le,
psiconv_formula_op_gt,
psiconv_formula_op_ge,
psiconv_formula_op_ne,
psiconv_formula_op_eq,
psiconv_formula_op_add,
psiconv_formula_op_sub,
psiconv_formula_op_mul,
psiconv_formula_op_div,
psiconv_formula_op_pow,
psiconv_formula_op_pos,
psiconv_formula_op_neg,
psiconv_formula_op_not,
psiconv_formula_op_and,
psiconv_formula_op_or,
psiconv_formula_op_con,
psiconv_formula_op_bra,
psiconv_formula_mark_eof,
psiconv_formula_dat_float,
psiconv_formula_dat_int,
psiconv_formula_dat_var,
psiconv_formula_dat_string,
psiconv_formula_dat_cellref,
psiconv_formula_dat_cellblock,
psiconv_formula_dat_vcellblock,
psiconv_formula_mark_opsep,
psiconv_formula_mark_opend,
psiconv_formula_fun_false,
psiconv_formula_fun_if,
psiconv_formula_fun_true,
psiconv_formula_fun_cell,
psiconv_formula_fun_errortype,
psiconv_formula_fun_isblank,
psiconv_formula_fun_iserr,
psiconv_formula_fun_iserror,
psiconv_formula_fun_islogical,
psiconv_formula_fun_isna,
psiconv_formula_fun_isnontext,
psiconv_formula_fun_isnumber,
psiconv_formula_fun_istext,
psiconv_formula_fun_n,
psiconv_formula_fun_type,
psiconv_formula_fun_address,
psiconv_formula_fun_column,
psiconv_formula_fun_columns,
psiconv_formula_fun_hlookup,
psiconv_formula_fun_index,
psiconv_formula_fun_indirect,
psiconv_formula_fun_lookup,
psiconv_formula_fun_offset,
psiconv_formula_fun_row,
psiconv_formula_fun_rows,
psiconv_formula_fun_vlookup,
psiconv_formula_fun_char,
psiconv_formula_fun_code,
psiconv_formula_fun_exact,
psiconv_formula_fun_find,
psiconv_formula_fun_left,
psiconv_formula_fun_len,
psiconv_formula_fun_lower,
psiconv_formula_fun_mid,
psiconv_formula_fun_proper,
psiconv_formula_fun_replace,
psiconv_formula_fun_rept,
psiconv_formula_fun_right,
psiconv_formula_fun_string,
psiconv_formula_fun_t,
psiconv_formula_fun_trim,
psiconv_formula_fun_upper,
psiconv_formula_fun_value,
psiconv_formula_fun_date,
psiconv_formula_fun_datevalue,
psiconv_formula_fun_day,
psiconv_formula_fun_hour,
psiconv_formula_fun_minute,
psiconv_formula_fun_month,
psiconv_formula_fun_now,
psiconv_formula_fun_second,
psiconv_formula_fun_today,
psiconv_formula_fun_time,
psiconv_formula_fun_timevalue,
psiconv_formula_fun_year,
psiconv_formula_fun_abs,
psiconv_formula_fun_acos,
psiconv_formula_fun_asin,
psiconv_formula_fun_atan,
psiconv_formula_fun_atan2,
psiconv_formula_fun_cos,
psiconv_formula_fun_degrees,
psiconv_formula_fun_exp,
psiconv_formula_fun_fact,
psiconv_formula_fun_int,
psiconv_formula_fun_ln,
psiconv_formula_fun_log10,
psiconv_formula_fun_mod,
psiconv_formula_fun_pi,
psiconv_formula_fun_radians,
psiconv_formula_fun_rand,
psiconv_formula_fun_round,
psiconv_formula_fun_sign,
psiconv_formula_fun_sin,
psiconv_formula_fun_sqrt,
psiconv_formula_fun_sumproduct,
psiconv_formula_fun_tan,
psiconv_formula_fun_trunc,
psiconv_formula_fun_cterm,
psiconv_formula_fun_ddb,
psiconv_formula_fun_fv,
psiconv_formula_fun_irr,
psiconv_formula_fun_npv,
psiconv_formula_fun_pmt,
psiconv_formula_fun_pv,
psiconv_formula_fun_rate,
psiconv_formula_fun_sln,
psiconv_formula_fun_syd,
psiconv_formula_fun_term,
psiconv_formula_fun_combin,
psiconv_formula_fun_permut,
psiconv_formula_vfn_average,
psiconv_formula_vfn_choose,
psiconv_formula_vfn_count,
psiconv_formula_vfn_counta,
psiconv_formula_vfn_countblank,
psiconv_formula_vfn_max,
psiconv_formula_vfn_min,
psiconv_formula_vfn_product,
psiconv_formula_vfn_stdevp,
psiconv_formula_vfn_stdev,
psiconv_formula_vfn_sum,
psiconv_formula_vfn_sumsq,
psiconv_formula_vfn_varp,
psiconv_formula_vfn_var
} psiconv_formula_type_t;
typedef psiconv_list psiconv_formula_list; /* Of struct psiconv_formula_s */
typedef struct psiconv_formula_s
{
psiconv_formula_type_t type;
union {
psiconv_u32 dat_int;
double dat_float;
psiconv_string_t dat_string;
psiconv_sheet_cell_reference_t dat_cellref;
psiconv_sheet_cell_block_t dat_cellblock;
psiconv_formula_list fun_operands;
psiconv_u32 dat_variable;
} data;
} *psiconv_formula;
typedef struct psiconv_sheet_line_s
{
psiconv_u32 position;
psiconv_sheet_cell_layout layout;
} *psiconv_sheet_line;
typedef psiconv_list psiconv_sheet_line_list;
/* Of struct psiconv_sheet_line_s */
typedef struct psiconv_sheet_grid_size_s
{
psiconv_u32 line_number;
psiconv_length_t size;
} *psiconv_sheet_grid_size;
typedef psiconv_list psiconv_sheet_grid_size_list;
/* Of struct psiconv_sheet_grid_size_s */
typedef psiconv_list psiconv_sheet_grid_break_list; /* of psiconv_u32 */
typedef struct psiconv_sheet_grid_section_s
{
psiconv_bool_t show_column_titles;
psiconv_bool_t show_row_titles;
psiconv_bool_t show_vertical_grid;
psiconv_bool_t show_horizontal_grid;
psiconv_bool_t freeze_rows;
psiconv_bool_t freeze_columns;
psiconv_u32 frozen_rows;
psiconv_u32 frozen_columns;
psiconv_u32 first_unfrozen_row_displayed;
psiconv_u32 first_unfrozen_column_displayed;
psiconv_bool_t show_page_breaks;
psiconv_u32 first_row;
psiconv_u32 first_column;
psiconv_u32 last_row;
psiconv_u32 last_column;
psiconv_length_t default_row_height;
psiconv_length_t default_column_width;
psiconv_sheet_grid_size_list row_heights;
psiconv_sheet_grid_size_list column_heights;
psiconv_sheet_grid_break_list row_page_breaks;
psiconv_sheet_grid_break_list column_page_breaks;
} *psiconv_sheet_grid_section;
typedef struct psiconv_sheet_worksheet_s
{
psiconv_sheet_cell_layout default_layout;
psiconv_sheet_cell_list cells;
psiconv_bool_t show_zeros;
psiconv_sheet_line_list row_default_layouts;
psiconv_sheet_line_list col_default_layouts;
psiconv_sheet_grid_section grid;
} *psiconv_sheet_worksheet;
typedef psiconv_list psiconv_sheet_worksheet_list;
/* of struct psiconv_sheet_worksheet_s */
typedef enum psiconv_variable_type
{
psiconv_var_int,
psiconv_var_float,
psiconv_var_string,
psiconv_var_cellref,
psiconv_var_cellblock
} psiconv_variable_type_t;
typedef struct psiconv_sheet_variable_s
{
psiconv_u32 number;
psiconv_string_t name;
psiconv_variable_type_t type;
union {
psiconv_s32 dat_int;
double dat_float;
psiconv_string_t dat_string;
psiconv_sheet_cell_reference_t dat_cellref;
psiconv_sheet_cell_block_t dat_cellblock;
} data;
} *psiconv_sheet_variable;
typedef psiconv_list psiconv_sheet_variable_list;
/* of struct psiconv_sheet_variable_s */
typedef struct psiconv_sheet_name_section_s
{
psiconv_string_t name;
} *psiconv_sheet_name_section;
typedef struct psiconv_sheet_info_section_s
{
psiconv_bool_t auto_recalc;
} *psiconv_sheet_info_section;
typedef struct psiconv_sheet_workbook_section_s
{
psiconv_formula_list formulas;
psiconv_sheet_worksheet_list worksheets;
psiconv_sheet_variable_list variables;
psiconv_sheet_info_section info;
psiconv_sheet_name_section name;
} *psiconv_sheet_workbook_section;
typedef struct psiconv_sheet_f_s
{
psiconv_page_layout_section page_sec;
psiconv_sheet_status_section status_sec;
psiconv_sheet_workbook_section workbook_sec;
} *psiconv_sheet_f;
/* NB: psiconv_file is already defined above */
struct psiconv_file_s
{
psiconv_file_type_t type;
void *file;
};
/* UID1 */
#define PSICONV_ID_PSION5 0x10000037
#define PSICONV_ID_CLIPART 0x10000041
/* UID2 */
#define PSICONV_ID_DATA_FILE 0x1000006D
#define PSICONV_ID_MBM_FILE 0x10000042
/* UID3 */
#define PSICONV_ID_WORD 0x1000007F
#define PSICONV_ID_TEXTED 0x10000085
#define PSICONV_ID_SKETCH 0x1000007D
#define PSICONV_ID_SHEET 0x10000088
/* Section table ids */
#define PSICONV_ID_WORD_STATUS_SECTION 0x10000243
#define PSICONV_ID_APPL_ID_SECTION 0x10000089
#define PSICONV_ID_TEXT_SECTION 0x10000106
#define PSICONV_ID_LAYOUT_SECTION 0x10000143
#define PSICONV_ID_WORD_STYLES_SECTION 0x10000104
#define PSICONV_ID_PAGE_LAYOUT_SECTION 0x10000105
#define PSICONV_ID_PASSWORD_SECTION 0x100000CD
#define PSICONV_ID_SKETCH_SECTION 0x1000007D
#define PSICONV_ID_SHEET_STATUS_SECTION 0x1000011F
#define PSICONV_ID_SHEET_WORKBOOK_SECTION 0x1000011D
#define PSICONV_ID_SHEET_GRAPH_SECTION 0x10000121
/* Other ids */
#define PSICONV_ID_PAGE_DIMENSIONS1 0x100000fd
#define PSICONV_ID_PAGE_DIMENSIONS2 0x1000010e
#define PSICONV_ID_TEXTED_BODY 0x1000005c
#define PSICONV_ID_TEXTED_REPLACEMENT 0x10000063
#define PSICONV_ID_TEXTED_UNKNOWN 0x10000065
#define PSICONV_ID_TEXTED_LAYOUT 0x10000066
#define PSICONV_ID_TEXTED_TEXT 0x10000064
#define PSICONV_ID_STYLE_REMOVABLE 0x1000004F
#define PSICONV_ID_STYLE_BUILT_IN 0x1000004C
#define PSICONV_ID_CLIPART_ITEM 0x10000040
#define PSICONV_ID_OBJECT 0x10000051
#define PSICONV_ID_OBJECT_DISPLAY_SECTION 0x10000146
#define PSICONV_ID_OBJECT_ICON_SECTION 0x1000012A
#define PSICONV_ID_OBJECT_SECTION_TABLE_SECTION 0x10000144
/* Return a clean layout_status. You can modify it at will. Returns NULL
if there is not enough memory. */
extern psiconv_character_layout psiconv_basic_character_layout(void);
/* Return a clean layout_status. You can modify it at will. Returns NULL
if there is not enough memory. */
extern psiconv_paragraph_layout psiconv_basic_paragraph_layout(void);
/* Clone a layout_status: the new copy is completely independent of the
original one. Returns NULL if there is not enough memory. */
extern psiconv_paragraph_layout psiconv_clone_paragraph_layout
(psiconv_paragraph_layout ls);
extern psiconv_character_layout psiconv_clone_character_layout
(psiconv_character_layout ls);
/* Get a numbered style. Returns NULL if the style is unknown. */
extern psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr);
/* Return the number corresponding to the stylename. Returns 0 on success,
an error code on failure. */
extern int psiconv_find_style(const psiconv_word_styles_section ss,
const psiconv_ucs2 *name,int *nr);
/* Get a numbered formula. Returns NULL if the style is unknown. */
extern psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr);
/* Return the default layout */
extern psiconv_sheet_cell_layout psiconv_get_default_layout
(psiconv_sheet_line_list row_defaults,
psiconv_sheet_line_list col_defaults,
psiconv_sheet_cell_layout cell_default,
int row,int col);
extern void psiconv_free_color(psiconv_color color);
extern void psiconv_free_border(psiconv_border border);
extern void psiconv_free_bullet(psiconv_bullet bullet);
extern void psiconv_free_font(psiconv_font font);
extern void psiconv_free_tab(psiconv_tab tab);
extern void psiconv_free_tabs(psiconv_all_tabs tabs);
extern void psiconv_free_paragraph_layout(psiconv_paragraph_layout layout);
extern void psiconv_free_character_layout(psiconv_character_layout layout);
extern void psiconv_free_word_style(psiconv_word_style style);
extern void psiconv_free_word_style_list(psiconv_word_style_list style_list);
extern void psiconv_free_word_styles_section
(psiconv_word_styles_section styles);
extern void psiconv_free_formula(psiconv_formula formula);
extern void psiconv_free_formula_list(psiconv_formula_list list);
extern void psiconv_free_sheet_status_section
(psiconv_sheet_status_section section);
extern void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout);
extern void psiconv_free_sheet_grid_break_list
(psiconv_sheet_grid_break_list list);
extern void psiconv_free_sheet_grid_size(psiconv_sheet_grid_size s);
extern void psiconv_free_sheet_grid_size_list
(psiconv_sheet_grid_size_list list);
extern void psiconv_free_sheet_grid_section(psiconv_sheet_grid_section sec);
extern void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet);
extern void psiconv_free_sheet_worksheet_list
(psiconv_sheet_worksheet_list list);
extern void psiconv_free_sheet_f(psiconv_sheet_f file);
extern void psiconv_free_sheet_cell(psiconv_sheet_cell cell);
extern void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list);
extern void psiconv_free_sheet_numberformat
(psiconv_sheet_numberformat numberformat);
extern void psiconv_free_sheet_line_list(psiconv_sheet_line_list list);
extern void psiconv_free_sheet_line(psiconv_sheet_line line);
extern void psiconv_free_sheet_name_section(psiconv_sheet_name_section section);
extern void psiconv_free_sheet_variable(psiconv_sheet_variable list);
extern void psiconv_free_sheet_variable_list(psiconv_sheet_variable_list list);
extern void psiconv_free_sheet_info_section(psiconv_sheet_info_section section);
extern void psiconv_free_sheet_workbook_section
(psiconv_sheet_workbook_section section);
extern void psiconv_free_header_section(psiconv_header_section header);
extern void psiconv_free_section_table_entry(psiconv_section_table_entry entry);
extern void psiconv_free_section_table_section
(psiconv_section_table_section section);
extern void psiconv_free_application_id_section
(psiconv_application_id_section section);
extern void psiconv_free_object_display_section
(psiconv_object_display_section section);
extern void psiconv_free_object_icon_section
(psiconv_object_icon_section section);
extern void psiconv_free_embedded_object_section
(psiconv_embedded_object_section object);
extern void psiconv_free_in_line_layout(psiconv_in_line_layout layout);
extern void psiconv_free_in_line_layouts(psiconv_in_line_layouts layouts);
extern void psiconv_free_replacement(psiconv_replacement replacement);
extern void psiconv_free_replacements(psiconv_replacements replacements);
extern void psiconv_free_paragraph(psiconv_paragraph paragraph);
extern void psiconv_free_text_and_layout(psiconv_text_and_layout text);
extern void psiconv_free_texted_section(psiconv_texted_section section);
extern void psiconv_free_page_header(psiconv_page_header header);
extern void psiconv_free_page_layout_section
(psiconv_page_layout_section section);
extern void psiconv_free_word_status_section
(psiconv_word_status_section section);
extern void psiconv_free_word_f(psiconv_word_f file);
extern void psiconv_free_texted_f(psiconv_texted_f file);
extern void psiconv_free_paint_data_section(psiconv_paint_data_section section);
extern void psiconv_free_pictures(psiconv_pictures section);
extern void psiconv_free_jumptable_section
(psiconv_jumptable_section section);
extern void psiconv_free_mbm_f(psiconv_mbm_f file);
extern void psiconv_free_sketch_section(psiconv_sketch_section sec);
extern void psiconv_free_sketch_f(psiconv_sketch_f file);
extern void psiconv_free_clipart_section(psiconv_clipart_section section);
extern void psiconv_free_cliparts(psiconv_cliparts section);
extern void psiconv_free_clipart_f(psiconv_clipart_f file);
extern void psiconv_free_file(psiconv_file file);
extern int psiconv_compare_color(const psiconv_color value1,
const psiconv_color value2);
extern int psiconv_compare_font(const psiconv_font value1,
const psiconv_font value2);
extern int psiconv_compare_border(const psiconv_border value1,
const psiconv_border value2);
extern int psiconv_compare_bullet(const psiconv_bullet value1,
const psiconv_bullet value2);
extern int psiconv_compare_tab(const psiconv_tab value1,
const psiconv_tab value2);
extern int psiconv_compare_all_tabs(const psiconv_all_tabs value1,
const psiconv_all_tabs value2);
extern int psiconv_compare_paragraph_layout
(const psiconv_paragraph_layout value1,
const psiconv_paragraph_layout value2);
extern int psiconv_compare_character_layout
(const psiconv_character_layout value1,
const psiconv_character_layout value2);
/* Get a newly allocated file with sensible defaults, ready to generate. */
extern psiconv_file psiconv_empty_file(psiconv_file_type_t type);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* def PSICONV_DATA_H */
psiconv-0.9.8/lib/psiconv/parse.h 0000644 0001750 0001750 00000004162 10336374670 013660 0000000 0000000 /*
parse.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Declarations only needed for the parser. If you want to parse, just
include this. */
#ifndef PSICONV_PARSE_H
#define PSICONV_PARSE_H
#include
#include
#include
#include
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern psiconv_file_type_t psiconv_file_type(psiconv_config config,
psiconv_buffer buf,
int *length,
psiconv_header_section *result);
/* Parses a Psion file. If its return-value is non-zero, something has
gone horribly wrong (badly corrupted file, or out of memory, usually),
and *result is undefined and unallocated; in normal cases, memory is
allocated to it and it is up to you to free it (using psiconv_free_file;
this is valid even if (*result)->file equals NULL).
Note that (*result)->file may be NULL if this file type is unknown
or unsupported! */
extern int psiconv_parse(psiconv_config config,
const psiconv_buffer buf,psiconv_file *result);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* def PSICONV_PARSE_H */
psiconv-0.9.8/lib/psiconv/list.h 0000644 0001750 0001750 00000012204 10336374667 013523 0000000 0000000 /*
list.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* A generic list type. In C++, this would be much neater. All elements must
be of the same size (solve it with pointers, if needed) */
#ifndef PSICONV_LIST_H
#define PSICONV_LIST_H
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Always use psiconv_list, never struct psiconv_list */
/* No need to export the actual internal format */
typedef struct psiconv_list_s *psiconv_list;
/* Before using a list, call list_new. It takes the size of a single element
as its argument. Always compute it with a sizeof() expression, just to be
safe. The returned list is empty.
If there is not enough memory available, NULL is returned. You should
always test for this explicitely, because the other functions do not
like a psiconv_list argument that is equal to NULL */
extern psiconv_list psiconv_list_new(size_t element_size);
/* This frees the list. If elements contain pointers that need to be freed
separately, call list_free_el below. */
extern void psiconv_list_free(psiconv_list l);
/* This calls free_el first for each element, before doing a list_free.
Note that you should *not* do 'free(el)' at any time; that is taken care of
automatically. */
extern void psiconv_list_free_el(psiconv_list l, void free_el(void *el));
/* Return the number of allocated elements */
extern psiconv_u32 psiconv_list_length(const psiconv_list l);
/* Return 1 if the list is empty, 0 if not */
extern int psiconv_list_is_empty(const psiconv_list l);
/* Empty a list. Note this does not reclaim any memory space! */
extern void psiconv_list_empty(psiconv_list l);
/* Get an element from the list, and return a pointer to it. Note: you can
directly modify this element, but be careful not to write beyond the
element memory space.
If indx is out of range, NULL is returned. */
extern void * psiconv_list_get(const psiconv_list l, psiconv_u32 indx);
/* Add an element at the end of the list. The element is copied from the
supplied element. Of course, this does not help if the element contains
pointers.
As the lists extends itself, it may be necessary to allocate new
memory. If this fails, a negative error-code is returned. If everything,
succeeds, 0 is returned. */
extern int psiconv_list_add(psiconv_list l, const void *el);
/* Remove the last element from the list, and copy it to el. Note that
this will not reduce the amount of space reserved for the list.
An error code is returned, which will be 0 zero if everything
succeeded. It is your own responsibility to make sure enough
space is allocated to el. */
extern int psiconv_list_pop(psiconv_list l, void *el);
/* Replace an element within the list. The element is copied from the
supplied element. Fails if you try to write at or after the end of
the list. */
extern int psiconv_list_replace(psiconv_list l, psiconv_u32 indx,
const void *el);
/* Do some action for each element. Note: you can directly modify the
elements supplied to action, and they will be changed in the list,
but never try a free(el)! */
extern void psiconv_list_foreach_el(psiconv_list l, void action(void *el));
/* Clone the list, that is, copy it. If elements contain pointers, you
should call the next routine. If not enough memory is available,
NULL is returned. */
extern psiconv_list psiconv_list_clone(const psiconv_list l);
/* Read upto size_t elements from file f, and put them at the end of list l.
Returned is the actual number of elements added. This assumes the file
layout and the memory layout of elements is the same. Note that if
not enough memory could be allocated, 0 is simply returned. */
extern size_t psiconv_list_fread(psiconv_list l,size_t size, FILE *f);
/* Read the whole file f to list l. Returns 0 on succes, and an errorcode
on failure. */
extern int psiconv_list_fread_all(psiconv_list l, FILE *f);
/* Write the whole list l to the opened file f. Returns 0 on succes, and
an errorcode on failure. */
extern int psiconv_list_fwrite_all(const psiconv_list l, FILE *f);
/* Concatenate two lists. The element sized does not have to be the same,
but the result may be quite unexpected if it is not. */
int psiconv_list_concat(psiconv_list l, const psiconv_list extra);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
psiconv-0.9.8/lib/psiconv/parse_routines.h 0000644 0001750 0001750 00000047743 10336374677 015633 0000000 0000000 /*
parse_routines.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PSICONV_PARSE_ROUTINES_H
#define PSICONV_PARSE_ROUTINES_H
#include
#include
#include
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* ******************
* parse_simple.c *
****************** */
extern psiconv_u8 psiconv_read_u8(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *status);
extern psiconv_u16 psiconv_read_u16(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *status);
extern psiconv_u32 psiconv_read_u32(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *status);
extern psiconv_s32 psiconv_read_sint(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length, int *status);
extern psiconv_u32 psiconv_read_S(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length, int *status);
extern psiconv_u32 psiconv_read_X(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length, int *status);
extern psiconv_length_t psiconv_read_length(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
int *status);
extern psiconv_size_t psiconv_read_size (const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
int *status);
extern psiconv_string_t psiconv_read_string(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off,int *length,
int *status);
extern psiconv_string_t psiconv_read_short_string(const psiconv_config config,
const psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,int *status);
extern psiconv_string_t psiconv_read_charlist(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int nrofchars,
int *status);
extern int psiconv_parse_bool(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_bool_t *result);
extern psiconv_float_t psiconv_read_float(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length, int *status);
/* ******************
* parse_layout.c *
****************** */
extern int psiconv_parse_color(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_color *result);
extern int psiconv_parse_font(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_font *result);
extern int psiconv_parse_border(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_border *result);
extern int psiconv_parse_bullet(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_bullet *result);
extern int psiconv_parse_tab(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_tab *result);
/* Note: the next two are special, because they modify an existing
layout structure! If it exits due to an unexpected error, part
of the structure may be modified, but it is still safe to call
psiconv_free_{paragraph,character}_layout_list on it (and that
is the only safe thing to do!) */
extern int psiconv_parse_paragraph_layout_list(const psiconv_config config,
const psiconv_buffer buf,
int lev, psiconv_u32 off, int *length,
psiconv_paragraph_layout result);
extern int psiconv_parse_character_layout_list(const psiconv_config config,
const psiconv_buffer buf,
int lev, psiconv_u32 off, int *length,
psiconv_character_layout result);
/* ****************
* parse_page.c *
**************** */
extern int psiconv_parse_page_header(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_page_header *result);
extern int psiconv_parse_page_layout_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_page_layout_section *result);
/* ******************
* parse_common.c *
****************** */
extern int psiconv_parse_header_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_header_section *result);
extern int psiconv_parse_section_table_section(const psiconv_config config,
const psiconv_buffer buf,
int lev, psiconv_u32 off,
int *length,
psiconv_section_table_section *result);
extern int psiconv_parse_application_id_section(const psiconv_config config,
const psiconv_buffer buf,
int lev, psiconv_u32 off, int *length,
psiconv_application_id_section *result);
extern int psiconv_parse_text_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_text_and_layout *result);
extern int psiconv_parse_styled_layout_section(const psiconv_config config,
const psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,
psiconv_text_and_layout result,
const psiconv_word_styles_section styles);
extern int psiconv_parse_styleless_layout_section(const psiconv_config config,
const psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,
psiconv_text_and_layout result,
const psiconv_character_layout base_char,
const psiconv_paragraph_layout base_para);
extern int psiconv_parse_embedded_object_section
(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_embedded_object_section *result);
extern int psiconv_parse_object_display_section(const psiconv_config config,
const psiconv_buffer buf,
int lev,
psiconv_u32 off, int *length,
psiconv_object_display_section *result);
extern int psiconv_parse_object_icon_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_object_icon_section *result);
/* ******************
* parse_texted.c *
****************** */
extern int psiconv_parse_texted_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_texted_section *result,
psiconv_character_layout base_char,
psiconv_paragraph_layout base_para);
/* ****************
* parse_word.c *
**************** */
extern int psiconv_parse_word_status_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_word_status_section *result);
extern int psiconv_parse_word_styles_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_word_styles_section *result);
/* *****************
* parse_sheet.c *
***************** */
extern int psiconv_parse_sheet_status_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_status_section *result);
extern int psiconv_parse_sheet_formula_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_formula_list *result);
extern int psiconv_parse_formula(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_formula *result);
extern int psiconv_parse_sheet_workbook_section(const psiconv_config config,
const psiconv_buffer buf,
int lev,
psiconv_u32 off, int *length,
psiconv_sheet_workbook_section *result);
extern int psiconv_parse_sheet_cell(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_cell *result,
const psiconv_sheet_cell_layout default_layout,
const psiconv_sheet_line_list row_default_layouts,
const psiconv_sheet_line_list col_default_layouts);
extern int psiconv_parse_sheet_cell_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_cell_list *result,
const psiconv_sheet_cell_layout default_layout,
const psiconv_sheet_line_list row_default_layouts,
const psiconv_sheet_line_list col_default_layouts);
extern int psiconv_parse_sheet_worksheet_list(const psiconv_config config,
const psiconv_buffer buf,
int lev,
psiconv_u32 off, int *length,
psiconv_sheet_worksheet_list *result);
extern int psiconv_parse_sheet_worksheet(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_worksheet *result);
extern int psiconv_parse_sheet_numberformat(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_numberformat result);
extern int psiconv_parse_sheet_cell_layout(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_cell_layout result);
extern int psiconv_parse_sheet_line(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_line *result,
const psiconv_sheet_cell_layout default_layout);
extern int psiconv_parse_sheet_line_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_line_list *result,
const psiconv_sheet_cell_layout default_layout);
extern int psiconv_parse_sheet_name_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_name_section *result);
extern int psiconv_parse_sheet_info_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_info_section *result);
extern int psiconv_parse_sheet_variable(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_variable *result);
extern int psiconv_parse_sheet_variable_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_variable_list *result);
extern int psiconv_parse_sheet_grid_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_grid_section *result);
extern int psiconv_parse_sheet_grid_size_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_grid_size_list *result);
extern int psiconv_parse_sheet_grid_size(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_grid_size *result);
extern int psiconv_parse_sheet_grid_break_list(const psiconv_config config,
const psiconv_buffer buf,
int lev, psiconv_u32 off, int *length,
psiconv_sheet_grid_break_list *result);
/* *****************
* parse_image.c *
***************** */
extern int psiconv_parse_paint_data_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
int isclipart,
psiconv_paint_data_section *result);
extern int psiconv_parse_jumptable_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_jumptable_section *result);
extern int psiconv_parse_sketch_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sketch_section *result);
extern int psiconv_parse_clipart_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_clipart_section *result);
/* ****************
* parse_driver.c *
**************** */
extern int psiconv_parse_texted_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, psiconv_texted_f *result);
extern int psiconv_parse_word_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, psiconv_word_f *result);
extern int psiconv_parse_mbm_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, psiconv_mbm_f *result);
extern int psiconv_parse_sketch_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, psiconv_sketch_f *result);
extern int psiconv_parse_clipart_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, psiconv_clipart_f *result);
extern int psiconv_parse_sheet_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, psiconv_sheet_f *result);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PSICONV_PARSE_ROUTINES_H */
psiconv-0.9.8/lib/psiconv/error.h 0000644 0001750 0001750 00000004100 10336374710 013662 0000000 0000000 /*
error.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PSICONV_ERROR_H
#define PSICONV_ERROR_H
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* These functions print error, warning, progress and debug information to
* stderr */
extern void psiconv_fatal(psiconv_config config,int level, psiconv_u32 off,
const char *format,...);
extern void psiconv_error(psiconv_config config,int level, psiconv_u32 off,
const char *format,...);
extern void psiconv_warn(psiconv_config config,int level, psiconv_u32 off,
const char *format,...);
extern void psiconv_progress(psiconv_config config,int level, psiconv_u32 off,
const char *format,...);
extern void psiconv_debug(psiconv_config config,int level, psiconv_u32 off,
const char *format,...);
#define PSICONV_VERB_DEBUG 5
#define PSICONV_VERB_PROGRESS 4
#define PSICONV_VERB_WARN 3
#define PSICONV_VERB_ERROR 2
#define PSICONV_VERB_FATAL 1
#define PSICONV_E_OK 0
#define PSICONV_E_OTHER 1
#define PSICONV_E_NOMEM 2
#define PSICONV_E_PARSE 3
#define PSICONV_E_GENERATE 4
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PSICONV_ERROR_H */
psiconv-0.9.8/lib/psiconv/generate_routines.h 0000644 0001750 0001750 00000024131 10336374732 016265 0000000 0000000 /*
generate_routines.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PSICONV_GENERATE_ROUTINES_H
#define PSICONV_GENERATE_ROUTINES_H
#include
#include
#include
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* *********************
* generate_simple.c *
********************* */
extern int psiconv_write_u8(const psiconv_config config,
psiconv_buffer buf,int lev,const psiconv_u8 value);
extern int psiconv_write_u16(const psiconv_config config,
psiconv_buffer buf,int lev,const psiconv_u16 value);
extern int psiconv_write_u32(const psiconv_config config,
psiconv_buffer buf,int lev,const psiconv_u32 value);
extern int psiconv_write_S(const psiconv_config config,
psiconv_buffer buf, int lev,const psiconv_u32 value);
extern int psiconv_write_X(const psiconv_config config,
psiconv_buffer buf, int lev,const psiconv_u32 value);
extern int psiconv_write_length(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_length_t value);
extern int psiconv_write_size(const psiconv_config config, psiconv_buffer buf,
int lev,const psiconv_size_t value);
extern int psiconv_write_bool(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_bool_t value);
extern int psiconv_write_short_string(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_string_t value);
extern int psiconv_write_string(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_string_t value);
int psiconv_write_charlist(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_string_t value);
extern int psiconv_write_offset(const psiconv_config config,
psiconv_buffer buf,int lev, const psiconv_u32 id);
/* *********************
* generate_layout.c *
********************* */
extern int psiconv_write_color(const psiconv_config config,
psiconv_buffer buf,int lev, const psiconv_color value);
extern int psiconv_write_font(const psiconv_config config,
psiconv_buffer buf,int lev, const psiconv_font value);
extern int psiconv_write_border(const psiconv_config config,
psiconv_buffer buf,int lev, const psiconv_border value);
extern int psiconv_write_bullet(const psiconv_config config,
psiconv_buffer buf,int lev, const psiconv_bullet value);
extern int psiconv_write_tab(const psiconv_config config,
psiconv_buffer buf,int lev,const psiconv_tab value);
extern int psiconv_write_paragraph_layout_list(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_paragraph_layout value,
const psiconv_paragraph_layout base);
extern int psiconv_write_character_layout_list(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_character_layout value,
const psiconv_character_layout base);
/* *******************
* generate_page.c *
******************* */
extern int psiconv_write_page_header(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_page_header value,
psiconv_buffer *extra_buf);
extern int psiconv_write_page_layout_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_page_layout_section value);
/* *********************
* generate_common.c *
********************* */
extern int psiconv_write_header_section(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_u32 uid1,
psiconv_u32 uid2, psiconv_u32 uid3);
extern int psiconv_write_section_table_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_section_table_section value);
extern int psiconv_write_application_id_section(const psiconv_config config,
psiconv_buffer buf,int lev,
psiconv_u32 id, const psiconv_string_t text);
extern int psiconv_write_text_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_text_and_layout value);
extern int psiconv_write_styled_layout_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_text_and_layout value,
const psiconv_word_styles_section styles);
extern int psiconv_write_styleless_layout_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_text_and_layout value,
const psiconv_character_layout base_char,
const psiconv_paragraph_layout base_para);
extern int psiconv_write_embedded_object_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_embedded_object_section value);
extern int psiconv_write_object_display_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_object_display_section value);
extern int psiconv_write_object_icon_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_object_icon_section value);
/* ********************
* generate_image.c *
******************** */
extern int psiconv_write_sketch_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_sketch_section value);
extern int psiconv_write_paint_data_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_paint_data_section value,
int is_clipart);
extern int psiconv_write_jumptable_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_jumptable_section value);
extern int psiconv_write_clipart_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_clipart_section value);
/* *********************
* generate_texted.c *
********************* */
extern int psiconv_write_texted_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_texted_section value,
const psiconv_character_layout base_char,
const psiconv_paragraph_layout base_para,
psiconv_buffer *extra_buf);
/* *******************
* generate_word.c *
******************* */
extern int psiconv_write_word_status_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_word_status_section value);
extern int psiconv_write_word_styles_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_word_styles_section value);
/* *********************
* generate_driver.c *
********************* */
extern int psiconv_write_word_file(const psiconv_config config,
psiconv_buffer buf,int lev,const psiconv_word_f value);
extern int psiconv_write_texted_file(const psiconv_config config,
psiconv_buffer buf,int lev,
psiconv_texted_f value);
extern int psiconv_write_sketch_file(const psiconv_config config,
psiconv_buffer buf,int lev,const psiconv_sketch_f value);
extern int psiconv_write_mbm_file(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_mbm_f value);
extern int psiconv_write_clipart_file(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_clipart_f value);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PSICONV_GENERATE_ROUTINES_H */
psiconv-0.9.8/lib/psiconv/generate.h 0000644 0001750 0001750 00000003305 10336374735 014340 0000000 0000000 /*
generate.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Declarations only needed for the parser. If you want to parse, just
include this. */
#ifndef PSICONV_GENERATE_H
#define PSICONV_GENERATE_H
#include
#include
#include
#include
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Generate a Psion file. If its return-value is non-zero, something has
gone horribly wrong (badly corrupted data, or out of memory, usually),
and *buf is undefined and unallocated; in normal cases, memory is
allocated to it and it is up to you to free it.
*/
extern int psiconv_write(psiconv_config config, psiconv_buffer *buf,
const psiconv_file value);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* def PSICONV_GENERATE_H */
psiconv-0.9.8/lib/psiconv/common.h 0000644 0001750 0001750 00000003510 10336374722 014030 0000000 0000000 /*
common.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999, 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Declarations only needed for the parser. If you want to parse, just
include this. */
#ifndef PSICONV_COMMON_H
#define PSICONV_COMMON_H
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* ***************
* misc.c *
*************** */
/* This function returns a copy of a Unicode string, converted to plain ASCII.
Anything codepage dependent (> 128) is sanitized away.
You should free this string yourself when you are
done with it. Returns NULL if there is not enough memory left. */
extern char *psiconv_make_printable(const psiconv_config config,
const psiconv_string_t s);
/* **************
* checkuid.c *
************** */
extern psiconv_u32 psiconv_checkuid(psiconv_u32 uid1,
psiconv_u32 uid2,psiconv_u32 uid3);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* def PSICONV_COMMON_H */
psiconv-0.9.8/lib/psiconv/buffer.h 0000644 0001750 0001750 00000010644 10336374712 014016 0000000 0000000 /*
buffer.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PSICONV_BUFFER_H
#define PSICONV_BUFFER_H
/* A psiconv_buffer is a buffer of raw byte data. It is used when parsing
or generating a Psion file. You can use references within it that
are resolved at a later time. */
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Always use psiconv_buffer, never struct psiconv_buffer_s */
/* No need to export the actual internal format */
typedef struct psiconv_buffer_s *psiconv_buffer;
/* Allocate a new buffer. Returns NULL when not enough memory is available.
All other functions assume you have called this function first! */
extern psiconv_buffer psiconv_buffer_new(void);
/* Free a buffer and reclaim its memory. Never use a buffer again after
calling this (unless you do a psiconv_buffer_new on it first) */
extern void psiconv_buffer_free(psiconv_buffer buf);
/* Get the length of the data */
extern psiconv_u32 psiconv_buffer_length(const psiconv_buffer buf);
/* Get one byte of data. Returns NULL if you are trying to read past
the end of the buffer. Do not use this; instead use psiconv_read_u8
and friends */
extern psiconv_u8 *psiconv_buffer_get(const psiconv_buffer buf,
psiconv_u32 off);
/* Add one byte of data to the end. Returns 0 on success, and an error
code on failure. Do not use this; instead use psiconv_write_u8 and
friends */
extern int psiconv_buffer_add(psiconv_buffer buf,psiconv_u8 data);
/* Do an fread to the buffer. Returns the number of read bytes. See
fread(3) for more information. */
extern size_t psiconv_buffer_fread(psiconv_buffer buf,size_t size, FILE *f);
/* Read a complete file to the buffer. Returns 0 on success, and an
error code on failure. */
extern int psiconv_buffer_fread_all(psiconv_buffer buf, FILE *f);
/* Write a complete buffer to file. Returns 0 on success, and an
error code on failure. */
extern int psiconv_buffer_fwrite_all(const psiconv_buffer buf, FILE *f);
/* Concatenate two buffers: the second buffer is appended to the first.
References are updated too. Buffer extra is untouched after this and must
still be freed if you want to get rid of it. */
extern int psiconv_buffer_concat(psiconv_buffer buf,
const psiconv_buffer extra);
/* Add a target to the reference list. This does not really change the
buffer data in any way. The id needs to be unique. The target is
added at the current end of the buffer. */
extern int psiconv_buffer_add_target(psiconv_buffer buf, int id);
/* Add a reference to a target to the reference list. The id does not
need to be defined already, though it must be by the time you call
psiconv_buffer_resolve. The reference is added to the current end
of the buffer, and space is allocated for it. References are always
longs (psiconv_u32). */
extern int psiconv_buffer_add_reference(psiconv_buffer buf,int id);
/* Resolve all references and empty the reference list. */
extern int psiconv_buffer_resolve(psiconv_buffer buf);
/* Get a unique reference id */
extern psiconv_u32 psiconv_buffer_unique_id(void);
/* Extract part of a buffer and put it into a new buffer. Note that
references and targets are not copied; you will have to resolve them
beforehand (but as this function is meant for reading buffers, they
will usually not be used). */
extern int psiconv_buffer_subbuffer(psiconv_buffer *buf,
const psiconv_buffer org,
psiconv_u32 offset, psiconv_u32 length);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* def PSICONV_BUFFER_H */
psiconv-0.9.8/lib/psiconv/unicode.h 0000644 0001750 0001750 00000005643 10336374726 014203 0000000 0000000 /*
unicode.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2003-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PSICONV_UNICODE_H
#define PSICONV_UNICODE_H
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* A simple unicode implementation, using UCS-2 (16-bit encoding).
Unicode strings are arrays of psiconv_u16 characters, zero-terminated.
Note that there is a lot in Unicode we do not support; for example,
we assume a single Unicode codepoint corresponds with a single character.
For EPOC, that should be enough */
extern int psiconv_unicode_select_characterset(const psiconv_config config,
int charset);
/* Translate a single character to a unicode character, using the
translation tables in config */
extern psiconv_ucs2 psiconv_unicode_read_char(const psiconv_config config,
psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,
int *status);
extern int psiconv_unicode_write_char(const psiconv_config config,
psiconv_buffer buf,
int lev,
psiconv_ucs2 value);
/* Compute the length of a unicode string */
extern int psiconv_unicode_strlen(const psiconv_ucs2 *input);
/* Duplicate a unicode string */
extern psiconv_ucs2 *psiconv_unicode_strdup(const psiconv_ucs2 *input);
/* Compare two unicode strings. Ordering as in Unicode codepoints! */
extern int psiconv_unicode_strcmp(const psiconv_ucs2 *str1, const psiconv_ucs2 *str2);
/* Return a newly allocated empty string */
extern psiconv_ucs2 *psiconv_unicode_empty_string(void);
/* Convert a psiconv_list of psiconv_ucs2 characters to a string */
extern psiconv_ucs2 *psiconv_unicode_from_list(psiconv_list input);
/* Look for needle in haystack, return pointer to found location */
extern psiconv_ucs2 *psiconv_unicode_strstr(const psiconv_ucs2 *haystack,
const psiconv_ucs2 *needle);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PSICONV_ERROR_H */
psiconv-0.9.8/lib/psiconv/general.h 0000664 0001750 0001750 00000002661 10336413033 014152 0000000 0000000 /*
data.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* All declarations which you may need to edit are here. At a later time,
this will be superseded by some automatic configuration script. */
#ifndef PSICONV_GENERAL_H
#define PSICONV_GENERAL_H
/* Data types; s8 means `signed 8-bit integer', u32 means `unsigned 32-bits
integer'. Configure figures out which types to use.
*/
typedef signed char psiconv_s8;
typedef unsigned char psiconv_u8;
typedef signed short psiconv_s16;
typedef unsigned short psiconv_u16;
typedef signed int psiconv_s32;
typedef unsigned int psiconv_u32;
typedef psiconv_u16 psiconv_ucs2;
#endif /* def PSICONV_GENERAL_H */
psiconv-0.9.8/lib/psiconv/Makefile.am 0000644 0001750 0001750 00000002114 10044276432 014415 0000000 0000000 INCLUDES=-I.. -I../../compat
lib_LTLIBRARIES = libpsiconv.la
libpsiconv_la_SOURCES = configuration.c error.c misc.c checkuid.c list.c \
buffer.c data.c image.c unicode.c \
parse_common.c parse_driver.c parse_formula.c \
parse_layout.c parse_image.c parse_page.c \
parse_simple.c parse_texted.c parse_word.c \
parse_sheet.c \
generate_simple.c generate_layout.c generate_driver.c \
generate_common.c generate_texted.c generate_page.c \
generate_word.c generate_image.c
libpsiconv_la_LDFLAGS = -version-info 10:2:4
libpsiconv_la_LIBADD = ../../compat/libcompat.la
libpsiconv_la_CFLAGS = -DPSICONVETCDIR=\"@PSICONVETCDIR@\"
psiconvincludedir = $(includedir)/psiconv
psiconvinclude_HEADERS = configuration.h data.h parse.h list.h \
parse_routines.h \
error.h generate_routines.h generate.h common.h \
buffer.h unicode.h general.h
noinst_HEADERS = image.h
psiconv-0.9.8/lib/psiconv/Makefile.in 0000664 0001750 0001750 00000342267 10336413007 014443 0000000 0000000 # Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(libpsiconv_la_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = lib/psiconv
DIST_COMMON = $(noinst_HEADERS) $(psiconvinclude_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/general.h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = general.h
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(psiconvincludedir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libpsiconv_la_DEPENDENCIES = ../../compat/libcompat.la
am_libpsiconv_la_OBJECTS = libpsiconv_la-configuration.lo \
libpsiconv_la-error.lo libpsiconv_la-misc.lo \
libpsiconv_la-checkuid.lo libpsiconv_la-list.lo \
libpsiconv_la-buffer.lo libpsiconv_la-data.lo \
libpsiconv_la-image.lo libpsiconv_la-unicode.lo \
libpsiconv_la-parse_common.lo libpsiconv_la-parse_driver.lo \
libpsiconv_la-parse_formula.lo libpsiconv_la-parse_layout.lo \
libpsiconv_la-parse_image.lo libpsiconv_la-parse_page.lo \
libpsiconv_la-parse_simple.lo libpsiconv_la-parse_texted.lo \
libpsiconv_la-parse_word.lo libpsiconv_la-parse_sheet.lo \
libpsiconv_la-generate_simple.lo \
libpsiconv_la-generate_layout.lo \
libpsiconv_la-generate_driver.lo \
libpsiconv_la-generate_common.lo \
libpsiconv_la-generate_texted.lo \
libpsiconv_la-generate_page.lo libpsiconv_la-generate_word.lo \
libpsiconv_la-generate_image.lo
libpsiconv_la_OBJECTS = $(am_libpsiconv_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/libpsiconv_la-buffer.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-checkuid.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-configuration.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-data.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-error.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-generate_common.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-generate_driver.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-generate_image.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-generate_layout.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-generate_page.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-generate_simple.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-generate_texted.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-generate_word.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-image.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-list.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-misc.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_common.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_driver.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_formula.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_image.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_layout.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_page.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_sheet.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_simple.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_texted.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-parse_word.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/libpsiconv_la-unicode.Plo
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libpsiconv_la_SOURCES)
DIST_SOURCES = $(libpsiconv_la_SOURCES)
psiconvincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(noinst_HEADERS) $(psiconvinclude_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOCS_FALSE = @ASCIIDOCS_FALSE@
ASCIIDOCS_TRUE = @ASCIIDOCS_TRUE@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
HTML4DOCS_FALSE = @HTML4DOCS_FALSE@
HTML4DOCS_TRUE = @HTML4DOCS_TRUE@
IMAGEMAGICK = @IMAGEMAGICK@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INT_16_BIT = @INT_16_BIT@
INT_32_BIT = @INT_32_BIT@
INT_8_BIT = @INT_8_BIT@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_DMALLOC = @LIB_DMALLOC@
LIB_MAGICK = @LIB_MAGICK@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PSICONVETCDIR = @PSICONVETCDIR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XHTMLDOCS_FALSE = @XHTMLDOCS_FALSE@
XHTMLDOCS_TRUE = @XHTMLDOCS_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
cflags_set = @cflags_set@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
INCLUDES = -I.. -I../../compat
lib_LTLIBRARIES = libpsiconv.la
libpsiconv_la_SOURCES = configuration.c error.c misc.c checkuid.c list.c \
buffer.c data.c image.c unicode.c \
parse_common.c parse_driver.c parse_formula.c \
parse_layout.c parse_image.c parse_page.c \
parse_simple.c parse_texted.c parse_word.c \
parse_sheet.c \
generate_simple.c generate_layout.c generate_driver.c \
generate_common.c generate_texted.c generate_page.c \
generate_word.c generate_image.c
libpsiconv_la_LDFLAGS = -version-info 10:2:4
libpsiconv_la_LIBADD = ../../compat/libcompat.la
libpsiconv_la_CFLAGS = -DPSICONVETCDIR=\"@PSICONVETCDIR@\"
psiconvincludedir = $(includedir)/psiconv
psiconvinclude_HEADERS = configuration.h data.h parse.h list.h \
parse_routines.h \
error.h generate_routines.h generate.h common.h \
buffer.h unicode.h general.h
noinst_HEADERS = image.h
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/psiconv/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu lib/psiconv/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
general.h: $(top_builddir)/config.status $(srcdir)/general.h.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libpsiconv.la: $(libpsiconv_la_OBJECTS) $(libpsiconv_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libpsiconv_la_LDFLAGS) $(libpsiconv_la_OBJECTS) $(libpsiconv_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-buffer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-checkuid.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-configuration.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-data.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-error.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-generate_common.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-generate_driver.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-generate_image.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-generate_layout.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-generate_page.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-generate_simple.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-generate_texted.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-generate_word.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-image.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-list.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-misc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_common.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_driver.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_formula.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_image.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_layout.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_page.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_sheet.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_simple.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_texted.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-parse_word.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsiconv_la-unicode.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
libpsiconv_la-configuration.o: configuration.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-configuration.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-configuration.Tpo" -c -o libpsiconv_la-configuration.o `test -f 'configuration.c' || echo '$(srcdir)/'`configuration.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-configuration.Tpo" "$(DEPDIR)/libpsiconv_la-configuration.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-configuration.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='configuration.c' object='libpsiconv_la-configuration.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-configuration.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-configuration.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-configuration.o `test -f 'configuration.c' || echo '$(srcdir)/'`configuration.c
libpsiconv_la-configuration.obj: configuration.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-configuration.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-configuration.Tpo" -c -o libpsiconv_la-configuration.obj `if test -f 'configuration.c'; then $(CYGPATH_W) 'configuration.c'; else $(CYGPATH_W) '$(srcdir)/configuration.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-configuration.Tpo" "$(DEPDIR)/libpsiconv_la-configuration.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-configuration.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='configuration.c' object='libpsiconv_la-configuration.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-configuration.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-configuration.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-configuration.obj `if test -f 'configuration.c'; then $(CYGPATH_W) 'configuration.c'; else $(CYGPATH_W) '$(srcdir)/configuration.c'; fi`
libpsiconv_la-configuration.lo: configuration.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-configuration.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-configuration.Tpo" -c -o libpsiconv_la-configuration.lo `test -f 'configuration.c' || echo '$(srcdir)/'`configuration.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-configuration.Tpo" "$(DEPDIR)/libpsiconv_la-configuration.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-configuration.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='configuration.c' object='libpsiconv_la-configuration.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-configuration.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-configuration.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-configuration.lo `test -f 'configuration.c' || echo '$(srcdir)/'`configuration.c
libpsiconv_la-error.o: error.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-error.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-error.Tpo" -c -o libpsiconv_la-error.o `test -f 'error.c' || echo '$(srcdir)/'`error.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-error.Tpo" "$(DEPDIR)/libpsiconv_la-error.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-error.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error.c' object='libpsiconv_la-error.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-error.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-error.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-error.o `test -f 'error.c' || echo '$(srcdir)/'`error.c
libpsiconv_la-error.obj: error.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-error.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-error.Tpo" -c -o libpsiconv_la-error.obj `if test -f 'error.c'; then $(CYGPATH_W) 'error.c'; else $(CYGPATH_W) '$(srcdir)/error.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-error.Tpo" "$(DEPDIR)/libpsiconv_la-error.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-error.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error.c' object='libpsiconv_la-error.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-error.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-error.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-error.obj `if test -f 'error.c'; then $(CYGPATH_W) 'error.c'; else $(CYGPATH_W) '$(srcdir)/error.c'; fi`
libpsiconv_la-error.lo: error.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-error.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-error.Tpo" -c -o libpsiconv_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-error.Tpo" "$(DEPDIR)/libpsiconv_la-error.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-error.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error.c' object='libpsiconv_la-error.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-error.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-error.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c
libpsiconv_la-misc.o: misc.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-misc.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-misc.Tpo" -c -o libpsiconv_la-misc.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-misc.Tpo" "$(DEPDIR)/libpsiconv_la-misc.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-misc.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libpsiconv_la-misc.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-misc.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-misc.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-misc.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
libpsiconv_la-misc.obj: misc.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-misc.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-misc.Tpo" -c -o libpsiconv_la-misc.obj `if test -f 'misc.c'; then $(CYGPATH_W) 'misc.c'; else $(CYGPATH_W) '$(srcdir)/misc.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-misc.Tpo" "$(DEPDIR)/libpsiconv_la-misc.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-misc.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libpsiconv_la-misc.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-misc.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-misc.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-misc.obj `if test -f 'misc.c'; then $(CYGPATH_W) 'misc.c'; else $(CYGPATH_W) '$(srcdir)/misc.c'; fi`
libpsiconv_la-misc.lo: misc.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-misc.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-misc.Tpo" -c -o libpsiconv_la-misc.lo `test -f 'misc.c' || echo '$(srcdir)/'`misc.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-misc.Tpo" "$(DEPDIR)/libpsiconv_la-misc.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-misc.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libpsiconv_la-misc.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-misc.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-misc.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-misc.lo `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
libpsiconv_la-checkuid.o: checkuid.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-checkuid.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-checkuid.Tpo" -c -o libpsiconv_la-checkuid.o `test -f 'checkuid.c' || echo '$(srcdir)/'`checkuid.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-checkuid.Tpo" "$(DEPDIR)/libpsiconv_la-checkuid.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-checkuid.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='checkuid.c' object='libpsiconv_la-checkuid.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-checkuid.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-checkuid.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-checkuid.o `test -f 'checkuid.c' || echo '$(srcdir)/'`checkuid.c
libpsiconv_la-checkuid.obj: checkuid.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-checkuid.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-checkuid.Tpo" -c -o libpsiconv_la-checkuid.obj `if test -f 'checkuid.c'; then $(CYGPATH_W) 'checkuid.c'; else $(CYGPATH_W) '$(srcdir)/checkuid.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-checkuid.Tpo" "$(DEPDIR)/libpsiconv_la-checkuid.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-checkuid.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='checkuid.c' object='libpsiconv_la-checkuid.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-checkuid.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-checkuid.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-checkuid.obj `if test -f 'checkuid.c'; then $(CYGPATH_W) 'checkuid.c'; else $(CYGPATH_W) '$(srcdir)/checkuid.c'; fi`
libpsiconv_la-checkuid.lo: checkuid.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-checkuid.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-checkuid.Tpo" -c -o libpsiconv_la-checkuid.lo `test -f 'checkuid.c' || echo '$(srcdir)/'`checkuid.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-checkuid.Tpo" "$(DEPDIR)/libpsiconv_la-checkuid.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-checkuid.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='checkuid.c' object='libpsiconv_la-checkuid.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-checkuid.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-checkuid.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-checkuid.lo `test -f 'checkuid.c' || echo '$(srcdir)/'`checkuid.c
libpsiconv_la-list.o: list.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-list.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-list.Tpo" -c -o libpsiconv_la-list.o `test -f 'list.c' || echo '$(srcdir)/'`list.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-list.Tpo" "$(DEPDIR)/libpsiconv_la-list.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-list.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='list.c' object='libpsiconv_la-list.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-list.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-list.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-list.o `test -f 'list.c' || echo '$(srcdir)/'`list.c
libpsiconv_la-list.obj: list.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-list.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-list.Tpo" -c -o libpsiconv_la-list.obj `if test -f 'list.c'; then $(CYGPATH_W) 'list.c'; else $(CYGPATH_W) '$(srcdir)/list.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-list.Tpo" "$(DEPDIR)/libpsiconv_la-list.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-list.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='list.c' object='libpsiconv_la-list.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-list.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-list.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-list.obj `if test -f 'list.c'; then $(CYGPATH_W) 'list.c'; else $(CYGPATH_W) '$(srcdir)/list.c'; fi`
libpsiconv_la-list.lo: list.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-list.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-list.Tpo" -c -o libpsiconv_la-list.lo `test -f 'list.c' || echo '$(srcdir)/'`list.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-list.Tpo" "$(DEPDIR)/libpsiconv_la-list.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-list.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='list.c' object='libpsiconv_la-list.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-list.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-list.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-list.lo `test -f 'list.c' || echo '$(srcdir)/'`list.c
libpsiconv_la-buffer.o: buffer.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-buffer.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-buffer.Tpo" -c -o libpsiconv_la-buffer.o `test -f 'buffer.c' || echo '$(srcdir)/'`buffer.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-buffer.Tpo" "$(DEPDIR)/libpsiconv_la-buffer.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-buffer.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='buffer.c' object='libpsiconv_la-buffer.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-buffer.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-buffer.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-buffer.o `test -f 'buffer.c' || echo '$(srcdir)/'`buffer.c
libpsiconv_la-buffer.obj: buffer.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-buffer.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-buffer.Tpo" -c -o libpsiconv_la-buffer.obj `if test -f 'buffer.c'; then $(CYGPATH_W) 'buffer.c'; else $(CYGPATH_W) '$(srcdir)/buffer.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-buffer.Tpo" "$(DEPDIR)/libpsiconv_la-buffer.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-buffer.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='buffer.c' object='libpsiconv_la-buffer.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-buffer.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-buffer.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-buffer.obj `if test -f 'buffer.c'; then $(CYGPATH_W) 'buffer.c'; else $(CYGPATH_W) '$(srcdir)/buffer.c'; fi`
libpsiconv_la-buffer.lo: buffer.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-buffer.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-buffer.Tpo" -c -o libpsiconv_la-buffer.lo `test -f 'buffer.c' || echo '$(srcdir)/'`buffer.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-buffer.Tpo" "$(DEPDIR)/libpsiconv_la-buffer.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-buffer.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='buffer.c' object='libpsiconv_la-buffer.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-buffer.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-buffer.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-buffer.lo `test -f 'buffer.c' || echo '$(srcdir)/'`buffer.c
libpsiconv_la-data.o: data.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-data.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-data.Tpo" -c -o libpsiconv_la-data.o `test -f 'data.c' || echo '$(srcdir)/'`data.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-data.Tpo" "$(DEPDIR)/libpsiconv_la-data.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-data.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='data.c' object='libpsiconv_la-data.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-data.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-data.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-data.o `test -f 'data.c' || echo '$(srcdir)/'`data.c
libpsiconv_la-data.obj: data.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-data.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-data.Tpo" -c -o libpsiconv_la-data.obj `if test -f 'data.c'; then $(CYGPATH_W) 'data.c'; else $(CYGPATH_W) '$(srcdir)/data.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-data.Tpo" "$(DEPDIR)/libpsiconv_la-data.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-data.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='data.c' object='libpsiconv_la-data.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-data.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-data.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-data.obj `if test -f 'data.c'; then $(CYGPATH_W) 'data.c'; else $(CYGPATH_W) '$(srcdir)/data.c'; fi`
libpsiconv_la-data.lo: data.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-data.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-data.Tpo" -c -o libpsiconv_la-data.lo `test -f 'data.c' || echo '$(srcdir)/'`data.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-data.Tpo" "$(DEPDIR)/libpsiconv_la-data.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-data.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='data.c' object='libpsiconv_la-data.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-data.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-data.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-data.lo `test -f 'data.c' || echo '$(srcdir)/'`data.c
libpsiconv_la-image.o: image.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-image.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-image.Tpo" -c -o libpsiconv_la-image.o `test -f 'image.c' || echo '$(srcdir)/'`image.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-image.Tpo" "$(DEPDIR)/libpsiconv_la-image.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='image.c' object='libpsiconv_la-image.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-image.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-image.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-image.o `test -f 'image.c' || echo '$(srcdir)/'`image.c
libpsiconv_la-image.obj: image.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-image.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-image.Tpo" -c -o libpsiconv_la-image.obj `if test -f 'image.c'; then $(CYGPATH_W) 'image.c'; else $(CYGPATH_W) '$(srcdir)/image.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-image.Tpo" "$(DEPDIR)/libpsiconv_la-image.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='image.c' object='libpsiconv_la-image.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-image.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-image.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-image.obj `if test -f 'image.c'; then $(CYGPATH_W) 'image.c'; else $(CYGPATH_W) '$(srcdir)/image.c'; fi`
libpsiconv_la-image.lo: image.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-image.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-image.Tpo" -c -o libpsiconv_la-image.lo `test -f 'image.c' || echo '$(srcdir)/'`image.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-image.Tpo" "$(DEPDIR)/libpsiconv_la-image.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='image.c' object='libpsiconv_la-image.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-image.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-image.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-image.lo `test -f 'image.c' || echo '$(srcdir)/'`image.c
libpsiconv_la-unicode.o: unicode.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-unicode.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-unicode.Tpo" -c -o libpsiconv_la-unicode.o `test -f 'unicode.c' || echo '$(srcdir)/'`unicode.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-unicode.Tpo" "$(DEPDIR)/libpsiconv_la-unicode.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-unicode.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='unicode.c' object='libpsiconv_la-unicode.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-unicode.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-unicode.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-unicode.o `test -f 'unicode.c' || echo '$(srcdir)/'`unicode.c
libpsiconv_la-unicode.obj: unicode.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-unicode.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-unicode.Tpo" -c -o libpsiconv_la-unicode.obj `if test -f 'unicode.c'; then $(CYGPATH_W) 'unicode.c'; else $(CYGPATH_W) '$(srcdir)/unicode.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-unicode.Tpo" "$(DEPDIR)/libpsiconv_la-unicode.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-unicode.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='unicode.c' object='libpsiconv_la-unicode.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-unicode.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-unicode.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-unicode.obj `if test -f 'unicode.c'; then $(CYGPATH_W) 'unicode.c'; else $(CYGPATH_W) '$(srcdir)/unicode.c'; fi`
libpsiconv_la-unicode.lo: unicode.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-unicode.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-unicode.Tpo" -c -o libpsiconv_la-unicode.lo `test -f 'unicode.c' || echo '$(srcdir)/'`unicode.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-unicode.Tpo" "$(DEPDIR)/libpsiconv_la-unicode.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-unicode.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='unicode.c' object='libpsiconv_la-unicode.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-unicode.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-unicode.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-unicode.lo `test -f 'unicode.c' || echo '$(srcdir)/'`unicode.c
libpsiconv_la-parse_common.o: parse_common.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_common.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_common.Tpo" -c -o libpsiconv_la-parse_common.o `test -f 'parse_common.c' || echo '$(srcdir)/'`parse_common.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_common.Tpo" "$(DEPDIR)/libpsiconv_la-parse_common.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_common.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_common.c' object='libpsiconv_la-parse_common.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_common.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_common.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_common.o `test -f 'parse_common.c' || echo '$(srcdir)/'`parse_common.c
libpsiconv_la-parse_common.obj: parse_common.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_common.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_common.Tpo" -c -o libpsiconv_la-parse_common.obj `if test -f 'parse_common.c'; then $(CYGPATH_W) 'parse_common.c'; else $(CYGPATH_W) '$(srcdir)/parse_common.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_common.Tpo" "$(DEPDIR)/libpsiconv_la-parse_common.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_common.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_common.c' object='libpsiconv_la-parse_common.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_common.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_common.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_common.obj `if test -f 'parse_common.c'; then $(CYGPATH_W) 'parse_common.c'; else $(CYGPATH_W) '$(srcdir)/parse_common.c'; fi`
libpsiconv_la-parse_common.lo: parse_common.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_common.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_common.Tpo" -c -o libpsiconv_la-parse_common.lo `test -f 'parse_common.c' || echo '$(srcdir)/'`parse_common.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_common.Tpo" "$(DEPDIR)/libpsiconv_la-parse_common.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_common.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_common.c' object='libpsiconv_la-parse_common.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_common.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_common.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_common.lo `test -f 'parse_common.c' || echo '$(srcdir)/'`parse_common.c
libpsiconv_la-parse_driver.o: parse_driver.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_driver.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo" -c -o libpsiconv_la-parse_driver.o `test -f 'parse_driver.c' || echo '$(srcdir)/'`parse_driver.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo" "$(DEPDIR)/libpsiconv_la-parse_driver.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_driver.c' object='libpsiconv_la-parse_driver.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_driver.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_driver.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_driver.o `test -f 'parse_driver.c' || echo '$(srcdir)/'`parse_driver.c
libpsiconv_la-parse_driver.obj: parse_driver.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_driver.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo" -c -o libpsiconv_la-parse_driver.obj `if test -f 'parse_driver.c'; then $(CYGPATH_W) 'parse_driver.c'; else $(CYGPATH_W) '$(srcdir)/parse_driver.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo" "$(DEPDIR)/libpsiconv_la-parse_driver.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_driver.c' object='libpsiconv_la-parse_driver.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_driver.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_driver.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_driver.obj `if test -f 'parse_driver.c'; then $(CYGPATH_W) 'parse_driver.c'; else $(CYGPATH_W) '$(srcdir)/parse_driver.c'; fi`
libpsiconv_la-parse_driver.lo: parse_driver.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_driver.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo" -c -o libpsiconv_la-parse_driver.lo `test -f 'parse_driver.c' || echo '$(srcdir)/'`parse_driver.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo" "$(DEPDIR)/libpsiconv_la-parse_driver.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_driver.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_driver.c' object='libpsiconv_la-parse_driver.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_driver.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_driver.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_driver.lo `test -f 'parse_driver.c' || echo '$(srcdir)/'`parse_driver.c
libpsiconv_la-parse_formula.o: parse_formula.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_formula.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo" -c -o libpsiconv_la-parse_formula.o `test -f 'parse_formula.c' || echo '$(srcdir)/'`parse_formula.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo" "$(DEPDIR)/libpsiconv_la-parse_formula.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_formula.c' object='libpsiconv_la-parse_formula.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_formula.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_formula.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_formula.o `test -f 'parse_formula.c' || echo '$(srcdir)/'`parse_formula.c
libpsiconv_la-parse_formula.obj: parse_formula.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_formula.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo" -c -o libpsiconv_la-parse_formula.obj `if test -f 'parse_formula.c'; then $(CYGPATH_W) 'parse_formula.c'; else $(CYGPATH_W) '$(srcdir)/parse_formula.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo" "$(DEPDIR)/libpsiconv_la-parse_formula.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_formula.c' object='libpsiconv_la-parse_formula.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_formula.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_formula.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_formula.obj `if test -f 'parse_formula.c'; then $(CYGPATH_W) 'parse_formula.c'; else $(CYGPATH_W) '$(srcdir)/parse_formula.c'; fi`
libpsiconv_la-parse_formula.lo: parse_formula.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_formula.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo" -c -o libpsiconv_la-parse_formula.lo `test -f 'parse_formula.c' || echo '$(srcdir)/'`parse_formula.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo" "$(DEPDIR)/libpsiconv_la-parse_formula.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_formula.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_formula.c' object='libpsiconv_la-parse_formula.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_formula.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_formula.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_formula.lo `test -f 'parse_formula.c' || echo '$(srcdir)/'`parse_formula.c
libpsiconv_la-parse_layout.o: parse_layout.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_layout.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo" -c -o libpsiconv_la-parse_layout.o `test -f 'parse_layout.c' || echo '$(srcdir)/'`parse_layout.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo" "$(DEPDIR)/libpsiconv_la-parse_layout.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_layout.c' object='libpsiconv_la-parse_layout.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_layout.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_layout.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_layout.o `test -f 'parse_layout.c' || echo '$(srcdir)/'`parse_layout.c
libpsiconv_la-parse_layout.obj: parse_layout.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_layout.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo" -c -o libpsiconv_la-parse_layout.obj `if test -f 'parse_layout.c'; then $(CYGPATH_W) 'parse_layout.c'; else $(CYGPATH_W) '$(srcdir)/parse_layout.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo" "$(DEPDIR)/libpsiconv_la-parse_layout.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_layout.c' object='libpsiconv_la-parse_layout.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_layout.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_layout.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_layout.obj `if test -f 'parse_layout.c'; then $(CYGPATH_W) 'parse_layout.c'; else $(CYGPATH_W) '$(srcdir)/parse_layout.c'; fi`
libpsiconv_la-parse_layout.lo: parse_layout.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_layout.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo" -c -o libpsiconv_la-parse_layout.lo `test -f 'parse_layout.c' || echo '$(srcdir)/'`parse_layout.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo" "$(DEPDIR)/libpsiconv_la-parse_layout.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_layout.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_layout.c' object='libpsiconv_la-parse_layout.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_layout.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_layout.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_layout.lo `test -f 'parse_layout.c' || echo '$(srcdir)/'`parse_layout.c
libpsiconv_la-parse_image.o: parse_image.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_image.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_image.Tpo" -c -o libpsiconv_la-parse_image.o `test -f 'parse_image.c' || echo '$(srcdir)/'`parse_image.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_image.Tpo" "$(DEPDIR)/libpsiconv_la-parse_image.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_image.c' object='libpsiconv_la-parse_image.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_image.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_image.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_image.o `test -f 'parse_image.c' || echo '$(srcdir)/'`parse_image.c
libpsiconv_la-parse_image.obj: parse_image.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_image.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_image.Tpo" -c -o libpsiconv_la-parse_image.obj `if test -f 'parse_image.c'; then $(CYGPATH_W) 'parse_image.c'; else $(CYGPATH_W) '$(srcdir)/parse_image.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_image.Tpo" "$(DEPDIR)/libpsiconv_la-parse_image.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_image.c' object='libpsiconv_la-parse_image.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_image.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_image.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_image.obj `if test -f 'parse_image.c'; then $(CYGPATH_W) 'parse_image.c'; else $(CYGPATH_W) '$(srcdir)/parse_image.c'; fi`
libpsiconv_la-parse_image.lo: parse_image.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_image.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_image.Tpo" -c -o libpsiconv_la-parse_image.lo `test -f 'parse_image.c' || echo '$(srcdir)/'`parse_image.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_image.Tpo" "$(DEPDIR)/libpsiconv_la-parse_image.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_image.c' object='libpsiconv_la-parse_image.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_image.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_image.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_image.lo `test -f 'parse_image.c' || echo '$(srcdir)/'`parse_image.c
libpsiconv_la-parse_page.o: parse_page.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_page.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_page.Tpo" -c -o libpsiconv_la-parse_page.o `test -f 'parse_page.c' || echo '$(srcdir)/'`parse_page.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_page.Tpo" "$(DEPDIR)/libpsiconv_la-parse_page.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_page.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_page.c' object='libpsiconv_la-parse_page.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_page.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_page.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_page.o `test -f 'parse_page.c' || echo '$(srcdir)/'`parse_page.c
libpsiconv_la-parse_page.obj: parse_page.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_page.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_page.Tpo" -c -o libpsiconv_la-parse_page.obj `if test -f 'parse_page.c'; then $(CYGPATH_W) 'parse_page.c'; else $(CYGPATH_W) '$(srcdir)/parse_page.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_page.Tpo" "$(DEPDIR)/libpsiconv_la-parse_page.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_page.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_page.c' object='libpsiconv_la-parse_page.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_page.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_page.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_page.obj `if test -f 'parse_page.c'; then $(CYGPATH_W) 'parse_page.c'; else $(CYGPATH_W) '$(srcdir)/parse_page.c'; fi`
libpsiconv_la-parse_page.lo: parse_page.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_page.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_page.Tpo" -c -o libpsiconv_la-parse_page.lo `test -f 'parse_page.c' || echo '$(srcdir)/'`parse_page.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_page.Tpo" "$(DEPDIR)/libpsiconv_la-parse_page.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_page.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_page.c' object='libpsiconv_la-parse_page.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_page.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_page.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_page.lo `test -f 'parse_page.c' || echo '$(srcdir)/'`parse_page.c
libpsiconv_la-parse_simple.o: parse_simple.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_simple.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo" -c -o libpsiconv_la-parse_simple.o `test -f 'parse_simple.c' || echo '$(srcdir)/'`parse_simple.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo" "$(DEPDIR)/libpsiconv_la-parse_simple.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_simple.c' object='libpsiconv_la-parse_simple.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_simple.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_simple.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_simple.o `test -f 'parse_simple.c' || echo '$(srcdir)/'`parse_simple.c
libpsiconv_la-parse_simple.obj: parse_simple.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_simple.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo" -c -o libpsiconv_la-parse_simple.obj `if test -f 'parse_simple.c'; then $(CYGPATH_W) 'parse_simple.c'; else $(CYGPATH_W) '$(srcdir)/parse_simple.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo" "$(DEPDIR)/libpsiconv_la-parse_simple.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_simple.c' object='libpsiconv_la-parse_simple.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_simple.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_simple.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_simple.obj `if test -f 'parse_simple.c'; then $(CYGPATH_W) 'parse_simple.c'; else $(CYGPATH_W) '$(srcdir)/parse_simple.c'; fi`
libpsiconv_la-parse_simple.lo: parse_simple.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_simple.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo" -c -o libpsiconv_la-parse_simple.lo `test -f 'parse_simple.c' || echo '$(srcdir)/'`parse_simple.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo" "$(DEPDIR)/libpsiconv_la-parse_simple.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_simple.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_simple.c' object='libpsiconv_la-parse_simple.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_simple.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_simple.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_simple.lo `test -f 'parse_simple.c' || echo '$(srcdir)/'`parse_simple.c
libpsiconv_la-parse_texted.o: parse_texted.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_texted.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo" -c -o libpsiconv_la-parse_texted.o `test -f 'parse_texted.c' || echo '$(srcdir)/'`parse_texted.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo" "$(DEPDIR)/libpsiconv_la-parse_texted.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_texted.c' object='libpsiconv_la-parse_texted.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_texted.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_texted.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_texted.o `test -f 'parse_texted.c' || echo '$(srcdir)/'`parse_texted.c
libpsiconv_la-parse_texted.obj: parse_texted.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_texted.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo" -c -o libpsiconv_la-parse_texted.obj `if test -f 'parse_texted.c'; then $(CYGPATH_W) 'parse_texted.c'; else $(CYGPATH_W) '$(srcdir)/parse_texted.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo" "$(DEPDIR)/libpsiconv_la-parse_texted.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_texted.c' object='libpsiconv_la-parse_texted.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_texted.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_texted.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_texted.obj `if test -f 'parse_texted.c'; then $(CYGPATH_W) 'parse_texted.c'; else $(CYGPATH_W) '$(srcdir)/parse_texted.c'; fi`
libpsiconv_la-parse_texted.lo: parse_texted.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_texted.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo" -c -o libpsiconv_la-parse_texted.lo `test -f 'parse_texted.c' || echo '$(srcdir)/'`parse_texted.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo" "$(DEPDIR)/libpsiconv_la-parse_texted.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_texted.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_texted.c' object='libpsiconv_la-parse_texted.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_texted.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_texted.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_texted.lo `test -f 'parse_texted.c' || echo '$(srcdir)/'`parse_texted.c
libpsiconv_la-parse_word.o: parse_word.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_word.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_word.Tpo" -c -o libpsiconv_la-parse_word.o `test -f 'parse_word.c' || echo '$(srcdir)/'`parse_word.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_word.Tpo" "$(DEPDIR)/libpsiconv_la-parse_word.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_word.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_word.c' object='libpsiconv_la-parse_word.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_word.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_word.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_word.o `test -f 'parse_word.c' || echo '$(srcdir)/'`parse_word.c
libpsiconv_la-parse_word.obj: parse_word.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_word.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_word.Tpo" -c -o libpsiconv_la-parse_word.obj `if test -f 'parse_word.c'; then $(CYGPATH_W) 'parse_word.c'; else $(CYGPATH_W) '$(srcdir)/parse_word.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_word.Tpo" "$(DEPDIR)/libpsiconv_la-parse_word.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_word.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_word.c' object='libpsiconv_la-parse_word.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_word.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_word.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_word.obj `if test -f 'parse_word.c'; then $(CYGPATH_W) 'parse_word.c'; else $(CYGPATH_W) '$(srcdir)/parse_word.c'; fi`
libpsiconv_la-parse_word.lo: parse_word.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_word.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_word.Tpo" -c -o libpsiconv_la-parse_word.lo `test -f 'parse_word.c' || echo '$(srcdir)/'`parse_word.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_word.Tpo" "$(DEPDIR)/libpsiconv_la-parse_word.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_word.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_word.c' object='libpsiconv_la-parse_word.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_word.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_word.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_word.lo `test -f 'parse_word.c' || echo '$(srcdir)/'`parse_word.c
libpsiconv_la-parse_sheet.o: parse_sheet.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_sheet.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo" -c -o libpsiconv_la-parse_sheet.o `test -f 'parse_sheet.c' || echo '$(srcdir)/'`parse_sheet.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo" "$(DEPDIR)/libpsiconv_la-parse_sheet.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_sheet.c' object='libpsiconv_la-parse_sheet.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_sheet.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_sheet.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_sheet.o `test -f 'parse_sheet.c' || echo '$(srcdir)/'`parse_sheet.c
libpsiconv_la-parse_sheet.obj: parse_sheet.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_sheet.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo" -c -o libpsiconv_la-parse_sheet.obj `if test -f 'parse_sheet.c'; then $(CYGPATH_W) 'parse_sheet.c'; else $(CYGPATH_W) '$(srcdir)/parse_sheet.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo" "$(DEPDIR)/libpsiconv_la-parse_sheet.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_sheet.c' object='libpsiconv_la-parse_sheet.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_sheet.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_sheet.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_sheet.obj `if test -f 'parse_sheet.c'; then $(CYGPATH_W) 'parse_sheet.c'; else $(CYGPATH_W) '$(srcdir)/parse_sheet.c'; fi`
libpsiconv_la-parse_sheet.lo: parse_sheet.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-parse_sheet.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo" -c -o libpsiconv_la-parse_sheet.lo `test -f 'parse_sheet.c' || echo '$(srcdir)/'`parse_sheet.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo" "$(DEPDIR)/libpsiconv_la-parse_sheet.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-parse_sheet.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse_sheet.c' object='libpsiconv_la-parse_sheet.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-parse_sheet.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-parse_sheet.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-parse_sheet.lo `test -f 'parse_sheet.c' || echo '$(srcdir)/'`parse_sheet.c
libpsiconv_la-generate_simple.o: generate_simple.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_simple.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo" -c -o libpsiconv_la-generate_simple.o `test -f 'generate_simple.c' || echo '$(srcdir)/'`generate_simple.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo" "$(DEPDIR)/libpsiconv_la-generate_simple.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_simple.c' object='libpsiconv_la-generate_simple.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_simple.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_simple.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_simple.o `test -f 'generate_simple.c' || echo '$(srcdir)/'`generate_simple.c
libpsiconv_la-generate_simple.obj: generate_simple.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_simple.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo" -c -o libpsiconv_la-generate_simple.obj `if test -f 'generate_simple.c'; then $(CYGPATH_W) 'generate_simple.c'; else $(CYGPATH_W) '$(srcdir)/generate_simple.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo" "$(DEPDIR)/libpsiconv_la-generate_simple.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_simple.c' object='libpsiconv_la-generate_simple.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_simple.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_simple.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_simple.obj `if test -f 'generate_simple.c'; then $(CYGPATH_W) 'generate_simple.c'; else $(CYGPATH_W) '$(srcdir)/generate_simple.c'; fi`
libpsiconv_la-generate_simple.lo: generate_simple.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_simple.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo" -c -o libpsiconv_la-generate_simple.lo `test -f 'generate_simple.c' || echo '$(srcdir)/'`generate_simple.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo" "$(DEPDIR)/libpsiconv_la-generate_simple.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_simple.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_simple.c' object='libpsiconv_la-generate_simple.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_simple.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_simple.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_simple.lo `test -f 'generate_simple.c' || echo '$(srcdir)/'`generate_simple.c
libpsiconv_la-generate_layout.o: generate_layout.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_layout.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo" -c -o libpsiconv_la-generate_layout.o `test -f 'generate_layout.c' || echo '$(srcdir)/'`generate_layout.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo" "$(DEPDIR)/libpsiconv_la-generate_layout.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_layout.c' object='libpsiconv_la-generate_layout.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_layout.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_layout.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_layout.o `test -f 'generate_layout.c' || echo '$(srcdir)/'`generate_layout.c
libpsiconv_la-generate_layout.obj: generate_layout.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_layout.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo" -c -o libpsiconv_la-generate_layout.obj `if test -f 'generate_layout.c'; then $(CYGPATH_W) 'generate_layout.c'; else $(CYGPATH_W) '$(srcdir)/generate_layout.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo" "$(DEPDIR)/libpsiconv_la-generate_layout.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_layout.c' object='libpsiconv_la-generate_layout.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_layout.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_layout.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_layout.obj `if test -f 'generate_layout.c'; then $(CYGPATH_W) 'generate_layout.c'; else $(CYGPATH_W) '$(srcdir)/generate_layout.c'; fi`
libpsiconv_la-generate_layout.lo: generate_layout.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_layout.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo" -c -o libpsiconv_la-generate_layout.lo `test -f 'generate_layout.c' || echo '$(srcdir)/'`generate_layout.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo" "$(DEPDIR)/libpsiconv_la-generate_layout.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_layout.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_layout.c' object='libpsiconv_la-generate_layout.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_layout.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_layout.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_layout.lo `test -f 'generate_layout.c' || echo '$(srcdir)/'`generate_layout.c
libpsiconv_la-generate_driver.o: generate_driver.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_driver.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo" -c -o libpsiconv_la-generate_driver.o `test -f 'generate_driver.c' || echo '$(srcdir)/'`generate_driver.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo" "$(DEPDIR)/libpsiconv_la-generate_driver.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_driver.c' object='libpsiconv_la-generate_driver.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_driver.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_driver.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_driver.o `test -f 'generate_driver.c' || echo '$(srcdir)/'`generate_driver.c
libpsiconv_la-generate_driver.obj: generate_driver.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_driver.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo" -c -o libpsiconv_la-generate_driver.obj `if test -f 'generate_driver.c'; then $(CYGPATH_W) 'generate_driver.c'; else $(CYGPATH_W) '$(srcdir)/generate_driver.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo" "$(DEPDIR)/libpsiconv_la-generate_driver.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_driver.c' object='libpsiconv_la-generate_driver.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_driver.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_driver.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_driver.obj `if test -f 'generate_driver.c'; then $(CYGPATH_W) 'generate_driver.c'; else $(CYGPATH_W) '$(srcdir)/generate_driver.c'; fi`
libpsiconv_la-generate_driver.lo: generate_driver.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_driver.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo" -c -o libpsiconv_la-generate_driver.lo `test -f 'generate_driver.c' || echo '$(srcdir)/'`generate_driver.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo" "$(DEPDIR)/libpsiconv_la-generate_driver.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_driver.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_driver.c' object='libpsiconv_la-generate_driver.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_driver.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_driver.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_driver.lo `test -f 'generate_driver.c' || echo '$(srcdir)/'`generate_driver.c
libpsiconv_la-generate_common.o: generate_common.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_common.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_common.Tpo" -c -o libpsiconv_la-generate_common.o `test -f 'generate_common.c' || echo '$(srcdir)/'`generate_common.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_common.Tpo" "$(DEPDIR)/libpsiconv_la-generate_common.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_common.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_common.c' object='libpsiconv_la-generate_common.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_common.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_common.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_common.o `test -f 'generate_common.c' || echo '$(srcdir)/'`generate_common.c
libpsiconv_la-generate_common.obj: generate_common.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_common.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_common.Tpo" -c -o libpsiconv_la-generate_common.obj `if test -f 'generate_common.c'; then $(CYGPATH_W) 'generate_common.c'; else $(CYGPATH_W) '$(srcdir)/generate_common.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_common.Tpo" "$(DEPDIR)/libpsiconv_la-generate_common.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_common.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_common.c' object='libpsiconv_la-generate_common.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_common.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_common.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_common.obj `if test -f 'generate_common.c'; then $(CYGPATH_W) 'generate_common.c'; else $(CYGPATH_W) '$(srcdir)/generate_common.c'; fi`
libpsiconv_la-generate_common.lo: generate_common.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_common.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_common.Tpo" -c -o libpsiconv_la-generate_common.lo `test -f 'generate_common.c' || echo '$(srcdir)/'`generate_common.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_common.Tpo" "$(DEPDIR)/libpsiconv_la-generate_common.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_common.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_common.c' object='libpsiconv_la-generate_common.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_common.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_common.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_common.lo `test -f 'generate_common.c' || echo '$(srcdir)/'`generate_common.c
libpsiconv_la-generate_texted.o: generate_texted.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_texted.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo" -c -o libpsiconv_la-generate_texted.o `test -f 'generate_texted.c' || echo '$(srcdir)/'`generate_texted.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo" "$(DEPDIR)/libpsiconv_la-generate_texted.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_texted.c' object='libpsiconv_la-generate_texted.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_texted.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_texted.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_texted.o `test -f 'generate_texted.c' || echo '$(srcdir)/'`generate_texted.c
libpsiconv_la-generate_texted.obj: generate_texted.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_texted.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo" -c -o libpsiconv_la-generate_texted.obj `if test -f 'generate_texted.c'; then $(CYGPATH_W) 'generate_texted.c'; else $(CYGPATH_W) '$(srcdir)/generate_texted.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo" "$(DEPDIR)/libpsiconv_la-generate_texted.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_texted.c' object='libpsiconv_la-generate_texted.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_texted.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_texted.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_texted.obj `if test -f 'generate_texted.c'; then $(CYGPATH_W) 'generate_texted.c'; else $(CYGPATH_W) '$(srcdir)/generate_texted.c'; fi`
libpsiconv_la-generate_texted.lo: generate_texted.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_texted.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo" -c -o libpsiconv_la-generate_texted.lo `test -f 'generate_texted.c' || echo '$(srcdir)/'`generate_texted.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo" "$(DEPDIR)/libpsiconv_la-generate_texted.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_texted.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_texted.c' object='libpsiconv_la-generate_texted.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_texted.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_texted.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_texted.lo `test -f 'generate_texted.c' || echo '$(srcdir)/'`generate_texted.c
libpsiconv_la-generate_page.o: generate_page.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_page.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_page.Tpo" -c -o libpsiconv_la-generate_page.o `test -f 'generate_page.c' || echo '$(srcdir)/'`generate_page.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_page.Tpo" "$(DEPDIR)/libpsiconv_la-generate_page.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_page.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_page.c' object='libpsiconv_la-generate_page.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_page.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_page.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_page.o `test -f 'generate_page.c' || echo '$(srcdir)/'`generate_page.c
libpsiconv_la-generate_page.obj: generate_page.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_page.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_page.Tpo" -c -o libpsiconv_la-generate_page.obj `if test -f 'generate_page.c'; then $(CYGPATH_W) 'generate_page.c'; else $(CYGPATH_W) '$(srcdir)/generate_page.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_page.Tpo" "$(DEPDIR)/libpsiconv_la-generate_page.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_page.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_page.c' object='libpsiconv_la-generate_page.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_page.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_page.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_page.obj `if test -f 'generate_page.c'; then $(CYGPATH_W) 'generate_page.c'; else $(CYGPATH_W) '$(srcdir)/generate_page.c'; fi`
libpsiconv_la-generate_page.lo: generate_page.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_page.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_page.Tpo" -c -o libpsiconv_la-generate_page.lo `test -f 'generate_page.c' || echo '$(srcdir)/'`generate_page.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_page.Tpo" "$(DEPDIR)/libpsiconv_la-generate_page.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_page.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_page.c' object='libpsiconv_la-generate_page.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_page.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_page.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_page.lo `test -f 'generate_page.c' || echo '$(srcdir)/'`generate_page.c
libpsiconv_la-generate_word.o: generate_word.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_word.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_word.Tpo" -c -o libpsiconv_la-generate_word.o `test -f 'generate_word.c' || echo '$(srcdir)/'`generate_word.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_word.Tpo" "$(DEPDIR)/libpsiconv_la-generate_word.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_word.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_word.c' object='libpsiconv_la-generate_word.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_word.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_word.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_word.o `test -f 'generate_word.c' || echo '$(srcdir)/'`generate_word.c
libpsiconv_la-generate_word.obj: generate_word.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_word.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_word.Tpo" -c -o libpsiconv_la-generate_word.obj `if test -f 'generate_word.c'; then $(CYGPATH_W) 'generate_word.c'; else $(CYGPATH_W) '$(srcdir)/generate_word.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_word.Tpo" "$(DEPDIR)/libpsiconv_la-generate_word.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_word.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_word.c' object='libpsiconv_la-generate_word.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_word.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_word.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_word.obj `if test -f 'generate_word.c'; then $(CYGPATH_W) 'generate_word.c'; else $(CYGPATH_W) '$(srcdir)/generate_word.c'; fi`
libpsiconv_la-generate_word.lo: generate_word.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_word.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_word.Tpo" -c -o libpsiconv_la-generate_word.lo `test -f 'generate_word.c' || echo '$(srcdir)/'`generate_word.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_word.Tpo" "$(DEPDIR)/libpsiconv_la-generate_word.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_word.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_word.c' object='libpsiconv_la-generate_word.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_word.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_word.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_word.lo `test -f 'generate_word.c' || echo '$(srcdir)/'`generate_word.c
libpsiconv_la-generate_image.o: generate_image.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_image.o -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_image.Tpo" -c -o libpsiconv_la-generate_image.o `test -f 'generate_image.c' || echo '$(srcdir)/'`generate_image.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_image.Tpo" "$(DEPDIR)/libpsiconv_la-generate_image.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_image.c' object='libpsiconv_la-generate_image.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_image.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_image.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_image.o `test -f 'generate_image.c' || echo '$(srcdir)/'`generate_image.c
libpsiconv_la-generate_image.obj: generate_image.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_image.obj -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_image.Tpo" -c -o libpsiconv_la-generate_image.obj `if test -f 'generate_image.c'; then $(CYGPATH_W) 'generate_image.c'; else $(CYGPATH_W) '$(srcdir)/generate_image.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_image.Tpo" "$(DEPDIR)/libpsiconv_la-generate_image.Po"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_image.c' object='libpsiconv_la-generate_image.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_image.Po' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_image.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_image.obj `if test -f 'generate_image.c'; then $(CYGPATH_W) 'generate_image.c'; else $(CYGPATH_W) '$(srcdir)/generate_image.c'; fi`
libpsiconv_la-generate_image.lo: generate_image.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -MT libpsiconv_la-generate_image.lo -MD -MP -MF "$(DEPDIR)/libpsiconv_la-generate_image.Tpo" -c -o libpsiconv_la-generate_image.lo `test -f 'generate_image.c' || echo '$(srcdir)/'`generate_image.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libpsiconv_la-generate_image.Tpo" "$(DEPDIR)/libpsiconv_la-generate_image.Plo"; else rm -f "$(DEPDIR)/libpsiconv_la-generate_image.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='generate_image.c' object='libpsiconv_la-generate_image.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libpsiconv_la-generate_image.Plo' tmpdepfile='$(DEPDIR)/libpsiconv_la-generate_image.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsiconv_la_CFLAGS) $(CFLAGS) -c -o libpsiconv_la-generate_image.lo `test -f 'generate_image.c' || echo '$(srcdir)/'`generate_image.c
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-psiconvincludeHEADERS: $(psiconvinclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(psiconvincludedir)" || $(mkdir_p) "$(DESTDIR)$(psiconvincludedir)"
@list='$(psiconvinclude_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(psiconvincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(psiconvincludedir)/$$f'"; \
$(psiconvincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(psiconvincludedir)/$$f"; \
done
uninstall-psiconvincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(psiconvinclude_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f '$(DESTDIR)$(psiconvincludedir)/$$f'"; \
rm -f "$(DESTDIR)$(psiconvincludedir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(psiconvincludedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-psiconvincludeHEADERS
install-exec-am: install-libLTLIBRARIES
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
uninstall-psiconvincludeHEADERS
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am \
install-libLTLIBRARIES install-man \
install-psiconvincludeHEADERS install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libLTLIBRARIES uninstall-psiconvincludeHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
psiconv-0.9.8/lib/psiconv/general.h.in 0000644 0001750 0001750 00000002737 10336374664 014601 0000000 0000000 /*
data.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* All declarations which you may need to edit are here. At a later time,
this will be superseded by some automatic configuration script. */
#ifndef PSICONV_GENERAL_H
#define PSICONV_GENERAL_H
/* Data types; s8 means `signed 8-bit integer', u32 means `unsigned 32-bits
integer'. Configure figures out which types to use.
*/
typedef signed @INT_8_BIT@ psiconv_s8;
typedef unsigned @INT_8_BIT@ psiconv_u8;
typedef signed @INT_16_BIT@ psiconv_s16;
typedef unsigned @INT_16_BIT@ psiconv_u16;
typedef signed @INT_32_BIT@ psiconv_s32;
typedef unsigned @INT_32_BIT@ psiconv_u32;
typedef psiconv_u16 psiconv_ucs2;
#endif /* def PSICONV_GENERAL_H */
psiconv-0.9.8/lib/psiconv/configuration.c 0000644 0001750 0001750 00000027223 10336374730 015410 0000000 0000000 /*
configuration.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include "error.h"
#include "unicode.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "configuration.h"
#ifdef DMALLOC
#include
#endif
#ifndef CONFIGURATION_SEARCH_PATH
#define CONFIGURATION_SEARCH_PATH PSICONVETCDIR "/psiconv.conf:~/.psiconv.conf"
#endif
static struct psiconv_config_s default_config =
{ PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL,'?','?',{ 0 },psiconv_bool_false };
static void psiconv_config_parse_statement(const char *filename,
int linenr,
const char *var, int value,
psiconv_config *config);
static void psiconv_config_parse_line(const char *filename, int linenr,
const char *line, psiconv_config *config);
static void psiconv_config_parse_file(const char *filename,
psiconv_config *config);
psiconv_config psiconv_config_default(void)
{
psiconv_config result;
result = malloc(sizeof(*result));
*result = default_config;
psiconv_unicode_select_characterset(result,1);
return result;
}
void psiconv_config_free(psiconv_config config)
{
free(config);
}
void psiconv_config_parse_statement(const char *filename,
int linenr,
const char *var, int value,
psiconv_config *config)
{
int charnr;
if (!(strcasecmp(var,"verbosity"))) {
if ((value >= 1) && (value <= 5))
(*config)->verbosity = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Verbosity should be between 1 and 5",filename,linenr);
} else if (!(strcasecmp(var,"color"))) {
if ((value == 0) || (value == 1))
(*config)->color = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Color should be 0 or 1",filename,linenr);
} else if (!(strcasecmp(var,"colordepth"))) {
if ((value > 0) && (value <= 32))
(*config)->colordepth = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"ColorDepth should be between 1 and 32",filename,linenr);
} else if (!(strcasecmp(var,"redbits"))) {
if ((value >= 0) && (value <= 32))
(*config)->redbits = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"RedBits should be between 1 and 32 or 0",filename,linenr);
} else if (!(strcasecmp(var,"greenbits"))) {
if ((value >= 0) && (value <= 32))
(*config)->greenbits = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"GreenBits should be between 1 and 32 or 0",filename,linenr);
} else if (!(strcasecmp(var,"bluebits"))) {
if ((value >= 0) && (value <= 32))
(*config)->bluebits = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"BlueBits should be between 1 and 32 or 0",filename,linenr);
} else if (!(strcasecmp(var,"characterset"))) {
if ((value >= 0) && (value <= 1))
psiconv_unicode_select_characterset(*config,value);
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"CharacterSet should be between 0 and 1",
filename,linenr);
} else if (!(strcasecmp(var,"unknownunicodechar"))) {
if ((value >= 1) && (value < 0x10000))
(*config)->unknown_unicode_char = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"UnknownUnicodeChar should be between 1 and 65535",
filename,linenr);
} else if (!(strcasecmp(var,"unknownepocchar"))) {
if ((value >= 1) && (value < 0x100))
(*config)->unknown_epoc_char = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"UnknownEPOCChar should be between 1 and 255",
filename,linenr);
} else if (sscanf(var,"char%d",&charnr) == strlen(var)) {
if ((charnr < 0) || (charnr > 255))
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"CharXXX should have XXX between 0 and 255",
filename,linenr);
if ((value >= 1) && (value <= 0x10000))
(*config)->unicode_table[charnr] = value;
else
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"CharXXX should be between 1 and 65535",
filename,linenr);
} else {
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Unknown variable %s",filename,linenr,var);
}
psiconv_debug(*config,0,0,"Configuration file %s, line %d: "
"Set variable %s to %d",filename,linenr,var,value);
}
void psiconv_config_parse_line(const char *filename, int linenr,
const char *line, psiconv_config *config)
{
int sovar,eovar,soval,eoval,eol;
char *var;
long val;
psiconv_debug(*config,0,0,"Going to parse line %d: %s",linenr,line);
sovar = 0;
while (line[sovar] && (line[sovar] < 32))
sovar ++;
if (!line[sovar] || line[sovar] == '#')
return;
eovar = sovar;
while (line[eovar] && (((line[eovar] >= 'A') && (line[eovar] <= 'Z')) ||
((line[eovar] >= 'a') && (line[eovar] <= 'z'))))
eovar ++;
if (sovar == eovar) {
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Syntax error (no variable found)",filename,linenr);
return;
}
soval = eovar;
while (line[soval] && (line[soval] <= 32))
soval ++;
if (line[soval] != '=') {
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Syntax error (no = token found)",filename,linenr);
return;
}
soval ++;
while (line[soval] && (line[soval] <= 32))
soval ++;
eoval = soval;
while (line[eoval] && ((line[eoval] >= '0') && (line[eoval] <= '9')))
eoval ++;
if (eoval == soval) {
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Syntax error (no value found)",filename,linenr);
return;
}
if (soval - eoval > 7) {
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Syntax error (value too large)",filename,linenr);
return;
}
eol = eoval;
while (line[eol] && (line[eol] < 32))
eol ++;
if (line[eol]) {
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Syntax error (trailing garbage)",filename,linenr);
return;
}
var = malloc(eovar - sovar + 1);
memcpy(var,line + sovar, eovar - sovar);
var[eovar-sovar] = 0;
val = atol(line + soval);
psiconv_config_parse_statement(filename,linenr,var,val,config);
free(var);
}
void psiconv_config_parse_file(const char *filename, psiconv_config *config)
{
int file,linenr;
struct stat stat_buf;
off_t filesize,bytes_left,bytes_read,sol,eol;
char *filebuffer,*filebuffer_ptr;
psiconv_progress(*config,0,0,
"Going to access configuration file %s",filename);
/* Try to open the file; it may fail, if it does not exist for example */
if ((file = open(filename,O_RDONLY)) == -1)
goto ERROR0;
/* Read the contents of the file into filebuffer. This may fail */
if (fstat(file,&stat_buf)) {
if (close(file))
psiconv_error(*config,0,0,"Configuration file %s: "
"Couldn't close file",filename);
return;
}
filesize = stat_buf.st_size;
if (!(filebuffer = malloc(filesize + 1))) {
psiconv_error(*config,0,0,"Configuration file %s: "
"Out of memory error",filename);
goto ERROR1;
}
filebuffer_ptr = filebuffer;
bytes_left = filesize;
bytes_read = 1; /* Dummy for the first time through the loop */
while ((bytes_read > 0) && bytes_left) {
bytes_read = read(file,filebuffer_ptr,bytes_left);
if (bytes_read > 0) {
filebuffer_ptr += bytes_read;
bytes_left -= bytes_read;
}
}
/* On NFS, the first read may fail and this is not fatal */
if (bytes_left && (bytes_left != filesize)) {
psiconv_error(*config,0,0,"Configuration file %s: "
"Couldn't read file into memory",filename);
goto ERROR2;
}
if (close(file)) {
psiconv_error(*config,0,0,"Configuration file %s: "
"Couldn't close file",filename);
file = -1;
goto ERROR2;
}
file = -1;
psiconv_progress(*config,0,0,
"Going to parse configuration file %s: ",filename);
/* Now we walk through the file to isolate lines */
linenr = 0;
sol = 0;
while (sol < filesize) {
linenr ++;
eol = sol;
while ((eol < filesize) && (filebuffer[eol] != 13) &&
(filebuffer[eol] != 10) && (filebuffer[eol] != 0))
eol ++;
if ((eol < filesize) && (filebuffer[eol] == 0)) {
psiconv_error(*config,0,0,"Configuration file %s, line %d: "
"Unexpected character \000 found",filename,linenr);
goto ERROR2;
}
if ((eol < filesize + 1) &&
(((filebuffer[eol] == 13) && (filebuffer[eol+1] == 10)) ||
((filebuffer[eol] == 10) && (filebuffer[eol+1] == 13)))) {
filebuffer[eol] = 0;
eol ++;
}
filebuffer[eol] = 0;
psiconv_config_parse_line(filename,linenr,filebuffer + sol,config);
sol = eol+1;
}
free(filebuffer);
return;
ERROR2:
free(filebuffer);
ERROR1:
if ((file != -1) && close(file))
psiconv_error(*config,0,0,"Configuration file %s: "
"Couldn't close file",filename);
ERROR0:
return;
}
void psiconv_config_read(const char *extra_config_files,
psiconv_config *config)
{
char *path,*pathptr,*filename,*filename_old;
const char *home;
int filename_len;
/* Make path be the complete search path, colon separated */
if (extra_config_files && strlen(extra_config_files)) {
path = malloc(strlen(CONFIGURATION_SEARCH_PATH) +
strlen(extra_config_files) + 2);
strcpy(path,CONFIGURATION_SEARCH_PATH);
strcat(path,":");
strcat(path,extra_config_files);
} else {
path = strdup(CONFIGURATION_SEARCH_PATH);
}
pathptr = path;
while (strlen(pathptr)) {
/* Isolate the next filename */
filename_len = (index(pathptr,':')?(index(pathptr,':') - pathptr):
strlen(pathptr));
filename = malloc(filename_len + 1);
filename = strncpy(filename,pathptr,filename_len);
filename[filename_len] = 0;
pathptr += filename_len;
if (strlen(pathptr))
pathptr ++;
/* Do ~ substitution */
if ((filename[0] == '~') && ((filename[1] == '/') || filename[1] == 0)) {
home = getenv("HOME");
if (home) {
filename_old = filename;
filename = malloc(strlen(filename_old) + strlen(home));
strcpy(filename,home);
strcpy(filename + strlen(filename),filename_old+1);
free(filename_old);
}
}
psiconv_config_parse_file(filename,config);
free(filename);
}
free(path);
}
psiconv-0.9.8/lib/psiconv/error.c 0000644 0001750 0001750 00000010710 10336374704 013664 0000000 0000000 /*
error.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include
#include
#include "error.h"
#ifdef DMALLOC
#include
#endif
static void psiconv_default_error_handler(int kind, psiconv_u32 off,
const char *message)
{
fprintf(stderr,"%s\n",message);
}
#define MAX_MESSAGE 1024
void psiconv_fatal(psiconv_config config, int level, psiconv_u32 off,
const char *format,...)
{
char buffer[MAX_MESSAGE];
va_list ap;
size_t curlen;
va_start(ap,format);
snprintf(buffer,MAX_MESSAGE,"Fatal error (offset %08x): ",off);
curlen = strlen(buffer);
vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap);
if (config->error_handler)
config->error_handler(PSICONV_VERB_FATAL,off,buffer);
else
psiconv_default_error_handler(PSICONV_VERB_FATAL,off,buffer);
va_end(ap);
exit(1);
}
void psiconv_error(psiconv_config config, int level, psiconv_u32 off,
const char *format,...)
{
char buffer[MAX_MESSAGE];
va_list ap;
size_t curlen;
va_start(ap,format);
if (config->verbosity >= PSICONV_VERB_ERROR) {
snprintf(buffer,MAX_MESSAGE,"ERROR (offset %08x): ",off);
curlen = strlen(buffer);
vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap);
if (config->error_handler)
config->error_handler(PSICONV_VERB_ERROR,off,buffer);
else
psiconv_default_error_handler(PSICONV_VERB_ERROR,off,buffer);
}
va_end(ap);
}
void psiconv_warn(psiconv_config config, int level, psiconv_u32 off,
const char *format,...)
{
char buffer[MAX_MESSAGE];
va_list ap;
size_t curlen;
va_start(ap,format);
if (config->verbosity >= PSICONV_VERB_WARN) {
snprintf(buffer,MAX_MESSAGE,"WARNING (offset %08x): ",off);
curlen = strlen(buffer);
vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap);
if (config->error_handler)
config->error_handler(PSICONV_VERB_WARN,off,buffer);
else
psiconv_default_error_handler(PSICONV_VERB_WARN,off,buffer);
}
va_end(ap);
}
void psiconv_progress(psiconv_config config,int level, psiconv_u32 off,
const char *format,...)
{
char buffer[MAX_MESSAGE];
va_list ap;
size_t curlen;
int i;
va_start(ap,format);
if (config->verbosity >= PSICONV_VERB_PROGRESS) {
snprintf(buffer,MAX_MESSAGE,"%08x ",off);
curlen = strlen(buffer);
for (i = 0; (i < level) && (i+curlen+3 < MAX_MESSAGE); i++)
buffer[i+curlen] = '=';
curlen += i;
buffer[curlen] = '>';
buffer[curlen+1] = ' ';
buffer[curlen+2] = '\0';
curlen += 2;
vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap);
if (config->error_handler)
config->error_handler(PSICONV_VERB_PROGRESS,off,buffer);
else
psiconv_default_error_handler(PSICONV_VERB_PROGRESS,off,buffer);
}
va_end(ap);
}
void psiconv_debug(psiconv_config config, int level, psiconv_u32 off,
const char *format,...)
{
char buffer[MAX_MESSAGE];
va_list ap;
size_t curlen;
int i;
va_start(ap,format);
if (config->verbosity >= PSICONV_VERB_DEBUG) {
snprintf(buffer,MAX_MESSAGE,"%08x ",off);
curlen = strlen(buffer);
for (i = 0; (i < level) && (i+curlen+3 < MAX_MESSAGE); i++)
buffer[i+curlen] = '-';
curlen += i;
buffer[curlen] = '>';
buffer[curlen+1] = ' ';
buffer[curlen+2] = '\0';
curlen += 2;
vsnprintf(buffer+curlen,MAX_MESSAGE-curlen,format,ap);
if (config->error_handler)
config->error_handler(PSICONV_VERB_DEBUG,off,buffer);
else
psiconv_default_error_handler(PSICONV_VERB_DEBUG,off,buffer);
}
va_end(ap);
}
psiconv-0.9.8/lib/psiconv/misc.c 0000644 0001750 0001750 00000002737 10336374711 013476 0000000 0000000 /*
parse_aux.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include
#include
#include "common.h"
#ifdef DMALLOC
#include
#endif
char *psiconv_make_printable(const psiconv_config config,
const psiconv_string_t input)
{
int i;
char *output;
if (!(output = malloc(sizeof(*output) *
(psiconv_unicode_strlen(input) + 1)))) {
return NULL;
}
for (i = 0; i < psiconv_unicode_strlen(input); i ++)
if (input[i] < 0x20 || input[i] >= 0x7f)
output[i] = '.';
else
output[i] = input[i];
output[i] = 0;
return output;
}
psiconv-0.9.8/lib/psiconv/checkuid.c 0000644 0001750 0001750 00000014512 10336374656 014324 0000000 0000000 /*
checkuid.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include "common.h"
#ifdef DMALLOC
#include
#endif
static psiconv_u32 uid1[32] =
{ /* bit 0 */ 0x000045A0,
/* bit 1 */ 0x00008B40,
/* bit 2 */ 0x000006A1,
/* bit 3 */ 0x00000D42,
/* bit 4 */ 0x00001A84,
/* bit 5 */ 0x00003508,
/* bit 6 */ 0x00006A10,
/* bit 7 */ 0x0000D420,
/* bit 8 */ 0x45A00000,
/* bit 9 */ 0x8B400000,
/* bit 10 */ 0x06A10000,
/* bit 11 */ 0x0D420000,
/* bit 12 */ 0x1A840000,
/* bit 13 */ 0x35080000,
/* bit 14 */ 0x6A100000,
/* bit 15 */ 0xD4200000,
/* bit 16 */ 0x0000AA51,
/* bit 17 */ 0x00004483,
/* bit 18 */ 0x00008906,
/* bit 19 */ 0x0000022D,
/* bit 20 */ 0x0000045A,
/* bit 21 */ 0x000008B4,
/* bit 22 */ 0x00001168,
/* bit 23 */ 0x000022D0,
/* bit 24 */ 0xAA510000,
/* bit 25 */ 0x44830000,
/* bit 26 */ 0x89060000,
/* bit 27 */ 0x022D0000,
/* bit 28 */ 0x045A0000,
/* bit 29 */ 0x08B40000,
/* bit 30 */ 0x11680000,
/* bit 31 */ 0x22D00000};
static psiconv_u32 uid2[32] =
{ /* bit 0 */ 0x000076B4,
/* bit 1 */ 0x0000ED68,
/* bit 2 */ 0x0000CAF1,
/* bit 3 */ 0x000085C3,
/* bit 4 */ 0x00001BA7,
/* bit 5 */ 0x0000374E,
/* bit 6 */ 0x00006E9C,
/* bit 7 */ 0x0000DD38,
/* bit 8 */ 0x76B40000,
/* bit 9 */ 0xED680000,
/* bit 10 */ 0xCAF10000,
/* bit 11 */ 0x85C30000,
/* bit 12 */ 0x1BA70000,
/* bit 13 */ 0x374E0000,
/* bit 14 */ 0x6E9C0000,
/* bit 15 */ 0xDD380000,
/* bit 16 */ 0x00003730,
/* bit 17 */ 0x00006E60,
/* bit 18 */ 0x0000DCC0,
/* bit 19 */ 0x0000A9A1,
/* bit 20 */ 0x00004363,
/* bit 21 */ 0x000086C6,
/* bit 22 */ 0x00001DAD,
/* bit 23 */ 0x00003B5A,
/* bit 24 */ 0x37300000,
/* bit 25 */ 0x6E600000,
/* bit 26 */ 0xDCC00000,
/* bit 27 */ 0xA9A10000,
/* bit 28 */ 0x43630000,
/* bit 29 */ 0x86C60000,
/* bit 30 */ 0x1DAD0000,
/* bit 31 */ 0x3B5A0000 };
static psiconv_u32 uid3[32] =
{ /* bit 0 */ 0x00003331,
/* bit 1 */ 0x00006662,
/* bit 2 */ 0x0000CCC4,
/* bit 3 */ 0x000089A9,
/* bit 4 */ 0x00000373,
/* bit 5 */ 0x000006E6,
/* bit 6 */ 0x00000DCC,
/* bit 7 */ 0x00001B98,
/* bit 8 */ 0x33310000,
/* bit 9 */ 0x66620000,
/* bit 10 */ 0xCCC40000,
/* bit 11 */ 0x89A90000,
/* bit 12 */ 0x03730000,
/* bit 13 */ 0x06E60000,
/* bit 14 */ 0x0DCC0000,
/* bit 15 */ 0x1B980000,
/* bit 16 */ 0x00001021,
/* bit 17 */ 0x00002042,
/* bit 18 */ 0x00004084,
/* bit 19 */ 0x00008108,
/* bit 20 */ 0x00001231,
/* bit 21 */ 0x00002462,
/* bit 22 */ 0x000048C4,
/* bit 23 */ 0x00009188,
/* bit 24 */ 0x10210000,
/* bit 25 */ 0x20420000,
/* bit 26 */ 0x40840000,
/* bit 27 */ 0x81080000,
/* bit 28 */ 0x12310000,
/* bit 29 */ 0x24620000,
/* bit 30 */ 0x48C40000,
/* bit 31 */ 0x91880000 };
psiconv_u32 psiconv_checkuid(psiconv_u32 id1,psiconv_u32 id2,psiconv_u32 id3)
{
psiconv_u32 i;
psiconv_u32 res = 0;
for (i = 0; i < 32; i++) {
if (id1 & (1 << i))
res = res ^ uid1[i];
if (id2 & (1 << i))
res = res ^ uid2[i];
if (id3 & (1 << i))
res = res ^ uid3[i];
}
return res;
}
psiconv-0.9.8/lib/psiconv/list.c 0000644 0001750 0001750 00000011406 10336374665 013517 0000000 0000000 /*
list.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include
#include
#include "general.h"
#include "list.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
static int psiconv_list_resize(psiconv_list l,psiconv_u32 nr);
struct psiconv_list_s {
psiconv_u32 cur_len;
psiconv_u32 max_len;
size_t el_size;
void *els;
};
psiconv_list psiconv_list_new(size_t element_size)
{
psiconv_list l;
l = malloc(sizeof(*l));
if (!l)
return NULL;
l->cur_len = 0;
l->max_len = 0;
l->el_size=element_size;
l->els = NULL;
return l;
}
void psiconv_list_free(psiconv_list l)
{
if (l->max_len)
free(l->els);
free(l);
l = NULL;
}
void psiconv_list_free_el(psiconv_list l, void free_el(void *el))
{
psiconv_list_foreach_el(l,free_el);
psiconv_list_free(l);
}
psiconv_u32 psiconv_list_length(const psiconv_list l)
{
return l->cur_len;
}
int psiconv_list_is_empty(const psiconv_list l)
{
return l->cur_len == 0;
}
void psiconv_list_empty(psiconv_list l)
{
l->cur_len = 0;
}
void *psiconv_list_get(const psiconv_list l, psiconv_u32 indx)
{
if (indx >= l->cur_len)
return NULL;
else
return ((char *) (l->els)) + indx * l->el_size;
}
int psiconv_list_add(psiconv_list l, const void *el)
{
int res;
if ((res = psiconv_list_resize(l,l->cur_len + 1)))
return res;
memcpy(((char *) (l->els)) + l->cur_len * l->el_size, el, l->el_size);
l->cur_len ++;
return 0;
}
int psiconv_list_pop(psiconv_list l, void *el)
{
if (! l->cur_len)
return -PSICONV_E_OTHER;
l->cur_len --;
memcpy(el,((char *)(l->els)) + l->cur_len * l->el_size,l->el_size);
return -PSICONV_E_OK;
}
int psiconv_list_replace(psiconv_list l, psiconv_u32 indx, const void *el)
{
if (indx >= l->cur_len)
return -PSICONV_E_OTHER;
memcpy(((char *) (l->els)) + indx * l->el_size,el, l->el_size);
return -PSICONV_E_OK;
}
void psiconv_list_foreach_el(psiconv_list l, void action(void *el))
{
psiconv_u32 i;
for (i = 0; i < l->cur_len; i ++)
action(psiconv_list_get(l,i));
}
psiconv_list psiconv_list_clone(const psiconv_list l)
{
psiconv_list l2;
psiconv_u32 i;
l2 = psiconv_list_new(l->el_size);
if (!l2)
return NULL;
for (i = 0; i < l->cur_len; i ++)
if (psiconv_list_add(l2,psiconv_list_get(l,i))) {
psiconv_list_free(l2);
return NULL;
}
return l2;
}
size_t psiconv_list_fread(psiconv_list l,size_t size, FILE *f)
{
size_t res;
if (psiconv_list_resize(l,l->cur_len + size))
return 0;
res = fread(((char *) (l->els)) + l->cur_len * l->el_size,l->el_size,size,f);
l->cur_len += res;
return res;
}
int psiconv_list_fread_all(psiconv_list l, FILE *f)
{
while (!feof(f)) {
if (!psiconv_list_fread(l,1024,f) && !feof(f))
return -PSICONV_E_NOMEM;
}
return -PSICONV_E_OK;
}
int psiconv_list_fwrite_all(const psiconv_list l, FILE *f)
{
psiconv_u32 pos = 0;
psiconv_u32 written;
psiconv_u32 len = psiconv_list_length(l);
while (pos < len) {
if (!(written = fwrite(((char *)(l->els)) + pos * l->el_size,l->el_size,
len - pos,f)))
return -PSICONV_E_OTHER;
pos += written;
}
return -PSICONV_E_OK;
}
int psiconv_list_resize(psiconv_list l,psiconv_u32 nr)
{
void * temp;
if (nr > l->max_len) {
l->max_len = 1.1 * nr;
l->max_len += 16 - l->max_len % 16;
temp = realloc(l->els,l->max_len * l->el_size);
if (temp) {
l->els = temp;
return -PSICONV_E_OK;
} else
return -PSICONV_E_NOMEM;
}
return -PSICONV_E_OK;
}
int psiconv_list_concat(psiconv_list l, const psiconv_list extra)
{
int res;
if (l->el_size != extra->el_size)
return -PSICONV_E_OTHER;
if ((res = psiconv_list_resize(l,
l->cur_len + extra->cur_len)))
return res;
/* Unreadable but correct. */
memcpy(((char *) (l->els)) + l->cur_len * l->el_size,extra->els,
extra->cur_len * extra->el_size);
l->cur_len += extra->cur_len;
return 0;
}
psiconv-0.9.8/lib/psiconv/buffer.c 0000644 0001750 0001750 00000013767 10336374660 014024 0000000 0000000 /*
buffer.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "list.h"
#include "error.h"
#include "buffer.h"
#ifdef DMALLOC
#include
#endif
typedef struct psiconv_relocation_s {
psiconv_u32 offset;
int id;
} *psiconv_relocation;
struct psiconv_buffer_s {
psiconv_list reloc_target; /* of struct relocation_s */
psiconv_list reloc_ref; /* of struct relocation_s */
psiconv_list data; /* of psiconv_u8 */
};
static psiconv_u32 unique_id = 1;
psiconv_u32 psiconv_buffer_unique_id(void)
{
return unique_id ++;
}
psiconv_buffer psiconv_buffer_new(void)
{
psiconv_buffer buf;
if (!(buf = malloc(sizeof(*buf))))
goto ERROR1;
if (!(buf->data = psiconv_list_new(sizeof(psiconv_u8))))
goto ERROR2;
if (!(buf->reloc_target = psiconv_list_new(
sizeof(struct psiconv_relocation_s))))
goto ERROR3;
if (!(buf->reloc_ref = psiconv_list_new(
sizeof(struct psiconv_relocation_s))))
goto ERROR4;
return buf;
ERROR4:
psiconv_list_free(buf->reloc_target);
ERROR3:
psiconv_list_free(buf->data);
ERROR2:
free(buf);
ERROR1:
return NULL;
}
void psiconv_buffer_free(psiconv_buffer buf)
{
psiconv_list_free(buf->reloc_ref);
psiconv_list_free(buf->reloc_target);
psiconv_list_free(buf->data);
free(buf);
}
psiconv_u32 psiconv_buffer_length(const psiconv_buffer buf)
{
return psiconv_list_length(buf->data);
}
psiconv_u8 *psiconv_buffer_get(const psiconv_buffer buf, psiconv_u32 off)
{
return psiconv_list_get(buf->data,off);
}
int psiconv_buffer_add(psiconv_buffer buf,psiconv_u8 data)
{
return psiconv_list_add(buf->data,&data);
}
size_t psiconv_buffer_fread(psiconv_buffer buf, size_t size, FILE *f)
{
return psiconv_list_fread(buf->data,size,f);
}
int psiconv_buffer_fread_all(psiconv_buffer buf, FILE *f)
{
return psiconv_list_fread_all(buf->data,f);
}
int psiconv_buffer_fwrite_all(const psiconv_buffer buf, FILE *f)
{
return psiconv_list_fwrite_all(buf->data,f);
}
int psiconv_buffer_subbuffer(psiconv_buffer *buf, const psiconv_buffer org,
psiconv_u32 offset, psiconv_u32 length)
{
int i;
int res;
psiconv_u8 *data;
if (! (*buf = psiconv_buffer_new())) {
res = PSICONV_E_NOMEM;
goto ERROR1;
}
for (i = 0; i < length; i++) {
if (!(data = psiconv_buffer_get(org,offset+i))) {
res = PSICONV_E_OTHER;
goto ERROR2;
}
if ((res = psiconv_buffer_add(*buf,*data))) {
goto ERROR2;
}
}
return 0;
ERROR2:
psiconv_buffer_free(*buf);
ERROR1:
return res;
}
int psiconv_buffer_concat(psiconv_buffer buf, const psiconv_buffer extra)
{
int res;
psiconv_u32 i;
psiconv_relocation reloc;
for (i = 0; i < psiconv_list_length(extra->reloc_target); i++) {
if (!(reloc = psiconv_list_get(extra->reloc_target,i)))
return -PSICONV_E_OTHER;
reloc->offset += psiconv_list_length(buf->data);
if ((res=psiconv_list_add(buf->reloc_target,reloc)))
return res;
}
for (i = 0; i < psiconv_list_length(extra->reloc_ref); i++) {
if (!(reloc = psiconv_list_get(extra->reloc_ref,i)))
return -PSICONV_E_OTHER;
reloc->offset += psiconv_list_length(buf->data);
if ((res = psiconv_list_add(buf->reloc_ref,reloc)))
return res;
}
return psiconv_list_concat(buf->data,extra->data);
}
int psiconv_buffer_resolve(psiconv_buffer buf)
{
int res;
psiconv_u32 i,j,temp;
psiconv_relocation target,ref;
for (i = 0; i < psiconv_list_length(buf->reloc_ref);i++) {
if (!(ref = psiconv_list_get(buf->reloc_ref,i)))
return -PSICONV_E_OTHER;
for (j = 0; j < psiconv_list_length(buf->reloc_target);j++) {
if (!(target = psiconv_list_get(buf->reloc_target,j)))
return -PSICONV_E_OTHER;
if (ref->id == target->id) {
temp = target->offset & 0xff;
if ((res = psiconv_list_replace(buf->data,ref->offset,&temp)))
return -PSICONV_E_OTHER;
temp = (target->offset >> 8) & 0xff;
if ((res = psiconv_list_replace(buf->data,ref->offset + 1,&temp)))
return -PSICONV_E_OTHER;
temp = (target->offset >> 16) & 0xff;
if ((res = psiconv_list_replace(buf->data,ref->offset + 2,&temp)))
return -PSICONV_E_OTHER;
temp = (target->offset >> 24) & 0xff;
if ((res = psiconv_list_replace(buf->data,ref->offset + 3,&temp)))
return -PSICONV_E_OTHER;
break;
}
}
if (j == psiconv_list_length(buf->reloc_target))
return -PSICONV_E_OTHER;
}
psiconv_list_empty(buf->reloc_target);
psiconv_list_empty(buf->reloc_ref);
return -PSICONV_E_OK;
}
int psiconv_buffer_add_reference(psiconv_buffer buf,int id)
{
struct psiconv_relocation_s reloc;
int res,i;
psiconv_u8 data;
reloc.offset = psiconv_list_length(buf->data);
reloc.id = id;
if ((res = psiconv_list_add(buf->reloc_ref,&reloc)))
return res;
data = 0x00;
for (i = 0; i < 4; i++)
if ((res = psiconv_list_add(buf->data,&data)))
return res;
return -PSICONV_E_OK;
}
int psiconv_buffer_add_target(psiconv_buffer buf, int id)
{
struct psiconv_relocation_s reloc;
reloc.offset = psiconv_list_length(buf->data);
reloc.id = id;
return psiconv_list_add(buf->reloc_target,&reloc);
}
psiconv-0.9.8/lib/psiconv/data.c 0000644 0001750 0001750 00000120105 10336374661 013446 0000000 0000000 /*
data.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "data.h"
#include "list.h"
#include "unicode.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
static psiconv_color clone_color(psiconv_color color);
static psiconv_font clone_font(psiconv_font font);
static psiconv_border clone_border(psiconv_border border);
static psiconv_bullet clone_bullet(psiconv_bullet bullet);
static psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs);
static void psiconv_free_style_aux(void *style);
static void psiconv_free_in_line_layout_aux(void * layout);
static void psiconv_free_paragraph_aux(void * paragraph);
static void psiconv_free_paint_data_section_aux(void * section);
static void psiconv_free_clipart_section_aux(void * section);
static void psiconv_free_formula_aux(void *data);
static void psiconv_free_sheet_worksheet_aux (void *data);
static void psiconv_free_sheet_variable_aux(void * variable);
static void psiconv_free_sheet_cell_aux(void *cell);
static void psiconv_free_sheet_line_aux(void *line);
static void psiconv_free_sheet_worksheet_aux (void *data);
static psiconv_word_styles_section psiconv_empty_word_styles_section(void);
static psiconv_text_and_layout psiconv_empty_text_and_layout(void);
static psiconv_texted_section psiconv_empty_texted_section(void);
static psiconv_page_header psiconv_empty_page_header(void);
static psiconv_page_layout_section psiconv_empty_page_layout_section(void);
static psiconv_word_status_section psiconv_empty_word_status_section(void);
static psiconv_word_f psiconv_empty_word_f(void);
static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void);
static psiconv_formula_list psiconv_empty_formula_list(void);
static psiconv_sheet_workbook_section
psiconv_empty_sheet_workbook_section(void);
static psiconv_sheet_f psiconv_empty_sheet_f(void);
static psiconv_texted_f psiconv_empty_texted_f(void);
static psiconv_paint_data_section psiconv_empty_paint_data_section(void);
static psiconv_pictures psiconv_empty_pictures(void);
static psiconv_mbm_f psiconv_empty_mbm_f(void);
static psiconv_sketch_section psiconv_empty_sketch_section(void);
static psiconv_sketch_f psiconv_empty_sketch_f(void);
static psiconv_clipart_f psiconv_empty_clipart_f(void);
static psiconv_cliparts psiconv_empty_cliparts(void);
/* Note: these defaults seem to be hard-coded somewhere outside the
files themself. */
psiconv_character_layout psiconv_basic_character_layout(void)
{
/* Make the structures static, to oblige IRIX */
static struct psiconv_color_s black =
{
0x00, /* red */
0x00, /* green */
0x00, /* blue */
};
static struct psiconv_color_s white =
{
0xff, /* red */
0xff, /* green */
0xff, /* blue */
};
static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ',
'N','e','w',' ',
'R','o','m','a','n',0 };
static struct psiconv_font_s font =
{
font_times, /* name */
3 /* screenfont */
};
struct psiconv_character_layout_s cl =
{
&black, /* color */
&white, /* back_color */
10.0, /* font_size */
psiconv_bool_false, /* italic */
psiconv_bool_false, /* bold */
psiconv_normalscript, /* super_sub */
psiconv_bool_false, /* underline */
psiconv_bool_false, /* strikethrough */
&font, /* font */
};
return psiconv_clone_character_layout(&cl);
}
/* Note: these defaults seem to be hard-coded somewhere outside the
files themself. */
psiconv_paragraph_layout psiconv_basic_paragraph_layout(void)
{
static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ',
'N','e','w',' ',
'R','o','m','a','n',0 };
static struct psiconv_font_s font =
{
font_times, /* name */
2 /* screenfont */
};
static struct psiconv_color_s black =
{
0x00, /* red */
0x00, /* green */
0x00, /* blue */
};
static struct psiconv_color_s white =
{
0xff, /* red */
0xff, /* green */
0xff, /* blue */
};
static struct psiconv_border_s no_border =
{
psiconv_border_none, /* kind */
1, /* thickness */
&black /* color */
};
static struct psiconv_bullet_s bullet =
{
psiconv_bool_false, /* on */
10.0, /* font_size */
0x201d, /* character */
psiconv_bool_true, /* indent */
&black, /* color */
&font, /* font */
};
static struct psiconv_all_tabs_s tabs =
{
0.64, /* normal */
NULL /* kind */
};
struct psiconv_paragraph_layout_s pl =
{
&white, /* back_color */
0.0, /* indent_left */
0.0, /* indent_right */
0.0, /* indent_first */
psiconv_justify_left, /* justify_hor */
psiconv_justify_middle,/* justify_ver */
10.0, /* linespacing */
psiconv_bool_false, /* linespacing_exact */
0.0, /* space_above */
0.0, /* space_below */
psiconv_bool_false, /* keep_together */
psiconv_bool_false, /* keep_with_next */
psiconv_bool_false, /* on_next_page */
psiconv_bool_false, /* no_widow_protection */
psiconv_bool_false, /* wrap_to_fit_cell */
0.0, /* left_margin */
&bullet, /* bullet */
&no_border, /* left_border */
&no_border, /* right_border */
&no_border, /* top_border */
&no_border, /* bottom_border */
&tabs, /* tabs */
};
psiconv_paragraph_layout res;
if (!(pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab_s))))
return NULL;
res = psiconv_clone_paragraph_layout(&pl);
psiconv_list_free(pl.tabs->extras);
return res;
}
psiconv_color clone_color(psiconv_color color)
{
psiconv_color result;
if (!(result = malloc(sizeof(*result))))
return NULL;
*result = *color;
return result;
}
psiconv_font clone_font(psiconv_font font)
{
psiconv_font result;
if(!(result = malloc(sizeof(*result))))
goto ERROR1;
*result = *font;
if (!(result->name = psiconv_unicode_strdup(result->name)))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_border clone_border(psiconv_border border)
{
psiconv_border result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
*result = *border;
if(!(result->color = clone_color(result->color)))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_bullet clone_bullet(psiconv_bullet bullet)
{
psiconv_bullet result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
*result = *bullet;
if (!(result->font = clone_font(result->font)))
goto ERROR2;
if (!(result->color = clone_color(result->color)))
goto ERROR3;
return result;
ERROR3:
psiconv_free_font(result->font);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs)
{
psiconv_all_tabs result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
*result = *all_tabs;
if (!(result->extras = psiconv_list_clone(result->extras)))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_character_layout psiconv_clone_character_layout
(psiconv_character_layout ls)
{
psiconv_character_layout result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
*result = *ls;
if (!(result->color = clone_color(result->color)))
goto ERROR2;
if (!(result->back_color = clone_color(result->back_color)))
goto ERROR3;
if (!(result->font = clone_font(result->font)))
goto ERROR4;
return result;
ERROR4:
psiconv_free_color(result->back_color);
ERROR3:
psiconv_free_color(result->color);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_paragraph_layout psiconv_clone_paragraph_layout
(psiconv_paragraph_layout ls)
{
psiconv_paragraph_layout result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
*result = *ls;
if (!(result->back_color = clone_color(result->back_color)))
goto ERROR2;
if (!(result->bullet = clone_bullet(result->bullet)))
goto ERROR3;
if (!(result->left_border = clone_border(result->left_border)))
goto ERROR4;
if (!(result->right_border = clone_border(result->right_border)))
goto ERROR5;
if (!(result->top_border = clone_border(result->top_border)))
goto ERROR6;
if (!(result->bottom_border = clone_border(result->bottom_border)))
goto ERROR7;
if (!(result->tabs = clone_all_tabs(result->tabs)))
goto ERROR8;
return result;
ERROR8:
psiconv_free_border(result->bottom_border);
ERROR7:
psiconv_free_border(result->top_border);
ERROR6:
psiconv_free_border(result->right_border);
ERROR5:
psiconv_free_border(result->left_border);
ERROR4:
psiconv_free_bullet(result->bullet);
ERROR3:
psiconv_free_color(result->back_color);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr)
{
if (nr == 0)
return ss->normal;
else
return psiconv_list_get(ss->styles,0xff - nr);
}
int psiconv_find_style(const psiconv_word_styles_section ss,
const psiconv_ucs2 *name,
int *nr)
{
const psiconv_ucs2 value_normal[] = { 'N','o','r','m','a','l',0 };
psiconv_word_style style;
int i;
if (!nr)
return PSICONV_E_OTHER;
if(!psiconv_unicode_strcmp(value_normal,name)) {
*nr = 0;
return 0;
}
for (i = 0; i < psiconv_list_length(ss->styles);i++) {
if (!(style = psiconv_list_get(ss->styles,i)))
return PSICONV_E_NOMEM;
if (!psiconv_unicode_strcmp(style->name,name)) {
*nr = 0xff - i;
return 0;
}
}
*nr = 0;
return PSICONV_E_OTHER;
}
psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr)
{
return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1);
}
/* TODO: What if a cell is both in a default row and a default column?!? */
psiconv_sheet_cell_layout psiconv_get_default_layout
(psiconv_sheet_line_list row_defaults,
psiconv_sheet_line_list col_defaults,
psiconv_sheet_cell_layout cell_default,
int row,int col)
{
int i;
psiconv_sheet_line line;
for (i = 0;i < psiconv_list_length(row_defaults);i++) {
line = psiconv_list_get(row_defaults,i);
if (line->position == row)
return line->layout;
}
for (i = 0;i < psiconv_list_length(col_defaults);i++) {
line = psiconv_list_get(col_defaults,i);
if (line->position == col)
return line->layout;
}
return cell_default;
}
void psiconv_free_color (psiconv_color color)
{
if (color)
free(color);
}
void psiconv_free_border(psiconv_border border)
{
if (border) {
psiconv_free_color(border->color);
free(border);
}
}
void psiconv_free_font(psiconv_font font)
{
if (font) {
if (font->name)
free(font->name);
free(font);
}
}
void psiconv_free_bullet(psiconv_bullet bullet)
{
if (bullet) {
psiconv_free_color(bullet->color);
psiconv_free_font(bullet->font);
free(bullet);
}
}
void psiconv_free_character_layout(psiconv_character_layout layout)
{
if (layout) {
psiconv_free_color(layout->color);
psiconv_free_color(layout->back_color);
psiconv_free_font(layout->font);
free(layout);
}
}
void psiconv_free_tab(psiconv_tab tab)
{
if (tab)
free(tab);
}
void psiconv_free_tabs(psiconv_all_tabs tabs)
{
if (tabs) {
psiconv_list_free(tabs->extras);
free(tabs);
}
}
void psiconv_free_paragraph_layout(psiconv_paragraph_layout layout)
{
if (layout) {
psiconv_free_color(layout->back_color);
psiconv_free_bullet(layout->bullet);
psiconv_free_border(layout->left_border);
psiconv_free_border(layout->right_border);
psiconv_free_border(layout->top_border);
psiconv_free_border(layout->bottom_border);
psiconv_free_tabs(layout->tabs);
free(layout);
}
}
void psiconv_free_style_aux(void *style)
{
if(((psiconv_word_style) style)->name)
free(((psiconv_word_style) style)->name);
psiconv_free_character_layout(((psiconv_word_style) style)->character);
psiconv_free_paragraph_layout(((psiconv_word_style) style)->paragraph);
}
void psiconv_free_word_style(psiconv_word_style style)
{
if (style) {
psiconv_free_style_aux(style);
free(style);
}
}
void psiconv_free_word_style_list(psiconv_word_style_list style_list)
{
if (style_list)
psiconv_list_free_el(style_list,psiconv_free_style_aux);
}
void psiconv_free_word_styles_section(psiconv_word_styles_section styles)
{
if (styles) {
psiconv_free_word_style(styles->normal);
psiconv_free_word_style_list(styles->styles);
free(styles);
}
}
void psiconv_free_header_section(psiconv_header_section header)
{
if (header)
free(header);
}
void psiconv_free_section_table_entry(psiconv_section_table_entry entry)
{
if (entry)
free(entry);
}
void psiconv_free_section_table_section(psiconv_section_table_section section)
{
if (section)
psiconv_list_free(section);
}
void psiconv_free_application_id_section(psiconv_application_id_section section)
{
if (section) {
if (section->name)
free(section->name);
free(section);
}
}
void psiconv_free_object_icon_section(psiconv_object_icon_section section)
{
if (section) {
if (section->icon_name)
free(section->icon_name);
free(section);
}
}
void psiconv_free_object_display_section(psiconv_object_display_section section)
{
if (section)
free(section);
}
void psiconv_free_embedded_object_section
(psiconv_embedded_object_section object)
{
if (object) {
psiconv_free_object_icon_section(object->icon);
psiconv_free_object_display_section(object->display);
psiconv_free_file(object->object);
free(object);
}
}
void psiconv_free_in_line_layout_aux(void * layout)
{
psiconv_free_character_layout(((psiconv_in_line_layout) layout)->layout);
psiconv_free_embedded_object_section
(((psiconv_in_line_layout) layout)->object);
}
void psiconv_free_in_line_layout(psiconv_in_line_layout layout)
{
if (layout) {
psiconv_free_in_line_layout_aux(layout);
free(layout);
}
}
void psiconv_free_in_line_layouts(psiconv_in_line_layouts layouts)
{
if (layouts)
psiconv_list_free_el(layouts,&psiconv_free_in_line_layout_aux);
}
void psiconv_free_replacement(psiconv_replacement replacement)
{
if (replacement)
free(replacement);
}
void psiconv_free_replacements(psiconv_replacements replacements)
{
if (replacements)
psiconv_list_free(replacements);
}
void psiconv_free_paragraph_aux(void * paragraph)
{
if(((psiconv_paragraph) paragraph)->text)
free(((psiconv_paragraph) paragraph)->text);
psiconv_free_character_layout(((psiconv_paragraph) paragraph)
->base_character);
psiconv_free_paragraph_layout(((psiconv_paragraph) paragraph)
->base_paragraph);
psiconv_free_in_line_layouts(((psiconv_paragraph) paragraph)
->in_lines);
psiconv_free_replacements(((psiconv_paragraph) paragraph)
->replacements);
}
void psiconv_free_paragraph(psiconv_paragraph paragraph)
{
if (paragraph) {
psiconv_free_paragraph_aux(paragraph);
free(paragraph);
}
}
void psiconv_free_text_and_layout(psiconv_text_and_layout text)
{
if (text)
psiconv_list_free_el(text,&psiconv_free_paragraph_aux);
}
void psiconv_free_texted_section(psiconv_texted_section section)
{
if (section) {
psiconv_free_text_and_layout(section->paragraphs);
free(section);
}
}
void psiconv_free_page_header(psiconv_page_header header)
{
if (header) {
psiconv_free_character_layout(header->base_character_layout);
psiconv_free_paragraph_layout(header->base_paragraph_layout);
psiconv_free_texted_section(header->text);
free(header);
}
}
void psiconv_free_page_layout_section(psiconv_page_layout_section section)
{
if (section) {
psiconv_free_page_header(section->header);
psiconv_free_page_header(section->footer);
free(section);
}
}
void psiconv_free_word_status_section(psiconv_word_status_section section)
{
if (section)
free(section);
}
void psiconv_free_word_f(psiconv_word_f file)
{
if (file) {
psiconv_free_page_layout_section(file->page_sec);
psiconv_free_text_and_layout(file->paragraphs);
psiconv_free_word_status_section(file->status_sec);
psiconv_free_word_styles_section(file->styles_sec);
free(file);
}
}
void psiconv_free_sheet_status_section(psiconv_sheet_status_section section)
{
if (section)
free(section);
}
void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat)
{
if (numberformat)
free(numberformat);
}
void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout)
{
psiconv_free_paragraph_layout(layout->paragraph);
psiconv_free_character_layout(layout->character);
psiconv_free_sheet_numberformat(layout->numberformat);
}
void psiconv_free_sheet_cell_aux(void *cell)
{
psiconv_sheet_cell data = cell;
psiconv_free_sheet_cell_layout(data->layout);
if ((data->type == psiconv_cell_string) && (data->data.dat_string))
free(data->data.dat_string);
}
void psiconv_free_sheet_cell(psiconv_sheet_cell cell)
{
if (cell) {
psiconv_free_sheet_cell_aux(cell);
free(cell);
}
}
void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list)
{
if (list)
psiconv_list_free_el(list,psiconv_free_sheet_cell_aux);
}
void psiconv_free_sheet_line_aux(void *line)
{
psiconv_sheet_line data = line;
psiconv_free_sheet_cell_layout(data->layout);
}
void psiconv_free_sheet_line(psiconv_sheet_line line)
{
if (line) {
psiconv_free_sheet_line_aux(line);
free(line);
}
}
void psiconv_free_sheet_line_list(psiconv_sheet_line_list list)
{
if (list)
psiconv_list_free_el(list,psiconv_free_sheet_line_aux);
}
void psiconv_free_sheet_grid_break_list(psiconv_sheet_grid_break_list list)
{
if (list)
psiconv_list_free(list);
}
void psiconv_free_sheet_grid_size(psiconv_sheet_grid_size s)
{
if (s)
free(s);
}
void psiconv_free_sheet_grid_size_list(psiconv_sheet_grid_size_list list)
{
if (list)
psiconv_list_free(list);
}
void psiconv_free_sheet_grid_section(psiconv_sheet_grid_section sec)
{
if (sec) {
psiconv_free_sheet_grid_size_list(sec->row_heights);
psiconv_free_sheet_grid_size_list(sec->column_heights);
psiconv_free_sheet_grid_break_list(sec->row_page_breaks);
psiconv_free_sheet_grid_break_list(sec->column_page_breaks);
free(sec);
}
}
void psiconv_free_sheet_worksheet_aux (void *data)
{
psiconv_sheet_worksheet section = data;
psiconv_free_sheet_cell_layout(section->default_layout);
psiconv_free_sheet_cell_list(section->cells);
psiconv_free_sheet_line_list(section->row_default_layouts);
psiconv_free_sheet_line_list(section->col_default_layouts);
psiconv_free_sheet_grid_section(section->grid);
}
void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet)
{
if (sheet) {
psiconv_free_sheet_worksheet_aux(sheet);
free(sheet);
}
}
void psiconv_free_sheet_worksheet_list(psiconv_sheet_worksheet_list list)
{
if (list)
psiconv_list_free_el(list,psiconv_free_sheet_worksheet_aux);
}
void psiconv_free_formula_aux(void *data)
{
psiconv_formula formula;
formula = data;
if (formula->type == psiconv_formula_dat_string)
free(formula->data.dat_string);
else if ((formula->type != psiconv_formula_dat_int) &&
(formula->type != psiconv_formula_dat_var) &&
(formula->type != psiconv_formula_dat_float) &&
(formula->type != psiconv_formula_dat_cellref) &&
(formula->type != psiconv_formula_dat_cellblock) &&
(formula->type != psiconv_formula_dat_vcellblock) &&
(formula->type != psiconv_formula_mark_opsep) &&
(formula->type != psiconv_formula_mark_opend) &&
(formula->type != psiconv_formula_mark_eof) &&
(formula->type != psiconv_formula_unknown))
psiconv_free_formula_list(formula->data.fun_operands);
}
void psiconv_free_formula(psiconv_formula formula)
{
if (formula) {
psiconv_free_formula_aux(formula);
free(formula);
}
}
void psiconv_free_formula_list(psiconv_formula_list list)
{
if (list)
psiconv_list_free_el(list,psiconv_free_formula_aux);
}
void psiconv_free_sheet_name_section(psiconv_sheet_name_section section)
{
if (section) {
if(section->name)
free(section->name);
free(section);
}
}
void psiconv_free_sheet_info_section(psiconv_sheet_info_section section)
{
if (section) {
free(section);
}
}
void psiconv_free_sheet_variable_aux(void * variable)
{
psiconv_sheet_variable var = variable;
if (var->name)
free(var->name);
if (var->type == psiconv_var_string)
free(var->data.dat_string);
}
void psiconv_free_sheet_variable(psiconv_sheet_variable var)
{
if (var) {
psiconv_free_sheet_variable_aux(var);
free(var);
}
}
void psiconv_free_sheet_variable_list(psiconv_sheet_variable_list list)
{
if (list)
psiconv_list_free_el(list,psiconv_free_sheet_variable_aux);
}
void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section)
{
if (section) {
psiconv_free_formula_list(section->formulas);
psiconv_free_sheet_worksheet_list(section->worksheets);
psiconv_free_sheet_name_section(section->name);
psiconv_free_sheet_info_section(section->info);
psiconv_free_sheet_variable_list(section->variables);
free(section);
}
}
void psiconv_free_sheet_f(psiconv_sheet_f file)
{
if (file) {
psiconv_free_page_layout_section(file->page_sec);
psiconv_free_sheet_status_section(file->status_sec);
psiconv_free_sheet_workbook_section(file->workbook_sec);
free(file);
}
}
void psiconv_free_texted_f(psiconv_texted_f file)
{
if (file) {
psiconv_free_page_layout_section(file->page_sec);
psiconv_free_texted_section(file->texted_sec);
free(file);
}
}
void psiconv_free_paint_data_section_aux(void * section)
{
if (((psiconv_paint_data_section) section)->red)
free(((psiconv_paint_data_section)section) -> red);
if (((psiconv_paint_data_section) section)->green)
free(((psiconv_paint_data_section)section) -> green);
if (((psiconv_paint_data_section) section)->blue)
free(((psiconv_paint_data_section)section) -> blue);
}
void psiconv_free_paint_data_section(psiconv_paint_data_section section)
{
if (section) {
psiconv_free_paint_data_section_aux(section);
free(section);
}
}
void psiconv_free_pictures(psiconv_pictures section)
{
if (section)
psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux);
}
void psiconv_free_jumptable_section (psiconv_jumptable_section section)
{
if (section)
psiconv_list_free(section);
}
void psiconv_free_mbm_f(psiconv_mbm_f file)
{
if (file) {
psiconv_free_pictures(file->sections);
free(file);
}
}
void psiconv_free_sketch_section(psiconv_sketch_section sec)
{
if (sec) {
psiconv_free_paint_data_section(sec->picture);
free(sec);
}
}
void psiconv_free_sketch_f(psiconv_sketch_f file)
{
if (file) {
psiconv_free_sketch_section(file->sketch_sec);
free(file);
}
}
void psiconv_free_clipart_section_aux(void *section)
{
if (section)
psiconv_free_paint_data_section(((psiconv_clipart_section) section)->picture);
}
void psiconv_free_clipart_section(psiconv_clipart_section section)
{
if (section) {
psiconv_free_clipart_section_aux(section);
free(section);
}
}
void psiconv_free_cliparts(psiconv_cliparts section)
{
if (section)
psiconv_list_free_el(section,&psiconv_free_clipart_section_aux);
}
void psiconv_free_clipart_f(psiconv_clipart_f file)
{
if (file) {
psiconv_free_cliparts(file->sections);
free(file);
}
}
void psiconv_free_file(psiconv_file file)
{
if (file) {
if (file->type == psiconv_word_file)
psiconv_free_word_f((psiconv_word_f) file->file);
else if (file->type == psiconv_texted_file)
psiconv_free_texted_f((psiconv_texted_f) file->file);
else if (file->type == psiconv_mbm_file)
psiconv_free_mbm_f((psiconv_mbm_f) file->file);
else if (file->type == psiconv_sketch_file)
psiconv_free_sketch_f((psiconv_sketch_f) file->file);
else if (file->type == psiconv_clipart_file)
psiconv_free_clipart_f((psiconv_clipart_f) file->file);
else if (file->type == psiconv_sheet_file)
psiconv_free_sheet_f((psiconv_sheet_f) file->file);
free(file);
}
}
int psiconv_compare_color(const psiconv_color value1,
const psiconv_color value2)
{
if (!value1 || !value2)
return 1;
if ((value1->red == value2->red) &&
(value1->green == value2->green) &&
(value1->blue == value2->blue))
return 0;
else
return 1;
}
int psiconv_compare_font(const psiconv_font value1,
const psiconv_font value2)
{
if (!value1 || !value2 || !value1->name || !value2->name)
return 1;
if ((value1->screenfont == value2->screenfont) &&
!psiconv_unicode_strcmp(value1->name,value2->name))
return 0;
else
return 1;
}
int psiconv_compare_border(const psiconv_border value1,
const psiconv_border value2)
{
if (!value1 || !value2)
return 1;
if ((value1->kind == value2->kind) &&
(value1->thickness == value2->thickness) &&
!psiconv_compare_color(value1->color,value2->color))
return 0;
else
return 1;
}
int psiconv_compare_bullet(const psiconv_bullet value1,
const psiconv_bullet value2)
{
if (!value1 || !value2)
return 1;
if ((value1->on == value2->on) &&
(value1->font_size == value2->font_size) &&
(value1->character == value2->character) &&
(value1->indent == value2->indent) &&
!psiconv_compare_color(value1->color,value2->color) &&
!psiconv_compare_font(value1->font,value2->font))
return 0;
else
return 1;
}
int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2)
{
if (!value1 || !value2)
return 1;
if ((value1->location == value2->location) &&
(value1->kind == value2->kind))
return 0;
else
return 1;
}
int psiconv_compare_all_tabs(const psiconv_all_tabs value1,
const psiconv_all_tabs value2)
{
int i;
if (!value1 || !value2 || !value1->extras || !value2->extras)
return 1;
if ((value1->normal != value2->normal) ||
psiconv_list_length(value1->extras) !=
psiconv_list_length(value2->extras))
return 1;
for (i = 0; i < psiconv_list_length(value1->extras); i++)
if (psiconv_compare_tab(psiconv_list_get(value1->extras,i),
psiconv_list_get(value2->extras,i)))
return 1;
return 0;
}
int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1,
const psiconv_paragraph_layout value2)
{
if (!value1 || !value2)
return 1;
if ((value1->indent_left == value2->indent_left) &&
(value1->indent_right == value2->indent_right) &&
(value1->indent_first == value2->indent_first) &&
(value1->justify_hor == value2->justify_hor) &&
(value1->justify_ver == value2->justify_ver) &&
(value1->linespacing == value2->linespacing) &&
(value1->space_above == value2->space_above) &&
(value1->space_below == value2->space_below) &&
(value1->keep_together == value2->keep_together) &&
(value1->keep_with_next == value2->keep_with_next) &&
(value1->on_next_page == value2->on_next_page) &&
(value1->no_widow_protection == value2->no_widow_protection) &&
(value1->border_distance == value2->border_distance) &&
!psiconv_compare_color(value1->back_color,value2->back_color) &&
!psiconv_compare_bullet(value1->bullet,value2->bullet) &&
!psiconv_compare_border(value1->left_border,value2->left_border) &&
!psiconv_compare_border(value1->right_border,value2->right_border) &&
!psiconv_compare_border(value1->top_border,value2->top_border) &&
!psiconv_compare_border(value1->bottom_border,value2->bottom_border) &&
!psiconv_compare_all_tabs(value1->tabs,value2->tabs))
return 0;
else
return 1;
}
int psiconv_compare_character_layout(const psiconv_character_layout value1,
const psiconv_character_layout value2)
{
if (!value1 || !value2)
return 1;
if ((value1->font_size == value2->font_size) &&
(value1->italic == value2->italic) &&
(value1->bold == value2->bold) &&
(value1->super_sub == value2->super_sub) &&
(value1->underline == value2->underline) &&
(value1->strikethrough == value2->strikethrough) &&
!psiconv_compare_color(value1->color,value2->color) &&
!psiconv_compare_color(value1->back_color,value2->back_color) &&
!psiconv_compare_font(value1->font,value2->font))
return 0;
else
return 1;
}
psiconv_word_styles_section psiconv_empty_word_styles_section(void)
{
psiconv_word_styles_section result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s))))
goto ERROR2;
if (!(result->normal = malloc(sizeof(struct psiconv_word_style_s))))
goto ERROR3;
if (!(result->normal->character = psiconv_basic_character_layout()))
goto ERROR4;
if (!(result->normal->paragraph = psiconv_basic_paragraph_layout()))
goto ERROR5;
result->normal->hotkey = 'N';
result->normal->name = NULL;
result->normal->built_in = psiconv_bool_true;
result->normal->outline_level = 0;
return result;
ERROR5:
psiconv_free_character_layout(result->normal->character);
ERROR4:
free(result->normal);
ERROR3:
psiconv_list_free(result->styles);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_text_and_layout psiconv_empty_text_and_layout(void)
{
return psiconv_list_new(sizeof(struct psiconv_paragraph_s));
}
psiconv_texted_section psiconv_empty_texted_section(void)
{
psiconv_texted_section result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->paragraphs = psiconv_empty_text_and_layout()))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_page_header psiconv_empty_page_header(void)
{
psiconv_page_header result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
result->on_first_page = psiconv_bool_true;
if (!(result->base_paragraph_layout = psiconv_basic_paragraph_layout()))
goto ERROR2;
if (!(result->base_character_layout = psiconv_basic_character_layout()))
goto ERROR3;
if (!(result->text = psiconv_empty_texted_section()))
goto ERROR4;
return result;
ERROR4:
psiconv_free_character_layout(result->base_character_layout);
ERROR3:
psiconv_free_paragraph_layout(result->base_paragraph_layout);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_page_layout_section psiconv_empty_page_layout_section(void)
{
psiconv_page_layout_section result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
result->first_page_nr = 1;
result->header_dist = result->footer_dist = 1.27;
result->left_margin = result->right_margin = 3.175;
result->top_margin = result->bottom_margin = 2.54;
result->page_width = 21.0;
result->page_height = 29.7;
result->landscape = psiconv_bool_false;
if (!(result->header = psiconv_empty_page_header()))
goto ERROR2;
if (!(result->footer = psiconv_empty_page_header()))
goto ERROR3;
return result;
ERROR3:
psiconv_free_page_header(result->header);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_word_status_section psiconv_empty_word_status_section(void)
{
psiconv_word_status_section result;
if (!(result = malloc(sizeof(*result))))
return NULL;
result->show_tabs = result->show_spaces = result->show_paragraph_ends =
result->show_hard_minus = result->show_hard_space =
result->fit_lines_to_screen = psiconv_bool_false;
result->show_full_pictures = result->show_full_graphs =
result->show_top_toolbar = result->show_side_toolbar =
psiconv_bool_true;
result->cursor_position = 0;
result->display_size = 1000;
return result;
}
psiconv_word_f psiconv_empty_word_f(void)
{
psiconv_word_f result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->page_sec = psiconv_empty_page_layout_section()))
goto ERROR2;
if (!(result->paragraphs = psiconv_empty_text_and_layout()))
goto ERROR3;
if (!(result->status_sec = psiconv_empty_word_status_section()))
goto ERROR4;
if (!(result->styles_sec = psiconv_empty_word_styles_section()))
goto ERROR5;
return result;
ERROR5:
psiconv_free_word_status_section(result->status_sec);
ERROR4:
psiconv_free_text_and_layout(result->paragraphs);
ERROR3:
psiconv_free_page_layout_section(result->page_sec);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_sheet_status_section psiconv_empty_sheet_status_section(void)
{
psiconv_sheet_status_section result;
if (!(result = malloc(sizeof(*result))))
return NULL;
result->show_horizontal_scrollbar = result->show_vertical_scrollbar =
psiconv_triple_auto;
result->show_graph = psiconv_bool_false;
result->show_top_sheet_toolbar = result->show_side_sheet_toolbar =
result->show_top_graph_toolbar = result->show_side_graph_toolbar =
psiconv_bool_true;
result->cursor_row = result->cursor_column = 0;
result->sheet_display_size = result->graph_display_size = 1000;
return result;
}
psiconv_formula_list psiconv_empty_formula_list(void)
{
return psiconv_list_new(sizeof(struct psiconv_formula_s));
}
psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void)
{
psiconv_sheet_workbook_section result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->formulas = psiconv_empty_formula_list()))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_sheet_f psiconv_empty_sheet_f(void)
{
psiconv_sheet_f result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->page_sec = psiconv_empty_page_layout_section()))
goto ERROR2;
if (!(result->status_sec = psiconv_empty_sheet_status_section()))
goto ERROR3;
if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section()))
goto ERROR4;
return result;
ERROR4:
psiconv_free_sheet_status_section(result->status_sec);
ERROR3:
psiconv_free_page_layout_section(result->page_sec);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_texted_f psiconv_empty_texted_f(void)
{
psiconv_texted_f result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->page_sec = psiconv_empty_page_layout_section()))
goto ERROR2;
if (!(result->texted_sec = psiconv_empty_texted_section()))
goto ERROR3;
return result;
ERROR3:
psiconv_free_page_layout_section(result->page_sec);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_paint_data_section psiconv_empty_paint_data_section(void)
{
psiconv_paint_data_section result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
/* Is this correct? */
result->xsize = result->ysize = result->pic_xsize = result->pic_ysize = 0;
/* Probably forbidden... */
if (!(result->red = malloc(0)))
goto ERROR2;
if (!(result->green = malloc(0)))
goto ERROR3;
if (!(result->blue = malloc(0)))
goto ERROR4;
return result;
ERROR4:
free(result->green);
ERROR3:
free(result->red);
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_pictures psiconv_empty_pictures(void)
{
psiconv_pictures result;
psiconv_paint_data_section pds;
if (!(result = psiconv_list_new(sizeof(struct psiconv_paint_data_section_s))))
goto ERROR1;
if (!(pds = psiconv_empty_paint_data_section()))
goto ERROR2;
if (psiconv_list_add(result,pds))
goto ERROR3;
free(pds);
return result;
ERROR3:
psiconv_free_paint_data_section(pds);
ERROR2:
psiconv_list_free(result);
ERROR1:
return NULL;
}
psiconv_mbm_f psiconv_empty_mbm_f(void)
{
psiconv_mbm_f result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->sections = psiconv_empty_pictures()))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_sketch_section psiconv_empty_sketch_section(void)
{
psiconv_sketch_section result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
result->displayed_xsize = 320;
result->displayed_ysize = 200;
result->picture_data_x_offset = result->picture_data_y_offset =
result->form_xsize = result->form_ysize =
result->displayed_size_x_offset = result->displayed_size_y_offset = 0;
result->magnification_x = result->magnification_y = 1.0;
result->cut_left = result->cut_right = result->cut_top =
result->cut_bottom = 0.0;
if (!(result->picture = psiconv_empty_paint_data_section()))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_sketch_f psiconv_empty_sketch_f(void)
{
psiconv_sketch_f result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->sketch_sec = psiconv_empty_sketch_section()))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_cliparts psiconv_empty_cliparts(void)
{
/* Is this correct? */
return psiconv_list_new(sizeof(struct psiconv_clipart_section_s));
}
psiconv_clipart_f psiconv_empty_clipart_f(void)
{
psiconv_clipart_f result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->sections = psiconv_empty_cliparts()))
goto ERROR2;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_file psiconv_empty_file(psiconv_file_type_t type)
{
psiconv_file result;
if (!(result = malloc(sizeof(*result))))
return NULL;
result->type = type;
if (type == psiconv_word_file) {
if (!(result->file = psiconv_empty_word_f()))
goto ERROR;
} else if (type == psiconv_sheet_file) {
if (!(result->file = psiconv_empty_sheet_f()))
goto ERROR;
} else if (type == psiconv_texted_file) {
if (!(result->file = psiconv_empty_texted_f()))
goto ERROR;
} else if (type == psiconv_mbm_file) {
if (!(result->file = psiconv_empty_mbm_f()))
goto ERROR;
} else if (type == psiconv_sketch_file) {
if (!(result->file = psiconv_empty_sketch_f()))
goto ERROR;
} else if (type == psiconv_clipart_file) {
if (!(result->file = psiconv_empty_clipart_f()))
goto ERROR;
} else
goto ERROR;
return result;
ERROR:
free(result);
return NULL;
}
psiconv-0.9.8/lib/psiconv/image.c 0000644 0001750 0001750 00000044006 10336374714 013623 0000000 0000000 /*
image.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2003-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* This file contains definitions used internally by
generate_image.c and parse_image.c */
#include "config.h"
#include "compat.h"
#include
#define PALET_NONE_LEN 0
psiconv_pixel_floats_t psiconv_palet_none =
{
PALET_NONE_LEN,
NULL,
NULL,
NULL
};
#define PALET_COLOR_4_LEN 16
static float palet_color_4_red[PALET_COLOR_4_LEN] =
{ 0x00/255.0, 0x55/255.0, 0x80/255.0, 0x80/255.0, /* 0x00 */
0x00/255.0, 0xff/255.0, 0x00/255.0, 0xff/255.0, /* 0x04 */
0xff/255.0, 0x00/255.0, 0x00/255.0, 0x80/255.0, /* 0x08 */
0x00/255.0, 0x00/255.0, 0xaa/255.0, 0xff/255.0 /* 0x0c */
};
static float palet_color_4_green[PALET_COLOR_4_LEN] =
{ 0x00/255.0, 0x55/255.0, 0x00/255.0, 0x80/255.0, /* 0x00 */
0x80/255.0, 0x00/255.0, 0xff/255.0, 0xff/255.0, /* 0x04 */
0x00/255.0, 0xff/255.0, 0xff/255.0, 0x00/255.0, /* 0x08 */
0x00/255.0, 0x80/255.0, 0xaa/255.0, 0xff/255.0 /* 0x0c */
};
static float palet_color_4_blue[PALET_COLOR_4_LEN] =
{ 0x00/255.0, 0x55/255.0, 0x00/255.0, 0x00/255.0, /* 0x00 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x04 */
0xff/255.0, 0x00/255.0, 0xff/255.0, 0x80/255.0, /* 0x08 */
0x80/255.0, 0x80/255.0, 0xaa/255.0, 0xff/255.0 /* 0x0c */
};
psiconv_pixel_floats_t psiconv_palet_color_4 =
{
PALET_COLOR_4_LEN,
palet_color_4_red,
palet_color_4_green,
palet_color_4_blue,
};
#define PALET_COLOR_8_LEN 256
static float palet_color_8_red[PALET_COLOR_8_LEN] =
{ 0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x00 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x04 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x08 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x0c */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x10 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x14 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x18 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x1c */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x20 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x24 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x28 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x2c */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x30 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x34 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x38 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x3c */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x40 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x44 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x48 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x4c */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x50 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x54 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x58 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x5c */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x60 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x64 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x68 */
0x11/255.0, 0x22/255.0, 0x44/255.0, 0x55/255.0, /* 0x6c */
0x77/255.0, 0x11/255.0, 0x22/255.0, 0x44/255.0, /* 0x70 */
0x55/255.0, 0x77/255.0, 0x00/255.0, 0x00/255.0, /* 0x74 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x78 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x7c */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x80 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x84 */
0x00/255.0, 0x00/255.0, 0x88/255.0, 0xaa/255.0, /* 0x88 */
0xbb/255.0, 0xdd/255.0, 0xee/255.0, 0x88/255.0, /* 0x8c */
0xaa/255.0, 0xbb/255.0, 0xdd/255.0, 0xee/255.0, /* 0x90 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0x94 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0x98 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0x9c */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0xa0 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0xa4 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0xa8 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0xac */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0xb0 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0xb4 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0xb8 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0xbc */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0xc0 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0xc4 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0xc8 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0xcc */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0xd0 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0xd4 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0xd8 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0xdc */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0xe0 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0xe4 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0xe8 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0xec */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0, /* 0xf0 */
0x00/255.0, 0x33/255.0, 0x66/255.0, 0x99/255.0, /* 0xf4 */
0xcc/255.0, 0xff/255.0, 0x00/255.0, 0x33/255.0, /* 0xf8 */
0x66/255.0, 0x99/255.0, 0xcc/255.0, 0xff/255.0 /* 0xfc */
};
static float palet_color_8_green[PALET_COLOR_8_LEN] =
{ 0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x00 */
0x00/255.0, 0x00/255.0, 0x33/255.0, 0x33/255.0, /* 0x04 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x08 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x0c */
0x66/255.0, 0x66/255.0, 0x99/255.0, 0x99/255.0, /* 0x10 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0x14 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0x18 */
0xcc/255.0, 0xcc/255.0, 0xff/255.0, 0xff/255.0, /* 0x1c */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0x20 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x24 */
0x00/255.0, 0x00/255.0, 0x33/255.0, 0x33/255.0, /* 0x28 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x2c */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x30 */
0x66/255.0, 0x66/255.0, 0x99/255.0, 0x99/255.0, /* 0x34 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0x38 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0x3c */
0xcc/255.0, 0xcc/255.0, 0xff/255.0, 0xff/255.0, /* 0x40 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0x44 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x48 */
0x00/255.0, 0x00/255.0, 0x33/255.0, 0x33/255.0, /* 0x4c */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x50 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x54 */
0x66/255.0, 0x66/255.0, 0x99/255.0, 0x99/255.0, /* 0x58 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0x5c */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0x60 */
0xcc/255.0, 0xcc/255.0, 0xff/255.0, 0xff/255.0, /* 0x64 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0x68 */
0x11/255.0, 0x22/255.0, 0x44/255.0, 0x55/255.0, /* 0x6c */
0x77/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x70 */
0x00/255.0, 0x00/255.0, 0x11/255.0, 0x22/255.0, /* 0x74 */
0x44/255.0, 0x55/255.0, 0x77/255.0, 0x00/255.0, /* 0x78 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x7c */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x80 */
0x00/255.0, 0x88/255.0, 0xaa/255.0, 0xbb/255.0, /* 0x84 */
0xdd/255.0, 0xee/255.0, 0x00/255.0, 0x00/255.0, /* 0x88 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x88/255.0, /* 0x8c */
0xaa/255.0, 0xbb/255.0, 0xdd/255.0, 0xee/255.0, /* 0x90 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x94 */
0x00/255.0, 0x00/255.0, 0x33/255.0, 0x33/255.0, /* 0x98 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x9c */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0xa0 */
0x66/255.0, 0x66/255.0, 0x99/255.0, 0x99/255.0, /* 0xa4 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xa8 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xac */
0xcc/255.0, 0xcc/255.0, 0xff/255.0, 0xff/255.0, /* 0xb0 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xb4 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0xb8 */
0x00/255.0, 0x00/255.0, 0x33/255.0, 0x33/255.0, /* 0xbc */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0xc0 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0xc4 */
0x66/255.0, 0x66/255.0, 0x99/255.0, 0x99/255.0, /* 0xc8 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xcc */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xd0 */
0xcc/255.0, 0xcc/255.0, 0xff/255.0, 0xff/255.0, /* 0xd4 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xd8 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0xdc */
0x00/255.0, 0x00/255.0, 0x33/255.0, 0x33/255.0, /* 0xe0 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0xe4 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0xe8 */
0x66/255.0, 0x66/255.0, 0x99/255.0, 0x99/255.0, /* 0xec */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xf0 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xf4 */
0xcc/255.0, 0xcc/255.0, 0xff/255.0, 0xff/255.0, /* 0xf8 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xfc */
};
static float palet_color_8_blue[PALET_COLOR_8_LEN] =
{ 0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x00 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x04 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x08 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x0c */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x10 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x14 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x18 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x1c */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x20 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x24 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x28 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x2c */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x30 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x34 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x38 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x3c */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x40 */
0x33/255.0, 0x33/255.0, 0x33/255.0, 0x33/255.0, /* 0x44 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x48 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x4c */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x50 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x54 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x58 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x5c */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x60 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x64 */
0x66/255.0, 0x66/255.0, 0x66/255.0, 0x66/255.0, /* 0x68 */
0x11/255.0, 0x22/255.0, 0x44/255.0, 0x55/255.0, /* 0x6c */
0x77/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x70 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x74 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x11/255.0, /* 0x78 */
0x22/255.0, 0x44/255.0, 0x55/255.0, 0x77/255.0, /* 0x7c */
0x88/255.0, 0xaa/255.0, 0xbb/255.0, 0xdd/255.0, /* 0x80 */
0xee/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x84 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0, /* 0x88 */
0x00/255.0, 0x00/255.0, 0x00/255.0, 0x88/255.0, /* 0x8c */
0xaa/255.0, 0xbb/255.0, 0xdd/255.0, 0xee/255.0, /* 0x90 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0x94 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0x98 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0x9c */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xa0 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xa4 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xa8 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xac */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xb0 */
0x99/255.0, 0x99/255.0, 0x99/255.0, 0x99/255.0, /* 0xb4 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xb8 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xbc */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xc0 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xc4 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xc8 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xcc */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xd0 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xd4 */
0xcc/255.0, 0xcc/255.0, 0xcc/255.0, 0xcc/255.0, /* 0xd8 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xdc */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xe0 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xe4 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xe8 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xec */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xf0 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xf4 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xf8 */
0xff/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0, /* 0xfc */
};
psiconv_pixel_floats_t psiconv_palet_color_8 =
{
PALET_COLOR_8_LEN,
palet_color_8_red,
palet_color_8_green,
palet_color_8_blue,
};
psiconv-0.9.8/lib/psiconv/unicode.c 0000644 0001750 0001750 00000020076 10336374721 014166 0000000 0000000 /*
unicode.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2003-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include "error.h"
#include "unicode.h"
#include "parse_routines.h"
#include "generate_routines.h"
#include
#include
#ifdef DMALLOC
#include
#endif
psiconv_ucs2 table_cp1252[0x100] =
{
/* 0x00 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, 0x0007,
/* 0x08 */ 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
/* 0x10 */ 0x00a0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
/* 0x18 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
/* 0x20 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
/* 0x28 */ 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
/* 0x30 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
/* 0x38 */ 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
/* 0x40 */ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
/* 0x48 */ 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
/* 0x50 */ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
/* 0x58 */ 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
/* 0x60 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
/* 0x68 */ 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
/* 0x70 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
/* 0x78 */ 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x0000,
/* 0x80 */ 0x20ac, 0x0000, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
/* 0x88 */ 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x017d, 0x0000,
/* 0x90 */ 0x0000, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
/* 0x98 */ 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x0000, 0x017e, 0x0178,
/* 0xa0 */ 0x0000, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
/* 0xa8 */ 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
/* 0xb0 */ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
/* 0xb8 */ 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
/* 0xc0 */ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
/* 0xd8 */ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
/* 0xd0 */ 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
/* 0xe8 */ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
/* 0xe0 */ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
/* 0xc8 */ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
/* 0xf0 */ 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
/* 0xf8 */ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff
};
/* TODO: Check the charset number, select the correct one */
extern int psiconv_unicode_select_characterset(const psiconv_config config,
int charset)
{
switch(charset) {
case 0: config->unicode = psiconv_bool_true;
break;
case 1: config->unicode = psiconv_bool_false;
memcpy(config->unicode_table,table_cp1252,
sizeof(psiconv_ucs2) * 0x100);
break;
default: return -1;
}
return 0;
}
psiconv_ucs2 psiconv_unicode_read_char(const psiconv_config config,
psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,int *status)
{
psiconv_u8 char1,char2,char3;
psiconv_ucs2 result=0;
int res;
int len=0;
char1 = psiconv_read_u8(config,buf,lev,off+len,&res);
if (res)
goto ERROR;
len ++;
if (config->unicode) {
if (char1 >= 0xf0) {
res = PSICONV_E_PARSE;
goto ERROR;
} else if (char1 < 0x80)
result = char1;
else {
char2 = psiconv_read_u8(config,buf,lev,off+len,&res);
len ++;
if ((char2 & 0xc0) != 0x80) {
res = PSICONV_E_PARSE;
goto ERROR;
}
if (char1 < 0xe0)
result = ((char1 & 0x1f) << 6) | (char2 & 0x3f);
else {
char3 = psiconv_read_u8(config,buf,lev,off+len,&res);
len ++;
if ((char3 & 0xc0) != 0x80) {
res = PSICONV_E_PARSE;
goto ERROR;
}
result = ((char1 & 0x0f) << 12) | ((char2 & 0x3f) << 6) |
(char3 & 0x3f);
}
}
} else
result = config->unicode_table[char1]?config->unicode_table[char1]:
config->unknown_unicode_char;
ERROR:
if (length)
*length = len;
if (status)
*status = res;
return result;
}
int psiconv_unicode_write_char(const psiconv_config config,
psiconv_buffer buf,
int lev, psiconv_ucs2 value)
{
int i;
int res=0;
if (config->unicode) {
if (value < 0x80) {
if ((res = psiconv_write_u8(config,buf,lev,value)))
goto ERROR;
} else if (value < 0x800) {
if ((res = psiconv_write_u8(config,buf,lev,0xc0 | (value >> 6))))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev,0x80 | (value & 0x3f))))
goto ERROR;
} else {
if ((res = psiconv_write_u8(config,buf,lev,0xe0 | (value >> 12))))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev,0x80 | ((value >> 6) & 0x3f))))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev,0x80 | (value & 0x3f))))
goto ERROR;
}
} else {
for (i = 0; i < 256; i++)
if (config->unicode_table[i] == value)
break;
if ((res = psiconv_write_u8(config,buf,lev,
i == 256?config->unknown_epoc_char:i)))
goto ERROR;
}
ERROR:
return res;
}
int psiconv_unicode_strlen(const psiconv_ucs2 *input)
{
int i = 0;
while (input[i])
i++;
return i;
}
psiconv_ucs2 *psiconv_unicode_strdup(const psiconv_ucs2 *input)
{
psiconv_ucs2 *output;
int i = 0;
if (!(output = malloc(sizeof(*output) *
(1 + psiconv_unicode_strlen(input)))))
return NULL;
while ((output[i] = input[i]))
i++;
return output;
}
int psiconv_unicode_strcmp(const psiconv_ucs2 *str1, const psiconv_ucs2 *str2)
{
int i = 0;
while (str1[i] && str2[i]) {
if (str1[i] < str2[i])
return -1;
if (str1[i] > str2[i])
return 1;
i++;
}
if (str1[i] < str2[i])
return -1;
else if (str1[i] > str2[i])
return 1;
else
return 0;
}
psiconv_ucs2 *psiconv_unicode_empty_string(void)
{
psiconv_ucs2 *result;
result = malloc(sizeof(psiconv_ucs2));
if (result)
result[0] = 0;
return result;
}
psiconv_ucs2 *psiconv_unicode_from_list(psiconv_list input)
{
psiconv_ucs2 *result;
int i;
psiconv_ucs2 *character;
if (!(result = malloc(sizeof(psiconv_ucs2) * (psiconv_list_length(input)+1))))
goto ERROR1;
for (i = 0; i < psiconv_list_length(input); i++) {
if (!(character = psiconv_list_get(input,i)))
goto ERROR2;
result[i] = *character;
}
result[i] = 0;
return result;
ERROR2:
free(result);
ERROR1:
return NULL;
}
psiconv_ucs2 *psiconv_unicode_strstr(const psiconv_ucs2 *haystack,
const psiconv_ucs2 *needle)
{
int i,j,haystack_len,needle_len;
haystack_len = psiconv_unicode_strlen(haystack);
needle_len = psiconv_unicode_strlen(needle);
for (i = 0; i < haystack_len - needle_len + 1; i++) {
for (j = 0; j < needle_len; j++)
if (haystack[i+j] != needle[j])
break;
if (j == needle_len)
return (psiconv_ucs2 *) haystack+i;
}
return NULL;
}
psiconv-0.9.8/lib/psiconv/parse_common.c 0000644 0001750 0001750 00000126040 10336374671 015224 0000000 0000000 /*
parse_common.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "parse_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
static int psiconv_parse_layout_section(const psiconv_config config,
const psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,
psiconv_text_and_layout result,
psiconv_word_styles_section styles,
int with_styles);
static psiconv_file_type_t psiconv_determine_embedded_object_type
(const psiconv_config config,
const psiconv_buffer buf,int lev,
int *status);
int psiconv_parse_header_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_header_section *result)
{
int res=0;
int len=0;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off+len,"Going to read the header section");
if (!((*result) = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read UID1 to UID3");
(*result)->uid1 = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"UID1: %08x",(*result)->uid1);
if ((*result)->uid1 == PSICONV_ID_CLIPART) {
/* That's all folks... */
(*result)->file = psiconv_clipart_file;
(*result)->uid2 = 0;
(*result)->uid3 = 0;
(*result)->checksum = 0;
len += 4;
psiconv_debug(config,lev+2,off+len,"File is a Clipart file");
goto DONE;
}
if ((*result)->uid1 != PSICONV_ID_PSION5) {
psiconv_error(config,lev+2,off+len,
"UID1 has unknown value. This is probably "
"not a (parsable) Psion 5 file");
res = -PSICONV_E_PARSE;
goto ERROR2;
}
len += 4;
(*result)->uid2 = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"UID2: %08x",(*result)->uid2);
len += 4;
(*result)->uid3 = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"UID3: %08x",(*result)->uid3);
len += 4;
(*result)->file = psiconv_unknown_file;
if ((*result)->uid1 == PSICONV_ID_PSION5) {
if ((*result)->uid2 == PSICONV_ID_DATA_FILE) {
if ((*result)->uid3 == PSICONV_ID_WORD) {
(*result)->file = psiconv_word_file;
psiconv_debug(config,lev+2,off+len,"File is a Word file");
} else if ((*result)->uid3 == PSICONV_ID_TEXTED) {
(*result)->file = psiconv_texted_file;
psiconv_debug(config,lev+2,off+len,"File is a TextEd file");
} else if ((*result)->uid3 == PSICONV_ID_SKETCH) {
(*result)->file = psiconv_sketch_file;
psiconv_debug(config,lev+2,off+len,"File is a Sketch file");
} else if ((*result)->uid3 == PSICONV_ID_SHEET) {
(*result)->file = psiconv_sheet_file;
psiconv_debug(config,lev+2,off+len,"File is a Sheet file");
}
} else if ((*result)->uid2 == PSICONV_ID_MBM_FILE) {
(*result)->file = psiconv_mbm_file;
if ((*result)->uid3 != 0x00)
psiconv_warn(config,lev+2,off+len,"UID3 set in MBM file?!?");
psiconv_debug(config,lev+2,off+len,"File is a MBM file");
}
}
if ((*result)->file == psiconv_unknown_file) {
psiconv_warn(config,lev+2,off+len,"Unknown file type");
(*result)->file = psiconv_unknown_file;
}
psiconv_progress(config,lev+2,off+len,"Checking UID4");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp == psiconv_checkuid((*result)->uid1,(*result)->uid2,
(*result)->uid3))
psiconv_debug(config,lev+2,off+len,"Checksum %08x is correct",temp);
else {
psiconv_error(config,lev+2,off+len,"Checksum failed, file corrupted!");
psiconv_debug(config,lev+2,off+len,"Expected checksum %08x, found %08x",
psiconv_checkuid((*result)->uid1,(*result)->uid2,
(*result)->uid3),temp);
res = -PSICONV_E_PARSE;
goto ERROR2;
}
len += 4;
DONE:
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,
"End of Header Section (total length: %08x)",len);
return res;
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Header Section failed");
if (length)
*length = 0;
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_section_table_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_section_table_section *result)
{
int res=0;
int len=0;
psiconv_section_table_entry entry;
int i;
psiconv_u8 nr;
psiconv_progress(config,lev+1,off+len,"Going to read the section table section");
if (!(*result = psiconv_list_new(sizeof(*entry))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the section table length");
nr = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Length: %08x",nr);
if (nr & 0x01) {
psiconv_warn(config,lev+2,off+len,
"Section table length odd - ignoring last entry");
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read the section table entries");
entry = malloc(sizeof(*entry));
for (i = 0; i < nr / 2; i++) {
entry->id = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off + len,"Entry %d: ID = %08x",i,entry->id);
len += 0x04;
entry->offset = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off +len,"Entry %d: Offset = %08x",i,entry->offset);
len += 0x04;
if ((res=psiconv_list_add(*result,entry)))
goto ERROR3;
}
free(entry);
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of section table section "
"(total length: %08x)", len);
return 0;
ERROR3:
free(entry);
ERROR2:
psiconv_list_free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Section Table Section failed");
if (length)
*length = 0;
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_application_id_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_application_id_section *result)
{
int res=0;
int len=0;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the application id section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the type identifier");
(*result)->id = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Identifier: %08x",(*result)->id);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the application id string");
(*result)->name = psiconv_read_string(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
len += leng;
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of application id section "
"(total length: %08x", len);
return res;
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Application ID Section failed");
if (length)
*length = 0;
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_text_section(const psiconv_config config,
const psiconv_buffer buf,int lev,psiconv_u32 off,
int *length,psiconv_text_and_layout *result)
{
int res = 0;
int len=0;
psiconv_u32 text_len;
psiconv_paragraph para;
psiconv_ucs2 temp;
psiconv_list line;
int nr;
int i,leng;
char *str_copy;
psiconv_progress(config,lev+1,off,"Going to parse the text section");
if(!(*result = psiconv_list_new(sizeof(*para))))
goto ERROR1;
if (!(para = malloc(sizeof(*para))))
goto ERROR2;
psiconv_progress(config,lev+2,off,"Reading the text length");
text_len = psiconv_read_X(config,buf,lev+2,off,&leng,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off,"Length: %08x",text_len);
len += leng;
if (!(line = psiconv_list_new(sizeof(psiconv_ucs2))))
goto ERROR3;
i = 0;
nr = 0;
while (i < text_len) {
temp = psiconv_unicode_read_char(config,buf,lev+2,off+len+i,&leng,&res);
if (res)
goto ERROR4;
if (i + leng > text_len) {
psiconv_error(config,lev+2,off+len+i,"Malformed text section");
res = PSICONV_E_PARSE;
goto ERROR4;
}
if ((temp == 0x06) || (i + leng == text_len)) {
if (!(para->text = psiconv_unicode_from_list(line)))
goto ERROR4;
if (!(str_copy = psiconv_make_printable(config,para->text)))
goto ERROR5;
psiconv_debug(config,lev+2,off+i+len,"Line %d: %d characters",nr,
strlen(str_copy) +1);
psiconv_debug(config,lev+2,off+i+len,"Line %d: `%s'",nr,str_copy);
free(str_copy);
i += leng;
if (!(para->in_lines = psiconv_list_new(sizeof(
struct psiconv_in_line_layout_s))))
goto ERROR5;
if (!(para->replacements = psiconv_list_new(sizeof(
struct psiconv_replacement_s))))
goto ERROR6;
if (!(para->base_character = psiconv_basic_character_layout()))
goto ERROR7;
if (!(para->base_paragraph = psiconv_basic_paragraph_layout()))
goto ERROR8;
para->base_style = 0;
if ((res = psiconv_list_add(*result,para)))
goto ERROR9;
psiconv_progress(config,lev+2,off+len+i,"Starting a new line");
psiconv_list_empty(line);
nr ++;
} else {
if ((res = psiconv_list_add(line,&temp)))
goto ERROR4;
i += leng;
}
}
psiconv_list_free(line);
free(para);
len += text_len;
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,
"End of text section (total length: %08x", len);
return res;
ERROR9:
psiconv_free_paragraph_layout(para->base_paragraph);
ERROR8:
psiconv_free_character_layout(para->base_character);
ERROR7:
psiconv_list_free(para->replacements);
ERROR6:
psiconv_list_free(para->in_lines);
ERROR5:
free(para->text);
ERROR4:
psiconv_list_free(line);
ERROR3:
free(para);
ERROR2:
psiconv_free_text_and_layout(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Text Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
/* First do a parse_text_section, or you will get into trouble here */
int psiconv_parse_layout_section(const psiconv_config config,
const psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,
psiconv_text_and_layout result,
psiconv_word_styles_section styles,
int with_styles)
{
int res = 0;
int len = 0;
psiconv_u32 temp;
int parse_styles,nr,i,j,total,leng,line_length;
typedef struct anon_style_s
{
int nr;
psiconv_s16 base_style;
psiconv_character_layout character;
psiconv_paragraph_layout paragraph;
} *anon_style;
typedef psiconv_list anon_style_list; /* of struct anon_style */
anon_style_list anon_styles;
struct anon_style_s anon;
anon_style anon_ptr=NULL;
psiconv_character_layout temp_char;
psiconv_paragraph_layout temp_para;
psiconv_word_style temp_style;
psiconv_paragraph para;
struct psiconv_in_line_layout_s in_line;
int *inline_count;
psiconv_progress(config,lev+1,off,"Going to read the layout section");
psiconv_progress(config,lev+2,off,"Going to read the section type");
temp = psiconv_read_u16(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
psiconv_debug(config,lev+2,off+len,"Type: %02x",temp);
parse_styles = with_styles;
if ((temp == 0x0001) && !with_styles) {
psiconv_warn(config,lev+2,off+len,"Styleless layout section expected, "
"but styled section found!");
parse_styles = 1;
} else if ((temp == 0x0000) && (with_styles)) {
psiconv_warn(config,lev+2,off+len,"Styled layout section expected, "
"but styleless section found!");
parse_styles = 0;
} else if ((temp != 0x0000) && (temp != 0x0001)) {
psiconv_warn(config,lev+2,off+len,
"Layout section type indicator has unknown value!");
}
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read paragraph type list");
if (!(anon_styles = psiconv_list_new(sizeof(anon))))
goto ERROR1;
psiconv_progress(config,lev+3,off+len,"Going to read paragraph type list length");
nr = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+3,off+len,"Length: %02x",nr);
len ++;
psiconv_progress(config,lev+3,off+len,
"Going to read the paragraph type list elements");
for (i = 0; i < nr; i ++) {
psiconv_progress(config,lev+3,off+len,"Element %d",i);
anon.nr = psiconv_read_u32(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+4,off+len,"Number: %08x",anon.nr);
len += 0x04;
psiconv_progress(config,lev+4,off,"Going to determine the base style");
if (parse_styles) {
temp = psiconv_read_u32(config,buf,lev+4, off+len,&res);
if (res)
goto ERROR3;
anon.base_style = psiconv_read_u8(config,buf,lev+3, off+len+4+temp,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+4,off+len+temp,
"Style indicator: %02x",anon.base_style);
} else
anon.base_style = 0;
if (!(temp_style = psiconv_get_style(styles,anon.base_style))) {
psiconv_warn(config,lev+4,off,"Unknown Style referenced");
if (!(temp_style = psiconv_get_style(styles,anon.base_style))) {
psiconv_warn(config,lev+4,off,"Base style unknown");
goto ERROR3;
}
}
if (!(anon.paragraph = psiconv_clone_paragraph_layout
(temp_style->paragraph)))
goto ERROR3;
if (!(anon.character = psiconv_clone_character_layout
(temp_style->character)))
goto ERROR3_1;
psiconv_progress(config,lev+4,off+len,"Going to read the paragraph layout");
if ((res = psiconv_parse_paragraph_layout_list(config,buf,lev+4,off+len,&leng,
anon.paragraph)))
goto ERROR3_2;
len += leng;
if (parse_styles)
len ++;
psiconv_progress(config,lev+4,off+len,"Going to read the character layout");
if ((res = psiconv_parse_character_layout_list(config,buf,lev+4,off+len,&leng,
anon.character)))
goto ERROR3_2;
len += leng;
if ((res = psiconv_list_add(anon_styles,&anon)))
goto ERROR3_2;
}
psiconv_progress(config,lev+2,off+len,"Going to parse the paragraph element list");
psiconv_progress(config,lev+3,off+len,"Going to read the number of paragraphs");
nr = psiconv_read_u32(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR3;
if (nr != psiconv_list_length(result)) {
psiconv_warn(config,lev+3,off+len,
"Number of text paragraphs and paragraph elements does not match");
psiconv_debug(config,lev+3,off+len,
"%d text paragraphs, %d paragraph elements",
psiconv_list_length(result),nr);
}
psiconv_debug(config,lev+3,off+len,"Number of paragraphs: %d",nr);
len += 4;
if (!(inline_count = malloc(nr * sizeof(*inline_count))))
goto ERROR3;
psiconv_progress(config,lev+3,off+len,"Going to read the paragraph elements");
for (i = 0; i < nr; i ++) {
psiconv_progress(config,lev+3,off+len,"Element %d",i);
if (i >= psiconv_list_length(result)) {
psiconv_debug(config,lev+4,off+len,"Going to allocate a new element");
if (!(para = malloc(sizeof(*para))))
goto ERROR4;
if (!(para->in_lines = psiconv_list_new(sizeof(
struct psiconv_in_line_layout_s))))
goto ERROR4_1;
para->base_style = 0;
if (!(para->base_character = psiconv_basic_character_layout()))
goto ERROR4_2;
if (!(para->base_paragraph = psiconv_basic_paragraph_layout()))
goto ERROR4_3;
if ((res = psiconv_list_add(result,para)))
goto ERROR4_4;
free(para);
}
if (!(para = psiconv_list_get(result,i)))
goto ERROR4;
psiconv_progress(config,lev+4,off+len,"Going to read the paragraph length");
temp = psiconv_read_u32(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR4;
if (temp != psiconv_unicode_strlen(para->text)+1) {
psiconv_warn(config,lev+4,off+len,
"Disagreement of the length of paragraph in layout section");
psiconv_debug(config,lev+4,off+len,
"Paragraph length: layout section says %d, counted %d",
temp,psiconv_unicode_strlen(para->text)+1);
} else
psiconv_debug(config,lev+4,off+len,"Paragraph length: %d",temp);
len += 4;
psiconv_progress(config,lev+4,off+len,"Going to read the paragraph type");
temp = psiconv_read_u8(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR4;
if (temp != 0x00) {
psiconv_debug(config,lev+4,off+len,"Type: %02x",temp);
for (j = 0; j < psiconv_list_length(anon_styles); j++) {
if (!(anon_ptr = psiconv_list_get(anon_styles,j))) {
psiconv_error(config,lev+4,off+len,"Data structure corruption");
goto ERROR4;
}
if (temp == anon_ptr->nr)
break;
}
if (j == psiconv_list_length(anon_styles)) {
psiconv_warn(config,lev+4,off+len,"Layout section paragraph type unknown");
psiconv_debug(config,lev+4,off+len,"Unknown type - using base styles instead");
para->base_style = 0;
if (!(temp_style = psiconv_get_style(styles,0))) {
psiconv_error(config,lev+4,off,"Base style unknown");
goto ERROR4;
}
if (!(temp_para = psiconv_clone_paragraph_layout
(temp_style->paragraph)))
goto ERROR4;
psiconv_free_paragraph_layout(para->base_paragraph);
para->base_paragraph = temp_para;
if (!(temp_char = psiconv_clone_character_layout
(temp_style->character)))
goto ERROR4;
psiconv_free_character_layout(para->base_character);
para->base_character = temp_char;
} else {
para->base_style = anon_ptr->base_style;
if (!(temp_para = psiconv_clone_paragraph_layout (anon_ptr->paragraph)))
goto ERROR4;
psiconv_free_paragraph_layout(para->base_paragraph);
para->base_paragraph = temp_para;
if (!(temp_char = psiconv_clone_character_layout (anon_ptr->character)))
goto ERROR4;
psiconv_free_character_layout(para->base_character);
para->base_character = temp_char;
}
inline_count[i] = 0;
len += 0x01;
} else {
psiconv_debug(config,lev+4,off+len,"Type: %02x (not based on a paragraph type)"
,temp);
len += 0x01;
if (parse_styles) {
temp = psiconv_read_u32(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR4;
psiconv_progress(config,lev+4,off+len+temp+4,
"Going to read the paragraph element base style");
temp = psiconv_read_u8(config,buf,lev+4, off+len+temp+4,&res);
if (res)
goto ERROR4;
psiconv_debug(config,lev+4,off+len+temp+4, "Style: %02x",temp);
} else
temp = 0x00;
if (!(temp_style = psiconv_get_style (styles,temp))) {
psiconv_warn(config,lev+4,off,"Unknown Style referenced");
if (!(temp_style = psiconv_get_style(styles,0))) {
psiconv_error(config,lev+4,off,"Base style unknown");
goto ERROR4;
}
}
if (!(temp_para = psiconv_clone_paragraph_layout(temp_style->paragraph)))
goto ERROR4;
psiconv_free_paragraph_layout(para->base_paragraph);
para->base_paragraph = temp_para;
if (!(temp_char = psiconv_clone_character_layout(temp_style->character)))
goto ERROR4;
psiconv_free_character_layout(para->base_character);
para->base_character = temp_char;
para->base_style = temp;
psiconv_progress(config,lev+4,off+len,"Going to read paragraph layout");
if ((res = psiconv_parse_paragraph_layout_list(config,buf,lev+4,off+len,&leng,
para->base_paragraph)))
goto ERROR4;
len += leng;
if (parse_styles)
len += 1;
psiconv_progress(config,lev+4,off+len,"Going to read number of in-line "
"layout elements");
inline_count[i] = psiconv_read_u32(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR4;
psiconv_debug(config,lev+4,off+len,"Nr: %08x",inline_count[i]);
len += 4;
}
}
psiconv_progress(config,lev+2,off+len,"Going to read the text layout inline list");
psiconv_progress(config,lev+3,off+len,"Going to read the number of elements");
nr = psiconv_read_u32(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR4;
psiconv_debug(config,lev+3,off+len,"Elements: %08x",nr);
len += 0x04;
psiconv_progress(config,lev+3,off+len,
"Going to read the text layout inline elements");
total = 0;
for (i = 0; i < psiconv_list_length(result); i++) {
if (!(para = psiconv_list_get(result,i))) {
psiconv_error(config,lev+3,off+len,"Data structure corruption");
goto ERROR4;
}
line_length = -1;
for (j = 0; j < inline_count[i]; j++) {
psiconv_progress(config,lev+3,off+len,"Element %d: Paragraph %d, element %d",
total,i,j);
if (total >= nr) {
psiconv_warn(config,lev+3,off+len,
"Layout section inlines: not enough element");
psiconv_debug(config,lev+3,off+len,"Can't read element!");
} else {
total ++;
in_line.object = NULL;
in_line.layout = NULL;
if (!(in_line.layout = psiconv_clone_character_layout
(para->base_character)))
goto ERROR4;
psiconv_progress(config,lev+4,off+len,"Going to read the element type");
temp = psiconv_read_u8(config,buf,lev+4,len+off,&res);
if (res)
goto ERROR5;
len += 1;
psiconv_debug(config,lev+4,off+len,"Type: %02x",temp);
psiconv_progress(config,lev+4,off+len,
"Going to read the number of characters it applies to");
in_line.length = psiconv_read_u32(config,buf,lev+4,len+off,&res);
if (res)
goto ERROR5;
psiconv_debug(config,lev+4,off+len,"Length: %02x",in_line.length);
len += 4;
psiconv_progress(config,lev+4,off+len,"Going to read the character layout");
if ((res = psiconv_parse_character_layout_list(config,buf,lev+4,off+len,&leng,
in_line.layout)))
goto ERROR5;
len += leng;
if (temp == 0x01) {
psiconv_debug(config,lev+4,off+len,"Found an embedded object");
psiconv_progress(config,lev+4,off+len,"Going to read the object marker "
"(0x%08x expected)",PSICONV_ID_OBJECT);
temp = psiconv_read_u32(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR5;
if (temp != PSICONV_ID_OBJECT) {
psiconv_warn(config,lev+4,off+len,"Unknown id marks embedded object");
psiconv_debug(config,lev+4,off+len,"Marker: read %08x, expected %08x",
temp,PSICONV_ID_OBJECT);
}
len += 4;
psiconv_progress(config,lev+4,off+len,
"Going to read the Embedded Object Section offset");
temp = psiconv_read_u32(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR5;
psiconv_debug(config,lev+4,off+len, "Offset: %08x",temp);
len += 4;
psiconv_progress(config,lev+4,off+len,
"Going to parse the Embedded Object Section");
if ((res = psiconv_parse_embedded_object_section(config,buf,lev+4,temp,
NULL,&(in_line.object))))
goto ERROR5;
psiconv_progress(config,lev+4,off+len,
"Going to read the object width");
in_line.object_width = psiconv_read_length(config,buf,lev+4,off+len,
&leng,&res);
if (res)
goto ERROR5;
psiconv_debug(config,lev+4,off+len,"Object width: %f cm",
in_line.object_width);
len += leng;
psiconv_progress(config,lev+4,off+len,
"Going to read the object height");
in_line.object_height = psiconv_read_length(config,buf,lev+4,off+len,&leng,
&res);
if (res)
goto ERROR5;
psiconv_debug(config,lev+4,off+len,"Object height: %f cm",
in_line.object_height);
len += leng;
} else if (temp != 0x00) {
psiconv_warn(config,lev+4,off+len,"Layout section unknown inline type");
}
if (line_length + in_line.length > psiconv_unicode_strlen(para->text)) {
psiconv_warn(config,lev+4,off+len,
"Layout section inlines: line length mismatch");
res = -1;
in_line.length = psiconv_unicode_strlen(para->text) - line_length;
}
line_length += in_line.length;
if ((res = psiconv_list_add(para->in_lines,&in_line)))
goto ERROR5;
}
}
}
if (total != nr) {
psiconv_warn(config,lev+4,off+len,
"Layout section too many inlines, skipping remaining");
}
free(inline_count);
for (i = 0 ; i < psiconv_list_length(anon_styles); i ++) {
if (!(anon_ptr = psiconv_list_get(anon_styles,i))) {
psiconv_error(config,lev+4,off+len,"Data structure corruption");
goto ERROR2;
}
psiconv_free_character_layout(anon_ptr->character);
psiconv_free_paragraph_layout(anon_ptr->paragraph);
}
psiconv_list_free(anon_styles);
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of layout section (total length: %08x)",
len);
return 0;
ERROR4_4:
psiconv_free_paragraph_layout(para->base_paragraph);
ERROR4_3:
psiconv_free_character_layout(para->base_character);
ERROR4_2:
psiconv_list_free(para->in_lines);
ERROR4_1:
free(para);
goto ERROR4;
ERROR3_2:
psiconv_free_character_layout(anon.character);
ERROR3_1:
psiconv_free_paragraph_layout(anon.paragraph);
goto ERROR3;
ERROR5:
if (in_line.layout)
psiconv_free_character_layout(in_line.layout);
if (in_line.object)
psiconv_free_embedded_object_section(in_line.object);
ERROR4:
free(inline_count);
ERROR3:
for (i = 0; i < psiconv_list_length(anon_styles); i++) {
if (!(anon_ptr = psiconv_list_get(anon_styles,i))) {
psiconv_error(config,lev+1,off,"Data structure corruption");
break;
}
psiconv_free_paragraph_layout(anon_ptr->paragraph);
psiconv_free_character_layout(anon_ptr->character);
}
ERROR2:
psiconv_list_free(anon_styles);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Layout Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_styled_layout_section(const psiconv_config config,
const psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,
psiconv_text_and_layout result,
psiconv_word_styles_section styles)
{
return psiconv_parse_layout_section(config,buf,lev,off,length,result,styles,1);
}
int psiconv_parse_styleless_layout_section(const psiconv_config config,
const psiconv_buffer buf,
int lev,psiconv_u32 off,
int *length,
psiconv_text_and_layout result,
const psiconv_character_layout base_char,
const psiconv_paragraph_layout base_para)
{
int res = 0;
psiconv_word_styles_section styles_section;
if (!(styles_section = malloc(sizeof(*styles_section))))
goto ERROR1;
if (!(styles_section->normal = malloc(sizeof(*styles_section->normal))))
goto ERROR2;
if (!(styles_section->normal->character =
psiconv_clone_character_layout(base_char)))
goto ERROR3;
if (!(styles_section->normal->paragraph =
psiconv_clone_paragraph_layout(base_para)))
goto ERROR4;
styles_section->normal->hotkey = 0;
if (!(styles_section->normal->name = psiconv_unicode_empty_string()))
goto ERROR5;
if (!(styles_section->styles = psiconv_list_new(sizeof(
struct psiconv_word_style_s))))
goto ERROR6;
res = psiconv_parse_layout_section(config,buf,lev,off,length,result,
styles_section,0);
psiconv_free_word_styles_section(styles_section);
return res;
ERROR6:
free(styles_section->normal->name);
ERROR5:
psiconv_free_paragraph_layout(styles_section->normal->paragraph);
ERROR4:
psiconv_free_character_layout(styles_section->normal->character);
ERROR3:
free(styles_section->normal);
ERROR2:
free(styles_section);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Styleless Layout Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_embedded_object_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_embedded_object_section *result)
{
int res=0;
int len=0;
int leng,i;
psiconv_section_table_section table;
psiconv_section_table_entry entry;
psiconv_u32 icon_sec=0,display_sec=0,table_sec=0;
psiconv_buffer subbuf;
psiconv_progress(config,lev+1,off+len,"Going to read an Embedded Object");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the Embedded Object Section");
psiconv_parse_section_table_section(config,buf,lev+2,off+len,&leng,&table);
len += leng;
for (i = 0; i < psiconv_list_length(table); i++) {
psiconv_progress(config,lev+2,off+len,"Going to read entry %d",i);
if (!(entry = psiconv_list_get(table,i)))
goto ERROR2;
if (entry->id == PSICONV_ID_OBJECT_DISPLAY_SECTION) {
display_sec = entry->offset;
psiconv_debug(config,lev+3,off+len,"Found the Object Display Section at %08x",
display_sec);
} else if (entry->id == PSICONV_ID_OBJECT_ICON_SECTION) {
icon_sec = entry->offset;
psiconv_debug(config,lev+3,off+len,"Found the Object Icon Section at %08x",
icon_sec);
} else if (entry->id == PSICONV_ID_OBJECT_SECTION_TABLE_SECTION) {
table_sec = entry->offset;
psiconv_debug(config,lev+3,off+len,"Found the Object Section Table Section at %08x",
table_sec);
} else {
psiconv_warn(config,lev+3,off+len,
"Found unknown section in the Object Display Section "
"(ignoring)");
psiconv_debug(config,lev+3,off+len,"Section ID %08x, offset %08x",
entry->id, entry->offset);
}
}
psiconv_progress(config,lev+2,off+len,"Looking for the Object Display Section");
if (!icon_sec) {
psiconv_warn(config,lev+2,off+len,"Object Display Section not found");
(*result)->display = NULL;
} else {
psiconv_debug(config,lev+2,off+len,"Object Display Section at offset %08x",
display_sec);
if ((res = psiconv_parse_object_display_section(config,buf,lev+2,display_sec,NULL,
&(*result)->display)))
goto ERROR2;
}
psiconv_progress(config,lev+2,off+len,"Looking for the Object Icon Section");
if (!icon_sec) {
psiconv_warn(config,lev+2,off+len,"Object Icon Section not found");
(*result)->icon = NULL;
} else {
psiconv_debug(config,lev+2,off+len,"Object Icon Section at offset %08x",icon_sec);
if ((res = psiconv_parse_object_icon_section(config,buf,lev+2,icon_sec,NULL,
&(*result)->icon)))
goto ERROR3;
}
psiconv_progress(config,lev+2,off+len,
"Looking for the Section Table Offset Section");
if (!table_sec) {
psiconv_warn(config,lev+2,off+len,
"Embedded Section Table Offset Section not found");
(*result)->object = NULL;
} else {
psiconv_progress(config,lev+2,off+len,
"Extracting object: add %08x to all following offsets",
table_sec);
/* We can't determine the length of the object, so we just take it all */
if ((res = psiconv_buffer_subbuffer(&subbuf,buf,table_sec,
psiconv_buffer_length(buf)-table_sec)))
goto ERROR4;
if (!((*result)->object = malloc(sizeof(*(*result)->object))))
goto ERROR5;
/* We need to find the file type, but we don't have a normal header */
/* So we try to find the Application ID Section and hope for the best */
psiconv_progress(config,lev+3,0,"Trying to determine the file type");
(*result)->object->type = psiconv_determine_embedded_object_type
(config,subbuf,lev+3,&res);
switch ((*result)->object->type) {
case psiconv_word_file:
if ((res = psiconv_parse_word_file(config,subbuf,lev+3,0,
((psiconv_word_f *) &(*result)->object->file))))
goto ERROR6;
break;
case psiconv_texted_file:
if ((res = psiconv_parse_texted_file(config,subbuf,lev+3,0,
((psiconv_texted_f *) &(*result)->object->file))))
goto ERROR6;
break;
case psiconv_sheet_file:
if ((res = psiconv_parse_sheet_file(config,subbuf,lev+3,0,
((psiconv_sheet_f *) &(*result)->object->file))))
goto ERROR6;
break;
case psiconv_sketch_file:
if ((res = psiconv_parse_sketch_file(config,subbuf,lev+3,0,
((psiconv_sketch_f *) &(*result)->object->file))))
goto ERROR6;
break;
default:
psiconv_warn(config,lev+3,0,"Can't parse embedded object (still continuing)");
(*result)->object->file = NULL;
}
}
psiconv_buffer_free(subbuf);
psiconv_free_section_table_section(table);
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of Embedded Object Section "
"(total length: %08x)",len);
return res;
ERROR6:
free((*result)->object);
ERROR5:
psiconv_buffer_free(subbuf);
ERROR4:
psiconv_free_object_icon_section((*result)->icon);
ERROR3:
psiconv_free_object_display_section((*result)->display);
ERROR2:
psiconv_free_section_table_section(table);
ERROR1:
psiconv_error(config,lev+1,off,"Reading Embedded Object failed");
if (length)
*length = 0;
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv_file_type_t psiconv_determine_embedded_object_type
(const psiconv_config config,
const psiconv_buffer buf,int lev,
int *status)
{
psiconv_u32 off;
psiconv_section_table_section table;
int res,i;
psiconv_file_type_t file_type = psiconv_unknown_file;
psiconv_section_table_entry entry;
psiconv_application_id_section applid;
psiconv_progress(config,lev+1,0,"Going to determine embedded object file type");
psiconv_progress(config,lev+2,0,"Going to read the Section Table Offset Section");
off = psiconv_read_u32(config,buf,lev,0,&res);
if (res)
goto ERROR1;
psiconv_debug(config,lev+2,0,"Offset: %08x",off);
psiconv_progress(config,lev+2,off,"Going to read the Section Table Section");
if ((res = psiconv_parse_section_table_section(config,buf,lev+2,off,NULL,&table)))
goto ERROR1;
psiconv_progress(config,lev+2,off,"Going to search the Section Table Section "
"for the Application ID Section");
for (i=0; i < psiconv_list_length(table); i++) {
psiconv_progress(config,lev+3,off,"Going to read entry %d",i);
if (!(entry = psiconv_list_get(table,i)))
goto ERROR2;
if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
psiconv_progress(config,lev+3,off,
"Found the Application ID Section at offset %08x",
entry->offset);
off = entry->offset;
break;
}
}
if (i == psiconv_list_length(table)) {
psiconv_error(config,lev+2,off,"No Application ID Section found");
res = PSICONV_E_PARSE;
goto ERROR2;
}
psiconv_progress(config,lev+2,off,"Going to read the Application ID Section");
if ((res = psiconv_parse_application_id_section(config,buf,lev+2,off,NULL,&applid)))
goto ERROR2;
switch (applid->id) {
case PSICONV_ID_WORD: file_type = psiconv_word_file;
psiconv_debug(config,lev+2,off,"Found a Word file");
break;
case PSICONV_ID_TEXTED: file_type = psiconv_texted_file;
psiconv_debug(config,lev+2,off,"Found a TextEd file");
break;
case PSICONV_ID_SKETCH: file_type = psiconv_sketch_file;
psiconv_debug(config,lev+2,off,"Found a Sketch file");
break;
case PSICONV_ID_SHEET: file_type = psiconv_sheet_file;
psiconv_debug(config,lev+2,off,"Found a Sheet file");
break;
default: psiconv_warn(config,lev+2,off,"Found an unknown file type");
psiconv_debug(config,lev+2,off,"Found ID %08x",applid->id);
}
ERROR2:
psiconv_free_application_id_section(applid);
ERROR1:
psiconv_free_section_table_section(table);
if (status)
*status = res;
return file_type;
}
int psiconv_parse_object_display_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_object_display_section *result)
{
int res = 0;
int len = 0;
int leng;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off,"Going to read the Object Display Section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the display as icon flag "
"(expecting 0x00 or 0x01)");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp == 0x00) {
(*result)->show_icon = psiconv_bool_true;
psiconv_debug(config,lev+2,off+len,"Displayed as icon");
} else if (temp == 0x01) {
(*result)->show_icon = psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Displayed as full document");
} else {
psiconv_warn(config,lev+2,off+len,"Unknown Object Display Section Icon Flag");
psiconv_debug(config,lev+2,off+len,"Icon flag found: %02x",temp);
/* Improvise */
(*result)->show_icon = (temp & 0x01?psiconv_bool_false:psiconv_bool_true);
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read the display width");
(*result)->width = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Display width: %f cm",(*result)->width);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the display height");
(*result)->height = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Display length: %f cm",(*result)->height);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read unknown long (%08x expected)",
0);
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (temp != 0) {
psiconv_warn(config,lev+2,off+len,"Unknown Object Display Section final long");
psiconv_debug(config,lev+2,off+len,"Long read: %08x",temp);
}
len += 4;
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of Object Display Section "
"(total length: %08x",len);
return res;
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off+len,"Reading of Object Display Section failed");
if (length)
*length=0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_object_icon_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_object_icon_section *result)
{
int res = 0;
int len = 0;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the Object Icon Section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the icon name");
(*result)->icon_name = psiconv_read_string(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the icon width");
(*result)->icon_width = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Icon width: %f cm",(*result)->icon_width);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the icon height");
(*result)->icon_height = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Icon length: %f cm",(*result)->icon_height);
len += leng;
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of Object Icon Section"
"(total length: %08x",len);
return res;
ERROR3:
free((*result)->icon_name);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off+len,"Reading of Object Icon Section failed");
if (length)
*length=0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/parse_driver.c 0000644 0001750 0001750 00000074475 10336374673 015247 0000000 0000000 /*
parse_driver.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "parse.h"
#include "parse_routines.h"
#include "unicode.h"
#ifdef DMALLOC
#include
#endif
/* Compare whether application id names match.
Sought must be lower case; the comparison is case insensitive */
static psiconv_bool_t applid_matches(psiconv_string_t found,
const char *sought)
{
int i;
if (psiconv_unicode_strlen(found) != strlen(sought))
return psiconv_bool_false;
for (i = 0; i < strlen(sought); i++)
if ((found[i] != sought[i]) &&
((sought[i] < 'a') || (sought[i] > 'z') ||
(found[i] != sought[i] + 'A' - 'a')))
return psiconv_bool_false;
return psiconv_bool_true;
}
psiconv_file_type_t psiconv_file_type(const psiconv_config config,
psiconv_buffer buf,int *length,
psiconv_header_section *result)
{
psiconv_header_section header;
psiconv_file_type_t res;
int leng;
if ((psiconv_parse_header_section(config,buf,0,0,&leng,&header)))
return psiconv_unknown_file;
res = header->file;
if (result)
*result = header;
else
psiconv_free_header_section(header);
if (length)
*length = leng;
return res;
}
int psiconv_parse(const psiconv_config config,const psiconv_buffer buf,
psiconv_file *result)
{
int res=0;
int lev=0;
int off=0;
int leng;
if (!((*result) = malloc(sizeof(**result))))
goto ERROR1;
(*result)->type = psiconv_file_type(config,buf,&leng,NULL);
if ((*result)->type == psiconv_unknown_file) {
psiconv_warn(config,lev+1,off,"Unknown file type: can't parse!");
(*result)->file = NULL;
} else if ((*result)->type == psiconv_word_file)
res = psiconv_parse_word_file(config,buf,lev+2,leng,
(psiconv_word_f *)(&((*result)->file)));
else if ((*result)->type == psiconv_texted_file)
res = psiconv_parse_texted_file(config,buf,lev+2,leng,
(psiconv_texted_f *)(&((*result)->file)));
else if ((*result)->type == psiconv_mbm_file)
res = psiconv_parse_mbm_file(config,buf,lev+2,leng,
(psiconv_mbm_f *)(&((*result)->file)));
else if ((*result)->type == psiconv_sketch_file)
res = psiconv_parse_sketch_file(config,buf,lev+2,leng,
(psiconv_sketch_f *)(&((*result)->file)));
else if ((*result)->type == psiconv_clipart_file)
res = psiconv_parse_clipart_file(config,buf,lev+2,leng,
(psiconv_clipart_f *)(&((*result)->file)));
else if ((*result)->type == psiconv_sheet_file)
res = psiconv_parse_sheet_file(config,buf,lev+2,leng,
(psiconv_sheet_f *)(&((*result)->file)));
else {
psiconv_warn(config,lev+1,off,"Can't parse this file yet!");
(*result)->file = NULL;
}
if (res)
goto ERROR2;
return 0;
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Psion File failed");
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_clipart_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, psiconv_clipart_f *result)
{
int res=0;
int i;
psiconv_jumptable_section table;
psiconv_clipart_section clipart;
psiconv_u32 *entry;
psiconv_progress(config,lev+1,off,"Going to read a clipart file");
if (!((*result) = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off,"Going to read the MBM jumptable");
if ((res = psiconv_parse_jumptable_section(config,buf,lev+2,off, NULL,&table)))
goto ERROR2;
psiconv_progress(config,lev+2,off,"Going to read the clipart sections");
if (!((*result)->sections = psiconv_list_new(sizeof(*clipart))))
goto ERROR3;
for (i = 0; i < psiconv_list_length(table); i ++) {
if (!(entry = psiconv_list_get(table,i)))
goto ERROR4;
psiconv_progress(config,lev+3,off,"Going to read clipart section %i",i);
if ((res = psiconv_parse_clipart_section(config,buf,lev+3,*entry,NULL,&clipart)))
goto ERROR4;
if ((res = psiconv_list_add((*result)->sections,clipart)))
goto ERROR5;
free(clipart);
}
psiconv_free_jumptable_section(table);
psiconv_progress(config,lev+1,off,"End of clipart file");
return res;
ERROR5:
psiconv_free_clipart_section(clipart);
ERROR4:
for (i = 0; i < psiconv_list_length((*result)->sections); i++) {
if (!(clipart = psiconv_list_get((*result)->sections,i))) {
psiconv_error(config,lev+1,off,"Data structure corruption");
goto ERROR3;
}
psiconv_free_clipart_section(clipart);
}
psiconv_list_free((*result)->sections);
ERROR3:
psiconv_free_jumptable_section(table);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Clipart File failed");
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_mbm_file(const psiconv_config config,
const psiconv_buffer buf,int lev, psiconv_u32 off,
psiconv_mbm_f *result)
{
int res=0;
int i;
psiconv_jumptable_section table;
psiconv_paint_data_section paint;
psiconv_u32 *entry;
psiconv_u32 sto;
psiconv_progress(config,lev+1,off,"Going to read a mbm file");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off,"Going to read the offset of the MBM jumptable");
sto = psiconv_read_u32(config,buf,lev+2,off,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off,"Offset: %08x",sto);
psiconv_progress(config,lev+2,off,"Going to read the MBM jumptable");
if ((res = psiconv_parse_jumptable_section(config,buf,lev+2,sto, NULL,&table)))
goto ERROR2;
psiconv_progress(config,lev+2,off,"Going to read the picture sections");
if (!((*result)->sections = psiconv_list_new(sizeof(*paint))))
goto ERROR3;
for (i = 0; i < psiconv_list_length(table); i ++) {
if (!(entry = psiconv_list_get(table,i)))
goto ERROR4;
psiconv_progress(config,lev+3,off,"Going to read picture section %i",i);
if ((res = psiconv_parse_paint_data_section(config,buf,lev+3,*entry,NULL,
0,&paint)))
goto ERROR4;
if ((res = psiconv_list_add((*result)->sections,paint)))
goto ERROR5;
free(paint);
}
psiconv_free_jumptable_section(table);
psiconv_progress(config,lev+1,off,"End of mbm file");
return 0;
ERROR5:
psiconv_free_paint_data_section(paint);
ERROR4:
for (i = 0; i < psiconv_list_length((*result)->sections); i++) {
if (!(paint = psiconv_list_get((*result)->sections,i))) {
psiconv_error(config,lev+1,off,"Data structure corruption");
goto ERROR3;
}
psiconv_free_paint_data_section(paint);
}
psiconv_list_free((*result)->sections);
ERROR3:
psiconv_free_jumptable_section(table);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of MBM File failed");
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sketch_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off,
psiconv_sketch_f *result)
{
psiconv_section_table_section table;
psiconv_application_id_section appl_id;
psiconv_u32 applid_sec = 0;
psiconv_u32 sketch_sec = 0;
psiconv_u32 sto;
psiconv_section_table_entry entry;
int i;
int res=0;
char *temp_str;
psiconv_progress(config,lev+1,off,"Going to read a sketch file");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off,
"Going to read the offset of the section table section");
sto = psiconv_read_u32(config,buf,lev+2,off,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off,"Offset: %08x",sto);
psiconv_progress(config,lev+2,sto, "Going to read the section table section");
if ((res = psiconv_parse_section_table_section(config,buf,lev+2,sto, NULL,&table)))
goto ERROR2;
for (i = 0; i < psiconv_list_length(table); i ++) {
psiconv_progress(config,lev+2,sto, "Going to read entry %d",i);
if (!(entry = psiconv_list_get(table,i)))
goto ERROR3;
if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
applid_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Application ID section at %08x",applid_sec);
} else if (entry->id == PSICONV_ID_SKETCH_SECTION) {
sketch_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Sketch section at %08x",sketch_sec);
} else {
psiconv_warn(config,lev+3,sto,
"Found unknown section in the Section Table (ignoring)");
psiconv_debug(config,lev+3,sto,
"Section ID %08x, offset %08x",entry->id,entry->offset);
}
}
psiconv_progress(config,lev+2,sto, "Looking for the Application ID section");
if (! applid_sec) {
psiconv_error(config,lev+2,sto,
"Application ID section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR3;
} else {
psiconv_debug(config,lev+2,sto,
"Application ID section at offset %08x",applid_sec);
if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL,
&appl_id)))
goto ERROR3;
}
if ((appl_id->id != PSICONV_ID_SKETCH) ||
!applid_matches(appl_id->name,"paint.app")) {
psiconv_warn(config,lev+2,applid_sec,
"Application ID section contains unexpected data");
psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",
PSICONV_ID_SKETCH,appl_id->id);
if (!(temp_str = psiconv_make_printable(config,appl_id->name)))
goto ERROR4;
psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found",
"Paint.app",temp_str);
free(temp_str);
res = -PSICONV_E_PARSE;
goto ERROR4;
}
psiconv_progress(config,lev+2,sto, "Looking for the Sketch section");
if (! sketch_sec) {
psiconv_warn(config,lev+2,sto,
"Sketch section not found in the section table");
} else {
psiconv_debug(config,lev+2,sto,
"Sketch section at offset %08x",applid_sec);
if ((res = psiconv_parse_sketch_section(config,buf,lev+2,sketch_sec,NULL,
&(*result)->sketch_sec)))
goto ERROR4;
}
psiconv_free_application_id_section(appl_id);
psiconv_free_section_table_section(table);
psiconv_progress(config,lev+1,off,"End of sketch file");
return res;
ERROR4:
psiconv_free_application_id_section(appl_id);
ERROR3:
free(table);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sketch File failed");
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_texted_file(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off,
psiconv_texted_f *result)
{
int res=0;
psiconv_section_table_section table;
psiconv_application_id_section appl_id;
char *temp_str;
psiconv_character_layout base_char;
psiconv_paragraph_layout base_para;
psiconv_u32 page_sec = 0;
psiconv_u32 texted_sec = 0;
psiconv_u32 applid_sec = 0;
psiconv_u32 sto;
psiconv_section_table_entry entry;
int i;
psiconv_progress(config,lev+1,off,"Going to read a texted file");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off,
"Going to read the offset of the section table section");
sto = psiconv_read_u32(config,buf,lev+2,off,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off,"Offset: %08x",sto);
psiconv_progress(config,lev+2,sto, "Going to read the section table section");
if ((res = psiconv_parse_section_table_section(config,buf,lev+2,sto, NULL,&table)))
goto ERROR2;
for (i = 0; i < psiconv_list_length(table); i ++) {
psiconv_progress(config,lev+2,sto, "Going to read entry %d",i);
if (!(entry = psiconv_list_get(table,i)))
goto ERROR3;
if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
applid_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Application ID section at %08x",applid_sec);
} else if (entry->id == PSICONV_ID_PAGE_LAYOUT_SECTION) {
page_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Page Layout section at %08x",page_sec);
} else if (entry->id == PSICONV_ID_TEXTED) {
texted_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the TextEd section at %08x",texted_sec);
} else {
psiconv_warn(config,lev+3,sto,
"Found unknown section in the Section Table (ignoring)");
psiconv_debug(config,lev+3,sto,
"Section ID %08x, offset %08x",entry->id,entry->offset);
}
}
psiconv_progress(config,lev+2,sto, "Looking for the Application ID section");
if (! applid_sec) {
psiconv_error(config,lev+2,sto,
"Application ID section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR3;
} else {
psiconv_debug(config,lev+2,sto,
"Application ID section at offset %08x",applid_sec);
if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL,
&appl_id)))
goto ERROR3;
}
if ((appl_id->id != PSICONV_ID_TEXTED) ||
!applid_matches(appl_id->name,"texted.app")) {
psiconv_warn(config,lev+2,applid_sec,
"Application ID section contains unexpected data");
psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",
PSICONV_ID_TEXTED,appl_id->id);
if (!(temp_str = psiconv_make_printable(config,appl_id->name)))
goto ERROR4;
psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found",
"TextEd.app",temp_str);
free(temp_str);
res = -PSICONV_E_PARSE;
goto ERROR4;
}
psiconv_progress(config,lev+2,sto,
"Looking for the Page layout section");
if (! page_sec) {
psiconv_error(config,lev+2,sto,
"Page layout section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR4;
} else {
psiconv_debug(config,lev+2,sto,
"Page layout section at offset %08x",page_sec);
if ((res = psiconv_parse_page_layout_section(config,buf,lev+2,page_sec,NULL,
&(*result)->page_sec)))
goto ERROR4;
}
if (!(base_char = psiconv_basic_character_layout()))
goto ERROR5;
if (!(base_para = psiconv_basic_paragraph_layout()))
goto ERROR6;
psiconv_progress(config,lev+2,sto,
"Looking for the TextEd section");
if (! texted_sec) {
psiconv_error(config,lev+2,sto,
"TextEd section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR7;
} else {
psiconv_debug(config,lev+2,sto, "TextEd section at offset %08x",texted_sec);
if ((res = psiconv_parse_texted_section(config,buf,lev+2,texted_sec,NULL,
&(*result)->texted_sec,
base_char,base_para)))
goto ERROR7;
}
psiconv_free_character_layout(base_char);
psiconv_free_paragraph_layout(base_para);
psiconv_free_application_id_section(appl_id);
psiconv_free_section_table_section(table);
psiconv_progress(config,lev+1,off,"End of TextEd file");
return 0;
ERROR7:
psiconv_free_paragraph_layout(base_para);
ERROR6:
psiconv_free_character_layout(base_char);
ERROR5:
psiconv_free_page_layout_section((*result)->page_sec);
ERROR4:
psiconv_free_application_id_section(appl_id);
ERROR3:
psiconv_free_section_table_section(table);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of TextEd File failed");
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_word_file(const psiconv_config config,
const psiconv_buffer buf,int lev, psiconv_u32 off,
psiconv_word_f *result)
{
int res=0;
psiconv_section_table_section table;
psiconv_application_id_section appl_id;
char *temp_str;
psiconv_u32 pwd_sec = 0;
psiconv_u32 status_sec = 0;
psiconv_u32 styles_sec = 0;
psiconv_u32 page_sec = 0;
psiconv_u32 text_sec = 0;
psiconv_u32 layout_sec = 0;
psiconv_u32 applid_sec = 0;
psiconv_section_table_entry entry;
psiconv_u32 sto;
int i;
psiconv_progress(config,lev+1,off,"Going to read a word file");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off,
"Going to read the offset of the section table section");
sto = psiconv_read_u32(config,buf,lev+2,off,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off,"Offset: %08x",sto);
psiconv_progress(config,lev+2,sto,
"Going to read the section table section");
if ((res = psiconv_parse_section_table_section(config,buf,lev+2,sto, NULL,&table)))
goto ERROR2;
for (i = 0; i < psiconv_list_length(table); i ++) {
psiconv_progress(config,lev+2,sto, "Going to read entry %d",i);
if (!(entry = psiconv_list_get(table,i)))
goto ERROR3;
if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
applid_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Application ID section at %08x",applid_sec);
} else if (entry->id == PSICONV_ID_PAGE_LAYOUT_SECTION) {
page_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Page Layout section at %08x",page_sec);
} else if (entry->id == PSICONV_ID_TEXT_SECTION) {
text_sec = entry->offset;
psiconv_debug(config,lev+3,sto, "Found the Text section at %08x",text_sec);
} else if (entry->id == PSICONV_ID_PASSWORD_SECTION) {
pwd_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Password section at %08x",pwd_sec);
psiconv_error(config,lev+3,sto,
"Password section found - can't read encrypted data");
res = -PSICONV_E_PARSE;
goto ERROR3;
} else if (entry->id == PSICONV_ID_WORD_STATUS_SECTION) {
status_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Word Status section at %08x",status_sec);
} else if (entry->id == PSICONV_ID_WORD_STYLES_SECTION) {
styles_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Word Styles section at %08x",styles_sec);
} else if (entry->id == PSICONV_ID_LAYOUT_SECTION) {
layout_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Layout section at %08x",layout_sec);
} else {
psiconv_warn(config,lev+3,sto,
"Found unknown section in the Section Table (ignoring)");
psiconv_debug(config,lev+3,sto,
"Section ID %08x, offset %08x",entry->id,entry->offset);
}
}
psiconv_progress(config,lev+2,sto,
"Looking for the Status section");
if (!status_sec) {
psiconv_error(config,lev+2,sto, "Status section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR3;
} else {
psiconv_debug(config,lev+2,sto, "Status section at offset %08x",status_sec);
if ((res = psiconv_parse_word_status_section(config,buf,lev+2,status_sec,NULL,
&((*result)->status_sec))))
goto ERROR3;
}
psiconv_progress(config,lev+2,sto, "Looking for the Application ID section");
if (! applid_sec) {
psiconv_error(config,lev+2,sto,
"Application ID section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR4;
} else {
psiconv_debug(config,lev+2,sto,
"Application ID section at offset %08x",applid_sec);
if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL,
&appl_id)))
goto ERROR4;
}
if ((appl_id->id != PSICONV_ID_WORD) ||
!applid_matches(appl_id->name,"word.app")) {
psiconv_warn(config,lev+2,applid_sec,
"Application ID section contains unexpected data");
psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",
PSICONV_ID_WORD,appl_id->id);
if (!(temp_str = psiconv_make_printable(config,appl_id->name)))
goto ERROR5;
psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found",
"Word.app",temp_str);
free(temp_str);
res = -PSICONV_E_PARSE;
goto ERROR5;
}
psiconv_progress(config,lev+2,sto,
"Looking for the Page layout section");
if (! page_sec) {
psiconv_error(config,lev+2,sto,
"Page layout section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR5;
} else {
psiconv_debug(config,lev+2,sto,
"Page layout section at offset %08x",page_sec);
if ((res = psiconv_parse_page_layout_section(config,buf,lev+2,page_sec,NULL,
&(*result)->page_sec)))
goto ERROR5;
}
psiconv_progress(config,lev+2,sto,
"Looking for the Word Style section");
if (!styles_sec) {
psiconv_error(config,lev+2,sto,
"Word styles section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR6;
} else {
psiconv_debug(config,lev+2,sto,
"Word styles section at offset %08x",styles_sec);
if ((res = psiconv_parse_word_styles_section(config,buf,lev+2,styles_sec,NULL,
&(*result)->styles_sec)))
goto ERROR6;
}
psiconv_progress(config,lev+2,sto,
"Looking for the Text section");
if (!text_sec) {
psiconv_error(config,lev+2,sto, "Text section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR7;
} else {
psiconv_debug(config,lev+2,sto,
"Text section at offset %08x",text_sec);
if ((res = psiconv_parse_text_section(config,buf,lev+2,text_sec,NULL,
&(*result)->paragraphs)))
goto ERROR7;
}
psiconv_progress(config,lev+2,sto, "Looking for the Layout section");
if (!layout_sec) {
psiconv_debug(config,lev+2,sto, "No layout section today");
} else {
psiconv_debug(config,lev+2,sto,
"Layout section at offset %08x",layout_sec);
if ((res = psiconv_parse_styled_layout_section(config,buf,lev+2,layout_sec,NULL,
(*result)->paragraphs,
(*result)->styles_sec)))
goto ERROR8;
}
psiconv_free_application_id_section(appl_id);
psiconv_free_section_table_section(table);
psiconv_progress(config,lev+1,off,"End of word file");
return 0;
ERROR8:
psiconv_free_text_and_layout((*result)->paragraphs);
ERROR7:
psiconv_free_word_styles_section((*result)->styles_sec);
ERROR6:
psiconv_free_page_layout_section((*result)->page_sec);
ERROR5:
psiconv_free_application_id_section(appl_id);
ERROR4:
psiconv_free_word_status_section((*result)->status_sec);
ERROR3:
psiconv_free_section_table_section(table);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Word File failed");
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_file(const psiconv_config config,
const psiconv_buffer buf,int lev, psiconv_u32 off,
psiconv_sheet_f *result)
{
int res=0;
psiconv_section_table_section table;
psiconv_application_id_section appl_id;
char *temp_str;
psiconv_u32 pwd_sec = 0;
psiconv_u32 status_sec = 0;
psiconv_u32 page_sec = 0;
psiconv_u32 applid_sec = 0;
psiconv_u32 workbook_sec = 0;
psiconv_section_table_entry entry;
psiconv_u32 sto;
int i;
psiconv_progress(config,lev+1,off,"Going to read a sheet file");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off,
"Going to read the offset of the section table section");
sto = psiconv_read_u32(config,buf,lev+2,off,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off,"Offset: %08x",sto);
psiconv_progress(config,lev+2,sto,
"Going to read the section table section");
if ((res = psiconv_parse_section_table_section(config,buf,lev+2,sto, NULL,&table)))
goto ERROR2;
for (i = 0; i < psiconv_list_length(table); i ++) {
psiconv_progress(config,lev+2,sto, "Going to read entry %d",i);
if (!(entry = psiconv_list_get(table,i)))
goto ERROR3;
if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
applid_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Application ID section at %08x",applid_sec);
} else if (entry->id == PSICONV_ID_PAGE_LAYOUT_SECTION) {
page_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Page Layout section at %08x",page_sec);
} else if (entry->id == PSICONV_ID_PASSWORD_SECTION) {
pwd_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Password section at %08x",pwd_sec);
psiconv_error(config,lev+3,sto,
"Password section found - can't read encrypted data");
res = -PSICONV_E_PARSE;
goto ERROR3;
} else if (entry->id == PSICONV_ID_SHEET_WORKBOOK_SECTION) {
workbook_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Sheet Workbook section at %08x",workbook_sec);
} else if (entry->id == PSICONV_ID_SHEET_STATUS_SECTION) {
status_sec = entry->offset;
psiconv_debug(config,lev+3,sto,
"Found the Sheet Status section at %08x",status_sec);
} else {
psiconv_warn(config,lev+3,sto,
"Found unknown section in the Section Table (ignoring)");
psiconv_debug(config,lev+3,sto,
"Section ID %08x, offset %08x",entry->id,entry->offset);
}
}
psiconv_progress(config,lev+2,sto,
"Looking for the Status section");
if (!status_sec) {
psiconv_error(config,lev+2,sto, "Status section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR3;
} else {
psiconv_debug(config,lev+2,sto, "Status section at offset %08x",status_sec);
if ((res = psiconv_parse_sheet_status_section(config,buf,lev+2,status_sec,NULL,
&((*result)->status_sec))))
goto ERROR3;
}
psiconv_progress(config,lev+2,sto, "Looking for the Application ID section");
if (! applid_sec) {
psiconv_error(config,lev+2,sto,
"Application ID section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR4;
} else {
psiconv_debug(config,lev+2,sto,
"Application ID section at offset %08x",applid_sec);
if ((res = psiconv_parse_application_id_section(config,buf,lev+2,applid_sec,NULL,
&appl_id)))
goto ERROR4;
}
if ((appl_id->id != PSICONV_ID_SHEET) ||
!applid_matches(appl_id->name,"sheet.app")) {
psiconv_warn(config,lev+2,applid_sec,
"Application ID section contains unexpected data");
psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",
PSICONV_ID_SHEET,appl_id->id);
if (!(temp_str = psiconv_make_printable(config,appl_id->name)))
goto ERROR5;
psiconv_debug(config,lev+2,applid_sec,"Name: `%s' expected, `%s' found",
"Sheet.app",temp_str);
free(temp_str);
res = -PSICONV_E_PARSE;
goto ERROR5;
}
psiconv_progress(config,lev+2,sto,
"Looking for the Page layout section");
if (! page_sec) {
psiconv_error(config,lev+2,sto,
"Page layout section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR5;
} else {
psiconv_debug(config,lev+2,sto,
"Page layout section at offset %08x",page_sec);
if ((res = psiconv_parse_page_layout_section(config,buf,lev+2,page_sec,NULL,
&(*result)->page_sec)))
goto ERROR5;
}
psiconv_progress(config,lev+2,sto,
"Looking for the Sheet Workbook section");
if (! workbook_sec) {
psiconv_error(config,lev+2,sto,
"Sheet workbook section not found in the section table");
res = -PSICONV_E_PARSE;
goto ERROR6;
} else {
psiconv_debug(config,lev+2,sto,
"Sheet workbook section at offset %08x",page_sec);
if ((res = psiconv_parse_sheet_workbook_section(config,buf,lev+2,workbook_sec,NULL,
&(*result)->workbook_sec)))
goto ERROR6;
}
psiconv_free_application_id_section(appl_id);
psiconv_free_section_table_section(table);
psiconv_progress(config,lev+1,off,"End of Sheet file");
return 0;
ERROR6:
psiconv_free_page_layout_section((*result)->page_sec);
ERROR5:
psiconv_free_application_id_section(appl_id);
ERROR4:
psiconv_free_sheet_status_section((*result)->status_sec);
ERROR3:
psiconv_free_section_table_section(table);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet File failed");
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/parse_formula.c 0000644 0001750 0001750 00000073145 10336374724 015407 0000000 0000000 /*
parse_formula.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2001-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "parse_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
struct formula_element
{
psiconv_formula_type_t formula_type;
int number_of_args;
const char* name;
};
static struct formula_element formula_elements[256] =
{
{psiconv_formula_unknown,0,"*UNKNOWN*"}, /* 0 */
{psiconv_formula_op_lt,2,"<"},
{psiconv_formula_op_le,2,"<="},
{psiconv_formula_op_gt,2,">"},
{psiconv_formula_op_ge,2,">="},
{psiconv_formula_op_ne,2,"<>"},
{psiconv_formula_op_eq,2,"="},
{psiconv_formula_op_add,2,"+"},
{psiconv_formula_op_sub,2,"-"},
{psiconv_formula_op_mul,2,"*"},
{psiconv_formula_op_div,2,"/"},
{psiconv_formula_op_pow,2,"^"},
{psiconv_formula_op_pos,1,"+"},
{psiconv_formula_op_neg,1,"-"},
{psiconv_formula_op_not,1,"NOT"},
{psiconv_formula_op_and,2,"AND"},
{psiconv_formula_op_or,2,"OR"}, /* 10 */
{psiconv_formula_op_con,2,"&"},
{psiconv_formula_op_bra,1,"()"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_mark_eof,0,"End of formula"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_dat_float,0,"Floating point number"},
{psiconv_formula_dat_int,0,"Signed integer number"}, /* 20 */
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_dat_var,0,"Named variable"},
{psiconv_formula_dat_string,0,"String"},
{psiconv_formula_dat_cellref,0,"Cell reference"},
{psiconv_formula_dat_cellblock,0,"Cell block"},
{psiconv_formula_dat_vcellblock,0,"Cell block {varargs}"},
{psiconv_formula_mark_opsep,0,"Operand separator"},
{psiconv_formula_mark_opend,0,"Operand list end"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"}, /* 30 */
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_fun_false,0,"FALSE"},
{psiconv_formula_fun_if,3,"IF"},
{psiconv_formula_fun_true,0,"TRUE"},
{psiconv_formula_fun_cell,2,"CELL"},
{psiconv_formula_fun_errortype,0,"ERRORTYPE"},
{psiconv_formula_fun_isblank,1,"ISBLANK"},
{psiconv_formula_fun_iserr,1,"ISERR"},
{psiconv_formula_fun_iserror,1,"ISERROR"},
{psiconv_formula_fun_islogical,1,"ISLOGICAL"},
{psiconv_formula_fun_isna,1,"ISNA"},
{psiconv_formula_fun_isnontext,1,"ISNONTEXT"},
{psiconv_formula_fun_isnumber,1,"ISNUMBER"},
{psiconv_formula_fun_istext,1,"ISTEXT"},
{psiconv_formula_fun_n,1,"N"}, /* 40 */
{psiconv_formula_fun_type,1,"TYPE"},
{psiconv_formula_fun_address,2,"ADDRESS"},
{psiconv_formula_fun_column,1,"COLUMN"},
{psiconv_formula_fun_columns,1,"COLUMNS"},
{psiconv_formula_fun_hlookup,3,"HLOOKUP"},
{psiconv_formula_fun_index,3,"INDEX"},
{psiconv_formula_fun_indirect,1,"INDIRECT"},
{psiconv_formula_fun_lookup,3,"LOOKUP"},
{psiconv_formula_fun_offset,3,"OFFSET"},
{psiconv_formula_fun_row,1,"ROW"},
{psiconv_formula_fun_rows,1,"ROWS"},
{psiconv_formula_fun_vlookup,3,"VLOOKUP"},
{psiconv_formula_fun_char,1,"CHAR"},
{psiconv_formula_fun_code,1,"CODE"},
{psiconv_formula_fun_exact,2,"EXACT"},
{psiconv_formula_fun_find,3,"FIND"}, /* 50 */
{psiconv_formula_fun_left,2,"LEFT"},
{psiconv_formula_fun_len,1,"LEN"},
{psiconv_formula_fun_lower,1,"LOWER"},
{psiconv_formula_fun_mid,3,"MID"},
{psiconv_formula_fun_proper,1,"PROPER"},
{psiconv_formula_fun_replace,4,"REPLACE"},
{psiconv_formula_fun_rept,2,"REPT"},
{psiconv_formula_fun_right,2,"RIGHT"},
{psiconv_formula_fun_string,2,"STRING"},
{psiconv_formula_fun_t,1,"T"},
{psiconv_formula_fun_trim,1,"TRIM"},
{psiconv_formula_fun_upper,1,"UPPER"},
{psiconv_formula_fun_value,1,"VALUE"},
{psiconv_formula_fun_date,3,"DATE"},
{psiconv_formula_fun_datevalue,1,"DATEVALUE"},
{psiconv_formula_fun_day,1,"DAY"}, /* 60 */
{psiconv_formula_fun_hour,1,"HOUR"},
{psiconv_formula_fun_minute,1,"MINUTE"},
{psiconv_formula_fun_month,1,"MONTH"},
{psiconv_formula_fun_now,0,"NOW"},
{psiconv_formula_fun_second,1,"SECOND"},
{psiconv_formula_fun_today,0,"TODAY"},
{psiconv_formula_fun_time,3,"TIME"},
{psiconv_formula_fun_timevalue,1,"TIMEVALUE"},
{psiconv_formula_fun_year,1,"YEAR"},
{psiconv_formula_fun_abs,1,"ABS"},
{psiconv_formula_fun_acos,1,"ACOS"},
{psiconv_formula_fun_asin,1,"ASIN"},
{psiconv_formula_fun_atan,1,"ATAN"},
{psiconv_formula_fun_atan2,2,"ATAN2"},
{psiconv_formula_fun_cos,1,"COS"},
{psiconv_formula_fun_degrees,0,"DEGREES"}, /* 70 */
{psiconv_formula_fun_exp,1,"EXP"},
{psiconv_formula_fun_fact,1,"FACT"},
{psiconv_formula_fun_int,1,"INT"},
{psiconv_formula_fun_ln,1,"LN"},
{psiconv_formula_fun_log10,1,"LOG10"},
{psiconv_formula_fun_mod,2,"MOD"},
{psiconv_formula_fun_pi,0,"PI"},
{psiconv_formula_fun_radians,1,"RADIANS"},
{psiconv_formula_fun_rand,0,"RAND"},
{psiconv_formula_fun_round,2,"ROUND"},
{psiconv_formula_fun_sign,1,"SIGN"},
{psiconv_formula_fun_sin,1,"SIN"},
{psiconv_formula_fun_sqrt,1,"SQRT"},
{psiconv_formula_fun_sumproduct,2,"SUMPRODUCT"},
{psiconv_formula_fun_tan,1,"TAN"},
{psiconv_formula_fun_trunc,1,"TRUNC"}, /* 80 */
{psiconv_formula_fun_cterm,3,"CTERM"},
{psiconv_formula_fun_ddb,4,"DDB"},
{psiconv_formula_fun_fv,3,"FV"},
{psiconv_formula_fun_irr,2,"IRR"},
{psiconv_formula_fun_npv,2,"NPV"},
{psiconv_formula_fun_pmt,3,"PMT"},
{psiconv_formula_fun_pv,3,"PV"},
{psiconv_formula_fun_rate,3,"RATE"},
{psiconv_formula_fun_sln,3,"SLN"},
{psiconv_formula_fun_syd,4,"SYD"},
{psiconv_formula_fun_term,3,"TERM"},
{psiconv_formula_fun_combin,2,"COMBIN"},
{psiconv_formula_fun_permut,2,"PERMUT"},
{psiconv_formula_vfn_average,-1,"AVERAGE"},
{psiconv_formula_vfn_choose,-1,"CHOOSE"},
{psiconv_formula_vfn_count,-1,"COUNT"}, /* 90 */
{psiconv_formula_vfn_counta,-1,"COUNTA"},
{psiconv_formula_vfn_countblank,-1,"COUNTBLANK"},
{psiconv_formula_vfn_max,-1,"MAX"},
{psiconv_formula_vfn_min,-1,"MIN"},
{psiconv_formula_vfn_product,-1,"PRODUCT"},
{psiconv_formula_vfn_stdevp,-1,"STDEVP"},
{psiconv_formula_vfn_stdev,-1,"STDEV"},
{psiconv_formula_vfn_sum,-1,"SUM"},
{psiconv_formula_vfn_sumsq,-1,"SUMSQ"},
{psiconv_formula_vfn_varp,-1,"VARP"},
{psiconv_formula_vfn_var,-1,"VAR"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"}, /* A0 */
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"}, /* B0 */
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"}, /* C0 */
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"}, /* D0 */
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"}, /* E0 */
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"}, /* F0 */
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"},
{psiconv_formula_unknown,0,"*UNKNOWN*"}};
static int psiconv_parse_sheet_ref(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_sheet_ref_t *result)
{
int res;
psiconv_u16 temp;
psiconv_progress(config,lev+1,off,"Going to read a sheet ref");
psiconv_progress(config,lev+2,off,"Going to read the offset encoding");
temp = psiconv_read_u16(config,buf,lev+2,off,&res);
if (res) {
if (length)
*length = 0;
return res;
}
psiconv_debug(config,lev+2,off,"Encoded word: %04x",temp);
result->absolute = (temp & 0x4000)?psiconv_bool_true:psiconv_bool_false;
result->offset = (temp & 0x3fff) * ((temp & 0x8000)?-1:1);
psiconv_debug(config,lev+2,off,"Reference: %s offset %d",
result->absolute?"absolute":"relative",result->offset);
if (length)
*length = 2;
return 0;
}
static int psiconv_parse_sheet_cell_reference(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_sheet_cell_reference_t *result)
{
int len = 0;
int leng,res;
psiconv_u8 temp;
psiconv_progress(config,lev+1,off+len,"Going to read a sheet cell reference");
psiconv_progress(config,lev+2,off+len,"Going to read the row reference");
if ((res = psiconv_parse_sheet_ref(config,buf,lev+2,off+len,&leng,&result->row)))
goto ERROR;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the column reference");
if ((res = psiconv_parse_sheet_ref(config,buf,lev+2,off+len,&leng,&result->column)))
goto ERROR;
len += leng;
psiconv_progress(config,lev+2,off+len,
"Going to read the trailing byte (%02x expected)",0);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR;
if (temp != 0) {
psiconv_warn(config,lev+2,off+len,"Unknown byte in cell reference (ignored");
psiconv_debug(config,lev+2,off+len,"Trailing byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev,off+len-1,
"End of cell reference (total length: %08x)", len);
if (length)
*length = len;
return 0;
ERROR:
if (length)
*length = 0;
return res;
}
static int psiconv_parse_sheet_cell_block(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_sheet_cell_block_t *result)
{
int len = 0;
int leng,res;
psiconv_progress(config,lev+1,off+len,"Going to read a sheet cell block");
psiconv_progress(config,lev+2,off+len,"Going to read the first cell");
if ((res = psiconv_parse_sheet_cell_reference(config,buf,lev+2,off+len,&leng,
&result->first)))
goto ERROR;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the last cell");
if ((res = psiconv_parse_sheet_cell_reference(config,buf,lev+2,off+len,&leng,
&result->last)))
goto ERROR;
len += leng;
psiconv_progress(config,lev,off+len-1,
"End of cell block (total length: %08x)", len);
if (length)
*length = len;
return 0;
ERROR:
if (length)
*length = 0;
return res;
}
static int psiconv_parse_formula_element_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_formula *result,
psiconv_u32 maxlen)
{
int res=0;
int len=0;
int leng;
int eof = 0;
psiconv_u8 marker,submarker,submarker2;
psiconv_formula_list formula_stack;
psiconv_formula formula,subformula,subformula1,subformula2,
subformula3,subformula4;
psiconv_u16 temp,nr_of_subs;
psiconv_progress(config,lev+1,off,"Going to read a formula element list");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
if (!(formula_stack = psiconv_list_new(sizeof(struct psiconv_formula_s))))
goto ERROR2;
if (!(formula = malloc(sizeof(*formula))))
goto ERROR3;
/* By setting the type to unknown, we can safely call psiconv_free_formula */
formula->type = psiconv_formula_unknown;
if (!(subformula1 = malloc(sizeof(*subformula1))))
goto ERROR4;
subformula1->type = psiconv_formula_unknown;
if (!(subformula2 = malloc(sizeof(*subformula2))))
goto ERROR5;
subformula2->type = psiconv_formula_unknown;
if (!(subformula3 = malloc(sizeof(*subformula3))))
goto ERROR6;
subformula3->type = psiconv_formula_unknown;
if (!(subformula4 = malloc(sizeof(*subformula4))))
goto ERROR7;
subformula4->type = psiconv_formula_unknown;
while (!eof && len+off < maxlen) {
psiconv_progress(config,lev+3,off+len,"Going to read a formula item marker");
marker = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR8;
psiconv_debug(config,lev+3,off+len,"Marker: %02x (%s)",marker,
formula_elements[marker].name);
len ++;
if (formula_elements[marker].formula_type == psiconv_formula_unknown) {
psiconv_error(config,lev+3,off+len,"Unknown formula marker found!");
goto ERROR8;
} else if ((formula_elements[marker].formula_type ==
psiconv_formula_mark_eof) ||
(formula_elements[marker].formula_type ==
psiconv_formula_mark_opend) ||
(formula_elements[marker].formula_type ==
psiconv_formula_mark_opsep)) {
len--;
psiconv_progress(config,lev+3,off+len,"End of this formula list");
eof = 1;
} else if (formula_elements[marker].formula_type ==
psiconv_formula_dat_int) {
psiconv_progress(config,lev+3,off+len,"Next item: an integer");
formula->data.dat_int = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR8;
formula->type = formula_elements[marker].formula_type;
psiconv_debug(config,lev+3,off+len,"Value: %08x",formula->data.dat_int);
len += 4;
if ((res = psiconv_list_add(formula_stack,formula)))
goto ERROR8;
formula->type = psiconv_formula_unknown;
} else if (formula_elements[marker].formula_type ==
psiconv_formula_dat_float) {
psiconv_progress(config,lev+3,off+len,"Next item: a float");
formula->data.dat_float = psiconv_read_float(config,buf,lev+2,off+len,&leng,
&res);
if (res)
goto ERROR8;
formula->type = formula_elements[marker].formula_type;
psiconv_debug(config,lev+3,off+len,"Value: %f",formula->data.dat_float);
len += leng;
if ((res = psiconv_list_add(formula_stack,formula)))
goto ERROR8;
formula->type = psiconv_formula_unknown;
} else if (formula_elements[marker].formula_type ==
psiconv_formula_dat_cellref) {
psiconv_progress(config,lev+3,off+len,"Next item: a cell reference");
if ((res = psiconv_parse_sheet_cell_reference(config,buf,lev+2,off+len,&leng,
&formula->data.dat_cellref)))
goto ERROR8;
formula->type = formula_elements[marker].formula_type;
len += leng;
if ((res = psiconv_list_add(formula_stack,formula)))
goto ERROR8;
formula->type = psiconv_formula_unknown;
} else if ((formula_elements[marker].formula_type ==
psiconv_formula_dat_cellblock) ||
(formula_elements[marker].formula_type ==
psiconv_formula_dat_vcellblock)) {
psiconv_progress(config,lev+3,off+len,"Next item: a cell block");
if ((res = psiconv_parse_sheet_cell_block(config,buf,lev+2,off+len,&leng,
&formula->data.dat_cellblock)))
goto ERROR8;
formula->type = formula_elements[marker].formula_type;
len += leng;
if ((res = psiconv_list_add(formula_stack,formula)))
goto ERROR8;
formula->type = psiconv_formula_unknown;
} else if (formula_elements[marker].formula_type ==
psiconv_formula_dat_string) {
psiconv_progress(config,lev+3,off+len,"Next item: a string");
formula->data.dat_string =
psiconv_read_short_string(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR8;
formula->type = formula_elements[marker].formula_type;
len += leng;
if ((res = psiconv_list_add(formula_stack,formula)))
goto ERROR8;
formula->type = psiconv_formula_unknown;
} else if ((formula_elements[marker].formula_type ==
psiconv_formula_dat_var)) {
psiconv_progress(config,lev+3,off+len,"Next item: a variable reference");
formula->data.dat_variable = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR8;
formula->type = formula_elements[marker].formula_type;
len += 4;
if ((res = psiconv_list_add(formula_stack,formula)))
goto ERROR8;
formula->type = psiconv_formula_unknown;
} else if (formula_elements[marker].number_of_args == -1) {
psiconv_progress(config,lev+3,off+len,"Going to parse a vararg function");
if (!(formula->data.fun_operands =
psiconv_list_new(sizeof(*formula))))
goto ERROR8;
formula->type = formula_elements[marker].formula_type;
nr_of_subs = 0;
do {
nr_of_subs ++;
psiconv_progress(config,lev+4,off+len,"Going to read vararg argument %d",
nr_of_subs);
if ((res = psiconv_parse_formula_element_list(config,buf,lev+4,off+len,&leng,
&subformula,maxlen)))
goto ERROR8;
len += leng;
if ((res = psiconv_list_add(formula->data.fun_operands,subformula))) {
psiconv_free_formula(subformula);
goto ERROR8;
}
free(subformula);
psiconv_progress(config,lev+4,off+len,"Going to read the next marker");
submarker = psiconv_read_u8(config,buf,lev+4,off+len,&res);
len ++;
if (res)
goto ERROR8;
submarker2 = psiconv_read_u8(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR8;
} while ((formula_elements[submarker].formula_type
== psiconv_formula_mark_opsep) &&
(formula_elements[submarker2].formula_type
!= psiconv_formula_mark_opend));
if ((formula_elements[submarker].formula_type ==
psiconv_formula_mark_opsep) &&
(formula_elements[submarker2].formula_type ==
psiconv_formula_mark_opend)) {
submarker=submarker2;
len++;
}
if (formula_elements[submarker].formula_type
!= psiconv_formula_mark_opend) {
psiconv_error(config,lev+3,off+len,"Formula corrupted!");
psiconv_debug(config,lev+3,off+len,"Found unexpected marker %02x",submarker);
goto ERROR8;
}
psiconv_progress(config,lev+3,off+len,"Going to read the repeated marker %02x",
marker);
submarker = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR8;
if (submarker != marker) {
psiconv_error(config,lev+3,off+len,"Formula corrupted!");
psiconv_debug(config,lev+3,off+len,"Expected marker %02x, found %02x",
marker,submarker);
goto ERROR8;
}
len++;
psiconv_progress(config,lev+3,off+len,
"Going to read the number of arguments (%d expected)",
nr_of_subs);
temp = psiconv_read_u16(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR8;
if (temp != nr_of_subs) {
psiconv_error(config,lev+3,off+len,"Formula corrupted!");
psiconv_debug(config,lev+3,off+len,
"Read %d arguments, but formula says there are %d",
nr_of_subs,temp);
goto ERROR8;
}
len += 2;
if ((res = psiconv_list_add(formula_stack,formula)))
goto ERROR8;
formula->type = psiconv_formula_unknown;
} else {
if (formula_elements[marker].number_of_args > 0)
if ((res = psiconv_list_pop(formula_stack,subformula1)))
goto ERROR8;
if (formula_elements[marker].number_of_args > 1)
if ((res = psiconv_list_pop(formula_stack,subformula2)))
goto ERROR8;
if (formula_elements[marker].number_of_args > 2)
if ((res = psiconv_list_pop(formula_stack,subformula3)))
goto ERROR8;
if (formula_elements[marker].number_of_args > 3)
if ((res = psiconv_list_pop(formula_stack,subformula4)))
goto ERROR8;
if (!(formula->data.fun_operands =
psiconv_list_new(sizeof(*formula))))
goto ERROR8;
formula->type = formula_elements[marker].formula_type;
if (formula_elements[marker].number_of_args > 3)
if ((res = psiconv_list_add(formula->data.fun_operands,subformula4)))
goto ERROR8;
if (formula_elements[marker].number_of_args > 2)
if ((res = psiconv_list_add(formula->data.fun_operands,subformula3)))
goto ERROR8;
if (formula_elements[marker].number_of_args > 1)
if ((res = psiconv_list_add(formula->data.fun_operands,subformula2)))
goto ERROR8;
if (formula_elements[marker].number_of_args > 0)
if ((res = psiconv_list_add(formula->data.fun_operands,subformula1)))
goto ERROR8;
if ((res = psiconv_list_add(formula_stack,formula)))
goto ERROR8;
subformula4->type = subformula3->type = subformula2->type =
subformula1->type = formula->type = psiconv_formula_unknown;
}
}
if ((len+off > maxlen) || !eof) {
psiconv_error(config,lev+2,off+len,"Formula corrupted!");
psiconv_debug(config,lev+2,off+len,"Expected end: %04x, found end: %04x",
maxlen,len+off);
goto ERROR8;
}
if ((psiconv_list_length(formula_stack)) != 1) {
psiconv_error(config,lev+2,off+len,"Formula corrupted!");
psiconv_debug(config,lev+2,off+len,"More than one item left on the stack (%d)",
psiconv_list_length(formula_stack));
goto ERROR8;
}
if ((res = psiconv_list_pop(formula_stack,*result)))
goto ERROR8;
psiconv_list_free(formula_stack);
free(formula);
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of formula element list (total length: %08x)", len);
return 0;
ERROR8:
psiconv_free_formula(subformula4);
ERROR7:
psiconv_free_formula(subformula3);
ERROR6:
psiconv_free_formula(subformula2);
ERROR5:
psiconv_free_formula(subformula1);
ERROR4:
psiconv_free_formula(formula);
ERROR3:
psiconv_free_formula_list(formula_stack);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of formula element list failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_formula(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_formula *result)
{
int res=0;
int len=0;
int leng;
psiconv_u32 bytelen,formula_end;
psiconv_u8 temp;
psiconv_progress(config,lev+1,off,"Going to read a formula");
psiconv_progress(config,lev+2,off+len,
"Going to read the formula byte length");
bytelen = psiconv_read_S(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR1;
psiconv_debug(config,lev+2,off+len,"Formula byte length: %d",bytelen);
len += leng;
bytelen += len;
formula_end = off + bytelen;
psiconv_progress(config,lev+2,off+len,"Going to read the formula elements list");
if ((res = psiconv_parse_formula_element_list(config,buf,lev+2,off+len,&leng,
result,formula_end)))
goto ERROR1;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the eof marker");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (formula_elements[temp].formula_type != psiconv_formula_mark_eof) {
psiconv_error(config,lev+2,off+len,"Formula corrupted!");
psiconv_debug(config,lev+2,off+len,"Expected marker: %02x, found byte: %02x",
0x15,temp);
goto ERROR2;
}
len ++;
if (off+len != formula_end) {
psiconv_error(config,lev+2,off+len,"Formula corrupted!");
psiconv_debug(config,lev+2,off+len,"Expected end: %04x, found end: %04x",
formula_end,len+off);
goto ERROR2;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of formula (total length: %08x)", len);
return 0;
ERROR2:
psiconv_free_formula(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of formula failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/parse_layout.c 0000644 0001750 0001750 00000063477 10336374675 015273 0000000 0000000 /*
parse_layout.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "parse_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
int psiconv_parse_color(const psiconv_config config,
const psiconv_buffer buf, int lev, psiconv_u32 off,
int *length, psiconv_color *result)
{
int res = 0;
int len = 0;
psiconv_progress(config,lev+1,off,"Going to parse color");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
(*result)->red = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->green = psiconv_read_u8(config,buf,lev+2,off+len+1,&res);
if (res)
goto ERROR2;
(*result)->blue = psiconv_read_u8(config,buf,lev+2,off+len+2,&res);
if (res)
goto ERROR2;
len += 3;
psiconv_debug(config,lev+2,off,"Color: red %02x, green %02x, blue %02x",
(*result)->red, (*result)->green, (*result)->blue);
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of color (total length: %08x)",len);
return 0;
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Color failed");
if (length)
*length = 0;
if (res == 0)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_font(const psiconv_config config,
const psiconv_buffer buf, int lev, psiconv_u32 off,
int *length, psiconv_font *result)
{
int res = 0;
char *str_copy;
int len=0;
int fontlen;
psiconv_progress(config,lev+1,off,"Going to parse font");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
fontlen = psiconv_read_u8(config,buf,lev+2,off,&res);
if (res)
goto ERROR2;
len = 1;
(*result)->name = psiconv_read_charlist(config,buf,lev+2,off+len, fontlen-1,&res);
if (res)
goto ERROR2;
len += fontlen - 1;
(*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
if (!(str_copy = psiconv_make_printable(config,(*result)->name)))
goto ERROR3;
psiconv_debug(config,lev+2,off+len,
"Found font `%s', displayed with screen font %02x",
str_copy,(*result)->screenfont);
free(str_copy);
len ++;
if (length)
*length = len;
psiconv_progress(config,lev+1,off + len - 1,
"End of font (total length: %08x)",len);
return 0;
ERROR3:
free ((*result)->name);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Font failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_border(const psiconv_config config,
const psiconv_buffer buf,int lev,psiconv_u32 off,
int *length, psiconv_border *result)
{
int res = 0;
int len = 0;
psiconv_u32 temp;
int leng;
psiconv_progress(config,lev+1,off,"Going to parse border data");
if (!(*result = malloc(sizeof(**result)))) {
goto ERROR1;
}
psiconv_progress(config,lev+2,off+len,"Going to read border kind");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp == 0x00)
(*result)->kind = psiconv_border_none;
else if (temp == 0x01)
(*result)->kind = psiconv_border_solid;
else if (temp == 0x02)
(*result)->kind = psiconv_border_double;
else if (temp == 0x03)
(*result)->kind = psiconv_border_dotted;
else if (temp == 0x04)
(*result)->kind = psiconv_border_dashed;
else if (temp == 0x05)
(*result)->kind = psiconv_border_dotdashed;
else if (temp == 0x06)
(*result)->kind = psiconv_border_dotdotdashed;
else {
psiconv_warn(config,lev+2,off,"Unknown border kind (defaults to `none')");
(*result)->kind = psiconv_border_none;
}
psiconv_debug(config,lev+2,off+len,"Kind: %02x",temp);
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read border thickness");
(*result)->thickness = psiconv_read_size(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
#if 0
/* This seems no longer necessary to test? */
if (((*result)->kind != psiconv_border_solid) &&
((*result)->kind != psiconv_border_double) &&
((*result)->thickness != 0.0) &&
(fabs((*result)->thickness - 1/20) >= 1/1000)) {
psiconv_warn(config,lev+2,off,
"Border thickness specified for unlikely border type");
}
#endif
psiconv_debug(config,lev+2,off+len,"Thickness: %f",(*result)->thickness);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the border color");
if ((psiconv_parse_color(config,buf,lev+2,off+len,&leng,&(*result)->color)))
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the final unknown byte "
"(0x00 or 0x01 expected)");
temp = psiconv_read_u8(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR3;
if ((temp != 0x01) && (temp != 0x00)) {
psiconv_warn(config,lev+2,off,"Unknown last byte in border specification");
psiconv_debug(config,lev+2,off+len, "Last byte: read %02x, expected %02x or %02x",
temp,0x00,0x01);
}
len ++;
if (length)
*length = len;
psiconv_progress(config,lev+1,off + len - 1,
"End of border (total length: %08x)",len);
return 0;
ERROR3:
psiconv_free_color((*result)->color);
ERROR2:
free (result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Border failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_bullet(const psiconv_config config,
const psiconv_buffer buf,int lev,psiconv_u32 off,
int *length, psiconv_bullet *result)
{
int res = 0;
int len = 0;
int leng;
int bullet_length;
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
(*result)->on = psiconv_bool_true;
psiconv_progress(config,lev+1,off,"Going to parse bullet data");
psiconv_progress(config,lev+2,off+len,"Going to read bullet length");
bullet_length = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Length: %02x",bullet_length);
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read bullet font size");
(*result)->font_size = psiconv_read_size(config,buf,lev+2,off+len, &leng,&res);
if (res)
goto ERROR2;
len +=leng;
psiconv_progress(config,lev+2,off+len,"Going to read bullet character");
(*result)->character = psiconv_unicode_read_char(config,buf,lev+2,
off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read indent on/off");
if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent)))
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Indent on: %02x",(*result)->indent);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read bullet color");
if ((res = psiconv_parse_color(config,buf,lev+2,off+len,&leng,&(*result)->color)))
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read bullet font");
if ((res = psiconv_parse_font(config,buf,lev+2,off+len,&leng,&(*result)->font)))
goto ERROR3;
len += leng;
if (len != bullet_length + 1) {
psiconv_warn(config,lev+2,off,"Bullet data structure length mismatch");
psiconv_debug(config,lev+2,off,"Length: specified %02x, found %02x",
bullet_length,len-1);
}
psiconv_progress(config,lev+1,off + len - 1,
"End of bullet data (total length: %08x)",len);
if (length)
*length = len;
return 0;
ERROR3:
psiconv_free_color((*result)->color);
ERROR2:
free (result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Bullet failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_tab(const psiconv_config config,
const psiconv_buffer buf, int lev, psiconv_u32 off,
int *length, psiconv_tab *result)
{
int res = 0;
int len = 0;
int leng;
psiconv_u8 temp;
psiconv_progress(config,lev+1,off,"Going to parse tab");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off,"Going to read tab location");
(*result)->location = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the tab kind");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp == 1)
(*result)->kind = psiconv_tab_left;
else if (temp == 2)
(*result)->kind = psiconv_tab_centre;
else if (temp == 3)
(*result)->kind = psiconv_tab_right;
else {
psiconv_warn(config,lev+2,off+len,"Unknown tab kind argument");
psiconv_debug(config,lev+2,off+len,"Kind found: %02x (defaulted to left tab)",
temp);
(*result)->kind = psiconv_tab_left;
}
psiconv_debug(config,lev+2,off+len,"Kind: %02x",temp);
len ++;
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of tab (total length: %08x)",len);
return 0;
ERROR2:
free (result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Tab failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_paragraph_layout_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_paragraph_layout result)
{
int res=0;
int len=0;
int list_length,leng,nr;
psiconv_u8 id;
psiconv_u32 temp;
psiconv_tab temp_tab;
psiconv_color temp_color;
psiconv_border temp_border;
psiconv_bullet temp_bullet;
psiconv_progress(config,lev+1,off,"Going to read paragraph layout list");
psiconv_progress(config,lev+2,off,"Going to read the list length");
list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR1;
psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
len += 4;
nr = 0;
while(len - 4 < list_length) {
psiconv_progress(config,lev+2,off+len,"Going to read element %d",nr);
psiconv_progress(config,lev+3,off+len,"Going to read the element id");
id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
len ++;
switch(id) {
case 0x01:
psiconv_progress(config,lev+3,off+len,"Going to read background color");
if ((res = psiconv_parse_color(config,buf,lev+3,off+len,&leng,&temp_color)))
goto ERROR1;
psiconv_free_color(result->back_color);
result->back_color = temp_color;
len += leng;
break;
case 0x02:
psiconv_progress(config,lev+3,off+len ,"Going to read indent left");
result->indent_left = psiconv_read_length(config,buf,lev+3,off+len,&leng,&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x03:
psiconv_progress(config,lev+3,off+len,"Going to read indent right");
result->indent_right = psiconv_read_length(config,buf,lev+2,off+len,&leng,
&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x04:
psiconv_progress(config,lev+3,off+len,"Going to read indent left first line");
result->indent_first = psiconv_read_length(config,buf,lev+2,off+len, &leng,
&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x05:
psiconv_progress(config,lev+3,off+len,"Going to read horizontal justify");
temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR1;
if (temp == 0x00)
result->justify_hor = psiconv_justify_left;
else if (temp == 0x01)
result->justify_hor = psiconv_justify_centre;
else if (temp == 0x02)
result->justify_hor = psiconv_justify_right;
else if (temp == 0x03)
result->justify_hor = psiconv_justify_full;
else {
psiconv_warn(config,lev+3,off+len, "Unknown horizontal justify argument "
"in paragraph layout codes list");
result->justify_hor = psiconv_justify_left;
}
psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
len ++;
break;
case 0x06:
psiconv_progress(config,lev+3,off+len,"Going to read vertical justify");
temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR1;
if (temp == 0x00)
result->justify_ver = psiconv_justify_top;
else if (temp == 0x01)
result->justify_ver = psiconv_justify_middle;
else if (temp == 0x02)
result->justify_ver = psiconv_justify_bottom;
else {
psiconv_warn(config,lev+3,off+len, "Unknown vertical justify argument "
"in paragraph layout codes list");
result->justify_ver = psiconv_justify_bottom;
}
psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
len ++;
break;
case 0x07:
psiconv_progress(config,lev+3,off+len,"Going to read linespacing distance");
result->linespacing = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x08:
psiconv_progress(config,lev+3,off+len,"Going to read linespacing exact");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
&result->linespacing_exact)))
goto ERROR1;
len += leng;
break;
case 0x09:
psiconv_progress(config,lev+3,off+len,"Going to read top space");
result->space_above = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x0a:
psiconv_progress(config,lev+3,off+len,"Going to read bottom space");
result->space_below = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x0b:
psiconv_progress(config,lev+3,off+len,"Going to read on one page");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
&result->keep_together)))
goto ERROR1;
len += leng;
break;
case 0x0c:
psiconv_progress(config,lev+3,off+len,"Going to read together with");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
&result->keep_with_next)))
goto ERROR1;
len += leng;
break;
case 0x0d:
psiconv_progress(config,lev+3,off+len,"Going to read on next page");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
&result->on_next_page)))
goto ERROR1;
len += leng;
break;
case 0x0e:
psiconv_progress(config,lev+3,off+len,"Going to read no widow protection");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
&result->no_widow_protection)))
goto ERROR1;
len += leng;
break;
case 0x0f:
psiconv_progress(config,lev+3,off+len,"Going to read wrap to fit cell limits");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
&result->wrap_to_fit_cell)))
goto ERROR1;
len += leng;
break;
case 0x10:
psiconv_progress(config,lev+3,off+len,"Going to read border distance to text");
result->border_distance = psiconv_read_length(config,buf,lev+3,
off+len,&leng,&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x11:
psiconv_progress(config,lev+3,off+len,"Going to read top border");
if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
goto ERROR1;
psiconv_free_border(result->top_border);
result->top_border = temp_border;
len += leng;
break;
case 0x12:
psiconv_progress(config,lev+3,off+len,"Going to read bottom border");
if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
goto ERROR1;
psiconv_free_border(result->bottom_border);
result->bottom_border = temp_border;
len += leng;
break;
case 0x13:
psiconv_progress(config,lev+3,off+len,"Going to read left border");
if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
goto ERROR1;
psiconv_free_border(result->left_border);
result->left_border = temp_border;
len += leng;
break;
case 0x14:
psiconv_progress(config,lev+3,off+len,"Going to read right border");
if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
goto ERROR1;
psiconv_free_border(result->right_border);
result->right_border = temp_border;
len += leng;
break;
case 0x15:
psiconv_progress(config,lev+3,off+len,"Going to read bullet");
if ((res = psiconv_parse_bullet(config,buf,lev+3,off+len,&leng,&temp_bullet)))
goto ERROR1;
psiconv_free_bullet(result->bullet);
result->bullet = temp_bullet;
len += leng;
break;
case 0x16:
psiconv_progress(config,lev+3,off+len,"Going to read standard tabs");
result->tabs->normal = psiconv_read_length(config,buf,lev+3,off+len,&leng,
&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x17:
psiconv_progress(config,lev+3,off+len,"Going to read extra tab");
if ((res = psiconv_parse_tab(config,buf,lev+3,off+len,&leng,&temp_tab)))
goto ERROR1;
if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) {
psiconv_free_tab(temp_tab);
goto ERROR1;
}
psiconv_free_tab(temp_tab);
len += leng;
break;
default:
psiconv_warn(config,lev+3,off+len,
"Unknown code in paragraph layout codes list");
psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
len ++;
break;
}
nr ++;
}
if (len - 4 != list_length) {
psiconv_error(config,lev+2,off+len,
"Read past end of paragraph layout codes list. I probably lost track "
"somewhere!");
psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
len-4,list_length);
res = PSICONV_E_PARSE;
goto ERROR1;
}
len = list_length + 4;
psiconv_progress(config,lev+1,off+len,
"End of paragraph layout list (total length: %08x)",len);
if (length)
*length = len;
return 0;
ERROR1:
psiconv_error(config,lev+1,off,"Reading of paragraph_layout_list failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_character_layout_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_character_layout result)
{
int res=0;
int len=0;
int list_length,leng,nr;
psiconv_u8 id;
psiconv_u32 temp;
psiconv_color temp_color;
psiconv_font temp_font;
psiconv_progress(config,lev+1,off,"Going to read character layout codes");
psiconv_progress(config,lev+2,off,"Going to read the list length");
list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR1;
psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
len += 4;
nr = 0;
while(len-4 < list_length) {
psiconv_progress(config,lev+2,off+len,"Going to read element %d",nr);
psiconv_progress(config,lev+3,off+len,"Going to read the element id");
id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
len ++;
switch(id) {
case 0x18:
psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
len ++;
break;
case 0x19:
psiconv_progress(config,lev+3,off+len,"Going to read text color");
if ((res = psiconv_parse_color(config,buf,lev+3,off+len, &leng,&temp_color)))
goto ERROR1;
psiconv_free_color(result->color);
result->color = temp_color;
len += leng;
break;
case 0x1a:
psiconv_progress(config,lev+3,off+len,"Going to read background color (?)");
if ((res = psiconv_parse_color(config,buf,lev+2,off+len, &leng,&temp_color)))
goto ERROR1;
psiconv_free_color(result->back_color);
result->back_color = temp_color;
len += leng;
break;
case 0x1b:
psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
len ++;
break;
case 0x1c:
psiconv_progress(config,lev+3,off+len,"Going to read font size");
result->font_size = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
if (res)
goto ERROR1;
len += leng;
break;
case 0x1d:
psiconv_progress(config,lev+3,off+len,"Going to read italic");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->italic)))
goto ERROR1;
len += leng;
break;
case 0x1e:
psiconv_progress(config,lev+3,off+len,"Going to read bold");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->bold)))
goto ERROR1;
len += leng;
break;
case 0x1f:
psiconv_progress(config,lev+3,off+len,"Going to read super_sub");
temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR1;
if (temp == 0x00)
result->super_sub = psiconv_normalscript;
else if (temp == 0x01)
result->super_sub = psiconv_superscript;
else if (temp == 0x02)
result->super_sub = psiconv_subscript;
else {
psiconv_warn(config,lev+3,off+len,
"Unknown super_sub argument in character layout codes list");
}
psiconv_debug(config,lev+3,off+len,"Super_sub: %02x",temp);
len ++;
break;
case 0x20:
psiconv_progress(config,lev+3,off+len,"Going to read underline");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
&result->underline)))
goto ERROR1;
len += leng;
break;
case 0x21:
psiconv_progress(config,lev+3,off+len,"Going to read strikethrough");
if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
&result->strikethrough)))
goto ERROR1;
len += leng;
break;
case 0x22:
psiconv_progress(config,lev+3,off+len,"Going to read font");
if ((res = psiconv_parse_font(config,buf,lev+3,off+len, &leng, &temp_font)))
goto ERROR1;
psiconv_free_font(result->font);
result->font = temp_font;
len += leng;
break;
case 0x23:
psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
len ++;
break;
case 0x24:
psiconv_progress(config,lev+3,off+len,
"Going to read unknown code 0x24 (%02x expected)", 0);
temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR1;
if (temp != 0) {
psiconv_warn(config,lev+3,off+len,
"Unknown code 0x24 value != 0x0 (0x%02x)", temp);
}
len ++;
break;
default:
psiconv_warn(config,lev+3,off+len,"Unknown code in character layout list");
psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
len ++;
break;
}
nr ++;
}
if (len - 4 != list_length) {
psiconv_error(config,lev+2,off+len,
"Read past end of character layout codes list. I probably lost track "
"somewhere!");
psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
len-4,list_length);
res = PSICONV_E_PARSE;
goto ERROR1;
}
len = list_length + 4;
psiconv_progress(config,lev+1,off+len,
"End of character layout list (total length: %08x)",len);
if (length)
*length = len;
return res;
ERROR1:
psiconv_error(config,lev+1,off,"Reading of character_layout_list failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/parse_image.c 0000644 0001750 0001750 00000103422 10336374674 015020 0000000 0000000 /*
parse_image.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "parse_routines.h"
#include "error.h"
#include "image.h"
#ifdef DMALLOC
#include
#endif
/* Extreme debugging info */
#undef LOUD
static int psiconv_decode_rle8 (const psiconv_config config, int lev,
psiconv_u32 off,
const psiconv_pixel_bytes encoded,
psiconv_pixel_bytes *decoded);
static int psiconv_decode_rle12 (const psiconv_config config, int lev,
psiconv_u32 off,
const psiconv_pixel_bytes encoded,
psiconv_pixel_bytes *decoded);
static int psiconv_decode_rle16 (const psiconv_config config, int lev,
psiconv_u32 off,
const psiconv_pixel_bytes encoded,
psiconv_pixel_bytes *decoded);
static int psiconv_decode_rle24 (const psiconv_config config, int lev,
psiconv_u32 off,
const psiconv_pixel_bytes encoded,
psiconv_pixel_bytes *decoded);
static int psiconv_bytes_to_pixel_data(const psiconv_config config,
int lev, psiconv_u32 off,
const psiconv_pixel_bytes bytes,
psiconv_pixel_ints *pixels,
int colordepth, int xsize, int ysize);
static int psiconv_pixel_data_to_floats (const psiconv_config config, int lev,
psiconv_u32 off,
const psiconv_pixel_ints pixels,
psiconv_pixel_floats_t *floats,
int colordepth, int color,
int redbits, int bluebits, int greenbits,
const psiconv_pixel_floats_t palet);
int psiconv_parse_jumptable_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_jumptable_section *result)
{
int res = 0;
int len = 0;
psiconv_u32 listlen,temp;
int i;
psiconv_progress(config,lev+1,off+len,"Going to read the jumptable section");
if (!((*result) = psiconv_list_new(sizeof(psiconv_u32))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the list length");
listlen = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"List length: %08x",listlen);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the list");
for (i = 0; i < listlen; i++) {
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if ((res = psiconv_list_add(*result,&temp)))
goto ERROR2;
psiconv_debug(config,lev+3,off+len,"Offset: %08x",temp);
len += 4;
}
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of jumptable section "
"(total length: %08x)", len);
return 0;
ERROR2:
psiconv_list_free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Jumptable Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_paint_data_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,int isclipart,
psiconv_paint_data_section *result)
{
int res = 0;
int len = 0;
psiconv_u32 size,offset,picsize,temp,datasize,color,
redbits,bluebits,greenbits;
psiconv_u8 byte;
int leng,i;
psiconv_u32 bits_per_pixel,compression;
psiconv_pixel_bytes bytes,decoded;
psiconv_pixel_ints pixels;
psiconv_pixel_floats_t floats,palet;
psiconv_progress(config,lev+1,off,"Going to read a paint data section");
if (!((*result) = malloc(sizeof(**result))))
goto ERROR1;
if (!(bytes = psiconv_list_new(sizeof(psiconv_u8))))
goto ERROR2;
psiconv_progress(config,lev+2,off+len,"Going to read section size");
size = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Section size: %08x",size);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read pixel data offset");
offset = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
if (offset != 0x28) {
psiconv_error(config,lev+2,off+len,
"Paint data section data offset has unexpected value");
psiconv_debug(config,lev+2,off+len,
"Data offset: read %08x, expected %08x",offset,0x28);
res = -1;
}
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read picture X size");
(*result)->xsize = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Picture X size: %08x:",(*result)->xsize);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read picture Y size");
(*result)->ysize = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Picture Y size: %08x:",(*result)->ysize);
len += 4;
picsize = (*result)->ysize * (*result)->xsize;
psiconv_progress(config,lev+2,off+len,"Going to read the real picture x size");
(*result)->pic_xsize = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Picture x size: %f",(*result)->pic_xsize);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the real picture y size");
(*result)->pic_ysize = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Picture y size: %f",(*result)->pic_ysize);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the number of bits per pixel");
bits_per_pixel=psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Bits per pixel: %d",bits_per_pixel);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read whether this is a colour or greyscale picture");
color = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
if ((color != 0) && (color != 1)) {
psiconv_warn(config,lev+2,off+len,
"Paint data section unknown color type (ignored)");
psiconv_debug(config,lev+2,off+len,
"Color: read %08x, expected %08x or %08x",color,0,1);
color = 1;
} else {
psiconv_debug(config,lev+2,off+len,"Color: %08x (%s picture)",
color,(color?"color":"greyscale"));
}
len += 4;
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
if (temp != 00) {
psiconv_warn(config,lev+2,off+len,
"Paint data section prologue has unknown values (ignored)");
psiconv_debug(config,lev+2,off+len,
"read %08x, expected %08x",temp, 0x00);
}
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read whether RLE compression is used");
compression=psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
if (compression > 4) {
psiconv_warn(config,lev+2,off+len,"Paint data section has unknown "
"compression type, assuming RLE");
psiconv_debug(config,lev+2,off+len,"Read compression type %d",compression);
compression = 0;
}
psiconv_debug(config,lev+2,off+len,"Compression: %s",
compression == 4?"RLE24":compression == 3?"RLE16":
compression == 2?"RLE12":compression == 1?"RLE8":"none");
len += 4;
if (isclipart) {
psiconv_progress(config,lev+2,off+len,"Going to read an unknown long");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
if (temp != 0xffffffff) {
psiconv_warn(config,lev+2,off+len,
"Paint data section prologue has unknown values (ignoring)");
psiconv_debug(config,lev+2,off+len,
"Read %08x, expected %08x",temp, 0xffffffff);
}
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read a second unknown long");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
if (temp != 0x44) {
psiconv_warn(config,lev+2,off+len,
"Paint data section prologue has unknown values (ignoring)");
psiconv_debug(config,lev+2,off+len,
"read %08x, expected %08x",temp, 0x44);
}
len += 4;
}
len = offset;
datasize = size - len;
if (isclipart)
len += 8;
if (color || (bits_per_pixel != 2))
psiconv_warn(config,lev+2,off+len,
"All image types except 2-bit greyscale are experimental!");
psiconv_progress(config,lev+2,off+len,"Going to read the pixel data");
for (i = 0; i < datasize; i++) {
byte = psiconv_read_u8(config,buf,lev+2,off+len+i,&res);
#ifdef LOUD
psiconv_debug(config,lev+2,off+len+i,
"Pixel byte %04x of %04x has value %02x",
i,datasize,byte);
#endif
if (res)
goto ERROR3;
psiconv_list_add(bytes,&byte);
}
len += datasize;
switch(compression) {
case 1:
if ((res = psiconv_decode_rle8(config,lev+2,off+len,bytes,&decoded)))
goto ERROR3;
psiconv_list_free(bytes);
bytes = decoded;
break;
case 2:
if ((psiconv_decode_rle12(config,lev+2,off+len,bytes,&decoded)))
goto ERROR3;
psiconv_list_free(bytes);
bytes = decoded;
break;
case 3:
if ((psiconv_decode_rle16(config,lev+2,off+len,bytes,&decoded)))
goto ERROR3;
psiconv_list_free(bytes);
bytes = decoded;
break;
case 4:
if ((psiconv_decode_rle24(config,lev+2,off+len,bytes,&decoded)))
goto ERROR3;
psiconv_list_free(bytes);
bytes = decoded;
break;
}
if ((res = psiconv_bytes_to_pixel_data(config,lev+2,off+len,bytes,
&pixels,bits_per_pixel,
(*result)->xsize,(*result)->ysize)))
goto ERROR3;
/* Use some heuristics; things may get unexpected around here */
bluebits = redbits = greenbits = 0;
palet = psiconv_palet_none;
if (color) {
if (bits_per_pixel == 4)
palet = psiconv_palet_color_4;
else if (bits_per_pixel == 8)
palet = psiconv_palet_color_8;
else {
redbits = (bits_per_pixel+2) / 3;
greenbits = (bits_per_pixel+2) / 3;
bluebits = bits_per_pixel - redbits - greenbits;
}
}
if ((res = psiconv_pixel_data_to_floats(config,lev+2,off+len,pixels,
&floats,bits_per_pixel,color,
redbits,greenbits,bluebits,palet)))
goto ERROR4;
(*result)->red = floats.red;
(*result)->green = floats.green;
(*result)->blue = floats.blue;
psiconv_list_free(bytes);
psiconv_list_free(pixels);
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of Paint Data Section (total length: %08x)", len);
return 0;
ERROR4:
psiconv_list_free(pixels);
ERROR3:
psiconv_list_free(bytes);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Paint Data Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sketch_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sketch_section *result)
{
int res=0;
int len=0;
psiconv_u32 temp;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the sketch section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the displayed hor. size");
(*result)->displayed_xsize = psiconv_read_u16(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Displayed hor. size: %04x",
(*result)->displayed_xsize);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read displayed ver. size");
(*result)->displayed_ysize = psiconv_read_u16(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Displayed ver. size: %04x",
(*result)->displayed_ysize);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read the data hor. offset");
(*result)->picture_data_x_offset = psiconv_read_u16(config,buf,lev+2,off + len,
&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Data hor. offset: %04x",
(*result)->picture_data_x_offset);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read the data ver. offset");
(*result)->picture_data_y_offset = psiconv_read_u16(config,buf,lev+2,off + len,
&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Data ver. offset: %04x",
(*result)->picture_data_y_offset);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read the displayed hor. offset");
(*result)->displayed_size_x_offset = psiconv_read_u16(config,buf,lev+2,off + len,
&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Displayed hor. offset: %04x",
(*result)->displayed_size_x_offset);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read the displayed ver. offset");
(*result)->displayed_size_y_offset = psiconv_read_u16(config,buf,lev+2,off + len,
&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Displayed ver. offset: %04x",
(*result)->displayed_size_y_offset);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read the form hor. size");
(*result)->form_xsize = psiconv_read_u16(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Form hor. size: %04x",
(*result)->form_xsize);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read form ver. size");
(*result)->form_ysize = psiconv_read_u16(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Form ver. size: %04x",
(*result)->form_ysize);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to skip 1 word of zeros");
temp = psiconv_read_u16(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0) {
psiconv_warn(config,lev+2,off+len,
"Unexpected value in sketch section preamble (ignored)");
psiconv_debug(config,lev+2,off+len,"Read %04x, expected %04x",
temp,0);
}
off += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read the picture data");
if ((res = psiconv_parse_paint_data_section(config,buf,lev+2,off+len,&leng,0,
&((*result)->picture))))
goto ERROR2;
off += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the hor. magnification");
(*result)->magnification_x = psiconv_read_u16(config,buf,lev+2,off+len,&res)/1000.0;
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Form hor. magnification: %f",
(*result)->magnification_x);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read the ver. magnification");
(*result)->magnification_y = psiconv_read_u16(config,buf,lev+2,off+len,&res)/1000.0;
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Form ver. magnification: %f",
(*result)->magnification_y);
len += 0x02;
psiconv_progress(config,lev+2,off+len,"Going to read the left cut");
temp = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR3;
(*result)->cut_left = (temp * 6.0) / (*result)->displayed_xsize;
psiconv_debug(config,lev+2,off+len,"Left cut: raw %08x, real: %f",
temp,(*result)->cut_left);
len += 0x04;
psiconv_progress(config,lev+2,off+len,"Going to read the right cut");
temp = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR3;
(*result)->cut_right = (temp * 6.0) / (*result)->displayed_xsize;
psiconv_debug(config,lev+2,off+len,"Right cut: raw %08x, real: %f",
temp,(*result)->cut_right);
len += 0x04;
psiconv_progress(config,lev+2,off+len,"Going to read the top cut");
temp = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR3;
(*result)->cut_top = (temp * 6.0) / (*result)->displayed_ysize;
psiconv_debug(config,lev+2,off+len,"Top cut: raw %08x, real: %f",
temp,(*result)->cut_top);
len += 0x04;
psiconv_progress(config,lev+2,off+len,"Going to read the bottom cut");
temp = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR3;
(*result)->cut_bottom = (temp * 6.0) / (*result)->displayed_ysize;
psiconv_debug(config,lev+2,off+len,"Bottom cut: raw %08x, real: %f",
temp,(*result)->cut_bottom);
len += 0x04;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sketch section (total length: %08x)", len);
return res;
ERROR3:
psiconv_free_paint_data_section((*result)->picture);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sketch Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_clipart_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_clipart_section *result)
{
int res=0;
int len=0;
int leng;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off+len,"Going to read the clipart section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the section ID");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != PSICONV_ID_CLIPART_ITEM) {
psiconv_warn(config,lev+2,off+len,
"Unexpected value in clipart section preamble (ignored)");
psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x",temp,
PSICONV_ID_CLIPART_ITEM);
} else
psiconv_debug(config,lev+2,off+len,"Clipart ID: %08x", temp);
off += 4;
psiconv_progress(config,lev+2,off+len,"Going to read an unknown long");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Unexpected value in clipart section preamble (ignored)");
psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x",temp,
0x02);
} else
psiconv_debug(config,lev+2,off+len,"First unknown long: %08x", temp);
off += 4;
psiconv_progress(config,lev+2,off+len,"Going to read a second unknown long");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0) {
psiconv_warn(config,lev+2,off+len,
"Unexpected value in clipart section preamble (ignored)");
psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x",temp, 0);
} else
psiconv_debug(config,lev+2,off+len,"Second unknown long: %08x", temp);
off += 4;
psiconv_progress(config,lev+2,off+len,"Going to read a third unknown long");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0) {
psiconv_warn(config,lev+2,off+len,
"Unexpected value in clipart section preamble (ignored)");
psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x",temp, 0);
} else
psiconv_debug(config,lev+2,off+len,"Third unknown long: %08x", temp);
off += 4;
psiconv_progress(config,lev+2,off+len,"Going to read a fourth unknown long");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if ((temp != 0x0c) && (temp != 0x08)) {
psiconv_warn(config,lev+2,off+len,
"Unexpected value in clipart section preamble (ignored)");
psiconv_debug(config,lev+2,off+len,"Read %08x, expected %08x or %08x",temp,
0x0c, 0x08);
} else
psiconv_debug(config,lev+2,off+len,"Fourth unknown long: %08x", temp);
off += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the Paint Data Section");
if ((res = psiconv_parse_paint_data_section(config,buf,lev+2,off+len,&leng,1,
&((*result)->picture))))
goto ERROR2;
len += leng;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of clipart section (total length: %08x)", len);
return 0;
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Font failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_decode_rle8 (const psiconv_config config, int lev, psiconv_u32 off,
const psiconv_pixel_bytes encoded,
psiconv_pixel_bytes *decoded)
{
int res=0;
psiconv_u8 *marker,*value;
int i,j;
psiconv_progress(config,lev+1,off,"Going to decode the RLE8 encoding");
if (!(*decoded = psiconv_list_new(sizeof(psiconv_u8))))
goto ERROR1;
for (i = 0; i < psiconv_list_length(encoded);) {
#ifdef LOUD
psiconv_progress(config,lev+2,off,"Going to read marker byte at %04x",i);
#endif
if (!(marker = psiconv_list_get(encoded,i)))
goto ERROR2;
#ifdef LOUD
psiconv_debug(config,lev+2,off,"Marker byte: %02x",*marker);
#endif
if (*marker < 0x80) {
#ifdef LOUD
psiconv_debug(config,lev+2,off,"Marker: repeat value byte %02x times",
*marker+1); */
psiconv_progress(config,lev+2,off,"Going to read value byte at %04x",i+1);
#endif
if (!(value = psiconv_list_get(encoded,i+1)))
goto ERROR2;
#ifdef LOUD
psiconv_debug(config,lev+2,off,"Value byte: %02x",*value);
psiconv_progress(config,lev+2,off,"Adding %02x pixels %02x",
*marker+1,*value);
#endif
for (j = 0; j < *marker + 1; j++)
if ((res = psiconv_list_add(*decoded,value)))
goto ERROR2;
i += 2;
} else {
#ifdef LOUD
psiconv_debug(config,lev+2,off,"Marker: %02x value bytes follow",
0x100 - *marker);
#endif
for (j = 0; j < (0x100 - *marker); j++) {
#ifdef LOUD
psiconv_progress(config,lev+2,off,"Going to read value byte at %04x",
i+j+1);
#endif
if (!(value = psiconv_list_get(encoded,i+j+1)))
goto ERROR2;
#ifdef LOUD
psiconv_debug(config,lev+2,off,"Value: %02x",*value);
#endif
if ((res = psiconv_list_add(*decoded,value)))
goto ERROR2;
}
i += (0x100 - *marker) + 1;
}
}
psiconv_progress(config,lev,off,
"End of RLE8 decoding process");
return 0;
ERROR2:
psiconv_list_free(*decoded);
ERROR1:
psiconv_error(config,lev+1,off,"Decoding of RLE8 failed");
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_decode_rle12 (const psiconv_config config, int lev, psiconv_u32 off,
const psiconv_pixel_bytes encoded,
psiconv_pixel_bytes *decoded)
{
int res=0;
psiconv_u8 *value0,*value1;
psiconv_u32 value,repeat;
int i,j;
psiconv_progress(config,lev+1,off,"Going to decode the RLE12 encoding");
if (!(*decoded = psiconv_list_new(sizeof(psiconv_u8))))
goto ERROR1;
for (i = 0; i < psiconv_list_length(encoded);) {
psiconv_progress(config,lev+2,off,"Going to read data word at %04x",i);
if (!(value0 = psiconv_list_get(encoded,i)))
goto ERROR2;
if (!(value1 = psiconv_list_get(encoded,i+1)))
goto ERROR2;
psiconv_debug(config,lev+2,off,"Data Word: %04x",*value0 + (*value1 << 8));
value = *value0 + ((*value1 & 0x0f) << 8);
repeat = (*value1 >> 4) + 1;
psiconv_progress(config,lev+2,off,"Adding %02x pixels %03x",
repeat,value);
for (j = 0; j < repeat; j ++)
if ((res = psiconv_list_add(*decoded,&value)))
goto ERROR2;
i += 2;
}
psiconv_progress(config,lev,off,
"End of RLE12 decoding process");
return 0;
ERROR2:
psiconv_list_free(*decoded);
ERROR1:
psiconv_error(config,lev+1,off,"Decoding of RLE12 failed");
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_decode_rle16 (const psiconv_config config, int lev, psiconv_u32 off,
const psiconv_pixel_bytes encoded,
psiconv_pixel_bytes *decoded)
{
int res=0;
psiconv_u8 *marker,*value0,*value1;
psiconv_u32 value;
int i,j;
psiconv_progress(config,lev+1,off,"Going to decode the RLE16 encoding");
if (!(*decoded = psiconv_list_new(sizeof(psiconv_u8))))
goto ERROR1;
for (i = 0; i < psiconv_list_length(encoded);) {
psiconv_progress(config,lev+2,off,"Going to read marker byte at %04x",i);
if (!(marker = psiconv_list_get(encoded,i)))
goto ERROR2;
psiconv_debug(config,lev+2,off,"Marker byte: %02x",*marker);
if (*marker < 0x80) {
psiconv_debug(config,lev+2,off,"Marker: repeat value word %02x times",
*marker+1);
psiconv_progress(config,lev+2,off,"Going to read value word at %04x",i+1);
if (!(value0 = psiconv_list_get(encoded,i+1)))
goto ERROR2;
if (!(value1 = psiconv_list_get(encoded,i+2)))
goto ERROR2;
value = *value0 + (*value1 << 8);
psiconv_debug(config,lev+2,off,"Value word: %02x",value);
psiconv_progress(config,lev+2,off,"Adding %02x pixels %04x",
*marker+1,value);
for (j = 0; j < *marker + 1; j++)
if ((res = psiconv_list_add(*decoded,&value)))
goto ERROR2;
i += 3;
} else {
psiconv_debug(config,lev+2,off,"Marker: %02x value words follow",
0x100 - *marker);
for (j = 0; j < (0x100 - *marker); j++) {
psiconv_progress(config,lev+2,off,"Going to read value word at %04x",
i+j*2+1);
if (!(value0 = psiconv_list_get(encoded,i+j*2+1)))
goto ERROR2;
if (!(value1 = psiconv_list_get(encoded,i+j*2+2)))
goto ERROR2;
value = *value0 + (*value1 << 8);
psiconv_debug(config,lev+2,off,"Value: %04x",value);
if ((res = psiconv_list_add(*decoded,&value)))
goto ERROR2;
}
i += (0x100 - *marker)*2 + 1;
}
}
psiconv_progress(config,lev,off,
"End of RLE16 decoding process");
return 0;
ERROR2:
psiconv_list_free(*decoded);
ERROR1:
psiconv_error(config,lev+1,off,"Decoding of RLE16 failed");
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_decode_rle24 (const psiconv_config config, int lev, psiconv_u32 off,
const psiconv_pixel_bytes encoded,
psiconv_pixel_bytes *decoded)
{
int res=0;
psiconv_u8 *marker,*value0,*value1,*value2;
psiconv_u32 value;
int i,j;
psiconv_progress(config,lev+1,off,"Going to decode the RLE24 encoding");
if (!(*decoded = psiconv_list_new(sizeof(psiconv_u8))))
goto ERROR1;
for (i = 0; i < psiconv_list_length(encoded);) {
psiconv_progress(config,lev+2,off,"Going to read marker byte at %04x",i);
if (!(marker = psiconv_list_get(encoded,i)))
goto ERROR2;
psiconv_debug(config,lev+2,off,"Marker byte: %02x",*marker);
if (*marker < 0x80) {
psiconv_debug(config,lev+2,off,"Marker: repeat value byte triplet %02x times",
*marker+1);
psiconv_progress(config,lev+2,off,"Going to read value byte triplet at %04x",i+1);
if (!(value0 = psiconv_list_get(encoded,i+1)))
goto ERROR2;
if (!(value1 = psiconv_list_get(encoded,i+2)))
goto ERROR2;
if (!(value2 = psiconv_list_get(encoded,i+3)))
goto ERROR2;
value = *value0 + (*value1 << 8) + (*value2 << 16);
psiconv_debug(config,lev+2,off,"Value byte triplet: %06x",value);
psiconv_progress(config,lev+2,off,"Adding %02x pixels %06x",
*marker+1,value);
for (j = 0; j < *marker + 1; j++)
if ((res = psiconv_list_add(*decoded,&value)))
goto ERROR2;
i += 4;
} else {
psiconv_debug(config,lev+2,off,"Marker: %02x value byte triplets follow",
0x100 - *marker);
for (j = 0; j < (0x100 - *marker); j++) {
psiconv_progress(config,lev+2,off,"Going to read value byte triplets at %04x",
i+j*3+1);
if (!(value0 = psiconv_list_get(encoded,i+j*3+1)))
goto ERROR2;
if (!(value1 = psiconv_list_get(encoded,i+j*3+2)))
goto ERROR2;
if (!(value2 = psiconv_list_get(encoded,i+j*3+3)))
goto ERROR2;
value = *value0 + (*value1 << 8) + (*value2 << 16);
psiconv_debug(config,lev+2,off,"Value: %06x",value);
if ((res = psiconv_list_add(*decoded,&value)))
goto ERROR2;
}
i += (0x100 - *marker)*3 + 1;
}
}
psiconv_progress(config,lev,off,
"End of RLE24 decoding process");
return 0;
ERROR2:
psiconv_list_free(*decoded);
ERROR1:
psiconv_error(config,lev+1,off,"Decoding of RLE24 failed");
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_bytes_to_pixel_data(const psiconv_config config,
int lev, psiconv_u32 off,
const psiconv_pixel_bytes bytes,
psiconv_pixel_ints *pixels,
int colordepth, int xsize, int ysize)
{
int res=0;
int ibits,obits,x,y,bits;
psiconv_u8 input;
psiconv_u32 nr,output;
psiconv_u8 *ientry;
psiconv_progress(config,lev+1,off,"Going to convert the bytes to pixels");
if (!(*pixels = psiconv_list_new(sizeof(psiconv_u32))))
goto ERROR1;
nr = 0;
for (y = 0; y < ysize; y++) {
/* New lines will start at longs */
while (nr % 4)
nr ++;
input = 0;
ibits = 0;
for (x= 0; x < xsize; x++) {
#ifdef LOUD
psiconv_progress(config,lev+2,off,
"Processing pixel at (x,y) = (%04x,%04x)",x,y);
#endif
output = 0;
obits = 0;
while (obits < colordepth) {
if (ibits == 0) {
#ifdef LOUD
psiconv_progress(config,lev+3,off,
"Going to read byte %08x",nr);
#endif
if (!(ientry = psiconv_list_get(bytes,nr)))
goto ERROR2;
#ifdef LOUD
psiconv_debug(config,lev+3,off,"Byte value: %02x",*ientry);
#endif
input = *ientry;
ibits = 8;
nr ++;
}
bits = ibits + obits > colordepth?colordepth-obits:ibits;
output = output << bits;
output |= input & ((1 << bits) - 1);
input = input >> bits;
ibits -= bits;
obits += bits;
}
#ifdef LOUD
psiconv_debug(config,lev+2,off,"Pixel value: %08x",output);
#endif
if ((res = psiconv_list_add(*pixels,&output)))
goto ERROR2;
}
}
psiconv_progress(config,lev,off,
"Converting bytes to pixels completed");
return 0;
ERROR2:
psiconv_list_free(*pixels);
ERROR1:
psiconv_error(config,lev+1,off,"Converting bytes to pixels failed");
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_pixel_data_to_floats (const psiconv_config config, int lev,
psiconv_u32 off,
const psiconv_pixel_ints pixels,
psiconv_pixel_floats_t *floats,
int colordepth, int color,
int redbits, int bluebits, int greenbits,
const psiconv_pixel_floats_t palet)
{
int res = 0;
psiconv_u32 i;
psiconv_u32 *pixel;
psiconv_progress(config,lev+1,off,"Going to convert pixels to floats");
if (!((*floats).red = malloc(psiconv_list_length(pixels) *
sizeof(*(*floats).red))))
goto ERROR1;
if (!((*floats).green = malloc(psiconv_list_length(pixels) *
sizeof(*(*floats).green))))
goto ERROR2;
if (!((*floats).blue = malloc(psiconv_list_length(pixels) *
sizeof(*(*floats).blue))))
goto ERROR3;
(*floats).length = psiconv_list_length(pixels);
for (i = 0; i < psiconv_list_length(pixels); i++) {
if (!(pixel = psiconv_list_get(pixels,i)))
goto ERROR4;
#ifdef LOUD
psiconv_progress(config,lev+2,off, "Handling pixel %04x (%04x)",i,*pixel);
#endif
if (!palet.length) {
if (color) {
(*floats).blue[i] = ((float) (*pixel & ((1 << bluebits) - 1))) /
((1 << bluebits) - 1);
(*floats).green[i] = ((float) ((*pixel >> bluebits) &
((1 << greenbits) - 1))) / ((1 << greenbits) - 1);
(*floats).red[i] = ((float) ((*pixel >> (bluebits+greenbits)) &
((1 << redbits) - 1))) / ((1 << redbits) - 1);
} else {
(*floats).red[i] = (*floats).green[i] =
(*floats).blue[i] = ((float) *pixel) /
((1 << colordepth) - 1);
}
} else {
if (*pixel >= palet.length) {
psiconv_warn(config,lev+2,off,
"Invalid palet color found (using color 0x00)");
(*floats).red[i] = palet.red[0];
(*floats).green[i] = palet.green[0];
(*floats).blue[i] = palet.blue[0];
} else {
(*floats).red[i] = palet.red[*pixel];
(*floats).green[i] = palet.green[*pixel];
(*floats).blue[i] = palet.blue[*pixel];
}
}
#ifdef LOUD
psiconv_debug(config,lev+2,off, "Pixel: Red (%f), green (%f), blue (%f)",
(*floats).red[i],(*floats).green[i],(*floats).blue[i]);
#endif
}
psiconv_progress(config,lev+1,off,"Finished converting pixels to floats");
return 0;
ERROR4:
free((*floats).blue);
ERROR3:
free((*floats).green);
ERROR2:
free((*floats).red);
ERROR1:
psiconv_error(config,lev+1,off,"Converting pixels to floats failed");
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/parse_page.c 0000644 0001750 0001750 00000022320 10336374676 014651 0000000 0000000 /*
parse_page.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "parse_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
int psiconv_parse_page_header(const psiconv_config config,
const psiconv_buffer buf,int lev,psiconv_u32 off,
int *length,psiconv_page_header *result)
{
int res = 0;
int len = 0;
int i,leng,has_content;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off,"Going to read a page header (or footer)");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the has_content flag");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp == 0x00)
has_content = 0;
else if (temp == 0x01)
has_content = 1;
else {
psiconv_warn(config,lev+2,off+len,
"Page header has_content flag unknown value (assumed default)");
psiconv_debug(config,lev+2,off+len,"Flag: %02x",temp);
has_content = 1;
}
psiconv_debug(config,lev+2,off+len,"Has_content flag: %02x",has_content);
len += 1;
psiconv_progress(config,lev+2,off+len,"Going to read displayed-on-first-page flag");
if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,
&(*result)->on_first_page)))
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read three zero bytes");
for (i = 0; i < 0x03; i++,len++) {
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x00) {
psiconv_warn(config,lev+2,off+len,
"Page Header unknown value in zero bytes section");
psiconv_debug(config,lev+2,off+len,"Byte %d: read %02x, expected %02x",
i,temp,0x00);
}
}
psiconv_progress(config,lev+2,off+len,"Going to read base paragraph layout");
if (!((*result)->base_paragraph_layout = psiconv_basic_paragraph_layout()))
goto ERROR2;
if (has_content) {
if ((res = psiconv_parse_paragraph_layout_list(config,buf,lev+2,off+len,&leng,
(*result)->base_paragraph_layout)))
goto ERROR3;
len += leng;
}
psiconv_progress(config,lev+2,off+len,"Going to read base character layout");
if (!((*result)->base_character_layout = psiconv_basic_character_layout()))
goto ERROR3;
if (has_content) {
if ((res = psiconv_parse_character_layout_list(config,buf,lev+2,off+len,&leng,
(*result)->base_character_layout)))
goto ERROR4;
}
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the TextEd section");
if (has_content) {
if ((res = psiconv_parse_texted_section(config,buf,lev+2,off+len,&leng,
&(*result)->text,
(*result)->base_character_layout,
(*result)->base_paragraph_layout)))
goto ERROR4;
len += leng;
} else {
(*result)->text = NULL;
}
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of page header"
"(total length: %08x", len);
return res;
ERROR4:
psiconv_free_character_layout((*result)->base_character_layout);
ERROR3:
psiconv_free_paragraph_layout((*result)->base_paragraph_layout);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Page Header failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_page_layout_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_page_layout_section *result)
{
int res = 0;
int len = 0;
int leng;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off,"Going to read the page layout section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read first page number");
(*result)->first_page_nr = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"First page: %d",(*result)->first_page_nr);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read header distance");
(*result)->header_dist = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Header distance: %6.3f",(*result)->header_dist);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read footer distance");
(*result)->footer_dist = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Footer distance: %6.3f",(*result)->footer_dist);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the left margin");
(*result)->left_margin = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Left margin: %6.3f",(*result)->left_margin);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going read the to right margin");
(*result)->right_margin = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Right margin: %6.3f",(*result)->right_margin);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the top margin");
(*result)->top_margin = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Top margin: %6.3f",(*result)->top_margin);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the bottom margin");
(*result)->bottom_margin = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Bottom margin: %6.3f",(*result)->bottom_margin);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the header");
if ((res = psiconv_parse_page_header(config,buf,lev+2,off+len,&leng,
&(*result)->header)))
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the footer");
if ((res = psiconv_parse_page_header(config,buf,lev+2,off+len,&leng,
&(*result)->footer)))
goto ERROR3;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read page dimensions id");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR4;
if ((temp != PSICONV_ID_PAGE_DIMENSIONS1) &&
(temp != PSICONV_ID_PAGE_DIMENSIONS2)) {
psiconv_warn(config,lev+2,off+len,
"Page layout section page dimensions marker not found");
psiconv_debug(config,lev+2,off+len,
"Page dimensions marker: read %08x, expected %08x or %08x",
temp, PSICONV_ID_PAGE_DIMENSIONS1,
PSICONV_ID_PAGE_DIMENSIONS2);
}
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the page width");
(*result)->page_width = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR4;
psiconv_debug(config,lev+2,off+len,"Page width: %6.3f",(*result)->page_width);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the page height");
(*result)->page_height = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR4;
psiconv_debug(config,lev+2,off+len,"Page height: %6.3f",(*result)->page_height);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read page portrait/landscape");
if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->landscape)))
goto ERROR4;
psiconv_debug(config,lev+2,off+len,"Landscape: %d",(*result)->landscape);
len += leng;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,"End of page section (total length: %08x)",
len);
return res;
ERROR4:
psiconv_free_page_header((*result)->footer);
ERROR3:
psiconv_free_page_header((*result)->header);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Page Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/parse_simple.c 0000644 0001750 0001750 00000031612 10336374700 015216 0000000 0000000 /*
parse_simple.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "parse_routines.h"
#include "error.h"
#include "unicode.h"
#ifdef DMALLOC
#include
#endif
static psiconv_float_t pow2(int n);
static psiconv_string_t psiconv_read_string_aux(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off,int *length, int *status,
int kind);
/* Very inefficient, but good enough for now. By implementing it ourselves,
we do not have to link with -lm */
psiconv_float_t pow2(int n)
{
psiconv_float_t res=1.0;
int i;
for (i = 0; i < (n<0?-n:n); i++)
res *= 2.0;
return n<0?1/res:res;
}
psiconv_u8 psiconv_read_u8(const psiconv_config config,const psiconv_buffer buf,int lev,psiconv_u32 off,
int *status)
{
psiconv_u8 *ptr;
ptr = psiconv_buffer_get(buf,off);
if (!ptr) {
psiconv_error(config,lev,off,"Trying byte read past the end of the file");
if (status)
*status = -PSICONV_E_PARSE;
return 0;
}
if (status)
*status = 0;
return *ptr;
}
psiconv_u16 psiconv_read_u16(const psiconv_config config,const psiconv_buffer buf,int lev,psiconv_u32 off,
int *status)
{
psiconv_u8 *ptr0,*ptr1;
ptr0 = psiconv_buffer_get(buf,off);
ptr1 = psiconv_buffer_get(buf,off+1);
if (!ptr0 || !ptr1) {
psiconv_error(config,lev,off,"Trying word read past the end of the file");
if (status)
*status = -PSICONV_E_PARSE;
return 0;
}
if (status)
*status = 0;
return *ptr0 + (*ptr1 << 8);
}
psiconv_u32 psiconv_read_u32(const psiconv_config config,const psiconv_buffer buf,int lev,psiconv_u32 off,
int *status)
{
psiconv_u8 *ptr0,*ptr1,*ptr2,*ptr3;
ptr0 = psiconv_buffer_get(buf,off);
ptr1 = psiconv_buffer_get(buf,off+1);
ptr2 = psiconv_buffer_get(buf,off+2);
ptr3 = psiconv_buffer_get(buf,off+3);
if (!ptr0 || !ptr1 || !ptr2 || !ptr3) {
psiconv_error(config,lev,off,"Trying long read past the end of the file");
if (status)
*status = -PSICONV_E_PARSE;
return 0;
}
if (status)
*status = 0;
return *ptr0 + (*ptr1 << 8) + (*ptr2 << 16) + (*ptr3 << 24);
}
psiconv_s32 psiconv_read_sint(const psiconv_config config,const psiconv_buffer buf,int lev,psiconv_u32 off,
int *length,int *status)
{
int localstatus;
psiconv_u32 temp;
temp=psiconv_read_u32(config,buf,lev,off,&localstatus);
if (status)
*status = localstatus;
if (length)
*length = localstatus?0:4;
return localstatus?0:(temp & 0x7fffffff)*(temp&0x80000000?-1:1);
}
psiconv_u32 psiconv_read_S(const psiconv_config config,const psiconv_buffer buf, int lev, psiconv_u32 off,
int *length,int *status)
{
psiconv_u8 temp;
psiconv_u32 res;
int len,localstatus;
psiconv_progress(config,lev+1,off,"Going to read a S length indicator");
temp = psiconv_read_u8(config,buf,lev+2,off,&localstatus);
if (localstatus)
goto ERROR;
if ((temp & 0x03) == 0x02) {
res = psiconv_read_u8(config,buf,lev+2,off,&localstatus) >> 2;
if (localstatus)
goto ERROR;
len = 1;
psiconv_debug(config,lev+2,off,"Indicator (1 byte): %02x",res);
} else if ((temp & 0x07) == 0x05) {
res = psiconv_read_u16(config,buf,lev+2,off,&localstatus) >> 3;
if (localstatus)
goto ERROR;
len = 2;
psiconv_debug(config,lev+2,off,"Indicator (2 bytes): %04x",res);
} else {
psiconv_error(config,lev+2,off,"S indicator: unknown encoding!");
psiconv_debug(config,lev+2,off,"Raw data first byte: %02x",temp);
goto ERROR;
}
if (length)
*length = len;
if (status)
*status = 0;
psiconv_progress(config,lev+1,off+len-1,
"End of S length indicator (total length: %08x)", len);
return res;
ERROR:
psiconv_error(config,lev+1,off,"Reading of S indicator failed");
if (status)
*status = localstatus;
if (length)
*length = 0;
return 0;
}
psiconv_u32 psiconv_read_X(const psiconv_config config,const psiconv_buffer buf, int lev, psiconv_u32 off,
int *length, int *status)
{
psiconv_u8 temp;
psiconv_u32 res;
int len,localstatus;
psiconv_progress(config,lev+1,off,"Going to read a X length indicator");
temp = psiconv_read_u8(config,buf,lev+2,off,&localstatus);
if (localstatus)
goto ERROR;
if ((temp & 0x01) == 0x00) {
res = psiconv_read_u8(config,buf,lev+2,off,&localstatus) >> 1;
if (localstatus)
goto ERROR;
len = 1;
psiconv_debug(config,lev+2,off,"Indicator (1 byte): %02x",res);
} else if ((temp & 0x03) == 0x01) {
res = psiconv_read_u16(config,buf,lev+2,off,&localstatus) >> 2;
if (localstatus)
goto ERROR;
len = 2;
psiconv_debug(config,lev+2,off,"Indicator (2 bytes): %04x",res);
} else if ((temp & 0x07) == 0x03) {
res = psiconv_read_u32(config,buf,lev+2,off,&localstatus) >> 3;
if (localstatus)
goto ERROR;
len = 4;
psiconv_debug(config,lev+2,off,"Indicator (4 bytes): %08x",res);
} else {
psiconv_error(config,lev+2,off,"X indicator: unknown encoding!");
psiconv_debug(config,lev+2,off,"Raw data first byte: %02x",temp);
goto ERROR;
}
if (length)
*length = len;
if (status)
*status = 0;
psiconv_progress(config,lev+1,off+len-1,
"End of X length indicator (total length: %08x)", len);
return res;
ERROR:
psiconv_error(config,lev+1,off,"Reading of X indicator failed");
if (status)
*status = localstatus;
if (length)
*length = 0;
return 0;
}
psiconv_length_t psiconv_read_length(const psiconv_config config,const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length, int *status)
{
psiconv_length_t res;
int localstatus;
res = (2.54/1440.0) * ((psiconv_s32) psiconv_read_u32(config,buf,lev,off,
&localstatus));
if (localstatus) {
psiconv_error(config,lev+1,off,"Reading of length failed");
if (length)
*length = 0;
if (status)
*status = localstatus;
return 0;
}
psiconv_debug(config,lev+1,off,"Length: %f",res);
if (length)
*length = 4;
if (status)
*status = 0;
return res;
}
psiconv_size_t psiconv_read_size(const psiconv_config config,const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length, int *status)
{
psiconv_size_t res;
int localstatus;
res = ((psiconv_s32) psiconv_read_u32(config,buf,lev,off,&localstatus)) / 20.0;
if (localstatus) {
psiconv_error(config,lev+1,off,"Reading of size failed");
if (length)
*length = 0;
if (status)
*status = localstatus;
return 0;
}
psiconv_debug(config,lev+1,off,"Size: %f",res);
if (status)
*status = 0;
if (length)
*length = 4;
return res;
}
int psiconv_parse_bool(const psiconv_config config,const psiconv_buffer buf, int lev, psiconv_u32 off,
int *length, psiconv_bool_t *result)
{
psiconv_u8 temp;
int localstatus;
temp = psiconv_read_u8(config,buf,lev,off,&localstatus);
if (localstatus) {
psiconv_error(config,lev+1,off,"Reading of bool failed");
if (length)
*length = 0;
return localstatus;
}
if (length)
*length = 1;
if (temp == 0) {
*result = psiconv_bool_false;
return 0;
} else if (temp == 1) {
*result = psiconv_bool_true;
return 0;
}
psiconv_warn(config,lev+1,off,"Unknown value for boolean");
psiconv_debug(config,lev+1,off,"Boolean value: %02x",temp);
*result = psiconv_bool_true;
return 0;
}
psiconv_string_t psiconv_read_string(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off,int *length, int *status)
{
return psiconv_read_string_aux(config,buf,lev,off,length,status,-1);
}
psiconv_string_t psiconv_read_short_string(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off,int *length, int *status)
{
return psiconv_read_string_aux(config,buf,lev,off,length,status,-2);
}
psiconv_string_t psiconv_read_charlist(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int nrofchars,
int *status)
{
int length;
if (nrofchars <= 0) {
psiconv_error(config,lev,off,
"psiconv_read_charlist called with non-positive nrofchars");
if (status)
*status = -PSICONV_E_OTHER;
return NULL;
}
return psiconv_read_string_aux(config,buf,lev,off,&length,status,nrofchars);
}
psiconv_string_t psiconv_read_string_aux(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off,int *length, int *status,
int kind)
{
int bytecount,i,leng,len,localstatus;
psiconv_string_t result;
char *res_copy;
psiconv_list string;
psiconv_ucs2 nextchar;
psiconv_ucs2 *nextcharptr;
psiconv_progress(config,lev+1,off,"Going to read a string");
if (kind == -1)
bytecount = psiconv_read_S(config,buf,lev+2,off,&leng,&localstatus);
else if (kind == -2) {
bytecount = psiconv_read_u8(config,buf,lev+2,off,&localstatus);
leng = 1;
} else {
bytecount = kind;
leng = 0;
localstatus = 0;
}
if (localstatus)
goto ERROR1;
psiconv_debug(config,lev+2,off,"Length: %i",bytecount);
len = leng;
if (!(string = psiconv_list_new(sizeof(*result))))
goto ERROR1;
/* Read the string into a temporary list */
i = 0;
while (i < bytecount) {
nextchar = psiconv_unicode_read_char(config,buf,lev,off+i+len,
&leng,&localstatus);
if (localstatus)
goto ERROR2;
if ((localstatus = psiconv_list_add(string,&nextchar)))
goto ERROR2;
i += leng;
}
if (i > bytecount) {
psiconv_error(config,lev,off+i+len,"Malformed string");
localstatus = PSICONV_E_PARSE;
goto ERROR2;
}
len += bytecount;
/* Copy the list to the actual string */
if (!(result = malloc(sizeof(*result) * (psiconv_list_length(string) + 1))))
goto ERROR2;
for (i = 0; i < psiconv_list_length(string); i++) {
if (!(nextcharptr = psiconv_list_get(string,i))) {
psiconv_error(config,lev,off+i+len,"Data structure corruption");
goto ERROR3;
}
result[i] = *nextcharptr;
}
result[i] = 0;
res_copy = psiconv_make_printable(config,result);
if (!res_copy)
goto ERROR3;
psiconv_debug(config,lev+2,off,"Contents: `%s'",res_copy);
free(res_copy);
psiconv_list_free(string);
if (length)
*length = len;
if (status)
*status = 0;
psiconv_progress(config,lev+1,off+len-1,"End of string (total length: %08x)",len);
return result;
ERROR3:
free(result);
ERROR2:
psiconv_list_free(string);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of string failed");
if (status)
*status = localstatus;
if (length)
*length = 0;
return NULL;
}
psiconv_float_t psiconv_read_float(const psiconv_config config,const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length, int *status)
{
psiconv_float_t result,bitvalue;
int res,bit;
psiconv_u32 temp=0;
psiconv_progress(config,lev+1,off,"Going to read a float");
bitvalue = 0.5;
result = 1.0;
for (bit = 0x33; bit > 0; bit--) {
if ((bit == 0x33) || ((bit & 0x07) == 0x07))
temp = psiconv_read_u8(config,buf,lev+2,off+ (bit >> 3),&res);
if (res)
goto ERROR;
if (temp & (0x01 << (bit & 0x07)))
result += bitvalue;
bitvalue /= 2.0;
}
temp = psiconv_read_u16(config,buf,lev+2,off+6,&res);
if (res)
goto ERROR;
if (temp & 0x8000)
result = -result;
temp = (temp & 0x7ff0) >> 4;
result *= pow2(((int) temp)-0x3ff);
psiconv_debug(config,lev+1,off,"Float value: %f",result);
if (length)
*length = 8;
if (*status)
*status = res;
return result;
ERROR:
psiconv_error(config,lev+1,off,"Reading of float failed");
if (length)
*length = 0;
if (*status)
*status = res;
return 0.0;
}
psiconv-0.9.8/lib/psiconv/parse_texted.c 0000644 0001750 0001750 00000011347 10336374701 015226 0000000 0000000 /*
parse_texted.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "parse_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
int psiconv_parse_texted_section(const psiconv_config config,
const psiconv_buffer buf,int lev,
psiconv_u32 off, int *length,
psiconv_texted_section *result,
psiconv_character_layout base_char,
psiconv_paragraph_layout base_para)
{
int res = 0;
int len = 0;
psiconv_u32 layout_sec = 0;
psiconv_u32 unknown_sec = 0;
psiconv_u32 replacement_sec = 0;
psiconv_u32 temp;
int leng;
psiconv_progress(config,lev+1,off,"Going to read a texted section");
if (!((*result) = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read section id");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != PSICONV_ID_TEXTED_BODY) {
psiconv_error(config,lev+2,off+len,
"Page header section body id not found");
psiconv_debug(config,lev+2,off+len,
"Page body id: read %08x, expected %08x",temp,
PSICONV_ID_TEXTED);
res = -PSICONV_E_PARSE;
goto ERROR2;
}
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the section jumptable");
while (temp = psiconv_read_u32(config,buf,lev+3,off+len,&res),
!res && temp != PSICONV_ID_TEXTED_TEXT) {
len += 4;
if (temp == PSICONV_ID_TEXTED_LAYOUT) {
layout_sec = psiconv_read_u32(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+3,off+len,"Found Layout section at %08x",layout_sec);
} else if (temp == PSICONV_ID_TEXTED_REPLACEMENT) {
replacement_sec = psiconv_read_u32(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+3,off+len,"Found Replacement section at %08x",
replacement_sec);
} else if (temp == PSICONV_ID_TEXTED_UNKNOWN) {
unknown_sec= psiconv_read_u32(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR2;
if (unknown_sec) {
psiconv_warn(config,lev+3,off+len,
"Unknown section in TextEd jumptable has real offset (ignoring)");
}
psiconv_debug(config,lev+3,off+len,"Found Unknown section at %08x",
unknown_sec);
} else {
psiconv_warn(config,lev+3,off+len,
"Unknown section in TextEd jumptable (ignoring)");
psiconv_debug(config,lev+3,off+len,"Section ID %08x at offset %08x",temp,
psiconv_read_u32(config,buf,lev+3,off+len,NULL));
}
len += 4;
}
if (res)
goto ERROR2;
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the text");
if ((res = psiconv_parse_text_section(config,buf,lev+2,off+len,&leng,
&(*result)->paragraphs)))
goto ERROR2;
len += leng;
if (layout_sec) {
psiconv_progress(config,lev+2,off+len,"Going to read the layout");
if ((res = psiconv_parse_styleless_layout_section(config,buf,lev+2,layout_sec,NULL,
(*result)->paragraphs,
base_char,base_para)))
goto ERROR3;
}
#if 0
if (replacement_sec) {
psiconv_progress(config,lev+2,off+len,"Going to read the replacements");
/* WHATEVER */
}
#endif
if (length)
*length = len;
psiconv_progress(config,lev+1,off+len-1,"End of TextEd section "
"(total length: %08x", len);
return 0;
ERROR3:
psiconv_free_text_and_layout((*result)->paragraphs);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of TextEd Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/parse_word.c 0000644 0001750 0001750 00000033415 10336374703 014706 0000000 0000000 /*
parse_word.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "parse_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
int psiconv_parse_word_status_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_word_status_section *result)
{
int res=0;
int len=0;
psiconv_u32 temp;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the word status section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Word status section initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the first byte of display flags");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->show_tabs = temp&0x01 ? psiconv_bool_true : psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show tabs: %02x",(*result)->show_tabs);
(*result)->show_spaces = temp&0x02 ? psiconv_bool_true : psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show spaces: %02x",(*result)->show_spaces);
(*result)->show_paragraph_ends = temp &0x04 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show paragraph ends: %02x",
(*result)->show_paragraph_ends);
(*result)->show_line_breaks = temp & 0x08 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show line breaks: %02x",
(*result)->show_line_breaks);
(*result)->show_hard_minus = temp & 0x20 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show hard minus: %02x",
(*result)->show_hard_minus);
(*result)->show_hard_space = temp & 0x40 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show hard space: %02x",
(*result)->show_hard_space);
if (temp & 0x90) {
psiconv_warn(config,lev+2,off+len,"Word status section first byte of display "
"flags contains unknown flags (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp & 0x90);
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read second byte of display flags");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->show_full_pictures = temp & 0x01 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show full pictures: %02x",
(*result)->show_full_pictures);
(*result)->show_full_graphs = temp & 0x02 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show full graphs: %02x",
(*result)->show_full_graphs);
if (temp & 0xfc) {
psiconv_warn(config,lev+2,off+len,"Word status section second byte of display "
"flags contains unknown flags (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp & 0xfc);
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read top toolbar setting");
if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,
&(*result)->show_top_toolbar)))
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read side toolbar setting");
if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,
&(*result)->show_side_toolbar)))
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read operational flags");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->fit_lines_to_screen = temp & 0x08 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Fit lines to screen: %02x",
(*result)->fit_lines_to_screen);
if (temp & 0xf7) {
psiconv_warn(config,lev+2,off+len,"Word status section operational flags "
"contains unknown flags (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp & 0xfc);
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read cursor position");
(*result)->cursor_position = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Cursor position: %08x",
(*result)->cursor_position);
len += 0x04;
psiconv_progress(config,lev+2,off+len,"Going to read display size");
(*result)->display_size = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Display size: %08x",
(*result)->display_size);
len += 0x04;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of word status section (total length: %08x)", len);
return 0;
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Word Status Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_word_styles_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_word_styles_section *result)
{
int res=0;
int len=0;
int leng,i,nr,j;
psiconv_word_style style;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off,"Going to read the word styles section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read style normal");
if (!(style = malloc(sizeof(*style))))
goto ERROR2;
style->name = NULL;
if (!(style->paragraph = psiconv_basic_paragraph_layout()))
goto ERROR2_1;
psiconv_progress(config,lev+3,off+len,"Going to read the paragraph codes");
if ((res = psiconv_parse_paragraph_layout_list(config,buf,lev+3,off+len,&leng,
style->paragraph)))
goto ERROR2_2;
len += leng;
psiconv_progress(config,lev+3,off+len,"Going to read the character codes");
if (!(style->character = psiconv_basic_character_layout()))
goto ERROR2_2;
if ((res = psiconv_parse_character_layout_list(config,buf,lev+3,off+len,&leng,
style->character)))
goto ERROR2_3;
len += leng;
/* Ugly: I really don't know whether this is right for UTF8 */
psiconv_progress(config,lev+3,off+len,"Going to read the hotkey");
style->hotkey = psiconv_unicode_read_char(config,buf,lev+3,off+len,NULL,&res);
psiconv_debug(config,lev+3,off+len,"Normal Hotkey value %08x",style->hotkey);
if (res)
goto ERROR2_3;
len += 0x04;
(*result)->normal = style;
psiconv_progress(config,lev+2,off+len,"Going to read hotkeys list");
if (!((*result)->styles = psiconv_list_new(sizeof(*style))))
goto ERROR3;
if (!(style = malloc(sizeof(*style)))) {
goto ERROR3_1;
}
psiconv_progress(config,lev+3,off+len,"Going to read the number of entries");
nr = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR3_2;
len ++;
psiconv_debug(config,lev+3,off+len,"Nummer of hotkeys: %02x",nr);
for (i = 0; i < nr; i ++) {
/* Ugly: I really don't know whether this is right for UTF8 */
style->hotkey = psiconv_unicode_read_char(config,buf,lev+3,off+len,
NULL,&res);
psiconv_debug(config,lev+3,off+len,"Hotkey %d value %08x",i,style->hotkey);
len += 0x04;
if ((res = psiconv_list_add((*result)->styles,style)))
goto ERROR3_2;
}
free(style);
psiconv_progress(config,lev+2,off+len,"Going to read all other styles");
psiconv_progress(config,lev+2,off+len,"Going to read the number of styles");
nr = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR4;
if (nr != psiconv_list_length((*result)->styles)) {
psiconv_warn(config,lev+3,off+len,"Number of styles and hotkeys do not match");
psiconv_debug(config,lev+3,off+len,"%d hotkeys, %d styles",
psiconv_list_length((*result)->styles), nr);
}
len ++;
for (i = 0; i < nr; i++) {
psiconv_progress(config,lev+2,off+len,"Next style: %d",i);
if (i >= psiconv_list_length((*result)->styles)) {
if (!(style = malloc(sizeof(*style))))
goto ERROR5;
style->hotkey = 0;
if (psiconv_list_add((*result)->styles,style)) {
free(style);
goto ERROR5;
}
psiconv_debug(config,lev+3,off+len,"New entry added in list");
free(style);
}
if (!(style = psiconv_list_get((*result)->styles,i)))
goto ERROR5;
psiconv_progress(config,lev+3,off+len,"Going to read the style name");
style->name = psiconv_read_string(config,buf,lev+3,off+len,&leng,&res);
if (res)
goto ERROR5;
len += leng;
psiconv_progress(config,lev+3,off+len,
"Going to read whether this style is built-in");
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR6;
if (temp == PSICONV_ID_STYLE_BUILT_IN) {
style->built_in = psiconv_bool_true;
psiconv_debug(config,lev+3,off+len,"Built-in style");
} else if (temp == PSICONV_ID_STYLE_REMOVABLE) {
style->built_in = psiconv_bool_false;
psiconv_debug(config,lev+3,off+len,"Removable style");
} else {
psiconv_warn(config,lev+3,off+len,
"Word styles section unknown style id (treated as built-in)");
psiconv_debug(config,lev+3,off+len,"Unknown id: %08x",temp);
style->built_in = psiconv_bool_false;
}
len += 4;
psiconv_progress(config,lev+3,off+len,"Going to read outline level");
style->outline_level = psiconv_read_u32(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR6;
psiconv_debug(config,lev+3,off+len,"Outline Level: %08x", style->outline_level);
len += 4;
psiconv_progress(config,lev+3,off+len,"Going to read the character codes");
if (!(style->character = psiconv_clone_character_layout((*result)->normal->character)))
goto ERROR6;
if ((res = psiconv_parse_character_layout_list(config,buf,lev+3,off+len,&leng,
style->character)))
goto ERROR7;
len += leng;
psiconv_progress(config,lev+3,off+len,"Going to read the paragraph codes");
if (!(style->paragraph = psiconv_clone_paragraph_layout((*result)->normal->paragraph)))
goto ERROR7;
if ((res = psiconv_parse_paragraph_layout_list(config,buf,lev+3,off+len,&leng,
style->paragraph)))
goto ERROR8;
len += leng;
}
psiconv_progress(config,lev+2,off+len,"Reading trailing bytes");
for (i = 0; i < psiconv_list_length((*result)->styles); i++) {
temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR4;
if (temp != 0xff) {
psiconv_warn(config,lev+3,off+len,"Unknown trailing style byte");
psiconv_debug(config,lev+3,off+len,"Trailing byte: %02x expected, read %02x",
0xff,temp);
} else
psiconv_debug(config,lev+3,off+len,"Read trailing byte 0xff");
len++;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of word styles section (total length: %08x)", len);
return res;
ERROR3_2:
free(style);
ERROR3_1:
psiconv_list_free((*result)->styles);
goto ERROR3;
ERROR2_3:
psiconv_free_character_layout(style->character);
ERROR2_2:
psiconv_free_paragraph_layout(style->paragraph);
ERROR2_1:
free (style);
goto ERROR2;
ERROR8:
psiconv_free_paragraph_layout(style->paragraph);
ERROR7:
psiconv_free_character_layout(style->character);
ERROR6:
free(style->name);
ERROR5:
for (j = 0; j < i ;j++) {
if (!(style = psiconv_list_get((*result)->styles,j))) {
psiconv_error(config,lev+1,off,"Data structure corruption");
goto ERROR4;
}
psiconv_free_character_layout(style->character);
psiconv_free_paragraph_layout(style->paragraph);
free(style->name);
}
ERROR4:
psiconv_list_free((*result)->styles);
ERROR3:
psiconv_free_word_style((*result)->normal);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Word Status Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/parse_sheet.c 0000644 0001750 0001750 00000214727 10336374736 015060 0000000 0000000 /*
parse_sheet.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "parse_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
static psiconv_sheet_cell_layout psiconv_basic_cell_layout(void)
{
psiconv_sheet_cell_layout result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->character = psiconv_basic_character_layout()))
goto ERROR2;
if (!(result->paragraph = psiconv_basic_paragraph_layout()))
goto ERROR3;
if (!(result->numberformat = malloc(sizeof(*result->numberformat))))
goto ERROR4;
result->numberformat->code = psiconv_numberformat_general;
result->numberformat->decimal = 2;
return result;
ERROR4:
psiconv_free_paragraph_layout(result->paragraph);
ERROR3:
psiconv_free_character_layout(result->character);
ERROR2:
free(result);
ERROR1:
return NULL;
}
static psiconv_sheet_cell_layout psiconv_clone_cell_layout
(psiconv_sheet_cell_layout original)
{
psiconv_sheet_cell_layout result;
if (!(result = malloc(sizeof(*result))))
goto ERROR1;
if (!(result->character =
psiconv_clone_character_layout(original->character)))
goto ERROR2;
if (!(result->paragraph =
psiconv_clone_paragraph_layout(original->paragraph)))
goto ERROR3;
if (!(result->numberformat = malloc(sizeof(*result->numberformat))))
goto ERROR4;
result->numberformat->code = original->numberformat->code;
result->numberformat->decimal = original->numberformat->decimal;
return result;
ERROR4:
psiconv_free_paragraph_layout(result->paragraph);
ERROR3:
psiconv_free_character_layout(result->character);
ERROR2:
free(result);
ERROR1:
return NULL;
}
static psiconv_sheet_cell_reference_t
psiconv_read_var_cellref (const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
int *status)
{
int len=0;
int res;
psiconv_sheet_cell_reference_t result;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off+len,"Going to read a sheet cell reference");
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x00);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp != 0x00) {
psiconv_warn(config,lev+2,off+len,
"Sheet cell reference initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp & 0xffff0000) {
psiconv_warn(config,lev+2,off+len,
"Sheet cell row reference to unknown row (reset)");
}
result.row.offset = temp;
result.row.absolute = psiconv_bool_true;
len += 4;
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp & 0xffff0000) {
psiconv_warn(config,lev+2,off+len,
"Sheet cell column reference to unknown row (reset)");
}
result.column.offset = temp;
result.column.absolute = psiconv_bool_true;
len += 4;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet column reference (total length: %08x)", len);
return result;
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Column Reference failed");
if (length)
*length = 0;
if (status)
*status = res?res:-PSICONV_E_NOMEM;
return result;
}
static psiconv_sheet_cell_block_t
psiconv_read_var_cellblock (const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
int *status)
{
int len=0;
int res;
psiconv_sheet_cell_block_t result;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off+len,"Going to read a sheet cell block reference");
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x00);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp != 0x00) {
psiconv_warn(config,lev+2,off+len,
"Sheet cell reference initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp & 0xffff0000) {
psiconv_warn(config,lev+2,off+len,
"Sheet block initial row reference to unknown row (reset)");
}
result.first.row.offset = temp;
result.first.row.absolute = psiconv_bool_true;
len += 4;
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp & 0xffff0000) {
psiconv_warn(config,lev+2,off+len,
"Sheet block initial column reference to unknown row (reset)");
}
result.first.column.offset = temp;
result.first.column.absolute = psiconv_bool_true;
len += 4;
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp & 0xffff0000) {
psiconv_warn(config,lev+2,off+len,
"Sheet block final row reference to unknown row (reset)");
}
result.last.row.offset = temp;
result.last.row.absolute = psiconv_bool_true;
len += 4;
temp = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp & 0xffff0000) {
psiconv_warn(config,lev+2,off+len,
"Sheet block final column reference to unknown row (reset)");
}
result.last.column.offset = temp;
result.last.column.absolute = psiconv_bool_true;
len += 4;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet cell block reference (total length: %08x)",
len);
return result;
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Cell Block Reference failed");
if (length)
*length = 0;
if (status)
*status = res?res:-PSICONV_E_NOMEM;
return result;
}
int psiconv_parse_sheet_numberformat(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_numberformat result)
{
int res=0;
int len=0;
psiconv_u8 temp;
psiconv_progress(config,lev+1,off,"Going to read a sheet numberformat");
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet numberformat initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len, "Going to read the code byte");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
psiconv_debug(config,lev+2,off+len,"Code: %02x",temp);
if (temp == 0x00)
result->code = psiconv_numberformat_general;
else if (temp == 0x02)
result->code = psiconv_numberformat_fixeddecimal;
else if (temp == 0x04)
result->code = psiconv_numberformat_scientific;
else if (temp == 0x06)
result->code = psiconv_numberformat_currency;
else if (temp == 0x08)
result->code = psiconv_numberformat_percent;
else if (temp == 0x0A)
result->code = psiconv_numberformat_triads;
else if (temp == 0x0C)
result->code = psiconv_numberformat_boolean;
else if (temp == 0x0E)
result->code = psiconv_numberformat_text;
else if (temp == 0x10)
result->code = psiconv_numberformat_date_dmm;
else if (temp == 0x12)
result->code = psiconv_numberformat_date_mmd;
else if (temp == 0x14)
result->code = psiconv_numberformat_date_ddmmyy;
else if (temp == 0x16)
result->code = psiconv_numberformat_date_mmddyy;
else if (temp == 0x18)
result->code = psiconv_numberformat_date_yymmdd;
else if (temp == 0x1A)
result->code = psiconv_numberformat_date_dmmm;
else if (temp == 0x1C)
result->code = psiconv_numberformat_date_dmmmyy;
else if (temp == 0x1E)
result->code = psiconv_numberformat_date_ddmmmyy;
else if (temp == 0x20)
result->code = psiconv_numberformat_date_mmm;
else if (temp == 0x22)
result->code = psiconv_numberformat_date_monthname;
else if (temp == 0x24)
result->code = psiconv_numberformat_date_mmmyy;
else if (temp == 0x26)
result->code = psiconv_numberformat_date_monthnameyy;
else if (temp == 0x28)
result->code = psiconv_numberformat_date_monthnamedyyyy;
else if (temp == 0x2A)
result->code = psiconv_numberformat_datetime_ddmmyyyyhhii;
else if (temp == 0x2C)
result->code = psiconv_numberformat_datetime_ddmmyyyyHHii;
else if (temp == 0x2E)
result->code = psiconv_numberformat_datetime_mmddyyyyhhii;
else if (temp == 0x30)
result->code = psiconv_numberformat_datetime_mmddyyyyHHii;
else if (temp == 0x32)
result->code = psiconv_numberformat_datetime_yyyymmddhhii;
else if (temp == 0x34)
result->code = psiconv_numberformat_datetime_yyyymmddHHii;
else if (temp == 0x36)
result->code = psiconv_numberformat_time_hhii;
else if (temp == 0x38)
result->code = psiconv_numberformat_time_hhiiss;
else if (temp == 0x3A)
result->code = psiconv_numberformat_time_HHii;
else if (temp == 0x3C)
result->code = psiconv_numberformat_time_HHiiss;
else {
psiconv_warn(config,lev+2,off+len,"Unknown number format (assumed general)");
result->code = psiconv_numberformat_general;
}
len ++;
psiconv_progress(config,lev+2,off+len, "Going to read the number of decimals");
result->decimal = psiconv_read_u8(config,buf,lev+2,off+len,&res) >> 1;
if (res)
goto ERROR1;
psiconv_debug(config,lev+2,off+len,"Decimals: %d",result->decimal);
len ++;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet number format (total length: %08x)", len);
return 0;
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Number Format failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_status_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_status_section *result)
{
int res=0;
int len=0;
psiconv_u32 temp;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the sheet status section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet status section initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the cursor row");
(*result)->cursor_row = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Cursor row: %08x",
(*result)->cursor_row);
len += 0x04;
psiconv_progress(config,lev+2,off+len,
"Going to read the cursor column");
(*result)->cursor_column = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Cursor column: %08x",
(*result)->cursor_column);
len += 0x04;
psiconv_progress(config,lev+2,off+len,"Going to read initially display graph");
if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,
&(*result)->show_graph)))
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,
"Going to read the toolbar status byte");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->show_side_sheet_toolbar = temp&0x01 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show side sheet toolbar: %02x",
(*result)->show_side_sheet_toolbar);
(*result)->show_top_sheet_toolbar = temp&0x02 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show top sheet toolbar: %02x",
(*result)->show_top_sheet_toolbar);
(*result)->show_side_graph_toolbar = temp&0x04 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show side graph toolbar: %02x",
(*result)->show_side_graph_toolbar);
(*result)->show_top_graph_toolbar = temp&0x08 ? psiconv_bool_true :
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Show top graph toolbar: %02x",
(*result)->show_top_graph_toolbar);
if (temp & 0xf0) {
psiconv_warn(config,lev+2,off+len,"Sheet status section toolbar byte "
"flags contains unknown flags (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp & 0xf0);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the scrollbar status byte");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if ((temp & 0x03) == 0x03) {
psiconv_warn(config,lev+2,off+len,"Sheet status section scrollbar byte "
"flags contains unknown flags (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown flag: %02x",temp & 0x03);
}
(*result)->show_horizontal_scrollbar = (temp&0x03) == 1? psiconv_triple_off :
(temp&0x03) == 2? psiconv_triple_auto:
psiconv_triple_on;
psiconv_debug(config,lev+2,off+len,"Show horizontal scrollbar: %02x",
(*result)->show_horizontal_scrollbar);
if ((temp & 0x0c) == 0x0c) {
psiconv_warn(config,lev+2,off+len,"Sheet status section scrollbar byte "
"flags contains unknown flags (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown flag: %02x",temp & 0x0c);
}
(*result)->show_vertical_scrollbar = (temp&0x0c) ==0x04? psiconv_triple_off:
(temp&0x0c) ==0x08? psiconv_triple_auto:
psiconv_triple_on;
psiconv_debug(config,lev+2,off+len,"Show vertical scrollbar: %02x",
(*result)->show_vertical_scrollbar);
if (temp & 0xf0) {
psiconv_warn(config,lev+2,off+len,"Sheet status section scrollbar byte "
"flags contains unknown flags (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp & 0xf0);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read an unknown byte (%02x expected)",0x00);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x00) {
psiconv_warn(config,lev+2,off+len,
"Sheet status section unknown byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read sheet display size");
(*result)->sheet_display_size = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Sheet display size: %08x",
(*result)->sheet_display_size);
len += 0x04;
psiconv_progress(config,lev+2,off+len,"Going to read graph display size");
(*result)->graph_display_size = psiconv_read_u32(config,buf,lev+2,off + len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Graph display size: %08x",
(*result)->graph_display_size);
len += 0x04;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet status section (total length: %08x)", len);
return 0;
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Status Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_workbook_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_workbook_section *result)
{
int res=0,with_name;
psiconv_u32 temp,formulas_off,worksheets_off,info_off,var_off,name_off=0;
int len=0;
psiconv_progress(config,lev+1,off,"Going to read the sheet workbook section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x or %02x expected)",
0x02,0x04);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if ((temp != 0x04) && temp !=0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet workbook section initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
with_name = temp ==0x04;
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the sheet info Section");
info_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",info_off);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the Formulas List");
formulas_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",formulas_off);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the Worksheet List");
worksheets_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",worksheets_off);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the Variable List");
var_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",var_off);
len += 4;
if (with_name) {
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the Name Section");
name_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",name_off);
len += 4;
}
psiconv_progress(config,lev+2,off+len,"Going to read the info section");
if ((res = psiconv_parse_sheet_info_section(config,buf,lev+2,info_off,NULL,
&(*result)->info)))
goto ERROR2;
psiconv_progress(config,lev+2,off+len,"Going to read the variables list");
if ((res = psiconv_parse_sheet_variable_list(config,buf,lev+2,var_off,NULL,
&(*result)->variables)))
goto ERROR3;
psiconv_progress(config,lev+2,off+len,"Going to read the formulas list");
if ((res = psiconv_parse_sheet_formula_list(config,buf,lev+2,formulas_off,NULL,
&(*result)->formulas)))
goto ERROR4;
psiconv_progress(config,lev+2,off+len,"Going to read the worksheet list");
if ((res = psiconv_parse_sheet_worksheet_list(config,buf,lev+2,worksheets_off,
NULL,&(*result)->worksheets)))
goto ERROR5;
if (with_name) {
psiconv_progress(config,lev+2,off+len,"Going to read the name section");
if ((res = psiconv_parse_sheet_name_section(config,buf,lev+2,name_off,NULL,
&(*result)->name)))
goto ERROR6;
} else
(*result)->name = NULL;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet workbook section (total length: %08x)", len);
return 0;
ERROR6:
psiconv_free_sheet_worksheet_list((*result)->worksheets);
ERROR5:
psiconv_free_formula_list((*result)->formulas);
ERROR4:
psiconv_free_sheet_variable_list((*result)->variables);
ERROR3:
psiconv_free_sheet_info_section((*result)->info);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Workbook Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_name_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_name_section *result)
{
int res=0;
psiconv_u32 temp;
int len=0,leng;
psiconv_progress(config,lev+1,off,"Going to read the sheet name section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet name section initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len, "Going to read the sheet name");
(*result)->name = psiconv_read_string(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
len += leng;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet name section (total length: %08x)", len);
return 0;
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Name Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_info_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_info_section *result)
{
int res=0;
psiconv_u32 temp;
int len=0,leng;
psiconv_progress(config,lev+1,off,"Going to read the sheet info section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet info section initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len, "Going to read an unknown Xint");
temp = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Value: %d\n",temp);
len += leng;
psiconv_progress(config,lev+2,off+len, "Going to read the flags byte");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->auto_recalc = temp & 0x01 ? psiconv_bool_true:psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,"Auto recalculation: %02x",
(*result)->auto_recalc);
if ((temp & 0xfe) != 0x02) {
psiconv_warn(config,lev+2,off+len,"Sheet Info Section flags byte "
"contains unknown flags (ignored)");
psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp &0xfe);
}
len ++;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet info section (total length: %08x)", len);
return 0;
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Name Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_formula_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_formula_list *result)
{
int res=0;
int len=0;
psiconv_u32 temp;
psiconv_formula formula;
psiconv_u32 listlen,i;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the sheet formula list");
if (!(*result = psiconv_list_new(sizeof(struct psiconv_formula_s))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet formula list initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the number of formulas");
listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Number of formulas: %d",listlen);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read all formulas");
for (i = 0; i < listlen; i++) {
psiconv_progress(config,lev+3,off+len,"Going to read formula %d",i);
if ((res = psiconv_parse_formula(config,buf,lev+3,off+len,&leng,&formula)))
goto ERROR2;
if ((res = psiconv_list_add(*result,formula)))
goto ERROR3;
free(formula);
len += leng;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet formula list (total length: %08x)", len);
return 0;
ERROR3:
psiconv_free_formula(formula);
ERROR2:
psiconv_list_free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Formula list failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_cell(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_cell *result,
const psiconv_sheet_cell_layout default_layout,
const psiconv_sheet_line_list row_default_layouts,
const psiconv_sheet_line_list col_default_layouts)
{
int res=0;
int len=0;
psiconv_u32 temp;
psiconv_bool_t has_layout;
int leng;
char *auxstr;
psiconv_progress(config,lev+1,off,"Going to read a sheet cell structure");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
(*result)->layout = NULL;
(*result)->type = psiconv_cell_blank;
psiconv_progress(config,lev+2,off+len,"Going to read the cell position");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
len ++;
temp += psiconv_read_u8(config,buf,lev+2,off+len,&res) << 8;
if (res)
goto ERROR2;
len ++;
temp += psiconv_read_u8(config,buf,lev+2,off+len,&res) << 16;
if (res)
goto ERROR2;
len ++;
(*result)->column = (temp >> 2) & 0xFF;
(*result)->row = (temp >> 10) & 0x3FFF;
psiconv_debug(config,lev+2,off+len,"Cell position is col:%02x row:%04x",
(*result)->column,(*result)->row);
if (temp & 0x03) {
psiconv_warn(config,lev+2,off+len,"Unknown flags in cell position (ignored)");
psiconv_debug(config,lev+2,off+len,"Flags: %02x",temp & 0x03);
}
psiconv_progress(config,lev+2,off+len,"Going to read the cell type");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
len ++;
(*result)->type = (temp >> 5) & 0x07;
(*result)->calculated = (temp & 0x08)?psiconv_bool_true:psiconv_bool_false;
has_layout = (temp & 0x10)?psiconv_bool_true:psiconv_bool_false;
psiconv_progress(config,lev+2,off+len,"Going to read the cell value");
if ((*result)->type == psiconv_cell_blank) {
psiconv_debug(config,lev+2,off+len,"Cell type is blank: no value given.");
} else if ((*result)->type == psiconv_cell_int) {
psiconv_progress(config,lev+2,off+len,"Going to read an integer");
(*result)->data.dat_int = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
len += 4;
psiconv_debug(config,lev+2,off+len,"Cell contents: %ld",(*result)->data.dat_int);
} else if ((*result)->type == psiconv_cell_bool) {
psiconv_progress(config,lev+2,off+len,"Going to read a boolean");
if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,
&(*result)->data.dat_bool)))
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Cell contents: %01x",temp);
(*result)->data.dat_bool = temp?psiconv_bool_true:psiconv_bool_false;
len += leng;
} else if ((*result)->type == psiconv_cell_error) {
psiconv_progress(config,lev+2,off+len,"Going to read the error code");
temp = psiconv_read_u16(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp == 0)
(*result)->data.dat_error = psiconv_sheet_error_none;
else if (temp == 1)
(*result)->data.dat_error = psiconv_sheet_error_null;
else if (temp == 2)
(*result)->data.dat_error = psiconv_sheet_error_divzero;
else if (temp == 3)
(*result)->data.dat_error = psiconv_sheet_error_value;
else if (temp == 4)
(*result)->data.dat_error = psiconv_sheet_error_reference;
else if (temp == 5)
(*result)->data.dat_error = psiconv_sheet_error_name;
else if (temp == 6)
(*result)->data.dat_error = psiconv_sheet_error_number;
else if (temp == 7)
(*result)->data.dat_error = psiconv_sheet_error_notavail;
else {
psiconv_warn(config,lev+2,off+len,"Unknown error code (default assumed)");
psiconv_debug(config,lev+2,off+len,"Error code: %04x",temp);
(*result)->data.dat_error = psiconv_sheet_error_none;
}
psiconv_debug(config,lev+2,off+len,"Cell contents: %04x",
(*result)->data.dat_error);
len += 2;
} else if ((*result)->type == psiconv_cell_float) {
psiconv_progress(config,lev+2,off+len,"Going to read a float");
(*result)->data.dat_float =
psiconv_read_float(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Cell contents: %f",(*result)->data.dat_float);
len += leng;
} else if ((*result)->type == psiconv_cell_string) {
psiconv_progress(config,lev+2,off+len,"Going to read a string");
(*result)->data.dat_string =
psiconv_read_string(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
if (!(auxstr = psiconv_make_printable(config,(*result)->data.dat_string)))
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Cell contents: `%s'",auxstr);
free(auxstr);
len += leng;
} else {
psiconv_error(config,lev+2,off+len,"Unknown Sheet Cell type: %02x",(*result)->type);
res = PSICONV_E_PARSE;
goto ERROR2;
}
if (!((*result)->layout = psiconv_clone_cell_layout(
psiconv_get_default_layout(row_default_layouts,
col_default_layouts,
default_layout,
(*result)->row,
(*result)->column))))
goto ERROR2;
if (has_layout) {
if ((res = psiconv_parse_sheet_cell_layout(config,buf,lev+2,off+len,
&leng,(*result)->layout)))
goto ERROR2;
len += leng;
}
if ((*result)->calculated) {
psiconv_progress(config,lev+2,off+len,"Going to read the cell formula reference");
temp = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Cell formula reference: %d",temp);
len += leng;
(*result)->ref_formula = temp;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet cell structure (total length: %08x)", len);
return 0;
ERROR2:
psiconv_free_sheet_cell(*result);
ERROR1:
psiconv_warn(config,lev+1,off,"Reading of Sheet Cell Structure failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_cell_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_cell_list *result,
const psiconv_sheet_cell_layout default_layout,
const psiconv_sheet_line_list row_default_layouts,
const psiconv_sheet_line_list col_default_layouts)
{
int res=0;
int len=0;
psiconv_u32 temp;
psiconv_sheet_cell cell;
psiconv_u32 listlen,i;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the sheet cell list");
if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_cell_s))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet cell list initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x00);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x00) {
psiconv_warn(config,lev+2,off+len,
"Sheet cell list initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the number of defined cells");
listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Number of defined cells: %d",listlen);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read all cells");
for (i = 0; i < listlen; i++) {
psiconv_progress(config,lev+3,off+len,"Going to read cell %d",i);
if ((res = psiconv_parse_sheet_cell(config,buf,lev+3,off+len,&leng,&cell,
default_layout,row_default_layouts,
col_default_layouts)))
goto ERROR2;
if ((res = psiconv_list_add(*result,cell)))
goto ERROR3;
free(cell);
len += leng;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet cell list (total length: %08x)", len);
return 0;
ERROR3:
psiconv_free_sheet_cell(cell);
ERROR2:
psiconv_free_sheet_cell_list(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Cells List failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_worksheet_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_worksheet_list *result)
{
psiconv_sheet_worksheet worksheet;
int res=0;
int len=0;
psiconv_u8 temp;
psiconv_u32 offset;
int leng,i,nr;
psiconv_progress(config,lev+1,off,"Going to read the worksheet list");
if (!(*result = psiconv_list_new(sizeof(*worksheet))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial bytes (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet worksheet list initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read the list length");
nr = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Length: %02x",nr);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the list");
for (i=0 ; i < nr; i++) {
psiconv_progress(config,lev+3,off+len,"Going to read element %d",i);
psiconv_progress(config,lev+4,off+len,
"Going to read the initial byte (%02x expected)",0x00);
temp = psiconv_read_u8(config,buf,lev+4,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x00) {
psiconv_warn(config,lev+4,off+len,
"Sheet worksheet element initial byte unknown value (ignored)");
psiconv_debug(config,lev+4,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+4,off+len,"Going to read the worksheet offset");
offset = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+4,off+len,"Offset: %08x",offset);
len += 4;
if ((res = psiconv_parse_sheet_worksheet(config,buf,lev+4,offset,NULL,
&worksheet)))
goto ERROR2;
if ((res = psiconv_list_add(*result,worksheet)))
goto ERROR3;
free(worksheet);
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of worksheet list (total length: %08x)", len);
return 0;
ERROR3:
psiconv_free_sheet_worksheet(worksheet);
ERROR2:
psiconv_free_sheet_worksheet_list(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of worksheet list failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_cell_layout(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_cell_layout result)
{
int res=0;
int len=0;
int leng;
psiconv_u8 temp;
psiconv_progress(config,lev+1,off,"Going to read a sheet cell layout");
psiconv_progress(config,lev+2,off+len,
"Going to read the first byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Worksheet section initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read the default formats flag");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR1;
len ++;
if (temp & 0x01) {
psiconv_progress(config,lev+3,off+len,"Going to read the default paragraph codes");
if ((res = psiconv_parse_paragraph_layout_list(config,buf,lev+3,off+len,&leng,
result->paragraph)))
goto ERROR1;
len += leng;
}
if (temp & 0x02) {
psiconv_progress(config,lev+3,off+len,"Going to read the default character codes");
if ((res = psiconv_parse_character_layout_list(config,buf,lev+3,off+len,&leng,
result->character)))
goto ERROR1;
len += leng;
}
if (temp & 0x04) {
psiconv_progress(config,lev+3,off+len, "Going to read the default number format");
psiconv_parse_sheet_numberformat(config,buf,lev+3,off+len,&leng,
result->numberformat);
len += leng;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet cell layout (total length: %08x)", len);
return 0;
ERROR1:
psiconv_error(config,lev+1,off,"Reading of sheet cell layout failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_worksheet(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_worksheet *result)
{
int res=0;
psiconv_u32 temp,cells_off,grid_off,rows_off,cols_off,unknown_off;
int len=0;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the sheet worksheet section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial bytes (%02x expected)",0x04);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x04) {
psiconv_warn(config,lev+2,off+len,
"Worksheet section initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len, "Going to read the flags byte");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Flags byte: %02x",temp);
(*result)->show_zeros = (temp & 0x01)?psiconv_bool_true:psiconv_bool_false;
if (temp & 0xfe) {
psiconv_warn(config,lev+2,off+len,
"Worksheet section flags byte unknown bits (ignored)");
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read the default cell layout");
if (!((*result)->default_layout = psiconv_basic_cell_layout()))
goto ERROR2;
if ((res = psiconv_parse_sheet_cell_layout(config,buf,lev+2,off+len,&leng,
(*result)->default_layout)))
goto ERROR3;
len += leng;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the row defaults Section");
rows_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",rows_off);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the column defaults Section");
cols_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",cols_off);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the Cells List");
cells_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",cells_off);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the Grid Section");
grid_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",grid_off);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read the offset of the 3rd ??? Section");
unknown_off = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Offset: %04x",unknown_off);
len += 4;
psiconv_progress(config,lev+2,off+len,
"Going to read a long of the 3rd ??? Section "
"(%08x expected)",0x00);
temp = psiconv_read_u32(config,buf,lev+2,unknown_off,&res);
if (res)
goto ERROR3;
if (temp != 0x00) {
psiconv_warn(config,lev+2,unknown_off,
"Unknown worksheet subsection has unknown contents (ignored)");
psiconv_debug(config,lev+2,unknown_off,"Offset: %04x",temp);
}
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the row defaults");
if ((res = psiconv_parse_sheet_line_list(config,buf,lev+2,rows_off,NULL,
&(*result)->row_default_layouts,
(*result)->default_layout)))
goto ERROR3;
psiconv_progress(config,lev+2,off+len,"Going to read the column defaults");
if ((res = psiconv_parse_sheet_line_list(config,buf,lev+2,cols_off,NULL,
&(*result)->col_default_layouts,
(*result)->default_layout)))
goto ERROR4;
psiconv_progress(config,lev+2,off+len,"Going to read the cells list");
if ((res = psiconv_parse_sheet_cell_list(config,buf,lev+2,cells_off,NULL,
&(*result)->cells,
(*result)->default_layout,
(*result)->row_default_layouts,
(*result)->col_default_layouts)))
goto ERROR5;
psiconv_progress(config,lev+2,off+len,"Going to read the grid section");
if ((res = psiconv_parse_sheet_grid_section(config,buf,lev+2,grid_off,NULL,
&(*result)->grid)))
goto ERROR6;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet worksheet section (total length: %08x)", len);
return 0;
ERROR6:
psiconv_free_sheet_cell_list((*result)->cells);
ERROR5:
psiconv_free_sheet_line_list((*result)->col_default_layouts);
ERROR4:
psiconv_free_sheet_line_list((*result)->row_default_layouts);
ERROR3:
psiconv_free_sheet_cell_layout((*result)->default_layout);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Worksheet Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_line(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_line *result,
const psiconv_sheet_cell_layout default_layout)
{
int res=0;
int len=0;
int leng;
psiconv_progress(config,lev+1,off,"Going to read a sheet line");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,"Going to read the line number");
(*result)->position = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Line number: %d\n",(*result)->position);
len += leng;
if (!((*result)->layout = psiconv_clone_cell_layout(default_layout)))
goto ERROR2;
if ((res = psiconv_parse_sheet_cell_layout(config,buf,lev+2,off+len,
&leng,(*result)->layout)))
goto ERROR3;
len += leng;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of the sheet line (total length: %08x)", len);
return 0;
ERROR3:
psiconv_free_sheet_cell_layout((*result)->layout);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of the sheet line failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_line_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_line_list *result,
const psiconv_sheet_cell_layout default_layout)
{
int res=0;
int len=0;
psiconv_u32 temp;
psiconv_sheet_line line;
psiconv_u32 listlen,i;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the sheet line list");
if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_line_s))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet line list initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the number of defined lines");
listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Number of defined lines: %d",listlen);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read all lines");
for (i = 0; i < listlen; i++) {
psiconv_progress(config,lev+3,off+len,"Going to read line %d",i);
if ((res = psiconv_parse_sheet_line(config,buf,lev+3,off+len,&leng,&line,
default_layout)))
goto ERROR2;
if ((res = psiconv_list_add(*result,line)))
goto ERROR3;
free(line);
len += leng;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet line list (total length: %08x)", len);
return 0;
ERROR3:
psiconv_free_sheet_line(line);
ERROR2:
psiconv_free_sheet_line_list(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Line List failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_variable(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_variable *result)
{
int res=0;
int len=0;
psiconv_u32 marker;
int leng;
psiconv_progress(config,lev+1,off,"Going to read a sheet variable");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len, "Going to read the variable name");
(*result)->name = psiconv_read_string(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the type marker");
marker = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Marker: %02x",marker);
len ++;
if (marker == 0x00) {
(*result)->type = psiconv_var_int;
psiconv_progress(config,lev+2,off+len,"Going to read a signed integer");
(*result)->data.dat_int = psiconv_read_sint(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Value: %d",(*result)->data.dat_int);
len += leng;
} else if (marker == 0x01) {
(*result)->type = psiconv_var_float;
psiconv_progress(config,lev+2,off+len,"Going to read a floating point number");
(*result)->data.dat_float = psiconv_read_float(config,buf,lev+2,off+len,&leng,
&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Value: %f",(*result)->data.dat_float);
len += leng;
} else if (marker == 0x02) {
(*result)->type = psiconv_var_string;
psiconv_progress(config,lev+2,off+len,"Going to read a string");
(*result)->data.dat_string = psiconv_read_string(config,buf,lev+2,off+len,
&leng, &res);
if (res)
goto ERROR3;
len += leng;
} else if (marker == 0x03) {
(*result)->type = psiconv_var_cellref;
psiconv_progress(config,lev+2,off+len,"Going to read a cell reference");
(*result)->data.dat_cellref = psiconv_read_var_cellref(config,buf,lev+2,off+len,
&leng, &res);
if (res)
goto ERROR3;
len += leng;
} else if (marker == 0x04) {
(*result)->type = psiconv_var_cellblock;
psiconv_progress(config,lev+2,off+len,"Going to read a cell block reference");
(*result)->data.dat_cellblock = psiconv_read_var_cellblock(config,buf,lev+2,
off+len,
&leng, &res);
if (res)
goto ERROR3;
len += leng;
} else {
psiconv_error(config,lev+2,off+len,"Sheet variable unknown type marker");
res = -PSICONV_E_PARSE;
goto ERROR3;
}
psiconv_progress(config,lev+2,off+len,"Going to read the variable number");
(*result)->number = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR4;
psiconv_debug(config,lev+2,off+len,"Number: %08x",(*result)->number);
len += 4;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet variable (total length: %08x)", len);
return 0;
ERROR4:
if ((*result)->type == psiconv_var_string)
free((*result)->data.dat_string);
ERROR3:
free((*result)->name);
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Variable failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_variable_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_variable_list *result)
{
int res=0;
int len=0;
psiconv_u32 temp;
psiconv_sheet_variable variable;
psiconv_u32 listlen,i;
int leng;
psiconv_progress(config,lev+1,off,"Going to read the sheet variable list");
if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_variable_s))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the initial byte (%02x expected)",0x02);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x02) {
psiconv_warn(config,lev+2,off+len,
"Sheet variable list initial byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to read the number of variables");
listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Number of variables: %d",listlen);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read all variables");
for (i = 0; i < listlen; i++) {
psiconv_progress(config,lev+3,off+len,"Going to read variable %d",i);
if ((res = psiconv_parse_sheet_variable(config,buf,lev+3,off+len,&leng,&variable)))
goto ERROR2;
if ((res = psiconv_list_add(*result,variable)))
goto ERROR3;
len += leng;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet variabels list (total length: %08x)", len);
return 0;
ERROR3:
psiconv_free_sheet_variable(variable);
ERROR2:
psiconv_list_free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Variable list failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_grid_section(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_grid_section *result)
{
int res=0,i;
int len=0,leng;
psiconv_u32 temp;
psiconv_progress(config,lev+1,off,"Going to read the sheet grid section");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len, "Going to read the first flags byte");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->show_column_titles = temp&0x01?psiconv_bool_true:
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,
"Show column titles: %s",
(*result)->show_column_titles?"true":"false");
(*result)->show_row_titles = temp&0x02?psiconv_bool_true:psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,
"Show row titles: %s",
(*result)->show_row_titles?"true":"false");
(*result)->show_vertical_grid = temp&0x04?psiconv_bool_true:
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,
"Show vertical grid: %s",
(*result)->show_vertical_grid?"true":"false");
(*result)->show_horizontal_grid = temp&0x07?psiconv_bool_true:
psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,
"Show horizontal grid: %s",
(*result)->show_horizontal_grid?"true":"false");
(*result)->freeze_rows = temp&0x80?psiconv_bool_true:psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,
"Freeze rows: %s",
(*result)->freeze_rows?"true":"false");
if ((temp & 0x70) != 0x30) {
psiconv_warn(config,lev+2,off+len,
"Grid section first flag byte has unknown bits (ignored)");
psiconv_debug(config,lev+2,off+len,"Bits: %02x (%02x expected)",temp&0x70,0x30);
}
len ++;
psiconv_progress(config,lev+2,off+len, "Going to read the second flags byte");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->freeze_columns = temp&0x01?psiconv_bool_true:psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,
"Freeze columns: %s", (*result)->freeze_columns?"true":"false");
if ((temp & 0xfe) != 0x80) {
psiconv_warn(config,lev+2,off+len,
"Grid section second flag byte has unknown bits (ignored)");
psiconv_debug(config,lev+2,off+len,"Bits: %02x (%02x expected)",temp&0xfe,0x80);
}
len ++;
psiconv_progress(config,lev+2,off+len,
"Going to an unknown byte (%02x expected)",0x90);
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
if (temp != 0x90) {
psiconv_warn(config,lev+2,off+len,
"Grid section third byte unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Value: %02x",temp);
}
len ++;
psiconv_progress(config,lev+2,off+len, "Going to read the fourth flags byte");
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
(*result)->show_page_breaks = temp&0x04?psiconv_bool_true:psiconv_bool_false;
psiconv_debug(config,lev+2,off+len,
"Show page breaks: %s",
(*result)->show_page_breaks?"true":"false");
if ((temp & 0xfc) != 0x00) {
psiconv_warn(config,lev+2,off+len,
"Grid section fourth flag byte has unknown bits (ignored)");
psiconv_debug(config,lev+2,off+len,"Bits: %02x (%02x expected)",temp&0xfc,0x00);
}
len ++;
psiconv_progress(config,lev+2,off+len,"Going to read the first visible row");
(*result)->first_row = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"First row: %d",(*result)->first_row);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the first visible column");
(*result)->first_column = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"First column: %d",(*result)->first_column);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the last visible row");
(*result)->last_row = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Last row: %d",(*result)->last_row);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the last visible column");
(*result)->last_column = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Last column: %d",(*result)->last_column);
len += 4;
psiconv_progress(config,lev+2,off+len,"Going to read the default row height");
(*result)->default_row_height = psiconv_read_length(config,buf,lev+2,off+len,
&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Default row height: %f",
(*result)->default_row_height);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the row heights list");
if ((res = psiconv_parse_sheet_grid_size_list(config,buf,lev+2,off+len,&leng,
&(*result)->row_heights)))
goto ERROR2;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the default column height");
(*result)->default_column_width = psiconv_read_length(config,buf,lev+2,off+len,
&leng,&res);
if (res)
goto ERROR3;
psiconv_debug(config,lev+2,off+len,"Default column width: %f",
(*result)->default_column_width);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the column heights list");
if ((res = psiconv_parse_sheet_grid_size_list(config,buf,lev+2,off+len,&leng,
&(*result)->column_heights)))
goto ERROR3;
len += leng;
psiconv_progress(config,lev+2,off+len,
"Going to read an unknown word (%04x expected)",0x00);
temp = psiconv_read_u16(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR4;
if (temp != 0x00) {
psiconv_warn(config,lev+2,off+len,
"Grid section unknown word has unknown value (ignored)");
psiconv_debug(config,lev+2,off+len,"Value: %04x",temp);
}
len += 2;
psiconv_progress(config,lev+2,off+len,"Going to read the row breaks list");
if ((res = psiconv_parse_sheet_grid_break_list(config,buf,lev+2,off+len,&leng,
&(*result)->row_page_breaks)))
goto ERROR4;
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read the column breaks list");
if ((res = psiconv_parse_sheet_grid_break_list(config,buf,lev+2,off+len,&leng,
&(*result)->column_page_breaks)))
goto ERROR5;
len += leng;
psiconv_progress(config,lev+2,off+len,
"Going to read 22 unknown bytes (%02x expected)",0x00);
for (i = 0; i < 22 ; i++) {
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR6;
if (temp != 0x00) {
psiconv_warn(config,lev+2,off+len,
"Grid section unknown byte %d has unknown value (ignored)",
i);
psiconv_debug(config,lev+2,off+len,"Value: %02x",temp);
}
len += 1;
}
if ((*result)->freeze_rows || (*result)->freeze_columns) {
psiconv_progress(config,lev+2,off+len,"Going to read number of frozen rows");
(*result)->frozen_rows = psiconv_read_u32(config,buf,lev+2,off+len, &res);
if (res)
goto ERROR6;
psiconv_debug(config,lev+2,off+len,"Number of frozen rows: %d",
(*result)->frozen_rows);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read number of frozen columns");
(*result)->frozen_columns = psiconv_read_u32(config,buf,lev+2,off+len, &res);
if (res)
goto ERROR6;
psiconv_debug(config,lev+2,off+len,"Number of frozen columns: %d",
(*result)->frozen_columns);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read first unfrozen row");
(*result)->first_unfrozen_row_displayed = psiconv_read_u32(config,buf,lev+2,
off+len, &res);
if (res)
goto ERROR6;
psiconv_debug(config,lev+2,off+len,"First row: %d",
(*result)->first_unfrozen_row_displayed);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read first unfrozen column");
(*result)->first_unfrozen_column_displayed = psiconv_read_u32(config,buf,lev+2,
off+len,&res);
if (res)
goto ERROR6;
psiconv_debug(config,lev+2,off+len,"First column: %d",
(*result)->first_unfrozen_column_displayed);
len += leng;
} else
(*result)->frozen_rows = (*result)->frozen_columns =
(*result)->first_unfrozen_row_displayed =
(*result)->first_unfrozen_column_displayed = 0;
psiconv_progress(config,lev+2,off+len,
"Going to read 3 unknown bytes (%02x expected)",0xff);
for (i = 0; i < 3 ; i++) {
temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR6;
if (temp != 0xff) {
psiconv_warn(config,lev+2,off+len,
"Grid section unknown byte %d has unknown value (ignored)",
i);
psiconv_debug(config,lev+2,off+len,"Value: %02x",temp);
}
len ++;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet grid section (total length: %08x)", len);
return 0;
ERROR6:
psiconv_free_sheet_grid_break_list((*result)->column_page_breaks);
ERROR5:
psiconv_free_sheet_grid_break_list((*result)->row_page_breaks);
ERROR4:
psiconv_free_sheet_grid_size_list((*result)->column_heights);
ERROR3:
psiconv_free_sheet_grid_size_list((*result)->row_heights);
ERROR2:
free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Grid Section failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_grid_size_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_grid_size_list *result)
{
int res=0;
int len=0,i;
int leng,listlen;
psiconv_sheet_grid_size size;
psiconv_progress(config,lev+1,off,"Going to read a sheet grid size list");
if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_grid_size_s))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the number of elements");
listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Number of elements: %d",listlen);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read all elements");
for (i = 0; i < listlen; i++) {
psiconv_progress(config,lev+3,off+len,"Going to read element %d",i);
if ((res = psiconv_parse_sheet_grid_size(config,buf,lev+3,off+len,&leng,&size)))
goto ERROR2;
if ((res = psiconv_list_add(*result,size)))
goto ERROR3;
free(size);
len += leng;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet grid size list (total length: %08x)", len);
return 0;
ERROR3:
psiconv_free_sheet_grid_size(size);
ERROR2:
psiconv_list_free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Grid Size List failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_grid_size(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_grid_size *result)
{
int res=0;
int len=0;
int leng;
psiconv_progress(config,lev+1,off,"Going to read a sheet grid size");
if (!(*result = malloc(sizeof(**result))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len, "Going to read the row or column number");
(*result)->line_number = psiconv_read_u32(config,buf,lev+2,off+len,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Line number: %d\n",(*result)->line_number);
len += 4;
psiconv_progress(config,lev+2,off+len, "Going to read the row or column height");
(*result)->size = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Size: %f\n",(*result)->size);
len += leng;
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet grid size(total length: %08x)", len);
return 0;
ERROR2:
free (*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Grid Size failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_parse_sheet_grid_break_list(const psiconv_config config,
const psiconv_buffer buf, int lev,
psiconv_u32 off, int *length,
psiconv_sheet_grid_break_list *result)
{
int res=0;
int len=0,i;
int leng,listlen;
psiconv_u32 nr;
psiconv_progress(config,lev+1,off,"Going to read a sheet grid break list");
if (!(*result = psiconv_list_new(sizeof(psiconv_u32))))
goto ERROR1;
psiconv_progress(config,lev+2,off+len,
"Going to read the number of elements");
listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res);
if (res)
goto ERROR2;
psiconv_debug(config,lev+2,off+len,"Number of elements: %d",listlen);
len += leng;
psiconv_progress(config,lev+2,off+len,"Going to read all elements");
for (i = 0; i < listlen; i++) {
psiconv_progress(config,lev+3,off+len,"Going to read element %d",i);
nr = psiconv_read_u32(config,buf,lev+3,off+len,&res);
if (res)
goto ERROR2;
if ((res = psiconv_list_add(*result,&nr)))
goto ERROR2;
len += leng;
}
if (length)
*length = len;
psiconv_progress(config,lev,off+len-1,
"End of sheet grid break list (total length: %08x)", len);
return 0;
ERROR2:
psiconv_list_free(*result);
ERROR1:
psiconv_error(config,lev+1,off,"Reading of Sheet Grid break List failed");
if (length)
*length = 0;
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
psiconv-0.9.8/lib/psiconv/generate_simple.c 0000644 0001750 0001750 00000020337 10336374731 015704 0000000 0000000 /*
generate_simple.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "generate_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
static int psiconv_write_string_aux(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_string_t value,int kind);
int psiconv_write_u8(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_u8 value)
{
int res;
psiconv_progress(config,lev,0,"Writing u8");
psiconv_debug(config,lev+1,0,"Value: %02x",value);
res = psiconv_buffer_add(buf,value);
if (res)
psiconv_error(config,lev,0,"Out of memory error");
return res;
}
int psiconv_write_u16(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_u16 value)
{
int res;
psiconv_progress(config,lev,0,"Writing u16");
psiconv_debug(config,lev+1,0,"Value: %04x",value);
if ((res = psiconv_buffer_add(buf,value & 0xff)))
goto ERROR;
if ((res = psiconv_buffer_add(buf,(value & 0xff00) >> 8)))
goto ERROR;
ERROR:
if (res)
psiconv_error(config,lev,0,"Out of memory error");
return res;
}
int psiconv_write_u32(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_u32 value)
{
int res;
psiconv_progress(config,lev,0,"Writing u32");
psiconv_debug(config,lev+1,0,"Value: %08x",value);
if ((res = psiconv_buffer_add(buf,value & 0xff)))
goto ERROR;
if ((res = psiconv_buffer_add(buf,(value & 0xff00) >> 8)))
goto ERROR;
if ((res = psiconv_buffer_add(buf,(value & 0xff0000) >> 16)))
goto ERROR;
if ((res = psiconv_buffer_add(buf,(value & 0xff000000) >> 24)))
goto ERROR;
ERROR:
if (res)
psiconv_error(config,lev,0,"Out of memory error");
return res;
}
int psiconv_write_S(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_u32 value)
{
int res;
psiconv_progress(config,lev,0,"Writing S");
psiconv_debug(config,lev+1,0,"Value: %08x",value);
if (value < 0x40)
res = psiconv_write_u8(config,buf,lev+2,value * 4 + 2);
else if (value < 0x2000)
res = psiconv_write_u16(config,buf,lev+2,value * 8 + 3);
else {
psiconv_error(config,0,psiconv_buffer_length(buf),
"Don't know how to write S value larger than 0x2000 "
"(trying %x)",value);
res = -PSICONV_E_GENERATE;
}
if (res)
psiconv_error(config,lev,0,"Writing of S failed");
else
psiconv_progress(config,lev,0,"End of S");
return res;
}
int psiconv_write_X(const psiconv_config config,psiconv_buffer buf,
int lev, const psiconv_u32 value)
{
int res;
psiconv_progress(config,lev,0,"Writing X");
psiconv_debug(config,lev+1,0,"Value: %08x",value);
if (value < 0x80)
res = psiconv_write_u8(config,buf,lev+2,value * 2);
else if (value < 0x4000)
res = psiconv_write_u16(config,buf,lev+2,value * 4 + 1);
else if (value < 0x20000000)
res = psiconv_write_u16(config,buf,lev+2,value * 8 + 3);
else {
psiconv_error(config,lev,0,
"Don't know how to write X value larger than 0x20000000 "
"(trying %x)",value);
res = -PSICONV_E_GENERATE;
}
if (res)
psiconv_error(config,lev,0,"Writing of X failed");
else
psiconv_progress(config,lev,0,"End of X");
return res;
}
int psiconv_write_length(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_length_t value)
{
int res;
psiconv_progress(config,lev,0,"Writing length");
psiconv_debug(config,lev+1,0,"Value: %f",value);
res = psiconv_write_u32(config,buf,lev+2,value * (1440.0/2.54) + 0.5);
if (res)
psiconv_error(config,lev,0,"Writing of length failed");
else
psiconv_progress(config,lev,0,"End of length");
return res;
}
int psiconv_write_size(const psiconv_config config,psiconv_buffer buf,
int lev, psiconv_size_t value)
{
int res;
psiconv_progress(config,lev,0,"Writing size");
psiconv_debug(config,lev+1,0,"Value: %f",value);
res = psiconv_write_u32(config,buf,lev+2,value * 20.0 + 0.5);
if (res)
psiconv_error(config,lev,0,"Writing of size failed");
else
psiconv_progress(config,lev,0,"End of size");
return res;
}
int psiconv_write_bool(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_bool_t value)
{
int res;
psiconv_progress(config,lev,0,"Writing bool");
psiconv_debug(config,lev+1,0,"Value: %s",
value == psiconv_bool_false?"False":"True");
if ((value != psiconv_bool_true) && (value != psiconv_bool_false))
psiconv_warn(config,0,psiconv_buffer_length(buf),
"Boolean has non-enum value (found %d, used true)",value);
res = psiconv_write_u8(config,buf,lev+2,value == psiconv_bool_false?0:1);
if (res)
psiconv_error(config,lev,0,"Writing of bool failed");
else
psiconv_progress(config,lev,0,"End of bool");
return res;
}
int psiconv_write_string(const psiconv_config config,psiconv_buffer buf,
int lev, const psiconv_string_t value)
{
int res;
psiconv_progress(config,lev,0,"Writing string");
res = psiconv_write_string_aux(config,buf,lev+1,value,-1);
if (res)
psiconv_error(config,lev,0,"Writing of string failed");
else
psiconv_progress(config,lev,0,"End of string");
return res;
}
int psiconv_write_short_string(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_string_t value)
{
int res;
psiconv_progress(config,lev,0,"Writing short string");
res = psiconv_write_string_aux(config,buf,lev+1,value,-2);
if (res)
psiconv_error(config,lev,0,"Writing of short string failed");
else
psiconv_progress(config,lev,0,"End of short string");
return res;
}
int psiconv_write_charlist(const psiconv_config config,psiconv_buffer buf,
int lev,const psiconv_string_t value)
{
int res;
psiconv_progress(config,lev,0,"Writing charlist");
res = psiconv_write_string_aux(config,buf,lev+1,value,0);
if (res)
psiconv_error(config,lev,0,"Writing of charlist failed");
else
psiconv_progress(config,lev,0,"End of charlist");
return res;
}
int psiconv_write_string_aux(const psiconv_config config,psiconv_buffer buf,
int lev, const psiconv_string_t value,int kind)
{
int res,i,len;
char *printable;
len = psiconv_unicode_strlen(value);
if (!value) {
psiconv_error(config,lev,0, "NULL string");
return -PSICONV_E_GENERATE;
}
if (!(printable = psiconv_make_printable(config,value))) {
psiconv_error(config,lev,0,"Out of memory error");
return -PSICONV_E_NOMEM;
}
psiconv_debug(config,lev+1,0,"Value: %s",printable);
free(printable);
if (kind == -1)
res = psiconv_write_S(config,buf,lev+2,len);
else if (kind == -2)
res = psiconv_write_u8(config,buf,lev+2,len);
else
res = 0;
if (res)
return res;
for (i = 0; i < len; i++)
if ((res = psiconv_unicode_write_char(config,buf,lev+2,value[i])))
return res;
return -PSICONV_E_OK;
}
int psiconv_write_offset(const psiconv_config config,psiconv_buffer buf,
int lev,psiconv_u32 id)
{
int res;
psiconv_progress(config,lev,0,"Writing offset");
psiconv_debug(config,lev+1,0,"ID: %08x",id);
res = psiconv_buffer_add_reference(buf,id);
if (res)
psiconv_error(config,lev,0,"Out of memory error");
return res;
}
psiconv-0.9.8/lib/psiconv/generate_layout.c 0000644 0001750 0001750 00000044121 10336374734 015730 0000000 0000000 /*
generate_layout.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "generate_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
int psiconv_write_color(const psiconv_config config, psiconv_buffer buf,
int lev, const psiconv_color value)
{
int res;
psiconv_progress(config,lev,0,"Writing color");
if (!value) {
psiconv_error(config,lev,0,"Null color");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if ((res = psiconv_write_u8(config,buf,lev+1,value->red)))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev+1,value->green)))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev+1,value->blue)))
goto ERROR;
psiconv_progress(config,lev,0,"End of color");
return 0;
ERROR:
psiconv_error(config,lev,0,"Writing of color failed");
return res;
}
int psiconv_write_font(const psiconv_config config, psiconv_buffer buf,
int lev, const psiconv_font value)
{
int res,len;
psiconv_progress(config,lev,0,"Writing font");
if (!value) {
psiconv_error(config,0,psiconv_buffer_length(buf),"Null font");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
len = psiconv_unicode_strlen(value->name);
if ((res = psiconv_write_u8(config,buf,lev+1,len+1)))
goto ERROR;
if ((res = psiconv_write_charlist(config,buf,lev+1,value->name)))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev+1,value->screenfont)))
goto ERROR;
psiconv_progress(config,lev,0,"End of font");
return 0;
ERROR:
psiconv_error(config,lev,0,"Writing of font failed");
return res;
}
int psiconv_write_border(const psiconv_config config, psiconv_buffer buf,int lev, const psiconv_border value)
{
int res;
psiconv_progress(config,lev,0,"Writing border");
if (!value) {
psiconv_error(config,lev,0,"Null border");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if (value->kind > psiconv_border_dotdotdashed)
psiconv_warn(config,lev,0,
"Unknown border kind (%d); assuming none",value->kind);
if ((res =psiconv_write_u8(config,buf,lev+1,
value->kind == psiconv_border_none?0:
value->kind == psiconv_border_solid?1:
value->kind == psiconv_border_double?2:
value->kind == psiconv_border_dotted?3:
value->kind == psiconv_border_dashed?4:
value->kind == psiconv_border_dotdashed?5:
value->kind == psiconv_border_dotdotdashed?6:
0)))
goto ERROR;
if ((res = psiconv_write_size(config,buf,lev+1,
(value->kind == psiconv_border_solid) ||
(value->kind == psiconv_border_double) ?
value->thickness:1.0/20.0)))
goto ERROR;
if ((res = psiconv_write_color(config,buf,lev+1,value->color)))
goto ERROR;
/* Unknown byte */
if ((res = psiconv_write_u8(config,buf,lev+1,1)))
goto ERROR;
psiconv_progress(config,lev,0,"End of border");
return 0;
ERROR:
psiconv_error(config,lev,0,"Writing of border failed");
return res;
}
int psiconv_write_bullet(const psiconv_config config, psiconv_buffer buf,int lev, const psiconv_bullet value)
{
int res;
psiconv_buffer extra_buf;
psiconv_progress(config,lev,0,"Writing bullet");
if (!value) {
psiconv_error(config,0,psiconv_buffer_length(buf),"Null bullet");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(extra_buf = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if ((res = psiconv_write_size(config,extra_buf,lev+1,value->font_size)))
goto ERROR2;
if ((res = psiconv_unicode_write_char(config,extra_buf,lev+1,
value->character)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->indent)))
goto ERROR2;
if ((res = psiconv_write_color(config,extra_buf,lev+1,value->color)))
goto ERROR2;
if ((res = psiconv_write_font(config,extra_buf,lev+1,value->font)))
goto ERROR2;
if ((res = psiconv_write_u8(config,buf,lev+1,psiconv_buffer_length(extra_buf))))
goto ERROR2;
if ((res = psiconv_buffer_concat(buf,extra_buf))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
ERROR2:
psiconv_buffer_free(extra_buf);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of bullet failed");
else
psiconv_progress(config,lev,0,"End of bullet");
return res;
}
int psiconv_write_tab(const psiconv_config config, psiconv_buffer buf,int lev, psiconv_tab value)
{
int res;
psiconv_progress(config,lev,0,"Writing tab");
if (!value) {
psiconv_error(config,lev,0,"Null tab");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if ((res = psiconv_write_length(config,buf,lev+1,value->location)))
goto ERROR;
if ((value->kind != psiconv_tab_left) &&
(value->kind != psiconv_tab_right) &&
(value->kind != psiconv_tab_centre))
psiconv_warn(config,lev,0,
"Unknown tab kind (%d); assuming left",value->kind);
if ((res = psiconv_write_u8(config,buf,lev+1,
value->kind == psiconv_tab_right?2:
value->kind == psiconv_tab_centre?3:1)))
goto ERROR;
psiconv_progress(config,lev,0,"End of tab");
return 0;
ERROR:
psiconv_error(config,lev,0,"Writing of tab failed");
return res;
}
int psiconv_write_paragraph_layout_list(const psiconv_config config,
psiconv_buffer buf,int lev,
psiconv_paragraph_layout value,
psiconv_paragraph_layout base)
{
int res,i;
psiconv_buffer extra_buf;
psiconv_tab tab;
psiconv_progress(config,lev,0,"Writing paragraph layout list");
if (!value) {
psiconv_error(config,lev,0,"Null paragraph layout list");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(extra_buf = psiconv_buffer_new())) {
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!base || psiconv_compare_color(base->back_color,value->back_color)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x01)))
goto ERROR2;
if ((res = psiconv_write_color(config,extra_buf,lev+1,value->back_color)))
goto ERROR2;
}
if (!base || (value->indent_left != base->indent_left)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x02)))
goto ERROR2;
if ((res = psiconv_write_length(config,extra_buf,lev+1,value->indent_left)))
goto ERROR2;
}
if (!base || (value->indent_right != base->indent_right)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x03)))
goto ERROR2;
if ((res = psiconv_write_length(config,extra_buf,lev+1,value->indent_right)))
goto ERROR2;
}
if (!base || (value->indent_first != base->indent_first)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x04)))
goto ERROR2;
if ((res = psiconv_write_length(config,extra_buf,lev+1,value->indent_first)))
goto ERROR2;
}
if (!base || (value->justify_hor != base->justify_hor)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x05)))
goto ERROR2;
if ((value->justify_hor < psiconv_justify_left) ||
(value->justify_hor > psiconv_justify_full))
psiconv_warn(config,lev,0,
"Unknown horizontal justify (%d); assuming left",
value->justify_hor);
if ((res = psiconv_write_u8(config,extra_buf,lev+1,
value->justify_hor == psiconv_justify_centre?1:
value->justify_hor == psiconv_justify_right?2:
value->justify_hor == psiconv_justify_full?3:0)))
goto ERROR2;
}
if (!base || (value->justify_ver != base->justify_ver)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x06)))
goto ERROR2;
if ((value->justify_ver < psiconv_justify_top) ||
(value->justify_ver > psiconv_justify_bottom))
psiconv_warn(config,0,psiconv_buffer_length(buf),
"Unknown vertical justify (%d); assuming middle",
value->justify_ver);
if ((res = psiconv_write_u8(config,extra_buf,lev+1,
value->justify_ver == psiconv_justify_centre?1:
value->justify_ver == psiconv_justify_right?2:0)))
goto ERROR2;
}
if (!base || (value->linespacing != base->linespacing)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x07)))
goto ERROR2;
if ((res = psiconv_write_size(config,extra_buf,lev+1,value->linespacing)))
goto ERROR2;
}
if (!base || (value->linespacing_exact != base->linespacing_exact)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x08)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->linespacing_exact)))
goto ERROR2;
}
if (!base || (value->space_above != base->space_above)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x09)))
goto ERROR2;
if ((res = psiconv_write_size(config,extra_buf,lev+1,value->space_above)))
goto ERROR2;
}
if (!base || (value->space_below != base->space_below)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x0a)))
goto ERROR2;
if ((res = psiconv_write_size(config,extra_buf,lev+1,value->space_below)))
goto ERROR2;
}
if (!base || (value->keep_together != base->keep_together)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x0b)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->keep_together)))
goto ERROR2;
}
if (!base || (value->keep_with_next != base->keep_with_next)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x0c)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->keep_with_next)))
goto ERROR2;
}
if (!base || (value->on_next_page != base->on_next_page)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x0d)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->on_next_page)))
goto ERROR2;
}
if (!base || (value->no_widow_protection != base->no_widow_protection)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x0e)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->no_widow_protection)))
goto ERROR2;
}
if (!base || (value->wrap_to_fit_cell != base->wrap_to_fit_cell)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x0f)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->wrap_to_fit_cell)))
goto ERROR2;
}
if (!base || (value->border_distance != base->border_distance)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x10)))
goto ERROR2;
if ((res = psiconv_write_length(config,extra_buf,lev+1,value->border_distance)))
goto ERROR2;
}
if (!base || psiconv_compare_border(value->top_border,base->top_border)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x11)))
goto ERROR2;
if ((res = psiconv_write_border(config,extra_buf,lev+1,value->top_border)))
goto ERROR2;
}
if (!base || psiconv_compare_border(value->bottom_border,
base->bottom_border)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x12)))
goto ERROR2;
if ((res = psiconv_write_border(config,extra_buf,lev+1,value->bottom_border)))
goto ERROR2;
}
if (!base || psiconv_compare_border(value->left_border,
base->left_border)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x13)))
goto ERROR2;
if ((res = psiconv_write_border(config,extra_buf,lev+1,value->left_border)))
goto ERROR2;
}
if (!base || psiconv_compare_border(value->right_border,
base->right_border)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x14)))
goto ERROR2;
if ((res = psiconv_write_border(config,extra_buf,lev+1,value->right_border)))
goto ERROR2;
}
if (!base || psiconv_compare_bullet(value->bullet,
base->bullet)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x15)))
goto ERROR2;
if ((res = psiconv_write_bullet(config,extra_buf,lev+1,value->bullet)))
goto ERROR2;
}
if (!value->tabs || !value->tabs->extras) {
psiconv_error(config,0,psiconv_buffer_length(buf),"Null tabs");
res = -PSICONV_E_GENERATE;
goto ERROR2;
}
/* It is not entirely clear how tabs are inherited. For now, I assume
if there is any difference at all, we will have to generate both
the normal tab-interval, and all specific tabs */
if (!base || psiconv_compare_all_tabs(value->tabs,base->tabs)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x16)))
goto ERROR2;
if ((res = psiconv_write_length(config,extra_buf,lev+1,value->tabs->normal)))
goto ERROR2;
for (i = 0; i < psiconv_list_length(value->tabs->extras); i++) {
if (!(tab = psiconv_list_get(value->tabs->extras,i))) {
psiconv_error(config,lev+1,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x17)))
goto ERROR2;
if ((res = psiconv_write_tab(config,extra_buf,lev+1,tab)))
goto ERROR2;
}
}
if ((res = psiconv_write_u32(config,buf,lev+1,psiconv_buffer_length(extra_buf))))
goto ERROR2;
if ((res = psiconv_buffer_concat(buf,extra_buf))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
ERROR2:
psiconv_buffer_free(extra_buf);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of paragraph layout list failed");
else
psiconv_progress(config,lev,0,"End of paragraph layout list");
return res;
}
int psiconv_write_character_layout_list(const psiconv_config config,
psiconv_buffer buf,int lev,
psiconv_character_layout value,
psiconv_character_layout base)
{
int res;
psiconv_buffer extra_buf;
psiconv_progress(config,lev,0,"Writing character layout list");
if (!value) {
psiconv_error(config,lev,0,"Null character layout list");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(extra_buf = psiconv_buffer_new())) {
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!base || psiconv_compare_color(base->color,value->color)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x19)))
goto ERROR2;
if ((res = psiconv_write_color(config,extra_buf,lev+1,value->color)))
goto ERROR2;
}
if (!base || psiconv_compare_color(base->back_color,value->back_color)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x1a)))
goto ERROR2;
if ((res = psiconv_write_color(config,extra_buf,lev+1,value->back_color)))
goto ERROR2;
}
if (!base || (value->font_size != base->font_size)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x1c)))
goto ERROR2;
if ((res = psiconv_write_size(config,extra_buf,lev+1,value->font_size)))
goto ERROR2;
}
if (!base || (value->italic != base->italic)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x1d)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->italic)))
goto ERROR2;
}
if (!base || (value->bold != base->bold)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x1e)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->bold)))
goto ERROR2;
}
if (!base || (value->super_sub != base->super_sub)) {
if ((value->super_sub != psiconv_superscript) &&
(value->super_sub != psiconv_subscript) &&
(value->super_sub != psiconv_normalscript))
psiconv_warn(config,lev,0,"Unknown supersubscript (%d); assuming normal",
value->super_sub);
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x1f)))
goto ERROR2;
if ((res = psiconv_write_u8(config,extra_buf,lev+1,
value->super_sub == psiconv_superscript?1:
value->super_sub == psiconv_subscript?2:0)))
goto ERROR2;
}
if (!base || (value->underline != base->underline)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x20)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->underline)))
goto ERROR2;
}
if (!base || (value->strikethrough != base->strikethrough)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x21)))
goto ERROR2;
if ((res = psiconv_write_bool(config,extra_buf,lev+1,value->strikethrough)))
goto ERROR2;
}
if (!base || psiconv_compare_font(base->font,value->font)) {
if ((res = psiconv_write_u8(config,extra_buf,lev+1,0x22)))
goto ERROR2;
if ((res = psiconv_write_font(config,extra_buf,lev+1,value->font)))
goto ERROR2;
}
if ((res = psiconv_write_u32(config,buf,lev+1,psiconv_buffer_length(extra_buf))))
goto ERROR2;
res = psiconv_buffer_concat(buf,extra_buf);
ERROR2:
psiconv_buffer_free(extra_buf);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of character layout list failed");
else
psiconv_progress(config,lev,0,"End of character layout list");
return res;
}
psiconv-0.9.8/lib/psiconv/generate_driver.c 0000644 0001750 0001750 00000043503 10336374706 015710 0000000 0000000 /*
generate_driver.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "error.h"
#include "generate_routines.h"
#ifdef DMALLOC
#include
#endif
static psiconv_ucs2 unicode_paint[10] = { 'P','a','i','n','t','.','a','p','p',0 };
static psiconv_ucs2 unicode_texted[11] ={ 'T','e','x','t','E','d','.','a','p','p',0 };
static psiconv_ucs2 unicode_word[9] = { 'W','o','r','d','.','a','p','p',0 };
int psiconv_write(const psiconv_config config, psiconv_buffer *buf,
const psiconv_file value)
{
int res;
int lev = 0;
if (!value) {
psiconv_error(config,0,0,"Can't parse to an empty buffer!");
return -PSICONV_E_OTHER;
}
if (!(*buf = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
return -PSICONV_E_NOMEM;
}
if (value->type == psiconv_word_file) {
if ((res = psiconv_write_header_section(config,*buf,lev+1,PSICONV_ID_PSION5,
PSICONV_ID_DATA_FILE,
PSICONV_ID_WORD)))
goto ERROR;
if ((res =psiconv_write_word_file(config,*buf,lev+1,(psiconv_word_f) (value->file))))
goto ERROR;
} else if (value->type == psiconv_texted_file) {
if ((res = psiconv_write_header_section(config,*buf,lev+1,PSICONV_ID_PSION5,
PSICONV_ID_DATA_FILE,
PSICONV_ID_TEXTED)))
goto ERROR;
if ((res =psiconv_write_texted_file(config,*buf,lev+1,
(psiconv_texted_f) (value->file))))
goto ERROR;
} else if (value->type == psiconv_sketch_file) {
if ((res = psiconv_write_header_section(config,*buf,lev+1,PSICONV_ID_PSION5,
PSICONV_ID_DATA_FILE,
PSICONV_ID_SKETCH)))
goto ERROR;
if ((res =psiconv_write_sketch_file(config,*buf,lev+1,
(psiconv_sketch_f) (value->file))))
goto ERROR;
} else if (value->type == psiconv_mbm_file) {
if ((res = psiconv_write_header_section(config,*buf,lev+1,PSICONV_ID_PSION5,
PSICONV_ID_MBM_FILE,
0x00000000)))
goto ERROR;
if ((res =psiconv_write_mbm_file(config,*buf,lev+1,
(psiconv_mbm_f) (value->file))))
goto ERROR;
} else if (value->type == psiconv_clipart_file) {
/* No complete header section, so we do it all in the below function */
if ((res =psiconv_write_clipart_file(config,*buf,lev+1,
(psiconv_clipart_f) (value->file))))
goto ERROR;
} else {
psiconv_error(config,0,0,"Unknown or unsupported file type");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if ((res = psiconv_buffer_resolve(*buf))) {
psiconv_error(config,lev+1,0,"Internal error resolving buffer references");
goto ERROR;
}
return -PSICONV_E_OK;
ERROR:
psiconv_buffer_free(*buf);
return res;
}
int psiconv_write_texted_file(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_texted_f value)
{
psiconv_character_layout base_char;
psiconv_paragraph_layout base_para;
int res;
psiconv_section_table_section section_table;
psiconv_section_table_entry entry;
psiconv_u32 section_table_id;
psiconv_buffer buf_texted;
psiconv_progress(config,lev,0,"Writing texted file");
if (!value) {
psiconv_error(config,lev,0,"Null TextEd file");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!(entry = malloc(sizeof(*entry)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(base_char = psiconv_basic_character_layout())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR3;
}
if (!(base_para = psiconv_basic_paragraph_layout())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR4;
}
section_table_id = psiconv_buffer_unique_id();
if ((res = psiconv_write_offset(config,buf,lev+1,section_table_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR5;
}
entry->id = PSICONV_ID_APPL_ID_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR5;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR5;
}
if ((res=psiconv_write_application_id_section(config,buf,lev+1,
PSICONV_ID_TEXTED,unicode_texted)))
goto ERROR5;
entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR5;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR5;
}
if ((res = psiconv_write_page_layout_section(config,buf,lev+1,value->page_sec)))
goto ERROR5;
entry->id = PSICONV_ID_TEXTED;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR5;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR5;
}
if ((res = psiconv_write_texted_section(config,buf,lev+1,value->texted_sec,
base_char,base_para,&buf_texted)))
goto ERROR5;
if ((res = psiconv_buffer_concat(buf,buf_texted))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
if ((res = psiconv_buffer_add_target(buf,section_table_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
res = psiconv_write_section_table_section(config,buf,lev+1,section_table);
ERROR6:
psiconv_buffer_free(buf_texted);
ERROR5:
psiconv_free_paragraph_layout(base_para);
ERROR4:
psiconv_free_character_layout(base_char);
ERROR3:
free(entry);
ERROR2:
psiconv_list_free(section_table);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of texted file failed");
else
psiconv_progress(config,lev,0,"End of texted file");
return res;
}
int psiconv_write_word_file(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_word_f value)
{
int res;
psiconv_section_table_section section_table;
psiconv_section_table_entry entry;
psiconv_u32 section_table_id;
psiconv_progress(config,lev,0,"Writing word file");
if (!value) {
psiconv_error(config,lev,0,"Null Word file");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!(entry = malloc(sizeof(*entry)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
section_table_id = psiconv_buffer_unique_id();
if ((res = psiconv_write_offset(config,buf,lev+1,section_table_id)))
goto ERROR3;
entry->id = PSICONV_ID_APPL_ID_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res=psiconv_write_application_id_section(config,buf,lev+1,
PSICONV_ID_WORD,unicode_word)))
goto ERROR3;
entry->id = PSICONV_ID_WORD_STATUS_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_write_word_status_section(config,buf,lev+1,value->status_sec)))
goto ERROR3;
entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_write_page_layout_section(config,buf,lev+1,value->page_sec)))
goto ERROR3;
entry->id = PSICONV_ID_WORD_STYLES_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_write_word_styles_section(config,buf,lev+1,value->styles_sec)))
goto ERROR3;
entry->id = PSICONV_ID_TEXT_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_write_text_section(config,buf,lev+1,value->paragraphs)))
goto ERROR3;
entry->id = PSICONV_ID_LAYOUT_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_write_styled_layout_section(config,buf,lev+1,value->paragraphs,
value->styles_sec)))
goto ERROR3;
if ((res = psiconv_buffer_add_target(buf,section_table_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
res = psiconv_write_section_table_section(config,buf,lev+1,section_table);
ERROR3:
free(entry);
ERROR2:
psiconv_list_free(section_table);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of word file failed");
else
psiconv_progress(config,lev,0,"End of word file");
return res;
}
int psiconv_write_sketch_file(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_sketch_f value)
{
int res;
psiconv_section_table_section section_table;
psiconv_section_table_entry entry;
psiconv_u32 section_table_id;
psiconv_progress(config,lev,0,"Writing sketch file");
if (!value) {
psiconv_error(config,lev,0,"Null Sketch file");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!(entry = malloc(sizeof(*entry)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
section_table_id = psiconv_buffer_unique_id();
if ((res = psiconv_write_offset(config,buf,lev+1,section_table_id)))
goto ERROR3;
entry->id = PSICONV_ID_APPL_ID_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res=psiconv_write_application_id_section(config,buf,lev+1,
PSICONV_ID_SKETCH,unicode_paint)))
goto ERROR3;
entry->id = PSICONV_ID_SKETCH_SECTION;
entry->offset = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(section_table,entry))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(buf,entry->offset))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_write_sketch_section(config,buf,lev+1,value->sketch_sec)))
goto ERROR3;
if ((res = psiconv_buffer_add_target(buf,section_table_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
res = psiconv_write_section_table_section(config,buf,lev+1,section_table);
ERROR3:
free(entry);
ERROR2:
psiconv_list_free(section_table);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of sketch file failed");
else
psiconv_progress(config,lev,0,"End of sketch file");
return res;
}
int psiconv_write_mbm_file(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_mbm_f value)
{
int res,i;
psiconv_jumptable_section jumptable;
psiconv_u32 *entry,id,table_id;
psiconv_paint_data_section section;
psiconv_progress(config,lev,0,"Writing mbm file");
if (!value) {
psiconv_error(config,lev,0,"Null MBM file");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(jumptable = psiconv_list_new(sizeof(*entry)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
table_id = psiconv_buffer_unique_id();
if ((res = psiconv_buffer_add_reference(buf,table_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
for (i = 0; i < psiconv_list_length(value->sections); i++) {
if (!(section = psiconv_list_get(value->sections,i))) {
psiconv_error(config,lev,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
id = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(jumptable,&id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if ((res = psiconv_buffer_add_target(buf,id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if ((res = psiconv_write_paint_data_section(config,buf,lev+1,section,0)))
goto ERROR2;
}
if ((res = psiconv_buffer_add_target(buf,table_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if ((res = psiconv_write_jumptable_section(config,buf,lev+1,jumptable)))
goto ERROR2;
ERROR2:
psiconv_list_free(jumptable);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of mbm file failed");
else
psiconv_progress(config,lev,0,"End of mbm file");
return res;
}
/* Note: this file is special, because it does not have a complete header! */
int psiconv_write_clipart_file(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_clipart_f value)
{
int res,i;
psiconv_jumptable_section jumptable;
psiconv_u32 *entry,id;
psiconv_clipart_section section;
psiconv_buffer sec_buf;
psiconv_progress(config,lev,0,"Writing clipart file");
if (!value) {
psiconv_error(config,lev,0,"Null Clipart file");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(jumptable = psiconv_list_new(sizeof(*entry)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!(sec_buf = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_CLIPART)))
goto ERROR3;
for (i = 0; i < psiconv_list_length(value->sections); i++) {
if (!(section = psiconv_list_get(value->sections,i))) {
psiconv_error(config,lev,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR3;
}
id = psiconv_buffer_unique_id();
if ((res = psiconv_list_add(jumptable,&id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_add_target(sec_buf,id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_write_clipart_section(config,sec_buf, lev+1,section)))
goto ERROR3;
}
if ((res = psiconv_write_jumptable_section(config,buf,lev+1,jumptable)))
goto ERROR3;
if ((res = psiconv_buffer_concat(buf,sec_buf))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
ERROR3:
psiconv_buffer_free(sec_buf);
ERROR2:
psiconv_list_free(jumptable);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of clipart file failed");
else
psiconv_progress(config,lev,0,"End of clipart file");
return res;
}
psiconv-0.9.8/lib/psiconv/generate_common.c 0000644 0001750 0001750 00000057702 10336374707 015714 0000000 0000000 /*
generate_common.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "generate_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
static int psiconv_write_layout_section(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_text_and_layout value,
const psiconv_word_styles_section styles,
int with_styles);
/* Maybe use a psiconv_header_section variable instead? */
int psiconv_write_header_section(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_u32 uid1,
psiconv_u32 uid2, psiconv_u32 uid3)
{
int res;
psiconv_progress(config,lev,0,"Writing header section");
if ((res = psiconv_write_u32(config,buf,lev+1,uid1)))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,uid2)))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,uid3)))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,
psiconv_checkuid(uid1,uid2,uid3))))
goto ERROR;
psiconv_progress(config,lev,0,"End of header section");
return 0;
ERROR:
psiconv_error(config,lev,0,"Writing of header section failed");
return res;
}
int psiconv_write_section_table_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_section_table_section value)
{
int res,i;
psiconv_section_table_entry entry;
psiconv_progress(config,lev,0,"Writing section table section");
if (!value) {
psiconv_error(config,lev,0,"Null section table section");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if ((res = psiconv_write_u8(config,buf,lev+1,2 * psiconv_list_length(value))))
goto ERROR;
for (i = 0; i < psiconv_list_length(value); i++) {
if (!(entry = psiconv_list_get(value,i))) {
psiconv_error(config,lev+1,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR;
}
if ((res = psiconv_write_u32(config,buf,lev+1,entry->id)))
goto ERROR;
if ((res = psiconv_write_offset(config,buf,lev+1,entry->offset)))
goto ERROR;
}
psiconv_progress(config,lev,0,"End of section table section");
return -PSICONV_E_OK;
ERROR:
psiconv_error(config,lev,0,"Writing of section table section failed");
return res;
}
int psiconv_write_application_id_section(const psiconv_config config,
psiconv_buffer buf,int lev,psiconv_u32 id,
const psiconv_string_t text)
{
int res;
psiconv_progress(config,lev,0,"Writing application id section");
if ((res = psiconv_write_u32(config,buf,lev+1,id)))
goto ERROR;
if ((res = psiconv_write_string(config,buf,lev+1,text)))
goto ERROR;
psiconv_progress(config,lev,0,"End of application id section");
return 0;
ERROR:
psiconv_error(config,lev,0,"Writing of application id section failed");
return res;
}
int psiconv_write_text_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_text_and_layout value)
{
int res;
psiconv_buffer extra_buf = NULL;
int i,j;
psiconv_paragraph paragraph;
psiconv_progress(config,lev,0,"Writing text section");
if (!value) {
psiconv_error(config,lev+1,0,"Null text section");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if (psiconv_list_length(value)) {
if (!(extra_buf = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR;
}
for (i = 0; i < psiconv_list_length(value); i++) {
if (!(paragraph = psiconv_list_get(value,i))) {
psiconv_error(config,lev+1,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR;
}
for (j = 0; j < psiconv_unicode_strlen(paragraph->text); j++)
if ((res = psiconv_unicode_write_char(config,extra_buf,lev+1,
paragraph->text[j])))
goto ERROR;
psiconv_unicode_write_char(config,extra_buf,lev+1,0x06);
}
if ((res = psiconv_write_X(config,buf,lev+1,psiconv_buffer_length(extra_buf))))
goto ERROR;
res = psiconv_buffer_concat(buf,extra_buf);
} else
/* Hack: empty text sections are just not allowed */
if ((res = psiconv_write_u16(config,buf,lev+1,0x0602)))
goto ERROR;
psiconv_progress(config,lev,0,"End of text section");
return 0;
ERROR:
if (extra_buf)
psiconv_buffer_free(extra_buf);
psiconv_error(config,lev,0,"Writing of text section failed");
return res;
}
int psiconv_write_layout_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_text_and_layout value,
const psiconv_word_styles_section styles,
int with_styles)
{
typedef struct psiconv_paragraph_type_list_s
{
psiconv_character_layout character;
psiconv_paragraph_layout paragraph;
psiconv_u8 style;
psiconv_u8 nr;
} *psiconv_paragraph_type_list;
psiconv_u32 obj_id;
psiconv_list paragraph_type_list; /* Of psiconv_paragraph_type_list_s */
psiconv_paragraph_type_list paragraph_type;
struct psiconv_paragraph_type_list_s new_type;
psiconv_buffer buf_types,buf_elements,buf_inlines,buf_objects;
psiconv_paragraph paragraph;
psiconv_in_line_layout in_line = NULL;
psiconv_word_style style;
psiconv_character_layout para_charlayout;
int i,j,para_type,nr_of_inlines=0,res,ptl_length,pel_length,thislen,paralen;
psiconv_progress(config,lev,0,"Writing layout section");
if (!value) {
psiconv_error(config,lev,0,"Null text section");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(paragraph_type_list = psiconv_list_new(sizeof(new_type)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!(buf_types = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(buf_elements = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR3;
}
if (!(buf_inlines = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR4;
}
if (!(buf_objects = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR5;
}
for (i = 0; i < psiconv_list_length(value); i++) {
if (!(paragraph = psiconv_list_get(value,i))) {
psiconv_error(config,lev+1,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR6;
}
if ((res = psiconv_write_u32(config,buf_elements,lev+1,
psiconv_unicode_strlen(paragraph->text)+1)))
goto ERROR6;
/* We need it for the next if-statement */
if (psiconv_list_length(paragraph->in_lines) == 1)
if (!(in_line = psiconv_list_get(paragraph->in_lines,0))) {
psiconv_error(config,lev+1,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR6;
}
if ((psiconv_list_length(paragraph->in_lines) > 1) ||
((psiconv_list_length(paragraph->in_lines) == 1) &&
(in_line->object != NULL))) {
/* Inline layouts, or an object, so we generate a paragraph element
and inline elements */
if ((res = psiconv_write_u8(config,buf_elements,lev+1,0x00)))
goto ERROR6;
if (!(style = psiconv_get_style(styles,paragraph->base_style))) {
psiconv_error(config,lev+1,0,"Unknown style");
res = -PSICONV_E_GENERATE;
goto ERROR6;
}
if ((res = psiconv_write_paragraph_layout_list(config,buf_elements,lev+1,
paragraph->base_paragraph,
style->paragraph)))
goto ERROR6;
if (with_styles)
if ((res = psiconv_write_u8(config,buf_elements,lev+1,paragraph->base_style)))
goto ERROR6;
if ((res = psiconv_write_u32(config,buf_elements,lev+1,
psiconv_list_length(paragraph->in_lines))))
goto ERROR6;
/* Generate the inlines. NB: Against what are all settings relative?!? */
paralen = 0;
for (j = 0; j < psiconv_list_length(paragraph->in_lines); j++) {
nr_of_inlines ++;
if (!(in_line = psiconv_list_get(paragraph->in_lines,j))) {
psiconv_error(config,lev,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR6;
}
if ((res = psiconv_write_u8(config,buf_inlines,lev+1,in_line->object?0x01:0x00)))
goto ERROR6;
thislen = in_line->length;
paralen += thislen;
/* If this is the last in_line, we need to make sure that the
complete length of all inlines equals the text length */
if (j == psiconv_list_length(paragraph->in_lines)-1) {
if (paralen > psiconv_unicode_strlen(paragraph->text)+1) {
psiconv_error(config,lev+1,0,"Inline formatting data length and line length are inconsistent");
res = -PSICONV_E_GENERATE;
goto ERROR6;
}
thislen += psiconv_unicode_strlen(paragraph->text)+1-paralen;
}
if ((res = psiconv_write_u32(config,buf_inlines,lev+1,thislen)))
goto ERROR6;
if ((res = psiconv_write_character_layout_list(config,buf_inlines,lev+1,
in_line->layout,
style->character)))
goto ERROR6;
if (in_line->object) {
if ((res = psiconv_write_u32(config,buf_inlines,lev+1,PSICONV_ID_OBJECT)))
goto ERROR6;
obj_id = psiconv_buffer_unique_id();
if ((res = psiconv_buffer_add_reference(buf_inlines,obj_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
if ((res = psiconv_buffer_add_target(buf_objects,obj_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
if ((res = psiconv_write_embedded_object_section(config,buf_objects,lev+1,
in_line->object)))
goto ERROR6;
if ((res = psiconv_write_length(config,buf_inlines,lev+1,in_line->object_width)))
goto ERROR6;
if ((res = psiconv_write_length(config,buf_inlines,lev+1,in_line->object_height)))
goto ERROR6;
}
}
} else {
/* No inline layouts (or only 1), so we generate a paragraph type list */
para_type = 0;
/* Set para_charlayout to the correct character-level layout */
if (psiconv_list_length(paragraph->in_lines) == 0)
para_charlayout = paragraph->base_character;
else {
if (!(in_line = psiconv_list_get(paragraph->in_lines,0))) {
psiconv_error(config,lev,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR6;
}
para_charlayout = in_line->layout;
}
for (j = 0; j < psiconv_list_length(paragraph_type_list); j++) {
if (!(paragraph_type = psiconv_list_get(paragraph_type_list,j))) {
psiconv_error(config,lev,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR6;
}
if ((paragraph->base_style == paragraph_type->style) &&
!psiconv_compare_character_layout(para_charlayout,
paragraph_type->character) &&
!psiconv_compare_paragraph_layout(paragraph->base_paragraph,
paragraph_type->paragraph)) {
para_type = paragraph_type->nr;
break;
}
}
if (!para_type) {
/* We need to add a new entry */
para_type = new_type.nr = j+1;
/* No need to copy them, we won't change them anyway */
new_type.paragraph = paragraph->base_paragraph;
new_type.character = para_charlayout;
new_type.style = paragraph->base_style;
paragraph_type = &new_type;
if ((res = psiconv_list_add(paragraph_type_list,paragraph_type))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
if ((res = psiconv_write_u32(config,buf_types,lev+1,paragraph_type->nr)))
goto ERROR6;
if (!(style = psiconv_get_style(styles,paragraph_type->style))) {
psiconv_error(config,lev,0,"Unknown style");
res = -PSICONV_E_GENERATE;
goto ERROR6;
}
if ((res = psiconv_write_paragraph_layout_list(config,buf_types,lev+1,
paragraph_type->paragraph,style->paragraph)))
goto ERROR6;
if (with_styles)
if ((res = psiconv_write_u8(config,buf_types,lev+1,paragraph_type->style)))
goto ERROR6;
if ((res = psiconv_write_character_layout_list(config,buf_types,lev+1,
paragraph_type->character,style->character)))
goto ERROR6;
}
if ((res = psiconv_write_u8(config,buf_elements,lev+1,para_type)))
goto ERROR6;
}
}
/* HACK: special case: no paragraphs at all. We need to improvize. */
if (!psiconv_list_length(value)) {
if ((res = psiconv_write_u32(config,buf_types,lev+1,1)))
goto ERROR6;
if ((res = psiconv_write_u32(config,buf_types,lev+1,0)))
goto ERROR6;
if (with_styles)
if ((res = psiconv_write_u8(config,buf_types,lev+1,0)))
goto ERROR6;
if ((res = psiconv_write_u32(config,buf_types,lev+1,0)))
goto ERROR6;
if ((res = psiconv_write_u32(config,buf_elements,lev+1,1)))
goto ERROR6;
if ((res = psiconv_write_u8(config,buf_elements,lev+1,1)))
goto ERROR6;
pel_length = 1;
ptl_length = 1;
} else {
pel_length = psiconv_list_length(value);
ptl_length = psiconv_list_length(paragraph_type_list);
}
/* Now append everything */
if ((res = psiconv_write_u16(config,buf,lev+1,with_styles?0x0001:0x0000)))
goto ERROR6;
if ((res = psiconv_write_u8(config,buf,lev+1, ptl_length)))
goto ERROR6;
if ((res = psiconv_buffer_concat(buf,buf_types))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
if ((res = psiconv_write_u32(config,buf,lev+1,pel_length)))
goto ERROR6;
if ((res = psiconv_buffer_concat(buf,buf_elements))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
if ((res = psiconv_write_u32(config,buf,lev+1,nr_of_inlines)))
goto ERROR6;
if ((res = psiconv_buffer_concat(buf,buf_inlines))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
if ((res = psiconv_buffer_concat(buf,buf_objects))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
ERROR6:
psiconv_buffer_free(buf_objects);
ERROR5:
psiconv_buffer_free(buf_inlines);
ERROR4:
psiconv_buffer_free(buf_elements);
ERROR3:
psiconv_buffer_free(buf_types);
ERROR2:
psiconv_list_free(paragraph_type_list);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of layout section failed");
else
psiconv_progress(config,lev,0,"End of layout section");
return res;
}
int psiconv_write_styled_layout_section(const psiconv_config config,
psiconv_buffer buf,int lev,
psiconv_text_and_layout result,
psiconv_word_styles_section styles)
{
int res;
psiconv_progress(config,lev,0,"Writing styled layout section");
res = psiconv_write_layout_section(config,buf,lev+1,result,styles,1);
if (res)
psiconv_error(config,lev,0,"Writing of styles layout section failed");
else
psiconv_progress(config,lev,0,"End of styled layout section");
return res;
}
int psiconv_write_styleless_layout_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_text_and_layout value,
const psiconv_character_layout base_char,
const psiconv_paragraph_layout base_para)
{
int res = 0;
psiconv_word_styles_section styles_section;
psiconv_progress(config,lev,0,"Writing styleless layout section");
if (!(styles_section = malloc(sizeof(*styles_section)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR1;
}
if (!(styles_section->normal = malloc(sizeof(*styles_section->normal)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if (!(styles_section->normal->character =
psiconv_clone_character_layout(base_char))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if (!(styles_section->normal->paragraph =
psiconv_clone_paragraph_layout(base_para))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR4;
}
styles_section->normal->hotkey = 0;
if (!(styles_section->normal->name = psiconv_unicode_empty_string())) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR5;
}
if (!(styles_section->styles = psiconv_list_new(sizeof(
struct psiconv_word_style_s)))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR6;
}
res = psiconv_write_layout_section(config,buf,lev+1,value,styles_section,0);
psiconv_free_word_styles_section(styles_section);
psiconv_progress(config,lev,0,"End of styleless layout section");
return res;
ERROR6:
free(styles_section->normal->name);
ERROR5:
psiconv_free_paragraph_layout(styles_section->normal->paragraph);
ERROR4:
psiconv_free_character_layout(styles_section->normal->character);
ERROR3:
free(styles_section->normal);
ERROR2:
free(styles_section);
ERROR1:
psiconv_error(config,lev,0,"Writing of styleless layout section failed");
if (!res)
return -PSICONV_E_NOMEM;
else
return res;
}
int psiconv_write_embedded_object_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_embedded_object_section value)
{
int res;
psiconv_u32 display_id,icon_id,table_id;
psiconv_buffer extra_buf;
psiconv_progress(config,lev,0,"Writing embedded object section");
if (!value) {
psiconv_error(config,lev,0,"Null Object");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(extra_buf = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
display_id = psiconv_buffer_unique_id();
icon_id = psiconv_buffer_unique_id();
table_id = psiconv_buffer_unique_id();
if ((res = psiconv_write_u8(config,buf,lev+1,0x06)))
goto ERROR2;
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_DISPLAY_SECTION)))
goto ERROR2;
if ((res = psiconv_buffer_add_reference(buf,display_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_ICON_SECTION)))
goto ERROR2;
if ((res = psiconv_buffer_add_reference(buf,icon_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_SECTION_TABLE_SECTION)))
goto ERROR2;
if ((res = psiconv_buffer_add_reference(buf,table_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if ((res = psiconv_buffer_add_target(buf,display_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if ((res = psiconv_write_object_display_section(config,buf,lev+1,value->display)))
goto ERROR2;
if ((res = psiconv_buffer_add_target(buf,icon_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if ((res = psiconv_write_object_icon_section(config,buf,lev+1,value->icon)))
goto ERROR2;
if ((res = psiconv_buffer_add_target(buf,table_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
switch(value->object->type) {
case psiconv_word_file:
if ((res = psiconv_write_word_file(config,extra_buf,lev+1,
(psiconv_word_f) value->object->file)))
goto ERROR2;
break;
case psiconv_sketch_file:
if ((res = psiconv_write_sketch_file(config,extra_buf,lev+1,
(psiconv_sketch_f) value->object->file)))
goto ERROR2;
break;
/*
case psiconv_sheet_file:
if ((res = psiconv_write_sheet_file(config,extra_buf,lev+1,
(psiconv_sheet_f) value->object->file)))
goto ERROR2;
break;
*/
default:
psiconv_error(config,lev,0,"Unknown or unsupported object type");
res = -PSICONV_E_GENERATE;
goto ERROR2;
}
if ((res = psiconv_buffer_resolve(extra_buf))) {
psiconv_error(config,lev+1,0,"Internal error resolving buffer references");
goto ERROR2;
}
if ((res = psiconv_buffer_concat(buf,extra_buf))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
psiconv_buffer_free(extra_buf);
psiconv_progress(config,lev,0,"End of embedded object section");
return 0;
ERROR2:
psiconv_buffer_free(extra_buf);
ERROR1:
psiconv_error(config,lev,0,"Writing of embedded object section failed");
return res;
}
int psiconv_write_object_display_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_object_display_section value)
{
int res;
psiconv_progress(config,lev,0,"Writing object display section");
if (!value) {
psiconv_error(config,lev,0,"Null Object Display Section");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if ((res = psiconv_write_u8(config,buf,lev+1,value->show_icon?0x00:0x01)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->width)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->height)))
goto ERROR1;
if ((res = psiconv_write_u32(config,buf,lev+1,0x00000000)))
goto ERROR1;
psiconv_progress(config,lev,0,"End of object display section");
return 0;
ERROR1:
psiconv_error(config,lev,0,"Writing of object display section failed");
return res;
}
int psiconv_write_object_icon_section(const psiconv_config config,
psiconv_buffer buf,int lev,
const psiconv_object_icon_section value)
{
int res;
psiconv_progress(config,lev,0,"Writing object icon section");
if (!value) {
psiconv_error(config,lev,0,"Null Object Icon Section");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if ((res = psiconv_write_string(config,buf,lev+1,value->icon_name)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->icon_width)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->icon_height)))
goto ERROR1;
psiconv_progress(config,lev,0,"End of object icon section");
return 0;
ERROR1:
psiconv_error(config,lev,0,"Writing of object icon section failed");
return res;
}
psiconv-0.9.8/lib/psiconv/generate_texted.c 0000644 0001750 0001750 00000006543 10336374737 015721 0000000 0000000 /*
generate_texted.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "generate_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
int psiconv_write_texted_section(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_texted_section value,
const psiconv_character_layout base_char,
const psiconv_paragraph_layout base_para,
psiconv_buffer *extra_buf)
{
int res,with_layout_section=0;
psiconv_u32 layout_id;
psiconv_progress(config,lev,0,"Writing texted section");
if (!value) {
psiconv_error(config,lev,0,"Null TextEd section");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(*extra_buf = psiconv_buffer_new())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
layout_id = psiconv_buffer_unique_id();
if ((res = psiconv_buffer_add_target(*extra_buf,layout_id))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR2;
}
if (psiconv_list_length(value->paragraphs)) {
with_layout_section = 1;
if ((res = psiconv_write_styleless_layout_section(config,*extra_buf,lev+1,
value->paragraphs,
base_char,base_para)))
goto ERROR2;
}
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_BODY)))
goto ERROR2;
/* Partly dummy TextEd Jumptable */
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_REPLACEMENT)))
goto ERROR2;
if ((res = psiconv_write_u32(config,buf,lev+1,0)))
goto ERROR2;
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_UNKNOWN)))
goto ERROR2;
if ((res = psiconv_write_u32(config,buf,lev+1,0)))
goto ERROR2;
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_LAYOUT)))
goto ERROR2;
if (with_layout_section) {
if ((res = psiconv_write_offset(config,buf,lev+1,layout_id)))
goto ERROR2;
} else {
if ((res = psiconv_write_u32(config,buf,lev+1,0)))
goto ERROR2;
}
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_TEXT)))
goto ERROR2;
if ((res = psiconv_write_text_section(config,buf,lev+1,value->paragraphs)))
goto ERROR2;
psiconv_progress(config,lev,0,"End of texted section");
return 0;
ERROR2:
psiconv_buffer_free(*extra_buf);
ERROR1:
psiconv_error(config,lev,0,"Writing of texted section failed");
return res;
}
psiconv-0.9.8/lib/psiconv/generate_page.c 0000644 0001750 0001750 00000012236 10336374723 015327 0000000 0000000 /*
generate_page.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include
#include "generate_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
int psiconv_write_page_header(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_page_header value,
psiconv_buffer *extra_buf)
{
int res;
psiconv_paragraph_layout basepara;
psiconv_character_layout basechar;
psiconv_progress(config,lev,0,"Writing page header");
if (!value) {
psiconv_error(config,lev,0,"Null page header");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(basepara=psiconv_basic_paragraph_layout())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!(basechar=psiconv_basic_character_layout())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
/* Unknown byte */
if ((res = psiconv_write_u8(config,buf,lev+1,0x01)))
goto ERROR3;
if ((res = psiconv_write_bool(config,buf,lev+1,value->on_first_page)))
goto ERROR3;
/* Three unknown bytes */
if ((res = psiconv_write_u8(config,buf,lev+1,0x00)))
goto ERROR3;
if ((res = psiconv_write_u8(config,buf,lev+1,0x00)))
goto ERROR3;
if ((res = psiconv_write_u8(config,buf,lev+1,0x00)))
goto ERROR3;
if ((res = psiconv_write_paragraph_layout_list(config,buf,lev+1,
value->base_paragraph_layout,basepara)))
goto ERROR3;
if ((res = psiconv_write_character_layout_list(config,buf,lev+1,
value->base_character_layout,basechar)))
goto ERROR3;
res = psiconv_write_texted_section(config,buf,lev+1,value->text,
value->base_character_layout,
value->base_paragraph_layout,extra_buf);
ERROR3:
psiconv_free_character_layout(basechar);
ERROR2:
psiconv_free_paragraph_layout(basepara);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of page header failed");
else
psiconv_progress(config,lev,0,"End of page header");
return res;
}
int psiconv_write_page_layout_section(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_page_layout_section value)
{
int res;
psiconv_buffer header_buf,footer_buf;
psiconv_progress(config,lev,0,"Writing page layout section");
if (!value) {
psiconv_error(config,lev,0,"Null page section");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if ((res = psiconv_write_u32(config,buf,lev+1,value->first_page_nr)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->header_dist)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->footer_dist)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->left_margin)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->right_margin)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->top_margin)))
goto ERROR1;
if ((res = psiconv_write_length(config,buf,lev+1,value->bottom_margin)))
goto ERROR1;
if ((res = psiconv_write_page_header(config,buf,lev+1,value->header,&header_buf)))
goto ERROR1;
if ((res = psiconv_write_page_header(config,buf,lev+1,value->footer,&footer_buf)))
goto ERROR2;
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_PAGE_DIMENSIONS2)))
goto ERROR3;
if ((res = psiconv_write_length(config,buf,lev+1,value->page_width)))
goto ERROR3;
if ((res = psiconv_write_length(config,buf,lev+1,value->page_height)))
goto ERROR3;
if ((res = psiconv_write_bool(config,buf,lev+1,value->landscape)))
goto ERROR3;
if ((res = psiconv_buffer_concat(buf,header_buf))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
if ((res = psiconv_buffer_concat(buf,footer_buf))) {
psiconv_error(config,lev+1,0,"Out of memory error");
goto ERROR3;
}
ERROR3:
psiconv_buffer_free(footer_buf);
ERROR2:
psiconv_buffer_free(header_buf);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of page layout section failed");
else
psiconv_progress(config,lev,0,"End of page layout section");
return res;
}
psiconv-0.9.8/lib/psiconv/generate_word.c 0000644 0001750 0001750 00000015236 10336374740 015370 0000000 0000000 /*
generate_word.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include
#include "generate_routines.h"
#include "error.h"
#ifdef DMALLOC
#include
#endif
int psiconv_write_word_status_section(const psiconv_config config,
psiconv_buffer buf, int lev,
psiconv_word_status_section value)
{
int res;
psiconv_progress(config,lev,0,"Writing word status section");
if (!value) {
psiconv_error(config,lev,0,"Null word status section");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if ((res = psiconv_write_u8(config,buf,lev+1,0x02)))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev+1,(value->show_tabs?0x01:0x00) |
(value->show_spaces?0x02:0x00) |
(value->show_paragraph_ends?0x04:0x00) |
(value->show_line_breaks?0x08:0x00) |
(value->show_hard_minus?0x20:0x00) |
(value->show_hard_space?0x40:0x00))))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev+1,(value->show_full_pictures?0x01:0x00) |
(value->show_full_graphs?0x02:0x00))))
goto ERROR;
if ((res = psiconv_write_bool(config,buf,lev+1,value->show_top_toolbar)))
goto ERROR;
if ((res = psiconv_write_bool(config,buf,lev+1,value->show_side_toolbar)))
goto ERROR;
if ((res = psiconv_write_u8(config,buf,lev+1,(value->fit_lines_to_screen?0x08:0x00))))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,value->cursor_position)))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,value->display_size)))
goto ERROR;
psiconv_progress(config,lev,0,"End of word status section");
return 0;
ERROR:
psiconv_error(config,lev,0,"Writing of word status section failed");
return res;
}
int psiconv_write_word_styles_section(const psiconv_config config,
psiconv_buffer buf, int lev,
psiconv_word_styles_section value)
{
int res,i,j;
psiconv_word_style style;
psiconv_paragraph_layout basepara;
psiconv_character_layout basechar;
psiconv_font font;
psiconv_u32 buflen;
psiconv_progress(config,lev,0,"Writing word styles section");
if (!value || !value->normal || !value->styles) {
psiconv_error(config,lev,0,"Null word styles section");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(basepara=psiconv_basic_paragraph_layout())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
if (!(basechar=psiconv_basic_character_layout())) {
psiconv_error(config,lev+1,0,"Out of memory error");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if ((res = psiconv_write_paragraph_layout_list(config,buf,lev+1,
value->normal->paragraph,
basepara)))
goto ERROR3;
/* Always generate the font for Normal */
font = basechar->font;
basechar->font = NULL;
res = psiconv_write_character_layout_list(config,buf,lev+1,
value->normal->character,
basechar);
basechar->font = font;
if (res)
goto ERROR3;
buflen = psiconv_buffer_length(buf);
if ((res = psiconv_unicode_write_char(config,buf,lev+1,
value->normal->hotkey)))
goto ERROR3;
for (j = psiconv_buffer_length(buf) - buflen; j < 4; j++)
if ((res = psiconv_write_u8(config,buf,lev+1,0)))
goto ERROR3;
if ((res = psiconv_write_u8(config,buf,lev+1,
psiconv_list_length(value->styles))))
goto ERROR3;
for (i = 0; i < psiconv_list_length(value->styles); i++) {
if (!(style = psiconv_list_get(value->styles,i))) {
psiconv_error(config,lev,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR3;
}
buflen = psiconv_buffer_length(buf);
if ((res = psiconv_unicode_write_char(config,buf,lev+1,style->hotkey)))
goto ERROR3;
for (j = psiconv_buffer_length(buf) - buflen; j < 4; j++)
if ((res = psiconv_write_u8(config,buf,lev+1,0)))
goto ERROR3;
}
if ((res = psiconv_write_u8(config,buf,lev+1,psiconv_list_length(value->styles))))
goto ERROR3;
for (i = 0; i < psiconv_list_length(value->styles); i++) {
if (!(style = psiconv_list_get(value->styles,i))) {
psiconv_error(config,lev,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR3;
}
if (!style->name) {
psiconv_error(config,lev,0,"Null style name");
res = -PSICONV_E_GENERATE;
goto ERROR3;
}
if ((res = psiconv_write_string(config,buf,lev+1,style->name)))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,style->built_in?PSICONV_ID_STYLE_BUILT_IN:
PSICONV_ID_STYLE_REMOVABLE)))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,style->outline_level)))
goto ERROR3;
if ((res = psiconv_write_character_layout_list(config,buf,lev+1,style->character,
value->normal->character)))
goto ERROR3;
if ((res = psiconv_write_paragraph_layout_list(config,buf,lev+1,style->paragraph,
value->normal->paragraph)))
goto ERROR3;
}
for (i = 0; i < psiconv_list_length(value->styles); i++)
if ((res = psiconv_write_u8(config,buf,lev+1,0xff)))
goto ERROR3;
res = -PSICONV_E_OK;
ERROR3:
psiconv_free_character_layout(basechar);
ERROR2:
psiconv_free_paragraph_layout(basepara);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of word styles section failed");
else
psiconv_progress(config,lev,0,"End of word styles section");
return res;
}
psiconv-0.9.8/lib/psiconv/generate_image.c 0000644 0001750 0001750 00000071051 10336374715 015476 0000000 0000000 /*
generate_image.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include "generate_routines.h"
#include "error.h"
#include "list.h"
#include "image.h"
#ifdef DMALLOC
#include
#endif
static int psiconv_collect_pixel_data(psiconv_pixel_ints *pixels,
int xsize,int ysize,
const psiconv_pixel_floats_t data,
int colordepth,int color,
int redbits,int greenbits,int bluebits,
const psiconv_pixel_floats_t palet);
static int psiconv_pixel_data_to_bytes(const psiconv_config config,int lev,
psiconv_pixel_bytes *bytes, int xsize,
int ysize, const psiconv_pixel_ints pixels,
int colordepth);
static int psiconv_encode_rle8(const psiconv_config config,
const psiconv_pixel_bytes plain_bytes,
psiconv_pixel_bytes *encoded_bytes);
static int psiconv_encode_rle12(const psiconv_config config,
const psiconv_pixel_bytes plain_bytes,
psiconv_pixel_bytes *encoded_bytes);
static int psiconv_encode_rle16(const psiconv_config config,
const psiconv_pixel_bytes plain_bytes,
psiconv_pixel_bytes *encoded_bytes);
static int psiconv_encode_rle24(const psiconv_config config,
const psiconv_pixel_bytes plain_bytes,
psiconv_pixel_bytes *encoded_bytes);
int psiconv_write_paint_data_section(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_paint_data_section value,
int is_clipart)
{
int res,colordepth,i;
psiconv_pixel_ints ints;
psiconv_pixel_floats_t floats,palet;
psiconv_list bytes,bytes_rle;
psiconv_u8 *byteptr,encoding;
psiconv_progress(config,lev,0,"Writing paint data section");
/* First, we check whether we can cope with the current configuration.
If not, we stop at once */
if ((config->colordepth != 2) && (config->colordepth != 4) &&
(config->colordepth != 8) && (config->colordepth != 12) &&
(config->colordepth != 16) && (config->colordepth != 24)) {
psiconv_error(config,lev,0,
"Unsupported color depth (%d); try 2, 4, 8, 16 or 24",
config->colordepth);
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if ((config->color) &&
(config->bluebits || config->redbits || config->greenbits) &&
(config->bluebits+config->redbits+config->greenbits!=config->colordepth)) {
psiconv_error(config,lev,0,
"Sum of red (%d), green (%d) and blue (%d) bits should be "
"equal to the color depth (%d)",
config->redbits,config->greenbits,config->bluebits,
config->colordepth);
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (config->color &&
!(config->redbits || config->greenbits || config->bluebits) &&
(config->colordepth != 4) && (config->colordepth != 8)) {
psiconv_error(config,lev,0,
"Current color depth (%d) has no palet associated with it",
config->colordepth);
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (config->color || (config->colordepth != 2))
psiconv_warn(config,lev,0,
"All image types except 2-bit greyscale are experimental!");
if (!value) {
psiconv_error(config,lev,0,"Null paint data section");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
floats.red = value->red;
floats.green = value->green;
floats.blue = value->blue;
floats.length = value->xsize * value->ysize;
palet = psiconv_palet_none;
if ((config->color) && (config->redbits == 0) && (config->greenbits == 0) &&
(config->bluebits == 0))
switch (config->colordepth) {
case 4: palet = psiconv_palet_color_4; break;
case 8: palet = psiconv_palet_color_8; break;
default: palet = psiconv_palet_none; break;
}
if ((res = psiconv_collect_pixel_data(&ints,value->xsize,
value->ysize,floats,
config->colordepth,config->color,
config->redbits,config->greenbits,
config->bluebits,palet))) {
psiconv_error(config,lev,0,"Error collecting pixel data");
goto ERROR1;
}
if ((res = psiconv_pixel_data_to_bytes(config,lev+1,&bytes,value->xsize,
value->ysize,ints,
config->colordepth))) {
psiconv_error(config,lev,0,"Error translating pixel data to bytes");
goto ERROR2;
}
switch (config->colordepth) {
case 2:
case 4:
case 8:
encoding = 0x01;
if ((res = psiconv_encode_rle8(config,bytes,&bytes_rle))) {
psiconv_error(config,lev,0,"Error encoding RLE8");
goto ERROR3;
}
break;
case 12:
encoding = 0x02;
if ((res = psiconv_encode_rle12(config,bytes,&bytes_rle))) {
psiconv_error(config,lev,0,"Error encoding RLE12");
goto ERROR3;
}
break;
case 16:
encoding = 0x03;
if ((res = psiconv_encode_rle16(config,bytes,&bytes_rle))) {
psiconv_error(config,lev,0,"Error encoding RLE16");
goto ERROR3;
}
break;
case 24:
encoding = 0x04;
if ((res = psiconv_encode_rle24(config,bytes,&bytes_rle))) {
psiconv_error(config,lev,0,"Error encoding RLE24");
goto ERROR3;
}
break;
default:
encoding = 0x00;
}
if (encoding) {
if (psiconv_list_length(bytes_rle) < psiconv_list_length(bytes)) {
psiconv_list_free(bytes);
bytes = bytes_rle;
} else {
psiconv_list_free(bytes_rle);
encoding = 0x00;
}
}
if ((res = psiconv_write_u32(config,buf,lev+1,
0x28+psiconv_list_length(bytes))))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,0x28)))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,value->xsize)))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,value->ysize)))
goto ERROR3;
if ((res = psiconv_write_length(config,buf,lev+1,value->pic_xsize)))
goto ERROR3;
if ((res = psiconv_write_length(config,buf,lev+1,value->pic_ysize)))
goto ERROR3;
colordepth = config->colordepth;
if ((res = psiconv_write_u32(config,buf,lev+1,colordepth)))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,(config->color?1:0))))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,0)))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,encoding)))
goto ERROR3;
if (is_clipart) {
if ((res = psiconv_write_u32(config,buf,lev+1,0xffffffff)))
goto ERROR3;
if ((res = psiconv_write_u32(config,buf,lev+1,0x00000044)))
goto ERROR3;
}
for (i = 0; i < psiconv_list_length(bytes); i++) {
if (!(byteptr = psiconv_list_get(bytes,i)))
goto ERROR3;
if ((res = psiconv_write_u8(config,buf,lev+1,*byteptr)))
goto ERROR3;
}
ERROR3:
psiconv_list_free(bytes);
ERROR2:
psiconv_list_free(ints);
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of paint data section failed");
else
psiconv_progress(config,lev,0,"End of paint data section");
return res;
}
/* Translate the floating point RGB information into pixel values.
The palet is optional; without it, we just use the
colordepth. With a large palet this is not very fast, but it will do for
now. For greyscale pictures, just use the palet. */
int psiconv_collect_pixel_data(psiconv_pixel_ints *pixels,int xsize,int ysize,
const psiconv_pixel_floats_t data,
int colordepth,int color,
int redbits,int bluebits,int greenbits,
const psiconv_pixel_floats_t palet)
{
int res,x,y,i;
psiconv_u32 index,pixel;
float p_red,p_green,p_blue,dist,new_dist;
if (!(*pixels = psiconv_list_new(sizeof(psiconv_u32)))) {
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
for (y = 0; y < ysize; y++) {
for (x = 0; x < xsize; x++) {
index = y*xsize+x;
p_red = data.red[index];
p_green = data.green[index];
p_blue = data.blue[index];
if (!palet.length) {
if (color)
pixel = (((psiconv_u32) (p_red * (1 << redbits) + 0.5))
<< (greenbits+bluebits)) +
(((psiconv_u32) (p_green * (1 << greenbits) + 0.5))
<< bluebits) +
((psiconv_u32) (p_blue * (1 << bluebits) + 0.5));
else
pixel = (0.212671 * p_red + 0.715160 * p_green + 0.072169 * p_blue) * ((1 << colordepth) * 0.999);
} else {
dist = 4; /* Max distance is 3, so this is safe */
pixel = -1;
for (i = 0; i < palet.length; i++) {
new_dist = (p_red - palet.red[i]) * (p_red - palet.red[i]) +
(p_green - palet.green[i]) * (p_green - palet.green[i]) +
(p_blue - palet.blue[i]) * (p_blue - palet.blue[i]);
if (new_dist < dist) {
pixel = i;
dist = new_dist;
}
}
}
if ((res = psiconv_list_add(*pixels,&pixel)))
goto ERROR2;
}
}
return 0;
ERROR2:
psiconv_list_free(*pixels);
ERROR1:
return res;
}
int psiconv_pixel_data_to_bytes(const psiconv_config config,int lev,
psiconv_pixel_bytes *bytes, int xsize,
int ysize, const psiconv_pixel_ints pixels,
int colordepth)
{
int res;
int x,y;
psiconv_u32 inputdata;
psiconv_u8 outputbyte;
psiconv_u32 *pixelptr;
int inputbitsleft,outputbitnr,bitsfit,outputbytenr;
if (!bytes) {
psiconv_error(config,lev,0,"NULL pixel data");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!pixels) {
psiconv_error(config,lev,0,"NULL pixel data");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (psiconv_list_length(pixels) != xsize * ysize) {
psiconv_error(config,lev,0,"Pixel number is not correct");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if (!(*bytes = psiconv_list_new(sizeof(psiconv_u8)))) {
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
outputbitnr = 0;
outputbyte = 0;
for (y = 0; y < ysize; y++) {
outputbytenr = 0;
for (x = 0; x < xsize; x++) {
if (!(pixelptr = psiconv_list_get(pixels,y*xsize+x))) {
psiconv_error(config,lev,0,"Data structure corruption");
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
inputbitsleft = colordepth;
inputdata = *pixelptr;
while (inputbitsleft) {
bitsfit = (inputbitsleft+outputbitnr<=8?inputbitsleft:8-outputbitnr);
outputbyte |= (inputdata & ((1 << bitsfit) - 1)) << outputbitnr;
inputdata = inputdata >> bitsfit;
inputbitsleft -= bitsfit;
outputbitnr += bitsfit;
if (outputbitnr == 8) {
if ((res = psiconv_list_add(*bytes,&outputbyte)))
goto ERROR2;
outputbitnr = 0;
outputbyte = 0;
outputbytenr ++;
}
}
}
/* Always end lines on a long border */
if (outputbitnr != 0) {
if ((res = psiconv_list_add(*bytes,&outputbyte)))
goto ERROR2;
outputbitnr = 0;
outputbyte = 0;
outputbytenr ++;
}
while (outputbytenr % 0x04) {
if ((res = psiconv_list_add(*bytes,&outputbyte)))
goto ERROR2;
outputbytenr ++;
}
}
return 0;
ERROR2:
psiconv_list_free(*bytes);
ERROR1:
return res;
}
/* RLE8 encoding:
Marker bytes followed by one or more data bytes.
Marker value 0x00-0x7f: repeat the next data byte (marker+1) times
Marker value 0xff-0x80: (0x100-marker) data bytes follow */
int psiconv_encode_rle8(const psiconv_config config,
const psiconv_pixel_bytes plain_bytes,
psiconv_pixel_bytes *encoded_bytes)
{
int res,i,j,len;
psiconv_u8 *entry,*next;
psiconv_u8 temp;
if (!(*encoded_bytes = psiconv_list_new(sizeof(*entry)))) {
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
for (i = 0; i < psiconv_list_length(plain_bytes);) {
if (!(entry = psiconv_list_get(plain_bytes,i))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next = psiconv_list_get(plain_bytes,i+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (i == psiconv_list_length(plain_bytes) - 2) {
temp = 0xfe;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next)))
goto ERROR2;
i +=2;
} else if (*next == *entry) {
len = 1;
while ((*next == *entry) &&
(i+len + 2 < psiconv_list_length(plain_bytes)) &&
len < 0x80) {
len ++;
if (!(next = psiconv_list_get(plain_bytes,i+len))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
}
temp = len - 1;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry)))
goto ERROR2;
i += len;
} else {
len = 1;
while ((*next != *entry) &&
(i+len+1 < psiconv_list_length(plain_bytes)) &&
len < 0x80) {
len ++;
entry = next;
if (!(next = psiconv_list_get(plain_bytes,i+len))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
}
len --;
temp = 0x100 - len;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
for (j = 0; j < len; j++) {
if (!(next = psiconv_list_get(plain_bytes,i+j))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if ((res = psiconv_list_add(*encoded_bytes,next)))
goto ERROR2;
}
i += len;
}
}
return 0;
ERROR2:
psiconv_list_free(*encoded_bytes);
ERROR1:
return res;
}
/* RLE12 encoding:
Word based. The 12 least significant bits contain the pixel colors.
the 4 most signigicant bits are the number of repetitions minus 1 */
int psiconv_encode_rle12(const psiconv_config config,
const psiconv_pixel_bytes plain_bytes,
psiconv_pixel_bytes *encoded_bytes)
{
typedef psiconv_list psiconv_word_data; /* of psiconv_u16 */
psiconv_word_data data;
int res,i,len,location;
psiconv_u16 *word_entry,*word_next;
psiconv_u16 word_data;
psiconv_u8 byte_temp;
psiconv_u8 *byte_entry;
/* First extract the 12-bit values to encode */
if (!(data = psiconv_list_new(sizeof(psiconv_u16)))) {
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
for (i = 0; i < psiconv_list_length(plain_bytes); i++) {
if (!(byte_entry = psiconv_list_get(plain_bytes,i))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
location = 0;
if (location == 0) {
word_data = *byte_entry;
location ++;
} else if (location == 1) {
word_data = (word_data << 4) + (*byte_entry & 0x0f);
if ((res = psiconv_list_add(data,&word_data)))
goto ERROR2;
word_data = *byte_entry >> 4;
location ++;
} else {
word_data = (word_data << 8) + *byte_entry;
if ((res = psiconv_list_add(data,&word_data)))
goto ERROR2;
location = 0;
}
}
if (!(*encoded_bytes = psiconv_list_new(sizeof(psiconv_u8)))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
for (i = 0; i < psiconv_list_length(data);) {
if (!(word_entry = psiconv_list_get(data,i))) {
res = -PSICONV_E_NOMEM;
goto ERROR3;
}
if (!(word_next = psiconv_list_get(data,i+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR3;
}
if (i == psiconv_list_length(data) - 2) {
byte_temp = *word_entry && 0xff;
if ((res = psiconv_list_add(*encoded_bytes,&byte_temp)))
goto ERROR3;
byte_temp = *word_entry >> 8;
if ((res = psiconv_list_add(*encoded_bytes,&byte_temp)))
goto ERROR3;
byte_temp = *word_next && 0xff;
if ((res = psiconv_list_add(*encoded_bytes,&byte_temp)))
goto ERROR3;
byte_temp = *word_next >> 8;
if ((res = psiconv_list_add(*encoded_bytes,&byte_temp)))
goto ERROR3;
i += 2;
}
len = 0;
while ((*word_entry == *word_next) && (len < 16) &&
(i+len+1 < psiconv_list_length(data))) {
len ++;
if (!(word_next = psiconv_list_get(data,i+len))) {
res = -PSICONV_E_NOMEM;
goto ERROR3;
}
}
byte_temp = *word_entry && 0xff;
if ((res = psiconv_list_add(*encoded_bytes,&byte_temp)))
goto ERROR3;
byte_temp = (*word_entry >> 8) + ((len - 1) << 4);
if ((res = psiconv_list_add(*encoded_bytes,&byte_temp)))
goto ERROR3;
i += len;
}
return 0;
ERROR3:
psiconv_list_free(*encoded_bytes);
ERROR2:
psiconv_list_free(data);
ERROR1:
return res;
}
/* RLE16 encoding:
Marker bytes followed by one or more data words.
Marker value 0x00-0x7f: repeat the next data word (marker+1) times
Marker value 0xff-0x80: (0x100-marker) data words follow */
int psiconv_encode_rle16(const psiconv_config config,
const psiconv_pixel_bytes plain_bytes,
psiconv_pixel_bytes *encoded_bytes)
{
int res,i,j,len;
psiconv_u8 *entry1,*entry2,*next1,*next2;
psiconv_u8 temp;
if (!(*encoded_bytes = psiconv_list_new(sizeof(*entry1)))) {
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
for (i = 0; i < psiconv_list_length(plain_bytes);) {
if (!(entry1 = psiconv_list_get(plain_bytes,i))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(entry2 = psiconv_list_get(plain_bytes,i+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next1 = psiconv_list_get(plain_bytes,i+2))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+3))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (i == psiconv_list_length(plain_bytes) - 4) {
temp = 0xfe;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry1)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry2)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next1)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next2)))
goto ERROR2;
i +=4;
} else if ((*next1 == *entry1) && (*next2 == *entry2)) {
len = 0;
while (((*next1 == *entry1) && (*next2 == *entry2)) &&
(i+2*len + 4 < psiconv_list_length(plain_bytes)) &&
len < 0x80) {
len ++;
if (!(next1 = psiconv_list_get(plain_bytes,i+len*2))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+len*2+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
}
temp = len - 1;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry1)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry2)))
goto ERROR2;
i += len*2;
} else {
len = 1;
while (((*next1 != *entry1) || (*next2 != *entry2))&&
(i+len*2+4 < psiconv_list_length(plain_bytes)) &&
len < 0x80) {
len ++;
entry1 = next1;
entry2 = next2;
if (!(next1 = psiconv_list_get(plain_bytes,i+len*2))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+len*2+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
}
len --;
temp = 0x100 - len;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
for (j = 0; j < len; j++) {
if (!(next1 = psiconv_list_get(plain_bytes,i+j*2))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+j*2+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if ((res = psiconv_list_add(*encoded_bytes,next1)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next2)))
goto ERROR2;
}
i += len*2;
}
}
return 0;
ERROR2:
psiconv_list_free(*encoded_bytes);
ERROR1:
return res;
}
/* RLE24 encoding:
Marker bytes followed by one or more data byte-triplets.
Marker value 0x00-0x7f: repeat the next data byte-triplets (marker+1) times
Marker value 0xff-0x80: (0x100-marker) data byte-triplets follow */
int psiconv_encode_rle24(const psiconv_config config,
const psiconv_pixel_bytes plain_bytes,
psiconv_pixel_bytes *encoded_bytes)
{
int res,i,j,len;
psiconv_u8 *entry1,*entry2,*entry3,*next1,*next2,*next3;
psiconv_u8 temp;
if (!(*encoded_bytes = psiconv_list_new(sizeof(*entry1)))) {
res = -PSICONV_E_NOMEM;
goto ERROR1;
}
for (i = 0; i < psiconv_list_length(plain_bytes);) {
if (!(entry1 = psiconv_list_get(plain_bytes,i))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(entry2 = psiconv_list_get(plain_bytes,i+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(entry3 = psiconv_list_get(plain_bytes,i+2))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next1 = psiconv_list_get(plain_bytes,i+3))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+4))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next3 = psiconv_list_get(plain_bytes,i+5))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (i == psiconv_list_length(plain_bytes) - 6) {
temp = 0xfe;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry1)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry2)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry3)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next1)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next2)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next3)))
goto ERROR2;
i +=4;
} else if ((*next1 == *entry1) && (*next2 == *entry2) &&
(*next3 == *entry3)) {
len = 0;
while (((*next1 == *entry1) && (*next2 == *entry2) &&
(*next3 == *entry3)) &&
(i+3*len + 6 < psiconv_list_length(plain_bytes)) &&
len < 0x80) {
len ++;
if (!(next1 = psiconv_list_get(plain_bytes,i+len*3))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+len*3+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next3 = psiconv_list_get(plain_bytes,i+len*3+2))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
}
temp = len - 1;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry1)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry2)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,entry3)))
goto ERROR2;
i += len*3;
} else {
len = 1;
while (((*next1 != *entry1) || (*next2 != *entry2) ||
(*next3 != *entry3)) &&
(i+len*3+6 < psiconv_list_length(plain_bytes)) &&
len < 0x80) {
len ++;
entry1 = next1;
entry2 = next2;
entry3 = next3;
if (!(next1 = psiconv_list_get(plain_bytes,i+len*3))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+len*3+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next3 = psiconv_list_get(plain_bytes,i+len*3+2))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
}
len --;
temp = 0x100 - len;
if ((res = psiconv_list_add(*encoded_bytes,&temp)))
goto ERROR2;
for (j = 0; j < len; j++) {
if (!(next1 = psiconv_list_get(plain_bytes,i+j*3))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+j*3+1))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if (!(next2 = psiconv_list_get(plain_bytes,i+j*3+2))) {
res = -PSICONV_E_NOMEM;
goto ERROR2;
}
if ((res = psiconv_list_add(*encoded_bytes,next1)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next2)))
goto ERROR2;
if ((res = psiconv_list_add(*encoded_bytes,next3)))
goto ERROR2;
}
i += len*3;
}
}
return 0;
ERROR2:
psiconv_list_free(*encoded_bytes);
ERROR1:
return res;
}
int psiconv_write_sketch_section(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_sketch_section value)
{
int res;
psiconv_progress(config,lev,0,"Writing sketch section");
if (!value) {
psiconv_error(config,lev,0,"NULL sketch section");
res = -PSICONV_E_GENERATE;
goto ERROR1;
}
if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_xsize)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_ysize)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->picture_data_x_offset)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->picture_data_y_offset)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_size_x_offset)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_size_y_offset)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->form_xsize)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->form_ysize)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,0x0000)))
goto ERROR1;
if ((res = psiconv_write_paint_data_section(config,buf,lev+1,value->picture,0)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->magnification_x * 0x03e8)))
goto ERROR1;
if ((res = psiconv_write_u16(config,buf,lev+1,value->magnification_y * 0x03e8)))
goto ERROR1;
if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_left * 0x0c *
value->displayed_xsize)))
goto ERROR1;
if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_right * 0x0c *
value->displayed_xsize)))
goto ERROR1;
if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_top * 0x0c *
value->displayed_ysize)))
goto ERROR1;
if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_bottom * 0x0c *
value->displayed_ysize)))
goto ERROR1;
ERROR1:
if (res)
psiconv_error(config,lev,0,"Writing of sketch section failed");
else
psiconv_progress(config,lev,0,"End of sketch section");
return res;
}
int psiconv_write_clipart_section(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_clipart_section value)
{
int res;
psiconv_progress(config,lev,0,"Writing clipart section");
if (!value) {
psiconv_error(config,lev,0, "NULL Clipart Section");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_CLIPART_ITEM)))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,0x00000002)))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,0x00000000)))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,0x00000000)))
goto ERROR;
if ((res = psiconv_write_u32(config,buf,lev+1,0x0000000C)))
goto ERROR;
if ((res = psiconv_write_paint_data_section(config,buf,lev+1,value->picture,1)))
goto ERROR;
ERROR:
if (res)
psiconv_error(config,lev,0,"Writing of clipart section failed");
else
psiconv_progress(config,lev,0,"End of clipart section");
return res;
}
int psiconv_write_jumptable_section(const psiconv_config config,
psiconv_buffer buf, int lev,
const psiconv_jumptable_section value)
{
int res,i;
psiconv_u32 *offset_ptr;
psiconv_progress(config,lev,0,"Writing jumptable section");
if (!value) {
psiconv_error(config,lev,0,"NULL Jumptable Section");
res = -PSICONV_E_GENERATE;
goto ERROR;
}
if ((res = psiconv_write_u32(config,buf,lev+1,psiconv_list_length(value))))
goto ERROR;
for (i = 0; i < psiconv_list_length(value); i++) {
if (!(offset_ptr = psiconv_list_get(value,i))) {
psiconv_error(config,lev,0,"Massive memory corruption");
res = -PSICONV_E_NOMEM;
goto ERROR;
}
if ((res = psiconv_write_offset(config,buf,lev+1,*offset_ptr)))
goto ERROR;
}
ERROR:
if (res)
psiconv_error(config,lev,0,"Writing of jumptable section failed");
else
psiconv_progress(config,lev,0,"End of jumptable section");
return res;
}
psiconv-0.9.8/lib/Makefile.am 0000644 0001750 0001750 00000000022 07655260342 012737 0000000 0000000 SUBDIRS = psiconv
psiconv-0.9.8/lib/Makefile.in 0000664 0001750 0001750 00000033130 10336413006 012743 0000000 0000000 # Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = lib
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOCS_FALSE = @ASCIIDOCS_FALSE@
ASCIIDOCS_TRUE = @ASCIIDOCS_TRUE@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
HTML4DOCS_FALSE = @HTML4DOCS_FALSE@
HTML4DOCS_TRUE = @HTML4DOCS_TRUE@
IMAGEMAGICK = @IMAGEMAGICK@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INT_16_BIT = @INT_16_BIT@
INT_32_BIT = @INT_32_BIT@
INT_8_BIT = @INT_8_BIT@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_DMALLOC = @LIB_DMALLOC@
LIB_MAGICK = @LIB_MAGICK@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PSICONVETCDIR = @PSICONVETCDIR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XHTMLDOCS_FALSE = @XHTMLDOCS_FALSE@
XHTMLDOCS_TRUE = @XHTMLDOCS_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
cflags_set = @cflags_set@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = psiconv
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu lib/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-libtool clean-recursive ctags \
ctags-recursive distclean distclean-generic distclean-libtool \
distclean-recursive distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-libtool \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
psiconv-0.9.8/program/ 0000777 0001750 0001750 00000000000 10336611560 011666 5 0000000 0000000 psiconv-0.9.8/program/psiconv-config/ 0000777 0001750 0001750 00000000000 10336611560 014612 5 0000000 0000000 psiconv-0.9.8/program/psiconv-config/Makefile.am 0000644 0001750 0001750 00000000321 10012204517 016545 0000000 0000000 INCLUDES=-I../.. -I../../lib -I../../compat
bin_SCRIPTS = psiconv-config
BUILT_SOURCES = psiconv-config psiconv-config.man
man1_MANS = psiconv-config.man
EXTRA_DIST = psiconv-config.in psiconv-config.man.in
psiconv-0.9.8/program/psiconv-config/Makefile.in 0000664 0001750 0001750 00000027632 10336413010 016575 0000000 0000000 # Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = program/psiconv-config
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/psiconv-config.in $(srcdir)/psiconv-config.man.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = psiconv-config psiconv-config.man
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
SCRIPTS = $(bin_SCRIPTS)
SOURCES =
DIST_SOURCES =
man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(man1_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOCS_FALSE = @ASCIIDOCS_FALSE@
ASCIIDOCS_TRUE = @ASCIIDOCS_TRUE@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
HTML4DOCS_FALSE = @HTML4DOCS_FALSE@
HTML4DOCS_TRUE = @HTML4DOCS_TRUE@
IMAGEMAGICK = @IMAGEMAGICK@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INT_16_BIT = @INT_16_BIT@
INT_32_BIT = @INT_32_BIT@
INT_8_BIT = @INT_8_BIT@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_DMALLOC = @LIB_DMALLOC@
LIB_MAGICK = @LIB_MAGICK@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PSICONVETCDIR = @PSICONVETCDIR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XHTMLDOCS_FALSE = @XHTMLDOCS_FALSE@
XHTMLDOCS_TRUE = @XHTMLDOCS_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
cflags_set = @cflags_set@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
INCLUDES = -I../.. -I../../lib -I../../compat
bin_SCRIPTS = psiconv-config
BUILT_SOURCES = psiconv-config psiconv-config.man
man1_MANS = psiconv-config.man
EXTRA_DIST = psiconv-config.in psiconv-config.man.in
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu program/psiconv-config/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu program/psiconv-config/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
psiconv-config: $(top_builddir)/config.status $(srcdir)/psiconv-config.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
psiconv-config.man: $(top_builddir)/config.status $(srcdir)/psiconv-config.man.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_SCRIPTS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f $$d$$p; then \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
else :; fi; \
done
uninstall-binSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(bin_SCRIPTS)'; for p in $$list; do \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-man1: $(man1_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)"
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
done
uninstall-man1:
@$(NORMAL_UNINSTALL)
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile $(SCRIPTS) $(MANS)
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-exec-am: install-binSCRIPTS
install-info: install-info-am
install-man: install-man1
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binSCRIPTS uninstall-info-am uninstall-man
uninstall-man: uninstall-man1
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am html html-am info info-am install install-am \
install-binSCRIPTS install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-man1 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am uninstall uninstall-am uninstall-binSCRIPTS \
uninstall-info-am uninstall-man uninstall-man1
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
psiconv-0.9.8/program/psiconv-config/psiconv-config.in 0000644 0001750 0001750 00000002454 10011534243 017777 0000000 0000000 #!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
exec_prefix_set=no
usage()
{
cat <&2
fi
lib_psiconv=yes
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
prefix=$optarg
if test $exec_prefix_set = no ; then
exec_prefix=$optarg
fi
;;
--prefix)
echo_prefix=yes
;;
--exec-prefix=*)
exec_prefix=$optarg
exec_prefix_set=yes
;;
--exec-prefix)
echo_exec_prefix=yes
;;
--version)
echo @VERSION@
exit 0
;;
--cflags)
echo_cflags=yes
;;
--libs)
echo_libs=yes
;;
psiconv)
lib_psiconv=yes
;;
*)
usage 1 1>&2
;;
esac
shift
done
if test "$echo_prefix" = "yes"; then
echo $prefix
fi
if test "$echo_exec_prefix" = "yes"; then
echo $exec_prefix
fi
if test "$echo_cflags" = "yes"; then
echo -I@includedir@
fi
if test "$echo_libs" = "yes"; then
libsp=""
if test "$lib_psiconv" = "yes"; then
libsp="$libsp -lpsiconv"
fi
echo -L@libdir@ $libsp
fi
psiconv-0.9.8/program/psiconv-config/psiconv-config.man.in 0000644 0001750 0001750 00000004155 10012205225 020545 0000000 0000000 .TH PSICONV 1 "10 February 2004" Version @VERSION@
.SH NAME
psiconv-config - script to get information about the installed version of Psiconv
.SH SYNOPSIS
.B psiconv-config [\-\-prefix\fI[=DIR]\fP] [\-\-exec\-prefix\fI[=DIR]\fP] [\-\-version] [\-\-libs] [\-\-cflags] [LIBRARIES]
.SH DESCRIPTION
.PP
\fIpsiconv-config\fP is a tool that is used to configure to determine
the compiler and linker flags that should be used to compile
and link programs that use \fIpsiconv\fP. It is also used internally
to the .m4 macros for GNU autoconf that are included with \fIpsiconv\fP.
.
.SH OPTIONS
.l
\fIpsiconv-config\fP accepts the following options:
.TP 8
.B LIBRARIES
\fIPsiconv\fP has one library 'psiconv'. If you specify one of
them, only the appropriate things for that library will be printed.
.TP 8
.B \-\-version
Print the currently installed version of \fIpsiconv\fP on the standard output.
.TP 8
.B \-\-libs
Print the linker flags that are necessary to link a \fIpsiconv\fP program.
.TP 8
.B \-\-cflags
Print the compiler flags that are necessary to compile a \fIpsiconv\fP program.
.TP 8
.B \-\-prefix=PREFIX
If specified, use PREFIX instead of the installation prefix that \fIpsiconv\fP
was built with when computing the output for the \-\-cflags and
\-\-libs options. This option is also used for the exec prefix
if \-\-exec\-prefix was not specified. This option must be specified
before any \-\-libs or \-\-cflags options.
.TP 8
.B \-\-exec\-prefix=PREFIX
If specified, use PREFIX instead of the installation exec prefix that
\fIpsiconv\fP was built with when computing the output for the \-\-cflags
and \-\-libs options. This option must be specified before any
\-\-libs or \-\-cflags options.
.SH SEE ALSO
.BR gtk-config (1),
.BR gimp (1),
.BR gimptool (1)
.SH COPYRIGHT
Copyright \(co 1998 Owen Taylor, Copyright \(co 2004 Frodo Looijaard.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation.
psiconv-0.9.8/program/Makefile.am 0000644 0001750 0001750 00000000047 10012001541 013616 0000000 0000000 SUBDIRS = psiconv psiconv-config extra
psiconv-0.9.8/program/Makefile.in 0000664 0001750 0001750 00000033171 10336413007 013652 0000000 0000000 # Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = program
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOCS_FALSE = @ASCIIDOCS_FALSE@
ASCIIDOCS_TRUE = @ASCIIDOCS_TRUE@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
HTML4DOCS_FALSE = @HTML4DOCS_FALSE@
HTML4DOCS_TRUE = @HTML4DOCS_TRUE@
IMAGEMAGICK = @IMAGEMAGICK@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INT_16_BIT = @INT_16_BIT@
INT_32_BIT = @INT_32_BIT@
INT_8_BIT = @INT_8_BIT@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_DMALLOC = @LIB_DMALLOC@
LIB_MAGICK = @LIB_MAGICK@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PSICONVETCDIR = @PSICONVETCDIR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XHTMLDOCS_FALSE = @XHTMLDOCS_FALSE@
XHTMLDOCS_TRUE = @XHTMLDOCS_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
cflags_set = @cflags_set@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = psiconv psiconv-config extra
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu program/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu program/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-libtool clean-recursive ctags \
ctags-recursive distclean distclean-generic distclean-libtool \
distclean-recursive distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-libtool \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
psiconv-0.9.8/program/psiconv/ 0000777 0001750 0001750 00000000000 10336611560 013347 5 0000000 0000000 psiconv-0.9.8/program/psiconv/Makefile.am 0000644 0001750 0001750 00000000617 10007511060 015310 0000000 0000000 INCLUDES=-I../.. -I../../lib -I../../compat
bin_PROGRAMS = psiconv
psiconv_SOURCES = psiconv.c general.c magick-aux.c \
gen_txt.c gen_image.c gen_xhtml.c gen_html4.c
psiconv_LDADD = ../../lib/psiconv/libpsiconv.la @LIB_MAGICK@ @LIB_DMALLOC@
psiconv_noinstHEADERS = gen.h psiconv.h magick-aux.h general.h
man1_MANS = psiconv.man
EXTRA_DIST = gen.h psiconv.h magick-aux.h general.h psiconv.man
psiconv-0.9.8/program/psiconv/Makefile.in 0000664 0001750 0001750 00000041642 10336413010 015327 0000000 0000000 # Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(psiconv_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
bin_PROGRAMS = psiconv$(EXEEXT)
subdir = program/psiconv
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_psiconv_OBJECTS = psiconv.$(OBJEXT) general.$(OBJEXT) \
magick-aux.$(OBJEXT) gen_txt.$(OBJEXT) gen_image.$(OBJEXT) \
gen_xhtml.$(OBJEXT) gen_html4.$(OBJEXT)
psiconv_OBJECTS = $(am_psiconv_OBJECTS)
psiconv_DEPENDENCIES = ../../lib/psiconv/libpsiconv.la
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/gen_html4.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/gen_image.Po ./$(DEPDIR)/gen_txt.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/gen_xhtml.Po ./$(DEPDIR)/general.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/magick-aux.Po ./$(DEPDIR)/psiconv.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(psiconv_SOURCES)
DIST_SOURCES = $(psiconv_SOURCES)
man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(man1_MANS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOCS_FALSE = @ASCIIDOCS_FALSE@
ASCIIDOCS_TRUE = @ASCIIDOCS_TRUE@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
HTML4DOCS_FALSE = @HTML4DOCS_FALSE@
HTML4DOCS_TRUE = @HTML4DOCS_TRUE@
IMAGEMAGICK = @IMAGEMAGICK@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INT_16_BIT = @INT_16_BIT@
INT_32_BIT = @INT_32_BIT@
INT_8_BIT = @INT_8_BIT@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_DMALLOC = @LIB_DMALLOC@
LIB_MAGICK = @LIB_MAGICK@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PSICONVETCDIR = @PSICONVETCDIR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XHTMLDOCS_FALSE = @XHTMLDOCS_FALSE@
XHTMLDOCS_TRUE = @XHTMLDOCS_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
cflags_set = @cflags_set@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
INCLUDES = -I../.. -I../../lib -I../../compat
psiconv_SOURCES = psiconv.c general.c magick-aux.c \
gen_txt.c gen_image.c gen_xhtml.c gen_html4.c
psiconv_LDADD = ../../lib/psiconv/libpsiconv.la @LIB_MAGICK@ @LIB_DMALLOC@
psiconv_noinstHEADERS = gen.h psiconv.h magick-aux.h general.h
man1_MANS = psiconv.man
EXTRA_DIST = gen.h psiconv.h magick-aux.h general.h psiconv.man
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu program/psiconv/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu program/psiconv/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
|| test -f $$p1 \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
psiconv$(EXEEXT): $(psiconv_OBJECTS) $(psiconv_DEPENDENCIES)
@rm -f psiconv$(EXEEXT)
$(LINK) $(psiconv_LDFLAGS) $(psiconv_OBJECTS) $(psiconv_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_html4.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_image.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_txt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_xhtml.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/general.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/magick-aux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psiconv.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-man1: $(man1_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)"
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
done
uninstall-man1:
@$(NORMAL_UNINSTALL)
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(MANS)
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-exec-am: install-binPROGRAMS
install-info: install-info-am
install-man: install-man1
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man
uninstall-man: uninstall-man1
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic clean-libtool ctags distclean distclean-compile \
distclean-generic distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-man1 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-info-am \
uninstall-man uninstall-man1
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
psiconv-0.9.8/program/psiconv/psiconv.c 0000644 0001750 0001750 00000022020 10336374750 015113 0000000 0000000 /*
psiconv.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Driver program */
#include "config.h"
#include "compat.h"
#include
#include
#include
#include
#include
#include
#include
#ifdef HAVE_UNISTD_H
#include
#endif
#ifdef IMAGEMAGICK
#include "magick-aux.h"
#endif
#include
#include
#include
#include
#include "psiconv.h"
#include "gen.h"
static void print_help(void);
static void print_version(void);
static void strtoupper(char *str);
void print_help(void)
{
fileformat ff;
int i,j;
puts("Syntax: psiconv [OPTIONS..] [FILE]");
puts("Convert the psion file FILE to other formats");
puts("If FILE is not specified, use stdin");
puts(" -c, --configfile=FILE Read extra configuration file after normal ones");
puts(" -e, --encoding=ENC Output encoding (default: UTF8)");
puts(" -h, --help Display this help and exit");
puts(" -n, --noise=LEVEL Select what to print on stderr (overrides psiconv.conf)");
puts(" -o, --outputfile Output to file instead of stdout");
puts(" -T, --type=FILETYPE Output type (default: XHTML or TIFF");
puts(" -V, --version Display the program version and exit");
puts("");
puts("The following encodings are currently supported:");
puts(" UTF8 Variable length Unicode encoding");
puts(" UCS2 Fixed 16-bit length Unicode encoding");
puts(" Psion The encoding your Psion uses (as in psiconv.conf)");
puts(" ASCII 7-bit ASCII (other symbols are substituted by '?')");
puts("");
puts("The following noise levels are currently supported:");
puts(" 1 or F: Fatal errors only");
puts(" 2 or E: Errors");
puts(" 3 or W: Warnings");
puts(" 4 or P: Progress indicators");
puts(" 5 or D: Debug data");
puts("");
puts("The following abbreviations are used in the output types list:");
puts(" C - processes ClipArt files");
puts(" c - processes ClipArt files containing only one image");
puts(" M - processes MBM files");
puts(" m - processes MBM files containing only one image");
puts(" S - processes Sketch files");
puts(" T - processes TextEd files");
puts(" W - processes Word files");
puts("");
puts("The following output types are known:");
for (i = 0; i < psiconv_list_length(fileformat_list); i ++) {
ff = psiconv_list_get(fileformat_list,i);
printf(" %s",ff->name);
for (j = strlen(ff->name); j < 10; j++)
putchar(' ');
printf("[%c%c%c%c%c] ",
ff->supported_format & FORMAT_CLIPART_MULTIPLE?'C':
ff->supported_format & FORMAT_CLIPART_SINGLE?'c':' ',
ff->supported_format & FORMAT_MBM_MULTIPLE?'M':
ff->supported_format & FORMAT_MBM_SINGLE?'m':' ',
ff->supported_format & FORMAT_SKETCH?'S':' ',
ff->supported_format & FORMAT_TEXTED?'T':' ',
ff->supported_format & FORMAT_WORD?'W':' ');
puts(ff->description);
}
puts("");
puts("When using UTF8 with LaTeX type, the resulting LaTeX source should be converted");
puts(" to a suitable encoding for your LaTeX installation before being typeset");
}
void print_version(void)
{
printf("Version %s\n",VERSION);
}
void strtoupper(char *str)
{
int i;
for (i = 0; i < strlen(str); i ++)
str[i] = toupper(str[i]);
}
int main(int argc, char *argv[])
{
struct option long_options[] =
{
{"help",no_argument,NULL,'h'},
{"version",no_argument,NULL,'V'},
{"configfile",required_argument,NULL,'c'},
{"noise",required_argument,NULL,'n'},
{"outputfile",required_argument,NULL,'o'},
{"type",required_argument,NULL,'T'},
{"encoding",no_argument,NULL,'e'},
{0,0,0,0}
};
const char* short_options = "hVn:o:e:T:c:";
int option_index;
FILE * f;
struct stat fbuf;
const char *inputfilename = "";
const char *outputfilename = "";
const char *extra_configfile = NULL;
char *type = NULL;
encoding encoding_type=ENCODING_UTF8;
psiconv_list outputlist;
int verbosity = 0;
psiconv_config config;
int c,i,res;
psiconv_buffer buf;
psiconv_file file;
fileformat ff = NULL;
if (!(fileformat_list = psiconv_list_new(sizeof(struct fileformat_s)))) {
fputs("Out of memory error",stderr);
exit(1);
}
init_txt();
init_xhtml();
init_html4();
init_image();
while(1) {
c = getopt_long(argc,argv,short_options, long_options, &option_index);
if (c == -1)
break;
switch(c) {
case 'h': print_help(); exit(0);
case 'V': print_version(); exit(0);
case 'n': switch(optarg[0]) {
case '1': case 'F':case 'f':
verbosity=PSICONV_VERB_FATAL;
break;
case '2': case 'E':case 'e':
verbosity=PSICONV_VERB_ERROR;
break;
case '3': case 'W':case 'w':
verbosity=PSICONV_VERB_WARN;
break;
case '4': case 'P':case 'p':
verbosity=PSICONV_VERB_PROGRESS;
break;
case '5': case 'D':case 'd':
verbosity=PSICONV_VERB_DEBUG;
break;
default:
fputs("Unknown noise level\n",stderr);
exit(1);
}
break;
case 'o': outputfilename = strdup(optarg); break;
case 'T': type = strdup(optarg); break;
case 'e': if(!strcmp(optarg,"UTF8"))
encoding_type = ENCODING_UTF8;
else if (!strcmp(optarg,"UCS2"))
encoding_type = ENCODING_UCS2;
else if (!strcmp(optarg,"ASCII"))
encoding_type = ENCODING_ASCII;
else if (!strcmp(optarg,"Psion"))
encoding_type = ENCODING_PSION;
else {
fputs("Unknown encoding type "
"(try '-h' for more information\n",stderr);
exit(1);
}
break;
case 'c': extra_configfile = strdup(optarg); break;
case '?': case ':': fputs("Try `-h' for more information\n",stderr);
exit(1);
default: fprintf(stderr,"Internal error: getopt_long returned character "
"code 0%o ?? (contact the author)\n", c);
exit(1); break;
}
}
if (optind < argc-1) {
fputs("I can only convert one file!\n"
"Try `-h' for more information\n",stderr);
exit(1);
} else if (optind == argc-1)
if (!(inputfilename = strdup(argv[optind]))) {
fputs("Out of memory error",stderr);
exit(1);
}
config = psiconv_config_default();
psiconv_config_read(extra_configfile,&config);
if (verbosity)
config->verbosity = verbosity;
/* Open inputfile for reading */
if (strlen(inputfilename) != 0) {
if(stat(inputfilename,&fbuf) < 0) {
perror(inputfilename);
exit(1);
}
f = fopen(inputfilename,"r");
if (! f) {
perror(inputfilename);
exit(1);
}
} else
f = stdin;
if (!(buf = psiconv_buffer_new())) {
fputs("Out of memory error",stderr);
exit(1);
}
if (psiconv_buffer_fread_all(buf,f)) {
fprintf(stderr,"Failure reading file");
exit(1);
}
if (strlen(inputfilename) != 0)
if (fclose(f)) {
perror(inputfilename);
exit(1);
}
if (psiconv_parse(config,buf,&file) || (file->type == psiconv_unknown_file))
{
fprintf(stderr,"Parse error\n");
exit(1);
}
if (!type) {
switch(file->type) {
case psiconv_word_file:
case psiconv_texted_file:
default:
type = "XHTML"; break;
case psiconv_mbm_file:
case psiconv_clipart_file:
case psiconv_sketch_file:
type = "TIFF"; break;
}
} else
strtoupper(type);
for (i = 0; i < psiconv_list_length(fileformat_list); i ++) {
ff = psiconv_list_get(fileformat_list,i);
if (! strcasecmp(type,ff->name)) {
break;
}
}
if (i == psiconv_list_length(fileformat_list)) {
fprintf(stderr,"Unknown output type: `%s'\n",type);
exit(1);
}
if (!(outputlist = psiconv_list_new(sizeof(psiconv_u8)))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
res = ff->output(config,outputlist,file,type,encoding_type);
if (res) {
fprintf(stderr,
"Output format `%s' not permitted for this file type\n",type);
exit(1);
}
psiconv_free_file(file);
if (strlen(outputfilename) != 0) {
f = fopen(outputfilename,"w");
if (! f) {
perror(inputfilename);
exit(1);
}
} else
f = stdout;
psiconv_list_fwrite_all(outputlist,f);
if (fclose(f)) {
perror(inputfilename);
exit(1);
}
psiconv_list_free(outputlist);
exit(0);
}
psiconv-0.9.8/program/psiconv/general.c 0000644 0001750 0001750 00000011123 10336374754 015055 0000000 0000000 /*
general.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2003-2004 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "compat.h"
#include "psiconv.h"
#include "general.h"
#include
#include
#include
#include
#include
/* Output a UCS2 character in one of the supported encodings. */
void output_char(psiconv_config config, psiconv_list list,
psiconv_ucs2 character, encoding enc)
{
psiconv_u8 temp;
psiconv_u8 *byteptr;
int res,i;
psiconv_buffer buf;
#define TEMPSTR_LEN 80
char tempstr[TEMPSTR_LEN];
if (enc == ENCODING_UCS2) {
temp = character >> 8;
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
temp = character & 0xff;
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
} else if (enc == ENCODING_UTF8) {
if (character < 0x80) {
temp = character;
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
} else if (character < 0x800) {
temp = 0xc0 + (character >> 6);
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
temp = 0x80 + (character & 0x3f);
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
} else {
temp = 0xe0 + (character >> 12);
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
temp = 0x80 + ((character >> 6) & 0x3f);
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
temp = 0x80 + (character & 0x3f);
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
}
} else if (enc == ENCODING_ASCII) {
if (character == 0xa0)
temp = ' ';
else if (character >= 0x80)
temp = '?';
else
temp = character;
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
} else if (enc == ENCODING_ASCII_HTML) {
if (character >= 0x80) {
snprintf(tempstr,TEMPSTR_LEN,"%x;",character);
output_simple_chars(config,list,tempstr,enc);
} else {
temp = character;
if ((res = psiconv_list_add(list,&temp))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
}
} else if (enc == ENCODING_PSION) {
if (!(buf = psiconv_buffer_new())) {
fputs("Out of memory error\n",stderr);
exit(1);
}
psiconv_unicode_write_char(config,buf,0,character);
for (i = 0; i < psiconv_buffer_length(buf); i++) {
if (!(byteptr = psiconv_buffer_get(buf,i))) {
fputs("Internal memory corruption\n",stderr);
exit(1);
}
if ((res = psiconv_list_add(list,byteptr))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
}
psiconv_buffer_free(buf);
}
}
void output_string(psiconv_config config, psiconv_list list,
psiconv_ucs2 *string, encoding enc)
{
int i = 0;
while (string[i]) {
output_char(config,list,string[i],enc);
i++;
}
}
void output_simple_chars(psiconv_config config, psiconv_list list,
char *string, encoding enc)
{
psiconv_ucs2 *ucs_string;
int i;
if (!(ucs_string = malloc(sizeof(*ucs_string) * (strlen(string) + 1)))) {
fputs("Out of memory error",stderr);
exit(1);
}
for (i = 0; i < strlen(string); i++) {
if ((string[i] != '\n') && ((string[i] < 0x20) || (string[i] > 0x7e))) {
fprintf(stderr,"output_simple_chars unknown char: %02x",string[i]);
exit(1);
}
ucs_string[i] = string[i];
}
ucs_string[i] = string[i];
output_string(config,list,ucs_string,enc);
free(ucs_string);
}
psiconv-0.9.8/program/psiconv/magick-aux.c 0000644 0001750 0001750 00000003547 10336374745 015501 0000000 0000000 /*
magick-aux.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#if IMAGEMAGICK
#include "magick-aux.h"
#endif
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#if IMAGEMAGICK
/* This used to be very ugly, but nowadays it is much better */
#if IMAGEMAGICK_API == 1 || IMAGEMAGICK_API == 2
const MagickInfo * GetMagickFileList(void)
{
ExceptionInfo exc;
GetExceptionInfo(&exc);
OpenModules(&exc);
return GetMagickInfo(NULL,&exc);
}
#elif IMAGEMAGICK_API == 3
const MagickInfo * GetMagickFileList(void)
{
MagickInfo **mi;
unsigned long nr;
int i;
ExceptionInfo exc;
GetExceptionInfo(&exc);
OpenModules(&exc);
mi = GetMagickInfoList("*",&nr);
for (i = 0; i < nr-1; i++) {
mi[i]->next = mi[i+1];
}
return *mi;
}
#elif IMAGEMAGICK_API == 4
const MagickInfo * GetMagickFileList(void)
{
MagickInfo **mi;
unsigned long nr;
int i;
ExceptionInfo exc;
GetExceptionInfo(&exc);
OpenModules(&exc);
mi = GetMagickInfoList("*",&nr,&exc);
for (i = 0; i < nr-1; i++) {
mi[i]->next = mi[i+1];
}
return *mi;
}
#endif
#endif /* IMAGEMAGICK */
psiconv-0.9.8/program/psiconv/gen_txt.c 0000644 0001750 0001750 00000014122 10336374747 015114 0000000 0000000 /*
* gen_text.c - Part of psiconv, a PSION 5 file formats converter
* Copyright (c) 1999 Andrew Johnson
* Portions Copyright (c) 1999-2005 Frodo Looijaard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include
#include
#include
#include
#include
#include "general.h"
#include "gen.h"
#include "psiconv.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
static void output_para(const psiconv_config config,psiconv_list list,
const psiconv_paragraph para,encoding encoding_type);
static void gen_word(const psiconv_config config, psiconv_list list,
psiconv_word_f wf, encoding encoding_type);
static void gen_texted(const psiconv_config config, psiconv_list list,
psiconv_texted_f tf, encoding encoding_type);
static int gen_txt(const psiconv_config config, psiconv_list list,
const psiconv_file file, const char *dest,
const encoding encoding_type);
static struct fileformat_s ff =
{
"ASCII",
"Plain text without much layout",
FORMAT_WORD | FORMAT_TEXTED,
gen_txt
};
void output_para(const psiconv_config config,psiconv_list list,
const psiconv_paragraph para,encoding encoding_type)
{
int i;
if (para && para->base_paragraph && para->base_paragraph->bullet &&
para->base_paragraph->bullet->on) {
output_char(config,list,para->base_paragraph->bullet->character,
encoding_type);
output_char(config,list,' ', encoding_type);
output_char(config,list,' ', encoding_type);
output_char(config,list,' ', encoding_type);
}
if (para && para->text) {
for (i = 0; i < psiconv_unicode_strlen(para->text); i++)
switch (para->text[i]) {
case 0x06:
case 0x07:
case 0x08:
output_char(config,list,'\n',encoding_type);
break;
case 0x09:
case 0x0a:
output_char(config,list,'\t',encoding_type);
break;
case 0x0b:
case 0x0c:
output_char(config,list,'-',encoding_type);
break;
case 0x0f:
output_char(config,list,' ',encoding_type);
break;
case 0x00:
case 0x01:
case 0x02:
case 0x03:
case 0x04:
case 0x05:
case 0x0e:
case 0x10:
case 0x11:
case 0x12:
case 0x13:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x18:
case 0x19:
case 0x1a:
case 0x1c:
case 0x1d:
case 0x1e:
case 0x1f:
break;
default:
output_char(config,list,para->text[i],encoding_type);
break;
}
output_char(config,list,'\n',encoding_type);
}
}
void gen_word(const psiconv_config config, psiconv_list list,
psiconv_word_f wf, encoding encoding_type)
{
int i;
psiconv_paragraph para;
if (wf && wf->page_sec && wf->page_sec->header &&
wf->page_sec->header->text && wf->page_sec->header->text->paragraphs) {
for (i=0;
i < psiconv_list_length(wf->page_sec->header->
text->paragraphs); i++) {
para = psiconv_list_get(wf->page_sec->header->text->paragraphs,
i);
output_para(config,list,para,encoding_type);
}
}
output_char(config,list,'\n',encoding_type);
if (wf && wf->paragraphs)
for (i=0; i < psiconv_list_length(wf->paragraphs); i++) {
para = psiconv_list_get(wf->paragraphs, i);
output_para(config, list,para,encoding_type);
}
output_char(config,list,'\n',encoding_type);
if (wf && wf->page_sec && wf->page_sec->footer &&
wf->page_sec->footer->text && wf->page_sec->footer->text->paragraphs) {
for (i=0;
i < psiconv_list_length(wf->page_sec->footer->
text->paragraphs); i++) {
para = psiconv_list_get(wf->page_sec->footer->text->paragraphs, i);
output_para(config,list,para,encoding_type);
}
}
}
void gen_texted(const psiconv_config config, psiconv_list list,
psiconv_texted_f tf, encoding encoding_type)
{
int i;
psiconv_paragraph para;
if (tf && tf->page_sec && tf->page_sec->header &&
tf->page_sec->header->text && tf->page_sec->header->text->paragraphs) {
for (i=0;
i < psiconv_list_length(tf->page_sec->header->
text->paragraphs); i++) {
para = psiconv_list_get(tf->page_sec->header->text->paragraphs,
i);
output_para(config,list,para,encoding_type);
}
}
output_char(config,list,'\n',encoding_type);
if (tf && tf->texted_sec && tf->texted_sec->paragraphs)
for (i=0; i < psiconv_list_length(tf->texted_sec->paragraphs); i++) {
para = psiconv_list_get(tf->texted_sec->paragraphs, i);
output_para(config, list,para,encoding_type);
}
output_char(config,list,'\n',encoding_type);
if (tf && tf->page_sec && tf->page_sec->footer &&
tf->page_sec->footer->text && tf->page_sec->footer->text->paragraphs) {
for (i=0;
i < psiconv_list_length(tf->page_sec->footer->
text->paragraphs); i++) {
para = psiconv_list_get(tf->page_sec->footer->text->paragraphs, i);
output_para(config,list,para,encoding_type);
}
}
}
int gen_txt(const psiconv_config config, psiconv_list list,
const psiconv_file file, const char *dest,
const encoding encoding_type)
{
if (file->type == psiconv_word_file) {
gen_word(config,list,(psiconv_word_f) file->file,encoding_type);
return 0;
} else if (file->type == psiconv_texted_file) {
gen_texted(config,list,(psiconv_texted_f) file->file,encoding_type);
return 0;
} else
return -1;
}
void init_txt(void)
{
psiconv_list_add(fileformat_list,&ff);
}
psiconv-0.9.8/program/psiconv/gen_image.c 0000644 0001750 0001750 00000016367 10336374743 015370 0000000 0000000 /*
* gen_image.c - Part of psiconv, a PSION 5 file formats converter
* Copyright (c) 1999-2005 Frodo Looijaard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "psiconv/data.h"
#include "gen.h"
#include "psiconv.h"
#include
#include
#ifdef IMAGEMAGICK
#include "magick-aux.h"
#endif
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#ifdef IMAGEMAGICK
static Image *get_paint_data_section(psiconv_paint_data_section sec);
static void image_to_list(psiconv_list list,Image *image,const char *dest);
static void gen_image_list(const psiconv_config config,psiconv_list list,
const psiconv_list sections, const char *dest);
static void gen_clipart(const psiconv_config config,psiconv_list list,
const psiconv_clipart_f f, const char *dest);
static void gen_mbm(const psiconv_config config,psiconv_list list,
const psiconv_mbm_f f, const char *dest);
static void gen_sketch(const psiconv_config config,psiconv_list list,
const psiconv_sketch_f f, const char *dest);
static int gen_image(psiconv_config config, psiconv_list list,
const psiconv_file file, const char *dest,
const encoding encoding_type);
/* This is ridiculously simple using ImageMagick. Without it, it would
be quite somewhat harder - it will be left for later on.
Note that we ignore any errors. Dangerous... */
Image *get_paint_data_section(psiconv_paint_data_section sec)
{
Image *image;
float *pixel, *p, *red, *green, *blue;
int x,y;
ExceptionInfo exc;
GetExceptionInfo(&exc);
red = sec->red;
green = sec->green;
blue = sec->blue;
p = pixel = malloc(sec->xsize * sec->ysize * 3 * sizeof(float));
for (y = 0; y < sec->ysize; y++) {
for (x = 0; x < sec->xsize; x++) {
*p++ = *red++;
*p++ = *green++;
*p++ = *blue++;
}
}
image = ConstituteImage(sec->xsize,sec->ysize,"RGB",FloatPixel,pixel,&exc);
if (! image || (exc.severity != UndefinedException)) {
MagickError(exc.severity,exc.reason,exc.description);
exit(1);
}
free(pixel);
DestroyExceptionInfo(&exc);
return image;
}
void image_to_list(psiconv_list list,Image *image,const char *dest)
{
ImageInfo *image_info;
ExceptionInfo exc;
size_t length;
char *data;
int i;
strcpy(image->magick,dest);
image_info = CloneImageInfo(NULL);
GetExceptionInfo(&exc);
data = ImageToBlob(image_info,image,&length,&exc);
if (!data || (exc.severity != UndefinedException)) {
MagickError(exc.severity,exc.reason,exc.description);
exit(1);
}
for (i = 0; i < length; i++) {
if (psiconv_list_add(list,data+i)) {
fprintf(stderr,"Out of memory error");
exit(1);
}
}
DestroyExceptionInfo(&exc);
DestroyImageInfo(image_info);
}
void gen_image_list(const psiconv_config config,psiconv_list list,
const psiconv_list sections, const char *dest)
{
psiconv_paint_data_section section;
const MagickInfo *mi;
ImageInfo *image_info;
Image *image = NULL;
Image *last_image = NULL;
Image *this_image, *images;
ExceptionInfo exc;
int i;
GetExceptionInfo(&exc);
mi = GetMagickInfo(dest,&exc);
if (!mi || (exc.severity != UndefinedException)) {
MagickError(exc.severity,exc.reason,exc.description);
exit(1);
}
if ((psiconv_list_length(sections) < 1) ||
((psiconv_list_length(sections)) > 1 && ! (mi->adjoin))) {
fprintf(stderr,"This image type supports only one image\n");
exit(1);
}
for (i = 0; i < psiconv_list_length(sections); i++) {
if (!(section = psiconv_list_get(sections,i))) {
fprintf(stderr,"Internal data structures corrupted\n");
exit(1);
}
this_image = get_paint_data_section(section);
if (! image) {
image = this_image;
} else {
last_image->next=this_image;
this_image->previous=last_image;
}
last_image = this_image;
}
image_info = CloneImageInfo(NULL);
if (image->next) {
images = CoalesceImages(image,&exc);
if (!images || (exc.severity != UndefinedException)) {
MagickError(exc.severity,exc.reason,exc.description);
exit(1);
}
} else
images = image;
image_to_list(list,image,dest);
DestroyExceptionInfo(&exc);
DestroyImageInfo(image_info);
if (image != images)
DestroyImages(image);
DestroyImages(images);
}
void gen_clipart(const psiconv_config config,psiconv_list list,
const psiconv_clipart_f f, const char *dest)
{
int i;
psiconv_list sections;
psiconv_clipart_section section;
if (!(sections = psiconv_list_new(sizeof(*section->picture)))) {
fprintf(stderr,"Out of memory error\n");
exit(1);
}
for (i = 0; i < psiconv_list_length(f->sections); i ++) {
if (!(section = psiconv_list_get(f->sections,i))) {
fprintf(stderr,"Internal data structures corrupted\n");
exit(1);
}
if ((psiconv_list_add(sections,section->picture))) {
fprintf(stderr,"Out of memory error\n");
exit(1);
}
}
gen_image_list(config,list,sections,dest);
psiconv_list_free(sections);
}
void gen_mbm(const psiconv_config config,psiconv_list list,
const psiconv_mbm_f f, const char *dest)
{
gen_image_list(config,list,f->sections,dest);
}
void gen_sketch(const psiconv_config config,psiconv_list list,
const psiconv_sketch_f f, const char *dest)
{
Image *image;
image = get_paint_data_section(f->sketch_sec->picture);
image_to_list(list,image,dest);
DestroyImage(image);
}
int gen_image(psiconv_config config, psiconv_list list,
const psiconv_file file, const char *dest,
const encoding encoding_type)
{
if (file->type == psiconv_mbm_file)
gen_mbm(config,list,(psiconv_mbm_f) file->file,dest);
else if (file->type == psiconv_clipart_file)
gen_clipart(config,list,
(psiconv_clipart_f) file->file,dest);
else
if (file->type == psiconv_sketch_file) {
gen_sketch(config, list,(psiconv_sketch_f) file->file,dest);
} else
return -1;
return 0;
}
#endif
void init_image(void)
{
struct fileformat_s ff;
#if IMAGEMAGICK
const MagickInfo *mi;
ff.output = gen_image;
for (mi = GetMagickFileList(); mi ; mi = mi->next) {
if (mi->encoder) {
ff.name = strdup(mi->name);
ff.description = strdup(mi->description);
ff.supported_format = FORMAT_CLIPART_SINGLE | FORMAT_MBM_SINGLE |
FORMAT_SKETCH;
if (mi->adjoin)
ff.supported_format |= FORMAT_MBM_MULTIPLE | FORMAT_CLIPART_MULTIPLE;
psiconv_list_add(fileformat_list,&ff);
}
}
#endif
}
psiconv-0.9.8/program/psiconv/gen_xhtml.c 0000644 0001750 0001750 00000066453 10336374753 015444 0000000 0000000 /* gen_html.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2004 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include
#include
#include "general.h"
#include "gen.h"
#include
#include
#include
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#define TEMPSTR_LEN 100
static void text(const psiconv_config config,psiconv_list list,
psiconv_string_t data,const encoding enc);
static void color(const psiconv_config config, psiconv_list list,
psiconv_color color,int may_be_transparant, const encoding enc);
static void border(const psiconv_config config, psiconv_list list,
psiconv_border_kind_t border,const encoding enc);
static void style_name(const psiconv_config config, psiconv_list list,
const psiconv_string_t name,const encoding enc);
static int character_layout_equal(const psiconv_character_layout l1,
const psiconv_character_layout l2);
static void character_layout_diffs(const psiconv_config config,
psiconv_list list,
const psiconv_character_layout new,
const psiconv_character_layout base,
const encoding enc);
static void paragraph_layout_diffs(const psiconv_config config,
psiconv_list list,
const psiconv_paragraph_layout new,
const psiconv_paragraph_layout base,
const encoding enc);
static void style(const psiconv_config config, psiconv_list list,
const psiconv_word_style style,
const psiconv_paragraph_layout base_para,
const psiconv_character_layout base_char,
const encoding enc);
static void styles(const psiconv_config config, psiconv_list list,
const psiconv_word_styles_section styles_sec,const encoding enc);
static void header(const psiconv_config config, psiconv_list list,
const psiconv_word_styles_section styles_sec,const encoding enc);
static void footer(const psiconv_config config, psiconv_list list,
const encoding enc);
static void characters(const psiconv_config config, psiconv_list list,
const psiconv_string_t textstr,
const psiconv_character_layout layout,
const psiconv_character_layout base,
const encoding enc);
static void paragraphs(const psiconv_config config, psiconv_list list,
psiconv_text_and_layout paragraphs,
const psiconv_word_styles_section styles,
const encoding enc);
static void paragraph(const psiconv_config config, psiconv_list list,
const psiconv_paragraph para,
const psiconv_word_styles_section styles_sec,
const encoding enc);
static void gen_word(const psiconv_config config, psiconv_list list,
const psiconv_word_f file, const encoding enc);
static void gen_texted(const psiconv_config config, psiconv_list list,
const psiconv_texted_f file, const encoding enc);
static int gen_xhtml(const psiconv_config config, psiconv_list list,
const psiconv_file file, const char *dest,
const encoding enc);
void text(const psiconv_config config,psiconv_list list,
psiconv_string_t data,const encoding enc)
{
int i;
for (i = 0; i < psiconv_unicode_strlen(data); i++) {
if ((data[i] == 0x06) || (data[i] == 0x07) || (data[i] == 0x08))
output_simple_chars(config,list,"
",enc);
else if ((data[i] == 0x0b) || (data[i] == 0x0c))
output_simple_chars(config,list,"-",enc);
else if ((data[i] == 0x0f) || (data[i] == 0x09) || (data[i] == 0x0a))
output_simple_chars(config,list," ",enc);
else if (data[i] >= 0x20)
output_char(config,list,data[i],enc);
}
}
void color(const psiconv_config config, psiconv_list list,
psiconv_color color,int may_be_transparant, const encoding enc)
{
char tempstr[TEMPSTR_LEN];
if (may_be_transparant &&
(color->red == 0xff) &&
(color->blue == 0xff) &&
(color->green == 0xff))
output_simple_chars(config,list,"transparant",enc);
else {
snprintf(tempstr,TEMPSTR_LEN,"rgb(%d,%d,%d)",
color->red,
color->green,
color->blue);
output_simple_chars(config,list,tempstr,enc);
}
}
void border(const psiconv_config config, psiconv_list list,
psiconv_border_kind_t border,const encoding enc)
{
output_simple_chars(config,list,
border == psiconv_border_none?"none":
border == psiconv_border_solid?"solid":
border == psiconv_border_double?"double":
border == psiconv_border_dotted?"dotted":
border == psiconv_border_dashed?"dashed":
border == psiconv_border_dotdashed?"dashed":
border == psiconv_border_dotdotdashed?"dashed":"",enc);
}
void style_name(const psiconv_config config, psiconv_list list,
const psiconv_string_t name,const encoding enc)
{
psiconv_string_t name_copy;
int i;
if (!name)
return;
if (!(name_copy = psiconv_unicode_strdup(name))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
for (i = 0; i < psiconv_unicode_strlen(name_copy); i++) {
if ((name_copy[i] < 0x21) ||
((name_copy[i] >= 0x7f) && name_copy[i] <= 0xa0))
name_copy[i] = '_';
}
output_string(config,list,name_copy,enc);
free(name_copy);
}
/* Check whether the same layout information would be generated */
int character_layout_equal(const psiconv_character_layout l1,
const psiconv_character_layout l2)
{
return (l1 && l2 &&
(l1->color->red == l2->color->red) &&
(l1->color->green == l2->color->green) &&
(l1->color->blue == l2->color->blue) &&
(l1->back_color->red == l2->back_color->red) &&
(l1->back_color->green == l2->back_color->green) &&
(l1->back_color->blue == l2->back_color->blue) &&
(l1->font_size == l2->font_size) &&
(l1->italic == l2->italic) &&
(l1->bold == l2->bold) &&
(l1->super_sub == l2->super_sub) &&
(l1->underline == l2->underline) &&
(l1->strikethrough == l2->strikethrough) &&
(l1->font->screenfont == l2->font->screenfont));
}
void character_layout_diffs(const psiconv_config config, psiconv_list list,
const psiconv_character_layout new,
const psiconv_character_layout base,
const encoding enc)
{
char tempstr[TEMPSTR_LEN];
if (!base || (new->color->red != base->color->red) ||
(new->color->green != base->color->green) ||
(new->color->blue != base->color->blue)) {
output_simple_chars(config,list,"color:",enc);
color(config,list,new->color,0,enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->back_color->red != base->back_color->red) ||
(new->back_color->green != base->back_color->green) ||
(new->back_color->blue != base->back_color->blue)) {
output_simple_chars(config,list,"background-color:",enc);
color(config,list,new->back_color,1,enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->font_size != base->font_size)) {
output_simple_chars(config,list,"font-size:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->font_size);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
if (!base || (new->italic != base->italic)) {
output_simple_chars(config,list,"font-style:",enc);
output_simple_chars(config,list,new->italic?"italic":"normal",enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->bold != base->bold)) {
output_simple_chars(config,list,"font-weight:",enc);
output_simple_chars(config,list,new->bold?"bold":"normal",enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->super_sub != base->super_sub)) {
output_simple_chars(config,list,"font-style:",enc);
output_simple_chars(config,list,
new->super_sub==psiconv_superscript?"super":
new->super_sub==psiconv_subscript?"sub":
"normal",enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->underline != base->underline) ||
(new->strikethrough != base->strikethrough)) {
output_simple_chars(config,list,"text-decoration:",enc);
output_simple_chars(config,list,new->underline?"underline":
new->strikethrough?"line-through":
"none",enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->font->screenfont != base->font->screenfont)) {
output_simple_chars(config,list,"font-family:",enc);
output_simple_chars(config,list,
new->font->screenfont == psiconv_font_serif?"serif":
new->font->screenfont == psiconv_font_sansserif?"sans-serif":
new->font->screenfont == psiconv_font_nonprop?"monospace":
new->font->screenfont == psiconv_font_misc?"fantasy":"",
enc);
}
}
void paragraph_layout_diffs(const psiconv_config config, psiconv_list list,
const psiconv_paragraph_layout new,
const psiconv_paragraph_layout base,
const encoding enc)
{
char tempstr[TEMPSTR_LEN];
float pad_left_base=0.0,pad_left_new,text_indent_base=0.0,text_indent_new;
if (new->bullet->on) {
pad_left_new = new->indent_left < new->indent_first?
new->indent_left:new->indent_first;
text_indent_new = 0.0;
} else {
pad_left_new = new->indent_left;
text_indent_new = new->indent_first;
}
if (base) {
if (base->bullet->on) {
pad_left_base = base->indent_left < base->indent_first?
base->indent_left:base->indent_first;
text_indent_base = 0.0;
} else {
pad_left_base = base->indent_left;
text_indent_base = base->indent_first;
}
}
if (!base || (new->back_color->red != base->back_color->red) ||
(new->back_color->green != base->back_color->green) ||
(new->back_color->blue != base->back_color->blue)) {
output_simple_chars(config,list,"background-color:",enc);
color(config,list,new->back_color,1,enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (pad_left_new != pad_left_base)) {
output_simple_chars(config,list,"padding-left:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",pad_left_new);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"cm;",enc);
}
if (!base || (new->indent_right != base->indent_right)) {
output_simple_chars(config,list,"padding-right:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->indent_right);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"cm;",enc);
}
if (!base || (text_indent_new != text_indent_base)) {
output_simple_chars(config,list,"text-indent:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",text_indent_new);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"cm;",enc);
}
if (!base || (new->justify_hor != base ->justify_hor)) {
output_simple_chars(config,list,"font-style:",enc);
output_simple_chars(config,list,
new->justify_hor==psiconv_justify_left?"left":
new->justify_hor==psiconv_justify_centre?"center":
new->justify_hor==psiconv_justify_right?"right":
new->justify_hor==psiconv_justify_full?"justify":
"",enc);
output_simple_chars(config,list,";",enc);
}
#if 0
/* This gave bad output... */
if (!base || (new->linespacing != base->linespacing)) {
output_simple_chars(config,list,"line-height:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->linespacing);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
#endif
if (!base || (new->space_above != base->space_above)) {
output_simple_chars(config,list,"padding-top:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->space_above);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
if (!base || (new->space_below != base->space_below)) {
output_simple_chars(config,list,"padding-bottom:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->space_below);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
if (!base || (new->right_border->kind != base->right_border->kind)) {
output_simple_chars(config,list,"border-right-style:",enc);
border(config,list,new->right_border->kind,enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->bottom_border->kind != base->bottom_border->kind)) {
output_simple_chars(config,list,"border-bottom-style:",enc);
border(config,list,new->bottom_border->kind,enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->top_border->kind != base->top_border->kind)) {
output_simple_chars(config,list,"border-top-style:",enc);
border(config,list,new->top_border->kind,enc);
output_simple_chars(config,list,";",enc);
}
if (!base || (new->left_border->kind != base->left_border->kind)) {
output_simple_chars(config,list,"border-left-style:",enc);
border(config,list,new->left_border->kind,enc);
output_simple_chars(config,list,";",enc);
}
if (!base ||
((new->right_border->kind != psiconv_border_none) &&
(new->right_border->thickness != base->right_border->thickness))) {
output_simple_chars(config,list,"border-right-width:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->right_border->thickness);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
if (!base ||
((new->bottom_border->kind != psiconv_border_none) &&
(new->bottom_border->thickness != base->bottom_border->thickness))) {
output_simple_chars(config,list,"border-bottom-width:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->bottom_border->thickness);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
if (!base ||
((new->top_border->kind != psiconv_border_none) &&
( new->top_border->thickness != base->top_border->thickness))) {
output_simple_chars(config,list,"border-top-width:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->top_border->thickness);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
if (!base ||
((new->left_border->kind != psiconv_border_none) &&
(new->left_border->thickness != base->left_border->thickness))) {
output_simple_chars(config,list,"border-left-width:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->left_border->thickness);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
if (!base ||
((new->right_border->kind != psiconv_border_none) &&
((new->right_border->color->red != base->right_border->color->red) ||
(new->right_border->color->green != base->right_border->color->green)||
(new->right_border->color->blue != base->right_border->color->blue)))) {
output_simple_chars(config,list,"border-right-color:",enc);
color(config,list,new->right_border->color,0,enc);
output_simple_chars(config,list,";",enc);
}
if (!base ||
((new->top_border->kind != psiconv_border_none) &&
((new->top_border->color->red != base->top_border->color->red) ||
(new->top_border->color->green != base->top_border->color->green) ||
(new->top_border->color->blue != base->top_border->color->blue)))) {
output_simple_chars(config,list,"border-top-color:",enc);
color(config,list,new->top_border->color,0,enc);
output_simple_chars(config,list,";",enc);
}
if (!base ||
((new->bottom_border->kind != psiconv_border_none) &&
((new->bottom_border->color->red != base->bottom_border->color->red) ||
(new->bottom_border->color->green !=base->bottom_border->color->green)||
(new->bottom_border->color->blue != base->bottom_border->color->blue)))){
output_simple_chars(config,list,"border-bottom-color:",enc);
color(config,list,new->bottom_border->color,0,enc);
output_simple_chars(config,list,";",enc);
}
if (!base ||
((new->left_border->kind != psiconv_border_none) &&
((new->left_border->color->red != base->left_border->color->red) ||
(new->left_border->color->green != base->left_border->color->green) ||
(new->left_border->color->blue != base->left_border->color->blue)))) {
output_simple_chars(config,list,"border-left-color:",enc);
color(config,list,new->left_border->color,0,enc);
output_simple_chars(config,list,";",enc);
}
}
void style(const psiconv_config config, psiconv_list list,
const psiconv_word_style style,
const psiconv_paragraph_layout base_para,
const psiconv_character_layout base_char,
const encoding enc)
{
output_simple_chars(config,list,"*.style_",enc);
style_name(config,list,style->name,enc);
output_simple_chars(config,list," {",enc);
paragraph_layout_diffs(config,list,style->paragraph,base_para,enc);
character_layout_diffs(config,list,style->character,base_char,enc);
output_simple_chars(config,list,"}\n",enc);
}
void styles(const psiconv_config config, psiconv_list list,
const psiconv_word_styles_section styles_sec,const encoding enc)
{
int i;
psiconv_word_style styl;
psiconv_character_layout base_char;
psiconv_paragraph_layout base_para;
if (!(base_char = psiconv_basic_character_layout())) {
fputs("Out of memory error\n",stderr);
exit(1);
}
if (!(base_para = psiconv_basic_paragraph_layout())) {
fputs("Out of memory error\n",stderr);
exit(1);
}
output_simple_chars(config,list,"\n",enc);
}
void header(const psiconv_config config, psiconv_list list,
const psiconv_word_styles_section styles_sec,const encoding enc)
{
output_simple_chars(config,list,
"\n",enc);
output_simple_chars(config,list,"",
enc);
output_simple_chars(config,list,"\n\n",enc);
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"EPOC32 file "
"converted by psiconv\n",enc);
styles(config,list,styles_sec,enc);
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"\n",enc);
}
void footer(const psiconv_config config, psiconv_list list, const encoding enc)
{
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"\n",enc);
}
void characters(const psiconv_config config, psiconv_list list,
const psiconv_string_t textstr,
const psiconv_character_layout layout,
const psiconv_character_layout base,
const encoding enc)
{
psiconv_list templist;
if (!(templist = psiconv_list_new(sizeof(psiconv_u8)))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
character_layout_diffs(config,templist,layout,base,enc);
if (psiconv_list_length(templist)) {
output_simple_chars(config,list,"",enc);
}
text(config,list,textstr,enc);
if (psiconv_list_length(templist)) {
output_simple_chars(config,list,"",enc);
}
psiconv_list_free(templist);
}
void paragraph(const psiconv_config config, psiconv_list list,
const psiconv_paragraph para,
const psiconv_word_styles_section styles_sec,
const encoding enc)
{
int i,charnr,start,len;
psiconv_string_t text;
psiconv_in_line_layout layout,next_layout;
psiconv_word_style style = NULL;
psiconv_paragraph_layout base_para;
psiconv_character_layout base_char;
psiconv_list templist;
if (!(templist = psiconv_list_new(sizeof(psiconv_u8)))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
if (styles_sec) {
if (!(style = psiconv_get_style(styles_sec,para->base_style))) {
fputs("Unknown style found; data corrupt\n",stderr);
exit(1);
}
base_para = style->paragraph;
base_char = style->character;
} else {
base_para = psiconv_basic_paragraph_layout();
base_char = psiconv_basic_character_layout();
if (!base_para || !base_char) {
fputs("Out of memory error\n",stderr);
exit(1);
}
}
output_simple_chars(config,
list,para->base_paragraph->bullet->on?"- name,enc);
output_simple_chars(config,list,"\" ",enc);
}
paragraph_layout_diffs(config,templist,para->base_paragraph,base_para,enc);
character_layout_diffs(config,templist,para->base_character,base_char,enc);
if (psiconv_list_length(templist)) {
output_simple_chars(config,list,"style=\"",enc);
if (psiconv_list_concat(list,templist)) {
fputs("Out of memory error\n",stderr);
exit(1);
}
output_simple_chars(config,list,"\"",enc);
}
output_simple_chars(config,list,">",enc);
if (psiconv_list_length(para->in_lines) == 0) {
if (psiconv_unicode_strlen(para->text))
characters(config,list,para->text,para->base_character,
para->base_character,enc);
} else {
charnr = 0;
start = -1;
for (i = 0; i < psiconv_list_length(para->in_lines); i++) {
if (start < 0)
start = charnr;
if (!(layout = psiconv_list_get(para->in_lines,i))) {
fputs("Internal data structures corruption\n",stderr);
exit(1);
}
if (i+1 < psiconv_list_length(para->in_lines)) {
if (!(next_layout = psiconv_list_get(para->in_lines,i+1))) {
fputs("Internal data structures corruption\n",stderr);
exit(1);
}
} else {
next_layout = NULL;
}
if (next_layout &&
character_layout_equal(layout->layout,next_layout->layout)) {
charnr += layout->length;
continue;
}
len = charnr - start + layout->length;
if (len) {
if (!(text = malloc(sizeof (*text) * (len + 1)))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
memcpy(text,para->text+start,len * sizeof(*text));
text[len] = 0;
characters(config,list,text,layout->layout,para->base_character,enc);
free(text);
}
charnr += layout->length;
start = -1;
}
}
output_simple_chars(config, list,
para->base_paragraph->bullet->on?"
\n":"
\n",
enc);
if (!styles_sec) {
psiconv_free_paragraph_layout(base_para);
psiconv_free_character_layout(base_char);
}
psiconv_list_free(templist);
}
void paragraphs(const psiconv_config config, psiconv_list list,
psiconv_text_and_layout paragraphs,
const psiconv_word_styles_section styles,
const encoding enc)
{
int i;
psiconv_paragraph para;
for (i = 0; i < psiconv_list_length(paragraphs); i++) {
if (!(para = psiconv_list_get(paragraphs,i))) {
fputs("Internal datastructure corruption\n",stderr);
exit(1);
}
paragraph(config,list,para,styles,enc);
}
}
void gen_word(const psiconv_config config, psiconv_list list,
const psiconv_word_f file, const encoding enc)
{
if (!file)
return;
header(config,list,file->styles_sec,enc);
paragraphs(config,list,file->paragraphs,file->styles_sec,enc);
footer(config,list,enc);
}
void gen_texted(const psiconv_config config, psiconv_list list,
const psiconv_texted_f file, const encoding enc)
{
header(config,list,NULL,enc);
paragraphs(config,list,file->texted_sec->paragraphs,NULL,enc);
footer(config,list,enc);
}
int gen_xhtml(const psiconv_config config, psiconv_list list,
const psiconv_file file, const char *dest,
const encoding enc)
{
encoding enc1 = enc;
if (enc == ENCODING_PSION) {
fputs("Unsupported encoding\n",stderr);
return -1;
} else if (enc == ENCODING_ASCII)
enc1 = ENCODING_ASCII_HTML;
if (file->type == psiconv_word_file) {
gen_word(config,list,(psiconv_word_f) file->file,enc1);
return 0;
} else if (file->type == psiconv_texted_file) {
gen_texted(config,list,(psiconv_texted_f) file->file,enc1);
return 0;
} else
return -1;
}
static struct fileformat_s fileformats[] =
{
{
"XHTML",
"XHTML 1.0 Strict, using CSS for formatting",
FORMAT_WORD | FORMAT_TEXTED,
gen_xhtml
},
{
NULL,
NULL,
0,
NULL
}
};
void init_xhtml(void)
{
int i;
for (i = 0; fileformats[i].name; i++)
psiconv_list_add(fileformat_list,fileformats+i);
}
psiconv-0.9.8/program/psiconv/gen_html4.c 0000644 0001750 0001750 00000027754 10336374742 015337 0000000 0000000 /*
gen_html.c - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include
#include
#include "general.h"
#include
#include
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#define TEMPSTR_LEN 100
static void text(const psiconv_config config,psiconv_list list,
psiconv_string_t data,const encoding enc);
static void header(const psiconv_config config, psiconv_list list,
const encoding enc);
static void footer(const psiconv_config config, psiconv_list list,
const encoding enc);
static void characters(const psiconv_config config, psiconv_list list,
const psiconv_string_t textstr,
const psiconv_character_layout layout,const encoding enc);
static void paragraph(const psiconv_config config, psiconv_list list,
psiconv_paragraph para, const encoding enc);
static void paragraphs(const psiconv_config config, psiconv_list list,
psiconv_text_and_layout paragraphs, const encoding enc);
static void gen_word(const psiconv_config config, psiconv_list list,
const psiconv_word_f file, const encoding enc);
static void gen_texted(const psiconv_config config, psiconv_list list,
const psiconv_texted_f file, const encoding enc);
static int gen_html4(const psiconv_config config, psiconv_list list,
const psiconv_file file, const char *dest,
const encoding enc);
void text(const psiconv_config config,psiconv_list list,
psiconv_string_t data,const encoding enc)
{
int i;
for (i = 0; i < psiconv_unicode_strlen(data); i++) {
if ((data[i] == 0x06) || (data[i] == 0x07) || (data[i] == 0x08))
output_simple_chars(config,list,"
",enc);
else if ((data[i] == 0x0b) || (data[i] == 0x0c))
output_simple_chars(config,list,"-",enc);
else if ((data[i] == 0x0f) || (data[i] == 0x09) || (data[i] == 0x0a))
output_simple_chars(config,list," ",enc);
else if (data[i] >= 0x20)
output_char(config,list,data[i],enc);
}
}
void header(const psiconv_config config, psiconv_list list, const encoding enc)
{
output_simple_chars(config,list,"\n",
enc);
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"EPOC32 file "
"converted by psiconv\n",enc);
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"\n",enc);
}
void footer(const psiconv_config config, psiconv_list list, const encoding enc)
{
output_simple_chars(config,list,"\n",enc);
output_simple_chars(config,list,"\n",enc);
}
int character_layout_equal(const psiconv_character_layout l1,
const psiconv_character_layout l2)
{
int font_size1,font_size2;
font_size1 = l1->font_size < 8 ?1:
l1->font_size < 10 ?2:
l1->font_size < 13 ?3:
l1->font_size < 17 ?4:
l1->font_size < 24 ?5:
l1->font_size < 36 ?6:7;
font_size2 = l2->font_size < 8 ?1:
l2->font_size < 10 ?2:
l2->font_size < 13 ?3:
l2->font_size < 17 ?4:
l2->font_size < 24 ?5:
l2->font_size < 36 ?6:7;
return (l1 && l2 &&
(l1->color->red == l2->color->red) &&
(l1->color->green == l2->color->green) &&
(l1->color->blue == l2->color->blue) &&
(font_size1 == font_size2) &&
(l1->italic == l2->italic) &&
(l1->bold == l2->bold) &&
(l1->super_sub == l2->super_sub) &&
(l1->underline == l2->underline) &&
(l1->strikethrough == l2->strikethrough) &&
(l1->font->screenfont == l2->font->screenfont));
}
void characters(const psiconv_config config, psiconv_list list,
const psiconv_string_t textstr,
const psiconv_character_layout layout,const encoding enc)
{
char tempstr[TEMPSTR_LEN];
output_simple_chars(config,list,"font->screenfont == psiconv_font_serif?"serif":
layout->font->screenfont == psiconv_font_sansserif?"sans-serif":
layout->font->screenfont == psiconv_font_nonprop?"monospace":
layout->font->screenfont == psiconv_font_misc?"fantasy":"",
enc);
output_simple_chars(config,list,"\"",enc);
if ((layout->font_size < 10) || (layout->font_size >= 13)) {
output_simple_chars(config,list," size=",enc);
output_simple_chars(config,list,
layout->font_size < 8 ?"1":
layout->font_size < 10 ?"2":
layout->font_size < 13 ?"3":
layout->font_size < 17 ?"4":
layout->font_size < 24 ?"5":
layout->font_size < 36 ?"6":"7",enc);
}
if ((layout->color->red != 0) || (layout->color->green != 0) ||
(layout->color->blue != 0)) {
snprintf(tempstr,TEMPSTR_LEN,"%02x%02x%02x",
layout->color->red,layout->color->green,layout->color->blue);
output_simple_chars(config,list," color=#",enc);
output_simple_chars(config,list,tempstr,enc);
}
output_simple_chars(config,list,">",enc);
if (layout->italic)
output_simple_chars(config,list,"",enc);
if (layout->bold)
output_simple_chars(config,list,"",enc);
if (layout->super_sub != psiconv_normalscript)
output_simple_chars(config,list,
layout->super_sub == psiconv_superscript?"":
layout->super_sub == psiconv_subscript?"":
"",enc);
if (layout->strikethrough)
output_simple_chars(config,list,"",enc);
if (layout->underline)
output_simple_chars(config,list,"",enc);
text(config,list,textstr,enc);
if (layout->underline)
output_simple_chars(config,list,"",enc);
if (layout->strikethrough)
output_simple_chars(config,list,"",enc);
if (layout->super_sub != psiconv_normalscript)
output_simple_chars(config,list,
layout->super_sub == psiconv_superscript?"":
layout->super_sub == psiconv_subscript?"":
"",enc);
if (layout->bold)
output_simple_chars(config,list,"",enc);
if (layout->italic)
output_simple_chars(config,list,"",enc);
output_simple_chars(config,list,"",enc);
}
void paragraph(const psiconv_config config, psiconv_list list,
psiconv_paragraph para, const encoding enc)
{
int i,charnr,start,len;
psiconv_string_t text;
psiconv_in_line_layout layout,next_layout;
output_simple_chars(config,list,
para->base_paragraph->bullet->on?"- base_paragraph->justify_hor == psiconv_justify_centre)
output_simple_chars(config,list," align=center",enc);
else if (para->base_paragraph->justify_hor == psiconv_justify_right)
output_simple_chars(config,list," align=right",enc);
else if (para->base_paragraph->justify_hor == psiconv_justify_full)
output_simple_chars(config,list," align=justify",enc);
output_simple_chars(config,list,">",enc);
if (psiconv_list_length(para->in_lines) == 0) {
if (psiconv_unicode_strlen(para->text))
characters(config,list,para->text,para->base_character,enc);
} else {
charnr = 0;
start = -1;
for (i = 0; i < psiconv_list_length(para->in_lines); i++) {
if (start < 0)
start = charnr;
if (!(layout = psiconv_list_get(para->in_lines,i))) {
fputs("Internal data structures corruption\n",stderr);
exit(1);
}
if (i+1 < psiconv_list_length(para->in_lines)) {
if (!(next_layout = psiconv_list_get(para->in_lines,i+1))) {
fputs("Internal data structures corruption\n",stderr);
exit(1);
}
} else {
next_layout = NULL;
}
if (next_layout &&
character_layout_equal(layout->layout,next_layout->layout)) {
charnr += layout->length;
continue;
}
len = charnr - start + layout->length;
if (len) {
if (!(text = malloc(sizeof (*text) * (len + 1)))) {
fputs("Out of memory error\n",stderr);
exit(1);
}
memcpy(text,para->text+charnr,len * sizeof(*text));
text[len] = 0;
characters(config,list,text,layout->layout,enc);
free(text);
}
charnr += layout->length;
start = -1;
}
}
output_simple_chars(config, list,
para->base_paragraph->bullet->on?"
\n":"\n",enc);
}
void paragraphs(const psiconv_config config, psiconv_list list,
psiconv_text_and_layout paragraphs, const encoding enc)
{
int i;
psiconv_paragraph para;
for (i = 0; i < psiconv_list_length(paragraphs); i++) {
if (!(para = psiconv_list_get(paragraphs,i))) {
fputs("Internal datastructure corruption\n",stderr);
exit(1);
}
paragraph(config,list,para,enc);
}
}
void gen_word(const psiconv_config config, psiconv_list list,
const psiconv_word_f file, const encoding enc)
{
if (!file)
return;
header(config,list,enc);
paragraphs(config,list,file->paragraphs,enc);
footer(config,list,enc);
}
void gen_texted(const psiconv_config config, psiconv_list list,
const psiconv_texted_f file, const encoding enc)
{
header(config,list,enc);
paragraphs(config,list,file->texted_sec->paragraphs,enc);
footer(config,list,enc);
}
int gen_html4(const psiconv_config config, psiconv_list list,
const psiconv_file file, const char *dest,
const encoding enc)
{
encoding enc1 = enc;
if (enc == ENCODING_PSION) {
fputs("Unsupported encoding\n",stderr);
return -1;
} else if (enc == ENCODING_ASCII)
enc1 = ENCODING_ASCII_HTML;
if (file->type == psiconv_word_file) {
gen_word(config,list,(psiconv_word_f) file->file,enc1);
return 0;
} else if (file->type == psiconv_texted_file) {
gen_texted(config,list,(psiconv_texted_f) file->file,enc1);
return 0;
} else
return -1;
}
static struct fileformat_s fileformats[] =
{
{
"HTML4",
"HTML 4.01 Transitional, without CSS",
FORMAT_WORD | FORMAT_TEXTED,
gen_html4
},
{
NULL,
NULL,
0,
NULL
}
};
void init_html4(void)
{
int i;
for (i = 0; fileformats[i].name; i++)
psiconv_list_add(fileformat_list,fileformats+i);
}
psiconv-0.9.8/program/psiconv/gen.h 0000644 0001750 0001750 00000002124 10336374741 014213 0000000 0000000 /*
gen.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1990-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PSICONV_GEN_H
#define PSICONV_GEN_H
#include "psiconv/data.h"
#include "psiconv.h"
void init_xhtml(void);
void init_html4(void);
void init_txt(void);
void init_rtf(void);
void init_image(void);
void init_latex(void);
#endif /* PSICONV_GEN_H */
psiconv-0.9.8/program/psiconv/psiconv.h 0000644 0001750 0001750 00000003364 10336374752 015134 0000000 0000000 /*
psiconv.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 1999-2005 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PSICONV_H
#define PSICONV_H
#include
#include
#define FORMAT_WORD 0x01
#define FORMAT_TEXTED 0x02
#define FORMAT_CLIPART_SINGLE 0x04
#define FORMAT_CLIPART_MULTIPLE 0x08
#define FORMAT_MBM_SINGLE 0x10
#define FORMAT_MBM_MULTIPLE 0x20
#define FORMAT_SKETCH 0x40
typedef enum
{
ENCODING_UTF8,
ENCODING_UCS2,
ENCODING_PSION,
ENCODING_ASCII,
ENCODING_ASCII_HTML
} encoding;
typedef int output_function(const psiconv_config config,
psiconv_list list, const psiconv_file file,
const char *type,
const encoding encoding_type);
typedef struct fileformat_s {
const char *name;
const char *description;
int supported_format;
output_function *output;
} *fileformat;
psiconv_list fileformat_list; /* of struct psiconv_fileformat */
#endif /* PSICONV_H */
psiconv-0.9.8/program/psiconv/magick-aux.h 0000644 0001750 0001750 00000002167 10336374756 015505 0000000 0000000 /*
magick-aux.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2000-2004 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#if IMAGEMAGICK
#if IMAGEMAGICK_API == 1
#include
#else
#include
#include
#include
#include
#endif /* IMAGEMAGICK_OLD */
extern const MagickInfo * GetMagickFileList(void);
#endif /* IMAGEMAGICK */
psiconv-0.9.8/program/psiconv/general.h 0000644 0001750 0001750 00000003432 10336374757 015071 0000000 0000000 /*
general.h - Part of psiconv, a PSION 5 file formats converter
Copyright (c) 2004 Frodo Looijaard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef GENERAL_H
#define GENERAL_H
#include
#include
#include
#include "psiconv.h"
/* Several routines to output text.
The text is appended to a psiconv_list of bytes (u8), in the specified
encoding. A single character may add several bytes to the list, in some
encodings. */
/* Output a single UCS2 character */
extern void output_char(psiconv_config config, psiconv_list list,
psiconv_ucs2 character, encoding enc);
/* Output a string of UCS2 characters */
extern void output_string(psiconv_config config, psiconv_list list,
psiconv_ucs2 *string, encoding enc);
/* Output a string of ASCII chars to the list. Only characters between
0x20 and 0x7e (inclusive) may be used. */
extern void output_simple_chars(psiconv_config config, psiconv_list list,
char *string, encoding enc);
#endif /* GENERAL_H */
psiconv-0.9.8/program/psiconv/psiconv.man 0000644 0001750 0001750 00000002653 10336374763 015462 0000000 0000000 .\"Created with GNOME Manpages Editor
.\"http://gmanedit.sourceforge.net
.\"Sergio Rua
.\"
.TH PSICONV 1 "11 November 2003"
.SH NAME
psiconv \- Translate Psion 5 and other EPOC device files.
.SH SYNOPSIS
.B psiconv
.RI [ \-d | \-\-debug ]
.RI [ \-h | \-\-help ]
.RI [ \-o | \-\-outputfile ]
.RI [ \-s | \-\-silent ]
.RI [ \-T | \-\-type=FILETYPE ]
.RI [ \-V | \-\-version ]
.RI [ \-v | \-\-verbose ]
.RI [ \-u | \-\-UTF8 ]
.RI [ FILE
.IR ... ]
.br
.SH DESCRIPTION
This manual page explains the
.B psiconv
program.
.B Psiconv
translates Psion 5 and other EPOC device files to more commonly used formats.
.br
Psiconv works like a filter: output is sent to
.B stdout
without the
.I -o
option, and input is read from
.B stdin
if no files are given.
.SH OPTIONS
.TP
.IR \-d | \-\-debug
Show debug information on stderr
.TP
.IR \-h | \-\-help
Display this help and exit
.TP
.IR \-o | \-\-outputfile
Output to file instead of stdout
.TP
.IR \-s | \-\-silent
Do not even show warnings on stderr
.TP
.IR \-T | \-\-type=FILETYPE
Output type
.TP
.IR \-V | \-\-version
Display the program version and exit
.TP
.IR \-v | \-\-verbose
Show progress indicators on stderr
.TP
.IR \-u | \-\-UTF8
Input file is encoded in UTF8
.SH LICENCE
Psiconv is released under the Gnu General Public License, version 2 or higher.
.SH BUGS
Many more formats should be supported.
.SH AUTHOR
Frodo Looijaard