diff options
author | Luke Bratch <l_bratch@yahoo.co.uk> | 2010-10-29 02:59:46 +0100 |
---|---|---|
committer | Luke Bratch <l_bratch@yahoo.co.uk> | 2010-10-29 02:59:46 +0100 |
commit | e5bda37c582ce5b18baebbb852c59da69bf6b7ea (patch) | |
tree | 98e6e004588f492bfee2944b400d78cbd601019e | |
parent | 6e7d4bc9040b619dd3271ba1d01f23c240b7c950 (diff) |
Add support for case insensitive name to number matching
-rw-r--r-- | blasms.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -40,6 +40,15 @@ void replacestr(char* source, int i, char* str) { strcat(source, strtmp + i + 2); } +/* Converts a string to lowercase */ +void strtolower(char* destination, char* source) { + int i; + + for (i = 0; i < strlen(source) + 1; i++) { + destination[i] = tolower(source[i]); + } +} + /* Set a sender's name as part of their number */ void setname(char* telnum) { FILE *fp; @@ -73,6 +82,7 @@ void settelnum(char* telnum, char* sms, int *offsetptr) { FILE *fp; char line[1024]; char name[1000]; + char namelower[1000]; char *strchrp; int offset = *offsetptr; @@ -94,7 +104,9 @@ void settelnum(char* telnum, char* sms, int *offsetptr) { remtrailn(line); if ((strchrp = strchr(line, ' ')) != NULL) { offset = strchrp - line; - if ((strlen(name) == strlen(line) - offset - 1) && !strncmp(name, line + offset + 1, strlen(name))) { + strtolower(namelower, name); + strtolower(line, line); + if ((strlen(name) == strlen(line) - offset - 1) && !strncmp(namelower, line + offset + 1, strlen(name))) { //printf("Name match: %s\n", line); strxfrm(telnum, line, offset); telnum[offset] = '\0'; |