Changeset 5667:7bc121d15d0e in roaraudio


Ignore:
Timestamp:
09/23/12 11:59:39 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added function retruning common namespaces

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/uuid.h

    r5665 r5667  
    5555int roar_uuid2str(char * str, const roar_uuid_t uuid, ssize_t len); 
    5656int roar_str2uuid(roar_uuid_t uuid, const char * str); 
     57 
     58// returns UUIDs for common namespaces. 
     59const roar_uuid_t * roar_uuid_get_ns_real(const char * ns); 
     60#define roar_uuid_get_ns(ns) (*roar_uuid_get_ns_real(ns)) 
     61 
    5762int roar_uuid_gen(roar_uuid_t uuid, enum roar_uuid_type type, const roar_uuid_t ns, const void * argp, ssize_t arglen); 
    5863#define roar_uuid_gen_null(uuid) roar_uuid_gen(uuid, ROAR_UUID_TYPE_NULL, NULL, NULL, -1) 
    5964#define roar_uuid_gen_time(uuid) roar_uuid_gen(uuid, ROAR_UUID_TYPE_TIME, NULL, NULL, -1) 
    6065#define roar_uuid_gen_random(uuid) roar_uuid_gen(uuid, ROAR_UUID_TYPE_RANDOM, NULL, NULL, -1) 
     66#define roar_uuid_gen_fromstr(uuid,str,ns) roar_uuid_gen(uuid, ROAR_UUID_TYPE_SHA1, roar_uuid_get_ns(ns), str, roar_mm_strlen(str)) 
    6167#define roar_uuid_clear(uuid) roar_uuid_gen_null(uuid) 
    6268 
  • libroar/uuid.c

    r5666 r5667  
    8585} 
    8686 
     87const roar_uuid_t * roar_uuid_get_ns_real(const char * ns) { 
     88 static const roar_uuid_t * __null = NULL, 
     89  dns  = {0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}, 
     90  url  = {0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}, 
     91  oid  = {0x6b, 0xa7, 0xb8, 0x12, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}, 
     92  x500 = {0x6b, 0xa7, 0xb8, 0x14, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}; 
     93 
     94 if ( ns == NULL ) { 
     95  roar_err_set(ROAR_ERROR_FAULT); 
     96  return __null; 
     97 } 
     98 
     99 if ( !strcasecmp(ns, "dns") ) { 
     100  return &dns; 
     101 } else if ( !strcasecmp(ns, "url") ) { 
     102  return &url; 
     103 } else if ( !strcasecmp(ns, "iso oid") || !strcasecmp(ns, "oid") ) { 
     104  return &oid; 
     105 } else if ( !strcasecmp(ns, "X.500 DN") || !strcasecmp(ns, "X500 DN") || !strcasecmp(ns, "x500") ) { 
     106  return &x500; 
     107 } 
     108 
     109 roar_err_set(ROAR_ERROR_NOENT); 
     110 return __null; 
     111} 
     112 
    87113int roar_uuid_gen(roar_uuid_t uuid, enum roar_uuid_type type, const roar_uuid_t ns, const void * argp, ssize_t arglen) { 
    88114 unsigned char digest[20]; 
Note: See TracChangeset for help on using the changeset viewer.