diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-02-27 13:28:40 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-02-27 13:28:40 +0000 |
commit | a783e2c18c6b566b2f4c2b06e6c388a9645c826c (patch) | |
tree | ae12abc157dee99bd4c67bab25316be06d3519a2 /src/dstring.h | |
parent | cb721df9888a296af824a4acab4916694d6dc35d (diff) | |
download | cpio-a783e2c18c6b566b2f4c2b06e6c388a9645c826c.tar.gz cpio-a783e2c18c6b566b2f4c2b06e6c388a9645c826c.tar.bz2 |
Added to the repository
Diffstat (limited to 'src/dstring.h')
-rw-r--r-- | src/dstring.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/dstring.h b/src/dstring.h new file mode 100644 index 0000000..515ee29 --- /dev/null +++ b/src/dstring.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* dstring.h - Dynamic string handling include file. Requires strings.h. | ||
2 | Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
17 | |||
18 | #ifndef NULL | ||
19 | #define NULL 0 | ||
20 | #endif | ||
21 | |||
22 | /* A dynamic string consists of record that records the size of an | ||
23 | allocated string and the pointer to that string. The actual string | ||
24 | is a normal zero byte terminated string that can be used with the | ||
25 | usual string functions. The major difference is that the | ||
26 | dynamic_string routines know how to get more space if it is needed | ||
27 | by allocating new space and copying the current string. */ | ||
28 | |||
29 | typedef struct | ||
30 | { | ||
31 | int ds_length; /* Actual amount of storage allocated. */ | ||
32 | char *ds_string; /* String. */ | ||
33 | } dynamic_string; | ||
34 | |||
35 | |||
36 | /* Macros that look similar to the original string functions. | ||
37 | WARNING: These macros work only on pointers to dynamic string records. | ||
38 | If used with a real record, an "&" must be used to get the pointer. */ | ||
39 | #define ds_strlen(s) strlen ((s)->ds_string) | ||
40 | #define ds_strcmp(s1, s2) strcmp ((s1)->ds_string, (s2)->ds_string) | ||
41 | #define ds_strncmp(s1, s2, n) strncmp ((s1)->ds_string, (s2)->ds_string, n) | ||
42 | #define ds_index(s, c) index ((s)->ds_string, c) | ||
43 | #define ds_rindex(s, c) rindex ((s)->ds_string, c) | ||
44 | |||
45 | void ds_init (); | ||
46 | void ds_resize (); | ||
47 | char *ds_fgetname (); | ||
48 | char *ds_fgets (); | ||
49 | char *ds_fgetstr (); | ||