Browse Source

Support multiple pattern input files, with different case-sensitivity

settings.
master
samr7 12 years ago
parent
commit
74e9eaaa6e
  1. 71
      oclvanitygen.c
  2. 6
      pattern.c
  3. 2
      pattern.h
  4. 71
      vanitygen.c

71
oclvanitygen.c

@ -80,6 +80,7 @@ version, name); @@ -80,6 +80,7 @@ version, name);
}
#define MAX_DEVS 32
#define MAX_FILE 4
int
main(int argc, char **argv)
@ -93,7 +94,6 @@ main(int argc, char **argv) @@ -93,7 +94,6 @@ main(int argc, char **argv)
int platformidx = -1, deviceidx = -1;
int prompt_password = 0;
char *seedfile = NULL;
FILE *fp = NULL;
char **patterns, *pend;
int verbose = 1;
int npatterns = 0;
@ -113,6 +113,13 @@ main(int argc, char **argv) @@ -113,6 +113,13 @@ main(int argc, char **argv)
int ndevstrs = 0;
int opened = 0;
FILE *pattfp[MAX_FILE], *fp;
int pattfpi[MAX_FILE];
int npattfp = 0;
int pattstdin = 0;
int i;
while ((opt = getopt(argc, argv,
"vqikNTX:eE:p:P:d:w:t:g:b:VSh?f:o:s:D:")) != -1) {
switch (opt) {
@ -229,11 +236,17 @@ main(int argc, char **argv) @@ -229,11 +236,17 @@ main(int argc, char **argv)
break;
}
case 'f':
if (fp) {
fprintf(stderr, "Multiple files specified\n");
if (npattfp >= MAX_FILE) {
fprintf(stderr,
"Too many input files specified\n");
return 1;
}
if (!strcmp(optarg, "-")) {
if (pattstdin) {
fprintf(stderr, "ERROR: stdin "
"specified multiple times\n");
return 1;
}
fp = stdin;
} else {
fp = fopen(optarg, "r");
@ -244,6 +257,9 @@ main(int argc, char **argv) @@ -244,6 +257,9 @@ main(int argc, char **argv)
return 1;
}
}
pattfp[npattfp] = fp;
pattfpi[npattfp] = caseinsensitive;
npattfp++;
break;
case 'o':
if (result_file) {
@ -301,23 +317,6 @@ main(int argc, char **argv) @@ -301,23 +317,6 @@ main(int argc, char **argv)
}
}
if (fp) {
if (!vg_read_file(fp, &patterns, &npatterns)) {
fprintf(stderr, "Failed to load pattern file\n");
return 1;
}
if (fp != stdin)
fclose(fp);
} else {
if (optind >= argc) {
usage(argv[0]);
return 1;
}
patterns = &argv[optind];
npatterns = argc - optind;
}
if (regex) {
vcp = vg_regex_context_new(addrtype, privtype);
@ -335,9 +334,37 @@ main(int argc, char **argv) @@ -335,9 +334,37 @@ main(int argc, char **argv)
vcp->vc_output_match = vg_output_match_console;
vcp->vc_output_timing = vg_output_timing_console;
if (!vg_context_add_patterns(vcp, (const char ** const)patterns,
npatterns))
if (!npattfp) {
if (optind >= argc) {
usage(argv[0]);
return 1;
}
patterns = &argv[optind];
npatterns = argc - optind;
if (!vg_context_add_patterns(vcp,
(const char ** const) patterns,
npatterns))
return 1;
}
for (i = 0; i < npattfp; i++) {
fp = pattfp[i];
if (!vg_read_file(fp, &patterns, &npatterns)) {
fprintf(stderr, "Failed to load pattern file\n");
return 1;
}
if (fp != stdin)
fclose(fp);
if (!regex)
vg_prefix_context_set_case_insensitive(vcp, pattfpi[i]);
if (!vg_context_add_patterns(vcp,
(const char ** const) patterns,
npatterns))
return 1;
}
if (!vcp->vc_npatterns) {
fprintf(stderr, "No patterns to search\n");

6
pattern.c

@ -1210,6 +1210,12 @@ typedef struct _vg_prefix_context_s { @@ -1210,6 +1210,12 @@ typedef struct _vg_prefix_context_s {
int vcp_caseinsensitive;
} vg_prefix_context_t;
void
vg_prefix_context_set_case_insensitive(vg_context_t *vcp, int caseinsensitive)
{
((vg_prefix_context_t *) vcp)->vcp_caseinsensitive = caseinsensitive;
}
static void
vg_prefix_context_clear_all_patterns(vg_context_t *vcp)
{

2
pattern.h

@ -139,6 +139,8 @@ extern void vg_context_wait_for_completion(vg_context_t *vcp); @@ -139,6 +139,8 @@ extern void vg_context_wait_for_completion(vg_context_t *vcp);
/* Prefix context methods */
extern vg_context_t *vg_prefix_context_new(int addrtype, int privtype,
int caseinsensitive);
extern void vg_prefix_context_set_case_insensitive(vg_context_t *vcp,
int caseinsensitive);
extern double vg_prefix_get_difficulty(int addrtype, const char *pattern);
/* Regex context methods */

71
vanitygen.c

@ -324,6 +324,8 @@ usage(const char *name) @@ -324,6 +324,8 @@ usage(const char *name)
version, name);
}
#define MAX_FILE 4
int
main(int argc, char **argv)
{
@ -339,7 +341,6 @@ main(int argc, char **argv) @@ -339,7 +341,6 @@ main(int argc, char **argv)
int prompt_password = 0;
int opt;
char *seedfile = NULL;
FILE *fp = NULL;
char pwbuf[128];
const char *result_file = NULL;
const char *key_password = NULL;
@ -349,6 +350,13 @@ main(int argc, char **argv) @@ -349,6 +350,13 @@ main(int argc, char **argv)
vg_context_t *vcp = NULL;
EC_POINT *pubkey_base = NULL;
FILE *pattfp[MAX_FILE], *fp;
int pattfpi[MAX_FILE];
int npattfp = 0;
int pattstdin = 0;
int i;
while ((opt = getopt(argc, argv, "vqrikeE:P:NTX:F:t:h?f:o:s:")) != -1) {
switch (opt) {
case 'v':
@ -425,12 +433,17 @@ main(int argc, char **argv) @@ -425,12 +433,17 @@ main(int argc, char **argv)
}
break;
case 'f':
if (fp) {
if (npattfp >= MAX_FILE) {
fprintf(stderr,
"Multiple files specified\n");
"Too many input files specified\n");
return 1;
}
if (!strcmp(optarg, "-")) {
if (pattstdin) {
fprintf(stderr, "ERROR: stdin "
"specified multiple times\n");
return 1;
}
fp = stdin;
} else {
fp = fopen(optarg, "r");
@ -441,6 +454,9 @@ main(int argc, char **argv) @@ -441,6 +454,9 @@ main(int argc, char **argv)
return 1;
}
}
pattfp[npattfp] = fp;
pattfpi[npattfp] = caseinsensitive;
npattfp++;
break;
case 'o':
if (result_file) {
@ -510,23 +526,6 @@ main(int argc, char **argv) @@ -510,23 +526,6 @@ main(int argc, char **argv)
}
}
if (fp) {
if (!vg_read_file(fp, &patterns, &npatterns)) {
fprintf(stderr, "Failed to load pattern file\n");
return 1;
}
if (fp != stdin)
fclose(fp);
} else {
if (optind >= argc) {
usage(argv[0]);
return 1;
}
patterns = &argv[optind];
npatterns = argc - optind;
}
if (regex) {
vcp = vg_regex_context_new(addrtype, privtype);
@ -545,9 +544,37 @@ main(int argc, char **argv) @@ -545,9 +544,37 @@ main(int argc, char **argv)
vcp->vc_output_match = vg_output_match_console;
vcp->vc_output_timing = vg_output_timing_console;
if (!vg_context_add_patterns(vcp, (const char ** const) patterns,
npatterns))
if (!npattfp) {
if (optind >= argc) {
usage(argv[0]);
return 1;
}
patterns = &argv[optind];
npatterns = argc - optind;
if (!vg_context_add_patterns(vcp,
(const char ** const) patterns,
npatterns))
return 1;
}
for (i = 0; i < npattfp; i++) {
fp = pattfp[i];
if (!vg_read_file(fp, &patterns, &npatterns)) {
fprintf(stderr, "Failed to load pattern file\n");
return 1;
}
if (fp != stdin)
fclose(fp);
if (!regex)
vg_prefix_context_set_case_insensitive(vcp, pattfpi[i]);
if (!vg_context_add_patterns(vcp,
(const char ** const) patterns,
npatterns))
return 1;
}
if (!vcp->vc_npatterns) {
fprintf(stderr, "No patterns to search\n");

Loading…
Cancel
Save