CUBRID Engine  latest
variable_string.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * variable_string.h : Variable-length string
22  *
23  */
24 
25 #ifndef _VARIABLE_STRING_H_
26 #define _VARIABLE_STRING_H_
27 
28 #ident "$Id$"
29 
30 #include <sys/types.h>
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
37 
38 /*
39  * Variable-length string gadgets. vs_new() takes the address of a
40  * varstring or NULL; if NULL, it heap-allocates a new one and returns
41  * its address. vs_free() should be used both for stack-allocated and
42  * heap-allocated varstrings; it will free all internal structures,
43  * and then free the varstring structure itself if it was heap
44  * allocated.
45  */
46  typedef struct
47  {
48  char *base;
49  char *limit;
50  char *start;
51  char *end;
53  } varstring;
54 
55  extern varstring *vs_new (varstring * vstr);
56  extern void vs_free (varstring * vstr);
57  extern void vs_clear (varstring * vstr);
58  extern int vs_append (varstring * vstr, const char *suffix);
59  extern int vs_prepend (varstring * vstr, const char *prefix);
60  extern int vs_sprintf (varstring * vstr, const char *fmt, ...);
61  extern int vs_strcat (varstring * vstr, const char *str);
62  extern int vs_strcatn (varstring * vstr, const char *str, int length);
63  extern int vs_strcpy (varstring * vstr, const char *str);
64  extern int vs_putc (varstring * vstr, int);
65  extern char *vs_str (varstring * vstr);
66  extern int vs_strlen (const varstring * vstr);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* _VARIABLE_STRING_H_ */
char * vs_str(varstring *vstr)
int vs_putc(varstring *vstr, int)
int vs_strcatn(varstring *vstr, const char *str, int length)
int vs_strlen(const varstring *vstr)
void vs_clear(varstring *vstr)
int vs_strcat(varstring *vstr, const char *str)
int vs_prepend(varstring *vstr, const char *prefix)
int vs_append(varstring *vstr, const char *suffix)
int vs_sprintf(varstring *vstr, const char *fmt,...)
char * limit
int heap_allocated
void vs_free(varstring *vstr)
int vs_strcpy(varstring *vstr, const char *str)
varstring * vs_new(varstring *vstr)
char * start