Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

_guuid4 - generate version 4 Universal Unique Identifier (from CRTE V21.0A50)

&pagelevel(4)&pagelevel

Syntax

#include <bs2uuid4.h>

int _guuid4(char *s, int len);

Description

_guuid4 generates a unique 36-character string each time it is called, representing a random-number-based (Version 4) Universal Unique Identifier (UUID) according to ISO/IEC 9834-8.

Parameters

char *s

 Pointer to the result string s. This area must be large enough to hold len characters.

int len

len must be 36 or 37. If len is 37, the result string will be null-terminated.

Return val.

Integer value


0

-1

if successful.

if there is an error.  If len has a value other than 36 or 37. errno is set to EINVAL

to indicate the error. The memory area pointed to by s remains unchanged in case of an error.

Notes

In bs2uuid4.h, UUID4_LEN is defined as 37.

The length 36 is supported to facilitate direct calls to the function from COBOL programs.

Example 1

Call function from C program:

#include <bs2uuid.h>
...
  
char buf[UUID4_LEN];
  
if (_guuid4(buf, UUID4_LEN) == UUID4_ESUCCESS) { ... }

Example 2

Call function from COBOL program:

       >>SOURCE FREE
>>IMP LISTING-OPTIONS MERGE-DIAGNOSTICS
PROGRAM-ID. TSTUUID4.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
   TERMINAL IS ttt.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 uuid4 PIC X(36) VALUE ALL "X".
01 uuid-len PIC S9(5) COMP-5 VALUE 36.
PROCEDURE DIVISION.
PARA1.
  CALL "_guuid4" USING uuid4 BY VALUE uuid-len.
  DISPLAY uuid4 UPON ttt.
  GOBACK.