aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/main.c b/main.c
index 086ed8e..5f3f929 100644
--- a/main.c
+++ b/main.c
@@ -31,13 +31,8 @@ const int color[] = {
COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE};
-
-
-
#define MAX_PATH 1024
-
-
extern char* msg_win_str;
extern conversation* currentConv;
@@ -49,14 +44,14 @@ char status[10];
extern int firstSMSIndex;
extern int canAugment;
extern int showName;
-
-#define DEBUG
-
+extern config_t config;
void fail_exit(const char *msg) {
if (visual_mode)
endwin();
+#ifdef DEBUG
fprintf(stderr, "%s\n", msg);
+#endif
exit(EXIT_FAILURE);
}
@@ -65,6 +60,7 @@ int main(int argc, char* argv[]){
#ifdef DEBUG
freopen("/tmp/mesms.debug", "w", stderr);
#endif
+ readConfigFile();
/* Gestion des paramètres */
while (1) {
@@ -97,12 +93,16 @@ int main(int argc, char* argv[]){
case 'c':
if( optarg ) {
int r = 0;
- if( r = fillContactList(DEFAULT_CONTACT_FILENAME) ) {
- fprintf(stderr, "Erreur à la lecture de la liste des contacts");
+ if( r = fillContactList(config.CONTACT_FILENAME) ) {
+#ifdef DEBUG
+ fprintf(stderr, "Error reading contact list\n");
+#endif
return r;
}
if( r = loadConv() ) {
- fprintf(stderr, "Erreur à la lecture de la liste des contacts");
+#ifdef DEBUG
+ fprintf(stderr, "Error reading contact list\n");
+#endif
return r;
}
contact* contact = NULL;
@@ -113,7 +113,9 @@ int main(int argc, char* argv[]){
else
r = findContactFromName(optarg, &contact);
if( r ) {
- fprintf(stderr, "Contact introuvable");
+#ifdef DEBUG
+ fprintf(stderr, "Missing contact");
+#endif
printf("%s",optarg);
return r;
}
@@ -123,7 +125,9 @@ int main(int argc, char* argv[]){
printf("%s", contact->number);
return 0;
} else {
- fprintf(stderr, "Numéro de téléphone manquant");
+#ifdef DEBUG
+ fprintf(stderr, "Missing phone number");
+#endif
}
break;
@@ -133,10 +137,6 @@ int main(int argc, char* argv[]){
}
}
-
- fprintf(stderr, "test");
-
-
/* Initialisation */
int size = 0;
@@ -172,18 +172,14 @@ int main(int argc, char* argv[]){
int r = 0;
- fprintf(stderr, "test1");
if( r = fillContactList(DEFAULT_CONTACT_FILENAME) ) {
return r;
}
if( r = loadConv() ) {
return r;
}
- fprintf(stderr, "test2");
sortContacts();
- fprintf(stderr, "test3");
-
for(int i = 0 ; i < 9 ; i++) {
init_pair( i+1, i, COLOR_BLACK);
}