#include <stdio.h>
#include <stdbool.h>
#include <getopt.h>

#include "blockdev.h"
#include "vfs.h"

struct program_options {
	char *devname;
};

static int get_options(int argc, char* argv[], struct program_options* opt);


int main(int argc, char* argv[])
{
	struct program_options opt;

	if (get_options(argc, argv, &opt)) {
		return -1;
	}


	if (devopen(opt.devname, NULL) != 1) {
		return -1;
	}

	// TODO

	devclose();
	return 0;
}



static void fprint_help(FILE* to, char * pname)
{
	fprintf(to, "Usage: %s\n"
		"  -d | --dev <path> \t File to use as block device\n"
		, pname);
}

static int get_options(int argc, char* argv[], struct program_options *opt){
	const struct option long_options[] = {
		{"dev", required_argument, NULL, 'd'},
		{NULL, 0, NULL, 0},
	};

	int c, option_index = 0;
	while ((c = getopt_long(argc, argv, "d:", long_options, &option_index)) != -1) {
		switch (c) {
		case 'd':
			opt->devname = optarg;
			break;
		default:
			fprint_help(stderr, argv[0]);
			return -1;
		}
	}

	if (argc == 1) {
		fprintf(stderr, "%s needs arguments.\n", argv[0]);
		fprint_help(stderr, argv[0]);
		return -1;
	}

	if (opt->devname == NULL) {
		fprintf(stderr, "Argument \"--dev/-d\" missing.\n");
		return -1;
	}
	return 0;
}
