/* librock/astring.h - - - - - - - - - - - - Copyright Notice - - - - - - - - - - - - Copyright 1998 Forrest J. Cavalier III See http://www.mibsoftware.com/librock/ for documentation and original copies of this software. This software shall be distributed with the implementation source code librock/text/astring.c, according to the librock license terms therein. License text in librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45 */ /**************************************************************/ #ifndef librock_INC_ASTRING_H #define librock_INC_ASTRING_H #ifdef librock_ENABLE_FULLDECL /* librock Full feature declarations. Useful rarely. - Declarations with pointer types. - Declarations selectable function by function. - Optional declaration of test/trace wrapper functions - Function type declaration macros */ #include #else #include /*#include */ #ifndef librock_ISOLATED /*#include */ /* Declares the FILE * for afgets() */ #endif #ifdef __cplusplus extern "C" { #endif /* Equivalents to strcpy() and strncpy() */ char *librock_astrcpy(char **ppasz,const char *pSrc); #ifdef librock_SIZE_T char *librock_astrcpyX(char **ppasz,const char *pSrc,void *(*reallocfn)(void *,librock_SIZE_T)); #endif char *librock_astrn0cpy(char **ppasz,const char *pSrc,int n); #ifdef librock_SIZE_T char *librock_astrn0cpyX(char **ppasz,const char *pSrc,int n,void *(*reallocfn)(void *,librock_SIZE_T)); #endif /* NOTE: astrn0cpy Always stores the ending \0 */ /* Equivalents to strcat() and strncat() */ char *librock_astrcat(char **ppasz, const char *pszSrc); #ifdef librock_SIZE_T char *librock_astrcatX(char **ppasz,const char*pszSrc,void *(*reallocfn)(void *,librock_SIZE_T)); #endif char *librock_astrn0cat(char **ppasz,const char *pSrc,int n); #ifdef librock_SIZE_T char *librock_astrn0catX(char **ppasz,const char *pSrc,int n,void *(*reallocfn)(void *,librock_SIZE_T)); #endif /* Non-fixed buffer size line reads */ #ifdef librock_FILE char *librock_afgets(char **ppasz,librock_FILE *f); #ifdef librock_SIZE_T char*librock_afgetsX(char **ppasz,librock_FILE *f,void *(*reallocfn)(void *,librock_SIZE_T)); #endif int librock_afgettoch(char **ppasz,librock_FILE *f,char chStop); #ifdef librock_SIZE_T int librock_afgettochX(char **ppasz,librock_FILE *f,char chStop,void *(*reallocfn)(void *,librock_SIZE_T)); #endif #endif /* Cleanup. */ void librock_astrfree(char **ppasz); #ifdef librock_SIZE_T void librock_astrfreeX(char **ppsz,void *(*reallocfn)(void *,librock_SIZE_T)); #endif /* Ensure there is space for working */ char *librock_astrensure(char **ppasz,int len); #ifdef librock_SIZE_T char *librock_astrensureX(char **ppasz,int len,void *(*reallocfn)(void *,librock_SIZE_T)); #endif /* realloc() so there is no wasted space. Note: not an astring anymore. */ char *librock_astrstatic(char **ppasz); #ifdef librock_SIZE_T char *librock_astrstaticX(char **ppasz,void *(*reallocfn)(void *,librock_SIZE_T)); #endif #ifndef librock_NOIMPL_vastrprintf #ifdef librock_VALIST int librock_vastrprintf(char **ppasz,const char *format,librock_VALIST ap); #endif int librock_astrprintf(char **ppasz,const char *format,...); #endif char *librock_asfmt(char **ppasz,...); /* 2004-03-26 */ #ifdef librock_VALIST char *librock_asvfmt(char **ppasz,const char *first,librock_VALIST *pvap); /* 2004-03-26 */ #endif #ifdef __cplusplus class librock_cpp_astring { /* Simple wrapper to allow auto cleanup in C++ */ private: char *m_asz; public: librock_cpp_astring() { m_asz = 0; }; ~librock_cpp_astring() {librock_astrfree(&m_asz);}; inline char **operator &() { return &m_asz; }; inline operator const char *() { return m_asz; }; }; #endif #ifdef __cplusplus }; #endif #include #endif /* Full declaration check */ #endif /* Recursive-include check */ /* $Log: astring.h,v $ Revision 1.4 2002/03/18 19:28:29 forrest@mibsoftware.com rights=#1 astrprintf prototypes Revision 1.3 2002/02/10 03:11:19 forrest@mibsoftware.com rights=#1 Fix comments Revision 1.2 2002/01/29 04:40:02 forrest@mibsoftware.com rights=#1 Prep for publish. API clean up, TAB, space at eol removal Revision 1.1 2001/01/06 19:36:16 forrest@mibsoftware.com rights=#1 Initial import to CVS rights#1 Copyright (c) Forrest J Cavalier III d-b-a Mib Software rights#1 License text in librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45 */