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


C++ check_magic函数代码示例

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


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

示例1: is_vfat

static inline bool is_vfat(const void *data, size_t size)
{
    return     check_magic(data, size, "MSWIN",    5, 0x52)
            || check_magic(data, size, "FAT32   ", 8, 0x52)
            || check_magic(data, size, "MSDOS",    5, 0x36)
            || check_magic(data, size, "FAT16   ", 8, 0x36)
            || check_magic(data, size, "FAT12   ", 8, 0x36)
            || check_magic(data, size, "FAT     ", 8, 0x36)
            || check_magic(data, size, "\353",     1, 0)
            || check_magic(data, size, "\351",     1, 0)
            || check_magic(data, size, "\125\252", 2, 0x1fe);
}
开发者ID:Caio99BR,项目名称:DualBootPatcher,代码行数:12,代码来源:blkid.cpp

示例2: ADhash_add

void *
ADhash_add (ADhash_t hash, void *key, void *data)
{
	struct hash_t		*h;
	struct hash_element_t	*p, *e;
	unsigned int		i;

	/* Check hash structure validity */
	if ((h = check_magic (hash, ADMAGIC_HASH)) == NULL) return (NULL);

	/* First check for duplicate key */
	p = hash_lookup (h, key);
	if (p != NULL) return (NULL);

	/* Create new hash element */
	NEW_ROF (e, NULL);
	e->key   = key;
	e->data  = data;

	/* Calculate hash index and add element to bucket */
	i = hash_index (h, key); e->bucket = i;
	if ((p = h->hash[i]) == NULL) {
		h->hash[i] = e;
	} else {
		while (p->next != NULL) p = p->next;
		p->next = e;
	}
	h->size++;

	/* Return new element */
	return (data);
}
开发者ID:ErikCumps,项目名称:spwproject,代码行数:32,代码来源:ad_hash.c

示例3: palloc

static void *core_prealloc(void *blk, size_t size) {
	void *new_blk;
	palloc_t *m;

	/* size == 0: free block */
	if(size == 0) {
		if(blk != NULL) pfree(blk);
		new_blk = NULL;		
	}
	else {
		/* allocate a new_blk */
		new_blk = palloc(size);
		/* if allocation was OK, and if old block exists, copy old block to new */
		if(new_blk != NULL && blk != NULL) {
			m = (palloc_t *)((char *)blk - sizeof(palloc_t));
			if(check_magic(m) == FALSE) {
				if(prealloc_error_message(m) == TRUE)
					return NULL;
			}
			/* Copy minimum of old and new block sizes */
			if(size > m -> size) size = m -> size;
			memcpy(new_blk,blk,size);
			/* free the old block */
			pfree(blk);
		}
	}
	return new_blk;
}
开发者ID:albertotorresfoltyn,项目名称:praos,代码行数:28,代码来源:palloc.c

示例4: debug_ADhash_report

void
debug_ADhash_report (FILE *rf, ADhash_t hash, char *msg)
{
	struct hash_t		*h;
	unsigned int		i;
	struct hash_element_t	*p;

	/* Check hash structure validity */
	if ((h = check_magic (hash, ADMAGIC_HASH)) == NULL) return;

	fprintf (rf, "ADhash (%s) = 0x%8.8x\n", msg, h);

	fprintf (rf, "buckets = %lu\n", h->buckets);
	fprintf (rf, "size    = %lu\n", h->size);
	fprintf (rf, "\n");

	for (i=0; i<h->buckets; i++) {
		if (!h->hash[i]) continue;

		fprintf (rf, "bucket[%3lu]", i);
		p = h->hash[i];
		while (p) {
			fprintf (rf, " {\"%s\", %lu}", (char *)(p->key), (ULONG)p->data);
			p = p->next;
		}
		fprintf (rf, "\n");
	}
	fprintf (rf, "\n");
}
开发者ID:ErikCumps,项目名称:spwproject,代码行数:29,代码来源:ad_hash.c

示例5: pconf_line

/* parse a provided line */
int pconf_line(PCONF_CTX *ctx, const char *line)
{
	size_t	i, linelen;

	if (!check_magic(ctx))
		return 0;

	ctx->linenum++;

	/* start over for the new line */
	ctx->numargs = 0;
	ctx->state = STATE_FINDWORDSTART;

	linelen = strlen(line);

	for (i = 0; i < linelen; i++) {
		ctx->ch = line[i];

		parse_char(ctx);

		if (ctx->state == STATE_PARSEERR)
			return 1;

		if (ctx->state == STATE_ENDOFLINE)
			return 1;
	}

	/* deal with any lingering characters */

	/* still building a word? */
	if (ctx->wordptr != ctx->wordbuf)	
		endofword(ctx);		/* tie it off */

	return 1;
}
开发者ID:BlueForeverI,项目名称:winnut,代码行数:36,代码来源:parseconf.c

示例6: program_load_datas

int		program_load_datas(t_list *programs)
{
  t_list_item	*item;
  t_program	*program;
  int		header_len;

  header_len = MAGIC_LEN + PROG_NAME_LENGTH
    + SIZE_CONTENT_LENGTH + COMMENT_LENGTH + 4;
  item = programs->top;
  while (item != NULL)
    {
      program = (t_program *)item->data;
      if (load_data(program) == RET_FAILURE)
	return (RET_FAILURE);
      if (program->data_len < header_len)
	return (error_int(RET_FAILURE, ERR_INVALID_HEADER));
      else if (program->data_len == header_len)
	return (error_int(RET_FAILURE, ERR_CONTENT_EMPTY));
      if (check_magic(program->data) == RET_FAILURE)
	return (RET_FAILURE);
      program->code = program->data + header_len;
      program->code_len = program->data_len - header_len;
      item = item->next;
    }
  return (RET_SUCCESS);
}
开发者ID:DBarthe,项目名称:Corewar,代码行数:26,代码来源:program_load_data.c

示例7: pconf_file_next

/* read from a file until a whole line is ready for use */
int pconf_file_next(PCONF_CTX *ctx)
{
	if (!check_magic(ctx))
		return 0;

	ctx->linenum++;

	/* start over for the new line */
	ctx->numargs = 0;
	ctx->state = STATE_FINDWORDSTART;

	while ((ctx->ch = fgetc(ctx->f)) != EOF) {
		parse_char(ctx);

		if (ctx->state == STATE_PARSEERR)
			return 1;

		if (ctx->state == STATE_ENDOFLINE)
			return 1;
	}

	/* deal with files that don't end in a newline */

	if (ctx->numargs != 0) {

		/* still building a word? */
		if (ctx->wordptr != ctx->wordbuf)
			endofword(ctx);

		return 1;
	}

	/* finished with nothing left over */
	return 0;
}
开发者ID:BlueForeverI,项目名称:winnut,代码行数:36,代码来源:parseconf.c

示例8: check_file

/********************************************************************************
*函数名称: check_file
*函数原型: __s32 check_file( __u32 *mem_base, __u32 size, const char *magic )
*函数功能: 使用“算术和”来校验内存中的一段数据
*入口参数: mem_base       待校验的数据在内存中的起始地址(必须是4字节对齐的)
*          size           待校验的数据的个数(以字节为单位,必须是4字节对齐的)
*          magic          magic number, 待校验文件的标识码
*返 回 值: CHECK_IS_CORRECT       校验正确
*          CHECK_IS_WRONG         校验错误
*备    注:
********************************************************************************/
__s32 check_file( __u32 *mem_base, __u32 size, const char *magic )
{
	if( check_magic( mem_base, magic ) == CHECK_IS_CORRECT
        &&check_sum( mem_base, size  ) == CHECK_IS_CORRECT )
        return CHECK_IS_CORRECT;
    else
    	return CHECK_IS_WRONG;
}
开发者ID:cta08403,项目名称:phoenixA20_linux_boot_sourcecode,代码行数:19,代码来源:check.c

示例9: check_file

/********************************************************************************
*函数名称: check_file
*函数原型: __s32 check_file( __u32 *mem_base, __u32 size, const char *magic )
*函数功能: 使用“算术和”来校验内存中的一段数据
*入口参数: mem_base       待校验的数据在内存中的起始地址(必须是4字节对齐的)
*          size           待校验的数据的个数(以字节为单位,必须是4字节对齐的)
*          magic          magic number, 待校验文件的标识码
*返 回 值: CHECK_IS_CORRECT       校验正确
*          CHECK_IS_WRONG         校验错误
*备    注:
********************************************************************************/
__s32 check_file( __u32 *mem_base, __u32 size, const char *magic )
{
	if( check_magic( mem_base, magic ) == 0
        &&check_sum( mem_base, size  ) == 0 )
        return 0;
    else
    	return -1;
}
开发者ID:dmitry-shavyrin,项目名称:a64_lichee,代码行数:19,代码来源:check.c

示例10: ext2fs_clear_generic_bitmap

void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
{
	if (check_magic(bitmap))
		return;

	memset(bitmap->bitmap, 0,
	       (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
}
开发者ID:HonestarKevin,项目名称:wm8880_4_4_uboot,代码行数:8,代码来源:gen_bitmap.c

示例11: oldmda_detect

static gint
oldmda_detect(const GwyFileDetectInfo *fileinfo,
              gboolean only_name)
{
    if (only_name)
        return g_str_has_suffix(fileinfo->name_lowercase, EXTENSION) ? 10 : 0;

    return check_magic(fileinfo->head) ? 100 : 0;
}
开发者ID:cbuehler,项目名称:gwyddion,代码行数:9,代码来源:oldmda.c

示例12: ADhash_size

AD_size_t
ADhash_size (ADhash_t hash)
{
	struct hash_t		*h;

	/* Check hash structure validity */
	if ((h = check_magic (hash, ADMAGIC_HASH)) == NULL) return (0);

	return (h->size);
}
开发者ID:ErikCumps,项目名称:spwproject,代码行数:10,代码来源:ad_hash.c

示例13: check_file_magic_vik

/*
 * Function to determine if a filename is a 'viking' type file
 */
gboolean check_file_magic_vik ( const gchar *filename )
{
  gboolean result = FALSE;
  FILE *ff = xfopen ( filename );
  if ( ff ) {
    result = check_magic ( ff, VIK_MAGIC );
    xfclose ( ff );
  }
  return result;
}
开发者ID:gapato,项目名称:viking,代码行数:13,代码来源:file.c

示例14: RSSIData_rssi

int16_t RSSIData_rssi(const RSSIData *msg) {
  check_magic(msg);
  if (has_field(msg, 2)) {
    return ntohs(msg->rssi);
  } else {
    fprintf(stderr, "Requested field rssi from RSSIData at address %p, but "
                    "message do3s not have the field \n",
            (void *)msg);
    return -1;
  }
}
开发者ID:jamesr66a,项目名称:EmbeddedCapstonePiSoftware,代码行数:11,代码来源:RSSIData.pbo.c

示例15: RSSIData_frameNum

int32_t RSSIData_frameNum(const RSSIData *msg) {
  check_magic(msg);
  if (has_field(msg, 5)) {
    return ntohl(msg->frameNum);
  } else {
    fprintf(stderr, "Requested field frameNum from RSSIData at address %p, but "
                    "message do3s not have the field \n",
            (void *)msg);
    return -1;
  }
}
开发者ID:jamesr66a,项目名称:EmbeddedCapstonePiSoftware,代码行数:11,代码来源:RSSIData.pbo.c


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