init
This commit is contained in:
11
src/config.h
Normal file
11
src/config.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* config.h - define configuration values */
|
||||
|
||||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
/* Length of string to be outputted */
|
||||
#define ECRYPT_STR_LEN 30
|
||||
|
||||
#define ECRYPT_VERSION "3.0.0"
|
||||
|
||||
#endif
|
||||
110
src/ecrypt.c
Normal file
110
src/ecrypt.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
ecrypt.c - string generation and comparison tool
|
||||
|
||||
This file is part of ecrypt.
|
||||
|
||||
ecrypt is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
ecrypt is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with ecrypt. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <color.h>
|
||||
#include <ecrypt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
static void
|
||||
usage(char *argv[])
|
||||
{
|
||||
printf("%s - string generator and checker\n", argv[0]);
|
||||
printf("usage: %s [-h] [-v] [-s] [-g] [-c]\n", argv[0]);
|
||||
printf("\n");
|
||||
printf("%s {-h} Show this message\n", argv[0]);
|
||||
printf("%s {-v} Show the current version\n", argv[0]);
|
||||
printf("%s {-s} View compile-time settings\n", argv[0]);
|
||||
printf("%s {-g} Generate a string\n", argv[0]);
|
||||
printf("%s {-c} Compare 2 files\n", argv[0]);
|
||||
printf("\n");
|
||||
printf("Ecrypt is free software.\n");
|
||||
printf("See the GNU GPL version 3 for details.\n");
|
||||
}
|
||||
|
||||
static void
|
||||
usage_small(char *argv[])
|
||||
{
|
||||
printf("usage: %s [-h] [-v] [-s] [-g] [-c]\n", argv[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
view_compile_time_settings(char *argv[])
|
||||
{
|
||||
printf("Compile-time settings for %s\n", argv[0]);
|
||||
printf("String length: %i\n", ECRYPT_STR_LEN);
|
||||
}
|
||||
|
||||
static void
|
||||
view_version(char *argv[])
|
||||
{
|
||||
printf("%s\n", argv[0]);
|
||||
printf(ECRYPT_VERSION);
|
||||
printf("\n");
|
||||
printf("Compiled against libecrypt\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
usage_small(argv);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, ":if:hvsgc")) != -1) {
|
||||
switch(opt) {
|
||||
case 'h':
|
||||
usage(argv);
|
||||
exit(0);
|
||||
break;
|
||||
case 'v':
|
||||
view_version(argv);
|
||||
exit(0);
|
||||
break;
|
||||
case 's':
|
||||
view_compile_time_settings(argv);
|
||||
exit(0);
|
||||
break;
|
||||
case 'g':
|
||||
ecrypt_gen(ECRYPT_STR_LEN);
|
||||
printf("\n");
|
||||
exit(0);
|
||||
break;
|
||||
case 'c':
|
||||
if (argc < 4) {
|
||||
printf("not enough arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
ecrypt_check(argv[2], argv[3]);
|
||||
break;
|
||||
case '?':
|
||||
usage_small(argv);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user