void vCreateAndVerifySampleFiles( void ) { unsigned char ucStatus; /* First create the volume. */ ucStatus = f_initvolume( ram_initfunc ); /* It is expected that the volume is not formatted. */ if( ucStatus == F_ERR_NOTFORMATTED ) { /* Format the created volume. */ ucStatus = f_format( F_FAT12_MEDIA ); } if( ucStatus == F_NO_ERROR ) { /* Create a set of files using f_write(). */ prvCreateDemoFilesUsing_f_write(); /* Read back and verify the files that were created using f_write(). */ prvVerifyDemoFileUsing_f_read(); /* Create sub directories two deep then create a file using putc. */ prvCreateDemoFileUsing_f_putc(); /* Read back and verify the file created by prvCreateDemoFileUsing_f_putc(). */ prvVerifyDemoFileUsing_f_getc(); } }
int Writer(int num) { char buf[1024]; char tempstr[80]; sorted = sort_top(tmptop); dog = 0; while (sorted) { dog++; if (num == 1) sprintf(tempstr, "%llu", pmc[sorted->num].Uploadbytes); if (num == 2) sprintf(tempstr, "%llu", pmc[sorted->num].Monthlybytes); strcpy(tempstr, f_format(tempstr)); sprintf(buf, " %3d %-24s %20s\n", dog, pmc[sorted->num].User, tempstr); fputs(buf, month_blt); sorted = sorted->next; } return 0; }
/* * call-seq: * cmp.inspect -> string * * Returns the value as a string for inspection. * * Complex(2).inspect #=> "(2+0i)" * Complex('-8/6').inspect #=> "((-4/3)+0i)" * Complex('1/2i').inspect #=> "(0+(1/2)*i)" * Complex(0, Float::INFINITY).inspect #=> "(0+Infinity*i)" * Complex(Float::NAN, Float::NAN).inspect #=> "(NaN+NaN*i)" */ static VALUE nucomp_inspect(VALUE self) { VALUE s; s = rb_usascii_str_new2("("); rb_str_concat(s, f_format(self, rb_inspect)); rb_str_cat2(s, ")"); return s; }
/* * call-seq: * rat.inspect -> string * * Returns the value as a string for inspection. * * For example: * * Rational(2).inspect #=> "(2/1)" * Rational(-8, 6).inspect #=> "(-4/3)" * Rational('0.5').inspect #=> "(1/2)" */ static VALUE nurat_inspect(VALUE self, SEL sel) { VALUE s; s = rb_usascii_str_new2("("); rb_str_concat(s, f_format(self, f_inspect)); rb_str_cat2(s, ")"); return s; }
GSN_STATUS App_FsInit(APP_FS_T *pFsCtx) { UINT32 memsize, memsize1; INT32 rc; UINT8 *pFsBuff, *pFsBuff1; pPartn_0_Info = &pFsCtx->partn[APP_FS_PARTN_CONFIG]; pPartn_1_Info = &pFsCtx->partn[APP_FS_PARTN_WEB_PAGES]; f_init(); f_enterFS(); App_ConfigPartnInfoSet(pFsCtx); /*Initialise Partition 0 (used cof storing configuration)*/ memsize = fs_getmem_flashdrive(fs_phy_nor_n25q_32mb_3v_65nm_0); pFsBuff = gsn_malloc(memsize); if(pFsBuff != NULL) { rc = f_mountdrive(0, pFsBuff, memsize, (void *)fs_mount_flashdrive, fs_phy_nor_n25q_32mb_3v_65nm_0); if(rc == F_ERR_NOTFORMATTED) { f_format(0); } } else { while(1); } #ifdef ADK_PROV_ENABLE/* Initialise Appropriate Web Pages Partition */ App_WebPagesPartnInfoSet(pFsCtx); memsize1 = fs_getmem_flashdrive(fs_phy_nor_n25q_32mb_3v_65nm_1); pFsBuff1 = gsn_malloc(memsize1); if(pFsBuff != NULL) { rc = f_mountdrive(1, pFsBuff1, memsize1, (void *)fs_mount_flashdrive, fs_phy_nor_n25q_32mb_3v_65nm_1); if(rc == F_ERR_NOTFORMATTED) { return GSN_FAILURE; } } else { while(1); } #endif return GSN_SUCCESS; }
/* Format the media in drive number 'driveno' Returns 0 for success and error code for failure. */ int fs_hfat_format (int driveno) { int ret; uint32 blocks; uint16 bytes_per_block; uint32 total_mb = 0; /* Unprotect memory * Due to the time taken to format we do not grab the global lock * which allows other threads to operate concurrently if using flash. * In lieu of this we must first unprotect the memory segment before * we operate on the HFAT protected memory region. */ fs_efs2_unprotect_memory (); /* We don't yet have an initialized drive. */ ret = f_initvolume (driveno, hfat_device_init, driveno); /* An error indicating Not Formatted is OK */ if ((ret != F_NO_ERROR) && (ret != F_ERR_NOTFORMATTED)) goto cleanup; /* Now we have an initialized volume.. Get the size. */ ret = hotplug_dev_get_size (hotplug_hdev (driveno), &blocks, &bytes_per_block); /* HFAT only works with block sizes of 512 bytes */ if (bytes_per_block == 512) total_mb = (blocks / (1024 / bytes_per_block)) / 1024; else ret = F_ERR_INVALIDDRIVE; /* Look at media size to determine FAT type */ if (ret == 0) { int ftype = total_mb <= 64 ? F_FAT12_MEDIA : (total_mb <= 2048 ? F_FAT16_MEDIA : F_FAT32_MEDIA); ret = f_format (driveno, ftype); } /* Discard the volume */ (void) f_delvolume (driveno); cleanup: /* Protect memory again */ fs_efs2_protect_memory (); return hfat_to_efs_err (ret); }
PRIVATE UINT8 AppS2wCmd_erasePartn(UINT8 *ptr) { UINT8 *p; UINT32 partn; p = AppS2wParse_NextParamGet(&ptr); if (!p) { return S2W_EINVAL; } AppS2wParse_Int(p, (UINT32 *)&partn); f_format(partn); return S2W_SUCCESS; }
/* * call-seq: * cmp.to_s -> string * * Returns the value as a string. * * Complex(2).to_s #=> "2+0i" * Complex('-8/6').to_s #=> "-4/3+0i" * Complex('1/2i').to_s #=> "0+1/2i" * Complex(0, Float::INFINITY).to_s #=> "0+Infinity*i" * Complex(Float::NAN, Float::NAN).to_s #=> "NaN+NaN*i" */ static VALUE nucomp_to_s(VALUE self) { return f_format(self, rb_String); }
/* * call-seq: * cmp.to_s -> string * * Returns the value as a string. */ static VALUE nucomp_to_s(VALUE self) { return f_format(self, f_to_s); }
/* * call-seq: * rat.to_s -> string * * Returns the value as a string. * * For example: * * Rational(2).to_s #=> "2/1" * Rational(-8, 6).to_s #=> "-4/3" * Rational('0.5').to_s #=> "1/2" */ static VALUE nurat_to_s(VALUE self, SEL sel) { return f_format(self, f_to_s); }