aboutsummaryrefslogtreecommitdiff
path: root/contactList.c
diff options
context:
space:
mode:
Diffstat (limited to 'contactList.c')
-rw-r--r--contactList.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/contactList.c b/contactList.c
index d817120..a5c7107 100644
--- a/contactList.c
+++ b/contactList.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include"contactList.h"
+#define _GNU_SOURCE
+#include "contactList.h"
contact* contactList;
size_t nbContacts;
@@ -70,7 +71,7 @@ int fillContactList(char* filename) {
if( contactList ) {
free(contactList);
}
-
+
if( !file ) {
perror("Unable to read contact file");
return 1;
@@ -82,7 +83,7 @@ int fillContactList(char* filename) {
if( c == ';' ) {
v++;
if( v >= 3) {
- fprintf(stderr, "Invalid format (contact file) : too many field");
+ perror("Invalid format (contact file) : too many field");
return 2; // Invalid
}
}
@@ -91,8 +92,8 @@ int fillContactList(char* filename) {
v = 0;
nbContacts++;
}
- else {// Pas assez
- fprintf(stderr, "Invalid format (contact file) : not enougth field");
+ else {// Not enougth
+ perror("Invalid format (contact file) : not enougth field");
return 2; // Invalid format
}
}
@@ -141,20 +142,26 @@ int fillContactList(char* filename) {
if( v == 0) {
contactList[i].name[nameLength++] = c;
if( nameLength > (sizeof contactList[i].name -1) ) {
+#ifdef DEBUG
fprintf(stderr, "too long name ?");
+#endif
return 3;
}
}else if( v == 1) {
contactList[i].display_name[display_nameLength++] = c;
if( display_nameLength > (sizeof contactList[i].display_name -1) ) {
+#ifdef DEBUG
fprintf(stderr, "too display name ?");
+#endif
return 9;
}
} else {
contactList[i].number[numberLength++] = c;
if( numberLength > (sizeof contactList[i].number -1) ) {
puts(contactList[i].number);
+#ifdef DEBUG
fprintf(stderr, "too long number ?");
+#endif
return 27+i;
}
}