Fabian Peter Hammerle vor 6 Jahren
Ursprung
Commit
9356287ec4
2 geänderte Dateien mit 15 neuen und 1 gelöschten Zeilen
  1. 3 1
      Makefile
  2. 12 0
      rgpgfs.c

+ 3 - 1
Makefile

@@ -3,7 +3,9 @@ SOURCES = *.c
 .PHONY = format
 
 rgpgfs : $(SOURCES)
-	gcc -Wall -Werror $^ $(shell pkg-config fuse3 --cflags --libs) -o $@
+	gcc -Wall -Werror $^ -o $@ \
+		$(shell pkg-config fuse3 --cflags --libs) \
+		$(shell gpgme-config --cflags --libs)
 
 format : $(SOURCES)
 	clang-format -i -verbose $^

+ 12 - 0
rgpgfs.c

@@ -12,11 +12,15 @@
 // http://libfuse.github.io/doxygen/globals.html
 #define FUSE_USE_VERSION 31
 #include <fuse.h>
+// https://www.gnupg.org/documentation/manuals/gpgme/Function-and-Data-Index.html
+#include <gpgme.h>
 
 #define FUSE_PATH_BUF_LEN 256
 static char cache_dir[] = "/tmp/rgpgfs-cache-XXXXXX";
 static const size_t CACHE_PATH_BUF_LEN = sizeof(cache_dir) + FUSE_PATH_BUF_LEN;
 
+static gpgme_ctx_t gpgme_ctx;
+
 static int rgpgfs_mkdirs(char *path) {
   char *delimiter = strrchr(path, '/');
   if (delimiter == NULL) {
@@ -158,6 +162,14 @@ int main(int argc, char *argv[]) {
     return 1;
   }
   printf("cache: %s\n", cache_dir);
+  printf("gpgme version: %s\n", gpgme_check_version(NULL));
+  gpg_error_t gpgme_init_err = gpgme_new(&gpgme_ctx);
+  if (gpgme_init_err != GPG_ERR_NO_ERROR) {
+    fprintf(stderr, "Failed to initialize gpgme: %s (%d)\n",
+            gpg_strerror(gpgme_init_err), gpgme_init_err);
+    return 1;
+  }
+  gpgme_release(gpgme_ctx);
   // TODO rm -r cache_dir (see man nftw)
   return fuse_main(argc, argv, &rgpgfs_fuse_operations, NULL);
 }