aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/dxvk.c6
-rw-r--r--src/main.c9
-rw-r--r--src/tar.c4
-rw-r--r--src/wine.c76
-rw-r--r--src/wine.h4
6 files changed, 82 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 0361e08..5aedaf9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
# GENERAL VARIABLES
NAME := polecat
-VERSION := 0.1.1
+VERSION := 0.1.2
TARGET ?= debug
DEBUG := 0
ifeq ($(TARGET),debug)
diff --git a/src/dxvk.c b/src/dxvk.c
index 32d7d69..817f195 100644
--- a/src/dxvk.c
+++ b/src/dxvk.c
@@ -40,7 +40,7 @@ int dxvk_install(int argc, char** argv)
if (choice > json_object_array_length(runner) - 1 || choice < 0)
{
- printf("`%i' is not a valid ID\n\nrun `polecat dxvk list' to get a valid ID", choice);
+ printf("`%i' is not a valid ID\n\nrun `" NAME " dxvk list' to get a valid ID", choice);
}
else
{
@@ -62,7 +62,7 @@ int dxvk_install(int argc, char** argv)
}
else
{
- puts("Usage: polecat dxvk download <ID>\n\nIDs are obtained via `polecat dxvk list' ");
+ puts("Usage: " NAME " dxvk download <ID>\n\nIDs are obtained via `" NAME " dxvk list' ");
}
return 0;
}
@@ -90,7 +90,7 @@ int dxvk_list(int argc, char** argv)
int dxvk_help(int argc, char** argv)
{
- puts("usage: polecat dxvk <command>\n\nList of commands:");
+ puts("usage: " NAME " dxvk <command>\n\nList of commands:");
print_help(dxvk_commands, ARRAY_LEN(dxvk_commands));
diff --git a/src/main.c b/src/main.c
index f1775e3..a3c1e8e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
+#include <linux/limits.h>
#include "main.h"
#include "wine.h"
@@ -9,7 +10,7 @@
const static struct Command main_commands[] = {
{ .name = "wine", .func = wine, .description = "manage wine versions" },
- { .name = "dxvk", .func = dxvk, .description = "manage dxvk versions (TODO)" },
+ //{ .name = "dxvk", .func = dxvk, .description = "manage dxvk versions (TODO)" },
{ .name = "info", .func = main_info, .description = "show some information about polecat" },
{ .name = "help", .func = main_help, .description = "displays this message" },
};
@@ -30,8 +31,8 @@ int main(int argc, char** argv)
int main_info(int argc, char** argv)
{
- char cfgdir[256];
- char datadir[256];
+ char cfgdir[PATH_MAX];
+ char datadir[PATH_MAX];
getConfigDir(cfgdir);
getDataDir(datadir);
@@ -49,7 +50,7 @@ int main_info(int argc, char** argv)
int main_help(int argc, char** argv)
{
- puts("usage: polecat <command>\n\nList of commands:");
+ puts("usage: " NAME " <command>\n\nList of commands:");
print_help(main_commands, ARRAY_LEN(main_commands));
diff --git a/src/tar.c b/src/tar.c
index 3f2983b..b2f4ba5 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -49,7 +49,7 @@ void extract(const char* filename, const char* outputdir)
a = archive_read_new();
archive_read_support_format_all(a);
- archive_read_support_compression_all(a);
+ archive_read_support_filter_all(a);
ext = archive_write_disk_new();
archive_write_disk_set_options(ext, flags);
archive_write_disk_set_standard_lookup(ext);
@@ -99,4 +99,4 @@ void extract(const char* filename, const char* outputdir)
archive_write_free(ext);
if (cwd != NULL) chdir(cwd);
-} \ No newline at end of file
+}
diff --git a/src/wine.c b/src/wine.c
index 82ab655..fe63644 100644
--- a/src/wine.c
+++ b/src/wine.c
@@ -1,8 +1,13 @@
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <json.h>
#include <libgen.h>
#include <unistd.h>
+#include <linux/limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
#include "wine.h"
#include "net.h"
@@ -10,10 +15,13 @@
#include "common.h"
#include "config.h"
+
const static struct Command wine_commands[] = {
- { .name = "install", .func = wine_install, .description = "download and install a wine version from lutris" },
- { .name = "list", .func = wine_list, .description = "list available wine versions" },
- { .name = "help", .func = wine_help, .description = "shows this message" },
+ { .name = "download", .func = wine_download, .description = "download and extract a wine version from lutris" },
+ { .name = "list", .func = wine_list, .description = "list installable wine versions" },
+ { .name = "run", .func = wine_run, .description = "run a installed wine version" },
+ { .name = "list-installed", .func = wine_installed, .description = "list installed wine versions" },
+ { .name = "help", .func = wine_help, .description = "shows this message" },
};
int wine(int argc, char** argv)
@@ -29,7 +37,7 @@ int wine(int argc, char** argv)
return wine_help(argc, argv);
}
-int wine_install(int argc, char** argv)
+int wine_download(int argc, char** argv)
{
if (argc == 4)
{
@@ -54,8 +62,8 @@ int wine_install(int argc, char** argv)
json_object_object_get_ex(value, "url", &url);
char* name = basename((char*)json_object_get_string(url));
- char datadir[256];
- char downloadpath[256];
+ char datadir[PATH_MAX];
+ char downloadpath[PATH_MAX];
getDataDir(datadir);
makeDir(datadir);
@@ -74,7 +82,7 @@ int wine_install(int argc, char** argv)
}
else
{
- puts("Usage: polecat wine download <ID>\n\nIDs are obtained via `polecat wine list' ");
+ puts("Usage: " NAME " wine download <ID>\n\nIDs are obtained via `" NAME " wine list' ");
}
return 0;
}
@@ -101,9 +109,61 @@ int wine_list(int argc, char** argv)
return 0;
}
+int wine_run(int argc, char** argv)
+{
+ if (argc > 3)
+ {
+ char winepath[PATH_MAX];
+ getDataDir(winepath);
+ char* winever = argv[3];
+
+ strcat(winepath, "/");
+ strcat(winepath, winever);
+ strcat(winepath, "/bin/wine");
+
+ for (int i = 4; i < argc; ++i)
+ {
+ strcat(winepath, " ");
+ strcat(winepath, argv[i]);
+ }
+
+ return system(winepath);
+ }
+ else
+ {
+ fprintf(stderr, "Specify a what wine version to run.\nUse `" NAME " wine list-installed' to list available versions\n");
+ }
+
+ return 0;
+}
+
+int wine_installed(int argc, char** argv)
+{
+ char datadir[PATH_MAX];
+ getDataDir(datadir);
+
+ DIR *dir;
+ struct dirent *ent;
+
+ fprintf(stderr, "Installed wine versions:\n");
+ if ((dir = opendir(datadir)) != NULL)
+ {
+ while ((ent = readdir (dir)) != NULL)
+ {
+ if (ent->d_name[0] != '.' && ent->d_type == 4)
+ {
+ fprintf(stderr, " - %s\n", ent->d_name);
+ }
+ }
+ closedir (dir);
+ }
+
+ return 0;
+}
+
int wine_help(int argc, char** argv)
{
- puts("usage: polecat wine <command>\n\nList of commands:");
+ puts("usage: " NAME " wine <command>\n\nList of commands:");
print_help(wine_commands, ARRAY_LEN(wine_commands));
diff --git a/src/wine.h b/src/wine.h
index 872a17e..47da0f2 100644
--- a/src/wine.h
+++ b/src/wine.h
@@ -2,8 +2,10 @@
#define WINE_H
int wine(int, char**);
-int wine_install(int, char**);
+int wine_download(int, char**);
int wine_list(int, char**);
+int wine_run(int, char**);
+int wine_installed(int, char**);
int wine_help(int, char**);
#endif \ No newline at end of file