aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--VERSION2
-rw-r--r--crypt.c40
-rw-r--r--crypt.h2
4 files changed, 26 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index e263d11..b5ddaf2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,8 @@
.POSIX:
.PHONY: all clean distclean install
PREFIX = /usr/local
-#CFLAGS = -Werror -Wstrict -pedantic # Recommended for GCC
+#CC = gcc
+#CFLAGS = -Wall -Werror -Wextra -ansi -pedantic
LDFLAGS = -lcrypt
ALL = crypt
all: $(ALL)
diff --git a/VERSION b/VERSION
index 9084fa2..26aaba0 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.1.0
+1.2.0
diff --git a/crypt.c b/crypt.c
index 5e13fbd..7ba42ef 100644
--- a/crypt.c
+++ b/crypt.c
@@ -7,14 +7,14 @@ int main (int argc, char **argv)
while ((opt = getopt(argc, argv, "h")) != -1) {
switch (opt) {
- case 'h': /* Help */
- usage(stdout, EXIT_SUCCESS);
- break;
- case '?': /* Unknown option */
- usage(stderr, EXIT_FAILURE);
- break;
- default: /* Shouldn't happen */
- abort();
+ case 'h': /* Help */
+ usage(stdout, EXIT_SUCCESS);
+ break;
+ case '?': /* Unknown option */
+ usage(stderr, EXIT_FAILURE);
+ break;
+ default: /* Shouldn't happen */
+ abort();
}
}
@@ -22,8 +22,9 @@ int main (int argc, char **argv)
* If we don't have three arguments left after processing the options,
* exit with usage information and error status
*/
- if (argc != 3)
+ if (argc != 3) {
usage(stderr, EXIT_FAILURE);
+ }
key = argv[1];
salt = argv[2];
@@ -32,25 +33,28 @@ int main (int argc, char **argv)
* Create the hash, but exit immediately with the system error string
* if it returns a null pointer (error condition)
*/
- if (!(hash = crypt(key, salt)))
+ if (!(hash = crypt(key, salt))) {
error(strerror(errno));
+ }
puts(hash);
exit(EXIT_SUCCESS);
}
/*
- * Show usage to given stream, and exit with given code
+ * Exit with error error message
*/
-void usage(FILE *stream, int status) {
- fputs("USAGE: crypt [-h | KEY SALT]\n", stream);
- exit(status);
+void error(char *message)
+{
+ fprintf(stderr, "%s\n", message);
+ exit(EXIT_FAILURE);
}
/*
- * Exit with error error message
+ * Show usage to given stream, and exit with given code
*/
-void error(char *message) {
- fprintf(stderr, "%s\n", message);
- exit(EXIT_FAILURE);
+void usage(FILE *stream, int status)
+{
+ fputs("USAGE: crypt [-h | KEY SALT]\n", stream);
+ exit(status);
}
diff --git a/crypt.h b/crypt.h
index 6612e01..0a25c0d 100644
--- a/crypt.h
+++ b/crypt.h
@@ -5,5 +5,5 @@
#include <string.h> /* strerror(3) */
#include <unistd.h> /* crypt(3) */
-void usage(FILE *, int);
void error(char *);
+void usage(FILE *, int);