+ size_t val_len = strnlen(value, PATH_SIZE);
+
+ key->operation = operation;
+
+ key->val_off = rule->bufsize;
+ strlcpy(rule->buf + rule->bufsize, value, val_len+1);
+ rule->bufsize += val_len+1;
+
+ return 0;
+}
+
+static int add_rule_key_pair(struct udev_rule *rule, struct key_pairs *pairs,
+ enum key_operation operation, const char *key, const char *value)
+{
+ size_t key_len = strnlen(key, PATH_SIZE);
+
+ if (pairs->count >= PAIRS_MAX) {
+ err("skip, too many keys in a single rule");
+ return -1;
+ }
+
+ add_rule_key(rule, &pairs->keys[pairs->count].key, operation, value);
+
+ /* add the key-name of the pair */
+ pairs->keys[pairs->count].key_name_off = rule->bufsize;
+ strlcpy(rule->buf + rule->bufsize, key, key_len+1);
+ rule->bufsize += key_len+1;
+
+ pairs->count++;
+
+ return 0;
+}
+
+static int add_to_rules(struct udev_rules *rules, char *line)
+{
+ struct udev_rule *rule;
+ size_t rule_size;
+ int valid;