本文整理汇总了C++中check_magic函数的典型用法代码示例。如果您正苦于以下问题:C++ check_magic函数的具体用法?C++ check_magic怎么用?C++ check_magic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_magic函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: pconf_finish
/* clean up the ctx space */
void pconf_finish(PCONF_CTX *ctx)
{
if (!check_magic(ctx))
return;
if (ctx->f)
fclose(ctx->f);
free_storage(ctx);
ctx->magic = 0;
}
开发者ID:BlueForeverI,项目名称:winnut,代码行数:13,代码来源:parseconf.c
示例17: pconf_parse_error
/* return 1 if an error occurred, but only do it once */
int pconf_parse_error(PCONF_CTX *ctx)
{
if (!check_magic(ctx))
return 0;
if (ctx->error == 1) {
ctx->error = 0;
return 1;
}
return 0;
}
开发者ID:BlueForeverI,项目名称:winnut,代码行数:13,代码来源:parseconf.c
示例18: Read_Modulefile
int Read_Modulefile( Tcl_Interp *interp,
char *filename)
{
int result;
char *startp, *endp;
#if WITH_DEBUGGING_UTIL
ErrorLogger( NO_ERR_START, LOC, _proc_Read_Modulefile, NULL);
#endif
/**
** Parameter check. A valid filename is to be given.
**/
if( !filename) {
if( OK != ErrorLogger( ERR_PARAM, LOC, "filename", NULL))
return( TCL_ERROR); /** -------- EXIT (FAILURE) -------> **/
}
/**
** Check for the module 'magic cookie'
** Trust stdin as a valid module file ...
**/
if( !strcmp( filename, _fil_stdin) && !check_magic( filename,
MODULES_MAGIC_COOKIE, MODULES_MAGIC_COOKIE_LENGTH)) {
if( OK != ErrorLogger( ERR_MAGIC, LOC, filename, NULL))
return( TCL_ERROR); /** -------- EXIT (FAILURE) -------> **/
}
/**
** Now do execute that module file and evaluate the result of the
** latest executed command
**/
result = Execute_TclFile(interp, filename);
#if WITH_DEBUGGING_UTIL
if(EM_ERROR == ReturnValue(interp, result))
ErrorLogger( NO_ERR_DEBUG, LOC, "Execution of '",
filename, "' failed", NULL);
#endif
/**
** Return the result as derivered from the module file execution
**/
#if WITH_DEBUGGING_UTIL
ErrorLogger( NO_ERR_END, LOC, _proc_Read_Modulefile, NULL);
#endif
return( result);
} /** End of 'Read_Modulefile' **/
开发者ID:HughMacdonald,项目名称:Environment-Modules_old,代码行数:53,代码来源:cmdModule.c
示例19: load_boot1_from_spinor
/*
************************************************************************************************************
*
* function
*
* name :
*
* parmeters :
*
* return :
*
* note :
*
*
************************************************************************************************************
*/
int load_boot1_from_spinor(void)
{
__u32 length;
struct spare_boot_head_t *bfh;
if(spinor_init(0))
{
printf("spinor init fail\n");
return -1;
}
/* 载入当前块最前面512字节的数据到SRAM中,目的是获取文件头 */
if(spinor_read(UBOOT_START_SECTOR_IN_SPINOR, 1, (void *)CONFIG_SYS_TEXT_BASE ) )
{
printf("the first data is error\n");
goto __load_boot1_from_spinor_fail;
}
printf("Succeed in reading Boot1 file head.\n");
/* 察看是否是文件头 */
if( check_magic( (__u32 *)CONFIG_SYS_TEXT_BASE, UBOOT_MAGIC ) != 0 )
{
printf("ERROR! Add %u doesn't store head of Boot1 copy.\n", UBOOT_START_SECTOR_IN_SPINOR );
goto __load_boot1_from_spinor_fail;
}
bfh = (struct spare_boot_head_t *)CONFIG_SYS_TEXT_BASE;
length = bfh->boot_head.length;
printf("The size of uboot is %x.\n", length );
if( ( length & ( 512 - 1 ) ) != 0 ) // length必须是NF_SECTOR_SIZE对齐的
{
printf("the boot1 is not aligned by %x\n", bfh->boot_head.align_size);
goto __load_boot1_from_spinor_fail;
}
if(spinor_read(UBOOT_START_SECTOR_IN_SPINOR, length/512, (void *)CONFIG_SYS_TEXT_BASE ))
{
printf("spinor read data error\n");
goto __load_boot1_from_spinor_fail;
}
bfh->boot_data.storage_type = 3;
return 0;
__load_boot1_from_spinor_fail:
return -1;
}
开发者ID:Gucan,项目名称:h3_lichee,代码行数:68,代码来源:load_boot1_from_spinor.c
示例20: free_mem
/*
* static int free_mem
*
* DESCRIPTION:
*
* Free an address from a memory pool.
*
* RETURNS:
*
* Success - MPOOL_ERROR_NONE
*
* Failure - Mpool error code
*
* ARGUMENTS:
*
* mp_p <-> Pointer to the memory pool. If NULL then it will do a
* normal free.
*
* addr <-> Address to free.
*
* size -> Size of the address being freed.
*/
static int free_mem(mpool_t *mp_p, void *addr, const unsigned long size)
{
unsigned long old_size, fence;
int ret;
mpool_block_t *block_p;
/*
* If the size is larger than a block then the allocation must be at
* the front of the block.
*/
if (size > MAX_BLOCK_USER_MEMORY(mp_p)) {
block_p = (mpool_block_t *)((char *)addr - sizeof(mpool_block_t));
if (block_p->mb_magic != BLOCK_MAGIC
|| block_p->mb_magic2 != BLOCK_MAGIC) {
return MPOOL_ERROR_POOL_OVER;
}
}
/* make sure we have enough bytes */
if (size < MIN_ALLOCATION) {
old_size = MIN_ALLOCATION;
}
else {
old_size = size;
}
/* if we are packing the pool smaller */
if (BIT_IS_SET(mp_p->mp_flags, MPOOL_FLAG_NO_FREE)) {
fence = 0;
}
else {
/* find the user's magic numbers if they were written */
ret = check_magic(addr, old_size);
if (ret != MPOOL_ERROR_NONE) {
return ret;
}
fence = FENCE_SIZE;
}
/* now we free the pointer */
ret = free_pointer(mp_p, addr, old_size + fence);
if (ret != MPOOL_ERROR_NONE) {
return ret;
}
mp_p->mp_user_alloc -= old_size;
/* adjust our stats */
mp_p->mp_alloc_c--;
return MPOOL_ERROR_NONE;
}
开发者ID:FrancisHe,项目名称:256_source,代码行数:73,代码来源:mpool.c
注:本文中的check_magic函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论