2017-01-16 16:28:12 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Brian Barto
|
2020-06-20 18:41:48 -04:00
|
|
|
*
|
2017-01-16 16:28:12 -05:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
2017-02-17 13:24:11 -05:00
|
|
|
* under the terms of the GPL License. See LICENSE for more details.
|
2017-01-16 16:28:12 -05:00
|
|
|
*/
|
|
|
|
|
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>
|
2017-01-19 11:17:40 -05:00
|
|
|
#include "nmseffect.h"
|
2018-10-24 21:44:48 -04:00
|
|
|
#include "input.h"
|
|
|
|
#include "error.h"
|
2017-01-19 11:17:40 -05:00
|
|
|
|
2021-09-24 15:00:45 -04:00
|
|
|
#define VERSION "1.0.0"
|
2017-01-19 11:17:40 -05:00
|
|
|
|
2018-10-24 21:50:42 -04:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2018-10-24 21:44:48 -04:00
|
|
|
int r, o;
|
|
|
|
unsigned char *input;
|
|
|
|
|
|
|
|
input = NULL;
|
2017-01-19 11:17:40 -05:00
|
|
|
|
2018-10-24 21:50:42 -04:00
|
|
|
while ((o = getopt(argc, argv, "f:ascv")) != -1)
|
|
|
|
{
|
|
|
|
switch (o)
|
|
|
|
{
|
2017-01-19 11:17:40 -05:00
|
|
|
case 'f':
|
|
|
|
nmseffect_set_foregroundcolor(optarg);
|
|
|
|
break;
|
|
|
|
case 'a':
|
2017-01-19 11:20:53 -05:00
|
|
|
nmseffect_set_autodecrypt(1);
|
2017-01-19 11:17:40 -05:00
|
|
|
break;
|
2020-06-20 18:41:48 -04:00
|
|
|
case 's':
|
|
|
|
nmseffect_set_maskblank(1);
|
|
|
|
break;
|
2017-01-19 11:17:40 -05:00
|
|
|
case 'c':
|
|
|
|
nmseffect_set_clearscr(1);
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
printf("nms version " VERSION "\n");
|
2018-10-24 21:50:42 -04:00
|
|
|
return EXIT_SUCCESS;
|
2017-01-19 11:17:40 -05:00
|
|
|
case '?':
|
|
|
|
if (isprint(optopt))
|
2018-10-24 21:50:42 -04:00
|
|
|
{
|
|
|
|
error_log("Unknown option '-%c'.", optopt);
|
|
|
|
}
|
2017-01-19 11:17:40 -05:00
|
|
|
else
|
2018-10-24 21:50:42 -04:00
|
|
|
{
|
|
|
|
error_log("Unknown option character '\\x%x'.", optopt);
|
|
|
|
}
|
|
|
|
error_print();
|
|
|
|
return EXIT_FAILURE;
|
2017-01-16 16:28:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-24 21:44:48 -04:00
|
|
|
r = input_get(&input, "Enter input: ");
|
|
|
|
if (r < 0)
|
|
|
|
{
|
|
|
|
error_log("Could not get input.");
|
|
|
|
error_print();
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
else if (r == 0)
|
|
|
|
{
|
|
|
|
error_log("Input is empty.");
|
|
|
|
error_print();
|
|
|
|
return EXIT_FAILURE;
|
2017-01-16 16:28:12 -05:00
|
|
|
}
|
|
|
|
|
2018-10-24 21:44:48 -04:00
|
|
|
r = nmseffect_exec(input, r);
|
2017-01-16 16:28:12 -05:00
|
|
|
|
2017-01-19 11:17:40 -05:00
|
|
|
free(input);
|
2017-01-16 16:28:12 -05:00
|
|
|
|
2018-10-24 21:44:48 -04:00
|
|
|
return EXIT_SUCCESS;
|
2017-01-16 16:28:12 -05:00
|
|
|
}
|