Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5/src/tools/tld/cstring.h – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**** cstring.h --- C string manipulation.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 **** Commentary:
36
 *
37
 ***=== INTRODUCTION =========================================================
38
 *
39
 * This file defines the C string type and specifies some functions that can
40
 * be used to manipulate C strings.
41
 *
42
 ***=== TYPES ================================================================
43
 *
44
 ** Type:	CStringP
45
 ** Repr:	char *
46
 *
47
 * This is the C string type.  It should be used for objects that are
48
 * strings, not for references to character objects.  It is actually defined
49
 * in the file "os-interface.h" to avoid a circularity in the header files
50
 * in this directory, but all files outside of this directory should get the
51
 * type definition by including this file.
52
 *
53
 ***=== FUNCTIONS ============================================================
54
 *
55
 ** Function:	CStringP		cstring_duplicate
56
 *			PROTO_S ((CStringP cstring))
57
 ** Exceptions:	XX_dalloc_no_memory
58
 *
59
 * This function returns a dynamically allocated copy of the specified
60
 * cstring.
61
 *
62
 ** Function:	CStringP		cstring_duplicate_prefix
63
 *			PROTO_S ((CStringP cstring, unsigned prefix))
64
 ** Exceptions:	XX_dalloc_no_memory
65
 *
66
 * This function returns a dynamically allocated copy of the specified prefix
67
 * of the specified cstring.  If the cstring is shorter than the prefix
68
 * length, then only the cstring is used.
69
 *
70
 ** Function:	unsigned		cstring_hash_value
71
 *			PROTO_S ((CStringP cstring))
72
 ** Exceptions:
73
 *
74
 * This function returns the hash value associated with the specified
75
 * cstring.  This value is guaranteed to be identical for all cstrings
76
 * with the same content.
77
 *
78
 ** Function:	unsigned		cstring_length
79
 *			PROTO_S ((CStringP cstring))
80
 ** Exceptions:
81
 *
82
 * This function returns the length of the specified cstring.
83
 *
84
 ** Function:	BoolT			cstring_equal
85
 *			PROTO_S ((CStringP cstring1, CStringP cstring2))
86
 ** Exceptions:
87
 *
88
 * This function returns true if the specified cstrings have the same
89
 * content, and false otherwise.
90
 *
91
 ** Function:	BoolT			cstring_ci_equal
92
 *			PROTO_S ((CStringP cstring1, CStringP cstring2))
93
 ** Exceptions:
94
 *
95
 * This function returns true if the specified cstrings have the same
96
 * content (ignoring differences in case), and false otherwise.
97
 *
98
 ** Function:	BoolT			cstring_to_unsigned
99
 *			PROTO_S ((CStringP cstring, unsigned *num_ref))
100
 ** Exceptions:
101
 *
102
 * This function parses an unsigned number in cstring.  If there is a valid
103
 * number in the string, it is assigned to the number pointed to by num_ref,
104
 * and the function returns true; otherwise the function returns false.  The
105
 * function checks for overflow; it will return false if the number is too
106
 * big.
107
 *
108
 ** Function:	BoolT			cstring_contains
109
 *			PROTO_S ((CStringP cstring, char c))
110
 ** Exceptions:
111
 *
112
 * This function returns true if the specified cstring contains the character
113
 * c, and false if it doesn't.
114
 *
115
 ** Function:	CStringP		cstring_find
116
 *			PROTO_S ((CStringP cstring, char c))
117
 ** Exceptions:
118
 *
119
 * This function returns a pointer to the first occurrence of the specified
120
 * character in the specified cstring, or nil if there is no occurrence.
121
 *
122
 ** Function:	CStringP		cstring_find_reverse
123
 *			PROTO_S ((CStringP cstring, char c))
124
 ** Exceptions:
125
 *
126
 * This function returns a pointer to the last occurrence of the specified
127
 * character in the specified cstring, or nil if there is no occurrence.
128
 *
129
 **** Change Log:
130
 * $Log: cstring.h,v $
131
 * Revision 1.1.1.1  1998/01/17  15:57:17  release
132
 * First version to be checked into rolling release.
133
 *
134
 * Revision 1.2  1994/12/12  11:45:26  smf
135
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
136
 * OSSG C Coding Standards.
137
 *
138
 * Revision 1.1.1.1  1994/07/25  16:06:09  smf
139
 * Initial import of os-interface shared files.
140
 *
141
**/
142
 
143
/****************************************************************************/
144
 
145
#ifndef H_CSTRING
146
#define H_CSTRING
147
 
148
#include "os-interface.h"
149
#include "dalloc.h"
150
 
151
/*--------------------------------------------------------------------------*/
152
 
153
extern CStringP			cstring_duplicate
154
	PROTO_S ((CStringP));
155
extern CStringP			cstring_duplicate_prefix
156
	PROTO_S ((CStringP, unsigned));
157
extern unsigned			cstring_hash_value
158
	PROTO_S ((CStringP));
159
extern unsigned			cstring_length
160
	PROTO_S ((CStringP));
161
extern BoolT			cstring_equal
162
	PROTO_S ((CStringP, CStringP));
163
extern BoolT			cstring_ci_equal
164
	PROTO_S ((CStringP, CStringP));
165
extern BoolT			cstring_to_unsigned
166
	PROTO_S ((CStringP, unsigned *));
167
extern BoolT			cstring_contains
168
	PROTO_S ((CStringP, char));
169
extern CStringP			cstring_find
170
	PROTO_S ((CStringP, char));
171
extern CStringP			cstring_find_reverse
172
	PROTO_S ((CStringP, char));
173
 
174
/*--------------------------------------------------------------------------*/
175
 
176
#ifdef FS_FAST
177
#define cstring_length(s) ((unsigned) strlen (s))
178
#define cstring_equal(s1, s2) (strcmp ((s1), (s2)) == 0)
179
#define cstring_contains(s, c) (strchr ((s), (c)) != NIL (CStringP))
180
#define cstring_find(s, c) (strchr ((s), (c)))
181
#define cstring_find_reverse(s, c) (strrchr ((s), (c)))
182
#endif /* defined (FS_FAST) */
183
 
184
#endif /* !defined (H_CSTRING) */