tMake bparams case-insensitive - dedup - deduplicating backup program
(HTM) git clone git://git.z3bra.org/dedup.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 05e0a550a54729efb11fb50d5259312dc9d58dab
(DIR) parent c047a4a58e9abda33685cce531c0e7386cf35290
(HTM) Author: sin <sin@2f30.org>
Date: Thu, 2 May 2019 15:44:39 +0100
Make bparams case-insensitive
Diffstat:
M bcompress.c | 9 +++++----
M bencrypt.c | 9 +++++----
M bstorage.c | 9 +++++----
3 files changed, 15 insertions(+), 12 deletions(-)
---
(DIR) diff --git a/bcompress.c b/bcompress.c
t@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include <snappy-c.h>
t@@ -92,9 +93,9 @@ bccreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar)
struct bops *bops;
int type;
- if (strcmp(bpar->calgo, "none") == 0)
+ if (strcasecmp(bpar->calgo, "none") == 0)
type = CDNONETYPE;
- else if (strcmp(bpar->calgo, "snappy") == 0)
+ else if (strcasecmp(bpar->calgo, "snappy") == 0)
type = CDSNAPPYTYPE;
else
return -1;
t@@ -130,9 +131,9 @@ bcopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar)
return -1;
}
- if (strcmp(bpar->calgo, "none") == 0) {
+ if (strcasecmp(bpar->calgo, "none") == 0) {
cctx->type = CDNONETYPE;
- } else if (strcmp(bpar->calgo, "snappy") == 0) {
+ } else if (strcasecmp(bpar->calgo, "snappy") == 0) {
cctx->type = CDSNAPPYTYPE;
} else {
bops->close(bctx);
(DIR) diff --git a/bencrypt.c b/bencrypt.c
t@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include <sodium.h>
t@@ -97,9 +98,9 @@ becreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar)
struct bops *bops;
int type;
- if (strcmp(bpar->ealgo, "none") == 0)
+ if (strcasecmp(bpar->ealgo, "none") == 0)
type = EDNONETYPE;
- else if (strcmp(bpar->ealgo, "XChaCha20-Poly1305") == 0)
+ else if (strcasecmp(bpar->ealgo, "XChaCha20-Poly1305") == 0)
type = EDCHACHATYPE;
else
return -1;
t@@ -145,9 +146,9 @@ beopen(struct bctx *bctx, char *path, int flags, int mode, struct bparam *bpar)
return -1;
}
- if (strcmp(bpar->ealgo, "none") == 0)
+ if (strcasecmp(bpar->ealgo, "none") == 0)
ectx->type = EDNONETYPE;
- else if (strcmp(bpar->ealgo, "XChaCha20-Poly1305") == 0)
+ else if (strcasecmp(bpar->ealgo, "XChaCha20-Poly1305") == 0)
ectx->type = EDCHACHATYPE;
else {
bops->close(bctx);
(DIR) diff --git a/bstorage.c b/bstorage.c
t@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include <sodium.h>
t@@ -314,9 +315,9 @@ bscreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar)
bhdr->flags = (VMAJ << VMAJSHIFT) | VMIN;
/* Set compression type */
- if (strcmp(bpar->calgo, "none") == 0) {
+ if (strcasecmp(bpar->calgo, "none") == 0) {
bhdr->flags |= CNONETYPE << CALGOSHIFT;
- } else if (strcmp(bpar->calgo, "snappy") == 0) {
+ } else if (strcasecmp(bpar->calgo, "snappy") == 0) {
bhdr->flags |= CSNAPPYTYPE << CALGOSHIFT;
} else {
free(sctx);
t@@ -325,9 +326,9 @@ bscreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar)
}
/* Set encryption type */
- if (strcmp(bpar->ealgo, "none") == 0) {
+ if (strcasecmp(bpar->ealgo, "none") == 0) {
bhdr->flags |= ENONETYPE << EALGOSHIFT;
- } else if (strcmp(bpar->ealgo, "XChaCha20-Poly1305") == 0) {
+ } else if (strcasecmp(bpar->ealgo, "XChaCha20-Poly1305") == 0) {
bhdr->flags |= ECHACHATYPE << EALGOSHIFT;
} else {
free(sctx);