Define file operations.

This patch adds functions for file open, file read line and
file close.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
diff --git a/utils.c b/utils.c
index 5976f74..bf0c148 100644
--- a/utils.c
+++ b/utils.c
@@ -95,3 +95,41 @@
 	free(rpath);
 	return ret;
 }
+
+int file_open(FILE **fp, const char *path, const char *name, const char *format)
+{
+	int ret;
+	char *rpath;
+
+	ret = asprintf(&rpath, "%s/%s", path, name);
+	if (ret < 0)
+		return ret;
+
+	ret = 0;
+	*fp = fopen(rpath, format);
+	if (!(*fp))
+		ret = -1;
+
+	free(rpath);
+	return ret;
+}
+
+int file_read_line(FILE **fp, char *line, int size)
+{
+	if (!(*fp))
+		return -1;
+
+	if (fgets(line, size, *fp) != NULL)
+		return 0;
+	else
+		return -1;
+}
+
+int file_close(FILE **fp)
+{
+	if (!(*fp))
+		return -1;
+
+	fclose(*fp);
+	return 0;
+}