|
Lines 1114-1169
Link Here
|
| 1114 |
pc->merge_type, pc->merge_type)); |
1114 |
pc->merge_type, pc->merge_type)); |
| 1115 |
break; |
1115 |
break; |
| 1116 |
} |
1116 |
} |
| 1117 |
} else if (pc->curelem == CURELEM_APPEND && pc->match_ok && |
1117 |
} else if ((pc->curelem == CURELEM_APPEND || pc->curelem == CURELEM_PREPEND) && pc->match_ok && |
| 1118 |
(hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRING || |
1118 |
(hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRING || |
| 1119 |
hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRLIST || |
1119 |
hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRLIST || |
| 1120 |
hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_INVALID)) { |
1120 |
hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_INVALID)) { |
| 1121 |
char buf[256]; |
1121 |
char buf[256]; |
| 1122 |
char buf2[256]; |
1122 |
char buf2[256]; |
| 1123 |
|
1123 |
|
| 1124 |
/* As soon as we are appending, we have matched the device... */ |
1124 |
/* As soon as we are appending/prepending, we have matched the device... */ |
| 1125 |
pc->device_matched = TRUE; |
1125 |
pc->device_matched = TRUE; |
| 1126 |
|
1126 |
|
| 1127 |
if (pc->merge_type == MERGE_TYPE_STRLIST) { |
1127 |
if (pc->merge_type == MERGE_TYPE_STRLIST) { |
| 1128 |
hal_device_property_strlist_append (pc->device, pc->merge_key, pc->cdata_buf); |
1128 |
if (pc->curelem == CURELEM_APPEND){ |
| 1129 |
} else { |
1129 |
hal_device_property_strlist_append (pc->device, pc->merge_key, pc->cdata_buf); |
| 1130 |
const char *existing_string; |
|
|
| 1131 |
|
| 1132 |
switch (pc->merge_type) { |
| 1133 |
case MERGE_TYPE_STRING: |
| 1134 |
strncpy (buf, pc->cdata_buf, sizeof (buf)); |
| 1135 |
break; |
| 1136 |
|
| 1137 |
case MERGE_TYPE_COPY_PROPERTY: |
| 1138 |
hal_device_property_get_as_string (pc->device, pc->cdata_buf, buf, sizeof (buf)); |
| 1139 |
break; |
| 1140 |
|
| 1141 |
default: |
| 1142 |
HAL_ERROR (("Unknown merge_type=%d='%c'", pc->merge_type, pc->merge_type)); |
| 1143 |
break; |
| 1144 |
} |
| 1145 |
|
| 1146 |
existing_string = hal_device_property_get_string (pc->device, pc->merge_key); |
| 1147 |
if (existing_string != NULL) { |
| 1148 |
strncpy (buf2, existing_string, sizeof (buf2)); |
| 1149 |
strncat (buf2, buf, sizeof (buf2) - strlen(buf2)); |
| 1150 |
} else { |
1130 |
} else { |
| 1151 |
strncpy (buf2, buf, sizeof (buf2)); |
1131 |
hal_device_property_strlist_prepend (pc->device, pc->merge_key, pc->cdata_buf); |
| 1152 |
} |
1132 |
} |
| 1153 |
hal_device_property_set_string (pc->device, pc->merge_key, buf2); |
|
|
| 1154 |
} |
| 1155 |
} else if (pc->curelem == CURELEM_PREPEND && pc->match_ok && |
| 1156 |
(hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRING || |
| 1157 |
hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRLIST || |
| 1158 |
hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_INVALID)) { |
| 1159 |
char buf[256]; |
| 1160 |
char buf2[256]; |
| 1161 |
|
| 1162 |
/* As soon as we are prepending, we have matched the device... */ |
| 1163 |
pc->device_matched = TRUE; |
| 1164 |
|
| 1165 |
if (pc->merge_type == MERGE_TYPE_STRLIST) { |
| 1166 |
hal_device_property_strlist_prepend (pc->device, pc->merge_key, pc->cdata_buf); |
| 1167 |
} else { |
1133 |
} else { |
| 1168 |
const char *existing_string; |
1134 |
const char *existing_string; |
| 1169 |
|
1135 |
|
|
Lines 1173-1180
Link Here
|
| 1173 |
break; |
1139 |
break; |
| 1174 |
|
1140 |
|
| 1175 |
case MERGE_TYPE_COPY_PROPERTY: |
1141 |
case MERGE_TYPE_COPY_PROPERTY: |
| 1176 |
hal_device_property_get_as_string (pc->device, pc->cdata_buf, buf, sizeof (buf)); |
1142 |
{ |
|
|
1143 |
char udi_to_merge_from[256]; |
| 1144 |
char prop_to_merge[256]; |
| 1145 |
|
| 1146 |
/* Resolve key paths like 'someudi/foo/bar/baz:prop.name' |
| 1147 |
* '@prop.here.is.an.udi:with.prop.name' |
| 1148 |
*/ |
| 1149 |
if (!resolve_udiprop_path (pc->cdata_buf, |
| 1150 |
pc->device->udi, |
| 1151 |
udi_to_merge_from, sizeof (udi_to_merge_from), |
| 1152 |
prop_to_merge, sizeof (prop_to_merge))) { |
| 1153 |
HAL_ERROR (("Could not resolve keypath '%s' on udi '%s'", pc->cdata_buf, pc->device->udi)); |
| 1154 |
} else { |
| 1155 |
HalDevice *d; |
| 1156 |
|
| 1157 |
d = hal_device_store_find (hald_get_gdl (), udi_to_merge_from); |
| 1158 |
if (d == NULL) { |
| 1159 |
d = hal_device_store_find (hald_get_tdl (), udi_to_merge_from); |
| 1160 |
} |
| 1161 |
if (d == NULL) { |
| 1162 |
HAL_ERROR (("Could not find device with udi '%s'", udi_to_merge_from)); |
| 1163 |
} else { |
| 1164 |
hal_device_property_get_as_string (d, prop_to_merge, buf, sizeof (buf)); |
| 1165 |
} |
| 1166 |
} |
| 1167 |
|
| 1177 |
break; |
1168 |
break; |
|
|
1169 |
} |
| 1178 |
|
1170 |
|
| 1179 |
default: |
1171 |
default: |
| 1180 |
HAL_ERROR (("Unknown merge_type=%d='%c'", pc->merge_type, pc->merge_type)); |
1172 |
HAL_ERROR (("Unknown merge_type=%d='%c'", pc->merge_type, pc->merge_type)); |
|
Lines 1183-1190
Link Here
|
| 1183 |
|
1175 |
|
| 1184 |
existing_string = hal_device_property_get_string (pc->device, pc->merge_key); |
1176 |
existing_string = hal_device_property_get_string (pc->device, pc->merge_key); |
| 1185 |
if (existing_string != NULL) { |
1177 |
if (existing_string != NULL) { |
| 1186 |
strncpy (buf2, buf, sizeof (buf2)); |
1178 |
if (pc->curelem == CURELEM_APPEND){ |
| 1187 |
strncat (buf2, existing_string, sizeof (buf2) - strlen(buf2)); |
1179 |
strncpy (buf2, existing_string, sizeof (buf2)); |
|
|
1180 |
strncat (buf2, buf, sizeof (buf2) - strlen(buf2)); |
| 1181 |
} else { |
| 1182 |
strncpy (buf2, buf, sizeof (buf2)); |
| 1183 |
strncat (buf2, existing_string, sizeof (buf2) - strlen(buf2)); |
| 1184 |
} |
| 1188 |
} else { |
1185 |
} else { |
| 1189 |
strncpy (buf2, buf, sizeof (buf2)); |
1186 |
strncpy (buf2, buf, sizeof (buf2)); |
| 1190 |
} |
1187 |
} |