本文整理汇总了C++中MSG函数的典型用法代码示例。如果您正苦于以下问题:C++ MSG函数的具体用法?C++ MSG怎么用?C++ MSG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MSG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new_part_tab
int new_part_tab(u8 *buf)
{
DM_PARTITION_INFO_PACKET *dm_part= (DM_PARTITION_INFO_PACKET *)buf;
int part_num,change_index,i;
int retval;
int pageoffset;
int start_addr=total_size+BLOCK_SIZE;
int current_addr=0;
pi.pt_changed =0;
pi.tool_or_sd_update = 1;
MSG (INIT, "new_pt par_nub enter \n");
//the first image is ?
for(part_num=0;part_num<PART_MAX_COUNT;part_num++)
{
memcpy(new_part[part_num].name,dm_part->part_info[part_num].part_name,MAX_PARTITION_NAME_LEN);
new_part[part_num].offset=dm_part->part_info[part_num].start_addr;
new_part[part_num].size=dm_part->part_info[part_num].part_len;
new_part[part_num].mask_flags=0;
//MSG (INIT, "DM_PARTITION_INFO_PACKET %s size %x %x \n",dm_part->part_info[part_num].part_name,dm_part->part_info[part_num].part_len,part_num);
MSG (INIT, "new_pt %s size %x \n",new_part[part_num].name,new_part[part_num].size);
if(dm_part->part_info[part_num].part_len ==0)
{
MSG (INIT, "new_pt last %x \n",part_num);
break;
}
}
MSG (INIT, "new_pt par_nub %x \n",part_num);
#if 1
//++++++++++for test
#if 0
part_num=13;
memcpy(&new_part[0],&lastest_part[0],sizeof(new_part));
MSG (INIT, "new_part %x size \n",sizeof(new_part));
for(i=0;i<part_num;i++)
{
MSG (INIT, "npt partition %s size \n",new_part[i].name);
//MSG (INIT, "npt %x size \n",new_part[i].offset);
//MSG (INIT, "npt %x size \n",lastest_part[i].offset);
//MSG (INIT, "npt %x size \n",new_part[i].size);
dm_part->part_info[5].part_visibility =1;
dm_part->part_info[5].dl_selected =1;
new_part[5].size = lastest_part[5].size+0x100000;
}
#endif
//------------for test
//Find the first changed partition, whether is visible
for(change_index=0;change_index<=part_num;change_index++)
{
if((new_part[change_index].size!=lastest_part[change_index].size)||(new_part[change_index].offset!=lastest_part[change_index].offset))
{
MSG (INIT, "new_pt %x size changed from %x to %x\n",change_index,lastest_part[change_index].size,new_part[change_index].size);
pi.pt_changed =1;
break;
}
}
if(pi.pt_changed==1)
{
//Is valid image update
for(i=change_index;i<=part_num;i++)
{
if(dm_part->part_info[i].dl_selected==0&&dm_part->part_info[i].part_visibility==1)
{
MSG (INIT, "Full download is need %x \n",i);
retval=DM_ERR_NO_VALID_TABLE;
return retval;
}
}
pageoffset=find_empty_page_from_top(start_addr);
//download partition used the new partition
//write mirror at the same 2 page
memset(page_buf,0xFF,PAGE_SIZE+64);
*(int *)sig_buf = MPT_SIG;
memcpy(page_buf,&sig_buf,PT_SIG_SIZE);
memcpy(&page_buf[PT_SIG_SIZE],&new_part[0],sizeof(new_part));
memcpy(&page_buf[PAGE_SIZE],&sig_buf,PT_SIG_SIZE);
pi.sequencenumber+=1;
memcpy(&page_buf[PAGE_SIZE+PT_SIG_SIZE],&pi,PT_SIG_SIZE);
#if 0
for(i=0;i<8;i++)
{
MSG (INIT, "%x\n",page_buf[i]);
}
#endif
if(pageoffset!=0xFFFF)
{
if((pageoffset%2)!=0)
{
MSG (INIT, "new_pt mirror block may destroy last time%x\n",pageoffset);
pageoffset+=1;
}
for(i=0;i<2;i++)
{
current_addr=start_addr+(pageoffset+i)*PAGE_SIZE;
if(!mtk_nand_write_page_hwecc(current_addr, page_buf))
//.........这里部分代码省略.........
示例2: MSG
int FolderTree::GetTypeAndName(string &strType, string &strName)
{
strType = MSG(MFolderTreeType);
strName.Clear();
return MODALTYPE_FINDFOLDER;
}
示例3: ghost_start
void ghost_start(const char * ghost_addr, const char * ghost_port)
{
/* You cannot start a running ghost listener.*/
if (ghost_run) return;
int i; /* loop variable and temporary variable for return value */
struct addrinfo addresses;
struct addrinfo *result; /* store result of getaddrinfo */
struct addrinfo *q; /* pointer to move into *result data */
char host_name[64];
char port_name[64];
memset(&addresses, 0, sizeof addresses);
addresses.ai_family = AF_UNSPEC; /* should handle IP v4 or v6 automatically */
addresses.ai_socktype = SOCK_DGRAM;
/* Get the credentials for this server. */
i = getaddrinfo(ghost_addr, ghost_port, &addresses, &result);
if (i != 0)
{ MSG("ERROR: [up] getaddrinfo on address %s (PORT %s) returned %s\n", ghost_addr, ghost_port, gai_strerror(i));
exit(EXIT_FAILURE); }
/* try to open socket for ghost listener */
for (q=result; q!=NULL; q=q->ai_next)
{ sock_ghost = socket(q->ai_family, q->ai_socktype,q->ai_protocol);
if (sock_ghost == -1) continue; /* try next field */
else break; }
/* See if the connection was a success, if not, this is a permanent failure */
if (q == NULL)
{ MSG("ERROR: [down] failed to open socket to any of server %s addresses (port %s)\n", ghost_addr, ghost_port);
i = 1;
for (q=result; q!=NULL; q=q->ai_next)
{ getnameinfo(q->ai_addr, q->ai_addrlen, host_name, sizeof host_name, port_name, sizeof port_name, NI_NUMERICHOST);
MSG("INFO: [down] result %i host:%s service:%s\n", i, host_name, port_name);
++i; }
exit(EXIT_FAILURE); }
/* connect so we can send/receive packet with the server only */
i = connect(sock_ghost, q->ai_addr, q->ai_addrlen);
if (i != 0) {
MSG("ERROR: [down] connect returned %s\n", strerror(errno));
exit(EXIT_FAILURE); }
freeaddrinfo(result);
/* set the circular buffer pointers to the beginning */
ghst_bgn = 0;
ghst_end = 0;
/* spawn thread to manage ghost connection */
ghost_run = true;
i = pthread_create( &thrid_ghost, NULL, (void * (*)(void *))thread_ghost, NULL);
if (i != 0)
{ MSG("ERROR: [main] impossible to create ghost thread\n");
exit(EXIT_FAILURE); }
/* We are done here, ghost thread is initialized and should be running by now. */
}
示例4: main
/*
|| Standard main
*/
int
main( int argc, char *argv[] )
{
char *pgmname; /* prog name in host format */
char *pgm; /* less any extension (.ext) */
char msgbuf[512]; /* message build work area */
FILE *outf;
int rc;
int i;
char pathname[MAX_PATH];
char *strtok_str = NULL;
/* Set program name */
if ( argc > 0 )
{
if ( strlen(argv[0]) == 0 )
{
pgmname = strdup( UTILITY_NAME );
}
else
{
char path[MAX_PATH];
#if defined( _MSVC_ )
GetModuleFileName( NULL, path, MAX_PATH );
#else
strncpy( path, argv[0], sizeof( path ) );
#endif
pgmname = strdup(basename(path));
#if !defined( _MSVC_ )
strncpy( path, argv[0], sizeof(path) );
#endif
}
}
else
{
pgmname = strdup( UTILITY_NAME );
}
pgm = strtok_r( strdup(pgmname), ".", &strtok_str);
INITIALIZE_UTILITY( pgmname );
/* Display the program identification message */
MSGBUF( msgbuf, MSG_C( HHC02499, "I", pgm, "Extract Files from AWS, HET or FAKETAPE" ) );
display_version (stderr, msgbuf+10, FALSE);
/*
|| Process option switches
*/
while( TRUE )
{
rc = getopt( argc, argv, "abhnsu" );
if( rc == -1 )
{
break;
}
switch( rc )
{
case 'a':
opts.flags |= O_ASCII;
set_codepage(NULL);
break;
case 'h':
usage( pgm );
exit( 1 );
break;
case 'n':
opts.flags |= O_NL;
break;
case 's':
opts.flags |= O_STRIP;
break;
case 'u':
opts.flags |= O_UNBLOCK;
break;
default:
usage( pgm );
exit( 1 );
break;
}
}
/*
|| Calc number of non-switch arguments
*/
argc -= optind;
/*
|| We must have at least the first 3 parms
*/
if(argc < 3)
{
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
sigaction( SIGQUIT, &sigact, NULL );
sigaction( SIGINT, &sigact, NULL );
sigaction( SIGTERM, &sigact, NULL );
/* Board config */
memset(&boardconf, 0, sizeof(boardconf));
boardconf.lorawan_public = true;
boardconf.clksrc = 1; /* Radio B is source by default */
lgw_board_setconf(boardconf);
/* RF config */
memset(&rfconf, 0, sizeof(rfconf));
rfconf.enable = true;
rfconf.freq_hz = freq_hz;
rfconf.rssi_offset = DEFAULT_RSSI_OFFSET;
rfconf.type = radio_type;
rfconf.tx_enable = true;
rfconf.tx_notch_freq = tx_notch_freq;
lgw_rxrf_setconf(TX_RF_CHAIN, rfconf);
/* Tx gain LUT */
memset(&txlut, 0, sizeof txlut);
txlut.size = 1;
txlut.lut[0].dig_gain = g_dig;
txlut.lut[0].pa_gain = g_pa;
txlut.lut[0].dac_gain = g_dac;
txlut.lut[0].mix_gain = g_mix;
txlut.lut[0].rf_power = 0;
lgw_txgain_setconf(&txlut);
/* Start the concentrator */
i = lgw_start();
if (i == LGW_HAL_SUCCESS) {
MSG("INFO: concentrator started, packet can be sent\n");
} else {
MSG("ERROR: failed to start the concentrator\n");
return EXIT_FAILURE;
}
/* fill-up payload and parameters */
memset(&txpkt, 0, sizeof(txpkt));
txpkt.freq_hz = freq_hz;
txpkt.tx_mode = IMMEDIATE;
txpkt.rf_chain = TX_RF_CHAIN;
txpkt.rf_power = 0;
if (strcmp(mod, "FSK") == 0) {
txpkt.modulation = MOD_FSK;
txpkt.datarate = br_kbps * 1e3;
} else {
txpkt.modulation = MOD_LORA;
switch (bw_khz) {
case 125: txpkt.bandwidth = BW_125KHZ; break;
case 250: txpkt.bandwidth = BW_250KHZ; break;
case 500: txpkt.bandwidth = BW_500KHZ; break;
default:
MSG("ERROR: invalid 'bw' variable\n");
return EXIT_FAILURE;
}
switch (sf) {
case 7: txpkt.datarate = DR_LORA_SF7; break;
case 8: txpkt.datarate = DR_LORA_SF8; break;
case 9: txpkt.datarate = DR_LORA_SF9; break;
case 10: txpkt.datarate = DR_LORA_SF10; break;
case 11: txpkt.datarate = DR_LORA_SF11; break;
case 12: txpkt.datarate = DR_LORA_SF12; break;
default:
示例6: ShowConsoleTitle
int FileViewer::ProcessKey(int Key)
{
if (RedrawTitle && (((unsigned int)Key & 0x00ffffff) < KEY_END_FKEY || IsInternalKeyReal((unsigned int)Key & 0x00ffffff)))
ShowConsoleTitle();
if (Key!=KEY_F3 && Key!=KEY_IDLE)
F3KeyOnly=false;
switch (Key)
{
#if 0
/* $ 30.05.2003 SVS
Фича :-) Shift-F4 в редакторе/вьювере позволяет открывать другой редактор/вьювер
Пока закомментим
*/
case KEY_SHIFTF4:
{
if (!Opt.OnlyEditorViewerUsed)
CtrlObject->Cp()->ActivePanel->ProcessKey(Key);
return TRUE;
}
#endif
/* $ 22.07.2000 tran
+ выход по ctrl-f10 с установкой курсора на файл */
case KEY_CTRLF10:
case KEY_RCTRLF10:
{
if (View.isTemporary())
{
return TRUE;
}
SaveScreen Sc;
string strFileName;
View.GetFileName(strFileName);
CtrlObject->Cp()->GoToFile(strFileName);
RedrawTitle = TRUE;
return (TRUE);
}
// $ 15.07.2000 tran + CtrlB switch KeyBar
case KEY_CTRLB:
case KEY_RCTRLB:
Opt.ViOpt.ShowKeyBar=!Opt.ViOpt.ShowKeyBar;
if (Opt.ViOpt.ShowKeyBar)
ViewKeyBar.Show();
else
ViewKeyBar.Hide0(); // 0 mean - Don't purge saved screen
Show();
KeyBarVisible = Opt.ViOpt.ShowKeyBar;
return (TRUE);
case KEY_CTRLSHIFTB:
case KEY_RCTRLSHIFTB:
{
Opt.ViOpt.ShowTitleBar=!Opt.ViOpt.ShowTitleBar;
TitleBarVisible = Opt.ViOpt.ShowTitleBar;
Show();
return (TRUE);
}
case KEY_CTRLO:
case KEY_RCTRLO:
if (!Opt.OnlyEditorViewerUsed)
{
if (FrameManager->ShowBackground())
{
SetCursorType(FALSE,0);
WaitKey();
FrameManager->RefreshFrame();
}
}
return TRUE;
case KEY_F3:
case KEY_NUMPAD5: case KEY_SHIFTNUMPAD5:
if (F3KeyOnly)
return TRUE;
case KEY_ESC:
case KEY_F10:
FrameManager->DeleteFrame();
return TRUE;
case KEY_F6:
if (!DisableEdit)
{
UINT cp=View.VM.CodePage;
string strViewFileName;
View.GetFileName(strViewFileName);
File Edit;
while(!Edit.Open(strViewFileName, FILE_READ_DATA, FILE_SHARE_READ|(Opt.EdOpt.EditOpenedForWrite?FILE_SHARE_WRITE:0), nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN))
{
if(!OperationFailed(strViewFileName, MEditTitle, MSG(MEditCannotOpen), false))
continue;
else
return TRUE;
}
//.........这里部分代码省略.........
示例7: main
int main(int argc, char **argv) {
int i = 0;
thread_data_t *td_arr;
GASNET_Safe(gasnet_init(&argc, &argv));
GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET));
mynode = gasnet_mynode();
nodes = gasnet_nodes();
if (argc > 1) iters = atoi(argv[1]);
if (!iters) iters = 10000;
#if GASNET_PAR
test_init("testteambarrier", 2, "(iters) (threadcount) (test sections)");
if (argc > 2) {
threads_per_node = atoi(argv[2]);
} else {
if (gasnett_getenv_yesno_withdefault("GASNET_TEST_POLITE_SYNC",0)) {
/* May overcommit only if somebody already expected it */
threads_per_node = gasnett_cpu_count();
} else {
threads_per_node = gasnett_cpu_count() / TEST_LOCALPROCS();
}
threads_per_node = MIN(threads_per_node, 8);
threads_per_node = test_thread_limit(threads_per_node);
threads_per_node = MAX(threads_per_node, 1);
}
if (threads_per_node > TEST_MAXTHREADS || threads_per_node < 1) {
printf("ERROR: Threads must be between 1 and %d\n", TEST_MAXTHREADS);
exit(EXIT_FAILURE);
}
if (argc > 3) TEST_SECTION_PARSE(argv[3]);
if (argc > 4) test_usage();
#else
test_init("testteambarrier", 1, "(iters) (test sections)");
threads_per_node = 1;
if (argc > 3) test_usage();
if (argc > 2) TEST_SECTION_PARSE(argv[2]);
#endif
TEST_SET_WAITMODE(threads_per_node);
td_arr = (thread_data_t*) test_malloc(sizeof(thread_data_t)*threads_per_node);
for(i=0; i<threads_per_node; i++) {
td_arr[i].my_local_thread = i;
td_arr[i].mythread = mynode*threads_per_node+i;
}
#if GASNET_PAR
test_createandjoin_pthreads(threads_per_node, &thread_main, td_arr, sizeof(thread_data_t));
#else
thread_main(&td_arr[0]);
#endif
test_free(td_arr);
gasnet_coll_barrier_notify(GASNET_TEAM_ALL, 0, GASNET_BARRIERFLAG_ANONYMOUS);
GASNET_Safe(gasnet_coll_barrier_wait(GASNET_TEAM_ALL, 0, GASNET_BARRIERFLAG_ANONYMOUS));
MSG("done.");
gasnet_exit(0);
return 0;
}
示例8: femu_hw_WritePageWithLayout
static int femu_hw_WritePageWithLayout(uffs_Device *dev, u32 block, u32 page,
const u8 *data, int data_len, const u8 *ecc, const uffs_TagStore *ts)
{
int written;
int abs_page;
int full_page_size;
uffs_FileEmu *emu;
struct uffs_StorageAttrSt *attr = dev->attr;
u8 spare[UFFS_MAX_SPARE_SIZE];
u8 ecc_buf[UFFS_MAX_ECC_SIZE];
int spare_len;
emu = (uffs_FileEmu *)(dev->attr->_private);
if (!emu || !(emu->fp)) {
goto err;
}
abs_page = attr->pages_per_block * block + page;
full_page_size = attr->page_data_size + attr->spare_size;
if (data && data_len > 0) {
if (data_len > attr->page_data_size)
goto err;
emu->em_monitor_page[abs_page]++;
if (emu->em_monitor_page[abs_page] > PAGE_DATA_WRITE_COUNT_LIMIT) {
MSG("Warrning: block %d page %d exceed it's maximum write time!", block, page);
goto err;
}
fseek(emu->fp, abs_page * full_page_size, SEEK_SET);
written = fwrite(data, 1, data_len, emu->fp);
if (written != data_len) {
MSG("write page I/O error ?");
goto err;
}
dev->st.page_write_count++;
dev->st.io_write += written;
}
if (ts) {
emu->em_monitor_spare[abs_page]++;
if (emu->em_monitor_spare[abs_page] > PAGE_SPARE_WRITE_COUNT_LIMIT) {
MSG("Warrning: block %d page %d (spare) exceed it's maximum write time!", block, page);
goto err;
}
if (!uffs_Assert(data != NULL, "BUG: Write spare without data ?"))
goto err;
uffs_EccMake(data, data_len, ecc_buf);
uffs_FlashMakeSpare(dev, ts, ecc_buf, spare);
spare_len = dev->mem.spare_data_size;
fseek(emu->fp, abs_page * full_page_size + attr->page_data_size, SEEK_SET);
written = fwrite(spare, 1, spare_len, emu->fp);
if (written != spare_len) {
MSG("write spare I/O error ?");
goto err;
}
dev->st.spare_write_count++;
dev->st.io_write += written;
}
if (data == NULL && ts == NULL) {
// mark bad block
fseek(emu->fp, abs_page * full_page_size + attr->page_data_size + attr->block_status_offs, SEEK_SET);
written = fwrite("\0", 1, 1, emu->fp);
if (written != 1) {
MSG("write bad block mark I/O error ?");
goto err;
}
dev->st.io_write++;
}
fflush(emu->fp);
return UFFS_FLASH_NO_ERR;
err:
fflush(emu->fp);
return UFFS_FLASH_IO_ERR;
}
示例9: list_version
void list_version(void)
{
int i;
int first;
char *s = "";
// When adding features here, don't forget to update the list of
// internal variables in eval.c!
MSG(longVersion);
// Print the list of patch numbers if there is at least one.
// Print a range when patches are consecutive: "1-10, 12, 15-40, 42-45"
if (included_patches[0] != 0) {
MSG_PUTS(_("\nIncluded patches: "));
first = -1;
// find last one
for (i = 0; included_patches[i] != 0; ++i) {}
while (--i >= 0) {
if (first < 0) {
first = included_patches[i];
}
if ((i == 0) || (included_patches[i - 1] != included_patches[i] + 1)) {
MSG_PUTS(s);
s = ", ";
msg_outnum((long)first);
if (first != included_patches[i]) {
MSG_PUTS("-");
msg_outnum((long)included_patches[i]);
}
first = -1;
}
}
}
// Print the list of extra patch descriptions if there is at least one.
if (extra_patches[0] != NULL) {
MSG_PUTS(_("\nExtra patches: "));
s = "";
for (i = 0; extra_patches[i] != NULL; ++i) {
MSG_PUTS(s);
s = ", ";
MSG_PUTS(extra_patches[i]);
}
}
#ifdef MODIFIED_BY
MSG_PUTS("\n");
MSG_PUTS(_("Modified by "));
MSG_PUTS(MODIFIED_BY);
#endif // ifdef MODIFIED_BY
#ifdef HAVE_PATHDEF
if ((*compiled_user != NUL) || (*compiled_sys != NUL)) {
MSG_PUTS(_("\nCompiled "));
if (*compiled_user != NUL) {
MSG_PUTS(_("by "));
MSG_PUTS(compiled_user);
}
if (*compiled_sys != NUL) {
MSG_PUTS("@");
MSG_PUTS(compiled_sys);
}
}
#endif // ifdef HAVE_PATHDEF
MSG_PUTS(_("\nHuge version "));
MSG_PUTS(_("without GUI."));
version_msg(_(" Features included (+) or not (-):\n"));
list_features();
#ifdef SYS_VIMRC_FILE
version_msg(_(" system vimrc file: \""));
version_msg(SYS_VIMRC_FILE);
version_msg("\"\n");
#endif // ifdef SYS_VIMRC_FILE
#ifdef USR_VIMRC_FILE
version_msg(_(" user vimrc file: \""));
version_msg(USR_VIMRC_FILE);
version_msg("\"\n");
#endif // ifdef USR_VIMRC_FILE
#ifdef USR_VIMRC_FILE2
version_msg(_(" 2nd user vimrc file: \""));
version_msg(USR_VIMRC_FILE2);
version_msg("\"\n");
#endif // ifdef USR_VIMRC_FILE2
#ifdef USR_VIMRC_FILE3
version_msg(_(" 3rd user vimrc file: \""));
version_msg(USR_VIMRC_FILE3);
version_msg("\"\n");
#endif // ifdef USR_VIMRC_FILE3
#ifdef USR_EXRC_FILE
//.........这里部分代码省略.........
示例10: femu_hw_ReadPageWithLayout
static URET femu_hw_ReadPageWithLayout(uffs_Device *dev, u32 block, u32 page, u8* data, int data_len, u8 *ecc,
uffs_TagStore *ts, u8 *ecc_store)
{
int nread;
uffs_FileEmu *emu;
int abs_page;
int full_page_size;
struct uffs_StorageAttrSt *attr = dev->attr;
unsigned char status;
u8 spare[UFFS_MAX_SPARE_SIZE];
int spare_len;
emu = (uffs_FileEmu *)(dev->attr->_private);
if (!emu || !(emu->fp)) {
goto err;
}
abs_page = attr->pages_per_block * block + page;
full_page_size = attr->page_data_size + attr->spare_size;
if (data && data_len > 0) {
if (data_len > attr->page_data_size)
goto err;
fseek(emu->fp, abs_page * full_page_size, SEEK_SET);
nread = fread(data, 1, data_len, emu->fp);
if (nread != data_len) {
MSG("read page I/O error ?");
goto err;
}
dev->st.io_read += nread;
dev->st.page_read_count++;
if (ecc) {
// calculate ECC for data
uffs_EccMake(data, data_len, ecc);
}
}
if (ts) {
spare_len = dev->mem.spare_data_size;
fseek(emu->fp, abs_page * full_page_size + attr->page_data_size, SEEK_SET);
nread = fread(spare, 1, spare_len, emu->fp);
if (nread != spare_len) {
MSG("read page spare I/O error ?");
goto err;
}
// unload ts and ecc from spare
uffs_FlashUnloadSpare(dev, spare, ts, ecc_store);
dev->st.io_read += nread;
dev->st.spare_read_count++;
}
if (data == NULL && ts == NULL) {
// read bad block mark
fseek(emu->fp, abs_page * full_page_size + attr->page_data_size + attr->block_status_offs, SEEK_SET);
nread = fread(&status, 1, 1, emu->fp);
if (nread != 1) {
MSG("read badblock mark I/O error ?");
goto err;
}
dev->st.io_read++;
return status == 0xFF ? UFFS_FLASH_NO_ERR : UFFS_FLASH_BAD_BLK;
}
return UFFS_FLASH_NO_ERR;
err:
return UFFS_FLASH_IO_ERR;
}
示例11: ReadPrefs
/* Retrieve preferences from the Preferences database */
void ReadPrefs( void )
{
Int16 version;
Int16 oldVersion;
UInt16 prefSize;
UInt16 oldPrefSize;
ASSERT( ViewerPrefID != ViewerPrefSearchStringID );
/* if not a test version remove preferences with ID 0 */
if ( ViewerPrefID != 0 )
RemovePref( 0 );
MemSet( &pref, sizeof( Preferences ), 0 );
/* if no preference found or the found preference has a "bad" size
and there is no preference using an old (incompatible) format,
then initialize a new preference structure */
prefSize = 0;
version = PrefGetAppPreferences( (UInt32) ViewerAppID,
(UInt16) ViewerPrefID, NULL, &prefSize, true);
if ( version == noPreferenceFound || sizeof( Preferences ) < prefSize ) {
MSG( _( "Version = %d, prefSize = %u\n", version, prefSize ) );
oldPrefSize = 0;
oldVersion = PrefGetAppPreferences( (UInt32) ViewerAppID,
(UInt16) ViewerOldPrefID, NULL, &oldPrefSize, true);
if ( oldVersion == noPreferenceFound ) {
MSG( "No old preferences found\n" );
pref.column.date = SHOW;
pref.column.size = SHOW;
pref.column.type = SHOW;
pref.strikethrough = false;
pref.defaultStrikethrough = false;
pref.multipleSelect = true;
pref.hardKeys = false;
pref.arrowKeys = false;
pref.searchFlags = 0;
pref.toolbar = TOOLBAR_TOP;
pref.lastForm = frmLibrary;
pref.scrollbar = SCROLLBAR_RIGHT;
pref.controlMode = MODE1;
pref.screenDepth = 0;
pref.searchEntries = 0;
pref.categories = dmAllCategoriesAdvanced;
pref.cardNo = 0;
pref.toolbarButton = 0;
pref.filterMode = FILTER_OR;
pref.fontModeMain = FONT_DEFAULT;
pref.underlineMode = false;
pref.defaultUnderlineMode = false;
pref.sortType = SORT_NAME;
pref.sortOrder = SORTORDER_ASC;
pref.autoscrollEnabled = false;
pref.autoscrollInterval = 0;
pref.autoscrollLastScrollTime = 0;
pref.autoscrollJump = 1;
pref.autoscrollMode = AUTOSCROLL_PIXELS;
pref.autoscrollDir = AUTOSCROLL_DOWN;
pref.autoscrollStayOn = false;
pref.location = RAM;
pref.gestures = true;
pref.gestMode[ GESTURES_UP ] = SELECT_GO_TO_TOP;
pref.gestMode[ GESTURES_RIGHT ] = SELECT_GO_FORWARD;
pref.gestMode[ GESTURES_DOWN ] = SELECT_GO_TO_BOTTOM;
pref.gestMode[ GESTURES_LEFT ] = SELECT_GO_BACK;
pref.gestMode[ GESTURES_TAP ] = SELECT_GO_HOME;
pref.syncPolicy = SYNC_AUTOMATIC;
pref.fontModeLibrary = FONT_DEFAULT;
pref.categoryStyle = CATEGORY_ADVANCED;
pref.hardcopyAction = HARDCOPY_DIALOG;
pref.hardcopyRange = HARDCOPY_INVIEW;
pref.hardcopyLink = HARDCOPY_ATBOTTOM;
pref.lineSpacing = -MINIMAL_LINE_SPACING;
pref.paragraphSpacing = DEFAULT_PARAGRAPH_SPACING;
pref.searchMode = SEARCH_IN_ONE_PAGE;
pref.enableSoftHyphens = true;
pref.defaultEnableSoftHyphens = true;
pref.indicateOpened = false;
pref.individualDocumentLayout = false;
pref.individualDocumentFonts = false;
pref.individualDocumentColor = false;
pref.individualDocumentLookup = false;
pref.forceDefaultColors = false;
pref.defaultForceDefaultColors = false;
pref.savedToolbar = TOOLBAR_TOP;
pref.savedScrollbar = SCROLLBAR_RIGHT;
pref.savedSilkscreen = DIA_STATE_MIN;
pref.pageControlsLink = false;
pref.defaultPageControlsLink = false;
pref.forceAlign = FORCE_ALIGN_NONE;
pref.defaultForceAlign = FORCE_ALIGN_NONE;
pref.joinUpAllRecords = false;
pref.rotate = ROTATE_ZERO;
pref.defaultRotate = ROTATE_ZERO;
pref.defaultLineSpacing = pref.lineSpacing;
pref.defaultParagraphSpacing = pref.paragraphSpacing;
pref.defaultFontModeMain = pref.fontModeMain;
pref.selectedWordAction = SELECT_WORD_SEARCH_FORM;
//.........这里部分代码省略.........
示例12: update_part_tab
int update_part_tab(void)
{
int retval=0;
int retry_w;
int retry_r;
int start_addr=total_size;
int current_addr=0;
//for test
// return DM_ERR_NO_SPACE_FOUND;
memset(page_buf,0xFF,PAGE_SIZE+64);
if((pi.pt_changed==1||pi.pt_has_space==0)&&pi.tool_or_sd_update== 1)
{
MSG (INIT, "update_pt pt changes\n");
if(!mtk_nand_erase(start_addr))
{//no good block for used in replace pool
MSG (INIT, "update_pt erase failed %x\n",start_addr);
if(pi.mirror_pt_dl==0)
retval = DM_ERR_NO_SPACE_FOUND;
return retval;
}
for(retry_r=0;retry_r<RETRY_TIMES;retry_r++)
{
for(retry_w=0;retry_w<RETRY_TIMES;retry_w++)
{
current_addr = start_addr+(retry_w+retry_r*RETRY_TIMES)*PAGE_SIZE;
*(int *)sig_buf = PT_SIG;
memcpy(page_buf,&sig_buf,PT_SIG_SIZE);
memcpy(&page_buf[PT_SIG_SIZE],&new_part[0],sizeof(new_part));
memcpy(&page_buf[PAGE_SIZE],&sig_buf,PT_SIG_SIZE);
memcpy(&page_buf[PAGE_SIZE+PT_SIG_SIZE],&pi,PT_SIG_SIZE);
if(!mtk_nand_write_page_hwecc(current_addr, page_buf))
{//no good block for used in replace pool . still used the original ones
MSG (INIT, "update_pt write failed %x\n",retry_w);
memset(page_buf,0,PT_SIG_SIZE);
if(!mtk_nand_write_page_hwecc(current_addr, page_buf))
{
MSG (INIT, "write error mark failed\n");
//continue retry
continue;
}
}
else
{
MSG (INIT, "write pt success %x %x \n",current_addr,retry_w);
break; // retry_w should not count.
}
}
if(retry_w==RETRY_TIMES)
{
MSG (INIT, "update_pt retry w failed\n");
if(pi.mirror_pt_dl==0)//mirror also can not write down
{
retval = DM_ERR_NO_SPACE_FOUND;
return retval;
}
else
{
return DM_ERR_OK;
}
}
current_addr = (start_addr+(((retry_w)+retry_r*RETRY_TIMES)*PAGE_SIZE));
if(!mtk_nand_read_page_hwecc(current_addr, page_readbuf)||memcmp(page_buf,page_readbuf,PAGE_SIZE))
{
MSG (INIT, "v or r failed %x\n",retry_r);
memset(page_buf,0,PT_SIG_SIZE);
if(!mtk_nand_write_page_hwecc(current_addr,page_buf))
{
MSG (INIT, "read error mark failed\n");
//continue retryp
continue;
}
}
else
{
MSG (INIT, "update_pt r&v ok%x\n",current_addr);
break;
}
}
}
else
{
MSG (INIT, "update_pt no change \n");
}
return DM_ERR_OK;
}
示例13: ensure_op
static void ensure_op(Validator *val, MVMuint16 opcode) {
if (val->cur_info->opcode != opcode) {
fail(val, MSG(val, "expected op %s but got %s"),
MVM_op_get_op(opcode)->name, val->cur_info->name);
}
}
示例14: sendnotice
static void sendnotice(const char *d)
/* sends file pointed to by d to the address in the return-path of the */
/* message. */
{
unsigned int x,y;
const char *err;
if (qmail_open(&qq) == -1)
strerr_die2sys(111,FATAL,MSG(ERR_QMAIL_QUEUE));
fd = open_read(d);
if (fd == -1)
strerr_die2sys(111,FATAL,MSG1(ERR_OPEN,d));
substdio_fdbuf(&sstext,read,fd,textbuf,sizeof(textbuf));
if (getln(&sstext,&line,&match,'\n') == -1) die_read();
if (!match) die_read();
if (!case_startb(line.s,line.len,"return-path:")) die_read();
x = 12 + byte_chr(line.s + 12,line.len-12,'<');
y = byte_rchr(line.s + x,line.len-x,'>');
if (x != line.len && x+y != line.len) {
stralloc_copyb(&to,line.s+x+1, y-1);
stralloc_0(&to);
} else
die_read();
hdr_add2s("Mailing-List: ",MSG(TXT_MAILING_LIST));
if (listid.len > 0)
hdr_add2("List-ID: ",listid.s,listid.len);
hdr_datemsgid(when+msgnum++);
hdr_from("-help");
hdr_subject(MSG(SUB_RETURNED_POST));
hdr_add2s("To: ",to.s);
if (flagmime) {
hdr_mime(CTYPE_MULTIPART);
hdr_boundary(0);
hdr_ctype(CTYPE_TEXT);
hdr_transferenc();
} else
qmail_puts(&qq,"\n\n");
copy(&qq,"text/top",flagcd);
copy(&qq,"text/mod-timeout",flagcd);
if (flagcd == 'B') {
encodeB("",0,&line,2);
qmail_put(&qq,line.s,line.len);
}
if (flagmime) {
hdr_boundary(0);
hdr_ctype(CTYPE_MESSAGE);
qmail_puts(&qq,"\n");
}
if (seek_begin(fd) == -1)
strerr_die2sys(111,FATAL,MSG1(ERR_SEEK,d));
substdio_fdbuf(&sstext,read,fd,textbuf,sizeof(textbuf));
if (qmail_copy(&qq,&sstext,-1) != 0) die_read();
close (fd);
if (flagmime)
hdr_boundary(1);
stralloc_copy(&line,&outlocal);
stralloc_cats(&line,"[email protected]");
stralloc_cat(&line,&outhost);
stralloc_0(&line);
qmail_from(&qq,line.s); /* sender */
qmail_to(&qq,to.s);
if (*(err = qmail_close(&qq)) != '\0')
strerr_die4x(111,FATAL,MSG(ERR_TMP_QMAIL_QUEUE),": ", err + 1);
strnum[fmt_ulong(strnum,qmail_qp(&qq))] = 0;
strerr_warn2("ezmlm-clean: info: qp ",strnum,0);
}
示例15: ensure_no_remaining_jumplabels
static void ensure_no_remaining_jumplabels(Validator *val) {
if (val->remaining_jumplabels != 0)
fail(val, MSG(val, "%" PRIu32 " jumplist labels missing their goto ops"),
val->remaining_jumplabels);
}