summaryrefslogtreecommitdiff
path: root/include/util.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-05 21:45:04 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-05 21:45:04 +0200
commita5f604469d5cde8cb654e209f1ec30bf8e44b51e (patch)
tree58e41e92e9f25de67e21e40510eb3150dac31712 /include/util.h
parentc7f38d808144e8f82805a6b84bfe48740af31b14 (diff)
Comment on all the things
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/util.h')
-rw-r--r--include/util.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/util.h b/include/util.h
index 1ec551c..4857539 100644
--- a/include/util.h
+++ b/include/util.h
@@ -4,14 +4,54 @@
#include <sys/types.h>
+/**
+ * @brief Turn a file path to a more usefull form
+ *
+ * Removes all preceeding and trailing slashes, shortens all sequences of
+ * slashes to a single slash and returns failure state if one of the path
+ * components is '..' or '.'.
+ *
+ * @param filename A pointer to the path to work on
+ *
+ * @return Zero on success, -1 on failure
+ */
int canonicalize_name(char *filename);
+/**
+ * @brief Write data to a file
+ *
+ * This is a wrapper around the Unix write() system call. It retries the write
+ * if it is interrupted by a signal or only part of the data was written.
+ */
ssize_t write_retry(int fd, void *data, size_t size);
+/**
+ * @brief Read data from a file
+ *
+ * This is a wrapper around the Unix read() system call. It retries the read
+ * if it is interrupted by a signal or less than the desired size was read.
+ */
ssize_t read_retry(int fd, void *buffer, size_t size);
+/**
+ * @brief A common implementation of the '--version' command line argument
+ *
+ * Prints out version information. The program name is extracted from the
+ * BSD style __progname global variable.
+ */
void print_version(void);
+/**
+ * @brief Create a directory and all its parents
+ *
+ * This is a wrapper around mkdir() that behaves like 'mkdir -p'. It tries to
+ * create every component of the given path and treats already existing entries
+ * as success.
+ *
+ * @param path A path to create
+ *
+ * @return Zero on success, -1 on failure
+ */
int mkdir_p(const char *path);
#endif /* UTIL_H */