summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2019-08-26 10:49:15 -0600
committerAaron Ball <nullspoon@oper.io>2019-08-26 10:49:15 -0600
commitfb359e3130fefdb987f2c204eb28c873f09cc354 (patch)
tree63899c523a198a43a84d6005124dbfbb778714f6 /src
parent230c9f2ee14f3ce89ecaefc6d2dc7f4a18b0d5dc (diff)
downloadupwgen-fb359e3130fefdb987f2c204eb28c873f09cc354.tar.gz
upwgen-fb359e3130fefdb987f2c204eb28c873f09cc354.tar.xz
Implement -0 and -A switches
These add upstream functionality to prevent usage of numerals and capitals in the output password. Also this fixes an issue with the character selection loop.
Diffstat (limited to 'src')
-rw-r--r--src/main.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c
index a266396..f31f47a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,15 +35,17 @@ void usage() {
"and symbols).\n\n"
"Usage:\n upwgen [options] [length]\n\n"
"Options:\n"
- " -c,--capitalize Include at least one capital letter in output\n"
- " -l,--lower Include at least one lower case letter in output\n"
- " -n,--numerals Include at least one numeral in output\n"
- " -y,--symbols Include at least one symbol in output\n"
- " -i,--i18n Include at least one international letter in output\n"
- " -1 Include chars from the most used scripts in the world\n"
- " -2 Include chars from the second most used scripts in the world\n"
- " -3 Include chars from the third most used scripts in the world\n"
- " -4 Include chars from the forth most used scripts in the world\n"
+ " -0,--no-numerals Include at least one numeral in output\n"
+ " -A,--no-capitalize Include at least one numeral in output\n"
+ " -c,--capitalize Include at least one capital letter in output\n"
+ " -l,--lower Include at least one lower case letter in output\n"
+ " -n,--numerals Include at least one numeral in output\n"
+ " -y,--symbols Include at least one symbol in output\n"
+ " -i,--i18n Include at least one international letter in output\n"
+ " -1 Include chars from the most used scripts in the world\n"
+ " -2 Include chars from the second most used scripts in the world\n"
+ " -3 Include chars from the third most used scripts in the world\n"
+ " -4 Include chars from the forth most used scripts in the world\n"
"\n"
" -h,--help Print this help text\n"
" -d,--debug Enable debug mode (prints entire character pool)\n"
@@ -73,11 +75,16 @@ int main(int argc, char* argv[]) {
set = i18n_set_new(I18N_TYPE_ASCII_UPPER);
i18n_set_add(set, I18N_TYPE_ASCII_LOWER);
i18n_set_add(set, I18N_TYPE_ASCII_NUMERALS);
- i18n_set_add(set, I18N_TYPE_ASCII_SYMBOLS);
while(i < argc) {
- if(strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--capitals") == 0) {
+ if(strcmp(argv[i], "-0") == 0 || strcmp(argv[i], "--no-numerals") == 0) {
+ set = i18n_set_rm_type(set, I18N_TYPE_ASCII_NUMERALS);
+
+ } else if(strcmp(argv[i], "-A") == 0 || strcmp(argv[i], "--no-capitalize") == 0) {
+ set = i18n_set_rm_type(set, I18N_TYPE_ASCII_UPPER);
+
+ } else if(strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--capitalize") == 0) {
i18n_set_add(set, I18N_TYPE_ASCII_UPPER);
} else if(strcmp(argv[i], "-l") == 0 || strcmp(argv[i], "--lower") == 0) {
@@ -147,9 +154,11 @@ int main(int argc, char* argv[]) {
int i = rand() % 10;
while(i > 0) {
// Loop
- if(cursor->next == NULL)
+ if(!cursor->next) {
cursor = set;
- cursor = cursor->next;
+ } else {
+ cursor = cursor->next;
+ }
i--;
}

Generated by cgit