summaryrefslogtreecommitdiff
path: root/blasms.c
diff options
context:
space:
mode:
authorLuke Bratch <l_bratch@yahoo.co.uk>2010-10-29 02:59:46 +0100
committerLuke Bratch <l_bratch@yahoo.co.uk>2010-10-29 02:59:46 +0100
commite5bda37c582ce5b18baebbb852c59da69bf6b7ea (patch)
tree98e6e004588f492bfee2944b400d78cbd601019e /blasms.c
parent6e7d4bc9040b619dd3271ba1d01f23c240b7c950 (diff)
Add support for case insensitive name to number matching
Diffstat (limited to 'blasms.c')
-rw-r--r--blasms.c14
1 files changed, 13 insertions, 1 deletions
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';