/*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 Lev Walkin . * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sf_smisc.h,v 1.6 2005/05/27 05:34:46 vlm Exp $ */ #ifndef __SF_SMISC_H__ #define __SF_SMISC_H__ #include #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /***********************************/ /*** Plain string array handlers ***/ /***********************************/ char **charize(const char *); /* Make null-terminated char** */ void free_values(char **); /* Free values AND the container */ size_t count_values(char **); int copy_values(char **from, char ***to); char *vjoin(char **, const char *delimiter); /* Join values with delimiter */ ssize_t vfind(char **, const char *); /* Work on char[]'s */ ssize_t cvfind(char **, const char *); /* Case-insensitive */ /**********************************/ /* Misc. string functions helpers */ /**********************************/ int eq (const char *a, const char *b); /* Equality test */ int ecq (const char *a, const char *b); /* Case-insensitive */ int ecq2(const char *a, const char *b); /* b's lowercase assumed */ int countchar (const char *, char what2countChar); int countchar2(const char *, const char *what2countSet); int countstr (const char *, const char *what2countStr); char *genstr(int number); /* Make string containing integer */ char *brace(char *, char rbrace); /* find a closing bracket */ char *bracen(char *, char rbrace, size_t nlen); /* find a closing bracket */ /* Need not to be free()'d */ const char *replace(const char *str, const char *what, const char *to);/* leak-free */ char *replace_detach(void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __SF_SMISC_H__ */