aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-09-27 11:22:39 +1200
committerDavid <dbphillipsnz@gmail.com>2014-09-27 11:22:39 +1200
commit3cee02998b117ee10e081aa8a6678c16a8efa413 (patch)
tree62a27f91a0755349f74d5d5d30f485d32d1e1830 /common.c
parent9f144943d69da2e88c304d392e0e3dc984036a28 (diff)
downloadparamano-3cee02998b117ee10e081aa8a6678c16a8efa413.tar.xz
New function for opening files or throwing debug output
Diffstat (limited to 'common.c')
-rw-r--r--common.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/common.c b/common.c
index c471b39..231ad50 100644
--- a/common.c
+++ b/common.c
@@ -1,18 +1,18 @@
/************************************************************************
- * This file is part of paramano. *
+ * This file is part of Paramano. *
* *
- * paramano is free software; you can redistribute it and/or *
+ * Paramano is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 3 of the *
* License, or (at your option) any later version. *
* *
- * paramano is distributed in the hope that it will be useful, *
+ * Paramano is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with paramano. If not, see *
+ * along with Paramano. If not, see *
* <http://www.gnu.org/licenses/>. *
************************************************************************/
@@ -67,6 +67,20 @@ bool file_has_line(const char *filename, const char *line)
/***********************************************************************
+ * Calls fopen on the specified file, giving debug error message on
+ * failure. Returns the file descriptor in all cases.
+ **********************************************************************/
+FILE* check_for_file(char* path)
+{
+ FILE* fd;
+ if(!(fd = fopen(path, "r")))
+ {
+ debug("Couldn't open '%s'\n",path);
+ }
+ return fd;
+}
+
+/***********************************************************************
* Fetches first number (ie the 35 of "35 123") from a
* string
**********************************************************************/