aboutsummaryrefslogtreecommitdiff
path: root/contactList.c
diff options
context:
space:
mode:
authorache <ache@ache.one>2019-02-07 10:59:50 +0100
committerache <ache@ache.one>2019-02-07 11:00:26 +0100
commitb84ddbea51b1247117891be301667feb2fa8975e (patch)
treeccd4ac8b7faaecaa63c8a34007a8930ada47d4dc /contactList.c
parentThe real UTF-8 problem is the code (diff)
Delete contact
Diffstat (limited to 'contactList.c')
-rw-r--r--contactList.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/contactList.c b/contactList.c
index 9c6640c..891054c 100644
--- a/contactList.c
+++ b/contactList.c
@@ -62,6 +62,17 @@ int addContact(const contact* cnct) {
contactList = realloc(contactList, nbContacts * sizeof *contactList);
memcpy(&contactList[nbContacts-1],cnct, sizeof *cnct);
}
+int deleteContact(contact* cnct) {
+ if( cnct->conversation ) {
+ *cnct->name = 0;
+ strcpy(cnct->display_name, cnct->number);
+ } else {
+ int index = cnct - contactList;
+ fprintf(stderr, "Index %d\n", index);
+ memmove(contactList+index, contactList + index + 1, (nbContacts-index-1) * sizeof(contact));
+ nbContacts--;
+ }
+}
int fillContactList(const char* filename) {
FILE* file = fopen(filename, "r");