libudev-list.c revision 666fcf03bceea8e8dd6c4510220036d1b949b814
/*
* libudev - interface to udev device information
*
* Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include "libudev.h"
#include "libudev-private.h"
/**
* SECTION:libudev-list
* @short_description: list operation
*
* Libudev list operations.
*/
/**
* udev_list_entry:
*
* Opaque object representing one entry in a list. An entry contains
* contains a name, and optionally a value.
*/
struct udev_list_entry {
struct udev_list_node node;
struct udev_list_node *list;
char *name;
char *value;
int num;
};
/* the list's head points to itself if empty */
{
}
{
}
struct udev_list_node *prev,
struct udev_list_node *next)
{
}
{
}
{
}
/* return list entry which embeds this node */
{
char *list;
return (struct udev_list_entry *)list;
}
/* insert entry into a list as the last element */
{
/* inserting before the list head make the node the last node in the list */
}
/* remove entry from a list */
{
}
/* insert entry into a list, before a given existing entry */
{
}
unsigned int flags)
{
struct udev_list_entry *entry_new;
if (flags & UDEV_LIST_UNIQUE) {
return entry_loop;
}
return NULL;
return entry_loop;
}
}
}
if (flags & UDEV_LIST_SORT) {
break;
}
}
return NULL;
return NULL;
}
return NULL;
}
}
if (entry_loop != NULL)
else
return entry_new;
}
{
}
{
struct udev_list_entry *entry_loop;
struct udev_list_entry *entry_tmp;
}
{
if (udev_list_is_empty(list))
return NULL;
}
/**
* udev_list_entry_get_next:
* @list_entry: current entry
*
* Returns: the next entry from the list, #NULL is no more entries are found.
*/
{
struct udev_list_node *next;
if (list_entry == NULL)
return NULL;
/* empty list or no more entries */
return NULL;
return list_node_to_entry(next);
}
/**
* udev_list_entry_get_by_name:
* @list_entry: current entry
* @name: name string to match
*
* Returns: the entry where @name matched, #NULL if no matching entry is found.
*/
UDEV_EXPORT struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name)
{
struct udev_list_entry *entry;
return entry;
}
}
return NULL;
}
/**
* udev_list_entry_get_name:
* @list_entry: current entry
*
* Returns: the name string of this entry.
*/
{
if (list_entry == NULL)
return NULL;
return list_entry->name;
}
/**
* udev_list_entry_get_value:
* @list_entry: current entry
*
* Returns: the value string of this entry.
*/
{
if (list_entry == NULL)
return NULL;
return list_entry->value;
}
{
if (list_entry == NULL)
return -EINVAL;
return list_entry->num;
}
{
if (list_entry == NULL)
return;
}