udev_rules_parse.c revision 17fcfb5972977b6a3aedca6ad2aa8d1fbfbc761d
/*
* Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2003-2008 Kay Sievers <kay.sievers@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include "udev.h"
#include "udev_rules.h"
{
}
{
struct udev_rules *rules;
if (!rules)
return NULL;
return NULL;
}
/* get next rule */
return rule;
}
{
next:
return NULL;
}
goto next;
}
return rule;
}
static int get_key(struct udev_rules *rules, char **line, char **key, enum key_operation *operation, char **value)
{
char *linepos;
char *temp;
return -1;
/* skip whitespace */
linepos++;
/* get the key */
if (linepos[0] == '\0')
return -1;
while (1) {
linepos++;
if (linepos[0] == '\0')
return -1;
break;
if (linepos[0] == '=')
break;
break;
}
/* remember end of key */
/* skip whitespace after key */
linepos++;
if (linepos[0] == '\0')
return -1;
/* get operation type */
linepos += 2;
linepos += 2;
*operation = KEY_OP_ADD;
linepos += 2;
} else if (linepos[0] == '=') {
linepos++;
linepos += 2;
} else
return -1;
/* terminate key */
temp[0] = '\0';
/* skip whitespace after operator */
linepos++;
if (linepos[0] == '\0')
return -1;
/* get the value*/
if (linepos[0] == '"')
linepos++;
else
return -1;
if (!temp)
return -1;
temp[0] = '\0';
temp++;
/* move line to next key */
return 0;
}
/* extract possible KEY{attr} */
{
char *pos;
char *attr;
attr++;
return NULL;
}
pos[0] = '\0';
return attr;
}
return NULL;
}
{
return 0;
}
static int add_rule_key_pair(struct udev_rules *rules, struct udev_rule *rule, struct key_pairs *pairs,
{
return -1;
}
/* add the key-name of the pair */
return 0;
}
static int add_to_rules(struct udev_rules *rules, char *line, const char *filename, unsigned int lineno)
{
int valid;
char *linepos;
char *attr;
int physdev = 0;
int retval;
valid = 0;
/* get all the keys */
while (1) {
char *key;
char *value;
if (retval)
break;
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
/* bus, class, subsystem events should all be the same */
} else
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
goto invalid;
}
goto invalid;
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
goto invalid;
}
err(rules->udev, "do not reference parent sysfs directories directly, that may break with a future kernel, \n"
goto invalid;
valid = 1;
continue;
}
goto invalid;
}
physdev = 1;
goto invalid;
valid = 1;
continue;
}
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
} else {
/* figure it out if it is executable */
char file[UTIL_PATH_SIZE];
char *pos;
if (pos)
pos[0] = '\0';
if (pos)
pos[0] = '\0';
}
} else {
}
}
valid = 1;
continue;
}
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
goto invalid;
}
valid = 1;
continue;
}
}
valid = 1;
continue;
}
valid = 1;
continue;
}
valid = 1;
continue;
}
valid = 1;
continue;
}
}
}
}
if (value[0] == '\0')
continue;
}
if (operation == KEY_OP_MATCH ||
else
valid = 1;
continue;
}
valid = 1;
char *endptr;
if (endptr[0] != '\0') {
char owner[32];
continue;
}
}
continue;
}
valid = 1;
char *endptr;
if (endptr[0] != '\0') {
char group[32];
continue;
}
}
continue;
}
valid = 1;
continue;
}
const char *pos;
}
}
}
}
}
}
}
valid = 1;
continue;
}
}
/* skip line if not any valid key was found */
if (!valid)
goto invalid;
/* grow buffer and add rule */
goto exit;
}
exit:
return 0;
return -1;
}
{
char line[UTIL_LINE_SIZE];
char *bufline;
unsigned int lineno;
char *buf;
int retval = 0;
return -1;
}
/* loop through the whole file */
cur = 0;
lineno = 0;
unsigned int i, j;
lineno++;
/* eat the whitespace */
bufline++;
count--;
}
if (count == 0)
continue;
/* see if this is a comment */
if (bufline[0] == '#')
continue;
continue;
}
/* skip backslash and newline from multiline rules */
for (i = j = 0; i < count; i++) {
continue;
}
line[j] = '\0';
}
return retval;
}
{
int retval = 0;
/* custom rules location for testing */
} else {
}
/* read default rules */
/* sort all rules files by basename into list of files */
continue;
continue;
continue;
}
break;
}
}
}
/* parse list of files */
else
} else
}
return retval;
}
{
}
}