aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-06-05 17:49:36 +1200
committerDavid <dbphillipsnz@gmail.com>2014-06-05 17:49:36 +1200
commitf33d490cc017c0a4915bb2ec175df0238702442b (patch)
tree62c19cd0b68f6d5bfd9a3105858d85b84b88b44a /common.c
parent66e266956c51be09cfc9a8c30c74d1ce80b834e0 (diff)
downloadparamano-f33d490cc017c0a4915bb2ec175df0238702442b.tar.xz
Clean-ups
Diffstat (limited to 'common.c')
-rw-r--r--common.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/common.c b/common.c
index 35bfe43..3bf7dd1 100644
--- a/common.c
+++ b/common.c
@@ -23,7 +23,7 @@
#include <string.h> /* lots of functions */
/***********************************************************************
- * Gets integer value from first line in file
+ * Return integer value from first line in file
**********************************************************************/
int get_int_value_from_file(const char* filename)
{
@@ -34,7 +34,7 @@ int get_int_value_from_file(const char* filename)
if(!(fd = fopen(filename, "r")))
return -1;
- if (fgets(buffer, 100, fd))
+ if (fgets(buffer, sizeof(buffer), fd))
value = get_int(buffer);
fclose(fd);
@@ -51,18 +51,18 @@ bool file_has_line(const char *filename, const char *line)
char buffer[512];
if (!(fd = fopen(filename, "r")))
- return FALSE;
+ return false;
while (fgets(buffer, sizeof(buffer), fd) != NULL)
{
if(strstr(buffer, line) != NULL)
{
fclose(fd);
- return TRUE;
+ return true;
}
}
fclose(fd);
- return FALSE;
+ return false;
}
@@ -76,9 +76,6 @@ int get_int(const char* string)
first_num = strpbrk(string, "0123456789");
debug("first_num: '%s'\n",first_num);
- if(first_num)
- return atoi(first_num);
- debug("first_num was 0, returning 1\n");
- return 1;
+ return atoi(first_num);
}