Fossil SCM
Added name_to_uuid2()
Commit
c685a35eb08a1c4676df34018fc1f1f75804bf58
Parent
ccd6c879b4442c5…
1 file changed
+20
+20
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -265,10 +265,30 @@ | ||
| 265 | 265 | blob_reset(pName); |
| 266 | 266 | db_blob(pName, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 267 | 267 | return 0; |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | + | |
| 271 | +/* | |
| 272 | +** This routine is similar to name_to_uuid() except in the form it | |
| 273 | +** takes its parameters and returns its value, and in that it does not | |
| 274 | +** treat errors as fatal. zName must be a UUID, as described for | |
| 275 | +** name_to_uuid(). zType is also as described for that function. If | |
| 276 | +** zName does not resolve, 0 is returned. If it is ambiguous, a | |
| 277 | +** negative value is returned. On success the rid is returned and | |
| 278 | +** pUuid (if it is not NULL) is set to the a newly-allocated string, | |
| 279 | +** the full UUID, which must eventually be free()d by the caller. | |
| 280 | +*/ | |
| 281 | +int name_to_uuid2(char const *zName, const char *zType, char **pUuid){ | |
| 282 | + int rid = symbolic_name_to_rid(zName, zType); | |
| 283 | + if((rid>0) && pUuid){ | |
| 284 | + *pUuid = db_text(NULL, "SELECT uuid FROM blob WHERE rid=%d", rid); | |
| 285 | + } | |
| 286 | + return rid; | |
| 287 | +} | |
| 288 | + | |
| 289 | + | |
| 270 | 290 | |
| 271 | 291 | /* |
| 272 | 292 | ** COMMAND: test-name-to-id |
| 273 | 293 | ** |
| 274 | 294 | ** Convert a name to a full artifact ID. |
| 275 | 295 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -265,10 +265,30 @@ | |
| 265 | blob_reset(pName); |
| 266 | db_blob(pName, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 267 | return 0; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /* |
| 272 | ** COMMAND: test-name-to-id |
| 273 | ** |
| 274 | ** Convert a name to a full artifact ID. |
| 275 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -265,10 +265,30 @@ | |
| 265 | blob_reset(pName); |
| 266 | db_blob(pName, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 267 | return 0; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /* |
| 272 | ** This routine is similar to name_to_uuid() except in the form it |
| 273 | ** takes its parameters and returns its value, and in that it does not |
| 274 | ** treat errors as fatal. zName must be a UUID, as described for |
| 275 | ** name_to_uuid(). zType is also as described for that function. If |
| 276 | ** zName does not resolve, 0 is returned. If it is ambiguous, a |
| 277 | ** negative value is returned. On success the rid is returned and |
| 278 | ** pUuid (if it is not NULL) is set to the a newly-allocated string, |
| 279 | ** the full UUID, which must eventually be free()d by the caller. |
| 280 | */ |
| 281 | int name_to_uuid2(char const *zName, const char *zType, char **pUuid){ |
| 282 | int rid = symbolic_name_to_rid(zName, zType); |
| 283 | if((rid>0) && pUuid){ |
| 284 | *pUuid = db_text(NULL, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 285 | } |
| 286 | return rid; |
| 287 | } |
| 288 | |
| 289 | |
| 290 | |
| 291 | /* |
| 292 | ** COMMAND: test-name-to-id |
| 293 | ** |
| 294 | ** Convert a name to a full artifact ID. |
| 295 |