source: main/branches/64_bit_Greenstone/greenstone2/common-src/indexers/mgpp/lib/local_strings.h@ 23508

Last change on this file since 23508 was 23508, checked in by sjm84, 13 years ago

Committing 64 bit changes into the branch

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
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
27class 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 size_t numbytes = fread(data + copy + 1, sizeof(u_char), suff, dict);
57 if(numbytes != suff)
58 {
59#ifdef DEBUG
60 fprintf(stderr, "[mgpp/lib/local_strings.h L59] number of bytes read by fread does not match the requested amount\n");
61#endif
62 }
63 *data = copy + suff;
64 }
65 inline static void readString(u_char **base, u_char *prev)
66 {
67 ((mgString *) &prev)->read(base);
68 }
69 inline static void readString(FILE *dict, u_char *prev)
70 {
71 ((mgString *) &prev)->read(dict);
72 }
73};
74
75int arg_atoi (char *str);
76int compare (u_char * s1, u_char * s2);
77int casecompare (u_char * s1, u_char * s2); /* [RPAP - Jan 97: Stem Index Change] */
78u_char *copy_string (u_char * src_str);
79char *str255_to_string (u_char * str255, char *str);
80int prefixlen (u_char * s1, u_char * s2);
81char *char2str (u_char c);
82char *word2str (u_char * s);
83char *de_escape_string (char *s);
84
85#endif
Note: See TracBrowser for help on using the repository browser.