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


C++ print_block函数代码示例

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


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

示例1: print_cube

static int print_cube(cube_t *cube){
  int i;
  int j;
  int k;

  for(i = 0; i < CUBE_ORDER; ++i){
    for(j = 0; j < CUBE_ORDER; ++j){
      print_block(&cube->face[UUU].block[i][j]);
    }
    printf("%x", i);
    printf("\n");
  }
  printf("0 1 2 3 4 5 6 7 8 9 a  a 9 8 7 6 5 4 3 2 1 0  a 9 8 7 6 5 4 3 2 1 0  0 1 2 3 4 5 6 7 8 9 a\n");
  for(i = 0; i < CUBE_ORDER; ++i){
    for(k = FFF; k <= LLL; ++k){
      for(j = 0; j < CUBE_ORDER; ++j){
	print_block(&cube->face[k].block[i][j]);
      }
      printf("%x", CUBE_ORDER - 1 - i);
    }
    printf("\n");
  }
  printf("0 1 2 3 4 5 6 7 8 9 a  a 9 8 7 6 5 4 3 2 1 0  a 9 8 7 6 5 4 3 2 1 0  0 1 2 3 4 5 6 7 8 9 a\n");
  for(i = 0; i < CUBE_ORDER; ++i){
    for(j = 0; j < CUBE_ORDER; ++j){
      print_block(&cube->face[DDD].block[i][j]);
    }
    printf("%x", CUBE_ORDER - 1 - i);
    printf("\n");
  }
  printf("0 1 2 3 4 5 6 7 8 9 a\n");
  return 0;
}
开发者ID:yonghuhaige,项目名称:cube,代码行数:33,代码来源:cube2.c

示例2: test_encryption

  /*(Key (128): E8E9EAEBEDEEEFF0F2F3F4F5F7F8F9FA 
Plaintext: 014BAF2278A69D331D5180103643E99A 
Ciphertext: 6743C3D1519AB4F2CD9A78AB09A511BD */
void test_encryption(){
  unsigned char 
  /* TODO: old values taht seem to be invalid:
     key[] = {0xE8, 0xE9, 0xEA, 0xEB, 0xED, 0xEE, 0xEF, 0xF0, 0xF2, 0xF3, 0xF4, 0xF5, 0xF7, 0xF8, 0xF9, 0xFA},
     plain[] = {0x01, 0x4B, 0xAF, 0x22, 0x78, 0xA6, 0x9D, 0x33, 0x1D, 0x51, 0x80, 0x10, 0x36, 0x43, 0xE9, 0x9A},
     cipher[] = {0x67, 0x43, 0xC3, 0xD1, 0x51, 0x9A, 0xB4, 0xF2, 0xCD, 0x9A, 0x78, 0xAB, 0x09, 0xA5, 0x11, 0xBD};
*/

/* TODO: test w/these values instead. if they work, investigate why the other ones don't:
    data = [0x68, 0x65, 0x6c, 0x6c,

                0x6f, 0x2c, 0x20, 0x77,
                0x6f, 0x72, 0x6c, 0x64,
                0x21, 0x21, 0x21, 0x21]
    key = [0x0f, 0x15, 0x71, 0xc9,
              0x47, 0xd9, 0xe8, 0x59,
              0x0c, 0xb7, 0xad, 0xd6,
              0xaf, 0x7f, 0x67, 0x98]
    result = @aes.encrypt(data, key)

    assert_equal([0x56, 0xdd, 0x68, 0x15, 0x44, 0x65, 0x7b, 0x76, 0xe5, 0x93, 0x51, 0xf5, 0x7d, 0x95, 0xa4, 0xb3], 
                      result)
    */
  unsigned char *c = encrypt(plain, key, 16);
  print_block(c, 16);
  print_block(cipher, 16);
  assert( bytencmp(c, cipher, 16) == 0 );
  //unsigned char *p = decrypt(c, key, 16);
  //assert( bytencmp(p, plain, 16) == 0 );

  free(c);
//  free(p);

}
开发者ID:justinethier,项目名称:aes,代码行数:37,代码来源:test.c

示例3: print_disk_tree

void print_disk_tree (int block_nr)
{
    struct buffer_head * bh;

    bh = bread (g_sb.s_dev, block_nr, g_sb.s_blocksize);
    if (B_IS_KEYS_LEVEL (bh)) {
	int i;
	struct disk_child * dc;

	g_stat_info.nr_internals ++;
	print_block (bh, print_mode (), -1, -1);
      
	dc = B_N_CHILD (bh, 0);
	for (i = 0; i <= B_NR_ITEMS (bh); i ++, dc ++)
	    print_disk_tree (dc->dc_block_number);

    } else if (B_IS_ITEMS_LEVEL (bh)) {
	g_stat_info.nr_leaves ++;
	print_block (bh, print_mode (), -1, -1);
    } else {
	print_block (bh, print_mode (), -1, -1);
	die ("print_disk_tree: bad block type");
    }
    brelse (bh);
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:25,代码来源:dumpreiserfs.c

示例4: print_block

void print_block(value v, int m)
{
    int size, i;

    margin(m);
    if (Is_long(v))
    {
        printf("immediate value (%ld)\n", Long_val(v));
        return;
    }
    printf("memory block: size=%d - ", size=Wosize_val(v));

    switch(Tag_val(v))
    {
        case Closure_tag:
            printf("closure with %d free variables\n", size-1);
            margin(m+4);
            printf("code pointer: %p\n", Code_val(v));
            for (i=1; i<size; i++)
                print_block(Field(v,i),m+4);
            break;

        case String_tag:
            printf("string: %s (%s)\n", String_val(v), (char *) v);
            break;

        case Double_tag:
            printf("float: %g\n", Double_val(v));
            break;

        case Double_array_tag:
            printf("float array: ");
            for (i=0; i<size/Double_wosize; i++)
                printf(" %g", Double_field(v,i));
            printf("\n");
            break;

        case Abstract_tag:
            printf("abstract type\n");
            break;

        case Custom_tag:
            printf("abstract finalized type\n");
            break;

        default:
            if (Tag_val(v) >= No_scan_tag)
            {
                printf("unknown tag");
                break;
            };
            printf("structured block (tag=%d):\n", Tag_val(v));
            for (i=0; i<size; i++)
                print_block(Field(v,i), m+4);
    }
    return;
}
开发者ID:twopisoft,项目名称:ocaml-book,代码行数:57,代码来源:inspect.c

示例5: print_width

/*
 * Set up the indentation for a list item; used from pre_it().
 */
static void
print_width(const struct mdoc_bl *bl, const struct roff_node *child)
{
	char		  buf[24];
	struct roffsu	  su;
	const char	 *end;
	int		  numeric, remain, sz, chsz;

	numeric = 1;
	remain = 0;

	/* Convert the width into a number (of characters). */
	if (bl->width == NULL)
		sz = (bl->type == LIST_hang) ? 6 : 0;
	else {
		end = a2roffsu(bl->width, &su, SCALE_MAX);
		if (end == NULL || *end != '\0')
			sz = man_strlen(bl->width);
		else if (SCALE_EN == su.unit)
			sz = su.scale;
		else {
			sz = 0;
			numeric = 0;
		}
	}

	/* XXX Rough estimation, might have multiple parts. */
	if (bl->type == LIST_enum)
		chsz = (bl->count > 8) + 1;
	else if (child != NULL && child->type == ROFFT_TEXT)
		chsz = man_strlen(child->string);
	else
		chsz = 0;

	/* Maybe we are inside an enclosing list? */
	mid_it();

	/*
	 * Save our own indentation,
	 * such that child lists can use it.
	 */
	Bl_stack[Bl_stack_len++] = sz + 2;

	/* Set up the current list. */
	if (chsz > sz && bl->type != LIST_tag)
		print_block(".HP", 0);
	else {
		print_block(".TP", 0);
		remain = sz + 2;
	}
	if (numeric) {
		(void)snprintf(buf, sizeof(buf), "%dn", sz + 2);
		print_word(buf);
	} else
		print_word(bl->width);
	TPremain = remain;
}
开发者ID:drscream,项目名称:illumos-joyent,代码行数:60,代码来源:mdoc_man.c

示例6: print_width

/*
 * Set up the indentation for a list item; used from pre_it().
 */
static void
print_width(const char *v, const struct mdoc_node *child, size_t defsz)
{
	char		  buf[24];
	struct roffsu	  su;
	size_t		  sz, chsz;
	int		  numeric, remain;

	numeric = 1;
	remain = 0;

	/* Convert v into a number (of characters). */
	if (NULL == v)
		sz = defsz;
	else if (a2roffsu(v, &su, SCALE_MAX)) {
		if (SCALE_EN == su.unit)
			sz = su.scale;
		else {
			sz = 0;
			numeric = 0;
		}
	} else
		sz = strlen(v);

	/* XXX Rough estimation, might have multiple parts. */
	chsz = (NULL != child && MDOC_TEXT == child->type) ?
	    strlen(child->string) : 0;

	/* Maybe we are inside an enclosing list? */
	mid_it();

	/*
	 * Save our own indentation,
	 * such that child lists can use it.
	 */
	Bl_stack[Bl_stack_len++] = sz + 2;

	/* Set up the current list. */
	if (defsz && chsz > sz)
		print_block(".HP", 0);
	else {
		print_block(".TP", 0);
		remain = sz + 2;
	}
	if (numeric) {
		(void)snprintf(buf, sizeof(buf), "%zun", sz + 2);
		print_word(buf);
	} else
		print_word(v);
	TPremain = remain;
}
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:54,代码来源:mdoc_man.c

示例7: test_chacha

void test_chacha(const uint8_t *key, const uint8_t *iv, uint8_t *expected, 
                uint8_t keylength, uint8_t rounds) {
    uint8_t cipher_data[64] =  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    uint8_t cipher_result[64] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    
    struct chacha_ctx cipher_ctx;

    uint8_t errors;
    
    chacha_set_key(&cipher_ctx, keylength, key);
    chacha_set_iv(&cipher_ctx, iv);
    chacha_crypt(&cipher_ctx, 64, rounds, &cipher_result[0], &cipher_data[0]);

    if (DEBUG) {
        printf("Result after encryption:\n");
        print_block(cipher_result);
      }

    errors = 0;
    for (uint8_t i = 0 ; i < 64 ; i++) {
      if (cipher_result[i] != expected[i]) {
        errors++;
      }
    }
    
    if (errors > 0) {
      printf("Error, expected:\n");
      print_block(&expected[0]);
      printf("Got:\n");
      print_block(cipher_result);
    }
    else {
      printf("Success, result matched expected.\n");
    }
}
开发者ID:altoplano,项目名称:PHC,代码行数:50,代码来源:test-chacha.c

示例8: search_by_entry_key

/* first calls search_by_key, then, if item is not found looks for the entry inside directory item indicated by
   search_by_key. (We assign a key to each directory item, and place multiple entries in a single directory item.)
   Fills the path to the entry, and to the entry position in the item */
int search_by_entry_key (struct super_block * sb, struct key * key, struct path * path, int * pos_in_item, int * repeat)
{
  /* search for a directory item using key of entry */
  if (search_by_key (sb, key, path, repeat, DISK_LEAF_NODE_LEVEL, READ_BLOCKS) == ITEM_FOUND) {
    *pos_in_item = 0;
    return POSITION_FOUND;
  }
#ifdef REISERFS_CHECK
  if (!PATH_LAST_POSITION (path))
    reiserfs_panic (sb, "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
#endif /* REISERFS_CHECK */
  PATH_LAST_POSITION (path) --;

#ifdef REISERFS_CHECK
  {
    struct item_head * ih = B_N_PITEM_HEAD (PATH_PLAST_BUFFER (path), PATH_LAST_POSITION (path));

    if (!I_IS_DIRECTORY_ITEM (ih) || COMP_SHORT_KEYS (&(ih->ih_key), key)) {
      print_block (PATH_PLAST_BUFFER (path), 0, -1, -1);
      reiserfs_panic (sb, "vs-7005: search_by_entry_key: found item %h is not directory item or "
		      "does not belong to the same directory as key %k", ih, key);
    }
  }
#endif /* REISERFS_CHECK */

  /* binary search in directory item by third component of the key */
  return bin_search_in_dir_item (PATH_PITEM_HEAD (path), B_I_DEH (PATH_PLAST_BUFFER (path), PATH_PITEM_HEAD (path)), key, pos_in_item);
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:31,代码来源:namei.c

示例9: decrypt_key

void decrypt_key(unsigned char* decryptedSap, unsigned char* keyIn, unsigned char* iv, unsigned char* keyOut)
{
   unsigned char blockIn[16];
   uint32_t key_schedule[11][4];
   uint32_t mode_key_schedule[11][4];
   generate_key_schedule(&decryptedSap[8], key_schedule);
   printf("Generating mode key:\n");
   generate_key_schedule(initial_session_key, mode_key_schedule);
   z_xor(keyIn, blockIn, 1);
   print_block("Input to cycle is: ", blockIn);
   cycle(blockIn, key_schedule);
   for (int j = 0; j < 16; j++)
      keyOut[j] = blockIn[j] ^ iv[j];
   print_block("Output from cycle is: ", keyOut);
   x_xor(keyOut, keyOut, 1);
}
开发者ID:EnkiChen,项目名称:playfair,代码行数:16,代码来源:omg_hax.c

示例10: test_shift_rows

void test_shift_rows(){
  char msg[] = "0123456789ABCDE";
  print_block(msg, 16);

printf("\n");
  shift_rows(msg, 16);
  print_block(msg, 16);

  printf("\n");
  inv_shift_rows(msg, 16);
  print_block(msg, 16);

// TODO: cannot use strcmp because it stops on 0!
// TODO: assert inv is equal to original
  assert( strcmp(msg, "0123456789ABCDE") == 0 );
}
开发者ID:justinethier,项目名称:aes,代码行数:16,代码来源:test.c

示例11: permute_block_1

void permute_block_1(unsigned char* block)
{
   block[0] = table_s3[block[0]];
   block[4] = table_s3[0x400+block[4]];
   block[8] = table_s3[0x800+block[8]];
   block[12] = table_s3[0xc00+block[12]];
   
   unsigned char tmp = block[13];
   block[13] = table_s3[0x100+block[9]];
   block[9] = table_s3[0xd00+block[5]];
   block[5] = table_s3[0x900+block[1]];
   block[1] = table_s3[0x500+tmp];

   tmp = block[2];
   block[2] = table_s3[0xa00+block[10]];
   block[10] = table_s3[0x200+tmp];
   tmp = block[6];
   block[6] = table_s3[0xe00+block[14]];
   block[14] = table_s3[0x600+tmp];

   tmp = block[3];
   block[3] = table_s3[0xf00+block[7]];
   block[7] = table_s3[0x300+block[11]];
   block[11] = table_s3[0x700+block[15]];
   block[15] = table_s3[0xb00+tmp];
   print_block("Permutation complete. Final value of block: ", block); // This looks right to me, at least for decrypt_kernel
}
开发者ID:EnkiChen,项目名称:playfair,代码行数:27,代码来源:omg_hax.c

示例12: block_check_invariants_print_result

bool block_check_invariants_print_result(Block* block, Value* out)
{
    circa::Value result;
    block_check_invariants(&result, block);

    if (list_length(&result) == 0)
        return true;

    string_append(out, list_length(&result));
    string_append(out, " errors found in block ");
    string_append_ptr(out, block);
    string_append(out, "\n");

    for (int i=0; i < list_length(&result); i++) {
        Value* error = list_get(&result,i);
        string_append(out, "[");
        string_append(out, as_int(list_get(error, 1)));
        string_append(out, "]");
        string_append(out, as_cstring(list_get(error, 2)));
        string_append(out, "\n");
    }

    string_append(out, "contents:\n");
    print_block(block, out);

    return false;
}
开发者ID:ShenTensen,项目名称:circa,代码行数:27,代码来源:block.cpp

示例13: permute_block_2

void permute_block_2(unsigned char* block, int round)
{
   // round is 0..8?
   printf("Permuting via table2, round %d... (block[0] = %02X)\n", round, block[0]);
   block[0] = permute_table_2(round*16+0)[block[0]];
   block[4] = permute_table_2(round*16+4)[block[4]];
   block[8] = permute_table_2(round*16+8)[block[8]];
   block[12] = permute_table_2(round*16+12)[block[12]];
   
   unsigned char tmp = block[13];
   block[13] = permute_table_2(round*16+13)[block[9]];
   block[9] = permute_table_2(round*16+9)[block[5]];
   block[5] = permute_table_2(round*16+5)[block[1]];
   block[1] = permute_table_2(round*16+1)[tmp];

   tmp = block[2];
   block[2] = permute_table_2(round*16+2)[block[10]];
   block[10] = permute_table_2(round*16+10)[tmp];
   tmp = block[6];
   block[6] = permute_table_2(round*16+6)[block[14]];
   block[14] = permute_table_2(round*16+14)[tmp];

   tmp = block[3];
   block[3] = permute_table_2(round*16+3)[block[7]];
   block[7] = permute_table_2(round*16+7)[block[11]];
   block[11] = permute_table_2(round*16+11)[block[15]];
   block[15] = permute_table_2(round*16+15)[tmp];
   print_block("Permutation (2) complete. Final value of block: ", block); // This looks right to me, at least for decrypt_kernel
}
开发者ID:EnkiChen,项目名称:playfair,代码行数:29,代码来源:omg_hax.c

示例14: pre_nm

static int
pre_nm(DECL_ARGS)
{
	char	*name;

	if (MDOC_BLOCK == n->type) {
		outflags |= MMAN_Bk;
		pre_syn(n);
	}
	if (MDOC_ELEM != n->type && MDOC_HEAD != n->type)
		return(1);
	name = n->child ? n->child->string : meta->name;
	if (NULL == name)
		return(0);
	if (MDOC_HEAD == n->type) {
		if (NULL == n->parent->prev)
			outflags |= MMAN_sp;
		print_block(".HP", 0);
		printf(" %zun", strlen(name) + 1);
		outflags |= MMAN_nl;
	}
	font_push('B');
	if (NULL == n->child)
		print_word(meta->name);
	return(1);
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:26,代码来源:mdoc_man.c

示例15: pre_fn

static int
pre_fn(DECL_ARGS)
{

	pre_syn(n);

	n = n->child;
	if (NULL == n)
		return 0;

	if (NODE_SYNPRETTY & n->flags)
		print_block(".HP 4n", MMAN_nl);

	font_push('B');
	print_node(meta, n);
	font_pop();
	outflags &= ~MMAN_spc;
	print_word("(");
	outflags &= ~MMAN_spc;

	n = n->next;
	if (NULL != n)
		pre_fa(meta, n);
	return 0;
}
开发者ID:drscream,项目名称:illumos-joyent,代码行数:25,代码来源:mdoc_man.c


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