|
1 | 1 | /* |
2 | 2 | * Copyright (C) 2012-2016 OpenHeadend S.A.R.L. |
| 3 | + * Copyright (C) 2026 EasyTools |
3 | 4 | * |
4 | 5 | * Authors: Christophe Massiot |
5 | 6 | * |
@@ -2187,6 +2188,24 @@ static inline int uref_##group##_copy_##attr(struct uref *uref, \ |
2187 | 2188 | { \ |
2188 | 2189 | return uref_attr_copy_rational(uref, uref_src, UDICT_TYPE_RATIONAL, \ |
2189 | 2190 | name); \ |
| 2191 | +} \ |
| 2192 | +/** @This compares the desc attribute in two urefs. \ |
| 2193 | + * \ |
| 2194 | + * @param uref1 pointer to the first uref \ |
| 2195 | + * @param uref2 pointer to the second uref \ |
| 2196 | + * @return 0 if both attributes are absent or identical \ |
| 2197 | + */ \ |
| 2198 | +static inline int \ |
| 2199 | +uref_##group##_cmp_##attr(struct uref *uref1, struct uref *uref2) \ |
| 2200 | +{ \ |
| 2201 | + struct urational v1, v2; \ |
| 2202 | + int err1 = uref_##group##_get_##attr(uref1, &v1); \ |
| 2203 | + int err2 = uref_##group##_get_##attr(uref2, &v2); \ |
| 2204 | + if (!ubase_check(err1) && !ubase_check(err2)) \ |
| 2205 | + return 0; \ |
| 2206 | + if (!ubase_check(err1) || !ubase_check(err2)) \ |
| 2207 | + return -1; \ |
| 2208 | + return urational_cmp(&v1, &v2); \ |
2190 | 2209 | } |
2191 | 2210 |
|
2192 | 2211 | /* @This allows to define accessors for a shorthand rational attribute. |
@@ -2238,6 +2257,24 @@ static inline int uref_##group##_copy_##attr(struct uref *uref, \ |
2238 | 2257 | struct uref *uref_src) \ |
2239 | 2258 | { \ |
2240 | 2259 | return uref_attr_copy_rational(uref, uref_src, type, NULL); \ |
| 2260 | +} \ |
| 2261 | +/** @This compares the desc attribute in two urefs. \ |
| 2262 | + * \ |
| 2263 | + * @param uref1 pointer to the first uref \ |
| 2264 | + * @param uref2 pointer to the second uref \ |
| 2265 | + * @return 0 if both attributes are absent or identical \ |
| 2266 | + */ \ |
| 2267 | +static inline int \ |
| 2268 | +uref_##group##_cmp_##attr(struct uref *uref1, struct uref *uref2) \ |
| 2269 | +{ \ |
| 2270 | + struct urational v1, v2; \ |
| 2271 | + int err1 = uref_##group##_get_##attr(uref1, &v1); \ |
| 2272 | + int err2 = uref_##group##_get_##attr(uref2, &v2); \ |
| 2273 | + if (!ubase_check(err1) && !ubase_check(err2)) \ |
| 2274 | + return 0; \ |
| 2275 | + if (!ubase_check(err1) || !ubase_check(err2)) \ |
| 2276 | + return -1; \ |
| 2277 | + return urational_cmp(&v1, &v2); \ |
2241 | 2278 | } |
2242 | 2279 |
|
2243 | 2280 | /* @This allows to define accessors for a rational attribute, with a name |
|
0 commit comments