summaryrefslogtreecommitdiffstats
path: root/irc/psybnc/files/patch-src_psybnc.c
blob: a4c2ef801b3d830d43b71766f09cf287ad8f7834 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- src/psybnc.c.orig	2016-06-20 14:41:27 UTC
+++ src/psybnc.c
@@ -44,6 +44,8 @@ int slice=0;
 
 #ifdef HAVE_SSL
 
+int fexists(char *fname);
+
 void initSSL()
 {
     SSL_load_error_strings();
@@ -171,13 +173,17 @@ main (int argc, char **argv)
   if(argc==2)
   {
       strmncpy(configfile,argv[1],sizeof(configfile));
-  } else {
+  } else if (fexists("psybnc.conf")) {
+  		strcpy(configfile, "psybnc.conf");
+  } else if (fexists(PREFIX "/etc/psybnc.conf")) {
       strcpy(configfile,"psybnc.conf");  /* rcsid */
+  } else {
+  		strcpy(configfile, "psybnc.conf");
   }
   conffile=fopen(configfile,"r");
   if(conffile==NULL)
   {
-     printf("Configuration File %s not found, aborting\nRun 'make menuconfig' for creating a configuration or create the file manually.\n",conffile); /* rcsid */
+     printf("Configuration file psybnc.conf not found in current directory or in " PREFIX "/etc/psybnc.conf.\n Copy " PREFIX "/etc/psybnc.conf.sample to the current directory as psybnc.conf :\n        cp " PREFIX "/etc/psybnc.conf.sample psybnc.conf\n\nOR create the file manually.\n"); /* rcsid */
      exit (0x0);
   }
   fclose(conffile);
@@ -302,3 +308,15 @@ main (int argc, char **argv)
   bncmain();
 }
 
+int fexists(char *fname)
+{
+    FILE *fn;
+    int rc=0;
+    fn=fopen(fname,"r");
+    if(fn!=NULL)
+    {
+	fclose(fn);
+	rc=1;
+    }
+    return rc;
+}
OpenPOWER on IntegriCloud