Lhogho
0.0.028
|
Go to the source code of this file.
Macros | |
#define | STRING(x) ((x)->unode.c[2]) |
#define | WORD(x) ((x)->unode.a[3]) |
#define | LENGTH(x) ((x)->unode.u[1] >> 8) |
#define | IDLENGTH(x) ((x)->unode.u[1]) |
#define | IS_WORD(x) (ID(x)==WORD_ID) |
#define | IS_SUBWORD(x) (ID(x)==SUBWORD_ID) |
#define | IS_ANY_WORD(x) ((ID(x)==WORD_ID)||(ID(x)==SUBWORD_ID)) |
#define | WORD_SIZE 256*256*256 |
max word length (in chars) More... | |
Functions | |
atom_t | new_word (chars_t string, uint_t length) |
creates a new word atom More... | |
atom_t | new_subword (atom_t word, chars_t string, uint_t length) |
creates a new subword atom More... | |
atom_t | create_word (int buff_len) |
Creates word with len buff_len and empty data. More... | |
void | delete_word (atom_t a) |
deletes word atom More... | |
void | delete_subword (atom_t a) |
deletes subword atom More... | |
void | dump_word (atom_t a, int level) |
dumps (sub)word atom More... | |
atom_t | read_word (chars_t filename) |
reads a word from ASCII, UTF-8 or UTF16-LE encoded file More... | |
void | write_word (atom_t word, chars_t filename) |
writes a word to ASCII or UTF-16LE encoded file More... | |
int | same_words (atom_t a, atom_t b) |
compares two words More... | |
atom_t | decode_word (unsigned char *buffer, int size, int dealc) |
decodes ASCII, UTF-8 or UTF16-LE encoded text More... | |
int | atom_to_boolean (atom_t a, int *np) |
convert atom to a boolean More... | |
int | atom_to_string (atom_t a, chars_t buff, int *buff_len) |
convert atom to string More... | |
atom_t | atom_to_word (atom_t data) |
convert atom to word or subword atom More... | |
atom_t | atom_to_real_word (atom_t data) |
convert atom to word More... | |
int | same_strings (int ci, chars_t sa, chars_t sb, int n) |
compares two strings More... | |
Variables | |
int | full_print_p |
integer of FULLPRINTP More... | |
atom_t | false_true [2] |
array holding words with FALSE and TRUE More... | |
#define IS_SUBWORD | ( | x) | (ID(x)==SUBWORD_ID) |
#define IS_ANY_WORD | ( | x) | ((ID(x)==WORD_ID)||(ID(x)==SUBWORD_ID)) |
word | word atom containing the host word of the word |
string | pointer to the first character of the word |
length | length of the word |
Creates a subword atom containing a substring of the string in a word atom. The reference count of the subword is 1, the reference count of the host word atom is incremented.
If word
parameter is subword, then it is replaced by its hosting word.
Definition at line 124 of file words.c.
atom_t create_word | ( | int | buff_len) |
filename | file name |
Reads the contents of text file into a word atom. If Unicode mode is switched off, the file is assumed to be in ASCII, otherwise it is UTF-8 or UTF-16LE (little endian) depending on the BOM (byte order mark). In case of error its code is stored in global variable errno
.
Definition at line 450 of file words.c.
word | word to be written |
wfilename | file name |
Writes the contents of a word atom to a file determined by its name. If Unicode mode is switched of, the encoding is ASCII, otherwise it is UTF-16LE (little endian) and the BOM (byte order mark) is included. In case of error its code is stored in global variable errno
.
Definition at line 339 of file words.c.
atom_t decode_word | ( | unsigned char * | buffer, |
int | size, | ||
int | dealc | ||
) |
buffer | buffer containing raw data |
size | size of buffer |
dealc | deallocate (=1) or not (=0) the input buffer |
If Unicode mode is switched off, the raw data are assumed to be in ASCII, otherwise they are UTF-8 or UTF-16LE (little endian) depending on the BOM (byte order mark).
BOM signatures are:
FF FE
FE FF
EF BB BF
The input buffer is deallocated if dealc!=0
Definition at line 382 of file words.c.
int atom_to_boolean | ( | atom_t | a, |
int * | np | ||
) |
a | atom to convert |
np | pointer where to put the result |
Converts an atom to a boolean integer number, i.e. 0 indicates FALSE and 1 (or non-zero) indicates TRUE. If conversion is possible, then *np will contain the result and the return value will be 1. Otherwise *np will be set to 0 and the return value will be set to 0.
Definition at line 538 of file words.c.
a | atom to convert |
buff | buffer where string will be written |
buff_len | length of the buffer |
Converts an atom to a string. If buffer is too small string is truncated. Conversion is successfull if atom is word, subword or number. Else return 0
Definition at line 649 of file words.c.
data | atom to convert |
Converts an atom to a word or a subword atom. If the input is a (sub)word, then it is returned directly. If it is a number, then a new word is created. Otherwise an error atom is returned.
Definition at line 592 of file words.c.
data | atom to convert |
Converts an atom to a word. This guarantees that the string in the word atom is zero-terminated. If the input is a word then it is reused. Otherwise a new word is created. Note that a new word is created even if the input is a subword.
Definition at line 622 of file words.c.