1 | /**************************************************************************
|
---|
2 | *
|
---|
3 | * local_strings.h -- string routines
|
---|
4 | * Copyright (C) 1994 Neil Sharman
|
---|
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 2 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, write to the Free Software
|
---|
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | *
|
---|
20 | **************************************************************************/
|
---|
21 |
|
---|
22 | #ifndef LOCAL_STRINGS_H
|
---|
23 | #define LOCAL_STRINGS_H
|
---|
24 |
|
---|
25 | #include "sysfuncs.h"
|
---|
26 |
|
---|
27 | class mgString
|
---|
28 | {
|
---|
29 | u_char *data;
|
---|
30 | public:
|
---|
31 | inline int length()
|
---|
32 | {
|
---|
33 | return data[0];
|
---|
34 | }
|
---|
35 | inline u_char *rawdata()
|
---|
36 | {
|
---|
37 | return data;
|
---|
38 | }
|
---|
39 | inline void read(u_char **base)
|
---|
40 | {
|
---|
41 | unsigned int copy, suff;
|
---|
42 |
|
---|
43 | copy = **base;
|
---|
44 | *base = *base + 1;
|
---|
45 | suff = **base;
|
---|
46 | *base = *base + 1;
|
---|
47 | memcpy( (data + copy + 1), *base, suff);
|
---|
48 | *data = copy + suff;
|
---|
49 | *base += suff;
|
---|
50 | }
|
---|
51 | inline void read(FILE *dict)
|
---|
52 | {
|
---|
53 | unsigned int copy, suff;
|
---|
54 | copy = fgetc(dict);
|
---|
55 | suff = fgetc(dict);
|
---|
56 | fread(data + copy + 1, sizeof(u_char), suff, dict);
|
---|
57 | *data = copy + suff;
|
---|
58 | }
|
---|
59 | inline static void readString(u_char **base, u_char *prev)
|
---|
60 | {
|
---|
61 | ((mgString *) &prev)->read(base);
|
---|
62 | }
|
---|
63 | inline static void readString(FILE *dict, u_char *prev)
|
---|
64 | {
|
---|
65 | ((mgString *) &prev)->read(dict);
|
---|
66 | }
|
---|
67 | };
|
---|
68 |
|
---|
69 | int arg_atoi (char *str);
|
---|
70 | int compare (u_char * s1, u_char * s2);
|
---|
71 | int casecompare (u_char * s1, u_char * s2); /* [RPAP - Jan 97: Stem Index Change] */
|
---|
72 | u_char *copy_string (u_char * src_str);
|
---|
73 | char *str255_to_string (u_char * str255, char *str);
|
---|
74 | int prefixlen (u_char * s1, u_char * s2);
|
---|
75 | char *char2str (u_char c);
|
---|
76 | char *word2str (u_char * s);
|
---|
77 | char *de_escape_string (char *s);
|
---|
78 |
|
---|
79 | #endif
|
---|