Code

Moved sdb_proto_send/sdb_proto_select to sdb_write/sdb_select.
[sysdb.git] / src / include / utils / os.h
index 26f7e59e6016137495fb0a5b2a94a630ddf7738e..38d53b2a8bb1281aa13987403ea60f96b3375a6d 100644 (file)
@@ -37,11 +37,7 @@ extern "C" {
 /*
  * sysdb_mkdir_all:
  * Recursively create the directory 'pathname' (similar to 'mkdir -p' on the
- * command line) and ensure that its mode is 'mode'. Any newly created
- * directories will have permissions according the the specified mode
- * (modified by the process's umask in the usual way). The function will
- * always ensure the specified permissions for the specified directory, even
- * if it exists already.
+ * command line) using file permissions as specified by 'mode'.
  *
  * Returns:
  *  - 0 on success
@@ -50,6 +46,60 @@ extern "C" {
 int
 sdb_mkdir_all(const char *pathname, mode_t mode);
 
+/*
+ * sdb_remove_all:
+ * Recursively deletes the specified path from the filesystem.
+ *
+ * Returns:
+ *  - 0 on success
+ *  - a negative value else
+ */
+int
+sdb_remove_all(const char *pathname);
+
+/*
+ * sdb_get_current_user:
+ * Returns the name of the current user. The string is allocated dynamically
+ * and has to be freed by the caller.
+ *
+ * Returns:
+ *  - the username on success
+ *  - NULL else
+ */
+char *
+sdb_get_current_user(void);
+
+enum {
+       SDB_SELECTIN = 0,
+       SDB_SELECTOUT,
+       SDB_SELECTERR,
+};
+
+/*
+ * sdb_select:
+ * Wait for a file-descriptor to become ready for I/O operations of the
+ * specified type. This is a simple wrapper around the select() system call.
+ * The type argument may be any of the SDB_SELECT* constants.
+ *
+ * Returns:
+ *  - the number of file descriptors ready for I/O
+ *  - a negative value on error
+ */
+int
+sdb_select(int fd, int type);
+
+/*
+ * sdb_write:
+ * Write a message to a file-descriptor. This is a simple wrapper around the
+ * write() system call ensuring that all data is written on success.
+ *
+ * Returns:
+ *  - the number of bytes written
+ *  - a negative value on error
+ */
+ssize_t
+sdb_write(int fd, size_t msg_len, const void *msg);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif