aboutsummaryrefslogtreecommitdiffstats
path: root/util/strgutil.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1998-01-07 20:47:46 +0000
committerWerner Koch <[email protected]>1998-01-07 20:47:46 +0000
commit762d3d7197f622296ea5360a73c46c88dcd26308 (patch)
treecfd34485dc436ef861b4f625d20388f3776c232e /util/strgutil.c
parentpatch release 0.1.1 (diff)
downloadgnupg-762d3d7197f622296ea5360a73c46c88dcd26308.tar.gz
gnupg-762d3d7197f622296ea5360a73c46c88dcd26308.zip
patchlevel 2
Diffstat (limited to '')
-rw-r--r--util/strgutil.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/util/strgutil.c b/util/strgutil.c
index daeefe8ae..ecdcb750c 100644
--- a/util/strgutil.c
+++ b/util/strgutil.c
@@ -62,6 +62,43 @@ memistr( char *buf, size_t buflen, const char *sub )
}
+/****************
+ * remove leading and trailing white spaces
+ */
+char *
+trim_spaces( char *str )
+{
+ char *string, *p, *mark;
+
+ string = str;
+ /* find first non space character */
+ for( p=string; *p && isspace( *(byte*)p ) ; p++ )
+ ;
+ /* move characters */
+ for( (mark = NULL); (*string = *p); string++, p++ )
+ if( isspace( *(byte*)p ) ) {
+ if( !mark )
+ mark = string ;
+ }
+ else
+ mark = NULL ;
+ if( mark )
+ *mark = '\0' ; /* remove trailing spaces */
+
+ return str ;
+}
+
+
+int
+string_count_chr( const char *string, int c )
+{
+ int count;
+ for(count=0; *string; string++ )
+ if( *string == c )
+ count++;
+ return count;
+}
+
/*********************************************
********** missing string functions *********
*********************************************/
@@ -78,3 +115,14 @@ stpcpy(char *a,const char *b)
}
#endif
+#ifndef HAVE_STRLWR
+char *
+strlwr(char *s)
+{
+ char *p;
+ for(p=s; *p; p++ )
+ *p = tolower(*p);
+ return s;
+}
+#endif
+