本文整理汇总了C++中dump_hex函数的典型用法代码示例。如果您正苦于以下问题:C++ dump_hex函数的具体用法?C++ dump_hex怎么用?C++ dump_hex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dump_hex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lan_send
static void
lan_send(lan_data_t *lan,
struct iovec *data, int vecs,
void *addr, int addr_len)
{
struct msghdr msg;
lan_addr_t *l = addr;
int rv;
if (debug) {
int left, i;
lanserv_log(DEBUG, NULL, "Sending message to:\n ");
dump_hex(&l->addr, l->addr_len, 16);
lanserv_log(DEBUG, NULL, "\nMsg:\n ");
left = 16;
for (i=0; i<vecs; i++) {
left = dump_hex(data[i].iov_base, data[i].iov_len, left);
}
lanserv_log(DEBUG, NULL, "\n");
}
msg.msg_name = &(l->addr);
msg.msg_namelen = l->addr_len;
msg.msg_iov = data;
msg.msg_iovlen = vecs;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
rv = sendmsg(l->xmit_fd, &msg, 0);
if (rv) {
/* FIXME - log an error. */
}
}
示例2: diff_records
void diff_records( token_mod_link** differences,
tglobal* global_original, tglobal* global_updated,
tfixed* fixed_original, tfixed* fixed_updated,
tlog* log_original, tlog* log_updated,
bool print_diff_info ) {
token_mod_link* diff_pair = NULL;
/* We may want to print the timestamps of the records
* being compared in order to differentiate them, in fact
* this is an essential part of the process...
*/
while( diff_pair = pop_tm_link( differences ) ) {
printf( "Difference found on token [%d]\n",
diff_pair->original ?
(unsigned short)diff_pair->original->token :
diff_pair->modified ?
(unsigned short)diff_pair->modified->token :
(unsigned short)-1 );
printf( "Original:\n" );
if ( diff_pair->original ) {
dump_hex( diff_pair->original->buffer,
diff_pair->original->length,
(size_t)DUMP_BYTES,
(size_t)16 );
} else {
printf( "NULL\n" );
}
printf( "Modified:\n" );
if ( diff_pair->modified ) {
dump_hex( diff_pair->modified->buffer,
diff_pair->modified->length,
(size_t)DUMP_BYTES,
(size_t)16 );
} else {
printf( "NULL\n" );
}
}
printf( "Global configuration modifications:\n" );
if ( !diff_global( global_original, global_updated, print_diff_info ) ) {
printf( " None.\n" );
}
printf( "Fixed configuration modifications:\n" );
if ( !diff_fixed( fixed_original, fixed_updated, print_diff_info ) ) {
printf( " None.\n" );
}
printf( "Log configuration modifications:\n" );
if ( !diff_log( log_original, log_updated, print_diff_info ) ) {
printf( " None.\n" );
}
}
示例3: main
int main(void)
{
uint8_t ct1[32], pt1[32], pt2[32], key[64];
int klen, plen, clen, i, j;
serpent_key_t skey;
serpent_blk ct2;
uint32_t *p;
printf("\nserpent-256 test\n");
for (i = 0; i<sizeof(keys) / sizeof(char*); i++) {
clen = hex2bin(ct1, cipher[i]);
plen = hex2bin(pt1, plain[i]);
klen = hex2bin(key, keys[i]);
/* set key */
memset(&skey, 0, sizeof(skey));
p = (uint32_t*)&skey.x[0][0];
serpent_set_encrypt_key(&skey, key);
printf("\nkey=");
for (j = 0; j<sizeof(skey) / sizeof(serpent_subkey_t) * 4; j++) {
if ((j % 8) == 0)
putchar('\n');
printf("%08X ", p[j]);
}
/* encrypt */
memcpy(ct2.b, pt1, SERPENT_BLOCK_SIZE);
printf("\n\n");
dump_hex("plaintext", ct2.b, 16);
serpent_encrypt(pt1,ct2.b, &skey);
dump_hex("ciphertext", ct2.b, 16);
if (memcmp(ct1, ct2.b, clen) == 0) {
printf("\nEncryption OK");
serpent_decrypt(ct2.b,pt1, &skey);
if (memcmp(pt1, ct2.b, plen) == 0) {
printf("\nDecryption OK");
dump_hex("plaintext", ct2.b, 16);
}
else {
printf("\nDecryption failed");
}
}
else {
printf("\nEncryption failed");
}
}
return 0;
}
示例4: check_results
static void check_results (const cl_uint num_devices, gpu_ctx_t *gpu_ctxs)
{
static uint64_t total = 0;
for (cl_uint device_id = 0; device_id < num_devices; device_id++)
{
gpu_ctx_t *gpu_ctx = &gpu_ctxs[device_id];
if (gpu_ctx->num_cached == 0) continue;
const size_t size_results = gpu_ctx->num_threads * sizeof (uint32_t);
gc_clEnqueueReadBuffer (gpu_ctx->command_queue, gpu_ctx->d_results, CL_TRUE, 0, size_results, gpu_ctx->h_results, 0, NULL, NULL);
for (uint32_t thread = 0; thread < gpu_ctx->num_threads; thread++)
{
if (gpu_ctx->h_results[thread] != 0xffffffff)
{
uint32_t gid = gpu_ctx->h_results[thread];
fprintf (stdout, "\nGPU #%2d: ALARM! Candidate number %u cracked the hash! Hex dump following:\n\n", device_id, gid);
dump_hex (stdout, gpu_ctx->plains_buf[gid], gpu_ctx->plains_len[gid]);
FILE *fd = fopen (POTFILE, "ab");
if (fd) // ignore error
{
fprintf (fd, "\nGPU #%2d: ALARM! Candidate number %u cracked the hash! Hex dump following:\n\n", device_id, gid);
dump_hex (fd, gpu_ctx->plains_buf[gid], gpu_ctx->plains_len[gid]);
fclose (fd);
}
exit (0);
}
}
const uint32_t num_cached = gpu_ctx->num_cached;
total += num_cached;
float ms;
timer_get (gpu_ctx->timer, ms);
if (ms == 0) continue;
float speed = (num_cached / ms) * 1000;
printf ("GPU #%2d: %u candidates in %u ms [%u/s] - Total = %llu...\n", device_id, num_cached, (uint32_t) ms, (uint32_t) speed, (long long unsigned int) total);
}
}
示例5: ccsrp_component_equal
CC_INLINE bool
ccsrp_component_equal(char *label, ccsrp_ctx_t srp, cc_unit *a, cc_unit *b) {
bool retval = ccn_cmp(ccsrp_ctx_n(srp), a, b) == 0;
if(!retval) {
size_t bytes_n = ccsrp_ctx_sizeof_n(srp);
cc_printf("ccsrp_test_calculations: mismatch for %s:\n", label);
cc_printf("\t");
dump_hex((void *) a, bytes_n);
cc_printf("\t");
dump_hex((void *) b, bytes_n);
cc_printf("\n");
}
return retval;
}
示例6: thex_dump_dime_records
static void
thex_dump_dime_records(const pslist_t *records)
{
const pslist_t *iter;
PSLIST_FOREACH(records, iter) {
const struct dime_record *record = iter->data;
g_assert(record);
dump_hex(stderr, "THEX DIME record type",
dime_record_type(record), dime_record_type_length(record));
dump_hex(stderr, "THEX DIME record ID",
dime_record_id(record), dime_record_id_length(record));
}
}
示例7: thex_dump_dime_records
static void
thex_dump_dime_records(const GSList *records)
{
const GSList *iter;
for (iter = records; NULL != iter; iter = g_slist_next(iter)) {
const struct dime_record *record;
record = iter->data;
g_assert(record);
dump_hex(stderr, "THEX DIME record type",
dime_record_type(record), dime_record_type_length(record));
dump_hex(stderr, "THEX DIME record ID",
dime_record_id(record), dime_record_id_length(record));
}
}
示例8: pack_unpack_datatype
static int pack_unpack_datatype( void* send_data, ompi_datatype_t *datatype, int count,
void* recv_data,
checker_t validator, void* validator_arg)
{
MPI_Aint position = 0, buffer_size;
void* buffer;
int error;
error = ompi_datatype_pack_external_size("external32",
count, datatype, &buffer_size);
if( MPI_SUCCESS != error ) goto return_error_code;
buffer = (void*)malloc(buffer_size);
if( NULL == buffer ) { error = MPI_ERR_UNKNOWN; goto return_error_code; }
error = ompi_datatype_pack_external("external32", (void*)send_data, count, datatype,
buffer, buffer_size, &position);
if( MPI_SUCCESS != error ) goto return_error_code;
if( 0 != validator(send_data, buffer, datatype, count, validator_arg) ) {
printf("Error during pack external. Bailing out\n");
return -1;
}
printf("packed %ld bytes into a %ld bytes buffer ", position, buffer_size); dump_hex(buffer, position); printf("\n");
position = 0;
error = ompi_datatype_unpack_external("external32", buffer, buffer_size, &position,
recv_data, count, datatype);
if( MPI_SUCCESS != error ) goto return_error_code;
free(buffer);
return_error_code:
return (error == MPI_SUCCESS ? 0 : -1);
}
示例9: main
/*
* === FUNCTION ======================================================================
* Name: main
* Description:
* =====================================================================================
*/
int main(int argc, char *argv[])
{
if (argc != 2)
{
printf("Usage: HexDump file \n");
return 1;
}
FILE *file = fopen(argv[1], "rb");
if (!file)
{
printf("Can't open the file.\n");
return 2;
}
char str[640000];
int len = 0;
char d[17] ; d[16]=0;
unsigned int bytes = 0;
while (bytes = fread(d, 1, 16, file))
{
memcpy(str+len,d,bytes);
printf("%s",d);
len += bytes;
}
printf("len = %d\n",len);
dump_hex(str,len);
fclose(file);
return 0;
}
示例10: huge_tth_extract32
bool
huge_tth_extract32(const char *buf, size_t len, struct tth *tth,
const gnutella_node_t *n)
{
if (len != TTH_BASE32_SIZE)
goto bad;
if (TTH_RAW_SIZE != base32_decode(tth->data, sizeof tth->data, buf, len))
goto bad;
return TRUE;
bad:
if (GNET_PROPERTY(share_debug)) {
if (is_printable(buf, len)) {
g_warning("%s has bad TTH (len=%u): %.*s",
gmsg_node_infostr(n),
(unsigned) len,
(int) MIN(len, (size_t) INT_MAX),
buf);
} else {
g_warning("%s has bad TTH (len=%u",
gmsg_node_infostr(n), (unsigned) len);
if (len)
dump_hex(stderr, "Base32 TTH", buf, len);
}
}
return FALSE;
}
示例11: WriteFdExactly
bool WriteFdExactly(int fd, const void* buf, size_t len) {
const char* p = reinterpret_cast<const char*>(buf);
int r;
#if ADB_TRACE
D("writex: fd=%d len=%d: ", fd, (int)len);
if (ADB_TRACING) {
dump_hex(reinterpret_cast<const unsigned char*>(buf), len);
}
#endif
while (len > 0) {
r = adb_write(fd, p, len);
if (r == -1) {
D("writex: fd=%d error %d: %s\n", fd, errno, strerror(errno));
if (errno == EAGAIN) {
adb_sleep_ms(1); // just yield some cpu time
continue;
} else if (errno == EPIPE) {
D("writex: fd=%d disconnected\n", fd);
errno = 0;
return false;
} else {
return false;
}
} else {
len -= r;
p += r;
}
}
return true;
}
示例12: writex
int writex(int fd, const void *ptr, size_t len)
{
char *p = (char*)ptr;
int r;
#if ADB_TRACE
D("writex: fd=%d len=%d: ", fd, (int)len);
dump_hex((const unsigned char *)ptr, len);
#endif
while (len > 0) {
r = adb_write(fd, p, len);
if (r > 0) {
len -= r;
p += r;
}
else {
if (r < 0) {
D("writex: fd=%d error %d: %s\n", fd, errno, strerror(errno));
if (errno == EINTR)
continue;
if (errno == EAGAIN) {
adb_sleep_ms(1); // just yield some cpu time
continue;
}
}
else {
D("writex: fd=%d disconnected\n", fd);
}
return -1;
}
}
return 0;
}
示例13: update_dump
void update_dump()
{
if(hex_dlg != NULL)
dump_hex();
if(text_dlg != NULL)
dump_text();
}
示例14: DumpCobol
void DumpCobol(BYTE level)
{
BYTE ch;
StdOutPrintf(L"\tLevel = %2d", level & 0x7f);
if (level & 0x80) {
StdOutPuts(L"(Group)");
}
loop:
// check next byte of type string
ch = getbyte();
if ((ch & 0xfe) == 0xc0) {
// output linkage informatioon byte
DumpCobLinkage (ch);
if (Leaf_pos < Leaf_bytes) {
ch = getbyte();
}
goto loop;
}
if (Leaf_pos <= Leaf_bytes) {
if ((ch & 0xe0) == 0xe0) {
// output OCCURS subscript information
DumpCobOccurs (ch);
goto loop;
}
}
if (Leaf_pos <= Leaf_bytes) {
DumpCobItem (ch);
}
dump_hex((Leaf_bytes - Leaf_pos), true);
StdOutPuts(L"\n");
}
示例15: readx
int readx(int fd, void *ptr, size_t len)
{
char *p = ptr;
int r;
#if ADB_TRACE
int len0 = len;
#endif
D("readx: %d %p %d\n", fd, ptr, (int)len);
while(len > 0) {
r = adb_read(fd, p, len);
if(r > 0) {
len -= r;
p += r;
} else {
D("readx: %d %d %s\n", fd, r, strerror(errno));
if((r < 0) && (errno == EINTR)) continue;
return -1;
}
}
#if ADB_TRACE
D("readx: %d ok: ", fd);
dump_hex( ptr, len0 );
#endif
return 0;
}