libudev.c revision 912541b0246ef315d4d851237483b98c9dd3f992
/*
* libudev - interface to udev device information
*
* Copyright (C) 2008-2010 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 <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "libudev.h"
#include "libudev-private.h"
/**
* SECTION:libudev
* @short_description: libudev context
*
* The context contains the default values read from the udev config file,
* and is passed to all library operations.
*/
/**
* udev:
*
* Opaque object representing the library context.
*/
struct udev {
int refcount;
void *userdata;
char *sys_path;
char *dev_path;
char *rules_path[4];
unsigned long long rules_path_ts[4];
int rules_path_count;
char *run_path;
struct udev_list properties_list;
int log_priority;
};
const char *format, ...)
{
}
{
}
/**
* udev_get_userdata:
* @udev: udev library context
*
* Retrieve stored data pointer from library context. This might be useful
* to access from callbacks like a custom logging function.
*
* Returns: stored userdata
**/
{
return NULL;
}
/**
* udev_set_userdata:
* @udev: udev library context
* @userdata: data pointer
*
* Store custom @userdata in the library context.
**/
{
return;
}
static char *set_value(char **s, const char *v)
{
free(*s);
*s = strdup(v);
util_remove_trailing_chars(*s, '/');
return *s;
}
/**
* udev_new:
*
* Create udev library context. This reads the udev configuration
* file, and fills in the default values.
*
* The initial refcount is 1, and needs to be decremented to
* release the resources of the udev library context.
*
* Returns: a new udev library context
**/
{
const char *env;
char *config_file = NULL;
FILE *f;
return NULL;
/* custom config file */
goto err;
}
/* default config file */
if (config_file == NULL)
if (config_file == NULL)
goto err;
if (f != NULL) {
char line[UTIL_LINE_SIZE];
int line_nr = 0;
char *key;
char *val;
line_nr++;
/* find key */
key++;
/* comment or empty line */
continue;
continue;
}
val[0] = '\0';
val++;
/* find value */
val++;
/* terminate key */
if (len == 0)
continue;
len--;
/* terminate value */
if (len == 0)
continue;
len--;
if (len == 0)
continue;
/* unquote */
continue;
}
val++;
}
continue;
}
continue;
}
continue;
}
continue;
}
continue;
}
}
fclose(f);
}
/* environment overwrites config */
/* set defaults */
goto err;
goto err;
goto err;
if (!udev->rules_path[0])
goto err;
goto err;
goto err;
}
dbg(udev, "rules_path='%s':'%s':'%s'\n", udev->rules_path[0], udev->rules_path[1], udev->rules_path[2]);
return udev;
err:
return NULL;
}
/**
* udev_ref:
* @udev: udev library context
*
* Take a reference of the udev library context.
*
* Returns: the passed udev library context
**/
{
return NULL;
return udev;
}
/**
* udev_unref:
* @udev: udev library context
*
* Drop a reference of the udev library context. If the refcount
* reaches zero, the resources of the context will be released.
*
**/
{
return;
return;
}
/**
* udev_set_log_fn:
* @udev: udev library context
* @log_fn: function to be called for logging messages
*
* The built-in logging writes to stderr. It can be
* overridden by a custom function, to plug log messages
* into the users' logging functionality.
*
**/
{
}
/**
* udev_get_log_priority:
* @udev: udev library context
*
* The initial logging priority is read from the udev config file
* at startup.
*
* Returns: the current logging priority
**/
{
return udev->log_priority;
}
/**
* udev_set_log_priority:
* @udev: udev library context
* @priority: the new logging priority
*
* Set the current logging priority. The value controls which messages
* are logged.
**/
{
char num[32];
}
{
if (stamp_usec)
return udev->rules_path_count;
}
/**
* udev_get_sys_path:
* @udev: udev library context
*
* Retrieve the sysfs mount point. The default is "/sys". For
* testing purposes, it can be overridden with udev_sys=
* in the udev configuration file.
*
* Returns: the sys mount point
**/
{
return NULL;
}
/**
* udev_get_dev_path:
* @udev: udev library context
*
* Retrieve the device directory path. The default value is "/dev",
* the actual value may be overridden in the udev configuration
* file.
*
* Returns: the device directory path
**/
{
return NULL;
}
/**
* udev_get_run_path:
* @udev: udev library context
*
*
* Returns: the runtime directory path
**/
{
return NULL;
}
{
struct udev_list_entry *list_entry;
if (list_entry != NULL)
return NULL;
}
}
{
}