]> Nishi Git Mirror - sp.git/commitdiff
Haiku対応
author諏訪子 <suwako@076.moe>
Fri, 5 Jul 2024 06:02:32 +0000 (15:02 +0900)
committer諏訪子 <suwako@076.moe>
Fri, 5 Jul 2024 06:02:32 +0000 (15:02 +0900)
CHANGELOG.md
Makefile
README.md
main.c
src/addpass.c
src/delpass.c
src/initpass.c
src/otppass.c
src/showpass.c
src/yankpass.c

index 18d86f4278ea37db272e8d9600adac9310572759..7157a38021e574dd5e1c678f809a11c9421de4fe 100644 (file)
@@ -1,3 +1,6 @@
+# 1.4.0
+* Haiku対応
+
 # 1.3.0
 * 英訳の追加 (レミリア・スカーレットさん)
 * GNU Make → BSD Make
index 4dcab7495f44844b5d16264a1d52686bf0a687fb..1e7727e99844bfc250041f58a9164d67c968070f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,17 +10,22 @@ NAME != cat main.c | grep "const char \*sofname" | awk '{print $$5}' | \
 VERSION != cat main.c | grep "const char \*version" | awk '{print $$5}' | \
        sed "s/\"//g" | sed "s/;//"
 PREFIX = /usr/local
-
-MANPREFIX = ${PREFIX}/man
-
-.if ${UNAME_S} == "FreeBSD"
-MANPREFIX = ${PREFIX}/share/man
+.if ${UNAME_S} == "Haiku"
+PREFIX = /boot/system
 .elif ${UNAME_S} == "Linux"
 PREFIX = /usr
+.endif
+
 MANPREFIX = ${PREFIX}/share/man
-.elif ${UNAME_S} == "NetBSD"
-PREFIX = /usr/pkg
-MANPREFIX = ${PREFIX}/share/man
+.if ${UNAME_S} == "OpenBSD"
+MANPREFIX = ${PREFIX}/man
+.elif ${UNAME_S} == "Haiku"
+MANPREFIX = ${PREFIX}/documentation/man
+.endif
+
+DATAPREFIX = ${PREFIX}/share
+.if ${UNAME_S} == "Haiku"
+DATAPREFIX = ${PREFIX}/data
 .endif
 
 CC = cc
@@ -82,12 +87,12 @@ install: all
        chmod 644 ${DESTDIR}${MANPREFIX}/man1/${NAME}-jp.1
 
 install-zsh:
-       cp sp-completion.zsh ${DESTDIR}${PREFIX}/share/zsh/site-functions/_sp
+       cp sp-completion.zsh ${DESTDIR}${DATAPREFIX}/zsh/site-functions/_sp
 
 uninstall:
        rm -rf ${DESTDIR}${PREFIX}/bin/${NAME}
        rm -rf ${DESTDIR}${MANPREFIX}/man1/${NAME}-en.1
        rm -rf ${DESTDIR}${MANPREFIX}/man1/${NAME}-jp.1
-       rm -rf ${DESTDIR}${PREFIX}/share/zsh/site-functions/_sp
+       rm -rf ${DESTDIR}${DATAPREFIX}/zsh/site-functions/_sp
 
 .PHONY: all clean dist install install-zsh uninstall
index 30756d7fa37f364e0a28e0908c0318f38a0b421b..10bf9f11328a66960b4f682cae69b29f78a4e6d9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -35,6 +35,14 @@ doas make install
 doas make install-zsh
 ```
 
+### Haiku
+```sh
+pkgman install bmake libassuan libassuan_devel gpgme gpgme_devel gnupg llvm18_clang
+bmake
+bmake install
+bmake install-zsh
+```
+
 ## 初期設定 | Initial setup
 「gpg -k」でGPG鍵IDを確認して、「sp -i [GPG ID]」を実行して下さい。
 Confirm your GPG key ID with "gpg -k", and run "sp -i [GPG ID]".
diff --git a/main.c b/main.c
index b549ab0cf92560e3c914552411374218c8a473bf..30065df520d4163608606c32acd64534b5e8f57c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -26,7 +26,11 @@ char *getfullpath(char *arg) {
     return NULL;
   }
 
+#if defined(__HAIKU__)
+  char *basedir = "/config/settings/sp/"
+#else
   char *basedir = "/.local/share/sp/";
+#endif
   size_t fullPathLen;
   char *fullPath;
   if (arg != NULL) {
index 4c7323c6d2589278b7a637213bef8b028e9c5f38..f6e92b59146deabf5c280e2bd8c85976b1a6f93d 100644 (file)
@@ -48,7 +48,11 @@ void addpass(char *file) {
     return;
   }
 
+#if defined(__HAIKU__)
+  char *basedir = "/config/settings/sp/"
+#else
   char *basedir = "/.local/share/sp/";
+#endif
   char *ext = ".gpg";
 
   char pass[256];
index b20d66a7b20a45d75c0b5000e703575db510a50d..5368264ede585cfd5d8e51b05ed7880ed8962e1d 100644 (file)
@@ -70,7 +70,11 @@ int delpass(char *file, int force) {
     return -1;
   }
 
+#if defined(__HAIKU__)
+  char *basedir = "/config/settings/sp/"
+#else
   char *basedir = "/.local/share/sp/";
+#endif
   char *ext = ".gpg";
 
   int alllen = snprintf(NULL, 0, "%s%s%s%s", homedir, basedir, file, ext) + 1;
index 2b4e71b1f2a52d4635c8b3a16449b35e0b4e1e82..c3bc2c93205d2149452e76225ada1af039aee0ea 100644 (file)
@@ -12,7 +12,11 @@ void initpass(char *gpgid) {
     return;
   }
 
+#if defined(__HAIKU)
+  char *basedir = "/config/settings/sp/"
+#else
   char *basedir = "/.local/share/sp/";
+#endif
   char dirpath[256];
   snprintf(dirpath, sizeof(dirpath), "%s%s", homedir, basedir);
 
index c74f13049a23194e245625669784dd2cc293e0ee..3f4e2c4d672f8c159a0b09cdb576fa67e5812452 100644 (file)
@@ -59,6 +59,25 @@ unsigned char *extract_secret(const char *otpauth_url, size_t *decoded_len) {
   return secret_decoded;
 }
 
+#if defined(__HAIKU__)
+uint64_t htobe64(uint64_t counter) {
+  uint64_t res = 0;
+  uint8_t *dest = (uint8_t *)&res;
+  uint8_t *src = (uint8_t *)&counter;
+
+  dest[0] = src[7];
+  dest[1] = src[6];
+  dest[2] = src[5];
+  dest[3] = src[4];
+  dest[4] = src[3];
+  dest[5] = src[2];
+  dest[6] = src[1];
+  dest[7] = src[0];
+
+  return res;
+}
+#endif
+
 uint32_t generate_totp(const char *secret, uint64_t counter) {
   counter = htobe64(counter);
 
index 826974b11c70e31c11aba64742da4e073ea6b6ac..d98eb1e53c6530f3613ca1f50324bf3378fb0e1a 100644 (file)
@@ -51,7 +51,11 @@ const char *showpass(char *file) {
     return NULL;
   }
 
+#if defined(__HAIKU__)
+  char *basedir = "/config/settings/sp/"
+#else
   char *basedir = "/.local/share/sp/";
+#endif
   char *ext = ".gpg";
   int alllen = snprintf(NULL, 0, "%s%s%s%s", homedir, basedir, file, ext) + 1;
   char *gpgpath = malloc(alllen);
index ac5a81437f42baed2c2263a7388a93aa356d2125..d03691d1d55d388426ad6df2e5b07753867c7404 100644 (file)
@@ -48,7 +48,11 @@ void yankpass(char *file) {
     return;
   }
 
+#if defined(__HAIKU__)
+  char *basedir = "/config/settings/sp/"
+#else
   char* basedir = "/.local/share/sp/";
+#endif
   char* ext = ".gpg";
   int alllen = snprintf(NULL, 0, "%s%s%s%s", homedir, basedir, file, ext) + 1;
   char* gpgpath = malloc(alllen);