Skip to content

Commit

Permalink
feat(uuid): uuid package
Browse files Browse the repository at this point in the history
  • Loading branch information
neverbot committed May 2, 2024
1 parent f0d7673 commit 5e80570
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions mudlib/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
!/packages/json
!/packages/test
!/packages/time
!/packages/uuid


# ignore games, except the common ones
Expand Down
2 changes: 2 additions & 0 deletions mudlib/packages/uuid/master.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

inherit "/packages/uuid/src/uuid.c";
22 changes: 22 additions & 0 deletions mudlib/packages/uuid/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# uuid.c

Found in:

[LPCsnippets Github Repository](https://github.com/atari2600tim/LPCsnippets/blob/master/uuid.c).

## Info

This is a "version 4" uuid. This is based on random numbers, the others use time.
https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)
supposed to use lower case but accept upper case (so run lower_case when comparing incoming stuff)

Author unknown.

Example:

```
> exec return "/packages/uuid/src/uuid.c"->uuid()
Result:
"be97d609-4d5d-4e35-9b17-00a2f85d353f"
```
11 changes: 11 additions & 0 deletions mudlib/packages/uuid/src/uuid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

string uuid()
{
// This is a "version 4" uuid. This is based on random numbers, the others use time.
// https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)
// supposed to use lower case but accept upper case (so run lower_case when comparing incoming stuff)

return sprintf("%04x%04x-%04x-4%03x-%0x%03x-%04x%04x%04x",
random(0x10000),random(0x10000),random(0x10000),random(0x1000),
(8+random(4)), random(0x1000),random(0x10000),random(0x10000),random(0x10000));
}

0 comments on commit 5e80570

Please sign in to comment.