2016-04-18 12:00:57 -04:00
|
|
|
#include <stdio.h>
|
2016-04-18 18:39:56 -04:00
|
|
|
#include <stdlib.h>
|
2016-05-01 17:09:38 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <ctype.h>
|
2016-04-18 12:00:57 -04:00
|
|
|
#include "nms.h"
|
|
|
|
|
2016-05-01 17:19:27 -04:00
|
|
|
#define VERSION "0.1.0"
|
|
|
|
|
2016-05-01 17:09:38 -04:00
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
int c, o, inSize = 0;
|
2016-04-27 11:01:41 -04:00
|
|
|
char *input = NULL;
|
2016-04-20 17:24:11 -04:00
|
|
|
NmsArgs args = INIT_NMSARGS;
|
2016-04-18 18:39:56 -04:00
|
|
|
|
2016-05-01 17:09:38 -04:00
|
|
|
// Processing command arguments
|
2016-05-01 17:19:27 -04:00
|
|
|
while ((o = getopt(argc, argv, "av")) != -1) {
|
2016-05-01 17:09:38 -04:00
|
|
|
switch (o) {
|
|
|
|
case 'a':
|
|
|
|
args.auto_decrypt = true;
|
|
|
|
break;
|
2016-05-01 17:19:27 -04:00
|
|
|
case 'v':
|
|
|
|
printf("nms version " VERSION "\n");
|
|
|
|
return 0;
|
2016-05-01 17:09:38 -04:00
|
|
|
case '?':
|
|
|
|
if (isprint(optopt))
|
|
|
|
fprintf (stderr, "Unknown option '-%c'.\n", optopt);
|
|
|
|
else
|
|
|
|
fprintf (stderr, "Unknown option character '\\x%x'.\n", optopt);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-18 12:00:57 -04:00
|
|
|
// Geting input
|
|
|
|
while ((c = getchar()) != EOF) {
|
2016-04-18 18:39:56 -04:00
|
|
|
++inSize;
|
|
|
|
input = realloc(input, inSize + 1);
|
|
|
|
input[inSize - 1] = c;
|
|
|
|
input[inSize] = '\0';
|
2016-04-18 12:00:57 -04:00
|
|
|
}
|
2016-04-18 18:39:56 -04:00
|
|
|
|
2016-04-20 17:08:35 -04:00
|
|
|
// Set needed args
|
|
|
|
args.src = input;
|
2016-04-20 18:16:19 -04:00
|
|
|
args.show_cursor = true;
|
2016-04-20 17:08:35 -04:00
|
|
|
|
2016-04-18 18:39:56 -04:00
|
|
|
// Display characters
|
2016-04-20 17:55:07 -04:00
|
|
|
nms_exec(&args);
|
2016-04-18 18:39:56 -04:00
|
|
|
|
|
|
|
// Don't forget to free the allocated memory!
|
|
|
|
free(input);
|
2016-04-18 12:00:57 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|