tools+libremail: Some refactoring

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-05-02 22:56:40 -04:00
parent 92de3cdebb
commit 7513445d1a
2 changed files with 10 additions and 6 deletions
+6
View File
@@ -9,4 +9,10 @@
/* Length of SHA256 hash in bytes */ /* Length of SHA256 hash in bytes */
#define SHA256_N_BYTES 32 #define SHA256_N_BYTES 32
/* Mailbox directory prefix */
#define MAILBOX_PREFIX "/var/mail"
/* Mailbox creation mode */
#define DEFAULT_MAILBOX_MODE 0600
#endif /* !LIBREMAIL_COMMON_H */ #endif /* !LIBREMAIL_COMMON_H */
+4 -6
View File
@@ -8,6 +8,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "libremail/file.h" #include "libremail/file.h"
#include "libremail/common.h"
/* Maximum command components */ /* Maximum command components */
#define CMD_MAX_CNP 6 #define CMD_MAX_CNP 6
@@ -15,8 +16,6 @@
/* Mailutil version */ /* Mailutil version */
#define MAILUTIL_VERSION "0.0.1" #define MAILUTIL_VERSION "0.0.1"
#define DEFAULT_MAILBOX_MODE 0600
/* /*
* Macro used to assert that the command list count is not * Macro used to assert that the command list count is not
* zero to avoid code duplication. * zero to avoid code duplication.
@@ -65,7 +64,8 @@ cmd_mailbox_create(const char *cmdlist[CMD_MAX_CNP], size_t count)
ASSERT_COUNT_N(count, 3); ASSERT_COUNT_N(count, 3);
snprintf(pathbuf, sizeof(pathbuf), "/var/mail/%s", cmdlist[2]); snprintf(pathbuf, sizeof(pathbuf), "%s/%s",
MAILBOX_PREFIX, cmdlist[2]);
/* Create the mailbox */ /* Create the mailbox */
if (try_mkdir(pathbuf, DEFAULT_MAILBOX_MODE) < 0) { if (try_mkdir(pathbuf, DEFAULT_MAILBOX_MODE) < 0) {
@@ -74,9 +74,7 @@ cmd_mailbox_create(const char *cmdlist[CMD_MAX_CNP], size_t count)
return -1; return -1;
} }
printf("created mailbox '%s' @ %s\n", printf("created mailbox '%s' @ %s\n", cmdlist[2], pathbuf);
cmdlist[2], pathbuf);
return 0; return 0;
} }