diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2026-04-26 11:51:56 +0200 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2026-04-26 11:53:41 +0200 |
| commit | d2fb6a8aac6abe5bfe4b4ea7f2528d119afbc8c6 (patch) | |
| tree | 611f03f03044f8f1210984d03b1cd28cd52016f2 /src/system.h | |
| parent | 34d935265e65b6b2a5c5dbdaf0c2cbcb97c205e1 (diff) | |
Create a "system" module
Also unify makefiles, otherwise dependencies are not properly resolved.
Diffstat (limited to 'src/system.h')
| -rw-r--r-- | src/system.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/system.h b/src/system.h new file mode 100644 index 0000000..950a82a --- /dev/null +++ b/src/system.h @@ -0,0 +1,30 @@ +#ifndef SYSTEM_H +#define SYSTEM_H + +/* Routines for interacting with the system, mainly executing processes and + * dealing with the file system. */ + +/* Used when encrypting or decrypting a file, see the copy_file_with_encryption + * function. */ +enum encrypt { + ENCRYPT, + DECRYPT +}; + +/* Return whether PATH exists in the file system. Exit if any non-"file not + * fount" error occurs. */ +int file_exists(const char *path); + +/* Copy the file whose path is IN at path OUT. OUT is created or overwritten if + * needed. */ +void copy_file(const char *in, const char *out); + +/* Like copy_file but with encryption, which is managed using GPG. */ +void copy_file_with_encryption(const char *in, const char *out, enum encrypt encrypt); + +/* Execute command in a child process, then wait for the child to exit before + * returning. If any error occurs, including in the child process, then if EXIT + * is non-zero, exit, else return -1. Return 0 on success. */ +int ftag_execvp(char *const *cmd, int can_exit); + +#endif |
