2 * Copyright 2001-2004 Brandon Long
5 * ClearSilver Templating System
7 * This code is made available under the terms of the ClearSilver License.
8 * http://www.clearsilver.net/license.hdf
12 #ifndef incl_HPHP_NEO_STR_H_
13 #define incl_HPHP_NEO_STR_H_ 1
19 #include "hphp/neo/neo_bool.h"
20 #include "hphp/neo/neo_misc.h"
22 /* This modifies the string its called with by replacing all the white
23 * space on the end with \0, and returns a pointer to the first
24 * non-white space character in the string
26 char *neos_strip (char *s
);
28 char *vsprintf_alloc (const char *fmt
, va_list ap
);
29 char *vnsprintf_alloc (int start_size
, const char *fmt
, va_list ap
);
31 /* Versions of the above which actually return a length, necessary if
32 * you expect embedded NULLs */
33 int vnisprintf_alloc (char **buf
, int start_size
, const char *fmt
, va_list ap
);
34 int visprintf_alloc (char **buf
, const char *fmt
, va_list ap
);
36 typedef struct _string
43 /* At some point, we should add the concept of "max len" to these so we
44 * can't get DoS'd by someone sending us a line without an end point,
46 void string_init (NEOSTRING
*str
);
47 NEOERR
*string_append (NEOSTRING
*str
, const char *buf
);
48 NEOERR
*string_appendn (NEOSTRING
*str
, const char *buf
, int l
);
49 NEOERR
*string_append_char (NEOSTRING
*str
, char c
);
50 NEOERR
*string_appendf (NEOSTRING
*str
, const char *fmt
, ...) ATTRIBUTE_PRINTF(2,3);
51 NEOERR
*string_appendvf (NEOSTRING
*str
, const char *fmt
, va_list ap
);
52 void string_clear (NEOSTRING
*str
);
55 char *repr_string_alloc (const char *s
);
60 #endif /* incl_HPHP_NEO_STR_H_ */