• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <brillo/udev/udev_list_entry.h>
6 
7 #include <libudev.h>
8 
9 #include <base/logging.h>
10 
11 namespace brillo {
12 
UdevListEntry()13 UdevListEntry::UdevListEntry() : list_entry_(nullptr) {}
14 
UdevListEntry(udev_list_entry * list_entry)15 UdevListEntry::UdevListEntry(udev_list_entry* list_entry)
16     : list_entry_(list_entry) {
17   CHECK(list_entry_);
18 }
19 
GetNext() const20 std::unique_ptr<UdevListEntry> UdevListEntry::GetNext() const {
21   udev_list_entry* list_entry = udev_list_entry_get_next(list_entry_);
22   return list_entry ? std::make_unique<UdevListEntry>(list_entry) : nullptr;
23 }
24 
GetByName(const char * name) const25 std::unique_ptr<UdevListEntry> UdevListEntry::GetByName(
26     const char* name) const {
27   udev_list_entry* list_entry = udev_list_entry_get_by_name(list_entry_, name);
28   return list_entry ? std::make_unique<UdevListEntry>(list_entry) : nullptr;
29 }
30 
GetName() const31 const char* UdevListEntry::GetName() const {
32   return udev_list_entry_get_name(list_entry_);
33 }
34 
GetValue() const35 const char* UdevListEntry::GetValue() const {
36   return udev_list_entry_get_value(list_entry_);
37 }
38 
39 }  // namespace brillo
40