Module: DhcpsApi::CommonMethods

Included in:
Option, Reservation, Server, Subnet
Defined in:
lib/dhcpsapi/common.rb

Instance Method Summary collapse

Instance Method Details

#empty_responseObject



89
90
91
# File 'lib/dhcpsapi/common.rb', line 89

def empty_response
  [[], 0, 0, 0]
end

#free_memory(a_struct) ⇒ Object



70
71
72
# File 'lib/dhcpsapi/common.rb', line 70

def free_memory(a_struct)
  DhcpsApi::Win2008::Common.DhcpRpcFreeMemory(a_struct.pointer)
end

#is_error?(exit_code) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
96
97
98
99
# File 'lib/dhcpsapi/common.rb', line 93

def is_error?(exit_code)
  !Set.new([
             0, # no error
             234 # more data
         # 259 no more items
           ]).include?(exit_code)
end

#retrieve_items(method_to_call, *args) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/dhcpsapi/common.rb', line 74

def retrieve_items(method_to_call, *args)
  to_return = []
  resume_handle = 0

  loop do
    items, resume_handle, elements_read, elements_total = send(method_to_call, *args)
    to_return += items
    args.pop
    args.push(resume_handle)
    break if elements_read == elements_total
  end

  [to_return, resume_handle]
end