aboutsummaryrefslogtreecommitdiff
path: root/contactList.c
diff options
context:
space:
mode:
Diffstat (limited to 'contactList.c')
-rw-r--r--contactList.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/contactList.c b/contactList.c
index 728cade..b40f3d4 100644
--- a/contactList.c
+++ b/contactList.c
@@ -44,11 +44,22 @@ void sortContacts(void) {
qsort(contactList, nbContacts, sizeof *contactList, cmpContact);
}
-int findContactFromName(const char* name, contact** out) {
+int findContactFromName(const char* name, contact** out, contact* from) {
+ int I = 0;
+
+ if( from )
+ I = from - contactList;
+
if( !name || !out || !*name)
return 1;
- for(int i = 0 ; i < nbContacts ; i++) {
+ for(int i = I+1 ; i < nbContacts ; i++) {
+ if( strcasestr(contactList[i].display_name, name) ) {
+ *out = contactList+i;
+ return 0;
+ }
+ }
+ for(int i = 0 ; i <= I ; i++) {
if( strcasestr(contactList[i].display_name, name) ) {
*out = contactList+i;
return 0;
@@ -56,7 +67,6 @@ int findContactFromName(const char* name, contact** out) {
}
return 2;
}
-
int addContact(const contact* cnct) {
nbContacts++;
contactList = realloc(contactList, nbContacts * sizeof *contactList);