MCPcopy Create free account
hub / github.com/antirez/ds4 / random_tool_id

Function random_tool_id

ds4_server.c:499–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497
498static bool server_image_media_type(const char *media_type) {
499 return media_type &&
500 (!strcasecmp(media_type, "image/png") ||
501 !strcasecmp(media_type, "image/jpeg") ||
502 !strcasecmp(media_type, "image/jpg"));
503}
504
505static bool server_image_inputs_push_base64(server_image_inputs *images,
506 const char *media_type,
507 const char *base64,
508 char marker[SERVER_IMAGE_MARKER_BYTES]) {
509 if (!server_image_media_type(media_type)) return false;
510 server_image_input image = {0};
511 if (!server_decode_base64(base64, &image.encoded, &image.encoded_len))
512 return false;
513 unsigned char nonce[12];
514 if (!random_bytes(nonce, sizeof(nonce))) {
515 uint64_t fallback = (uint64_t)time(NULL) ^
516 ((uint64_t)getpid() << 32) ^
517 (uint64_t)(uintptr_t)images;
518 memcpy(nonce, &fallback, sizeof(fallback));
519 memset(nonce + sizeof(fallback), 0, sizeof(nonce) - sizeof(fallback));
520 }
521 static const char hex[] = "0123456789abcdef";
522 size_t pos = (size_t)snprintf(image.marker, sizeof(image.marker),

Callers 3

openai_tool_stream_idFunction · 0.85
anthropic_tool_stream_idFunction · 0.85
assign_tool_call_idsFunction · 0.85

Calls 1

random_bytesFunction · 0.85

Tested by

no test coverage detected