/* vim: ts=4 sw=4 sts=4 ff=unix fenc=utf-8 : * ===================================================================== * sc_string.h * Copyright (c) 2003 - 2011 sys0tem * LICENSE : * LGPL (GNU Lesser General Public License - Version 3,29 June 2007) * http://www.gnu.org/copyleft/lesser.html * or * EPL (Eclipse Public License - v1.0) * http://www.eclipse.org/legal/epl-v10.html * ===================================================================== */ #ifndef __SC_STRING_H__ #define __SC_STRING_H__ #include <string.h> #include <sc_os.h> #include <sc_stdbool.h> typedef struct SC_String_ { size_t _useSize; size_t _bufSize; char* buffer; bool (*append)(struct SC_String_*, const char*); void (*setLength)(struct SC_String_*, size_t len); bool (*isEmpty)(struct SC_String_*); void (*clear)(struct SC_String_*); } SC_String; #ifdef __cplusplus extern "C" { #endif size_t SC_strnlen(const char* s, size_t n); char* SC_strndup(const char* s, size_t n, const char* file, int line); char* SC_strndupa(const char* s, size_t n); const char* SC_memindex(const char* target, size_t tSize, const char* search, size_t sSize); int SC_indexOf(const char* str, const char* search); int SC_lastIndexOf(const char* str, const char* search); #define strnlen(s, n) SC_strnlen(s, n) #define strndupa(s, n) SC_strndupa(s, n) #define strdupa(s) strndupa(s, strlen(s)) #ifdef SC_DEBUG #define strndup(s, n) SC_strndup(s, n, __FILE__, __LINE__) #define strdup(s) strndup(s, strlen(s)) #else #define strndup(s, n) SC_strndup(s, n, NULL, 0) #define strdup(s) strndup(s, strlen(s)) #endif /* SC_DEBUG */ SC_String* SC_String_new(size_t bufSize); void SC_String_delete(SC_String* str); #ifdef __cplusplus } #endif #endif /* __SC_STRING_H__ */