UUID Handling
[Brought To You By APR]

Collaboration diagram for UUID Handling:

Data Structures

struct  switch_uuid_t

Defines

#define SWITCH_UUID_FORMATTED_LENGTH   256
#define SWITCH_MD5_DIGESTSIZE   16
#define SWITCH_MD5_DIGEST_STRING_SIZE   33

Functions

void switch_uuid_format (char *buffer, const switch_uuid_t *uuid)
void switch_uuid_get (switch_uuid_t *uuid)
switch_status_t switch_uuid_parse (switch_uuid_t *uuid, const char *uuid_str)
switch_status_t switch_md5 (unsigned char digest[SWITCH_MD5_DIGESTSIZE], const void *input, switch_size_t inputLen)
switch_status_t switch_md5_string (char digest_str[SWITCH_MD5_DIGEST_STRING_SIZE], const void *input, switch_size_t inputLen)


Define Documentation

#define SWITCH_MD5_DIGEST_STRING_SIZE   33

Definition at line 597 of file switch_apr.h.

#define SWITCH_MD5_DIGESTSIZE   16

Definition at line 596 of file switch_apr.h.

Referenced by switch_md5_string().

#define SWITCH_UUID_FORMATTED_LENGTH   256

UUIDs are formatted as: 00112233-4455-6677-8899-AABBCCDDEEFF

Definition at line 594 of file switch_apr.h.

Referenced by switch_caller_profile_dup(), switch_caller_profile_new(), switch_core_perform_file_open(), switch_ivr_insert_file(), switch_ivr_intercept_session(), and switch_uuid_str().


Function Documentation

switch_status_t switch_md5 ( unsigned char  digest[SWITCH_MD5_DIGESTSIZE],
const void *  input,
switch_size_t  inputLen 
)

MD5 in one step

Parameters:
digest The final MD5 digest
input The message block to use
inputLen The length of the message block

Definition at line 1006 of file switch_apr.c.

01007 {
01008         return apr_md5(digest, input, inputLen);
01009 }

switch_status_t switch_md5_string ( char  digest_str[SWITCH_MD5_DIGEST_STRING_SIZE],
const void *  input,
switch_size_t  inputLen 
)

Definition at line 1011 of file switch_apr.c.

References SWITCH_MD5_DIGESTSIZE, and switch_snprintf().

01012 {
01013         unsigned char digest[SWITCH_MD5_DIGESTSIZE];
01014         apr_status_t status = apr_md5(digest, input, inputLen);
01015         int x;
01016 
01017         digest_str[SWITCH_MD5_DIGEST_STRING_SIZE - 1] = '\0';
01018 
01019         for (x = 0; x < SWITCH_MD5_DIGESTSIZE; x++) {
01020                 switch_snprintf(digest_str + (x * 2), 3, "%02x", digest[x]);
01021         }
01022 
01023         return status;
01024 }

void switch_uuid_format ( char *  buffer,
const switch_uuid_t uuid 
)

Format a UUID into a string, following the standard format

Parameters:
buffer The buffer to place the formatted UUID string into. It must be at least APR_UUID_FORMATTED_LENGTH + 1 bytes long to hold the formatted UUID and a null terminator
uuid The UUID to format

Definition at line 974 of file switch_apr.c.

References buf.

Referenced by switch_core_init(), switch_core_perform_file_open(), switch_core_session_request_uuid(), switch_ivr_insert_file(), and switch_uuid_str().

00975 {
00976 #ifndef WIN32
00977         apr_uuid_format(buffer, (const apr_uuid_t *) uuid);
00978 #else
00979         RPC_CSTR buf;
00980         UuidToString((const UUID *) uuid, &buf);
00981         strcpy(buffer, (const char *) buf);
00982         RpcStringFree(&buf);
00983 #endif
00984 }

void switch_uuid_get ( switch_uuid_t uuid  ) 

Generate and return a (new) UUID

Parameters:
uuid The resulting UUID

Definition at line 986 of file switch_apr.c.

References runtime, switch_mutex_lock(), switch_mutex_unlock(), and switch_runtime::uuid_mutex.

Referenced by switch_core_init(), switch_core_perform_file_open(), switch_core_session_request_uuid(), switch_ivr_insert_file(), and switch_uuid_str().

00987 {
00988         switch_mutex_lock(runtime.uuid_mutex);
00989 #ifndef WIN32
00990         apr_uuid_get((apr_uuid_t *) uuid);
00991 #else
00992         UuidCreate((UUID *) uuid);
00993 #endif
00994         switch_mutex_unlock(runtime.uuid_mutex);
00995 }

switch_status_t switch_uuid_parse ( switch_uuid_t uuid,
const char *  uuid_str 
)

Parse a standard-format string into a UUID

Parameters:
uuid The resulting UUID
uuid_str The formatted UUID

Definition at line 997 of file switch_apr.c.

00998 {
00999 #ifndef WIN32
01000         return apr_uuid_parse((apr_uuid_t *) uuid, uuid_str);
01001 #else
01002         return UuidFromString((RPC_CSTR) uuid_str, (UUID *) uuid);
01003 #endif
01004 }


Generated on Wed May 16 04:00:17 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7