blob: 54b90ceaf5a4554332fa1c4bdb09267f1284bb9b (
plain) (
tree)
|
|
#include "crypt.h"
/*
* Main function
*/
int main (int argc, char **argv)
{
/* The hash we will produce, hopefully */
char *hash = NULL;
/* Assume user doesn't want help */
int help = 0;
/* Iterate through any options */
int o;
while ((o = getopt(argc, argv, OPTSTRING)) != -1) {
switch (o) {
case 'h':
help = 1;
break;
case '?':
fprintf(stderr, "Unknown option\n");
break;
default:
abort();
}
}
/* If help was asked, give it */
if (help) {
fprintf(stdout, "%s\n", USAGE);
exit(EXIT_SUCCESS);
}
/* If we don't have three arguments, bail */
if (argc != 3) {
fprintf(stderr, "%s\n", USAGE);
exit(EXIT_FAILURE);
}
/* All seems well, build the hash and print it */
hash = crypt(argv[1], argv[2]);
fprintf(stdout, "%s\n", hash);
exit(EXIT_SUCCESS);
}
|