From 745b61171af167dfe5756920f968d976bd4b6366 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Tue, 3 Jan 2012 10:48:44 +0100 Subject: [PATCH] Introduce LiveGetDevice function --- src/util-device.c | 28 ++++++++++++++++++++++++++++ src/util-device.h | 1 + 2 files changed, 29 insertions(+) diff --git a/src/util-device.c b/src/util-device.c index 94d48df9a7..7549f3a89a 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -93,6 +93,34 @@ char *LiveGetDeviceName(int number) { return NULL; } +/** + * \brief Get a pointer to the device at idx + * + * \param number idx of the device in our list + * + * \retval ptr pointer to the string containing the device + * \retval NULL on error + */ +LiveDevice *LiveGetDevice(char *name) { + int i = 0; + LiveDevice *pd; + + if (name == NULL) { + SCLogWarning(SC_ERR_INVALID_VALUE, "Name of device should not be null"); + return NULL; + } + + TAILQ_FOREACH(pd, &live_devices, next) { + if (!strcmp(name, pd->dev)) { + return pd; + } + + i++; + } + + return NULL; +} + int LiveBuildDeviceList(char * runmode) diff --git a/src/util-device.h b/src/util-device.h index 77b99bd23c..ce6997f3b9 100644 --- a/src/util-device.h +++ b/src/util-device.h @@ -30,6 +30,7 @@ typedef struct LiveDevice_ { int LiveRegisterDevice(char *dev); int LiveGetDeviceCount(void); char *LiveGetDeviceName(int number); +LiveDevice *LiveGetDevice(char *dev); int LiveBuildDeviceList(char * base); #endif /* __UTIL_DEVICE_H__ */