device_info.c revision 1c755acb8b54d6f80f5596caa88a09843742ae97
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/***************************************************************************
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * CVSID: $Id$
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * device_store.c : Search for .fdi files and merge on match
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Licensed under the Academic Free License version 2.1
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * This program is free software; you can redistribute it and/or modify
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * it under the terms of the GNU General Public License as published by
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * the Free Software Foundation; either version 2 of the License, or
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * (at your option) any later version.
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * This program is distributed in the hope that it will be useful,
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * but WITHOUT ANY WARRANTY; without even the implied warranty of
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * GNU General Public License for more details.
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * You should have received a copy of the GNU General Public License
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * along with this program; if not, write to the Free Software
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc **************************************************************************/
#include "hald.h"
#include "logger.h"
#include "device_info.h"
#include "device_store.h"
#include "util.h"
CURELEM_DEVICE_INFO = 0,
MERGE_TYPE_UNKNOWN = 0,
char *file;
int cdata_buf_len;
int depth;
int curelem;
int merge_type;
* /org/freedesktop/Hal/devices/computer:kernel.name
* @block.storage_device:storage.bus
static gboolean
goto out;
HalDevice *d;
if (d == NULL)
if (d == NULL)
goto out;
goto out;
const char *udiprop;
const char *newudi;
goto out;
out:
return rc;
static gboolean
match_compare_property (HalDevice *d, const char *key, const char *right_side, dbus_int64_t *result)
int proptype;
goto out;
switch (proptype) {
case HAL_PROPERTY_TYPE_STRING:
case HAL_PROPERTY_TYPE_INT32:
case HAL_PROPERTY_TYPE_UINT64:
*result = ((dbus_int64_t) hal_device_property_get_uint64 (d, key)) - ((dbus_int64_t) strtoll (right_side, NULL, 0));
case HAL_PROPERTY_TYPE_DOUBLE:
out:
return rc;
static dbus_bool_t
const char *key;
int num_attrib;
HalDevice *d;
return FALSE;
return FALSE;
return FALSE;
if (d == NULL) {
if (d == NULL) {
return FALSE;
const char *value;
return FALSE;
value) != 0)
return FALSE;
return TRUE;
return FALSE;
return FALSE;
return TRUE;
return FALSE;
return FALSE;
return TRUE;
return FALSE;
return FALSE;
return FALSE;
return TRUE;
if (should_exist) {
return TRUE;
return FALSE;
return FALSE;
return TRUE;
int type;
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
return FALSE;
if (should_be_empty) {
if (is_empty)
return TRUE;
return FALSE;
if (is_empty)
return FALSE;
return TRUE;
const char *str;
return FALSE;
if (should_be_ascii) {
if (is_ascii)
return TRUE;
return FALSE;
if (is_ascii)
return FALSE;
return TRUE;
return FALSE;
/*HAL_INFO (("is_absolute=%d, should_be=%d, path='%s'", is_absolute_path, should_be_absolute_path, path));*/
if (should_be_absolute_path) {
if (is_absolute_path)
return TRUE;
return FALSE;
if (is_absolute_path)
return FALSE;
return TRUE;
const char *needle;
const char *haystack;
GSList *i;
return FALSE;
return contains;
const char *needle;
char *needle_lowercase;
char *haystack_lowercase;
if (needle_lowercase != NULL && haystack_lowercase != NULL && strstr (haystack_lowercase, needle_lowercase)) {
GSList *i;
return FALSE;
return contains_ncase;
return FALSE;
return result < 0;
return FALSE;
return result <= 0;
return FALSE;
return result > 0;
return FALSE;
return result >= 0;
return FALSE;
int num_attrib;
int num_attrib;
int num_attrib;
int num_attrib;
int num_attrib;
case MERGE_TYPE_STRING:
case MERGE_TYPE_STRLIST:
case MERGE_TYPE_INT32:
case MERGE_TYPE_UINT64:
case MERGE_TYPE_BOOLEAN:
case MERGE_TYPE_DOUBLE:
case MERGE_TYPE_COPY_PROPERTY:
* '@prop.here.is.an.udi:with.prop.name'
HalDevice *d;
if (d == NULL) {
if (d == NULL) {
const char *existing_string;
case MERGE_TYPE_STRING:
case MERGE_TYPE_COPY_PROPERTY:
const char *existing_string;
case MERGE_TYPE_STRING:
case MERGE_TYPE_COPY_PROPERTY:
int bytes_left;
int bytes_to_copy;
if (bytes_to_copy > 0)
static dbus_bool_t
int rc;
int filesize;
char *filebuf;
goto out;
goto out;
goto out;
goto out;
if (rc == 0) {
buf,
out:
return device_matched;
#ifdef __GLIBC__
my_alphasort(const void *a, const void *b)
return -alphasort (a, b);
static dbus_bool_t
int num_entries;
found_fdi_file = 0;
return FALSE;
int len;
char *filename;
if (found_fdi_file) {
int num_bytes;
char *dirname;
num_bytes));
filename);
return found_fdi_file;
char *s1;
char *s2;
char *s3;
if (!have_checked_hal_fdi_source) {
switch (type) {
case DEVICE_INFO_TYPE_POLICY:
return ret;