From 6b443e7b875f25eaceb11f64d17660260587829e Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Fri, 24 Sep 2010 21:17:50 -0700 Subject: [PATCH] added warning if icsLogon file couldn't be opened --- xboard.c | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/xboard.c b/xboard.c index abf3c26..9a073d0 100644 --- a/xboard.c +++ b/xboard.c @@ -2642,23 +2642,33 @@ CmailSigHandlerCallBack(isr, closure, message, count, error) void ICSInitScript() { - FILE *f; - char buf[MSG_SIZ]; - char *p; + /* try to open the icsLogon script, either in the location given + * or in the users HOME directory + */ + + FILE *f; + char buf[MSG_SIZ]; + char *homedir; - f = fopen(appData.icsLogon, "r"); - if (f == NULL) { - p = getenv("HOME"); - if (p != NULL) { - safeStrCpy(buf, p, sizeof(buf)/sizeof(buf[0]) ); + f = fopen(appData.icsLogon, "r"); + if (f == NULL) + { + homedir = getenv("HOME"); + if (homedir != NULL) + { + safeStrCpy(buf, homedir, sizeof(buf)/sizeof(buf[0]) ); strncat(buf, "/", MSG_SIZ - strlen(buf) - 1); strncat(buf, appData.icsLogon, MSG_SIZ - strlen(buf) - 1); f = fopen(buf, "r"); } } - if (f != NULL) - ProcessICSInitScript(f); + if (f != NULL) + ProcessICSInitScript(f); + else + printf("Warning: Couldn't open icsLogon file (checked %s and %s).\n", appData.icsLogon, buf); + + return; } void -- 1.7.0.4