diff options
-rwxr-xr-x | content/posts/WIP-how-bsd-authentication-works/gen_dot.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/content/posts/WIP-how-bsd-authentication-works/gen_dot.rb b/content/posts/WIP-how-bsd-authentication-works/gen_dot.rb index 5adb453..9f71876 100755 --- a/content/posts/WIP-how-bsd-authentication-works/gen_dot.rb +++ b/content/posts/WIP-how-bsd-authentication-works/gen_dot.rb @@ -1,10 +1,11 @@ #!/usr/bin/env ruby # frozen_string_literal: true -# Copyright (c) 2021 Dante Catalfamo +# Copyright (C) 2021 Dante Catalfamo # SPDX-License-Identifier: MIT require 'digest' +require 'set' SOURCE_DIR = File.join Dir.home, 'src', 'github.com', 'openbsd', 'src', 'lib', 'libc', 'gen' FILENAMES = %w[authenticate.c auth_subr.c login_cap.c].freeze @@ -42,7 +43,7 @@ class FunctionDigraph end def emit - puts "#{from} -> #{to} [color = \"##{color}\"]" if to =~ /auth|login|^_/ + puts "#{from} -> #{to} [color = \"##{color}\"]" end def color @@ -60,8 +61,12 @@ class FunctionDigraph puts 'rankdir=LR' puts 'splines=ortho' puts 'graph [pad="0.5", nodesep="0.5", ranksep="1.5"]' + all_functions = Set.new + @subgraphs.each { |s| all_functions.merge(s.functions) } @subgraphs.each(&:emit) - @pairs.uniq { |p| [p.to, p.from] }.each(&:emit) + @pairs.uniq { |p| [p.to, p.from] }.each do |p| + p.emit if all_functions.include?(p.to) + end puts '}' end |