OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [charset.h] - Blame information for rev 476

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
/* Character set conversion support for GDB.
2
   Copyright (C) 2001, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3
 
4
   This file is part of GDB.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
 
19
#ifndef CHARSET_H
20
#define CHARSET_H
21
 
22
/* If the target program uses a different character set than the host,
23
   GDB has some support for translating between the two; GDB converts
24
   characters and strings to the host character set before displaying
25
   them, and converts characters and strings appearing in expressions
26
   entered by the user to the target character set.
27
 
28
   GDB's code pretty much assumes that the host character set is some
29
   superset of ASCII; there are plenty if ('0' + n) expressions and
30
   the like.  */
31
 
32
/* Return the name of the current host/target character set.  The
33
   result is owned by the charset module; the caller should not free
34
   it.  */
35
const char *host_charset (void);
36
const char *target_charset (struct gdbarch *gdbarch);
37
const char *target_wide_charset (struct gdbarch *gdbarch);
38
 
39
/* These values are used to specify the type of transliteration done
40
   by convert_between_encodings.  */
41
enum transliterations
42
  {
43
    /* Error on failure to convert.  */
44
    translit_none,
45
    /* Transliterate to host char.  */
46
    translit_char
47
  };
48
 
49
/* Convert between two encodings.
50
 
51
   FROM is the name of the source encoding.
52
   TO is the name of the target encoding.
53
   BYTES holds the bytes to convert; this is assumed to be characters
54
   in the target encoding.
55
   NUM_BYTES is the number of bytes.
56
   WIDTH is the width of a character from the FROM charset, in bytes.
57
   For a variable width encoding, WIDTH should be the size of a "base
58
   character".
59
   OUTPUT is an obstack where the converted data is written.  The
60
   caller is responsible for initializing the obstack, and for
61
   destroying the obstack should an error occur.
62
   TRANSLIT specifies how invalid conversions should be handled.  */
63
void convert_between_encodings (const char *from, const char *to,
64
                                const gdb_byte *bytes, unsigned int num_bytes,
65
                                int width, struct obstack *output,
66
                                enum transliterations translit);
67
 
68
 
69
/* These values are used by wchar_iterate to report errors.  */
70
enum wchar_iterate_result
71
  {
72
    /* Ordinary return.  */
73
    wchar_iterate_ok,
74
    /* Invalid input sequence.  */
75
    wchar_iterate_invalid,
76
    /* Incomplete input sequence at the end of the input.  */
77
    wchar_iterate_incomplete,
78
    /* EOF.  */
79
    wchar_iterate_eof
80
  };
81
 
82
/* Declaration of the opaque wchar iterator type.  */
83
struct wchar_iterator;
84
 
85
/* Create a new character iterator which returns wchar_t's.  INPUT is
86
   the input buffer.  BYTES is the number of bytes in the input
87
   buffer.  CHARSET is the name of the character set in which INPUT is
88
   encoded.  WIDTH is the number of bytes in a base character of
89
   CHARSET.
90
 
91
   This function either returns a new character set iterator, or calls
92
   error.  The result can be freed using a cleanup; see
93
   make_cleanup_wchar_iterator.  */
94
struct wchar_iterator *make_wchar_iterator (const gdb_byte *input, size_t bytes,
95
                                            const char *charset,
96
                                            size_t width);
97
 
98
/* Return a new cleanup suitable for destroying the wchar iterator
99
   ITER.  */
100
struct cleanup *make_cleanup_wchar_iterator (struct wchar_iterator *iter);
101
 
102
/* Perform a single iteration of a wchar_t iterator.
103
 
104
   Returns the number of characters converted.  A negative result
105
   means that EOF has been reached.  A positive result indicates the
106
   number of valid wchar_ts in the result; *OUT_CHARS is updated to
107
   point to the first valid character.
108
 
109
   In all cases aside from EOF, *PTR is set to point to the first
110
   converted target byte.  *LEN is set to the number of bytes
111
   converted.
112
 
113
   A zero result means one of several unusual results.  *OUT_RESULT is
114
   set to indicate the type of un-ordinary return.
115
 
116
   wchar_iterate_invalid means that an invalid input character was
117
   seen.  The iterator is advanced by WIDTH (the argument to
118
   make_wchar_iterator) bytes.
119
 
120
   wchar_iterate_incomplete means that an incomplete character was
121
   seen at the end of the input sequence.
122
 
123
   wchar_iterate_eof means that all bytes were successfully
124
   converted.  The other output arguments are not set.  */
125
int wchar_iterate (struct wchar_iterator *iter,
126
                   enum wchar_iterate_result *out_result,
127
                   gdb_wchar_t **out_chars,
128
                   const gdb_byte **ptr, size_t *len);
129
 
130
 
131
 
132
/* GDB needs to know a few details of its execution character set.
133
   This knowledge is isolated here and in charset.c.  */
134
 
135
/* The escape character.  */
136
#define HOST_ESCAPE_CHAR 27
137
 
138
/* Convert a letter, like 'c', to its corresponding control
139
   character.  */
140
char host_letter_to_control_character (char c);
141
 
142
/* Convert a hex digit character to its numeric value.  E.g., 'f' is
143
   converted to 15.  This function assumes that C is a valid hex
144
   digit.  Both upper- and lower-case letters are recognized.  */
145
int host_hex_value (char c);
146
 
147
#endif /* CHARSET_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.