aboutsummaryrefslogtreecommitdiff
path: root/src/wine.c
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2020-08-10 12:43:26 +0200
committerJan200101 <sentrycraft123@gmail.com>2020-08-10 12:43:26 +0200
commit1753e2b151cbb4af75a4e9ea61720b3704b03805 (patch)
tree6265e9829a6d6b76ddae13de2138ef8f1c657ccd /src/wine.c
parentc11dd0eae09df4982459a34d764910d0501f2ae2 (diff)
downloadpolecat-1753e2b151cbb4af75a4e9ea61720b3704b03805.tar.gz
polecat-1753e2b151cbb4af75a4e9ea61720b3704b03805.zip
a lot of changes […]0.1.3
- go to next entry of argv and decrement argc the deeper it goes - add basic lutris functionality - remove "help" from help message and as a command - replace all stderr prints with stdout prints (usually stderr is better for directly informing the user but in this case I don't think it will help much) - add libarchive dependency to the README - bump version number
Diffstat (limited to 'src/wine.c')
-rw-r--r--src/wine.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/wine.c b/src/wine.c
index 3f50eee..c6f445e 100644
--- a/src/wine.c
+++ b/src/wine.c
@@ -17,29 +17,29 @@
const static struct Command wine_commands[] = {
- { .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" },
+ { .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 = "installed", .func = wine_installed, .description = "list installed wine versions" },
};
int wine(int argc, char** argv)
{
- if (argc > 2)
+ if (argc > 1)
{
for (int i = 0; i < ARRAY_LEN(wine_commands); ++i)
{
- if (!strcmp(wine_commands[i].name, argv[2])) return wine_commands[i].func(argc, argv);
+ if (!strcmp(wine_commands[i].name, argv[1])) return wine_commands[i].func(argc-1, argv+1);
}
}
+
return wine_help(argc, argv);
}
int wine_download(int argc, char** argv)
{
- if (argc == 4)
+ if (argc == 2)
{
struct json_object* runner = fetchJSON(WINE_API);
@@ -48,11 +48,11 @@ int wine_download(int argc, char** argv)
struct json_object* versions;
json_object_object_get_ex(runner, "versions", &versions);
- int choice = atoi(argv[3]);
+ int choice = atoi(argv[1]);
if (choice > json_object_array_length(versions) - 1 || choice < 0)
{
- fprintf(stderr, "`%i' is not a valid ID\n\nrun `polecat wine list' to get a valid ID\n", choice);
+ printf("`%i' is not a valid ID\n\nrun `polecat wine list' to get a valid ID\n", choice);
}
else
{
@@ -72,11 +72,11 @@ int wine_download(int argc, char** argv)
strcat(downloadpath, "/");
strcat(downloadpath, name);
- fprintf(stderr, "Downloading %s\n", name);
+ printf("Downloading %s\n", name);
downloadFile(json_object_get_string(url), downloadpath);
- fprintf(stderr, "Extracting %s\n", name);
+ printf("Extracting %s\n", name);
extract(downloadpath, datadir);
- fprintf(stderr, "Done\n");
+ printf("Done\n");
}
json_object_put(runner);
@@ -115,17 +115,17 @@ int wine_list(int argc, char** argv)
int wine_run(int argc, char** argv)
{
- if (argc > 3)
+ if (argc > 1)
{
char winepath[PATH_MAX];
getDataDir(winepath);
- char* winever = argv[3];
+ char* winever = argv[1];
strcat(winepath, "/");
strcat(winepath, winever);
strcat(winepath, "/bin/wine");
- for (int i = 4; i < argc; ++i)
+ for (int i = 2; i < argc; ++i)
{
strcat(winepath, " ");
strcat(winepath, argv[i]);
@@ -134,7 +134,7 @@ int wine_run(int argc, char** argv)
return system(winepath);
}
- fprintf(stderr, "Specify a what wine version to run.\nUse `" NAME " wine list-installed' to list available versions\n");
+ printf("Specify a what wine version to run.\nUse `" NAME " wine list-installed' to list available versions\n");
return 0;
}
@@ -147,7 +147,7 @@ int wine_installed(int argc, char** argv)
DIR *dir;
struct dirent *ent;
- fprintf(stderr, "Installed wine versions:\n");
+ printf("Installed wine versions:\n");
if ((dir = opendir(datadir)) != NULL)
{
while ((ent = readdir (dir)) != NULL)
@@ -158,7 +158,7 @@ int wine_installed(int argc, char** argv)
*/
if (ent->d_name[0] != '.' && ent->d_type == DT_DIR)
{
- fprintf(stderr, " - %s\n", ent->d_name);
+ printf(" - %s\n", ent->d_name);
}
}
closedir (dir);