Method: Rex::Compat.getenv

Defined in:
lib/rex/compat.rb

.getenv(var) ⇒ Object



236
237
238
239
240
241
242
243
244
245
246
# File 'lib/rex/compat.rb', line 236

def self.getenv(var)
  if (is_windows and @@loaded_win32api)
    f = Win32API.new("kernel32", "GetEnvironmentVariable", ["P", "P", "I"], "I")
    buff = "\x00" * 16384
    sz = f.call(var, buff, buff.length)
    return nil if sz == 0
    buff[0,sz]
  else
    ENV[var]
  end
end