• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ show_error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_no_track

int get_no_track ( char * dev )
{
	int sg_fd, k,i;
	unsigned char  header[32];
	sg_io_hdr_t io_hdr;
	struct cdrom_generic_command cgc;
	TrackData *trak_data_array,*track;
	union
	{
		struct request_sense	s;
		unsigned char		u[18];
	} _sense;


	if ( ( sg_fd=open ( dev,O_RDWR|O_NONBLOCK ) ) < 0 &&
	        ( sg_fd=open ( dev,O_RDONLY|O_NONBLOCK ) ) < 0 )
	{

		perror ( "\nerror opening given file name" );
		show_error("error opening given file name");
		return 1;
	}

	if ( ( ioctl ( sg_fd, SG_GET_VERSION_NUM, &k ) < 0 ) || ( k < 30000 ) )
	{
		printf ( "\n%s is not an sg device, or old sg driver\n",dev );
		show_error("device is not an sg device, or old sg driver");
		return 1;
	}

	memset ( &io_hdr, 0, sizeof ( sg_io_hdr_t ) );
	io_hdr.interface_id = 'S';
	io_hdr.cmd_len = 10;
	io_hdr.mx_sb_len = sizeof ( _sense );
	io_hdr.dxfer_len =32;
	io_hdr.cmdp = cgc.cmd;
	io_hdr.sbp = _sense.u;
	io_hdr.timeout = 20000;
	io_hdr.dxferp		= header;
	io_hdr.dxfer_len		= 32;
	io_hdr.dxfer_direction	= SG_DXFER_FROM_DEV;
	io_hdr.flags	= SG_FLAG_LUN_INHIBIT|SG_FLAG_DIRECT_IO;



	cgc.quiet = 1;
	cgc.sense = &_sense.s;
	cgc.cmd[0] = GPCMD_READ_DISC_INFO;	// READ DISC INFORMATION
	cgc.cmd[6] = 0;
	cgc.cmd[7] = 0;
	cgc.cmd[8] = 32;
	cgc.cmd[9] = 0;

	if ( ioctl ( sg_fd,SG_IO,&io_hdr ) ) return -1;

//	printf ( "\nREAD DISC INFORMATION:" );

	main_app->no_of_tracks=header[11]<<8|header[6] ;
//	printf ( "\nNO OF TRACKS:  %d", no_of_tracks );

	trak_data_array =calloc ( main_app->no_of_tracks,sizeof ( TrackData ) );

	for ( i=1;i<=main_app->no_of_tracks;i++ )
	{
		track=&trak_data_array[i-1];

		cgc.cmd[0] = GPCMD_READ_TRACK_RZONE_INFO;	// READ TRACK INFORMATION
		cgc.cmd[1] = 1;
		cgc.cmd[2] = i>>24;
		cgc.cmd[3] = i>>16;
		cgc.cmd[4] = i>>8;
		cgc.cmd[5] = i;
		cgc.cmd[8] =32;
		cgc.cmd[9] = 0;

		if ( ioctl ( sg_fd,SG_IO,&io_hdr ) ) return -1;
		track->track_no=i-1;
		track->track_start= header[8]<<24|header[9]<<16|header[10]<<8|header[11];

		track->track_size=header[24]<<24|header[25]<<16|header[26]<<8|header[27];
		if ( header[7]&2 )
			track->track_end=header[28]<<24|header[29]<<16|header[30]<<8|header[31];

	}
	main_app->cd_data=trak_data_array;
	close ( sg_fd );

	return 0;
}
开发者ID:kallisti5,项目名称:cd-track-reader,代码行数:89,代码来源:cd_info.c


示例2: systemcom_system_reset_format

//慎用将系统恢复到白纸状态
//35个region,编号如下
//0-4 RAID5(6+1)
//RAID6:(5+2)
//5-9:CAUCHY orginal RS
//10-14:CAUCHY RS
//15-19:EVENODD
//20-24:RDP
//25-30:LIBERATION CODE
//30-34:blaum-roth code
//建立一个7NAS和7disk的系统,客官要是不是这个配置自己改
int systemcom_system_reset_format()
{
	//format先建立device和disk的信息
	int i,disknum,devicenum,resTF;
	int pushtime,maxbuffersize;
	int multindex;
	//int chunksize;

	char *diskpath,*curdiskpath,*username,*curusername,*filename,*curfilename;

	UINT64 currentid;
	//全局变量是用于
	UINT64 *glodiskidlist,*glodeviceidlist,*glofileidlist;
	DEVICEBLOCK *glodeviceblockptr,*curglodeviceblockptr;
	DISKBLOCK *glodiskblockptr,*curglodiskblockptr;

	UINT64 *RDPdeviceid;
	DEVICEBLOCK *RDPdeviceblockptr,*curRDPdeviceblockptr;

	UINT64 *RDPdiskid;
	DISKBLOCK *RDPdiskblockptr,*curRDPdiskblockptr;

	CHUNKBLOCK *chunkblockbuffer;

	GLOPUSHLIST *pushlistptr;

	DEVICE *deviceptr,*curdeviceptr;
	DEVICEGROUP *devicegroupptr;
	

	DISK *diskptr,*curdiskptr;
	DISKGROUP *diskgroupptr;
	DISKBLOCK *diskblockptr;
	UINT64 *diskidlist;//用于记录指针
	UINT64 volumn;

	REGION *regionptr,*curregionptr;//指针和当前指针
	REGIONBLOCK *regionblockptr,*curregionblockptr;
	REGIONGROUP *regiongroupptr;
	UINT64 *regionidlist;
	int regionnum;
	UINT64 totalsize;

	USERPROFILE *userprofileptr,*curuserprofileptr;
	USERLOCATION *userlocationptr;
	USERGROUP *usergroupptr;

	IDITEM *systemnextid;

	CODEPARA *codepara;

	STRIPDES *strdes;//条带描述

	FILEMETA *filemetaptr;//计算
	FILEINF *fileinfptr;
	FILEMETAGROUP *filemetagroupptr;
	//UINT64 fileidlist;//仅仅需要记录一个即可
	//时间
	time_t rawtime;
	struct tm *Nowtime;

	int strindex,codetype;
	
	disknum=TOTDISKNUMBER;
	devicenum=TOTDEVICENUMBER;
	regionnum=TOTREGIONNUM;
	deviceptr=talloc(DEVICE,devicenum);
	if(deviceptr==NULL)
	{
		show_error("systemcom","system_reset_format","No memory");
		return FALSE;
	}
	diskptr=talloc(DISK,disknum);
	if(diskptr==NULL)
	{
		show_error("systemcom","system_reset_format","No memory");
		return FALSE;
	}
	//因为是手工初始化globaldefine可以省略
	//需要设定但是需要设定参数
	intial_kind();//初始化类别
	//设定缓冲区
	pushtime=0;
	/*chunkblockbuffer=talloc(CHUNKBLOCK,chksize_MB(4));//4G的存储器缓冲,因此4G/1K=最多4M个
	if(chunkblockbuffer==NULL)
	{
		show_error("systemcom","system_reset_format","No memory");
		return FALSE;
	}*/
//.........这里部分代码省略.........
开发者ID:swallows888,项目名称:SWALLOWFS,代码行数:101,代码来源:system_com.c


示例3: main

int main(int argc, char **argv)
{
  argv0 = argv[0];

  int opt;
  while ((opt = getopt(argc, argv, "fs:P")) != -1)
  {
    switch (opt)
    {
      case 'f':
        opt_force = 1;
        break;
      case 's':
      {
        char *endptr;
        long value;
        errno = 0;
        value = strtol(optarg, &endptr, 10);
        if (errno != 0)
          ;
        else if (endptr == optarg || *endptr != '\0')
          errno = EINVAL;
        else if (value <= 0 || (unsigned long) value >= block_size_limit)
          errno = ERANGE;
        if (errno != 0)
        {
          show_error(NULL);
          show_usage(0);
          return EXIT_FAILURE;
        }
        block_size = (size_t) value;
        break;
      }
      case 'P':
        opt_punch++;
        break;
      default:
        show_usage(0);
        return EXIT_FAILURE;
    }
  }
  if (optind >= argc)
  {
    show_usage(1);
    return EXIT_FAILURE;
  }
  buffer = malloc(block_size);
  if (buffer == NULL)
  {
    show_error(NULL);
    return 1;
  }

  int rc = 0;
  while (optind < argc)
  {
    rc |= eat(argv[optind]);
    optind++;
  }
  return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
#undef punch_opt
}
开发者ID:jwilk,项目名称:hungrycat,代码行数:62,代码来源:hungrycat.c


示例4: dah_talk_open

static int 
dah_talk_open(struct service *srv, talk_info_t *talk, 
        talk_handle_t *hdl, media_info_t *info)
{
    int ret = -1;
    dah_service_t *dah_srv;

    DH_AUDIO_FORMAT aft;
    DHDEV_TALKDECODE_INFO cur_talk_mode;

    NMP_ASSERT(srv && talk);

    memset(&aft, 0, sizeof(DH_AUDIO_FORMAT));
    memset(&cur_talk_mode, 0, sizeof(DHDEV_TALKDECODE_INFO));

    aft.byFormatTag = 0;
    aft.nChannels = 1;
    aft.nSamplesPerSec = 8000;
    aft.wBitsPerSample = 16;

    dah_srv = (dah_service_t*)srv;
    talk->handle = dah_get_user_id(&dah_srv->parm);
    if(talk->frm)
    {
        nmp_dealloc(talk->frm, sizeof(frame_t) + MAX_ENCODE_BUFFER_LEN);
        talk->frm = NULL;
    }

    talk->frm = (frame_t *)nmp_alloc0(sizeof(frame_t) + MAX_ENCODE_BUFFER_LEN);
    if(!talk->frm)
    {
        return -1;
    }
	
    if (DAH_LOGOUT == dah_get_user_id(&dah_srv->parm))
    {
        show_warn("dah device is disconnected.\n");
    }
    else
    {
        ret = CLIENT_InitAudioEncode(aft);
        if(ret != 0)
        {
            show_error("CLIENT_InitAudioEncode error ret = %d\n", ret);
            if(talk->frm)
            {
                nmp_dealloc(talk->frm, sizeof(frame_t) + MAX_ENCODE_BUFFER_LEN);
                talk->frm = NULL;
            }
            return -1;
        }

        //查询设备支持的语音对讲列表
        DHDEV_TALKFORMAT_LIST lstTalkEncode = {0};
        int nRetlen = 0;
        BOOL bSuccess = CLIENT_QueryDevState(dah_get_user_id(&dah_srv->parm), DH_DEVSTATE_TALK_ECTYPE, 
                (char*)&lstTalkEncode, sizeof(DHDEV_TALKFORMAT_LIST), &nRetlen, 2000);
        if (!(bSuccess&&nRetlen == sizeof(DHDEV_TALKFORMAT_LIST)))
        {
            show_error("query talk format failed, error = 0x%x\n", CLIENT_GetLastError());
            if(talk->frm)
            {
                nmp_dealloc(talk->frm, sizeof(frame_t) + MAX_ENCODE_BUFFER_LEN);
                talk->frm = NULL;
            }
            return -1;
        }

        ret = set_audio_attr(info, &cur_talk_mode);
        if(ret != 0)
        {
            if(talk->frm)
            {
                nmp_dealloc(talk->frm, sizeof(frame_t) + MAX_ENCODE_BUFFER_LEN);
                talk->frm = NULL;
            }
            return -1;
        }
        // 设置服务器模式语音对讲模式
        bSuccess = CLIENT_SetDeviceMode(dah_get_user_id(&dah_srv->parm), DH_TALK_ENCODE_TYPE, &cur_talk_mode);
        bSuccess = CLIENT_SetDeviceMode(dah_get_user_id(&dah_srv->parm), DH_TALK_SERVER_MODE, NULL);

        //  开始对讲
        talk->talk_handle = CLIENT_StartTalkEx(dah_get_user_id(&dah_srv->parm), 
            				(pfAudioDataCallBack)dah_audio_data_callback, (LDWORD)talk);
        if(0 != talk->talk_handle)
        {
            show_info("Start talk success! talk_handle = %d\n", (int)talk->talk_handle);
        }
        else
        {
            show_error("Start talk failed!, error = 0x%x, user_id = %d\n", 
                CLIENT_GetLastError(), dah_get_user_id(&dah_srv->parm));
            if(talk->frm)
            {
                nmp_dealloc(talk->frm, sizeof(frame_t) + MAX_ENCODE_BUFFER_LEN);
                talk->frm = NULL;
            }
            return -1;
        }
//.........这里部分代码省略.........
开发者ID:dulton,项目名称:nampu,代码行数:101,代码来源:nmp_dah_talk.cpp


示例5: compressFile

void compressFile(string & file_name, string const & ref_file_name, const int num_workers, 
	bool seq_only, bool discard_secondary_alignments) {
	int dictionary_size = 1<<23;
	int match_len_limit = 36; // equivalent to -6 option

	// const int num_workers = num_threads - 1;//max(2, num_threads - 1); // one for parsing
	const int slots_per_worker = 20;
	const int num_slots =
		( ( num_workers > 1 ) ? num_workers * slots_per_worker : 1 );

	Packet_courier courier(num_workers, num_slots);

	// open output streams
	Output_args output_args = initializeOutputStreams(file_name, seq_only, discard_secondary_alignments, &courier);

	// cerr << "Initialized output streams" << endl;

	// from plzip library implementation
	// initialize parsing thread -- pass courier, FDs for output
	Parser_args parser_args;
	parser_args.output = output_args;
	parser_args.file_name = file_name;
	parser_args.ref_file_name = ref_file_name;
	parser_args.courier = &courier;
	parser_args.seq_only = seq_only;
	parser_args.discard_secondary_alignments = discard_secondary_alignments;

	pthread_t * parser_thread = new pthread_t();
	int errcode = pthread_create( parser_thread, 0, parseSAM, &parser_args );
	if ( errcode ) { 
		show_error( "Can't create parser thread", errcode ); cleanup_and_fail(); 
	}

	// initialize worker threads
	Worker_arg worker_arg;
	worker_arg.courier = &courier;
	worker_arg.dictionary_size = dictionary_size;
	worker_arg.match_len_limit = match_len_limit;

	pthread_t * worker_threads = new( std::nothrow ) pthread_t[num_workers];
	if( !worker_threads ) { 
		cleanup_and_fail(); 
	}
	for( int i = 0; i < num_workers; ++i ) {
		errcode = pthread_create( worker_threads + i, 0, cworker, &worker_arg );
		if( errcode ) { 
			show_error( "Can't create worker threads", errcode ); cleanup_and_fail(); 
		}
	}

	// cerr << "launched threads" << endl;

	// concurrently wait for threads to return compressed packets; write them to disk
	muxer(courier);

	// join worker threads
	for( int i = num_workers - 1; i >= 0; --i ) {
		errcode = pthread_join( worker_threads[i], 0 );
		if( errcode ) { 
			show_error( "Can't join worker threads", errcode ); cleanup_and_fail(); 
		}
		else {
			// cerr << "thread " << i << " joined" << endl;
		}
	}
	delete[] worker_threads;

	// join the parser thread
	errcode = pthread_join( *parser_thread, 0 );
	if( errcode ) {
		show_error( "Can't join parser thread", errcode ); cleanup_and_fail(); 
	}

	// destructor in OutputBuffer will close file output streams
};
开发者ID:Kingsford-Group,项目名称:referee,代码行数:75,代码来源:RefereeCompress.hpp


示例6: main

int
main (int argc, char **argv)
{
	int i ; 
	char *source_dir = NULL ;
	const char *destination_dir = NULL ;
	Bool do_data = False;
	ASDocType target_type = DocType_Source ;
	/* Save our program name - for error messages */
	set_DeadPipe_handler(DeadPipe);
    InitMyApp (CLASS_ASDOCGEN, argc, argv, NULL, asdocgen_usage, 0 );
	LinkAfterStepConfig();
	InitSession();
    for( i = 1 ; i< argc ; ++i)
	{
		LOCAL_DEBUG_OUT( "argv[%d] = \"%s\", original argv[%d] = \"%s\"", i, argv[i]?argv[i]:"(null)", i, MyArgs.saved_argv[i]);	  
		if( argv[i] != NULL  )
		{
			if( (strcmp( argv[i], "-t" ) == 0 || strcmp( argv[i], "--target" ) == 0) && i+1 < argc && argv[i+1] != NULL ) 
			{
				++i ;
				if( mystrcasecmp( argv[i], "plain" ) == 0 || mystrcasecmp( argv[i], "text" ) == 0) 
					target_type = DocType_Plain ; 														   
				else if( mystrcasecmp( argv[i], "html" ) == 0 ) 
					target_type = DocType_HTML ; 														   
				else if( mystrcasecmp( argv[i], "php" ) == 0 ) 
					target_type = DocType_PHP ; 														   
				else if( mystrcasecmp( argv[i], "xml" ) == 0 ) 
					target_type = DocType_XML ; 														   
				else if( mystrcasecmp( argv[i], "nroff" ) == 0 ) 
					target_type = DocType_NROFF ; 														   
				else if( mystrcasecmp( argv[i], "source" ) == 0 ) 
					target_type = DocType_Source ; 														   
				else
					show_error( "unknown target type \"%s\"" );
			}else if( (strcmp( argv[i], "-s" ) == 0 || strcmp( argv[i], "--css" ) == 0) && i+1 < argc && argv[i+1] != NULL ) 
			{
				++i ;				
				HTML_CSS_File = argv[i] ;
			}else if( strcmp( argv[i], "--faq-css" ) == 0 && i+1 < argc && argv[i+1] != NULL ) 
			{
				++i ;				
				FAQ_HTML_CSS_File = argv[i] ;
			}else if( strcmp( argv[i], "--html-data-back" ) == 0 && i+1 < argc && argv[i+1] != NULL ) 
			{
				++i ;				
				if( strcasecmp( argv[i], "none") == 0 ) 
					HTML_DATA_BACKGROUND_File = NULL ;
				else
					HTML_DATA_BACKGROUND_File = argv[i] ;
			}else if( (strcmp( argv[i], "-d" ) == 0 || strcmp( argv[i], "--data" ) == 0) ) 
			{
				do_data = True ;
			}else if( (strcmp( argv[i], "-S" ) == 0 || strcmp( argv[i], "--source" ) == 0) && i+1 < argc && argv[i+1] != NULL ) 
			{
				++i ;				
				source_dir = argv[i] ;
			}else if( (strcmp( argv[i], "-D" ) == 0 || strcmp( argv[i], "--dst" ) == 0) && i+1 < argc && argv[i+1] != NULL ) 
			{
				++i ;				
				destination_dir = argv[i] ;
			}
		}
	}		  
	if( destination_dir == NULL ) 
		destination_dir = do_data?"data":ASDocTypeExtentions[target_type] ;
	if( source_dir == NULL ) 
		source_dir = do_data?"../../afterstep":"source" ;

#if 0

    ConnectAfterStep ( mask_reg, 0);
	
  	SendInfo ( "Nop \"\"", 0);
#endif
	ProcessedSyntaxes = create_ashash( 7, pointer_hash_value, NULL, NULL );
	Glossary = create_ashash( 4096, string_hash_value, string_compare, string_destroy );
	Index = create_ashash( 4096, string_hash_value, string_compare, string_destroy );
	UserLinks = create_ashash( 4096, string_hash_value, string_compare, string_destroy );
	APILinks = create_ashash( 4096, string_hash_value, string_compare, string_destroy );

	Links = UserLinks;

	GlossaryName = UserGlossaryName ; 
	TopicIndexName = UserTopicIndexName ; 

	if( target_type < DocType_Source )
	{	
		time_t curtime;
    	struct tm *loctime;
		
		DocBookVocabulary = create_ashash( 7, casestring_hash_value, casestring_compare, string_destroy_without_data );
		for( i = 1 ; i < DOCBOOK_SUPPORTED_IDS ; ++i )
			add_hash_item( DocBookVocabulary, AS_HASHABLE(SupportedDocBookTagInfo[i].tag), (void*)(SupportedDocBookTagInfo[i].tag_id));
		
		/* Get the current time. */
		curtime = time (NULL);
     	/* Convert it to local time representation. */
		loctime = localtime (&curtime);
		strftime(CurrentDateLong, DATE_SIZE, "%b %e %Y", loctime);
//.........这里部分代码省略.........
开发者ID:cooljeanius,项目名称:AfterStep,代码行数:101,代码来源:ASDocGen.c


示例7: do_emit_mssgtext_body

static int do_emit_mssgtext_body(FILE *fp_dest, SEND_BODYPART *part)
{
    char buf[SLEN];
    SEND_MULTIPART *mp;
    int rc, part_active;
    size_t len;
    long fpos;
    FILE *fp_src;

    bodypart_integrity_check(part);
    assert(part->part_type == BP_IS_MSSGTEXT);

    rc = -1;
    /*
     * This clever hack initializes properly on multipart/mixed
     * and suppresses multipart boundaries on text/plain.
     */
    part_active = MULTIPART_IS_EMPTY(part->subparts);

    if ((fp_src = file_open(part->fname, "r")) == NULL)
	goto done;

    while (fpos = ftell(fp_src), (len =
		mail_gets(buf, sizeof(buf), fp_src)) > 0) {

	if (buf[0] == '[') {

	    /* [nosave] and [no save] are directives to savecopy */
	    if (strbegConst(buf, MSSG_DONT_SAVE))
		continue;
	    if (strbegConst(buf, MSSG_DONT_SAVE2))
		continue;

	    /* [attach ...] handled after body complete */
	    if (strbegConst(buf+1, MSSG_ATTACH))
		continue;

	    /* do [include] */
	    if (strbegConst(buf+1, MSSG_INCLUDE)) {
		assert(!MULTIPART_IS_EMPTY(part->subparts));
		if ((mp = multipart_find(part->subparts, fpos)) == NULL) {
		    show_error(catgets(elm_msg_cat, ElmSet,
			    ElmCannotRefindInclusion,
			    "Cannot re-find inclusion located at offset %lu!"),
			    (unsigned long)fpos);
		    goto done;
		}
		if (do_emit_multipart_sep(fp_dest, part, FALSE) < 0)
		    goto done;
		if (emitpart(fp_dest, MULTIPART_PART(mp)) < 0)
		    goto done;
		part_active = FALSE;
		continue;
	    }

	}

	/* see if we need to emit the multipart separator */
	if (!part_active) {
	    if (do_emit_multipart_sep(fp_dest, part, FALSE) < 0)
		goto done;
	    if (do_emit_mimepart_header(fp_dest, part) < 0)
		goto done;
	    putc('\n', fp_dest);
	    part_active = TRUE;
	}

#ifdef NEED_LONE_PERIOD_ESCAPE
	/* some transports (e.g. smail2.5) take lone dot as end of message */
	if (buf[0] == '.' && buf[1] == '\n' && buf[2] == '\0')
	    (void) strcpy(buf, ". \n");
#endif

	/* emit the line of output */
	if (fwrite(buf, 1, len, fp_dest) != len) {
	    show_error("Error writing message body to temp file.  [%s]",
		strerror(errno));
	    goto done;
	}

    }

    /* emit the attachments */
    if (!MULTIPART_IS_EMPTY(part->subparts)) {
	mp = NULL;
	while ((mp = multipart_next(part->subparts, mp)) != NULL) {
	    if (MULTIPART_ID(mp) == MP_ID_ATTACHMENT) {
		if (do_emit_multipart_sep(fp_dest, part, FALSE) < 0)
		    goto done;
		if (emitpart(fp_dest, MULTIPART_PART(mp)) < 0)
		    goto done;
	    }
	}
	if (do_emit_multipart_sep(fp_dest, part, TRUE) < 0)
	    goto done;
    }

    if (file_close(fp_src, part->fname) < 0)
	goto done;
    fp_src = NULL;
//.........这里部分代码省略.........
开发者ID:wfp5p,项目名称:elm,代码行数:101,代码来源:sndpart_io.c


示例8: do_reset

void
do_reset(void)
{
    if (bdmReset() < 0)
        show_error("Reset");
}
开发者ID:osfreedom,项目名称:bdm-osbdm,代码行数:6,代码来源:cpu32-check.c


示例9: execute

void
execute(int memory_type, int loops)
{
    void initialize_system(void);

    unsigned char wbuf[MAX_CODE_LEN];
    unsigned char rbuf[MAX_CODE_LEN];
    unsigned long pc, csr;
    unsigned long address;
    int status;
    int code_len;
    int i, b, loop = 0;
    int verify_error = 0;

    const char *code =
        "46FC 2700"
        "2E7C 0E00 0000"
        "207C A0A0 A0A0"
        "227C A1A1 A1A1"
        "247C A2A2 A2A2"
        "267C A3A3 A3A3"
        "287C A4A4 A4A4"
        "2A7C A5A5 A5A5"
        "2C7C A6A6 A6A6"
        "2E7C A7A7 A7A7"
        "203C D0D0 D0D0"
        "223C D1D1 D1D1"
        "243C D2D2 D2D2"
        "263C D3D3 D3D3"
        "283C D4D4 D4D4"
        "2A3C D5D5 D5D5"
        "2C3C D6D6 D6D6"
        "2E3C D7D7 D7D7"
        "4E71"
        "6000 FFFC";

    printf("\nCPU32 %s code execution test: iteration %d of %d\n",
           memory_type == INTERNAL_RAM ? "internal": "external",
           loop, loops);

    /*
     * Convert the code to binary to load. The code is
     * like this as it is easy to cut and paste in.
     */
    code_len = strlen(code);

    if (code_len >= MAX_CODE_LEN) {
        printf("Too much code for the buffer.\n");
        clean_exit(1);
    }

    b = 0;

    for (i = 0; i < code_len; i++) {
        if (code[i] > ' ') {
            if (code[i] >= '0' && code[i] <= '9')
                wbuf[b] = code[i] - '0';
            else if (code[i] >= 'a' && code[i] <= 'f')
                wbuf[b] = code[i] - 'a' + 10;

            i++;

            if (code[i] >= '0' && code[i] <= '9')
                wbuf[b] = (wbuf[b] << 4) | (code[i] - '0');
            else if (code[i] >= 'a' && code[i] <= 'f')
                wbuf[b] = (wbuf[b] << 4) | (code[i] - 'a' + 10);

            b++;
        }
    }

    initialize_system();

    if (memory_type == INTERNAL_RAM) {
        address = DPRAM_BASE;
        printf("Loading code into DPRAM, base address: 0x%.8lX\n", address);
    }
    else {
        address = 0x0;
        printf("Loading code into external RAM, base address: 0x%.8lX\n",
               address);
    }

    if (bdmWriteMemory(address, wbuf, b) < 0)
        show_error("Writing buffer to RAM");

    if (bdmReadMemory(address, rbuf, b) < 0)
        show_error("Reading buffer from RAM");

    for (i = 0; i < b; i++) {
        if (wbuf[i] != rbuf[i]) {
            printf("Read buffer and write buffer do not agree!\n");
            verify_error = 1;

            if (stop_on_error)
                clean_exit(1);
        }
    }

    if (!verify_error)
//.........这里部分代码省略.........
开发者ID:osfreedom,项目名称:bdm-osbdm,代码行数:101,代码来源:cpu32-check.c


示例10: main


//.........这里部分代码省略.........
                if (arg == argc) {
                    printf(" -a option requires a parameter");
                    exit(0);
                }
                align_check_loops = strtoul(argv[arg], NULL, 0);
                break;

            case 'C':
                options_stop_on_error = 0;
                break;

            case 'Q':
                options_stop_quiet = 1;
                break;

            default:
                printf(" Unknown option!");

            case '?':
            case 'h':
                usage();
                break;
            }
        }
    }

    if (!dev)
    {
        printf(" ERROR: No BDM device set.\n");
        exit(1);
    }

    if (bdmOpen(dev) < 0)
        show_error("Open");

    if (driver_debug)
        bdmSetDriverDebugFlag(driver_debug);

    if (delay_counter)
        bdmSetDelay(delay_counter);

    if (bdmGetDrvVersion(&driver_version) < 0)
        show_error("GetDrvVersion");

    printf("BDM Driver Version : %x.%x\n",
           driver_version >> 8, driver_version & 0xff);

    if (bdmGetProcessor(&cpu_type) < 0)
        show_error("GetProcessor");

    switch(cpu_type) {
    case BDM_CPU32:
        printf("Processor  : CPU32\n");
        break;
    default:
        printf("Unsupported processor type!\n");
        clean_exit(1);
        break;
    }

    if (bdmGetInterface(&iface) < 0)
        show_error("GetInterface");

    switch(iface) {
    case BDM_CPU32_ERIC:
        printf("Interface  : Eric's CPU32\n");
开发者ID:osfreedom,项目名称:bdm-osbdm,代码行数:67,代码来源:cpu32-check.c


示例11: show_registers

void
show_registers(void)
{
    unsigned long a, d, r;
    int i;

    printf("\nRegisters:\n");
    printf("A0-7:");
    for (i = 0 ; i < 8 ; i++) {
        if (bdmReadRegister(i + 8, &a) < 0)
            show_error("Read address register");
        printf("%.8lX ", a);
    }

    printf("\nD0-7:");
    for (i = 0 ; i < 8 ; i++) {
        if (bdmReadRegister(i, &d) < 0)
            show_error("Read address register");
        printf("%.8lX ", d);
    }

    printf("\n");

    if (bdmReadSystemRegister(BDM_REG_RPC, &r) < 0)
        show_error("Read RPC system register");
    printf(" RPC:%.8lX", r);

    if (bdmReadSystemRegister(BDM_REG_PCC, &r) < 0)
        show_error("Read PCC system register");
    printf("  PCC:%.8lX", r);

    if (bdmReadSystemRegister(BDM_REG_SR, &r) < 0)
        show_error("Read SR system register");
    printf("  SR :%.8lX", r);

    if (bdmReadSystemRegister(BDM_REG_USP, &r) < 0)
        show_error("Read USP system register");
    printf("  USP:%.8lX\n", r);

    if (bdmReadSystemRegister(BDM_REG_SSP, &r) < 0)
        show_error("Read SSP system register");
    printf(" SSP:%.8lX", r);

    if (bdmReadSystemRegister(BDM_REG_SFC, &r) < 0)
        show_error("Read SFC system register");
    printf("  SFC:%.8lX", r);

    if (bdmReadSystemRegister(BDM_REG_DFC, &r) < 0)
        show_error("Read DFC system register");
    printf("  DFC:%.8lX", r);

    if (bdmReadSystemRegister(BDM_REG_FAR, &r) < 0)
        show_error("Read FAR system register");
    printf("  FAR:%.8lX\n", r);

    if (bdmReadSystemRegister(BDM_REG_VBR, &r) < 0)
        show_error("Read VBR system register");
    printf(" VBR:%.8lX", r);

    if (bdmReadSystemRegister(BDM_REG_ATEMP, &r) < 0)
        show_error("Read ATEMP system register");
    printf("  ATEMP:%.8lX", r);

    if (bdmReadSystemRegister(BDM_REG_MBAR, &r) < 0)
        show_error("Read MBAR system register");
    printf("  MBAR:%.8lX\n\n", r);
}
开发者ID:osfreedom,项目名称:bdm-osbdm,代码行数:67,代码来源:cpu32-check.c


示例12: initialize_system

/*
 * Perform any target specific initialization required to check
 * main (external to the processor) memory.
 */
void
initialize_system(void)
{
    unsigned long r;
    unsigned short rword;

    printf("Initializing target\n");
    do_reset();

    if (bdmWriteMBAR(__MBAR) < 0)
        show_error("MBAR write");

    if (bdmReadMBAR(&r) < 0)
        show_error("MBAR read");

    if (options_verbose)
        printf("Readback MBAR = 0x%.8lX\n", r);

    if (r != __MBAR)
        show_error("MBAR readback");

    if (bdmWriteSystemRegister(BDM_REG_DFC, 0x5) < 0)
        show_error("Write 0x5 to DFC");

    if (bdmWriteSystemRegister(BDM_REG_SFC, 0x5) < 0)
        show_error("Write 0x5 to SFC");

    if (bdmWriteByte(CLKOCR_ADDR, 0x8f) < 0)
        show_error("Write to CLKOCR");

    if(bdmWriteWord(PLLCR_ADDR, 0xd000) < 0)
        show_error("Write to PLLCR");

    if (bdmWriteWord(CDVCR_ADDR, 0x8000) < 0)
        show_error("Write to CDVCR");

    if (bdmWriteByte(SYPCR_ADDR, 0x7f) < 0)
        show_error("Write to SYPCR");

    if (bdmWriteLongWord(MCR_ADDR, 0x4c7f) < 0)
        show_error("Write to MCR");

    if (bdmWriteWord(PEPAR_ADDR, 0x0080) < 0)
        show_error("Write to PEPAR");

    if (bdmReadWord(PEPAR_ADDR, &rword) < 0)
        show_error("Read of PEPAR");

    if ((rword && 0x20) == 0) /* PEPAR is not written */
        printf("PWW in PEPAR is not set!");

    /*if (bdmWriteLongWord(GMR_ADDR, 0x16e801A0) < 0) */
    if (bdmWriteLongWord(GMR_ADDR, 0x179801A0) < 0)
        show_error("Write to GMR");

    if (bdmWriteLongWord(BR0_ADDR, 0x04000001) < 0)
        show_error("Write to BR0");

    /* if (bdmWriteLongWord(OR0_ADDR, 0xfc000000) < 0) */
    if (bdmWriteLongWord(OR0_ADDR, 0x84000000) < 0)
        show_error("Write to OR0");

    if (bdmWriteLongWord(BR1_ADDR, 0x00000001) < 0)
        show_error("Write to BR1");

    if (bdmWriteLongWord(OR1_ADDR, 0x02000001) < 0)
        show_error("Write to OR1");
}
开发者ID:osfreedom,项目名称:bdm-osbdm,代码行数:72,代码来源:cpu32-check.c


示例13: show_error

void RecordList::show_lock_error() const {

    show_error("member function called when still looking for records");
}
开发者ID:szte-wsn,项目名称:szte-wsn,代码行数:4,代码来源:RecordList.cpp


示例14: CAONTRS_test

int CAONTRS_test()
{
	int i,k,n,r,itemindex,randnum,strlen,resTF;
	char *tracepath;//记录一下轨迹的路径
	FILE *fin,*fout;//用于输入trace,输出结果
	CODEPARA *codeptr;
	BYTE *content;//需要加密的内容
	ADDRESSLIST *addlistptr;
	SHAREADDRESS *addptr,*curaddptr;
	TRACEITEM *itemptr;
	int starttick,endtick;
	double sectime;

	content=talloc(BYTE,chksize_MB(100));//开100MB空间希望不会有比他大的
	if(content==NULL)
	{
		show_error("CAONTRS","CAONTRS_test","No memory");
		return FALSE;
	}
	codeptr=talloc(CODEPARA,1);
	if(codeptr==NULL)
	{
		show_error("CAONTRS","CAONTRS_test","No memory");
		return FALSE;
	}
	addptr=talloc(SHAREADDRESS,7);
	curaddptr=addptr;
	for(i=0;i<7;i++)
	{
		curaddptr->storepath=talloc(char,10);
		if(curaddptr->storepath==NULL)
		{
			show_error("CAONTRS","CAONTRS_test","No memory");
			return FALSE;
		}
		curaddptr++;
	}
	addlistptr=talloc(ADDRESSLIST,1);
	if(addlistptr==NULL)
	{
		show_error("CAONTRS","CAONTRS_test","No memory");
		return FALSE;
	}
	itemptr=talloc(TRACEITEM,1);
	if(itemptr==NULL)
	{
		show_error("CAONTRS","CAONTRS_test","No memory");
		return FALSE;
	}
	addlistptr->addressptr=addptr;
	addlistptr->codeptr=codeptr;
	memset(content,1,chksize_MB(100));
	k=4;
	fout=fopen(".\\CAONT-RS.txt","w");
	if(fout==NULL)
	{
		show_error("CAONTRS","CAONTRS_test","output file cannot open");
		return FALSE;
	}
	for(r=0;r<100;r++)
	{
		for(i=0;i<7;i++)
		{
			switch(i)
			{
			case 0://轨迹放在本地
				tracepath=".\\usr.txt";
				//linenum=
				//strlen=chksize_KB(64);
				break;
			case 1:
				tracepath=".\\web.txt";
				//strlen=chksize_KB(128);
				break;
			case 2:
				tracepath=".\\proj.txt";
				//strlen=chksize_KB(256);
				break;
			case 3:
				tracepath=".\\ts.txt";
				//strlen=chksize_KB(512);
				break;
			case 4:
				tracepath=".\\rsrch.txt";
				//strlen=chksize_MB(1);
				break;
			case 5:
				tracepath=".\\mds.txt";
				break;
			case 6:
				tracepath=".\\hm.txt";
				break;
			}
			fin=fopen(tracepath,"r");
			if(fin==NULL)
			{
				show_error("CAONTRS","CAONTRS_test","trace cannot open");
				return FALSE;
			}
			
//.........这里部分代码省略.........
开发者ID:swallows888,项目名称:SWALLOWFS,代码行数:101,代码来源:CAONTRS_test.c


示例15: parse_message_line

void parse_message_line(char *line)
{
	char *rest;
	int action = -1;
	button_info *b;
	char *act;
	char *buttonn;
	int mousebutton;

	silent = False;
	do
	{
		action = GetTokenIndex(line, actions, -1, &rest);
		if (action == -1)
		{
			show_error("Message not understood: %s", line);
			return;
		}
		if (action == 0)
		{
			silent = True;
			break;
		}
	} while (action == 0);

	/* If silent was given (to surpress erros from parsing commands, then
	 * retokenise the rest of the line, so that token matching for the
	 * actual command is possible.
	 */
	if (silent == True) {
		line = PeekToken(line, &rest);
		action = GetTokenIndex(rest, actions, -1, &rest);
	}

	/* find out which button */
	b = parse_button_id(&rest);
	if (!b || !rest)
	{
		return;
	}

	switch (action)
	{
	case 1:
		/* ChangeButton */
		/* The dimensions of individual buttons (& the overall size of
		 * the FvwmButtons window) is based on the initial
		 * configuration for the module. In some configurations,
		 * dynamically adding/changing a title/icon may mean it no
		 * longer fits on a button. Currently, there are no checks for
		 * this occurance. */
		while (rest && rest[0] != '\0')
		{
			char *option_pair;
			int option, i;
			char *value0, *value;
			FvwmPicture *icon;

			/* parse option and value and give diagnostics */
			rest = GetQuotedString(
				rest, &option_pair, ",", NULL, NULL, NULL);
			while (isspace(*rest))
			{
				rest++;
			}
			if (!option_pair)
				continue;

			option = GetTokenIndex(
				option_pair, button_options, -1, &value0);
			if (option < 0)
			{
				show_error(
					"Unsupported button option line '%s'\n",
					option_pair);
				free(option_pair);
				continue;
			}

			GetNextToken(value0, &value);
			free(option_pair);

			if (value == NULL)
			{
				show_error(
					"No title/icon to change specified.\n");
				continue;
			}
			switch (option)
			{
			case 0:
				/* Title */
				if (b->flags.b_Title)
					free(b->title);
				b->flags.b_Title = 1;
				b->title = value;
				value = NULL;
				break;
			case 2:
				/* ActiveTitle */
//.........这里部分代码省略.........
开发者ID:lemenkov,项目名称:fvwm,代码行数:101,代码来源:dynamic.c


示例16: verify_internal_ram

void
verify_internal_ram(int loops)
{
#define SRAM_BYTE_SIZE (256)
#define SRAM_BUF_SIZE  (SRAM_BYTE_SIZE / sizeof(unsigned long))

    void initialize_system(void);

    unsigned long buf[SRAM_BUF_SIZE];
    unsigned int  test;
    unsigned int  i;
    int           sram_ok;
    int           loop = 0;

    printf("Internal DPAM Test, %d loops\n", loops);
    initialize_system();

    while (loop < loops) {
        loop++;
        printf(" %5i : ", loop);
        for (test = 0; test < sizeof(test_pattern)/sizeof(test_pattern[0]);
                test++) {
            for (i = 0; i < SRAM_BUF_SIZE; i++) {
                buf[i] = test_pattern[test];
            }

            sram_ok = 1;

            if (bdmWriteMemory(DPRAM_BASE, (unsigned char*) buf, SRAM_BYTE_SIZE) < 0) {
                if (stop_quiet)
                    printf("W");
                else
                    show_error("Writing SRAM buffer");
            }

            if (bdmReadMemory(DPRAM_BASE, (unsigned char*) buf, SRAM_BYTE_SIZE) < 0) {
                if(stop_quiet)
                    printf("R");
                else
                    show_error("Reading SRAM buffer");
            }

            for (i = 0; i < SRAM_BUF_SIZE; i++) {
                if (buf[i] != test_pattern[test]) {
                    sram_ok = 0;
                    if(stop_quiet)
                        printf("R");
                    else {
                        printf("  addr=%08lx,  write/read %08lx %08lx\n",
                               DPRAM_BASE + (i * sizeof(unsigned long)),
                               test_pattern[test], buf[i]);
                        show_error("Verifing SRAM");
                    }
                }
            }

            if(sram_ok)
                printf(".");

            fflush(stdout);
        }
        printf("\n");
    }
}
开发者ID:osfreedom,项目名称:bdm-osbdm,代码行数:64,代码来源:cpu32-check.c


示例17: main

int main( const int argc, const char *argv[] )
  {
  int n = strlen( argv[0] );
  char loose = 0;
  const ap_Option options[] =
    {
    { 'G', "traditional",       ap_no  },
    { 'h', "help",              ap_no  },
    { 'l', "loose-exit-status", ap_no  },
    { 'p', "prompt",            ap_yes },
    { 's', "quiet",             ap_no  },
    { 's', "silent",            ap_no  },
    { 'v', "verbose",           ap_no  },
    { 'V', "version",           ap_no  },
    {   0, 0,                   ap_no } };
  Arg_parser parser;
  int argind;

  if( !ap_init( &parser, argc, argv, options, 0 ) )
    { show_error( "Memory exhausted", 0, 0 ); return 1; }
  if( ap_error( &parser ) )				/* bad option */
    { show_error( ap_error( &parser ), 0, 1 ); return 1; }
  invocation_name = argv[0];
  restricted_ = ( n > 2 && argv[0][n-3] == 'r' );

  for( argind = 0; argind < ap_arguments( &parser ); ++argind )
    {
    const int code = ap_code( &parser, argind );
    const char * arg = ap_argument( &parser, argind );
    if( !code ) break;					/* no more options */
    switch( code )
      {
      case 'G': traditional_ = 1; break;	/* backward compatibility */
      case 'h': show_help(); return 0;
      case 'l': loose = 1; break;
      case 'p': set_prompt( arg ); break;
      case 's': scripted_ = 1; break;
      case 'v': set_verbose(); break;
      case 'V': show_version(); return 0;
      default: show_error( "internal_error: uncaught option", 0, 0 ); return 3;
      }
    }
  setlocale( LC_ALL, "" );
  if( !init_buffers() ) return 1;

  while( argind < ap_arguments( &parser ) )
    {
    const char * arg = ap_argument( &parser, argind );
    if( !strcmp( arg, "-" ) ) { scripted_ = 1; ++argind; continue; }
    if( may_access_filename( arg ) )
      {
      if( read_file( arg, 0 ) < 0 && is_regular_file( 0 ) )
        return 2;
      else if( arg[0] != '!' ) set_def_filename( arg );
      }
    else
      {
      fputs( "?\n", stderr );
      if( arg[0] ) set_error_msg( "Invalid filename" );
      if( is_regular_file( 0 ) ) return 2;
      }
    break;
    }
  ap_free( &parser );

  return main_loop( loose );
  }
开发者ID:ystk,项目名称:debian-ed,代码行数:67,代码来源:main.c


示例18: verify_alignment

int
verify_alignment(void)
{
    unsigned long  addr;
    unsigned char  byte;
    unsigned short word;
    unsigned long  lword;

    /*
     * Check the values using a byte read.
     */
    printf("Reading bytes :");
    for (addr = 0; addr < ALIGN_MEM_SIZE; addr += sizeof(byte)) {
        if (bdmReadByte(addr + DPRAM_BASE, &byte) < 0) {
            if(stop_quiet)
                printf("W");
            else {
                printf("\n");
                printf("Read byte at 0x%08lx\n", addr + DPRAM_BASE);
                show_error("Reading with bytes");
            }
            return -1;
        } else if (byte != addr) {
            if(stop_quiet)
                printf("b");
            else {
                printf("\n");
                printf("Read byte match addr=0x%08lx, read=0x%02x, wanted=0x%02x\n",
                       addr + DPRAM_BASE, byte, (unsigned char)addr);
                show_error("Bytes read does not match");
            }
            return -1;
        }
        else {
            if ((addr % 32) == 0)
                printf("\n");
            printf(".");
        }
    }

    /*
     * Check the values using a word read.
     */
    printf("\n Reading words :");
    for (addr = 0; addr < ALIGN_MEM_SIZE; addr += sizeof(word) ) {
        if (bdmReadWord(addr + DPRAM_BASE, &word) < 0) {
            if(stop_quiet)
                printf("w");
            else {
                pr 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ show_file函数代码示例发布时间:2022-05-30
下一篇:
C++ show_date函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap