summaryrefslogtreecommitdiff
path: root/src/base/textFile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/textFile.c')
-rw-r--r--src/base/textFile.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/base/textFile.c b/src/base/textFile.c
index c09c879..8db6713 100644
--- a/src/base/textFile.c
+++ b/src/base/textFile.c
@@ -1,4 +1,3 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,7 +30,7 @@ textFile_t *text_file_new(char *s)
return new;
}
-static void createLine(list_t * list, char *p, int len)
+static void createLine(list_t *list, char *p, int len)
{
char *line;
char *begin_line;
@@ -47,8 +46,9 @@ static void createLine(list_t * list, char *p, int len)
do {
end_line = memchr(begin_line, '\n', len);
- if (end_line == NULL)
+ if (end_line == NULL) {
break;
+ }
length_line = (int) (end_line - (begin_line));
@@ -65,8 +65,7 @@ static void createLine(list_t * list, char *p, int len)
}
/*
- * Nacita subor *s a vrati ho f
- * formatovany v type textFile_t*
+ * Loads file *s and returns him formatted to textFile_t*
*/
textFile_t *text_file_load(char *s)
{
@@ -79,20 +78,20 @@ textFile_t *text_file_load(char *s)
assert(s != NULL);
if (lstat(s, &buf) < 0) {
- fprintf(stderr, _("ERROR: unable to get file status for %s!\n"), s);
+ fprintf(stderr, _("[Error] Unable to get file status [%s]\n"), s);
return NULL;
}
file_length = buf.st_size;
if ((file = fopen(s, "rb")) == NULL) {
- fprintf(stderr, _("ERROR: unable to open file %s for reading\n"), s);
+ fprintf(stderr, _("[Error] Unable to open file for reading [%s]\n"), s);
return NULL;
}
p = malloc(file_length * sizeof(char));
if (fread(p, file_length * sizeof(char), 1, file) != 1) {
- fprintf(stderr, _("ERROR: unable to read data from file %s\n"), s);
+ fprintf(stderr, _("[Error] Unable to read data from file [%s]\n"), s);
fclose(file);
return NULL;
}
@@ -108,23 +107,22 @@ textFile_t *text_file_load(char *s)
}
/*
- * Zobrazi text ulozeny v *p
- * do stdout
+ * Prints the text saved in *p into stdout
*/
-void text_file_print(textFile_t * p)
+void text_file_print(textFile_t *p)
{
int i;
assert(p != NULL);
- printf(_("Printing file: \"%s\"\n\n"), p->file);
+ printf(_("[Debug] Printing file [%s]\n\n"), p->file);
for (i = 0; i < p->text->count; i++) {
printf("%3d >> %s\n", i, (char *) p->text->list[i]);
}
}
-void text_file_save(textFile_t * p)
+void text_file_save(textFile_t *p)
{
int i;
FILE *file;
@@ -141,10 +139,9 @@ void text_file_save(textFile_t * p)
}
/*
- * Uvolni text ulozeny v type textFile_t*
- * z pamate.
+ * Removes text saved in *p from the memory
*/
-void text_file_destroy(textFile_t * p)
+void text_file_destroy(textFile_t *p)
{
assert(p != NULL);