aboutsummaryrefslogtreecommitdiffstats
path: root/jnlib/stringhelp.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2001-07-31 15:21:58 +0000
committerWerner Koch <[email protected]>2001-07-31 15:21:58 +0000
commitec8c9d9494494656b2618ecfc43ec485dc931ec4 (patch)
tree6b1c0a24c103fe809693d52ef7cdd1b4ddd36378 /jnlib/stringhelp.c
parentAdded 2 examples (diff)
downloadgpgme-ec8c9d9494494656b2618ecfc43ec485dc931ec4.tar.gz
gpgme-ec8c9d9494494656b2618ecfc43ec485dc931ec4.zip
A couple of minor changes and a short README for Gpgcom
Diffstat (limited to '')
-rw-r--r--jnlib/stringhelp.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/jnlib/stringhelp.c b/jnlib/stringhelp.c
index f222a627..0d3035e8 100644
--- a/jnlib/stringhelp.c
+++ b/jnlib/stringhelp.c
@@ -264,6 +264,79 @@ compare_filenames( const char *a, const char *b )
}
+/****************************************************
+ ******** locale insensitive ctype functions ********
+ ****************************************************/
+/* FIXME: replace them by a table lookup and macros */
+int
+ascii_isupper (int c)
+{
+ return c >= 'A' && c <= 'Z';
+}
+
+int
+ascii_islower (int c)
+{
+ return c >= 'a' && c <= 'z';
+}
+
+int
+ascii_toupper (int c)
+{
+ if (c >= 'a' && c <= 'z')
+ c &= ~0x20;
+ return c;
+}
+
+int
+ascii_tolower (int c)
+{
+ if (c >= 'A' && c <= 'Z')
+ c |= 0x20;
+ return c;
+}
+
+
+int
+ascii_strcasecmp( const char *a, const char *b )
+{
+ if (a == b)
+ return 0;
+
+ for (; *a && *b; a++, b++) {
+ if (*a != *b && ascii_toupper(*a) != ascii_toupper(*b))
+ break;
+ }
+ return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
+}
+
+int
+ascii_memcasecmp( const char *a, const char *b, size_t n )
+{
+ if (a == b)
+ return 0;
+ for ( ; n; n--, a++, b++ ) {
+ if( *a != *b && ascii_toupper (*a) != ascii_toupper (*b) )
+ return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
+ }
+ return 0;
+}
+
+int
+ascii_strcmp( const char *a, const char *b )
+{
+ if (a == b)
+ return 0;
+
+ for (; *a && *b; a++, b++) {
+ if (*a != *b )
+ break;
+ }
+ return *a == *b? 0 : (*(signed char *)a - *(signed char *)b);
+}
+
+
+
/*********************************************
********** missing string functions *********
*********************************************/