当前位置: 首页>>代码示例>>C++>>正文


C++ pack32函数代码示例

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


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

示例1: job_options_pack

/*
 *  Pack all accumulated options into Buffer "buf"
 */
int job_options_pack (job_options_t opts, Buf buf)
{
	uint32_t count = 0;
	ListIterator i;
	struct job_option_info *opt;

	packstr (JOB_OPTIONS_PACK_TAG, buf);

	if (opts == NULL) {
		pack32  (0, buf);
		return (0);
	}

	xassert (opts->magic == JOB_OPTIONS_MAGIC);
	xassert (opts->options != NULL);
	xassert (opts->iterator != NULL);

	count = list_count (opts->options);
	pack32  (count, buf);

	i = list_iterator_create (opts->options);

	while ((opt = list_next (i)))
		job_option_info_pack (opt, buf);
	list_iterator_destroy (i);

	return (count);
}
开发者ID:A1ve5,项目名称:slurm,代码行数:31,代码来源:job_options.c

示例2: SshAgentSignEd25519

ssh_string SshAgentSignEd25519(uint8_t* data, int dataSize, ssh_key key, uint32_t flags)
{
    // Prepare a buffer for the signature in a blob of the form:
    // blobLength[ typeNameLength[ typeName ] signatureLength[ signature ] ]
    uint32_t typeNameLength = 11;
    unsigned long long signatureLength = dataSize + 64;
    uint32_t blobLength = 8 + typeNameLength + (uint32_t)signatureLength;
    uint8_t* signature = malloc(blobLength + 4);
    if (signature == NULL)
    {
        return NULL;
    }
    
    // Sign the data in place in the blob buffer.
    int signatureIndex = 12 + typeNameLength;
    int result = crypto_sign_ed25519(signature + signatureIndex, &signatureLength, data, dataSize, (uint8_t*)key->ed25519_privkey);
    if (result != 0)
    {
        free(signature);
        return NULL;
    }
    
    // Recalculate the blob length now that we have the final length of the ED25519 signature and format the rest of the blob.
    blobLength = 8 + typeNameLength + (uint32_t)signatureLength;
    pack32(signature, blobLength);
    int index = 4;
    pack32(signature + index, typeNameLength);
    index += 4;
    memcpy(signature + index, "ssh-ed25519", typeNameLength);
    index += typeNameLength;
    pack32(signature + index, (uint32_t)signatureLength);
    
    return (ssh_string)signature;
}
开发者ID:Devolutions,项目名称:SshTerminal,代码行数:34,代码来源:SshAgent.c

示例3: pack_slurm_step_layout

extern void pack_slurm_step_layout(slurm_step_layout_t *step_layout,
				   Buf buffer, uint16_t protocol_version)
{
	uint32_t i = 0;

	if (protocol_version >= SLURM_2_3_PROTOCOL_VERSION) {
		if (step_layout)
			i=1;

		pack16(i, buffer);
		if (!i)
			return;
		packstr(step_layout->front_end, buffer);
		packstr(step_layout->node_list, buffer);
		pack32(step_layout->node_cnt, buffer);
		pack32(step_layout->task_cnt, buffer);
		pack16(step_layout->task_dist, buffer);

		for (i=0; i<step_layout->node_cnt; i++) {
			pack32_array(step_layout->tids[i],
				     step_layout->tasks[i],
				     buffer);
		}
	} else {
		error("pack_slurm_step_layout: protocol_version "
		      "%hu not supported", protocol_version);
	}
}
开发者ID:Thorso,项目名称:slurm,代码行数:28,代码来源:slurm_step_layout.c

示例4: _dump_part_state

/*
 * _dump_part_state - dump the state of a specific partition to a buffer
 * IN part_ptr - pointer to partition for which information
 *	is requested
 * IN/OUT buffer - location to store data, pointers automatically advanced
 */
static void _dump_part_state(struct part_record *part_ptr, Buf buffer)
{
	xassert(part_ptr);
	if (default_part_loc == part_ptr)
		part_ptr->flags |= PART_FLAG_DEFAULT;
	else
		part_ptr->flags &= (~PART_FLAG_DEFAULT);

	packstr(part_ptr->name,          buffer);
	pack32(part_ptr->grace_time,	 buffer);
	pack32(part_ptr->max_time,       buffer);
	pack32(part_ptr->default_time,   buffer);
	pack32(part_ptr->max_nodes_orig, buffer);
	pack32(part_ptr->min_nodes_orig, buffer);

	pack16(part_ptr->flags,          buffer);
	pack16(part_ptr->max_share,      buffer);
	pack16(part_ptr->preempt_mode,   buffer);
	pack16(part_ptr->priority,       buffer);

	pack16(part_ptr->state_up,       buffer);
	packstr(part_ptr->allow_groups,  buffer);
	packstr(part_ptr->allow_alloc_nodes, buffer);
	packstr(part_ptr->alternate,     buffer);
	packstr(part_ptr->nodes,         buffer);
}
开发者ID:lipari,项目名称:slurm,代码行数:32,代码来源:partition_mgr.c

示例5: slurm_ckpt_pack_job

extern int slurm_ckpt_pack_job(check_jobinfo_t jobinfo, Buf buffer,
			       uint16_t protocol_version)
{
	struct check_job_info *check_ptr =
		(struct check_job_info *)jobinfo;

	if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		uint32_t x;
		uint32_t y;
		uint32_t z;
		uint32_t size;

		size = 0;
		pack16(CHECK_POE, buffer);
		x = get_buf_offset(buffer);
		pack32(size, buffer);

		y = get_buf_offset(buffer);

		pack16(check_ptr->disabled, buffer);
		pack16(check_ptr->node_cnt, buffer);
		pack16(check_ptr->reply_cnt, buffer);
		pack16(check_ptr->wait_time, buffer);
		pack32(check_ptr->error_code, buffer);
		packstr(check_ptr->error_msg, buffer);
		pack_time(check_ptr->time_stamp, buffer);

		z = get_buf_offset(buffer);
		set_buf_offset(buffer, x);
		pack32(z - y, buffer);
		set_buf_offset(buffer, z);
	}

	return SLURM_SUCCESS;
}
开发者ID:FredHutch,项目名称:slurm,代码行数:35,代码来源:checkpoint_poe.c

示例6: _pack_coll_ring_info

static int _pack_coll_ring_info(pmixp_coll_t *coll,
				pmixp_coll_ring_msg_hdr_t *ring_hdr,
				Buf buf)
{
	pmixp_proc_t *procs = coll->pset.procs;
	size_t nprocs = coll->pset.nprocs;
	uint32_t type = PMIXP_COLL_TYPE_FENCE_RING;
	int i;

	/* 1. store the type of collective */
	pack32(type, buf);

	/* 2. Put the number of ranges */
	pack32(nprocs, buf);
	for (i = 0; i < (int)nprocs; i++) {
		/* Pack namespace */
		packmem(procs->nspace, strlen(procs->nspace) + 1, buf);
		pack32(procs->rank, buf);
	}

	/* 3. pack the ring header info */
	packmem((char*)ring_hdr, sizeof(pmixp_coll_ring_msg_hdr_t), buf);

	return SLURM_SUCCESS;
}
开发者ID:chrisdukey,项目名称:slurm,代码行数:25,代码来源:pmixp_coll_ring.c

示例7: bb_pack_bufs

/* Pack individual burst buffer records into a buffer */
extern int bb_pack_bufs(uid_t uid, bb_state_t *state_ptr, Buf buffer,
			uint16_t protocol_version)
{
	int i, rec_count = 0;
	struct bb_alloc *bb_alloc;
	int eof, offset;

	xassert(state_ptr);
	offset = get_buf_offset(buffer);
	pack32(rec_count,  buffer);
	if (!state_ptr->bb_ahash)
		return rec_count;

	for (i = 0; i < BB_HASH_SIZE; i++) {
		bb_alloc = state_ptr->bb_ahash[i];
		while (bb_alloc) {
			if ((uid == 0) || (uid == bb_alloc->user_id)) {
				_pack_alloc(bb_alloc, buffer, protocol_version);
				rec_count++;
			}
			bb_alloc = bb_alloc->next;
		}
	}
	if (rec_count != 0) {
		eof = get_buf_offset(buffer);
		set_buf_offset(buffer, offset);
		pack32(rec_count, buffer);
		set_buf_offset(buffer, eof);
	}

	return rec_count;
}
开发者ID:Q-Leap-Networks,项目名称:qlustar-slurm,代码行数:33,代码来源:burst_buffer_common.c

示例8: bb_pack_usage

/* Pack individual burst buffer usage records into a buffer (used for limits) */
extern int bb_pack_usage(uid_t uid, bb_state_t *state_ptr, Buf buffer,
			 uint16_t protocol_version)
{
	int i, rec_count = 0;
	bb_user_t *bb_usage;
	int eof, offset;

	xassert(state_ptr);
	offset = get_buf_offset(buffer);
	pack32(rec_count,  buffer);
	if (!state_ptr->bb_uhash)
		return rec_count;

	for (i = 0; i < BB_HASH_SIZE; i++) {
		bb_usage = state_ptr->bb_uhash[i];
		while (bb_usage) {
			if (((uid == 0) || (uid == bb_usage->user_id)) &&
			    (bb_usage->size != 0)) {
				pack64(bb_usage->size,          buffer);
				pack32(bb_usage->user_id,       buffer);
				rec_count++;
			}
			bb_usage = bb_usage->next;
		}
	}
	if (rec_count != 0) {
		eof = get_buf_offset(buffer);
		set_buf_offset(buffer, offset);
		pack32(rec_count, buffer);
		set_buf_offset(buffer, eof);
	}

	return rec_count;
}
开发者ID:Q-Leap-Networks,项目名称:qlustar-slurm,代码行数:35,代码来源:burst_buffer_common.c

示例9: _pack_front_end

/*
 * _pack_front_end - dump all configuration information about a specific
 *	front_end node in machine independent form (for network transmission)
 * IN dump_front_end_ptr - pointer to front_end node for which information is
 *	requested
 * IN/OUT buffer - buffer where data is placed, pointers automatically updated
 * IN protocol_version - slurm protocol version of client
 * NOTE: if you make any changes here be sure to make the corresponding
 *	changes to load_front_end_config in api/node_info.c
 */
static void _pack_front_end(struct front_end_record *dump_front_end_ptr,
			    Buf buffer, uint16_t protocol_version)
{
	if (protocol_version >= SLURM_2_6_PROTOCOL_VERSION) {
		packstr(dump_front_end_ptr->allow_groups, buffer);
		packstr(dump_front_end_ptr->allow_users, buffer);
		pack_time(dump_front_end_ptr->boot_time, buffer);
		packstr(dump_front_end_ptr->deny_groups, buffer);
		packstr(dump_front_end_ptr->deny_users, buffer);
		packstr(dump_front_end_ptr->name, buffer);
		pack16(dump_front_end_ptr->node_state, buffer);

		packstr(dump_front_end_ptr->reason, buffer);
		pack_time(dump_front_end_ptr->reason_time, buffer);
		pack32(dump_front_end_ptr->reason_uid, buffer);

		pack_time(dump_front_end_ptr->slurmd_start_time, buffer);
	} else if (protocol_version >= SLURM_2_5_PROTOCOL_VERSION) {
		pack_time(dump_front_end_ptr->boot_time, buffer);
		packstr(dump_front_end_ptr->name, buffer);
		pack16(dump_front_end_ptr->node_state, buffer);

		packstr(dump_front_end_ptr->reason, buffer);
		pack_time(dump_front_end_ptr->reason_time, buffer);
		pack32(dump_front_end_ptr->reason_uid, buffer);

		pack_time(dump_front_end_ptr->slurmd_start_time, buffer);
	} else {
		error("_pack_front_end: Unsupported slurm version %u",
		      protocol_version);
	}
}
开发者ID:Cray,项目名称:slurm,代码行数:42,代码来源:front_end.c

示例10: SshAgentSignDss

ssh_string SshAgentSignDss(uint8_t* data, int dataSize, ssh_key key, uint32_t flags)
{
    unsigned char hash[SHA_DIGEST_LEN] = {0};
    SHACTX ctx;
    
    ctx = sha1_init();
    if (ctx == NULL)
    {
        return NULL;
    }
    
    sha1_update(ctx, data, dataSize);
    sha1_final(hash, ctx);   // This release ctx.
    
    DSA_SIG* sig = NULL;
    sig = DSA_do_sign(hash, sizeof(hash), key->dsa);
    if (sig == NULL)
    {
        return NULL;
    }
    
    uint8_t sigblob[40];
    memset(sigblob, 0, 40);
    int rlen = BN_num_bytes(sig->r);
    int slen = BN_num_bytes(sig->s);
    BN_bn2bin(sig->r, sigblob + 20 - rlen);
    BN_bn2bin(sig->s, sigblob + 40 - slen);
    
    if (flags & SSH_AGENT_OLD_SIGNATURE)
    {
        uint8_t* signatureBlob = malloc(sizeof(sigblob));
        if (signatureBlob == NULL)
        {
            return NULL;
        }
        memcpy(signatureBlob, sigblob, 40);
        
        return (ssh_string)signatureBlob;
    }
    
    int signatureTypeLength = 7;
    int signatureLength = 40;
    int signatureBlobLength = 8 + signatureTypeLength + signatureLength;
    
    uint8_t* signatureBlob = malloc(4 + signatureBlobLength);
    if (signatureBlob == NULL)
    {
        return NULL;
    }
    
    pack32(signatureBlob, signatureBlobLength);
    pack32(signatureBlob + 4, signatureTypeLength);
    memcpy(signatureBlob + 8, "ssh-dss", signatureTypeLength);
    pack32(signatureBlob + 15, signatureLength);
    memcpy(signatureBlob + 19, sigblob, 40);
    
    return (ssh_string)signatureBlob;
}
开发者ID:Devolutions,项目名称:SshTerminal,代码行数:58,代码来源:SshAgent.c

示例11: power_mgmt_data_pack

/* Pack a power management data structure */
extern void power_mgmt_data_pack(power_mgmt_data_t *power, Buf buffer,
				 uint16_t protocol_version)
{
	if (!power) {
		pack32(NO_VAL, buffer);
	} else {
		pack32(power->cap_watts, buffer);
	}
}
开发者ID:SchedMD,项目名称:slurm,代码行数:10,代码来源:power.c

示例12: SshAgentMakeIdentityListReply

uint8_t* SshAgentMakeIdentityListReply(SshAgentContext* context)
{
    uint8_t* message = NULL;
    
    int keyCount = (context->isLocked ? 0 : context->keyCount);
    
    ssh_string* keyBlobs = (keyCount > 0 ? calloc(keyCount, sizeof(ssh_string*)) : NULL);
    if (keyBlobs == NULL && keyCount > 0)
    {
        return NULL;
    }
    int totalBlobSize = 0;
    int i;
    for (i = 0; i < keyCount; i++)
    {
        int sshResult = ssh_pki_export_pubkey_blob(context->keys[i], keyBlobs + i);
        if (sshResult != SSH_OK)
        {
            goto FREE_KEY_BLOBS;
        }
        totalBlobSize += ntohl(keyBlobs[i]->size);
    }

    int messageSize = 5 + totalBlobSize + 8 * keyCount;
    message = malloc(messageSize + 4);
    if (message == NULL)
    {
        goto FREE_KEY_BLOBS;
    }
    
    pack32(message, messageSize);
    message[4] = SSH2_AGENT_IDENTITIES_ANSWER;
    pack32(message + 5, keyCount);
    int index = 9;
    for (i = 0; i < keyCount; i++)
    {
        ssh_string blob = keyBlobs[i];
        int blobSize = unpack32((uint8_t*)blob) + 4;
        memcpy(message + index, blob, blobSize);
        index += blobSize;
        
        memset(message + index, 0, 4);
        index += 4;
    }
    
FREE_KEY_BLOBS:
    for (i = 0; i < keyCount; i++)
    {
        ssh_string blob = keyBlobs[i];
        ssh_string_free(blob);
    }

    free(keyBlobs);
    
    return message;
}
开发者ID:Devolutions,项目名称:SshTerminal,代码行数:56,代码来源:SshAgent.c

示例13: _pack_register_ctld_msg

static void _pack_register_ctld_msg(dbd_register_ctld_msg_t *msg,
				    uint16_t rpc_version, Buf buffer)
{
	if (rpc_version >= SLURM_MIN_PROTOCOL_VERSION) {
		pack16(msg->dimensions, buffer);
		pack32(msg->flags, buffer);
		pack32(msg->plugin_id_select, buffer);
		pack16(msg->port, buffer);
	}
}
开发者ID:SchedMD,项目名称:slurm,代码行数:10,代码来源:slurmdbd_pack.c

示例14: pack32_array

/* Given a *uint32_t, it will pack an array of size_val */
void pack32_array(uint32_t * valp, uint32_t size_val, Buf buffer)
{
	uint32_t i = 0;

	pack32(size_val, buffer);

	for (i = 0; i < size_val; i++) {
		pack32(*(valp + i), buffer);
	}
}
开发者ID:A1ve5,项目名称:slurm,代码行数:11,代码来源:pack.c

示例15: io_init_msg_pack

static void
io_init_msg_pack(struct slurm_io_init_msg *hdr, Buf buffer)
{
	pack16(hdr->version, buffer);
       	pack32(hdr->nodeid, buffer);
	pack32(hdr->stdout_objs, buffer);
	pack32(hdr->stderr_objs, buffer);
	packmem((char *) hdr->cred_signature,
		(uint32_t) SLURM_IO_KEY_SIZE, buffer);
}
开发者ID:A1ve5,项目名称:slurm,代码行数:10,代码来源:io_hdr.c


注:本文中的pack32函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。