Audio-RaveMP

 view release on metacpan or  search on metacpan

ravemp.c  view on Meta::CPAN

    }

    /* Dump data */

    XP("Block 0x%x Page 0x%x (%u %u)\n",block,page,block,page);

    for (i=0;i<PAGE_SIZE;i+=16) {

	XP("%04x  ",i);

	p = &xpage.data[i];

	hexdump_line(p);

	XP("\n");
    }

    /* Dump tag data */

    XP("TAG:  ");

    p = &xpage.tag[0];

    hexdump_line(p);

    XP("\n");
}
/******************************* hexdump_line ****************************/
static void hexdump_line(unsigned char *p)
{
    int j;

    for (j=0;j<16;j++)
	XP("%02x ",*p++);

    XP("  ");
    p -= 16;

    for (j=0;j<16;j++,p++)
	XP("%c",*p<' '||*p>=127?'.':*p);
}
/***************************** read_numbers **************************/
static int read_numbers(unsigned char *p,unsigned count,...)
{
    int i,j,arg;
    unsigned int *ip;
    va_list ap;

    va_start(ap,count);

    for (i=0;i<count;i++) {

	if (strncasecmp(p,"0x",2)==0)
	    j = sscanf(p+2,"%x",&arg);
	else
	    j = sscanf(p,"%u",&arg);

	if (j < 1)
	    break;

	/* Get argument pointer (if any) and return decoded value */

	if ((ip=va_arg(ap,unsigned int *)) != NULL)
	    *ip = arg;

	/* Skip field just processed and white space following it */

	while (isdigit(*p)||tolower(*p)=='x'|| (tolower(*p)>='a'&&tolower(*p)<='f'))
	    p++;

	while (isblank(*p))
	    p++;
    }

    return i;	/* Return number of fields decoded */
}
/********************** XPV *****************************/
static void XPV(int level,char *fmt,...)
{
    /* To be implemented... */

#if 0
    if (level < xpv_level)
	return;
#endif

}
/************************ load_fat **********************/
static int load_fat(unsigned char *fatbuff)
{
    int i;
    struct page xpage;

    memset(fatbuff,0,TOTAL_BLOCKS);

    for (i=0;i<TOTAL_BLOCKS/PAGE_SIZE;i++) {

	if (!read_page(0,i,&xpage))
	    return 0;

	memcpy(fatbuff+(i*PAGE_SIZE),xpage.data,PAGE_SIZE);
    }

    return 1;
}
/************************ store_fat **********************/

static int store_fat(unsigned char *fatbuff)
{
    int i;
    unsigned char *blkbuff;

    /* Allocate block buffer */

    if ((blkbuff=malloc(MAX_BLOCK_SIZE)) == NULL) {
	XP("Memory Allocation failure\n");
	exit();
    }

    /* Read existing FAT data block */

    if (!read_block(0,blkbuff)) {
	XP("Update failed: Couldn't read FAT\n");
	free(blkbuff);
	return 0;
    }

    if (*blkbuff != 'F') {
	XP("Failure: Pre-write FAT validation error (0x%x should be 0xx)\n",*blkbuff,'F');
	free(blkbuff);
	return 0;
    }

    /* Copy new FAT area into block */



( run in 0.544 second using v1.01-cache-2.11-cpan-9581c071862 )