home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
APPS
/
TEKST
/
GRECODE
/
RECODE.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-20
|
5KB
|
156 lines
/* Conversion of files between different charsets and usages.
Copyright (C) 1990 Free Software Foundation, Inc.
Francois Pinard <pinard@iro.umontreal.ca>, 1988.
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, 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.
*/
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because it found this file in $srcdir). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
#include <stdio.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
/* Some systems do not define EXIT_*, even with STDC_HEADERS. */
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
#ifdef __STDC__
#define _(Args) Args
#else
#define _(Args) ()
#endif
void *xmalloc _((int));
char *xstrdup _((const char *));
int argmatch _((const char *, const char *const *));
/* Description of a charset. */
typedef const char* DOUBLE_TABLE[8];
typedef struct charset CHARSET;
struct charset
{
const char *name; /* main name */
int ignore; /* non zero if should be ignored */
DOUBLE_TABLE *table; /* double table for RFC 1345 */
int size; /* size of each DOUBLE_TABLE entry */
};
/* Description of a single step of recoding. */
typedef enum quality QUALITY;
enum quality
{
REVERSIBLE, /* reversible one to one recoding */
ONE_TO_ONE, /* simple one to one recoding */
MANY_TO_ONE, /* many characters to one recoding */
ONE_TO_MANY, /* one to many characters recoding */
MANY_TO_MANY /* many to many characters recoding */
};
typedef struct step STEP;
struct step
{
CHARSET *before; /* charset before conversion */
CHARSET *after; /* charset after conversion */
QUALITY quality; /* recoding quality */
void (*init_recode) _((STEP *));
void (*file_recode) _((const STEP *, FILE *, FILE *));
const unsigned char *one_to_one; /* recoding array of 256 chars */
const char *const *one_to_many; /* recoding array of 256 strings */
int conversion_cost; /* cost for this single step only */
};
typedef struct known_pair KNOWN_PAIR;
struct known_pair
{
unsigned char left; /* first character in pair */
unsigned char right; /* second character in pair */
};
/* Description of list formats. */
enum list_format
{
NO_FORMAT, /* format not decided yet */
DECIMAL_FORMAT, /* concise tabular list using decimal */
OCTAL_FORMAT, /* concise tabular list using octal */
HEXADECIMAL_FORMAT, /* concise tabular list using hexadecimal */
FULL_FORMAT /* full list, one character per line */
};
/* recode.c. */
extern int ascii_graphics;
extern char diaeresis_char;
extern int diacritics_only;
extern int strict_mapping;
extern enum list_format list_format;
extern int decoding_charset_flag;
extern const unsigned char *one_to_same;
extern CHARSET *rfc1345;
void usage _((int));
const char *quality_to_string _((QUALITY));
QUALITY merge_qualities _((QUALITY, QUALITY));
void declare_step _((const char *, const char *, QUALITY, void (*) (STEP *),
void (*) (const STEP *, FILE *, FILE *)));
void declare_double_step _((DOUBLE_TABLE *, const char *, int));
unsigned char *invert_table _((const unsigned char *));
void complete_pairs _((STEP *, int, const KNOWN_PAIR *, int, int));
void file_one_to_one _((const STEP *, FILE *, FILE *));
void file_one_to_many _((const STEP *, FILE *, FILE *));
/* charname.c. */
char *symbol_to_charname _((const char *));
/* charset.c. */
extern CHARSET charset_array[];
extern int number_of_charsets;
void prepare_charset_initialization _((void));
CHARSET *find_charset _((const char *));
void declare_alias _((const char *, const char *));
void make_argmatch_array _((void));
const char *clean_charset_name _((const char *));
void list_all_charsets _((void));
void list_full_charset _((CHARSET *));
void list_concise_charset _((CHARSET *));