CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/compiler/utils.rb
Views: 1904
1
module Metasploit
2
module Framework
3
module Compiler
4
module Utils
5
6
# Returns the normalized C code (with headers).
7
#
8
# @param code [String] The C source code.
9
# @param headers [Metasploit::Framework::Compiler::Headers::Win32]
10
# @return [String] The normalized code.
11
def self.normalize_code(code, headers)
12
code = code.lines.map { |line|
13
if line =~ /^\s*#include <([[:print:]]+)>$/
14
h = headers.include("#{$1}")
15
%Q|#{h}\n|
16
else
17
line
18
end
19
}.join
20
21
code
22
end
23
24
end
25
end
26
end
27
end
28
29