-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac2fd35
commit f423875
Showing
4 changed files
with
7 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
|
||
/* code original by Jan Dlabal <[email protected]>, partially rewritten by vh, | ||
rainy tweaks by owein <[email protected]>*/ | ||
/* code original by Jan Dlabal <[email protected]>, partially rewritten by vh. */ | ||
|
||
#include <ctype.h> | ||
#include <math.h> | ||
|
@@ -174,8 +173,6 @@ int32_t bf_init(char *arg) { | |
|
||
bf_options.crs_len = crs_len; | ||
bf_options.current = bf_options.from; | ||
bf_options.rain = 0; | ||
bf_options.gcounter = 0; | ||
|
||
memset((char *) bf_options.state, 0, sizeof(bf_options.state)); | ||
|
||
|
@@ -202,7 +199,7 @@ uint64_t bf_get_pcount() { | |
return foo; | ||
} | ||
|
||
char *bf_next(_Bool rainy) { | ||
char *bf_next() { | ||
int32_t i, pos = bf_options.current - 1; | ||
|
||
if (bf_options.current > bf_options.to) | ||
|
@@ -213,18 +210,7 @@ char *bf_next(_Bool rainy) { | |
return NULL; | ||
} | ||
|
||
if(rainy) | ||
{ | ||
bf_options.rain = bf_options.gcounter; | ||
bf_options.ptr[0] = bf_options.crs[bf_options.state[0]]; | ||
for(i=1; i<bf_options.current; ++i) { | ||
bf_options.ptr[i] = bf_options.crs[(bf_options.state[i] + bf_options.rain) % bf_options.crs_len]; | ||
bf_options.rain -= bf_options.rain / bf_options.crs_len; | ||
} | ||
bf_options.gcounter++; | ||
} | ||
else | ||
for(i=0; i<bf_options.current; ++i) | ||
for(i=0; i<bf_options.current; ++i) | ||
bf_options.ptr[i] = bf_options.crs[bf_options.state[i]]; | ||
//we don't subtract the same depending on wether the length is odd or even | ||
bf_options.ptr[bf_options.current] = 0; | ||
|
@@ -237,22 +223,13 @@ char *bf_next(_Bool rainy) { | |
} | ||
|
||
//we revert the ordering of the bruteforce to fix the first static character | ||
if(rainy) { | ||
pos = 0; | ||
while (pos < bf_options.current && (++bf_options.state[pos]) >= bf_options.crs_len) { | ||
bf_options.state[pos] = 0; | ||
pos++; | ||
} | ||
} | ||
else | ||
while (pos >= 0 && (++bf_options.state[pos]) >= bf_options.crs_len) { | ||
bf_options.state[pos] = 0; | ||
pos--; | ||
} | ||
|
||
if (pos < 0 || pos >= bf_options.current) { | ||
bf_options.current++; | ||
bf_options.rain = 0; | ||
memset((char *)bf_options.state, 0, sizeof(bf_options.state)); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters