+ switch (c) {
+ case 'b':
+ if (strlen(udev->bus_id) == 0)
+ break;
+ strnfieldcat(string, udev->bus_id, maxsize);
+ dbg("substitute bus_id '%s'", udev->bus_id);
+ break;
+ case 'k':
+ if (strlen(udev->kernel_name) == 0)
+ break;
+ strnfieldcat(string, udev->kernel_name, maxsize);
+ dbg("substitute kernel name '%s'", udev->kernel_name);
+ break;
+ case 'n':
+ if (strlen(udev->kernel_number) == 0)
+ break;
+ strnfieldcat(string, udev->kernel_number, maxsize);
+ dbg("substitute kernel number '%s'", udev->kernel_number);
+ break;
+ case 'm':
+ strnintcat(string, udev->minor, maxsize);
+ dbg("substitute minor number '%u'", udev->minor);
+ break;
+ case 'M':
+ strnintcat(string, udev->major, maxsize);
+ dbg("substitute major number '%u'", udev->major);
+ break;
+ case 'c':
+ if (strlen(udev->program_result) == 0)
+ break;
+ /* get part part of the result string */
+ i = 0;
+ if (attr != NULL)
+ i = atoi(attr);
+ if (i > 0) {
+ strfieldcpy(temp1, udev->program_result);
+ pos2 = temp1;
+ while (i) {
+ i--;
+ pos3 = strsep(&pos2, " ");
+ if (pos3 == NULL) {
+ dbg("requested part of result string not found");
+ break;
+ }
+ }
+ if (pos3) {
+ strnfieldcat(string, pos3, maxsize);
+ dbg("substitute part of result string '%s'", pos3);
+ }
+ } else {
+ strnfieldcat(string, udev->program_result, maxsize);
+ dbg("substitute result string '%s'", udev->program_result);
+ }
+ break;
+ case 's':
+ if (attr != NULL) {
+ tmpattr = find_sysfs_attribute(class_dev, sysfs_device, attr);
+ if (tmpattr == NULL) {
+ dbg("sysfa attribute '%s' not found", attr);
+ break;
+ }
+ strnfieldcat(string, tmpattr->value, maxsize);
+ dbg("substitute sysfs value '%s'", tmpattr->value);
+ } else {
+ dbg("missing attribute");
+ }
+ break;
+ case '%':
+ strnfieldcat(string, "%", maxsize);
+ break;
+ default:
+ dbg("unknown substitution type '%%%c'", c);
+ break;
+ }
+ /* truncate to specified length */
+ if (len > 0)
+ pos[len] = '\0';