From e5bda37c582ce5b18baebbb852c59da69bf6b7ea Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Fri, 29 Oct 2010 02:59:46 +0100 Subject: Add support for case insensitive name to number matching --- blasms.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'blasms.c') diff --git a/blasms.c b/blasms.c index 641b651..0967170 100644 --- a/blasms.c +++ b/blasms.c @@ -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'; -- cgit v1.2.3