diff options
| author | Harshavardhana Ranganath <harsha@gluster.com> | 2010-02-22 04:37:47 +0000 | 
|---|---|---|
| committer | Anand V. Avati <avati@dev.gluster.com> | 2010-02-22 02:29:38 -0800 | 
| commit | 7c59c0849e4c54be7473151dd45468c68b957ec4 (patch) | |
| tree | 5656139f870dd0d4603967a9e3a3333e8a777dc9 /libglusterfs/src/common-utils.c | |
| parent | 85cda442079ba252d3a1e625b1f53ca207887159 (diff) | |
Add new gf_strstr dropin replacement for "strstr"
Signed-off-by: Harshavardhana <harsha@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 609 (Add new "conf-dir" option)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=609
Diffstat (limited to 'libglusterfs/src/common-utils.c')
| -rw-r--r-- | libglusterfs/src/common-utils.c | 36 | 
1 files changed, 36 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 3f52a90a010..7b5e02a344c 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -565,6 +565,42 @@ free_exit:  }  int  +gf_strstr (const char *str, const char *delim, const char *match) +{ +        char *tmp      = NULL; +        char *save_ptr = NULL; +        char *tmp_str  = NULL; + +        int  ret       = 0; + +        tmp_str = strdup (str); + +        if (str == NULL || delim == NULL || match == NULL || tmp_str == NULL) { +                ret = -1; +		goto out; +	} + + +        tmp = strtok_r (tmp_str, delim, &save_ptr); + +        while (tmp) { +                ret = strcmp (tmp, match); + +                if (ret == 0) +                        break; + +                tmp = strtok_r (NULL, delim, &save_ptr); +        } + +out: +        if (tmp_str) +                free (tmp_str); + +        return ret; + +} + +int  gf_volume_name_validate (const char *volume_name)  {  	const char *vname = NULL;  | 
