summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/textfile.c18
-rw-r--r--common/textfile.h12
2 files changed, 15 insertions, 15 deletions
diff --git a/common/textfile.c b/common/textfile.c
index 2ed929a3..bb55109c 100644
--- a/common/textfile.c
+++ b/common/textfile.c
@@ -36,7 +36,7 @@
#include <sys/mman.h>
#include <sys/param.h>
-int create_dirs(char *filename, mode_t mode)
+int create_dirs(const char *filename, const mode_t mode)
{
struct stat st;
char dir[PATH_MAX + 1], *prev, *next;
@@ -70,7 +70,7 @@ int create_dirs(char *filename, mode_t mode)
return 0;
}
-int create_file(char *filename, mode_t mode)
+int create_file(const char *filename, const mode_t mode)
{
int fd;
@@ -86,7 +86,7 @@ int create_file(char *filename, mode_t mode)
return 0;
}
-static inline char *find_key(char *map, char *key, size_t len)
+static inline char *find_key(char *map, const char *key, size_t len)
{
char *off = strstr(map, key);
@@ -97,7 +97,7 @@ static inline char *find_key(char *map, char *key, size_t len)
return off;
}
-static inline int write_key_value(int fd, char *key, char *value)
+static inline int write_key_value(int fd, const char *key, const char *value)
{
char *str;
size_t size;
@@ -119,7 +119,7 @@ static inline int write_key_value(int fd, char *key, char *value)
return err;
}
-static int write_key(char *pathname, char *key, char *value)
+static int write_key(const char *pathname, const char *key, const char *value)
{
struct stat st;
char *map, *off, *end, *str;
@@ -223,17 +223,17 @@ close:
return -err;
}
-int textfile_put(char *pathname, char *key, char *value)
+int textfile_put(const char *pathname, const char *key, const char *value)
{
return write_key(pathname, key, value);
}
-int textfile_del(char *pathname, char *key)
+int textfile_del(const char *pathname, const char *key)
{
return write_key(pathname, key, NULL);
}
-char *textfile_get(char *pathname, char *key)
+char *textfile_get(const char *pathname, const char *key)
{
struct stat st;
char *map, *off, *end, *str = NULL;
@@ -297,7 +297,7 @@ close:
return str;
}
-int textfile_foreach(char *pathname,
+int textfile_foreach(const char *pathname,
void (*func)(char *key, char *value, void *data), void *data)
{
struct stat st;
diff --git a/common/textfile.h b/common/textfile.h
index 3c8b6841..2e6d57b2 100644
--- a/common/textfile.h
+++ b/common/textfile.h
@@ -21,12 +21,12 @@
*
*/
-int create_dirs(char *filename, mode_t mode);
-int create_file(char *filename, mode_t mode);
+int create_dirs(const char *filename, const mode_t mode);
+int create_file(const char *filename, const mode_t mode);
-int textfile_put(char *pathname, char *key, char *value);
-int textfile_del(char *pathname, char *key);
-char *textfile_get(char *pathname, char *key);
+int textfile_put(const char *pathname, const char *key, const char *value);
+int textfile_del(const char *pathname, const char *key);
+char *textfile_get(const char *pathname, const char *key);
-int textfile_foreach(char *pathname,
+int textfile_foreach(const char *pathname,
void (*func)(char *key, char *value, void *data), void *data);