Skip to content

Commit

Permalink
Adding a UUID generator for SOAP message IDs, and indirectly Onvif su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
wberube committed Nov 26, 2024
1 parent 777f77e commit 37968a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/hal/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,18 @@ void unescape_uri(char *uri) {
src++;
}
*dst = '\0';
}

void uuid_generate(char *uuid) {
const char *chars = "0123456789abcdef";

int i, j = 0;
for (i = 0; i < 36; i++) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
uuid[i] = '-';
} else {
uuid[i] = chars[rand() % 16];
}
}
uuid[36] = '\0';
}
4 changes: 3 additions & 1 deletion src/hal/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ void reverse(void *arr, size_t width);

char *split(char **input, char *sep);

void unescape_uri(char *uri);
void unescape_uri(char *uri);

void uuid_generate(char *uuid);

0 comments on commit 37968a4

Please sign in to comment.