FreeSWITCH API Documentation  1.7.0
Data Structures | Macros | Functions
+ Collaboration diagram for UUID Handling:

Data Structures

struct  switch_uuid_t
 

Macros

#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)
 

Detailed Description

Macro Definition Documentation

#define SWITCH_MD5_DIGEST_STRING_SIZE   33

Definition at line 548 of file switch_apr.h.

#define SWITCH_MD5_DIGESTSIZE   16

Definition at line 547 of file switch_apr.h.

Referenced by switch_md5_string().

#define SWITCH_UUID_FORMATTED_LENGTH   256

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
digestThe final MD5 digest
inputThe message block to use
inputLenThe length of the message block

Definition at line 1087 of file switch_apr.c.

1088 {
1089  return apr_md5(digest, input, inputLen);
1090 }
switch_status_t switch_md5_string ( char  digest_str[SWITCH_MD5_DIGEST_STRING_SIZE],
const void *  input,
switch_size_t  inputLen 
)

Definition at line 1092 of file switch_apr.c.

References SWITCH_MD5_DIGESTSIZE, and switch_snprintf().

1093 {
1094  unsigned char digest[SWITCH_MD5_DIGESTSIZE];
1095  apr_status_t status = apr_md5(digest, input, inputLen);
1096  int x;
1097 
1098  digest_str[SWITCH_MD5_DIGEST_STRING_SIZE - 1] = '\0';
1099 
1100  for (x = 0; x < SWITCH_MD5_DIGESTSIZE; x++) {
1101  switch_snprintf(digest_str + (x * 2), 3, "%02x", digest[x]);
1102  }
1103 
1104  return status;
1105 }
#define SWITCH_MD5_DIGEST_STRING_SIZE
Definition: switch_apr.h:548
int switch_snprintf(char *buf, switch_size_t len, const char *format,...)
Definition: switch_apr.c:184
#define SWITCH_MD5_DIGESTSIZE
Definition: switch_apr.h:547
void switch_uuid_format ( char *  buffer,
const switch_uuid_t uuid 
)

Format a UUID into a string, following the standard format

Parameters
bufferThe 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
uuidThe UUID to format

Definition at line 1055 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().

1056 {
1057 #ifndef WIN32
1058  apr_uuid_format(buffer, (const apr_uuid_t *) uuid);
1059 #else
1060  RPC_CSTR buf;
1061  UuidToString((const UUID *) uuid, &buf);
1062  strcpy(buffer, (const char *) buf);
1063  RpcStringFree(&buf);
1064 #endif
1065 }
switch_byte_t switch_byte_t * buf
void switch_uuid_get ( switch_uuid_t uuid)

Generate and return a (new) UUID

Parameters
uuidThe resulting UUID

Definition at line 1067 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().

1068 {
1070 #ifndef WIN32
1071  apr_uuid_get((apr_uuid_t *) uuid);
1072 #else
1073  UuidCreate((UUID *) uuid);
1074 #endif
1076 }
struct switch_runtime runtime
Definition: switch_core.c:64
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * uuid_mutex
switch_status_t switch_uuid_parse ( switch_uuid_t uuid,
const char *  uuid_str 
)

Parse a standard-format string into a UUID

Parameters
uuidThe resulting UUID
uuid_strThe formatted UUID

Definition at line 1078 of file switch_apr.c.

1079 {
1080 #ifndef WIN32
1081  return apr_uuid_parse((apr_uuid_t *) uuid, uuid_str);
1082 #else
1083  return UuidFromString((RPC_CSTR) uuid_str, (UUID *) uuid);
1084 #endif
1085 }