diff options
Diffstat (limited to '')
| -rw-r--r-- | config.h | 10 | ||||
| -rw-r--r-- | passgen.c | 28 | 
2 files changed, 18 insertions, 20 deletions
| diff --git a/config.h b/config.h new file mode 100644 index 0000000..1160580 --- /dev/null +++ b/config.h @@ -0,0 +1,10 @@ +#define DEFAULT_GRAMMAR "Cvccvc!##"
 +
 +// For vowels:
 +//   i, o excluded due to potentially confusing 1/l/i + 0/o
 +//   y included as a vowel because it kinda is one
 +#define CLASSES \
 +  CLASS('v', "aeuy") \
 +  CLASS('c', "bcdfghkmnprstvwxz") \
 +  CLASS('#', "1234567890") \
 +  CLASS('!', "@#$%^&*_-+=()[]{}")
 @@ -1,3 +1,5 @@ +#include "config.h"
 +
  #include <stdio.h>
  #include <stdlib.h>
  #include <stdbool.h>
 @@ -5,14 +7,12 @@  #include <unistd.h>
  #include <string.h>
 -#define DEFAULT_GRAMMAR "Cvccvc!##"
 +#define CLASS(c, chars) \
 +  case c: \
 +    class = chars; \
 +    class_size = sizeof(chars)-1; \
 +    break;
 -// i, o excluded due to potentially confusing 1/l/i + 0/o
 -// y included as a vowel because it kinda is one
 -#define VOWELS "aeuy"
 -#define CONSONANTS "bcdfghkmnprstvwxz"
 -#define NUMBERS "1234567890"
 -#define SYMBOLS "@#$%^&*_-+=()[]{}"
  int main(int argc, char *argv[])
  {
 @@ -64,20 +64,8 @@ int main(int argc, char *argv[])      char *class;
      int class_size = 0;
 -#define setClass(cl) \
 -    class = cl; \
 -    class_size = sizeof(cl)-1; \
 -    break;
 -
      switch (c) {
 -    case 'c':
 -      setClass(CONSONANTS);
 -    case 'v':
 -      setClass(VOWELS);
 -    case '!':
 -      setClass(SYMBOLS);
 -    case '#':
 -      setClass(NUMBERS);
 +    CLASSES
      default:
        printf("ERROR: Invalid grammar character '%c'.\n", c);
        if (grammar != (char*)DEFAULT_GRAMMAR)
 | 
