2022-03-07 16:12:40 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2022-03-14 14:31:03 -06:00
|
|
|
#include <stb/stb_image.h>
|
2022-03-07 16:12:40 -07:00
|
|
|
|
|
|
|
const char *VERSION = "0.1.0";
|
|
|
|
|
|
|
|
int handleArg(arg) char *arg; {
|
2022-03-07 18:34:17 -07:00
|
|
|
int value, size;
|
2022-03-07 16:12:40 -07:00
|
|
|
char flag, *longFlag, first, firstTwo[3];
|
2022-03-14 14:31:03 -06:00
|
|
|
const char *help;
|
2022-03-07 16:12:40 -07:00
|
|
|
|
2022-03-07 18:34:17 -07:00
|
|
|
help = "usage: uirc [-hl] [-r] IMAGE1 [IMAGE2] [...]\n\n"
|
2022-03-07 16:25:52 -07:00
|
|
|
|
|
|
|
"options:\n"
|
|
|
|
"\t-h\t> Display this message\n"
|
|
|
|
"\t-l\t> Display the license disclaimer for uirc (BSD 2-Clause)\n\n"
|
|
|
|
|
|
|
|
"\t-r\t> Display the resolution of the image (in addition to the ratio)\n\n"
|
|
|
|
|
|
|
|
"help:\n"
|
|
|
|
"If you get stuck using uirc, you can read the manpage for uirc:\n\n"
|
|
|
|
|
|
|
|
"\t'man uirc'\n\n";
|
2022-03-07 16:12:40 -07:00
|
|
|
|
|
|
|
flag = '-';
|
|
|
|
longFlag = "--";
|
|
|
|
first = arg[0];
|
|
|
|
|
|
|
|
firstTwo[0] = arg[0];
|
|
|
|
firstTwo[1] = arg[1];
|
|
|
|
firstTwo[2] = '\0';
|
2022-03-07 18:34:17 -07:00
|
|
|
size = sizeof arg;
|
2022-03-07 16:12:40 -07:00
|
|
|
|
|
|
|
//if (strcmp(longFlag, firstTwo) == 0) {
|
|
|
|
//printf("it has two dashes\n");
|
|
|
|
// switch (arg) {
|
|
|
|
// case "--okay":
|
|
|
|
// printf("success");
|
|
|
|
// break;
|
|
|
|
// default:
|
|
|
|
// printf("failure");
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// return 0;
|
|
|
|
//} else if (flag == first) {
|
|
|
|
// printf("it has a dash\n");
|
|
|
|
// return 0;
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (flag == first) {
|
2022-03-07 18:34:17 -07:00
|
|
|
for (int i = 1; i < size; i++) {
|
|
|
|
switch (arg[i]) {
|
|
|
|
case 'h':
|
|
|
|
printf("an unneccessary image ratio calculator (uirc) v%s\n\n", VERSION);
|
|
|
|
printf("Copyright 2022 Bryson Steck\nLicensed under the BSD 2-Clause. You can read the license by running 'uirc -l'\n\n");
|
|
|
|
printf("%s\n", help);
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
printf("%s\n", license);
|
|
|
|
break;
|
|
|
|
case '\0':
|
|
|
|
break;
|
|
|
|
//default:
|
|
|
|
// printf("uirc: invalid argument \"%s\"\n", arg);
|
|
|
|
// return 1;
|
|
|
|
}
|
2022-03-07 16:12:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int readFile() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(argc, argv) int argc; char *argv[]; {
|
|
|
|
//int i;
|
|
|
|
char *i;
|
|
|
|
|
|
|
|
if (argc <= 1) {
|
|
|
|
printf("uirc: at least one argument is required\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *a = argv[1];
|
|
|
|
return handleArg(a);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|