Fossil SCM

Added name_to_uuid2()

stephan 2012-03-18 02:45 trunk
Commit c685a35eb08a1c4676df34018fc1f1f75804bf58
1 file changed +20
+20
--- src/name.c
+++ src/name.c
@@ -265,10 +265,30 @@
265265
blob_reset(pName);
266266
db_blob(pName, "SELECT uuid FROM blob WHERE rid=%d", rid);
267267
return 0;
268268
}
269269
}
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
+
270290
271291
/*
272292
** COMMAND: test-name-to-id
273293
**
274294
** Convert a name to a full artifact ID.
275295
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button