summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-02-11 12:12:27 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-02-11 12:12:27 +0000
commit2fa395ac7d4bd9d0108194c375bf69839f4d62ec (patch)
tree26373779f740a01a82b890e15fbac3a5efca4483 /common
parentdfc20857eb381b464b8fd6efdaac59e4a15f5d6d (diff)
Use const qualifier for textfile library
Diffstat (limited to 'common')
-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);