shokara's own minecraft launcher
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 

70 lines
1.5 KiB

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "versions.h"
#include "somc.h"
char somc_data_dir[256];
static void usage(char *name);
static void usage(char *name)
{
printf("Usage: %s list-versions\n"
" %s instance-create name version-id\n",
name, name);
}
int main(int argc, char **argv)
{
char *home_dir;
if (argc == 1) {
usage(argv[0]);
return EXIT_FAILURE;
}
if ((home_dir = getenv("HOME")) == NULL) {
fprintf(stderr, "$HOME is not set? Defaulting to current directory.\n");
home_dir = ".";
}
strncpy(somc_data_dir, home_dir, sizeof(somc_data_dir));
strncat(somc_data_dir, "/.somc",
sizeof(somc_data_dir) - strlen(somc_data_dir) - 1);
somc_data_dir[sizeof(somc_data_dir) - 1] = '\0';
mkdir(somc_data_dir, 0755);
chdir(somc_data_dir);
if (strncmp(argv[1], "list-versions", 13) == 0) {
if (argc != 2) {
usage(argv[0]);
return EXIT_FAILURE;
}
if (list_versions() < 0) {
fprintf(stderr, "versions failed to list "
"(%s/versions_manifest.json possibly "
"corrupt)\n", somc_data_dir);
return EXIT_FAILURE;
}
} else if (strncmp(argv[1], "instance-create", 15) == 0) {
if (argc != 4) {
usage(argv[0]);
return EXIT_FAILURE;
}
if (instance_create(argv[2], argv[3]) < 0) {
fprintf(stderr, "instance %s with version %s failed to create\n",
argv[2], argv[3]);
}
} else {
usage(argv[0]);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}