~ubuntu-branches/ubuntu/breezy/malaga/breezy

« back to all changes in this revision

Viewing changes to malaga.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2005-01-10 11:52:04 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110115204-hpgncw5pb0m1t8i6
Tags: 6.13-5
debian/control (malaga-doc Recommends): Suggest gv as a
postscript-viewer instead of ghostview.  (Closes: #289701).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 1995 Bjoern Beutel. */
 
2
 
 
3
/* Description. =============================================================*/
 
4
 
 
5
/* This is the header file for "libmalaga". */
 
6
 
 
7
/*===========================================================================*/
 
8
 
 
9
#ifdef __cplusplus
 
10
extern "C" {
 
11
#endif
 
12
 
 
13
/* Constants. ===============================================================*/
 
14
 
 
15
/* Current version of libmalaga interface. */
 
16
#define LIBMALAGA_VERSION 6 
 
17
 
 
18
/* Minimum version of libmalaga interface that is still fully supported. */
 
19
#define MIN_LIBMALAGA_VERSION 6
 
20
 
 
21
#undef NULL
 
22
#define NULL 0 /* Null pointer. */
 
23
 
 
24
/* Some standard symbols. */
 
25
enum {NIL_SYMBOL, YES_SYMBOL, NO_SYMBOL, 
 
26
      SYMBOL_SYMBOL, STRING_SYMBOL, NUMBER_SYMBOL, LIST_SYMBOL, RECORD_SYMBOL};
 
27
 
 
28
/* Basic types. =============================================================*/
 
29
 
 
30
/* Numeric types. */
 
31
typedef signed char byte_t; /* Signed 8 bits. */
 
32
typedef unsigned char u_byte_t; /* Unsigned 8 bits. */
 
33
typedef signed short int short_t; /* Signed 16 bits. */
 
34
typedef unsigned short int u_short_t; /* Unsigned 16 bits. */
 
35
typedef signed int int_t; /* Signed 32 bits. */
 
36
typedef unsigned int u_int_t; /* Unsigned 32 bits. */
 
37
 
 
38
/* Character types. */
 
39
typedef char char_t; /* A single char. */
 
40
typedef char_t *string_t; /* An EOS-terminated C-style string. */
 
41
enum {EOS= '\0'}; /* End-Of-String control character. */
 
42
#define ORD(c) ((u_byte_t) (c)) /* The ordinal number of character C. */
 
43
 
 
44
/* Boolean type. */
 
45
#undef bool_t /* <rpc/rpc.h> conflicts with "bool_t" definition */
 
46
#undef TRUE
 
47
#undef FALSE
 
48
typedef enum {FALSE, TRUE} bool_t;
 
49
 
 
50
typedef u_short_t cell_t;
 
51
/* A value is stored in one or more cells.
 
52
 * Use this type if you want to allocate memory (pools etc.) for values. */ 
 
53
 
 
54
typedef cell_t *value_t; /* Reference to a Malaga values by this type. */
 
55
typedef cell_t symbol_t;
 
56
 
 
57
typedef enum {MORPHOLOGY, SYNTAX} grammar_t; /* Grammatical analysis types. */
 
58
 
 
59
/* Variables. ===============================================================*/
 
60
 
 
61
extern char_t malaga_version[]; /* Read only! */
 
62
extern bool_t hangul; /* Read only! */
 
63
 
 
64
extern string_t malaga_error; 
 
65
/* If one of the functions below has created an error, this variable
 
66
 * contains an error message. If a function did its job, it is NULL. */
 
67
 
 
68
extern enum {INTERNAL_ORDER, ALPHABETIC_ORDER, 
 
69
               DEFINITION_ORDER} attribute_order;
 
70
/* The order in which attributes in a record are printed.
 
71
 * INTERNAL_ORDER is the order in which attributes are stored internally.
 
72
 * ALPHABETIC_ORDER means the alphabetic order of the attribute names.
 
73
 * DEFINITION_ORDER is the order in which the attributes are defined in the 
 
74
 * symbol file.
 
75
 * Used by "value_readable". */
 
76
 
 
77
/* Value functions. =========================================================*/
 
78
 
 
79
extern value_t new_value( value_t value );
 
80
/* Allocate space for VALUE and copy it.
 
81
 * Free the space occupied by this value with "free" after use. */
 
82
 
 
83
extern int_t length_of_value( value_t value );
 
84
/* Return the length of VALUE in cells. */
 
85
 
 
86
extern symbol_t get_value_type( value_t value );
 
87
/* Return the type of VALUE. Depending of the type, the result value may be
 
88
 * SYMBOL_SYMBOL, STRING_SYMBOL, NUMBER_SYMBOL, LIST_SYMBOL, RECORD_SYMBOL. */
 
89
 
 
90
extern symbol_t value_to_symbol( value_t value );
 
91
/* Return VALUE as a symbol. It is an error if VALUE is no symbol. */
 
92
 
 
93
extern string_t get_symbol_name( symbol_t symbol );
 
94
/* Return the name of SYMBOL. */
 
95
 
 
96
extern value_t get_atoms( symbol_t symbol );
 
97
/* Return the list of atoms of SYMBOL. */
 
98
 
 
99
extern string_t get_value_string( value_t string );
 
100
/* Return the value of STRING as a C-style string in external encoding. 
 
101
 * The string must be freed after use. */
 
102
 
 
103
extern value_t get_attribute( value_t record, symbol_t attribute );
 
104
/* Return the value of ATTRIBUTE in RECORD or NULL if it doesn't exist. */
 
105
 
 
106
extern int_t get_list_length( value_t list );
 
107
/* Return the number of elements in the list LIST. */
 
108
 
 
109
extern value_t get_element( value_t list, int_t n );
 
110
/* Return the N-th element of the list LIST, or NULL if it doesn't exist.
 
111
 * If N is positive, elements will be counted from the left border.
 
112
 * If N is negative, elements will be counted from the right border. */
 
113
 
 
114
extern double value_to_double( value_t value );
 
115
/* Return the value of VALUE which must be a number value. */
 
116
 
 
117
extern int_t value_to_int( value_t value );
 
118
/* Return the value of VALUE which must be an integral number value. */
 
119
 
 
120
extern value_t get_value_part( value_t value, value_t path );
 
121
/* Return the value part of VALUE that is specified by the path PATH. 
 
122
 * If that value part does not exist, return NULL. */
 
123
 
 
124
extern value_t get_first_item( value_t value );
 
125
/* If VALUE is a list, then return its first element (or NULL).
 
126
 * If VALUE is a record, then return its first attribute (or NULL). */
 
127
 
 
128
extern value_t get_next_item( value_t value, value_t item );
 
129
/* If VALUE is a list, and ELEMENT one of its elements,
 
130
 * then NEW_ELEMENT is the successor of ELEMENT (or NULL).
 
131
 * If VALUE is a record, and ELEMENT one of its attributes,
 
132
 * then NEW_ELEMENT is the next attribute in VALUE (or NULL). */
 
133
 
 
134
extern bool_t values_equal( value_t value1, value_t value2 );
 
135
/* Return a truth value indicating whether VALUE1 and VALUE2 are equal.
 
136
 * VALUE1 an VALUE2 must be of same type or one of them must be nil.
 
137
 * Refer to documentation to see what "equal" in Malaga really means. */
 
138
 
 
139
extern bool_t values_congruent( value_t value1, value_t value2 );
 
140
/* Return a truth value indicating whether VALUE1 and VALUE2 have
 
141
 * at least one element in common.
 
142
 * VALUE1 and VALUE2 must both be symbols or lists. */
 
143
 
 
144
extern bool_t value_in_value( value_t value1, value_t value2 );
 
145
/* Return bool value saying if VALUE1 is element or attribute of VALUE2.
 
146
 * VALUE2 must be a list or a record.
 
147
 * If VALUE2 is a record, then VALUE1 must be a symbol. */
 
148
 
 
149
extern string_t value_to_readable( value_t value, 
 
150
                                   bool_t full_value,
 
151
                                   int_t indent );
 
152
/* Return VALUE in a format readable for humans. 
 
153
 * If FULL_VALUE == TRUE, show all attributes, even those that are hidden.
 
154
 * If INDENT >= 0, format value, i.e. print each element of a list or record
 
155
 * on a line of its own. Assume the value is indented by INDENT columns.
 
156
 * Use "free" to free the space after use. */
 
157
 
 
158
extern value_t parse_malaga_value( string_t string );
 
159
/* Convert the STRING to a Malaga value and return it.
 
160
 * The value must be freed after use.
 
161
 * This function sets "malaga_error". */
 
162
 
 
163
/* Functions. ===============================================================*/
 
164
 
 
165
extern void set_option( string_t option );
 
166
/* Set a libmalaga option.
 
167
 * This function sets "malaga_error". */
 
168
 
 
169
extern string_t get_info( void );
 
170
/* Get info about the current grammar. */
 
171
 
 
172
extern void analyse_item( string_t item, grammar_t grammar );
 
173
/* Analyse ITEM according to GRAMMAR.
 
174
 * GRAMMAR must be MORPHOLOGY or SYNTAX.
 
175
 * This function sets "malaga_error". */
 
176
 
 
177
extern value_t first_analysis_result( void );
 
178
/* Get the first result of the last call of "analyse_item".
 
179
 * Return NULL if there is no result. */
 
180
 
 
181
extern value_t next_analysis_result( void );
 
182
/* Get the next result of the last call of "analyse_item".
 
183
 * Return NULL if there is no more result. */
 
184
 
 
185
extern void init_libmalaga( string_t project_file );
 
186
/* Initialise this module.
 
187
 * This function sets "malaga_error". */
 
188
 
 
189
extern void terminate_libmalaga( void );
 
190
/* Terminate this module. */
 
191
 
 
192
/*===========================================================================*/
 
193
 
 
194
#ifdef __cplusplus
 
195
}
 
196
#endif
 
197
 
 
198
/* End of file. =============================================================*/