102
if (sscanf (str, "%x", hex) != 1)
105
if (sscanf (str, "%x%n", hex, &end) < 1)
109
if (*str && (! strchr (" \t\r\n", *str)))
117
* @str: string to parse.
118
* @array: integer array to fill.
119
* @array_len: number of elements of integer array.
121
* Scans @str and reads a colon separated array of hexadecimal numbers.
123
* These arrays are a little strange, the kernel actually prints them
124
* backwards starting from the first non-zero part; so they may not actually
127
* Returns: 0 on success, 1 on failure.
130
parse_array (const char *str,
136
memset (array, 0, array_len * sizeof (unsigned int));
142
if (sscanf (str, "%x%n", &array[--i], &end) < 1)
148
} else if (*str && (! strchr (" \t\r\n", *str))) {
155
for (j = 0; j < array_len; j++, i++)
156
array[j] = (i < array_len ? array[i] : 0);
163
* @line: line to parse.
164
* @format: expected values.
166
* Parses the line according to the @format string, after skipping any
167
* initial module name. The format string should be a sequence of 'x'
168
* or 'a' characters; for each 'x' character an unsigned int pointer
169
* should be passed and a hexadecimal number parsed from the line will
170
* be placed in it; for each 'a' character an unsigned int pointer
171
* should be passed with enough space for as many elements as specified
172
* by a size_t parameter also passed.
175
* parse_line(line, "xxa", &hex1, &hex2, array, 4)
177
* Returns: 0 if all values are pased, 1 if not.
180
parse_line (const char *line,
187
va_start (args, format);
189
for (c = format; *c; c++) {
193
line += strcspn (line, " \t\r\n");
194
line += strspn (line, " \t\r\n");
198
val = va_arg (args, unsigned int *);
199
if (parse_hex (line, val))
204
val = va_arg (args, unsigned int *);
205
len = va_arg (args, size_t);
206
if (parse_array (line, val, len))
220
* @mask: bits that must be present in the array.
221
* @array: array to check.
222
* @array_len: number of elements in both arrays.
224
* Check that @array has all of the bits present in @mask.
226
* Returns: 0 if the arrays match, non-zero if not.
229
match_array (const unsigned int *mask,
230
const unsigned int *array,
235
for (i = 0; i < array_len; i++) {
236
if (! FLAG_SET(array[i], mask[i]))