From: 諏訪子 Date: Tue, 21 May 2024 18:48:04 +0000 (+0900) Subject: Merge branch 'master' of gitler.moe:suwako/sp into chkpass X-Git-Url: http://10.11.0.4:5575/?a=commitdiff_plain;h=c5f42cc9523d13737abf135019751aaa09fdbe5a;p=sp.git Merge branch 'master' of gitler.moe:suwako/sp into chkpass --- c5f42cc9523d13737abf135019751aaa09fdbe5a diff --cc main.c index ed13347,23485f4..82bf732 --- a/main.c +++ b/main.c @@@ -148,12 -54,24 +55,27 @@@ char *getfullpath(char *arg) return fullPath; } - int main(int argc, char* argv[]) { - char *lang = getenv("SP_LANG"); - + int main(int argc, char *argv[]) { if (argc < 2) { - if (lang != NULL && strncmp(lang, "en", 2) == 0) helpme_en(); - else helpme(); + usage(); + return 0; + } + + if (strcmp(argv[1], "-g") == 0) { + if (argc != 3 && argc != 4) { + usage(); + return 1; + } ++ else if (strcmp(argv[1], "-o") == 0) { ++ char* fullPath = getfullpath(argv[2]); ++ if (fullPath == NULL) return -1; + + if (argc == 3) genpass(atoi(argv[2]), true); + else if (argc == 4 && strcmp(argv[3], "risk") == 0) + genpass(atoi(argv[2]), false); + else if (argc == 4 && strcmp(argv[3], "secure") == 0) + genpass(atoi(argv[2]), true); + return 0; } @@@ -167,10 -85,9 +89,9 @@@ delpass(argv[2], 1); addpass(argv[2]); } -- else if (strcmp(argv[1], "-o") == 0) { - char* fullPath = getfullpath(argv[2]); ++ } else if (strcmp(argv[1], "-o") == 0) { + char *fullPath = getfullpath(argv[2]); if (fullPath == NULL) return -1; - otppass(fullPath); free(fullPath); } else { @@@ -183,11 -99,9 +103,10 @@@ if (basePath == NULL) return -1; if (strcmp(argv[1], "-l") == 0) listpass(basePath, 0); + else if (strcmp(argv[1], "-c") == 0) chkpass(basePath); else if (strcmp(argv[1], "-v") == 0) printf("%s-%s\n", sofname, version); else { - if (lang != NULL && strncmp(lang, "en", 2) == 0) helpme_en(); - else helpme(); + usage(); free(basePath); return 1; }