1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #ifndef STRINGUTILS_H_GUARD_
- #define STRINGUTILS_H_GUARD_
- /* * About * *
- * c+h library for wrapping strings.
- * Suited for:
- * function arguments, no additional var for buffer or length;
- * replacing sprintf() and strcat();
- * read-once-use-often, no need for strlen();
- *
- * Heap allocated, call for SU_free() when you have finished with it.
- * Beware, there is no reallocation inside SU_set() and SU_cat(),
- * take care of fitting your string yourself, otherwise it will be cut off.
- * */
- /* Macros */
- #include <stddef.h>
- #define STRINGUTILS_IMPLEMENTATION
- #define SU_MAX_PATH_LENGTH 4096
- /* Typedef */
- typedef struct string
- {
- char * s;
- size_t length;
- size_t bytes;
- } string;
- /* Protos */
- string * SU_new ( size_t size );
- string * SU_copy ( string * src );
- void SU_construct ( string * dst, size_t src );
- void SU_set ( string * dst, const char * fmt, ... );
- void SU_cat ( string * dst, const char * fmt, ... );
- void SU_free ( string * str );
- void SU_fit_with_trunk ( string * dst, string * src, const char * cutoff );
- string * SU_simple ( char * input );
- #endif
|