MCPcopy Create free account
hub / github.com/OpenPrinting/cups / httpAssembleUUID

Function httpAssembleUUID

cups/http-support.c:494–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492 */
493
494char * /* I - UUID string */
495httpAssembleUUID(const char *server, /* I - Server name */
496 int port, /* I - Port number */
497 const char *name, /* I - Object name or NULL */
498 int number, /* I - Object number or 0 */
499 char *buffer, /* I - String buffer */
500 size_t bufsize) /* I - Size of buffer */
501{
502 char data[1024]; /* Source string for MD5 */
503 unsigned char md5sum[16]; /* MD5 digest/sum */
504
505
506 /*
507 * Build a version 3 UUID conforming to RFC 4122.
508 *
509 * Start with the MD5 sum of the server, port, object name and
510 * number, and some random data on the end.
511 */
512
513 snprintf(data, sizeof(data), "%s:%d:%s:%d:%04x:%04x", server,
514 port, name ? name : server, number,
515 (unsigned)CUPS_RAND() & 0xffff, (unsigned)CUPS_RAND() & 0xffff);
516
517 cupsHashData("md5", (unsigned char *)data, strlen(data), md5sum, sizeof(md5sum));
518
519 /*
520 * Generate the UUID from the MD5...
521 */
522
523 snprintf(buffer, bufsize,
524 "urn:uuid:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
525 "%02x%02x%02x%02x%02x%02x",
526 md5sum[0], md5sum[1], md5sum[2], md5sum[3], md5sum[4], md5sum[5],
527 (md5sum[6] & 15) | 0x30, md5sum[7], (md5sum[8] & 0x3f) | 0x40,
528 md5sum[9], md5sum[10], md5sum[11], md5sum[12], md5sum[13],
529 md5sum[14], md5sum[15]);
530
531 return (buffer);
532}
533
534
535/*

Callers 4

create_jobFunction · 0.85
add_job_uuidFunction · 0.85
cupsdAddPrinterFunction · 0.85
mainFunction · 0.85

Calls 1

cupsHashDataFunction · 0.85

Tested by 1

mainFunction · 0.68