コード例 #1
0
ファイル: ls.c プロジェクト: YogaPan/linux-basic
static int show_stat(const char *path)
{
	int ret;
	struct stat s;

	if (access(path, F_OK) < 0) {
		fprintf(stderr, "path not exists\n");
		return -1;
	}

	ret = stat(path, &s);
	if (ret < 0) {
		perror("stat");
		return -1;
	}

	show_inode(&s);
	show_mode(&s);
	show_user(&s);
	show_size(&s);
	show_time(&s);
	printf(" %s\n", path);

	return 0;
}
コード例 #2
0
ファイル: gui_sendmap.cpp プロジェクト: casaretto/cgpsmapper
bool GUI_manager::remove_IMG() {
	char	buffer[MAX_PATH+1];
	char	internal_name[20];
	int		item = ListView_GetSelectionMark(IMG_list);
	int		count = ListView_GetItemCount(IMG_list);
	bool	removed = false;
	
	if( item > -1 ) {
		ListView_GetItemText(IMG_list,item,2,buffer,MAX_PATH);
		ListView_GetItemText(IMG_list,item,3,internal_name,sizeof internal_name);
		if( strlen(buffer) && strlen(internal_name) ) {
			if( uploader->remove_img_file(buffer,internal_name) && !removed ) 
				removed = true;
		}
		if( ListView_DeleteItem(IMG_list,item) ) {
			removed = true;
			if( (item+1) >= count )
				item--;
		}
		SetSelection(IMG_list,item);
		show_size();
	}
	uploader->remove_all();
	return removed;
}
コード例 #3
0
ファイル: show_size_to_byte.c プロジェクト: RoverMo/base
int main(int argc, char *argv[])
{
	int size;

	size = show_size("1M");
	printf("%d\n", size);

	return 0;
}
コード例 #4
0
ファイル: my_ls.c プロジェクト: KIDxiaoyuan/kid
void display_l(const char * filename,int flag)
{
    int ans[4],i;
    struct stat buf;
    struct passwd* pwd;
    struct group*  grp;
    if(stat(filename,&buf) == -1)
    {
        perror("stat");
        return ;
    }
    get_st_mode(buf.st_mode,ans);
    switch(ans[3])
    {
                case(1): printf("l"); break;
                case(2): printf("-"); break;
                case(3): printf("d"); break;
                case(4): printf("c"); break;
                case(5): printf("b"); break;
                case(6): printf("f"); break;
                case(7): printf("s"); break;
                default: break;           
    }
        for(i=0;i<3;i++)
    {
            if(ans[i]%2==0) printf("r");
            else  printf("-");
            if(ans[i]%3==0) printf("w");
            else printf("-");
            if(ans[i]%5==0) printf("x");
            else printf("-");
    }
        printf(" ");
    printf(" %3ld ",buf.st_nlink);
    if((pwd=getpwuid(buf.st_uid))==NULL)
       printf(" %-3d ",buf.st_uid);
       else 
       printf(" %5s ",pwd->pw_name);
    if((grp=getgrgid(buf.st_gid))==NULL)
    printf(" %5d ",buf.st_gid);
    else 
       printf(" %5s ",grp->gr_name);
    show_size(buf.st_size);
    char time[100];
    if(flag==true)
    strcpy(time,ctime(&buf.st_mtime));
    else 
    strcpy(time,ctime(&buf.st_atime));
    for(i=0;i<10;i++)
    printf("%c",time[i]);
}
コード例 #5
0
ファイル: gui_sendmap.cpp プロジェクト: casaretto/cgpsmapper
void GUI_manager::add_IMG(const char* full_path_file_name) {
	int				item = ListView_GetItemCount(IMG_list);
	vector<internal_file>	TRE_file_list;
	char	tmp[1024];
	char	local_file_name[1024];
	char	t_file_type[255];
	char	drive[5];
	char	dir[1024];

	GetWindowText(region_name,tmp,1000);

	_splitpath(full_path_file_name,drive,dir,local_file_name,t_file_type);

	if( !strcmp(strupr( t_file_type ),".TXT" ) ) {
		FILE*	list = fopen(full_path_file_name,"r");
		char	file_name[1025];
		strcpy(tmp,"map");
		if( list ) {
			while( fgets(file_name,1024,list) != NULL ) {
				//remove 'non asci' chars!
				while( file_name[strlen(file_name)-1] < 32 && strlen(file_name))
					file_name[strlen(file_name)-1] = 0;
				if( strlen(file_name) ) {
					if( file_name[0] == ':' ) {
						strcpy(tmp,&file_name[1]);
					} else {
						uploader->add_img_file(file_name,&TRE_file_list,"",0,0,tmp,uploader->get_product_id(tmp));
					}
				}
			}
			fclose(list);
		}
	} else {
		uploader->add_img_file(full_path_file_name,&TRE_file_list,"",0,0,tmp,uploader->get_product_id(tmp));
	}
	
	for( vector<internal_file>::iterator f = TRE_file_list.begin(); f < TRE_file_list.end(); f++ ) {
		InsertItem(IMG_list, item , LPARAM("%s"),(*f).region_name.c_str());
		SetSubItemText (IMG_list, item, 1, "%s", (*f).TRE_map_name.c_str());
		SetSubItemText (IMG_list, item, 2, "%s", (*f).file_name.c_str());
		SetSubItemText (IMG_list, item, 3, "%s", (*f).get_internal_short_name());
	}
	AutoSizeColumns(IMG_list);
	show_size();
	
}
コード例 #6
0
ファイル: gui_sendmap.cpp プロジェクト: casaretto/cgpsmapper
void GUI_manager::enter_sync_mode(bool verbose) {
	char	b_title1[500];
	char	b_title2[500];
	int		item = ListView_GetItemCount(IMG_list);
	vector<internal_file> TRE_file_list;

	sync_mode = false;
	if( connect(true) == false )
		return;

	SetSelection(IMG_list,0);
	while( remove_IMG() )
		;

	loadString(IDS_SYNC_START,b_title1,sizeof(b_title1));
	loadString(IDS_SYNC_TITLE,b_title2,sizeof(b_title2));

	if( verbose ) {
		if( MessageBox(NULL,b_title1,b_title2,MB_ICONERROR | MB_YESNO) == IDYES ) {
			sync_mode = true;
		}
	} else 
		sync_mode = true;
	
	if( sync_mode ) {
		EnableWindow(GetDlgItem (gui_hwndDlg, IDC_IMG_FILE),FALSE);
		EnableWindow(GetDlgItem (gui_hwndDlg, IDC_EXE_FILE),FALSE);
		EnableWindow(GetDlgItem (gui_hwndDlg, IDC_STORE_FILES),FALSE);
		

		SetCursor (g_hWaitCursor);
			
		if( uploader->download_directory(&TRE_file_list) == true ) {
			item = ListView_GetItemCount(IMG_list);
			for( vector<internal_file>::iterator f = TRE_file_list.begin(); f < TRE_file_list.end(); f++ ) {
				InsertItem(IMG_list, item , LPARAM("%s"),(*f).region_name.c_str());
				SetSubItemText (IMG_list, item, 1, "%s", (*f).TRE_map_name.c_str());
				SetSubItemText (IMG_list, item, 2, "%s", (*f).file_name.c_str());
				SetSubItemText (IMG_list, item, 3, "%s", (*f).get_internal_short_name());
			}
			AutoSizeColumns(IMG_list);
			show_size();
		}
		SetCursor (g_hArrowCursor);
	}
}
コード例 #7
0
ファイル: main.cpp プロジェクト: CCJY/coliru
int main() { 
	typedef long double ld;

	show_size(char(), short(), int(), long(), float(), double(), ld());
}
コード例 #8
0
ファイル: main.cpp プロジェクト: CCJY/coliru
void show_size(T t, Args...args) { 
	show_size(t);
	show_size(args...);
}
コード例 #9
0
int
main(void)
{
    printf("Size/offsets of data structures:\n");

    show_size(attr_t);
    show_size(chtype);
#if NCURSES_WIDECHAR
    show_size(cchar_t);
#endif
    show_size(mmask_t);
    show_size(MEVENT);
    show_size(NCURSES_BOOL);

    printf("\n");
    show_size(SCREEN);
    show_offset(SCREEN, _panelHook);
#if USE_REENTRANT
    show_offset(SCREEN, _ttytype);
#endif
#ifdef TRACE
    show_offset(SCREEN, tracechr_buf);
#endif
#ifdef USE_SP_WINDOWLIST
    show_offset(SCREEN, _windowlist);
#endif
    show_offset(SCREEN, rsp);
#if NCURSES_EXT_FUNCS
#if USE_NEW_PAIR
    show_offset(SCREEN, _ordered_pairs);
#endif
#if NCURSES_SP_FUNCS
    show_offset(SCREEN, use_tioctl);
#endif
#endif
#if USE_WIDEC_SUPPORT
    show_offset(SCREEN, _screen_acs_fix);
#endif

    printf("\n");
    show_size(TERMINAL);
    show_offset(TERMINAL, type);
    show_offset(TERMINAL, Filedes);
#if defined(TERMIOS)
    show_offset(TERMINAL, Ottyb);
    show_offset(TERMINAL, Nttyb);
#endif
    show_offset(TERMINAL, _baudrate);
    show_offset(TERMINAL, _termname);
#if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR
    show_offset(TERMINAL, type2);
#endif

    printf("\n");
    show_size(TERMTYPE);
#if NCURSES_XNAMES
    show_offset(TERMTYPE, ext_str_table);
    show_offset(TERMTYPE, ext_Strings);
#endif

    printf("\n");
    show_size(WINDOW);
#if NCURSES_WIDECHAR
    show_offset(WINDOW, _bkgrnd);
#if NCURSES_EXT_COLORS
    show_offset(WINDOW, _color);
#endif
#endif
    return EXIT_SUCCESS;
}
コード例 #10
0
ファイル: E-Bandwidth.c プロジェクト: Limsik/e17
static void
timer_cb(void *data)
{
   char                buff[1024];
   double              val = -1.0, val2 = -1.0;
   unsigned char       invalid;
   unsigned long       in_bytes, out_bytes;
   static unsigned long in_delta = -1, out_delta = -1;

   invalid = net_get_bytes_inout(device_string, &val, &val2);
   if (invalid)
     {
	D(("Failed to open %s -- %s\n", device_string, strerror(errno)));
	Esync();
	Epplet_timer(timer_cb, NULL, 10.0, "TIMER");
	return;
     }
   if ((last_in == 0) && (last_out == 0))
     {
	last_in = (unsigned long)val;
	last_out = (unsigned long)val2;
	Esync();
	Epplet_timer(timer_cb, NULL, 1.0, "TIMER");
	return;
     }

   in_bytes = (unsigned long)val - last_in;
   out_bytes = (unsigned long)val2 - last_out;
   D(("In %lu, out %lu\n", in_bytes, out_bytes));

   if (in_bytes > max_in)
     {
	max_in = in_bytes;
	Esnprintf(buff, sizeof(buff), "%lu", max_in);
	Epplet_modify_config("max_in", buff);
	D(("Set max_in to %lu\n", max_in));
     }
   if (in_bytes != in_delta)
     {
	in_val = (int)((((float)in_bytes) / max_in) * 100.0);
	Epplet_gadget_data_changed(in_bar);
	sprintf(buff, "I: ");
	show_size(in_bytes, buff + 3);
	strcat(buff, "/s");
	Epplet_change_label(in_label, buff);
	in_delta = in_bytes;
     }
   last_in += in_bytes;

   if (out_bytes > max_out)
     {
	max_out = out_bytes;
	Esnprintf(buff, sizeof(buff), "%lu", max_out);
	Epplet_modify_config("max_out", buff);
	D(("Set max_out to %lu\n", max_out));
     }
   if (out_bytes != out_delta)
     {
	out_val = (int)((((float)out_bytes) / max_out) * 100.0);
	Epplet_gadget_data_changed(out_bar);
	sprintf(buff, "O: ");
	show_size(out_bytes, buff + 3);
	strcat(buff, "/s");
	Epplet_change_label(out_label, buff);
	out_delta = out_bytes;
     }
   last_out += out_bytes;

   Esync();
   Epplet_timer(timer_cb, NULL, 1.0, "TIMER");
   return;
   data = NULL;
}
コード例 #11
0
static void
timer_cb(void *data)
{

   FILE               *fp;
   char                buff[1024];
   unsigned long       a, b, c, d, e;
   unsigned long       in_blks = 0, out_blks = 0;
   static unsigned long last_in = 0, last_out = 0, in_delta = 0, out_delta = 0;

   if (!(fp = fopen("/proc/diskstats", "r")))
     {
	if (!(fp = fopen("/proc/stat", "r")))
	  {
	     D(("Failed to open /proc/stat -- %s\n", strerror(errno)));
	     return;
	  }
     }

   for (; fgets(buff, sizeof(buff), fp);)
     {
	if (BEGMATCH(buff, "disk_rblk"))
	  {
	     sscanf(buff, "%*s %lu %lu %lu %lu", &a, &b, &c, &d);
	     in_blks = a + b + c + d;
	     fgets(buff, sizeof(buff), fp);
	     sscanf(buff, "%*s %lu %lu %lu %lu", &a, &b, &c, &d);
	     out_blks = a + b + c + d;
	  }
	else if (BEGMATCH(buff, "disk_io"))
	  {
	     char               *pbuff = buff + 9;

	     for (in_blks = out_blks = 0; *pbuff == '(';
		  pbuff = strchr(pbuff, ' ') + 1)
	       {
		  pbuff = strchr(++pbuff, '(');
		  sscanf(++pbuff, "%lu,%lu,%lu,%lu,%lu", &a, &b, &c, &d, &e);
		  in_blks += c;
		  out_blks += e;
	       }
	  }
	else
	  {
	     char                tmp[64];

	     /* Hopefully no one can exploit /proc/diskstats without root. :-) */
	     sscanf(buff, "%lu %lu %s %*u %*u %lu %*u %*u %*u %lu", &a, &b, tmp,
		    &c, &d);
	     /* Check for hdX or sdX, or md#, or...??? */
	     if ((((*tmp == 'h') || (*tmp == 's')) && (tmp[1] == 'd')
		  && (isalpha(tmp[2])) && (tmp[3] == 0)) || ((*tmp == 'm')
							     && (tmp[1] == 'd')
							     &&
							     (isdigit(tmp[2]))))
	       {
		  in_blks += c;
		  out_blks += d;
	       }
	  }
     }
   in_blks -= last_in;
   out_blks -= last_out;
   fclose(fp);

   if (last_in)
     {
	/* We must have some history data to do anything. */
	if (in_blks > max_in)
	  {
	     max_in = in_blks;
	     Esnprintf(buff, sizeof(buff), "%lu", max_in);
	     Epplet_modify_config("max_in", buff);
	  }
	if (in_blks != in_delta)
	  {
	     in_val = (int)((((float)in_blks) / max_in) * 100.0);
	     Epplet_gadget_data_changed(in_bar);
	     sprintf(buff, "I: ");
	     show_size(in_blks * 512, buff + 3);
	     strcat(buff, "/s");
	     Epplet_change_label(in_label, buff);
	  }
	in_delta = in_blks;
     }
   last_in += in_blks;

   if (last_out)
     {
	/* We must have some history data to do anything. */
	if (out_blks > max_out)
	  {
	     max_out = out_blks;
	     Esnprintf(buff, sizeof(buff), "%lu", max_out);
	     Epplet_modify_config("max_out", buff);
	  }
	if (out_blks != out_delta)
	  {
	     out_val = (int)((((float)out_blks) / max_out) * 100.0);
	     Epplet_gadget_data_changed(out_bar);
	     sprintf(buff, "O: ");
	     show_size(out_blks * 512, buff + 3);
	     strcat(buff, "/s");
	     Epplet_change_label(out_label, buff);
	  }
	out_delta = out_blks;
     }
   last_out += out_blks;

   Esync();
   Epplet_timer(timer_cb, NULL, 1.0, "TIMER");
   return;
   data = NULL;
}
コード例 #12
0
ファイル: shvio-convert.c プロジェクト: dhobsong/libviper
int main (int argc, char * argv[])
{
	UIOMux * uiomux;
	uiomux_resource_t uiores;

	char * infilename[2] = {NULL, NULL}, * outfilename = NULL;
	FILE * infile[2], * outfile = NULL;
	size_t nread;
	size_t input_size[2], output_size;
	SHVIO *vio;
	struct ren_vid_surface src[2];
	const struct ren_vid_surface *srclist[2] = {
		&src[0], &src[1]
	};
	struct ren_vid_surface dst;
	void *inbuf[2], *outbuf;
	int ret;
	int frameno=0;

	int show_version = 0;
	int show_help = 0;
	int show_list_vio = 0;
	char * progname;
	char * viodev = NULL;
	int error = 0;

	int c;
	char * optstring = "hvo:O:c:s:C:S:f:u:l";

#ifdef HAVE_GETOPT_LONG
	static struct option long_options[] = {
		{"help", no_argument, 0, 'h'},
		{"version", no_argument, 0, 'v'},
		{"output", required_argument, 0, 'o'},
		{"overlay", required_argument, 0, 'O'},
		{"input-colorspace", required_argument, 0, 'c'},
		{"input-size", required_argument, 0, 's'},
		{"output-colorspace", required_argument, 0, 'C'},
		{"output-size", required_argument, 0, 'S'},
		{"filter", required_argument, 0, 'f'},
		{"vio", required_argument, 0, 'u'},
		{"list", no_argument, 0, 'l'},
		{NULL,0,0,0}
	};
#endif

#if defined(USE_MERAM_RA) || defined(USE_MERAM_WB)
#define ALIGN16(_x)	(((_x) + 15) / 16 * 16)
#define ADJUST_PITCH(_p, _w)			\
	{					\
		(_p) = ((_w) - 1) | 1023;	\
		(_p) = (_p) | ((_p) >> 1);	\
		(_p) = (_p) | ((_p) >> 2);	\
		(_p) += 1;			\
	}

	unsigned long val;
	MERAM *meram = meram_open();
	MERAM_REG *regs = meram_lock_reg(meram);
	size_t sz;
	unsigned long mblock;
	ICB *icbr, *icbw;
#endif /* defined(USE_MERAM_RA) || defined(USE_MERAM_WB) */
	memset(src, 0, sizeof (src[0]) * 2);
	src[0].w = -1;
	src[0].h = -1;
	dst.w = -1;
	dst.h = -1;
	src[0].format = REN_UNKNOWN;
	dst.format = REN_UNKNOWN;
	src[0].bpitchy = src[0].bpitchc = src[0].bpitcha = 0;
	dst.bpitchy = dst.bpitchc = dst.bpitcha = 0;

	memcpy((void *)&src[1], (void *)&src[0], sizeof(src[0]));

	src[1].blend_out.x = 0;
	src[1].blend_out.y = 0;
	src[1].blend_out.w = 220;
	src[1].blend_out.h = 440;

	progname = argv[0];

	if (argc < 2) {
		usage (progname);
		return (1);
	}

	while (1) {
#ifdef HAVE_GETOPT_LONG
		c = getopt_long (argc, argv, optstring, long_options, NULL);
#else
		c = getopt (argc, argv, optstring);
#endif
		if (c == -1) break;
		if (c == ':') {
			usage (progname);
			goto exit_err;
		}

		switch (c) {
		case 'h': /* help */
			show_help = 1;
			break;
		case 'v': /* version */
			show_version = 1;
			break;
		case 'o': /* output */
			outfilename = optarg;
			break;
		case 'O': /* ovalery */
			infilename[1] = optarg;
			break;
		case 'c': /* input colorspace */
			set_colorspace (optarg, &src[0].format);
			break;
		case 's': /* input size */
			set_size (optarg, &src[0].w, &src[0].h);
			break;
		case 'C': /* output colorspace */
			set_colorspace (optarg, &dst.format);
			break;
		case 'S': /* output size */
			set_size (optarg, &dst.w, &dst.h);
			break;
		case 'f': /* filter mode */
			rotation = strtoul(optarg, NULL, 0);
			break;
		case 'l':
			show_list_vio = 1;
			break;
		case 'u':
			viodev = optarg;
			break;
		default:
			break;
		}
	}

	if (show_version) {
		printf ("%s version " VERSION "\n", progname);
	}

	if (show_help) {
		usage (progname);
	}
#if 0
	if (show_list_vio) {
		char **vio;
		int i, n;

		if (shvio_list_vio(&vio, &n) < 0) {
			printf ("Can't get a list of VIO available...\n");
		} else {
			for(i = 0; i < n; i++)
				printf("%s", vio[i]);
			printf("Total: %d VIOs available.\n", n);
		}
	}
#endif

	if (show_version || show_help || show_list_vio) {
		goto exit_ok;
	}

	if (optind >= argc) {
		usage (progname);
		goto exit_err;
	}

	infilename[0] = argv[optind++];

	if (optind < argc) {
		outfilename = argv[optind++];
	}

	printf ("Input file: %s\n", infilename[0]);
	if (infilename[1] != NULL)
		printf ("Overlay file: %s\n", infilename[1]);
	printf ("Output file: %s\n", outfilename);

	guess_colorspace (infilename[0], &src[0].format);
	if (infilename[1])
		guess_colorspace (infilename[1], &src[1].format);
	guess_colorspace (outfilename, &dst.format);
	/* If the output colorspace isn't given and can't be guessed, then default to
	 * the input colorspace (ie. no colorspace conversion) */
	if (dst.format == REN_UNKNOWN)
		dst.format = src[0].format;

	guess_size (infilename[0], src[0].format, &src[0].w, &src[0].h);
	if (rotation & 0xF) {
		/* Swap width/height for rotation */
		dst.w = src[0].h;
		dst.h = src[0].w;
	} else if (dst.w == -1 && dst.h == -1) {
		/* If the output size isn't given and can't be guessed, then default to
		 * the input size (ie. no rescaling) */
		dst.w = src[0].w;
		dst.h = src[0].h;
	}
	if (infilename[1])
		guess_size (infilename[1], src[1].format, &src[1].w, &src[1].h);

	/* Setup memory pitch */
	src[0].pitch = src[0].w;
	src[1].pitch = src[1].w;
	dst.pitch = dst.w;

	/* Check that all parameters are set */
	if (src[0].format == REN_UNKNOWN) {
		fprintf (stderr, "ERROR: Input colorspace unspecified\n");
		error = 1;
	}
	if (src[0].w == -1) {
		fprintf (stderr, "ERROR: Input width unspecified\n");
		error = 1;
	}
	if (src[0].h == -1) {
		fprintf (stderr, "ERROR: Input height unspecified\n");
		error = 1;
	}

	if (dst.format == REN_UNKNOWN) {
		fprintf (stderr, "ERROR: Output colorspace unspecified\n");
		error = 1;
	}
	if (dst.w == -1) {
		fprintf (stderr, "ERROR: Output width unspecified\n");
		error = 1;
	}
	if (dst.h == -1) {
		fprintf (stderr, "ERROR: Output height unspecified\n");
		error = 1;
	}

	if (error) goto exit_err;

	printf ("Input colorspace:\t%s\n", show_colorspace (src[0].format));
	printf ("Input size:\t\t%dx%d %s\n", src[0].w, src[0].h, show_size (src[0].w, src[0].h));
	printf ("Output colorspace:\t%s\n", show_colorspace (dst.format));
	printf ("Output size:\t\t%dx%d %s\n", dst.w, dst.h, show_size (dst.w, dst.h));
	printf ("Rotation:\t\t%s\n", show_rotation (rotation));

	input_size[0] = imgsize (src[0].format, src[0].w, src[0].h);
	if (infilename[1] != NULL)
		input_size[1] = imgsize (src[1].format, src[1].w, src[1].h);
	output_size = imgsize (dst.format, dst.w, dst.h);

	if (/*viodev*/ 1) {
		const char *blocks[2] = { "VPU5", NULL };
		uiomux = uiomux_open_named(blocks);
		uiores = 1 << 0;

	} else {
		uiomux = uiomux_open ();
		uiores = UIOMUX_SH_VEU;
	} 

	/* Set up memory buffers */
	src[0].py = inbuf[0] = uiomux_malloc (uiomux, uiores, input_size[0], 32);
	if (src[0].format == REN_RGB565) {
		src[0].pc = 0;
	} else if (src[0].format == REN_YV12) {
		src[0].pc2 = src[0].py + (src[0].w * src[0].h);	/* Cr(V) */
		src[0].pc = src[0].pc2 + (src[0].w * src[0].h) / 4;	/* Cb(U) */
	} else if (src[0].format == REN_YV16) {
		src[0].pc2 = src[0].py + (src[0].w * src[0].h);	/* Cr(V) */
		src[0].pc = src[0].pc2 + (src[0].w * src[0].h) / 2;	/* Cb(U) */
	} else {
		src[0].pc = src[0].py + (src[0].w * src[0].h);	/* CbCr(UV) */
	}

	if (infilename[1] != NULL) {
		src[1].py = inbuf[1] = uiomux_malloc (uiomux, uiores, input_size[1], 32);
		if (src[1].format == REN_RGB565) {
			src[1].pc = 0;
		} else if (src[1].format == REN_YV12) {
			src[1].pc2 = src[1].py + (src[1].w * src[1].h);	/* Cr(V) */
			src[1].pc = src[1].pc2 + (src[1].w * src[1].h) / 4;	/* Cb(U) */
		} else if (src[1].format == REN_YV16) {
			src[1].pc2 = src[1].py + (src[1].w * src[1].h);	/* Cr(V) */
			src[1].pc = src[1].pc2 + (src[1].w * src[1].h) / 2;	/* Cb(U) */
		} else {
			src[1].pc = src[1].py + (src[1].w * src[1].h);	/* CbCr(UV) */
		}
	}

	dst.py = outbuf = uiomux_malloc (uiomux, uiores, output_size, 32);
	if (dst.format == REN_RGB565) {
		dst.pc = 0;
	} else if (dst.format == REN_YV12) {
		dst.pc2 = dst.py + (dst.w * dst.h);	/* Cr(V) */
		dst.pc = dst.pc2 + (dst.w * dst.h) / 4;	/* Cb(U) */
	} else if (dst.format == REN_YV16) {
		dst.pc2 = dst.py + (dst.w * dst.h);	/* Cr(V) */
		dst.pc = dst.pc2 + (dst.w * dst.h) / 2;	/* Cb(U) */
	} else {
		dst.pc = dst.py + (dst.w * dst.h);	/* CbCr(UV) */
	}

#if defined(USE_MERAM_RA) || defined(USE_MERAM_WB)
#error aaaa
	meram_read_reg(meram, regs, MEVCR1, &val);
	val |= 1 << 29;		/* use 0xc0000000-0xdfffffff */
	meram_write_reg(meram, regs, MEVCR1, val);
	meram_unlock_reg(meram, regs);
#endif /* defined(USE_MERAM_RA) || defined(USE_MERAM_WB) */

#if defined(USE_MERAM_RA)
#error bbbb
	/* calcurate byte-pitch */
	src[0].bpitchy = size_y(src[0].format, src[0].pitch, 0);

	/* set up read-ahead cache for input */
	icbr = meram_lock_icb(meram, 0);
	val = (3 << 24) |		/* KRBNM: ((3+1) << 1) = 8 lines */
		((16 - 1) << 16);	/* BNM: 16 = KRBNM * 2 lines */
	ADJUST_PITCH(sz, src[0].bpitchy);
	sz *= 16;			/* 16 lines */
	if (src[0].format == REN_NV12) {
		val |= 2 << 12;	/* CPL: YCbCr420 */
		sz = sz * 3 / 2;
	} else if (src[0].format == REN_NV16) {
		val |= 3 << 12;	/* CPL: YCbCr422 */
		sz = sz * 2;
	}
	meram_write_icb(meram, icbr, MExxMCNF, val);

	sz = (sz + 1023) / 1024;
	mblock = meram_alloc_icb_memory(meram, icbr,
					    (sz == 0) ? 1 : sz);
	val = (1 << 28) |		/* BSZ: 2^1 line/block */
		(mblock << 16) |	/* MSAR */
		(3 << 9) |		/* WD: (constant) */
		(1 << 8) |		/* WS: (constant) */
		(1 << 3) |		/* CM: address mode 1 */
		1;			/* MD: read buffer mode */
	meram_write_icb(meram, icbr, MExxCTRL, val);

	val = ((src[0].h - 1) << 16) |	/* YSZM1 */
		(src[0].bpitchy - 1);	/* XSZM1 */
	meram_write_icb(meram, icbr, MExxBSIZE, val);
	val = ALIGN16(src[0].bpitchy);	/* SBSIZE: 16 bytes aligned */
	meram_write_icb(meram, icbr, MExxSBSIZE, val);

	ADJUST_PITCH(src[0].bpitchy, src[0].bpitchy);
	src[0].bpitchc = src[0].bpitcha = src[0].bpitchy;

	val = uiomux_all_virt_to_phys(src[0].py);
	meram_write_icb(meram, icbr, MExxSSARA, val);

	src[0].py = (void *)meram_get_icb_address(meram, icbr, 0);
	uiomux_register(src[0].py, (unsigned long)src[0].py, 8 << 20);
	if (is_ycbcr(src[0].format)) {
		val = uiomux_all_virt_to_phys(src[0].pc);
		meram_write_icb(meram, icbr, MExxSSARB, val);
		src[0].pc = (void *)meram_get_icb_address(meram, icbr, 1);
		uiomux_register(src[0].pc, (unsigned long)src[0].pc, 8 << 20);
	} else {
		meram_write_icb(meram, icbr, MExxSSARB, 0);
	}
#endif /* defined(USE_MERAM_RA) */

#if defined(USE_MERAM_WB)
	/* calcurate byte-pitch */
	dst.bpitchy = size_y(dst.format, dst.pitch, 0);

	/* set up write-back cache for input */
	icbw = meram_lock_icb(meram, 1);
	val = (3 << 28) |		/* KWBNM: ((3+1) << 1) = 8 lines */
		((16 - 1) << 16);	/* BNM: 16 = KWBNM * 2 lines */
	ADJUST_PITCH(sz, dst.bpitchy);
	sz *= 16;			/* 16 lines */
	if (dst.format == REN_NV12) {
		val |= 2 << 12;	/* CPL: YCbCr420 */
		sz = sz * 3 / 2;
	} else if (dst.format == REN_NV16) {
		val |= 3 << 12;	/* CPL: YCbCr422 */
		sz = sz * 2;
	}
	meram_write_icb(meram, icbw, MExxMCNF, val);
	sz = (sz + 1023) / 1024;
	mblock = meram_alloc_icb_memory(meram, icbw,
					(sz == 0) ? 1 : sz);
	val = (1 << 28) |		/* BSZ: 2^1 line/block */
		(mblock << 16) |	/* MSAR */
		(3 << 9) |		/* WD: (constant) */
		(1 << 8) |		/* WS: (constant) */
		(1 << 3) |		/* CM: address mode 1 */
		2;			/* MD: write buffer mode */
	meram_write_icb(meram, icbw, MExxCTRL, val);

	val = ((dst.h - 1) << 16) |	/* YSZM1 */
		(dst.bpitchy - 1);	/* XSZM1 */
	meram_write_icb(meram, icbw, MExxBSIZE, val);
	val = ALIGN16(dst.bpitchy);	/* SBSIZE: 16 bytes aligned */
	meram_write_icb(meram, icbw, MExxSBSIZE, val);

	ADJUST_PITCH(dst.bpitchy, dst.bpitchy);
	dst.bpitchc = dst.bpitcha = dst.bpitchy;

	val = uiomux_all_virt_to_phys(dst.py);
	meram_write_icb(meram, icbw, MExxSSARA, val);

	dst.py = (void *)meram_get_icb_address(meram, icbw, 0);
	uiomux_register(dst.py, (unsigned long)dst.py, 8 << 20);
	if (is_ycbcr(dst.format)) {
		val = uiomux_all_virt_to_phys(dst.pc);
		meram_write_icb(meram, icbw, MExxSSARB, val);
		dst.pc = (void *)meram_get_icb_address(meram, icbw, 1);
		uiomux_register(dst.pc, (unsigned long)dst.pc, 8 << 20);
	} else {
		meram_write_icb(meram, icbw, MExxSSARB, 0);
	}
#endif /* defined(USE_MERAM_WB) */

	if (strcmp (infilename[0], "-") == 0) {
		infile[0] = stdin;
	} else {
		infile[0] = fopen (infilename[0], "rb");
		if (infile[0] == NULL) {
			fprintf (stderr, "%s: unable to open input file %s\n",
				 progname, infilename[0]);
			goto exit_err;
		}
	}

	if (infilename[1] != NULL) {
		infile[1] = fopen (infilename[1], "rb");
		if (infile[1] == NULL) {
			fprintf (stderr, "%s: unable to open input file %s\n",
				 progname, infilename[1]);
			goto exit_err;
		}
	}

	if (outfilename != NULL) {
		if (strcmp (outfilename, "-") == 0) {
			outfile = stdout;
		} else {
			outfile = fopen (outfilename, "wb");
			if (outfile == NULL) {
				fprintf (stderr, "%s: unable to open output file %s\n",
					 progname, outfilename);
				goto exit_err;
			}
		}
	}

	if (!viodev)
		vio = shvio_open();
	else
		vio = shvio_open_named(viodev);

	if (vio == 0) {
		fprintf (stderr, "Error opening VIO\n");
		goto exit_err;
	}

	while (1) {
#ifdef DEBUG
		fprintf (stderr, "%s: Converting frame %d\n", progname, frameno);
#endif

		/* Read input */
		if ((nread = fread (inbuf[0], 1, input_size[0], infile[0])) != input_size[0]) {
			if (nread == 0 && feof (infile[0])) {
				break;
			} else {
				fprintf (stderr, "%p, %s: errors reading input file %s %d %d %d\n", inbuf[0],
					 progname, infilename[0], nread, input_size[0], ferror(infile[0]));
			}
		}
#if 1
		if (infilename[1] != NULL) {
			if ((nread = fread (inbuf[1], 1, input_size[1], infile[1])) != input_size[1]) {
				if (nread == 0 && feof (infile[1])) {
					break;
				} else {
					fprintf (stderr, "%s: error reading input file %s\n",
						 progname, infilename[1]);
				}
			}

			printf("invoke shvio_setup_blend()...\n");
			ret = shvio_setup_blend(vio, NULL, srclist, 2, &dst);
			shvio_start(vio);
			printf("shvio_start_blend() = %d\n", ret);
			ret = shvio_wait(vio);
		} else {
#endif
			if (rotation) {
				ret = shvio_rotate(vio, &src[0], &dst, rotation);
			} else {
				ret = shvio_resize(vio, &src[0], &dst);
			}
		}

#if defined(USE_MERAM_WB)
		meram_read_icb(meram, icbw, MExxCTRL, &val);
		val |= 1 << 5;	/* WF: flush data */
		meram_write_icb(meram, icbw, MExxCTRL, val);
#endif
#if defined(USE_MERAM_RA)
		meram_read_icb(meram, icbr, MExxCTRL, &val);
		val |= 1 << 4;	/* RF: flush data */
		meram_write_icb(meram, icbr, MExxCTRL, val);
#endif

		/* Write output */
		if (outfile && fwrite (outbuf, 1, output_size, outfile) != output_size) {
				fprintf (stderr, "%s: error writing input file %s\n",
					 progname, outfilename);
		}

		frameno++;
	}

	shvio_close (vio);

#if defined(USE_MERAM_RA)
	/* finialize the read-ahead cache */
	uiomux_unregister(src[0].py);
	if (is_ycbcr(src[0].format))
		uiomux_unregister(src[0].pc);
	meram_free_icb_memory(meram, icbr);
	meram_unlock_icb(meram, icbr);
#endif
#if defined(USE_MERAM_WB)
	/* finialize the write-back cache */
	uiomux_unregister(dst.py);
	if (is_ycbcr(dst.format))
		uiomux_unregister(dst.pc);
	meram_free_icb_memory(meram, icbw);
	meram_unlock_icb(meram, icbw);
#endif
#if defined(USE_MERAM_RA) || defined(USE_MERAM_WB)
	meram_close(meram);
#endif

	uiomux_free (uiomux, uiores, src[0].py, input_size[0]);
	if (infilename[1] != NULL)
		uiomux_free (uiomux, uiores, src[1].py, input_size[1]);
	uiomux_free (uiomux, uiores, dst.py, output_size);
	uiomux_close (uiomux);

	if (infile[0] != stdin) fclose (infile[0]);
	if (infilename[1] != NULL)
		fclose (infile[1]);

	if (outfile == stdout) {
		fflush (stdout);
	} else if (outfile) {
		fclose (outfile);
	}

	printf ("Frames:\t\t%d\n", frameno);

exit_ok:
	exit (0);

exit_err:
	exit (1);
}
コード例 #13
0
/* return TRUE if a command match, FALSE if not */
static TBOOLEAN
 show_two()
{
    if (almost_equals(c_token, "p$lot")) {
	(void) putc('\n', stderr);
	show_plot();
	c_token++;
    } else if (almost_equals(c_token, "par$ametric")) {
	(void) putc('\n', stderr);
	show_parametric();
	c_token++;
    } else if (almost_equals(c_token, "poi$ntsize")) {
	(void) putc('\n', stderr);
	show_pointsize();
	c_token++;
    } else if (almost_equals(c_token, "enc$oding")) {
	(void) putc('\n', stderr);
	show_encoding();
	c_token++;
    } else if (almost_equals(c_token, "pol$ar")) {
	(void) putc('\n', stderr);
	show_polar();
	c_token++;
    } else if (almost_equals(c_token, "an$gles")) {
	(void) putc('\n', stderr);
	show_angles();
	c_token++;
    } else if (almost_equals(c_token, "ti$cs")) {
	(void) putc('\n', stderr);
	show_tics(TRUE, TRUE, TRUE, TRUE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "tim$estamp")) {
	(void) putc('\n', stderr);
	show_xyzlabel("time", &timelabel);
	fprintf(stderr, "\twritten in %s corner\n", (timelabel_bottom ? "bottom" : "top"));
	if (timelabel_rotate)
	    fputs("\trotated if the terminal allows it\n\t", stderr);
	else
	    fputs("\tnot rotated\n\t", stderr);
	c_token++;
    } else if (almost_equals(c_token, "su$rface")) {
	(void) putc('\n', stderr);
	show_surface();
	c_token++;
    } else if (almost_equals(c_token, "hi$dden3d")) {
	(void) putc('\n', stderr);
	show_hidden3d();
	c_token++;
    } else if (almost_equals(c_token, "cla$bel")) {
	(void) putc('\n', stderr);
	show_label_contours();
	c_token++;
    } else if (almost_equals(c_token, "xti$cs")) {
	show_tics(TRUE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "yti$cs")) {
	show_tics(FALSE, TRUE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "zti$cs")) {
	show_tics(FALSE, FALSE, TRUE, FALSE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "x2ti$cs")) {
	show_tics(FALSE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "y2ti$cs")) {
	show_tics(FALSE, FALSE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "xdti$cs")) {
	show_tics(TRUE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "ydti$cs")) {
	show_tics(FALSE, TRUE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "zdti$cs")) {
	show_tics(FALSE, FALSE, TRUE, FALSE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "x2dti$cs")) {
	show_tics(FALSE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "y2dti$cs")) {
	show_tics(FALSE, FALSE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "xmti$cs")) {
	show_tics(TRUE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "ymti$cs")) {
	show_tics(FALSE, TRUE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "zmti$cs")) {
	show_tics(FALSE, FALSE, TRUE, FALSE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "x2mti$cs")) {
	show_tics(FALSE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "y2mti$cs")) {
	show_tics(FALSE, FALSE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "sa$mples")) {
	(void) putc('\n', stderr);
	show_samples();
	c_token++;
    } else if (almost_equals(c_token, "isosa$mples")) {
	(void) putc('\n', stderr);
	show_isosamples();
	c_token++;
    } else if (almost_equals(c_token, "si$ze")) {
	(void) putc('\n', stderr);
	show_size();
	c_token++;
    } else if (almost_equals(c_token, "orig$in")) {
	(void) putc('\n', stderr);
	show_origin();
	c_token++;
    } else if (almost_equals(c_token, "t$erminal")) {
	(void) putc('\n', stderr);
	show_term();
	c_token++;
    } else if (almost_equals(c_token, "rr$ange")) {
	(void) putc('\n', stderr);
	show_range(R_AXIS, rmin, rmax, autoscale_r, "r");
	c_token++;
    } else if (almost_equals(c_token, "tr$ange")) {
	(void) putc('\n', stderr);
	show_range(T_AXIS, tmin, tmax, autoscale_t, "t");
	c_token++;
    } else if (almost_equals(c_token, "ur$ange")) {
	(void) putc('\n', stderr);
	show_range(U_AXIS, umin, umax, autoscale_u, "u");
	c_token++;
    } else if (almost_equals(c_token, "vi$ew")) {
	(void) putc('\n', stderr);
	show_view();
	c_token++;
    } else if (almost_equals(c_token, "vr$ange")) {
	(void) putc('\n', stderr);
	show_range(V_AXIS, vmin, vmax, autoscale_v, "v");
	c_token++;
    } else if (almost_equals(c_token, "v$ariables")) {
	show_variables();
	c_token++;
    } else if (almost_equals(c_token, "ve$rsion")) {
	show_version(stderr);
    } else if (almost_equals(c_token, "xr$ange")) {
	(void) putc('\n', stderr);
	show_range(FIRST_X_AXIS, xmin, xmax, autoscale_x, "x");
	c_token++;
    } else if (almost_equals(c_token, "yr$ange")) {
	(void) putc('\n', stderr);
	show_range(FIRST_Y_AXIS, ymin, ymax, autoscale_y, "y");
	c_token++;
    } else if (almost_equals(c_token, "x2r$ange")) {
	(void) putc('\n', stderr);
	show_range(SECOND_X_AXIS, x2min, x2max, autoscale_x2, "x2");
	c_token++;
    } else if (almost_equals(c_token, "y2r$ange")) {
	(void) putc('\n', stderr);
	show_range(SECOND_Y_AXIS, y2min, y2max, autoscale_y2, "y2");
	c_token++;
    } else if (almost_equals(c_token, "zr$ange")) {
	(void) putc('\n', stderr);
	show_range(FIRST_Z_AXIS, zmin, zmax, autoscale_z, "z");
	c_token++;
    } else if (almost_equals(c_token, "z$ero")) {
	(void) putc('\n', stderr);
	show_zero();
	c_token++;
    } else if (almost_equals(c_token, "a$ll")) {
	c_token++;
	show_version(stderr);
	show_autoscale();
	show_bars();
	show_border();
	show_boxwidth();
	show_clip();
	show_contour();
	show_dgrid3d();
	show_mapping();
	(void) fprintf(stderr, "\tdummy variables are \"%s\" and \"%s\"\n",
		       dummy_var[0], dummy_var[1]);
	show_format();
	show_style("data", data_style);
	show_style("functions", func_style);
	show_grid();
	show_xzeroaxis();
	show_yzeroaxis();
	show_label(0);
	show_arrow(0);
	show_linestyle(0);
	show_keytitle();
	show_key();
	show_logscale();
	show_offsets();
	show_margin();
	show_output();
	show_parametric();
	show_pointsize();
	show_encoding();
	show_polar();
	show_angles();
	show_samples();
	show_isosamples();
	show_view();
	show_surface();
#ifndef LITE
	show_hidden3d();
#endif
	show_size();
	show_origin();
	show_term();
	show_tics(TRUE, TRUE, TRUE, TRUE, TRUE);
	show_mtics(mxtics, mxtfreq, "x");
	show_mtics(mytics, mytfreq, "y");
	show_mtics(mztics, mztfreq, "z");
	show_mtics(mx2tics, mx2tfreq, "x2");
	show_mtics(my2tics, my2tfreq, "y2");
	show_xyzlabel("time", &timelabel);
	if (parametric || polar) {
	    if (!is_3d_plot)
		show_range(T_AXIS, tmin, tmax, autoscale_t, "t");
	    else {
		show_range(U_AXIS, umin, umax, autoscale_u, "u");
		show_range(V_AXIS, vmin, vmax, autoscale_v, "v");
	    }
	}
	show_range(FIRST_X_AXIS, xmin, xmax, autoscale_x, "x");
	show_range(FIRST_Y_AXIS, ymin, ymax, autoscale_y, "y");
	show_range(SECOND_X_AXIS, x2min, x2max, autoscale_x2, "x2");
	show_range(SECOND_Y_AXIS, y2min, y2max, autoscale_y2, "y2");
	show_range(FIRST_Z_AXIS, zmin, zmax, autoscale_z, "z");
	show_xyzlabel("title", &title);
	show_xyzlabel("xlabel", &xlabel);
	show_xyzlabel("ylabel", &ylabel);
	show_xyzlabel("zlabel", &zlabel);
	show_xyzlabel("x2label", &x2label);
	show_xyzlabel("y2label", &y2label);
	show_datatype("xdata", FIRST_X_AXIS);
	show_datatype("ydata", FIRST_Y_AXIS);
	show_datatype("x2data", SECOND_X_AXIS);
	show_datatype("y2data", SECOND_Y_AXIS);
	show_datatype("zdata", FIRST_Z_AXIS);
	show_timefmt();
	show_locale();
	show_zero();
	show_missing();
	show_plot();
	show_variables();
	show_functions();
	c_token++;
    } else
	return (FALSE);
    return (TRUE);
}
コード例 #14
0
ファイル: pcap.c プロジェクト: mafzzz/heterogeneous_hthreads
void setup_ncurses( void )
{
    main_win = initscr();
    keypad(main_win, TRUE);     // enable keyboard mapping
    nonl();                     // tell curses not to do NL->CR/NL on output
    cbreak();                   // input chars one at a time, no wait for \n
    noecho();                   // don't echo input
    nodelay(main_win, TRUE);    // do non-blocking input
    curs_set( 0 );              // don't show the cursor

    size_win = create_window( main_win, 6, COLS/2, 0, 0 );
    pack_win = create_window( main_win, 6, COLS/2, 0, COLS/2 );
    mini_win = create_window( main_win, 5, COLS/4, 6, 0*(COLS/4) );
    maxi_win = create_window( main_win, 5, COLS/4, 6, 1*(COLS/4) );
    mean_win = create_window( main_win, 5, COLS/4, 6, 2*(COLS/4) );
    stdd_win = create_window( main_win, 5, COLS/4, 6, 3*(COLS/4) );
    data_win = create_window( main_win, LINES - 16, COLS, 11, 0 );
    oper_win = create_window( main_win, 5, COLS, LINES-5, 0 );

    // Use colors if the terminal has them
    if( has_colors() )
    {
        start_color();
        /*
        * Simple color assignment, often all we need.
        */
        init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
        init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
        init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
        init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
        init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
        init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
        init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
        init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
    }

    show_size( size_win, 0, 0 );
    show_packet( pack_win, NULL, 0 );
    show_mini( mini_win, 0 );
    show_maxi( maxi_win, 0 );
    show_mean( mean_win, 0 );
    show_stdd( stdd_win, 0 );
    show_data( data_win, NULL, 0 );
    show_operation( oper_win, "Waiting for Data..." );

    box( size_win, 0, 0 );
    box( pack_win, 0, 0 );
    box( mini_win, 0, 0 );
    box( maxi_win, 0, 0 );
    box( mean_win, 0, 0 );
    box( stdd_win, 0, 0 );
    box( data_win, 0, 0 );
    box( oper_win, 0, 0 );
    
    wrefresh( size_win );
    wrefresh( pack_win );
    wrefresh( mini_win );
    wrefresh( maxi_win );
    wrefresh( mean_win );
    wrefresh( stdd_win );
    wrefresh( data_win );
    wrefresh( oper_win );
}
コード例 #15
0
ファイル: pcap.c プロジェクト: mafzzz/heterogeneous_hthreads
void dump_packet( Huint size, Huint *data, FILE *fl)
{
    Huint   i;
    Huint   val;
    float   temp;
    float   sum;
    
    fwrite( data, sizeof(Huint), size, fl );
    fflush( fl );

    num_bytes   += size * sizeof(Huint);
    num_packets += 1;

    for( i = 0; i < size; i++ )
    {
        val = ntohl( data[i] );

        res_total   += val;
        res_number  += 1;

        if( val > res_max || res_number == 1 )  res_max = val;
        if( val < res_min || res_number == 1 )  res_min = val;
    }

    if( res_number > 0 )    res_mean = (float)res_total / (float)res_number;
    else                    res_mean = 0.0f;
    
    sum = 0;
    for( i = 0; i < size; i++ )
    {
        val     = ntohl( data[i] );
        temp    = val - res_mean;
        sum     += (temp * temp); 
    }

    sum /= (size - 1);
    res_std = sqrt( sum );

    show_size( size_win, num_bytes, num_packets );
    show_packet( pack_win, (Hubyte*)data, size*sizeof(Huint) );
    show_mini( mini_win, res_min );
    show_maxi( maxi_win, res_max );
    show_mean( mean_win, res_mean );
    show_stdd( stdd_win, res_std );
    show_data( data_win, (Hubyte*)data, size*sizeof(Huint) );
    show_operation( oper_win, "Showing Data..." );

    box( size_win, 0, 0 );
    box( pack_win, 0, 0 );
    box( mini_win, 0, 0 );
    box( maxi_win, 0, 0 );
    box( mean_win, 0, 0 );
    box( stdd_win, 0, 0 );
    box( data_win, 0, 0 );
    box( oper_win, 0, 0 );
    
    wrefresh( size_win );
    wrefresh( pack_win );
    wrefresh( mini_win );
    wrefresh( maxi_win );
    wrefresh( mean_win );
    wrefresh( stdd_win );
    wrefresh( data_win );
    wrefresh( oper_win );
}