commit 4b06b666a98ea0239b0c72a579f8434246fb2d39
parent 4183d854092f2254ce5e421c5f10a33a70565285
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date: Sat, 20 Nov 2021 17:15:27 +0100
Added windows binary
Diffstat:
6 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/INSTALL b/INSTALL
@@ -8,6 +8,16 @@ pruning table. If so, about 200Mb should be enough.
# Installation
+## On Windows
+
+Try downloading and executing in a terminal the file nissy.exe, then
+follow the instructions in the UNIX section below for downloading and
+installing the pruning tables.
+If nissy.exe does not work, you can try following the UNIX instructions
+in WSL (Windows Subsystem for Linux) or in a similar environment.
+
+Sorry for the inconvenience, I don't have a Windows machine to test this on.
+
## On a UNIX system:
Edit the Makefile to match your local configuration (usually not necessary, but you
diff --git a/Makefile b/Makefile
@@ -22,6 +22,9 @@ options:
nissy:
${CC} ${CFLAGS} -o nissy.o src/*.c
+win:
+ x86_64-w64-mingw32-gcc ${CFLAGS} -static -o nissy.exe src/*.c
+
debug:
${CC} ${DBGFLAGS} -o nissy.o src/*.c
@@ -50,5 +53,5 @@ uninstall:
rm -rf ${DESTDIR}${PREFIX}/bin/nissy ${DESTDIR}${MANPREFIX}/man1/nissy.1
for s in ${SCRIPTS}; do rm -rf ${DESTDIR}${PREFIX}/bin/$$s; done
-.PHONY: all options nissy debug clean dist install uninstall
+.PHONY: all options nissy win debug clean dist install uninstall
diff --git a/doc/nissy.1 b/doc/nissy.1
@@ -127,7 +127,8 @@ If that variable is unset the folder
.Nm $XDG_DATA_HOME/nissy
or
.Nm $HOME/.nissy
-is used instead.
+is used instead. If none of this environment variables is defined
+(e.g. in a non-UNIX system), the current folder is used.
.
.Sh EXAMPLES
.
diff --git a/nissy-2.0beta3.tar.gz b/nissy-2.0beta3.tar.gz
Binary files differ.
diff --git a/nissy.exe b/nissy.exe
Binary files differ.
diff --git a/src/env.c b/src/env.c
@@ -4,6 +4,16 @@ bool initialized_env = false;
char *tabledir;
void
+mymkdir(char *d, int m)
+{
+#ifdef _WIN32
+ mkdir(d);
+#else
+ mkdir(d, m);
+#endif
+}
+
+void
init_env()
{
char *nissydata = getenv("NISSYDATA");
@@ -15,21 +25,24 @@ init_env()
return;
if (nissydata != NULL) {
- tabledir = malloc(strlen(nissydata) * sizeof(char) + 20);
+ tabledir = malloc((strlen(nissydata) + 20) * sizeof(char));
strcpy(tabledir, nissydata);
} else if (localdata != NULL) {
- tabledir = malloc(strlen(localdata) * sizeof(char) + 20);
+ tabledir = malloc((strlen(localdata) + 20) * sizeof(char));
strcpy(tabledir, localdata);
strcat(tabledir, "/nissy");
} else if (home != NULL) {
- tabledir = malloc(strlen(home) * sizeof(char) + 20);
+ tabledir = malloc((strlen(home) + 20) * sizeof(char));
strcpy(tabledir, home);
strcat(tabledir, "/.nissy");
+ } else {
+ tabledir = malloc(20 * sizeof(char));
+ strcpy(tabledir, ".");
}
- mkdir(tabledir, 0777);
+ mymkdir(tabledir, 0777);
strcat(tabledir, "/tables");
- mkdir(tabledir, 0777);
+ mymkdir(tabledir, 0777);
read = !access(tabledir, R_OK);
write = !access(tabledir, W_OK);