added warning if icsLogon file couldn't be opened
authorArun Persaud <arun@nubati.net>
Sat, 25 Sep 2010 04:17:50 +0000 (21:17 -0700)
committerArun Persaud <arun@nubati.net>
Fri, 8 Oct 2010 01:46:53 +0000 (18:46 -0700)
xboard.c

index abf3c26..9a073d0 100644 (file)
--- 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