您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ uuid_generate函数代码示例

51自学网 2021-06-03 09:26:20
  C++
这篇教程C++ uuid_generate函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中uuid_generate函数的典型用法代码示例。如果您正苦于以下问题:C++ uuid_generate函数的具体用法?C++ uuid_generate怎么用?C++ uuid_generate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了uuid_generate函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: init

  void init(size_t arg, size_t padding)  {    _lengths.resize(arg);    _keys.resize(arg);    for (size_t x= 0; x < _keys.size(); x++)    {      libtest::vchar_t key_buffer;      key_buffer.resize(padding +1);      memset(&key_buffer[0], 'x', padding);#if defined(HAVE_UUID_UUID_H) && HAVE_UUID_UUID_H      if (HAVE_UUID_UUID_H)      {        uuid_t out;        uuid_generate(out);        uuid_unparse(out, &key_buffer[0]);        _keys[x]= strdup(&key_buffer[0]);        (_keys[x])[UUID_STRING_MAXLENGTH]= 'x';      }      else // We just use a number and pad the string if UUID is not available#endif      {        char int_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];        int key_length= snprintf(int_buffer, sizeof(int_buffer), "%u", uint32_t(x));        memcpy(&key_buffer[0], int_buffer, key_length);        _keys[x]= strdup(&key_buffer[0]);      }      _lengths[x]= padding;    }  }
开发者ID:Baoxiyi-Github,项目名称:Libmemcached,代码行数:32,


示例2: pn_i_genuuid

char* pn_i_genuuid(void) {    char *generated = (char *) malloc(37*sizeof(char));    uuid_t uuid;    uuid_generate(uuid);    uuid_unparse(uuid, generated);    return generated;}
开发者ID:jimmypc92,项目名称:AndroidProtonBuild,代码行数:7,


示例3: uuid_generate

void FFEADContext::addBean(Bean& bean){	StringUtil::trim(bean.name);	if(bean.name=="") {#ifdef HAVE_LIBUUID		uuid_t idt;		uuid_generate(idt);		std::string ids;		for(int i=0;i<16;i++){			ids.push_back(idt[i]);		}		bean.name = ids;#elif HAVE_BSDUUIDINC		uuid_t idt;		uint32_t status;		uuid_create(&idt, &status);		std::string ids((const char *) &idt, sizeof(idt));		bean.name = ids;#else		bean.name = CastUtil::lexical_cast<std::string>(Timer::getCurrentTime());#endif	}	if(bean.name!="" && beans.find(bean.appName+bean.name)==beans.end())		beans[bean.appName+bean.name] = bean;}
开发者ID:sumeetchhetri,项目名称:ffead-cpp,代码行数:26,


示例4: init_new_client

client_t * init_new_client(agent_t *agent, uuid_t * uuid) {	client_t *new_client; 		new_client = calloc(sizeof(client_t),1);    if(new_client == NULL)    {       printf("Malloc failed!/n");       exit(1);    }    new_client->buffered_packet_table = NULL;    new_client->allowed_connections = 0; 	new_client->agent_sock = calloc(sizeof(int) , agent->options.num_parallel_connections); 	new_client->agent_side_event_info = calloc(sizeof(struct event_info_struct) ,agent->options.num_parallel_connections);    new_client->send_seq = 0;    new_client->recv_seq = 0;    new_client->agent_fd_poll = calloc(sizeof(char) , agent->options.num_parallel_connections);    new_client->num_parallel_connections = 0;    new_client->client_hash.client =  new_client;    gettimeofday(&new_client->client_hash.accept_start, NULL);   if(uuid == NULL)   {      uuid_generate(new_client->client_hash.id);     }    else    {      memcpy(new_client->client_hash.id, *uuid, sizeof(uuid_t));    }       HASH_ADD_INT(agent->clients_hashes, id, (&new_client->client_hash)); 	return new_client; }
开发者ID:aaronorosen,项目名称:sos-agent,代码行数:35,


示例5: jalls_create_record

int jalls_create_record(enum jaldb_rec_type rec_type, struct jalls_thread_context *thread_ctx, struct jaldb_record **prec){	if (!thread_ctx || !thread_ctx->ctx || !prec || *prec) {		return -1;	}	char *timestamp = jaldb_gen_timestamp();	if (!timestamp) {		return -1;	}	struct jaldb_record *rec = jaldb_create_record();	rec->type = rec_type;	rec->pid = thread_ctx->peer_pid;	rec->have_uid = 1;	rec->uid = thread_ctx->peer_uid;	rec->hostname = jal_strdup(thread_ctx->ctx->hostname);	rec->timestamp = timestamp;	rec->username = jalls_get_user_id_str(thread_ctx->peer_uid);	rec->sec_lbl = jalls_get_security_label(thread_ctx->fd);	uuid_copy(rec->host_uuid, thread_ctx->ctx->system_uuid);	uuid_generate(rec->uuid);	if (rec->username == NULL) {		return -1;		}	*prec = rec;	return 0;}
开发者ID:jalop-tresys,项目名称:JALoP,代码行数:30,


示例6: psivshmem_init_device_handle

staticvoid psivshmem_init_device_handle(ivshmem_pci_dev_t *dev){/* * This function initiates all required parameters to handle the shared memory access. * The first byte of the shared memory is used as a simple mutex to let the verry first * process initialize a pthread spinlock which is inter-vm thread safe. */    dev->first_byte = (volatile unsigned char*) dev->ivshmem_base;    dev->spinlock = (volatile pthread_spinlock_t*)(dev->ivshmem_base + sizeof(char));    dev->uuid = (volatile uuid_t*)(dev->ivshmem_base + sizeof(char) + sizeof(pthread_spinlock_t));    dev->bitmap = dev->ivshmem_base + sizeof(char) + sizeof(pthread_spinlock_t) + sizeof(uuid_t);    dev->frame_size = IVSHMEM_FRAME_SIZE;    dev->num_of_frames = dev->mem_size_byte / IVSHMEM_FRAME_SIZE;    dev->bitmap_length = dev->num_of_frames / (sizeof(char)*CHAR_BIT);    dev->meta_data_size = (dev->bitmap - dev->ivshmem_base) + dev->bitmap_length * sizeof (char);    unsigned long long n;    // Assumption: unused device contains only zeros    if (uuid_is_null(*((uuid_t*)dev->uuid)) && psivshmem_atomic_TestAndSet(dev->first_byte)){    	pthread_spin_init(dev->spinlock, PTHREAD_PROCESS_SHARED);        uuid_generate(*((uuid_t*)dev->uuid));	for(n =0; n< dev->bitmap_length; n++) SET_BIT(dev->bitmap,n); //mark all used frames in bitmap	*(dev->first_byte) = IVSHMEM_DEVICE_MAGIC; //indicate PCI device to be used by ivshmem plugin    } else {    /* active waiting until other process has initialized the shared meta data     * otherwise a device collision will be detected psivshmem_init_uio_device()     */    psivshmem_init_wait(dev);    }    uuid_unparse_lower(*(uuid_t*)dev->uuid, dev->uuid_str);    DPRINT(3,"ivshmem: my uuid: %s",dev->uuid_str);}
开发者ID:RWTH-OS,项目名称:pscom,代码行数:33,


示例7: createGUID

char* createGUID(char* uid){	#ifdef WIN32	char buffer[GUID_LEN] = { 0 };    GUID guid;    if(CoCreateGuid(&guid))    {    	//printf(stderr, "create guid error/n");    	return NULL;    }    _snprintf(buffer, sizeof(buffer),    "%08X%04X%04x%02X%02X%02X%02X%02X%02X%02X%02X",    guid.Data1, guid.Data2, guid.Data3,    guid.Data4[0], guid.Data4[1], guid.Data4[2],    guid.Data4[3], guid.Data4[4], guid.Data4[5],    guid.Data4[6], guid.Data4[7]);#endif#ifndef CLIENTMAKE	if(uid == NULL) return NULL;	bzero(uid,32);	uuid_t uu;    uuid_generate(uu);    //printf("{");	int i = 0;    for(i=0;i<15;i++)        sprintf(uid,"%s%02X",uid,uu[i]);	return uid;	//TODO    //printf("%02X}/n",uu[15]);#endif	}
开发者ID:zt9788,项目名称:push-server,代码行数:32,


示例8: generateUUID

/** * Shallow wrapper around uuid, that comes up with some random pseudo * uuid if uuid is not available */char *generateUUID(void){#ifdef HAVE_UUID# ifdef UUID_PRINTABLE_STRING_LENGTH	/* Solaris */	char out[UUID_PRINTABLE_STRING_LENGTH];# else	char out[37];# endif	uuid_t uuid;	uuid_generate(uuid);	uuid_unparse(uuid, out);#else	/* try to do some pseudo interesting stuff, and stash it in the	 * format of an UUID to at least return some uniform answer */	char out[37];	char *p = out;	/* generate something like this:	 * cefa7a9c-1dd2-11b2-8350-880020adbeef ("%08x-%04x-%04x-%04x-%012x") */	p += snprintf(p, 5, "%04x", rand() % 65536);	p += snprintf(p, 6, "%04x-", rand() % 65536);	p += snprintf(p, 6, "%04x-", rand() % 65536);	p += snprintf(p, 6, "%04x-", rand() % 65536);	p += snprintf(p, 6, "%04x-", rand() % 65536);	p += snprintf(p, 5, "%04x", rand() % 65536);	p += snprintf(p, 5, "%04x", rand() % 65536);	p += snprintf(p, 5, "%04x", rand() % 65536);#endif	return(strdup(out));}
开发者ID:Clay-Birkett,项目名称:monetdb,代码行数:36,


示例9: gen_uuid_inplace

void gen_uuid_inplace (char *buf){    uuid_t uuid;    uuid_generate (uuid);    uuid_unparse_lower (uuid, buf);}
开发者ID:andrey-str,项目名称:ccnet,代码行数:7,


示例10: debug

REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when) {    debug(D_REGISTRY, "Registry: registry_person_allocate('%s'): allocating new person, sizeof(PERSON)=%zu", (person_guid)?person_guid:"", sizeof(REGISTRY_PERSON));    REGISTRY_PERSON *p = mallocz(sizeof(REGISTRY_PERSON));    if(!person_guid) {        for(;;) {            uuid_t uuid;            uuid_generate(uuid);            uuid_unparse_lower(uuid, p->guid);            debug(D_REGISTRY, "Registry: Checking if the generated person guid '%s' is unique", p->guid);            if (!dictionary_get(registry.persons, p->guid)) {                debug(D_REGISTRY, "Registry: generated person guid '%s' is unique", p->guid);                break;            }            else                info("Registry: generated person guid '%s' found in the registry. Retrying...", p->guid);        }    }    else        strncpyz(p->guid, person_guid, GUID_LEN);    debug(D_REGISTRY, "Registry: registry_person_allocate('%s'): creating dictionary of urls", p->guid);    avl_init(&p->person_urls, person_url_compare);    p->first_t = p->last_t = (uint32_t)when;    p->usages = 0;    registry.persons_memory += sizeof(REGISTRY_PERSON);    registry.persons_count++;    dictionary_set(registry.persons, p->guid, p, sizeof(REGISTRY_PERSON));    return p;}
开发者ID:darrentangdt,项目名称:netdata,代码行数:35,


示例11: main

int main(int argc, char **argv){    Octstr *os;    char id[UUID_STR_LEN + 1];    uuid_t uid;    gwlib_init();    debug("uuid",0,"Creating UUID");    uuid_generate(uid);    debug("uuid",0,"Parse into char");    uuid_unparse(uid, id);    debug("uuid",0,"Create Octstr");    os = octstr_create(id);    debug("uuid",0,"UUID is: %s", octstr_get_cstr(os));    debug("uuid",0,"Removing dashes");    octstr_replace(os, octstr_imm("-"), octstr_imm(""));    debug("uuid",0,"UUID is: %s", octstr_get_cstr(os));    octstr_destroy(os);    uuid_clear(uid);    gwlib_shutdown();    return 0;}
开发者ID:LeeVidor,项目名称:kannel-mongodb,代码行数:25,


示例12: LADSGetGUID

DWORDLADSGetGUID(    PSTR* ppszGUID    ){    DWORD dwError = 0;    PSTR  pszGUID = NULL;    uuid_t uuid = {0};    CHAR  szUUID[37] = "";    uuid_generate(uuid);    uuid_unparse(uuid, szUUID);    dwError = LwAllocateString(                       szUUID,                       &pszGUID);    BAIL_ON_LSA_ERROR(dwError);    *ppszGUID = pszGUID;cleanup:    return dwError;error:    *ppszGUID = NULL;    LW_SAFE_FREE_STRING(pszGUID);    goto cleanup;}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:33,


示例13: GenRandUUID

	//	// UUID	std::string	GenRandUUID(void)	{		unsigned char uuid[16];		char retstr[64] = { 0 };#if defined _PLATFORM_WINDOWS_		GUID guid;		::CoCreateGuid(&guid);		memcpy(uuid, &guid, sizeof(uuid));		_snprintf_s(retstr, sizeof(retstr) - 1			, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"			, uuid[0], uuid[1], uuid[2], uuid[3]			, uuid[4], uuid[5], uuid[6], uuid[7]			, uuid[8], uuid[9], uuid[10], uuid[11]			, uuid[12], uuid[13], uuid[14], uuid[15]			);#elif defined _PLATFORM_LINUX_		uuid_t guid;		uuid_generate(guid);		memcpy(uuid, &guid, sizeof(uuid));		snprintf(retstr, sizeof(retstr)-1			, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"			, uuid[0], uuid[1], uuid[2], uuid[3]			, uuid[4], uuid[5], uuid[6], uuid[7]			, uuid[8], uuid[9], uuid[10], uuid[11]			, uuid[12], uuid[13], uuid[14], uuid[15]			);#endif		return retstr;	}
开发者ID:mybestcool,项目名称:xhnet,代码行数:34,


示例14: MakeUUID

int MakeUUID(char *location){    uuid_t uuid;    uuid_generate(uuid);    memcpy((void *)location, (void *)&uuid, sizeof(uuid));    return 1;}
开发者ID:philippeback,项目名称:Pyonkee,代码行数:7,


示例15: Object_init

static voidObject_init(sim_class_t *cls, void *obj, void *arg){  sim_object_t *sobj = obj;  uuid_generate(sobj->uuid);  avl_insert(objects, sobj->uuid, sobj);}
开发者ID:nforrester,项目名称:openorbit,代码行数:7,


示例16: uuid_init

static int uuid_init(const char *file){	char uuid[37];	uuid_t uu;	FILE *f = NULL;	int err = 0;	f = fopen(file, "r");	if (f) {		err = 0;		goto out;	}	f = fopen(file, "w");	if (!f) {		err = errno;		DEBUG_WARNING("init: fopen() %s (%m)/n", file, err);		goto out;	}	uuid_generate(uu);	uuid_unparse(uu, uuid);	re_fprintf(f, "%s", uuid);	DEBUG_NOTICE("init: generated new UUID (%s)/n", uuid); out:	if (f)		fclose(f);	return err;}
开发者ID:FihlaTV,项目名称:BareSip-Android,代码行数:34,


示例17: noit_poller_schedule

intnoit_poller_schedule(const char *target,                     const char *module,                     const char *name,                     const char *filterset,                     noit_hash_table *config,                     u_int32_t period,                     u_int32_t timeout,                     const char *oncheck,                     int flags,                     uuid_t in,                     uuid_t out) {  noit_check_t *new_check;  new_check = calloc(1, sizeof(*new_check));  if(!new_check) return -1;  /* The module and the UUID can never be changed */  new_check->module = strdup(module);  if(uuid_is_null(in))    uuid_generate(new_check->checkid);  else    uuid_copy(new_check->checkid, in);  noit_check_update(new_check, target, name, filterset, config,                    period, timeout, oncheck, flags);  assert(noit_hash_store(&polls,                         (char *)new_check->checkid, UUID_SIZE,                         new_check));  uuid_copy(out, new_check->checkid);  return 0;}
开发者ID:easel,项目名称:reconnoiter,代码行数:32,


示例18: uuid_generate

zmq::uuid_t::uuid_t (){    uuid_generate (uuid);    uuid_unparse (uuid, string_buf);    create_blob ();}
开发者ID:jeffdik,项目名称:zeromq2,代码行数:7,


示例19: xbox_assert

Boolean XLinuxUUID::Generate (VUUIDBuffer* outUUID){	xbox_assert(sizeof(outUUID->fBytes)==sizeof(uuid_t));	//doesn't fail.	uuid_generate(outUUID->fBytes);	return true;}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:7,


示例20: uuid_generate

string BeatBoard::SessionManager::createSessionId() {    uuid_t uuid;    char buff[1024];    uuid_generate(uuid);    uuid_unparse_upper(uuid, buff);    return string(buff);}
开发者ID:yushi,项目名称:beatboard,代码行数:7,


示例21: sg_uuid_gen

struct sg_uuid_str sg_uuid_gen(enum sg_uuid_method method, int uppercase){    uuid_t uu;    struct sg_uuid_str us;    assert(method >= SGUUIDMETHOD_DEFAULT && method <= SGUUIDMETHOD_TIME_MAC);    memset(&us, 0, sizeof(struct sg_uuid_str));    switch (method) {    case SGUUIDMETHOD_DEFAULT:        uuid_generate(uu);        break;    case SGUUIDMETHOD_RANDOM:        uuid_generate_random(uu);        break;    case SGUUIDMETHOD_TIME_MAC:        uuid_generate_time(uu);        break;    case SGUUIDMETHOD_TIME_MAC_SAFE:        uuid_generate_time_safe(uu);        break;    default:        sg_log_err("UUID method error.");        return us;    }    if (uppercase == 0)        uuid_unparse_lower(uu, us.buf);    else        uuid_unparse_upper(uu, us.buf);    return us;}
开发者ID:IvwsIgeMq,项目名称:libsg,代码行数:34,


示例22: cont_create

static intcont_create(test_arg_t *arg, uuid_t uuid){	uuid_generate(uuid);	print_message("creating container "DF_UUIDF"/n", DP_UUID(uuid));	return daos_cont_create(arg->pool.poh, uuid, NULL, NULL);}
开发者ID:daos-stack,项目名称:daos,代码行数:7,


示例23: smd_ut_add_and_fetch_ptab

static voidsmd_ut_add_and_fetch_ptab(void **state){	int				rc;	uuid_t				pool_uuid;	int				stream;	uint64_t			blob_id = 32;	struct smd_nvme_pool_info	info;	uuid_generate(pool_uuid);	stream = 4;	smd_nvme_set_pool_info(pool_uuid, stream, blob_id, &info);	rc = smd_nvme_add_pool(&info);	assert_int_equal(rc, 0);	memset(&info, '0', sizeof(info));	rc = smd_nvme_get_pool(pool_uuid, stream, &info);	if (rc) {		print_error("NVME get pool failed :%d/n", rc);		assert_int_equal(rc, 0);	}	rc = uuid_compare(pool_uuid, info.npi_pool_uuid);	assert_int_equal(rc, 0);	assert_true(info.npi_stream_id == stream);	assert_true(info.npi_blob_id == blob_id);}
开发者ID:daos-stack,项目名称:daos,代码行数:28,


示例24: sll_count

// Create a new session// FIXME - This is currently open to a DoS attack.//         but since we have a session limit, just for opendias.char *create_session() {  char *session_id;  // Check upper session count limit  int current_session_count = sll_count( sll_findFirstElement( sessions ) );  o_log( DEBUGM, "There are currently %d active sessions", current_session_count);  if( current_session_count > MAX_SESSIONS ) {    return NULL;  }  // Generate session key  uuid_t uu;  char *sid = malloc(36+1);  uuid_generate(uu);  uuid_unparse(uu, sid);  session_id = o_strdup(sid);  free(sid);  o_log(DEBUGM, "Generated new session: %s", session_id );  // Create new session structure  struct session_data *session_element = malloc( sizeof(struct session_data) );  session_element->last_accessed = time(NULL);  session_element->session_container = sll_init();  // Save and return  sll_insert( sessions, o_strdup(session_id), session_element );  return session_id;}
开发者ID:Rventric,项目名称:opendias,代码行数:31,


示例25: init_device

static intinit_device(struct sbd_context *st){	struct sector_header_s	*s_header;	struct sector_node_s	*s_node;	struct sector_mbox_s	*s_mbox;	struct stat 		s;	char			uuid[37];	int			i;	int			rc = 0;	s_header = sector_alloc();	s_node = sector_alloc();	s_mbox = sector_alloc();	memcpy(s_header->magic, sbd_magic, sizeof(s_header->magic));	s_header->version = sbd_version;	s_header->slots = 255;	s_header->sector_size = sector_size;	s_header->timeout_watchdog = timeout_watchdog;	s_header->timeout_allocate = timeout_allocate;	s_header->timeout_loop = timeout_loop;	s_header->timeout_msgwait = timeout_msgwait;	s_header->minor_version = 1;	uuid_generate(s_header->uuid);	uuid_unparse_lower(s_header->uuid, uuid);	fstat(st->devfd, &s);	/* printf("st_size = %ld, st_blksize = %ld, st_blocks = %ld/n",			s.st_size, s.st_blksize, s.st_blocks); */	cl_log(LOG_INFO, "Creating version %d.%d header on device %d (uuid: %s)",			s_header->version, s_header->minor_version,			st->devfd, uuid);	fprintf(stdout, "Creating version %d.%d header on device %d (uuid: %s)/n",			s_header->version, s_header->minor_version,			st->devfd, uuid);	if (header_write(st, s_header) < 0) {		rc = -1; goto out;	}	cl_log(LOG_INFO, "Initializing %d slots on device %d",			s_header->slots,			st->devfd);	fprintf(stdout, "Initializing %d slots on device %d/n",			s_header->slots,			st->devfd);	for (i=0;i < s_header->slots;i++) {		if (slot_write(st, i, s_node) < 0) {			rc = -1; goto out;		}		if (mbox_write(st, i, s_mbox) < 0) {			rc = -1; goto out;		}	}out:	free(s_node);	free(s_header);	free(s_mbox);	return(rc);}
开发者ID:credativ,项目名称:sbd,代码行数:60,


示例26: main

int main(int argc, char *argv[]) {  FILE *secret, *pub, *out;  int len = 0;  uuid_t uuid;  if( argc != 4 ) {    printf( "Usage: catkeys <secret key file> <pubkey file> <outputfile>/n" );  }  secret = fopen(argv[1], "rb");  if( secret == NULL ) {    printf( "Can't open secret key file %s, failing./n", argv[1] );    exit(0);  }  pub = fopen( argv[2], "r" );  if( pub == NULL ) {    printf( "Can't open public key file %s, failing./n", argv[2] );    exit(0);  }  out = fopen( argv[3], "wb" );  if( out == NULL ) {    printf( "Can't open binary output file %s, failing./n", argv[3] );    exit(0);  }  len = 0;  while( !feof(secret) ){    len ++;    fputc(fgetc(secret), out);  }  if( len >= SECLEN ) {    printf( "Warning! Secret key input larger than 2k./n" );  }  while( len < SECLEN ) {    len++;    fputc(0, out); // pad 0's to 2k length  }    while( !feof(pub) ) {    len++;    fputc(fgetc(pub), out);  }  if( len >= (SECLEN + PUBLEN)) {    printf( "Warning! public key length too long./n" );  }  while( len < (SECLEN + PUBLEN) ) {    len++;    fputc(0, out); // pad 0's to almost 4k length  }    uuid_generate(uuid);  fwrite( uuid, sizeof(uuid), 1, out );    print_uuid(&uuid);  fclose(out);  fclose(secret);  fclose(pub);}
开发者ID:LucidOne,项目名称:onyxfirmware,代码行数:59,


示例27: ngx_x_rid_header_get_variable

ngx_int_t ngx_x_rid_header_get_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) {  u_char            *p         = NULL;  ngx_table_elt_t   *header;  ngx_str_t          hv;  size_t             hlen      = 22;  header = search_headers_in(r, ngx_x_rid_header_name.data, ngx_x_rid_header_name.len);  if (header != NULL) {      hv = header->value;      if (hv.len >= 20 && hv.len <= 50) {          // Reuse existing header          hlen = hv.len;          p = hv.data;      }  }  if (p == NULL) {      // Prepare 22 bytes to store the base58 string      p = ngx_pnalloc(r->pool, 22);      if (p == NULL) {          return NGX_ERROR;      }#if (NGX_FREEBSD)#error FreeBSD is not supported yet, sorry.#elif (NGX_LINUX)      uuid_t* uuid;      // return of uuid_s_ok = 0      if ( uuid_create(&uuid) ) {        return -1;      }      if ( uuid_make(uuid, UUID_MAKE_V4) ) {        uuid_destroy(uuid);        return -1;      }      // at this point we have 16 bytes in "uuid", ready for conversion      uuid_fmt22(uuid, p);      uuid_destroy(uuid);#elif (NGX_SOLARIS)#error Solaris is not supported yet, sorry.#elif (NGX_DARWIN)      uuid_t uuid;      uuid_generate(uuid);      uuid_fmt22(uuid, p);#endif  }  v->len = hlen;  v->valid = 1;  v->no_cacheable = 0;  v->not_found = 0;  v->data = p;  return NGX_OK;}
开发者ID:ebp,项目名称:nginx-x-rid-header,代码行数:59,


示例28: on_connect

void on_connect(EV_P_ struct ev_io *io, int revents) {    while (1) {        struct sockaddr_in client_addr;        socklen_t len = sizeof (struct sockaddr_in);        int client_sock = accept(io->fd, (struct sockaddr *) &client_addr, &len);        if (client_sock >= 0) {            if (set_nonblock(client_sock) == -1) {                shutdown_printerr(client_sock, "can't set the socket mode O_NONBLOCK for client/n");                return;            }            if (set_linger(client_sock) == -1) {                shutdown_printerr(client_sock, "can't set SO_LINGER sock option for client/n");                return;            }            if (set_keepalive(client_sock) == -1) {                shutdown_printerr(client_sock, "can't set SO_KEEPALIVE sock option for client/n");                return;            }            server_ctx_t *srv_ctx = (server_ctx_t *) ev_userdata(loop);            client_ctx_t* cli_ctx = get_client_ctx(srv_ctx);            cli_ctx->io.ctx = cli_ctx;            cli_ctx->connected_at = time(NULL);            uuid_generate(cli_ctx->uuid);            memcpy(&cli_ctx->client_addr, &client_addr, sizeof (struct sockaddr_in));            ev_io_init((ev_io *) & cli_ctx->io, client_read_write, client_sock, EV_READ);            ev_io_start(loop, (ev_io *) & cli_ctx->io);            char time_buff[32];            strftime(time_buff, sizeof (time_buff), "%Y-%m-%d %H:%M:%S %Z", localtime(&cli_ctx->connected_at));            char *addr = inet_ntoa(cli_ctx->client_addr.sin_addr);            char uuid_buff[37];            uuid_unparse_lower(cli_ctx->uuid, (char *) &uuid_buff);            printf("client accepted %s:%hu %s at %s/n", addr, client_addr.sin_port, &uuid_buff, &time_buff);            char *welcome_msg = server_welcome(srv_ctx, cli_ctx);            send_message(loop, cli_ctx->uuid, welcome_msg, strlen(welcome_msg));            free(welcome_msg);            char *new_client_msg = server_client_connected(cli_ctx);            for (ssize_t i = 0; i < srv_ctx->clients_count; i++) {                if (uuid_compare(srv_ctx->clients[i]->uuid, cli_ctx->uuid) != 0) {                    send_message(loop, srv_ctx->clients[i]->uuid, new_client_msg, strlen(new_client_msg));                }            }            free(new_client_msg);        } else {            if (errno == EAGAIN)                return;            if (errno == EMFILE || errno == ENFILE) {                fprintf(stderr, "out of file descriptors/n");                return;            } else if (errno != EINTR) {                fprintf(stderr, "accept connections error/n");                return;            }        }    }}
开发者ID:mpsnp,项目名称:mchat-server,代码行数:59,


示例29: uuidgen

intuuidgen(struct uuid *store, int count){	while (--count > 0)		uuid_generate(store++);	return 0;}
开发者ID:ryo,项目名称:netbsd-src,代码行数:8,


示例30: uuidget

/**获取随机数UUID*author  mleaf_hexi*mail:[email
C++ uuid_is_null函数代码示例
C++ uuid_create函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。