cfad47cfa3/tads2/cmap.h

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
/* $Header: d:/cvsroot/tads/TADS2/cmap.h,v 1.2 1999/05/17 02:52:14 MJRoberts Exp $ */
2
3
/* 
4
 *   Copyright (c) 1998, 2002 Michael J. Roberts.  All Rights Reserved.
5
 *   
6
 *   Please see the accompanying license file, LICENSE.TXT, for information
7
 *   on using and copying this software.  
8
 */
9
/*
10
Name
11
  cmap.h - character mapping definitions
12
Function
13
  
14
Notes
15
  
16
Modified
17
  05/31/98 MJRoberts  - Creation
18
*/
19
20
#ifndef CMAP_H
21
#define CMAP_H
22
23
struct errcxdef;
24
25
/* ------------------------------------------------------------------------ */
26
/*
27
 *   Initialize the default character mappings.  If no mapping file is to
28
 *   be read, this function will establish identify mappings that leave
29
 *   characters untranslated. 
30
 */
31
void cmap_init_default(void);
32
33
34
/*
35
 *   Load a character map file.  Returns zero on success, non-zero on
36
 *   failure.  If filename is null, we'll use the default mapping.
37
 */
38
int cmap_load(char *filename);
39
40
41
/*
42
 *   Turn off character translation.  This overrides any game character
43
 *   set that we find and simply uses the default translation. 
44
 */
45
void cmap_override(void);
46
47
48
/*
49
 *   Set the game's internal character set.  This should be called when a
50
 *   game is loaded, and the game specifies an internal character set.  If
51
 *   there is no character map file explicitly loaded, we will attempt to
52
 *   load a character mapping file that maps this character set to the
53
 *   current native character set.  Signals an error on failure.  This
54
 *   routine will succeed (without doing anything) if a character set has
55
 *   already been explicitly loaded, since an explicitly-loaded character
56
 *   set overrides the automatic character set selection that we attempt
57
 *   when loading a game.
58
 *   
59
 *   argv0 must be provided so that we know where to look for our mapping
60
 *   file on systems where mapping files are stored in the same directory
61
 *   as the TADS executables.  
62
 */
63
void cmap_set_game_charset(struct errcxdef *errctx,
64
                           char *internal_id, char *internal_ldesc,
65
                           char *argv0);
66
67
68
/* ------------------------------------------------------------------------ */
69
/*
70
 *   Mapping macros 
71
 */
72
73
/* map a native character (read externally) into an internal character */
74
#define cmap_n2i(c) (G_cmap_input[(unsigned char)(c)])
75
76
/* map an internal character into a native character (for display) */
77
#define cmap_i2n(c) (G_cmap_output[(unsigned char)(c)])
78
79
80
/* ------------------------------------------------------------------------ */
81
/*
82
 *   Global character mapping tables.  The character map is established at
83
 *   start-up. 
84
 */
85
86
/* 
87
 *   input-mapping table - for native character 'n', cmap_input[n] yields
88
 *   the internal character code 
89
 */
90
extern unsigned char G_cmap_input[256];
91
92
/*
93
 *   output-mapping table - for internal character 'n', cmap_output[n]
94
 *   yields the output character code 
95
 */
96
extern unsigned char G_cmap_output[256];
97
98
/* the ID of the loaded character set */
99
extern char G_cmap_id[5];
100
101
/* the full name (for display purposes) of the loaded character set */
102
#define CMAP_LDESC_MAX_LEN  40
103
extern char G_cmap_ldesc[CMAP_LDESC_MAX_LEN + 1];
104
105
/*
106
 *   Maximum expansion for an HTML entity mapping 
107
 */
108
#define CMAP_MAX_ENTITY_EXPANSION  50
109
110
111
/* ------------------------------------------------------------------------ */
112
/* 
113
 *   Signatures for character map files.  The signature is stored at the
114
 *   beginning of the file.  
115
 */
116
117
/* single-byte character map version 1.0.0 */
118
#define CMAP_SIG_S100  "TADS2 charmap S100\n\r\01a"
119
120
#endif /* CMAP_H */
121