[GH-ISSUE #2789] Source tree clean-up / reorganize #1791

Open
opened 2026-10-15 04:24:31 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @magnumripper on GitHub (Sep 26, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2789

It was brought up recently in a mail discussion that our source tree is "disorganized" with like "800 source files in a single directory". This is absolutely true. I'm so used to it I haven't cared much about it. Making it better should be pretty easy. Here are two easy steps for making it a little better:

  1. For a starter, we could move all plugins (and nothing else) to src/plugins. That will half the number of files directly under src...
  2. We have lots of pure OpenCL headers (for inclusion by kernels) directly under src, they should either go to src/opencl like the kernels - or perhaps src/opencl/include if we want to.

After that, it gets trickier to get lots of improvement with little work but we can probably find out a couple more things.

Originally created by @magnumripper on GitHub (Sep 26, 2017). Original GitHub issue: https://github.com/openwall/john/issues/2789 It was brought up recently in a mail discussion that our source tree is "disorganized" with like "800 source files in a single directory". This is absolutely true. I'm so used to it I haven't cared much about it. Making it better should be pretty easy. Here are two easy steps for making it a little better: 1. For a starter, we could move all plugins (and nothing else) to `src/plugins`. That will half the number of files directly under `src`... 2. We have lots of pure OpenCL headers (for inclusion by kernels) directly under `src`, they should either go to `src/opencl` like the kernels - or perhaps `src/opencl/include` if we want to. After that, it gets trickier to get lots of improvement with little work but we can probably find out a couple more things.
Author
Owner

@frank-dittrich commented on GitHub (Sep 26, 2017):

we could also move all non-plugin formats into a separate directory (formats?), and all source files which are not used to build john, but separate binaires, into another directory (tools?).

<!-- gh-comment-id:332339079 --> @frank-dittrich commented on GitHub (Sep 26, 2017): we could also move all non-plugin formats into a separate directory (formats?), and all source files which are not used to build john, but separate binaires, into another directory (tools?).
Author
Owner

@magnumripper commented on GitHub (Sep 26, 2017):

Agreed, except we can't move any core (a.k.a. "john proper") files unless that change comes from "upstream".

Theoretically we could have something like this tho'

src   (this would almost be as empty as in John Proper)
src/jumbo
src/jumbo/include
src/jumbo/plugins
src/jumbo/plugins/include (maybe overkill)
src/jumbo/tools
src/jumbo/tools/include  (probably overkill)
src/jumbo/aes(/...)
src/jumbo/opencl
src/jumbo/opencl/include
src/jumbo/ztex(/...)
src/jumbo/...
<!-- gh-comment-id:332350667 --> @magnumripper commented on GitHub (Sep 26, 2017): Agreed, except we can't move any core (a.k.a. "john proper") files unless that change comes from "upstream". Theoretically we could have something like this tho' ``` src (this would almost be as empty as in John Proper) src/jumbo src/jumbo/include src/jumbo/plugins src/jumbo/plugins/include (maybe overkill) src/jumbo/tools src/jumbo/tools/include (probably overkill) src/jumbo/aes(/...) src/jumbo/opencl src/jumbo/opencl/include src/jumbo/ztex(/...) src/jumbo/... ```
Author
Owner

@magnumripper commented on GitHub (Sep 26, 2017):

$ l *_plug.c | wc -l
     358
$ l opencl*_plug.c | wc -l
      79
$ bc <<< 358-79
279
$ l opencl_*h | wc -l
      45
$ l *_plug.h | wc -l
       2
$ l opencl*_plug.h | wc -l
       1

Most plugin headers aren't named plug (as they don't need to), eg. dmg_common_plug.c vs. dmg_common.h, so the header figures above are way low.

<!-- gh-comment-id:332352464 --> @magnumripper commented on GitHub (Sep 26, 2017): ``` $ l *_plug.c | wc -l 358 $ l opencl*_plug.c | wc -l 79 $ bc <<< 358-79 279 $ l opencl_*h | wc -l 45 $ l *_plug.h | wc -l 2 $ l opencl*_plug.h | wc -l 1 ``` Most plugin headers aren't named `plug` (as they don't need to), eg. `dmg_common_plug.c` vs. `dmg_common.h`, so the header figures above are way low.
Author
Owner

@ghost commented on GitHub (Nov 3, 2017):

Anyone with perl skills can change plugin_deps.pl? The -f $object at line 30 has to #include (at least):

src/jumbo/include              // general *.h
src/jumbo/opencl/include  // OpenCL *.h

I tried, but the result is ridiculous:

diff --git a/src/plugin_deps.pl b/src/plugin_deps.pl
index f98f486de..57d35729d 100755
--- a/src/plugin_deps.pl
+++ b/src/plugin_deps.pl
@@ -22,10 +22,37 @@ sub find_deps {
 	while (<$fh>) {
 		if (/^\s*#\s*include\s+"([^"]+)"/) {
 			my $object = $base_dir . $1;
-			if ($src_file =~ /^opencl\// && $object =~ /\.cl$/) {
-				$object = "opencl/" . $object;
+			my $file = $1;
+			my $tmp = "";
+
+			if (! -f $object) {
+				$tmp = $file;
+				if (-f $tmp) {
+					$object = $tmp
+				} elsif ($file =~ /\.c$/) {
+					$tmp = "jumbo/" . $file;
+					if (-f $tmp) {
+						$object = $tmp
+					}
+					$tmp = "jumbo/opencl/" . $file;
+					if (-f $tmp) {
+						$object = $tmp
+					}
+				} elsif ($file =~ /\.h$/) {
+					$tmp = "jumbo/include/" . $file;
+					if (-f $tmp) {
+						$object = $tmp
+					}
+					$tmp = "jumbo/opencl/include/" . $file;
+					if (-f $tmp) {
+						$object = $tmp
+					}
+				}
 			}
 			while ($object =~ s/([^\/]+)\/..\///g) {}
+			if ($object =~ /arch.h$/ && $object ne "arch.h") {
+				$object = $file;
+			}
 			if ($object eq "arch.h" || $object eq "autoconfig.h" || -f $object) {
 				if (!($uniqdep_ref->{$object}++)) {
 					#print "src $src_file obj $object\n";
@@ -69,6 +96,9 @@ sub proc_file {
 		} elsif ($object =~ /\.cl$/) {
 			$object =~ s/^opencl\//..\/run\/kernels\//;
 			$type = "cl";
+		} elsif ($object =~ /\.h$/) {
+			$object =~ s/^opencl\//..\/run\/kernels\//;
+			$type = "h";
 		}
 		if ($type) {
 			my $deps = find_deps($src_file, $uniqobj_ref, \%uniqdeps);
<!-- gh-comment-id:341756805 --> @ghost commented on GitHub (Nov 3, 2017): Anyone with perl skills can change plugin_deps.pl? The `-f $object` at line 30 has to \#include (at least): ``` src/jumbo/include // general *.h src/jumbo/opencl/include // OpenCL *.h ``` I tried, but the result is ridiculous: ``` diff --git a/src/plugin_deps.pl b/src/plugin_deps.pl index f98f486de..57d35729d 100755 --- a/src/plugin_deps.pl +++ b/src/plugin_deps.pl @@ -22,10 +22,37 @@ sub find_deps { while (<$fh>) { if (/^\s*#\s*include\s+"([^"]+)"/) { my $object = $base_dir . $1; - if ($src_file =~ /^opencl\// && $object =~ /\.cl$/) { - $object = "opencl/" . $object; + my $file = $1; + my $tmp = ""; + + if (! -f $object) { + $tmp = $file; + if (-f $tmp) { + $object = $tmp + } elsif ($file =~ /\.c$/) { + $tmp = "jumbo/" . $file; + if (-f $tmp) { + $object = $tmp + } + $tmp = "jumbo/opencl/" . $file; + if (-f $tmp) { + $object = $tmp + } + } elsif ($file =~ /\.h$/) { + $tmp = "jumbo/include/" . $file; + if (-f $tmp) { + $object = $tmp + } + $tmp = "jumbo/opencl/include/" . $file; + if (-f $tmp) { + $object = $tmp + } + } } while ($object =~ s/([^\/]+)\/..\///g) {} + if ($object =~ /arch.h$/ && $object ne "arch.h") { + $object = $file; + } if ($object eq "arch.h" || $object eq "autoconfig.h" || -f $object) { if (!($uniqdep_ref->{$object}++)) { #print "src $src_file obj $object\n"; @@ -69,6 +96,9 @@ sub proc_file { } elsif ($object =~ /\.cl$/) { $object =~ s/^opencl\//..\/run\/kernels\//; $type = "cl"; + } elsif ($object =~ /\.h$/) { + $object =~ s/^opencl\//..\/run\/kernels\//; + $type = "h"; } if ($type) { my $deps = find_deps($src_file, $uniqobj_ref, \%uniqdeps); ```
Author
Owner

@solardiz commented on GitHub (Nov 3, 2017):

Maybe @AlekseyCherepanov would want to help with Perl.

<!-- gh-comment-id:341759674 --> @solardiz commented on GitHub (Nov 3, 2017): Maybe @AlekseyCherepanov would want to help with Perl.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1791
No description provided.