Пример #1
0
/*
 * Construct one file in a PID directory, if a file with the given name should
 * exist at all.
 */
static void
make_one_pid_entry(struct inode * parent, char * name, int slot)
{
	struct inode *node;
	struct inode_stat stat;
	int i;

	/* Don't readd if it is already there. */
	node = get_inode_by_name(parent, name);
	if (node != NULL)
		return;

	/* Only add the file if it is a known, registered name. */
	for (i = 0; pid_files[i].name != NULL; i++) {
		if (!strcmp(name, pid_files[i].name)) {
			make_stat(&stat, slot, i);

			node = add_inode(parent, name, i, &stat, (index_t)0,
			    (cbdata_t)0);

			if (node == NULL)
				out_of_inodes();

			break;
		}
	}
}
Пример #2
0
Stat *make_center_broken_nodes_count_stat(){
  Stat *ret = make_stat(ALL, DISTANCE_DIRECT, BROKEN, COUNT);
  if(ret == NULL) return ret;

  ret->is_center = only_one_node;
  ret->distance_func = fake_distance;
  return ret;
}
Пример #3
0
Stat *make_center_cascade_nodes_count_stat(){
  Stat *ret = make_stat(ATTACK,DISTANCE_WALK,CASCADE,COUNT);

  if(ret == NULL) return ret;

  ret->is_center = only_one_node;
  ret->distance_func = fake_distance;
  return ret;
}
Пример #4
0
/*
 * Construct all files in a PID directory.
 */
static void
make_all_pid_entries(struct inode * parent, int slot)
{
	struct inode *node;
	struct inode_stat stat;
	int i;

	for (i = 0; pid_files[i].name != NULL; i++) {
		node = get_inode_by_index(parent, i);
		if (node != NULL)
			continue;

		make_stat(&stat, slot, i);

		node = add_inode(parent, pid_files[i].name, i, &stat,
		    (index_t)0, (cbdata_t)0);

		if (node == NULL)
			out_of_inodes();
	}
}
Пример #5
0
 void process_block_impl(Block* block, ThreadData* data) const {
     BranchData* d = boost::polymorphic_downcast<BranchData*>(data);
     AlignmentStat stat;
     make_stat(stat, block);
     double block_weight = stat.noident_nogap() + stat.noident_gap();
     if (block_weight < opt_value("min-noident").as<int>()) {
         return;
     }
     if (opt_value("log").as<bool>()) {
         block_weight = log(block_weight);
     }
     boost::scoped_ptr<TreeNode> tree(print_tree_->make_tree(block));
     Leafs leafs;
     tree->all_leafs(leafs);
     std::sort(leafs.begin(), leafs.end(), GenomeNameCompare());
     BranchTable t;
     tree->branch_table(t, leafs, block_weight);
     add_table(d->table, t);
     BOOST_FOREACH (const BranchTable::value_type& branch_length,
                   t) {
         d->branch_blocks[branch_length.first].push_back(block);
     }
Пример #6
0
/* and final */
static void print_stat(Parrot_Interp interpreter, IMC_Unit * unit)
{
    int sets[4] = {0,0,0,0};
    int cols[4] = {-1,-1,-1,-1};

    make_stat(unit, sets, cols);
    info(interpreter, 1, "sub %s:\n\tregisters in .imc:\t I%d, N%d, S%d, P%d\n",
            function, imcsets[0], imcsets[1], imcsets[2], imcsets[3]);
    info(interpreter, 1, "\t%d labels, %d lines deleted, %d if_branch, %d branch_branch\n",
            ostat.deleted_labels, ostat.deleted_ins, ostat.if_branch,
            ostat.branch_branch);
    info(interpreter, 1, "\t%d used once deleted\n",
            ostat.used_once);
    info(interpreter, 1, "\t%d invariants_moved\n", ostat.invariants_moved);
    info(interpreter, 1, "\tregisters needed:\t I%d, N%d, S%d, P%d\n",
            sets[0], sets[1], sets[2], sets[3]);
    info(interpreter, 1, "\tregisters in .pasm:\t I%d, N%d, S%d, P%d - %d spilled\n",
            cols[0]+1, cols[1]+1, cols[2]+1, cols[3]+1,
            unit->n_spilled);
    info(interpreter, 1, "\t%d basic_blocks, %d edges\n",
            unit->n_basic_blocks, edge_count(unit));

}
Пример #7
0
int main(string dest) {
   object ob,item;
   string buf;
   int age,x,ac,width;

   ob = this_player();

   if( dest && this_player()->query_level() >= WIZLEVEL ) {
      ob = find_player(dest);
      if( !ob ) ob = find_living( dest );
	  if( !ob ) {
         ob = single_present( dest, environment(this_player()) );
		 if( ob && !ob->query_is_living() )
            ob = 0;
	  }
      if (!ob) {
         msg(capitalize(dest)+" was not found.");
         return 1;
      }
   }

   age = ob->query_age()-ob->query_last_login();
   if( age ) age += time();
   width = this_player()->query_term_width();

   buf = "~CSC2"+tab("-",width-3)+"\n";
   buf += pad("~CSC3"+ob->query_pretitle()+"~CSC4 "+capitalize(""+ob->query_name())+" ~CSC3"+ob->query_title(),width+12,2)+"\n";
   buf += "~CSC2"+tab("-",width-3)+"\n";
   buf += "~CSC4Level: ~CSC3"+query_personal_title(ob);
   if (this_player()->query_level() >= WIZLEVEL)
     buf += " ("+(string)ob->query_level()+")";

   buf +=  "\n~CSC4Str: " + make_stat(ob, "strength");
   buf +=  "~CSC4Dex: " + make_stat(ob, "dexterity");
   buf +=  "~CSC4Con: " + make_stat(ob, "constitution");
   buf +=  "~CSC4Spd: " + make_stat(ob, "speed") + "\n";

   buf +=  "~CSC4Wil: " + make_stat(ob, "will");
   buf +=  "~CSC4Int: " + make_stat(ob, "intelligence");
   buf +=  "~CSC4Emp: " + make_stat(ob, "empathy");
   buf +=  "~CSC4Cha: " + make_stat(ob, "charm") + "\n";

   buf += "~CSC4Alignment: ~CSC3"+ob->query_alignment_string();
   if (this_player()->query_level() >= WIZLEVEL)
     buf += "~CSC2 (lawful: "+ob->query_lawful_alignment()+", good: "+ob->query_good_alignment()+")\n";
   else
     buf += "\n";

   if( age != 0 )
      buf += "~CSC4Age:    ~CSC3"+int_to_time(age)+"\n";
   buf += pad("~CSC4Sex:    ~CSC3"+gender_string(ob->query_gender()), 32, 0);
   buf += pad(" ~CSC4Race: ~CSC3"+capitalize(ob->query_race()), 31, 0);
   buf += " ~CSC4Deaths: ~CSC3"+ob->query_deaths()+"\n";
   buf += "~CSC4Weight: ~CSC3"+ob->query_us_weight()+" lbs";
   if (this_player()->query_level() >= WIZLEVEL)
     buf += "~CSC2 ("+ob->query_weight()+" grams)\n";
   else
     buf += "~CSC2 ("+(ob->query_weight()/1000)+" kg)\n";

   buf += "~CSC4Carried:  ~CSC3" + carry_string(ob) + "\n";

   buf += "/bin/hp"->hp_string(ob)+"\n";

   buf += "~CSC2Food:   " + meter( ob, "food" ) + "\n";
   buf += "~CSC2Water:  " + meter( ob, "drink" ) + "\n";

   buf += "~CSC4Defense: ~CSC3" + ac_string(ob) + "\n";
   buf += pad("~CSC4Form:    ~CSC3" + capitalize(ob->query_form()),32,0);

   if (ob->query_skill("other.endurance"))
     buf += pad(" ~CSC4Soak: ~CSC3" + (ob->query_soak()?"on":"off"),32,0);
   buf += "~CSC4Wimpy: ~CSC3" + (ob->query_wimpy()?ob->query_wimpy()+"%":"off") + "\n";

   if( find_objectref(ob->query_env_var("home")) ) {
       object home_room = find_objectref(ob->query_env_var("home"));
       object home_bldg = environment(home_room);
       object home_zone;
	   buf += "~CSC4Home:    ~CSC3"+home_room->query_short();
       if( home_bldg ) {
          home_zone = environment(home_bldg);
		  string owner;
          if( home_bldg->query_owner() )
            owner = capitalize(home_bldg->query_owner())+"'s";
          else
            owner = "An unowned";
          buf += ", "+owner+" "+home_bldg->query_name()+", "+home_zone->query_short();
       }
       buf += "\n";
   }

   // stance
   buf += "~CSC3"+pronoun_string(ob);
   switch (ob->query_stance()) {
     case ST_STANDING: buf += "standing up."; break;
     case ST_SITTING: buf += "sitting down."; break;
     case ST_LYING: buf += "lying down."; break;
     case ST_CROUCHING: buf += "crouching."; break;
     case ST_JUMPING: buf += "jumping."; break;
     case ST_FALLING: buf += "falling."; break;
	 case ST_FLYING: buf += "flying."; break;
     case ST_UNBALANCED: buf += "unbalanced."; break;
     default: buf += "tilted at some obnoxiously uncomfortable angle."; break;
   }

   // party
   if( ob->query_env_var("party") ) {
     string party = ob->query_env_var("party");
     string pupil = ob->query_env_var("mentoring");
     string leader = PARTY_DAEMON->query_party_leader(party);
     buf += "\n~CSC3" + pronoun_string(ob) +
            (leader == ob->query_name() ? "the leader" : "a member") +
            " of the party ~CSC2" + capitalize(party) + "~CSC3";
     if( pupil )
       buf += ", and are mentoring ~CSC2" + capitalize(pupil) + "~CSC3.";
     else if( pupil = PARTY_DAEMON->query_mentor(ob->query_name()) ) {
       buf += ", " + (ob==this_player()?"and":"is") +
			  " are being mentored by ~CSC2" + capitalize(pupil) + "~CSC3.";
	 } else
       buf += ".";
   }

   buf += "\n~CSC2"+tab("-",width-3);

   msg(buf+"~CDEF");
   return 1;
}
Пример #8
0
int
main(int argc, char **argv)
	{
	int	i, fdin, ss_v, ss_h, chroma_ss, textout;
	int 	do_vectorscope;
	int	pwidth, pheight; /* Needed for the vectorscope */
	int	plane0_l, plane1_l, plane2_l;
	u_char	*yuv[3], *cp;
#ifdef	HAVE_SDLgfx
	int	j;
	int temp_x, temp_y;
	u_char	*cpx, *cpy;
#endif
	y4m_stream_info_t istream;
	y4m_frame_info_t iframe;

	do_vectorscope = 0;
	scalepercent = 0;

#ifdef	HAVE_SDLgfx
	textout = 0;
#else
	textout = 1;
#endif

	while	((i = getopt(argc, argv, "tps:")) != EOF)
		{
		switch	(i)
			{
			case	't':
				textout = 1;
				break;
			case	'p':
				scalepercent = 1;
				break;
			case	's':
				do_vectorscope = atoi(optarg);
				break;
			default:
				usage();
			}
		}

#ifdef HAVE_SDLgfx
	if ( (do_vectorscope < 0) || (do_vectorscope >16) )
		usage();

	/* Initialize SDL */
	desired_bpp = 8; 
	video_flags = 0;
	video_flags |= SDL_DOUBLEBUF;
	number_of_frames = 1;

	memset(fy_stats, '\0', sizeof (fy_stats));
	memset(ly_stats, '\0', sizeof (ly_stats));

        if	( SDL_Init(SDL_INIT_VIDEO) < 0 ) 
                mjpeg_error_exit1("Couldn't initialize SDL:%s",SDL_GetError());
        atexit(SDL_Quit);                       /* Clean up on exit */
        /* Initialize the display */
	if (do_vectorscope == 0)
	        screen = SDL_SetVideoMode(width,heigth,desired_bpp,video_flags);
	else
	        screen=SDL_SetVideoMode(width_v,heigth,desired_bpp,video_flags);

        if	(screen == NULL)
                mjpeg_error_exit1("Couldn't set %dx%dx%d video mode: %s",
                                width, heigth, desired_bpp, SDL_GetError());

	SDL_WM_SetCaption("y4mhistogram", "y4mhistogram");

	y4m_init_area(screen); /* Here we draw the basic layout */
#endif /* HAVE_SDLgfx */

	fdin = fileno(stdin);

	y4m_accept_extensions(1);

	y4m_init_stream_info(&istream);
	y4m_init_frame_info(&iframe);

	if	(y4m_read_stream_header(fdin, &istream) != Y4M_OK)
		mjpeg_error_exit1("stream header error");

        if      (y4m_si_get_plane_count(&istream) != 3)
                mjpeg_error_exit1("Only 3 plane formats supported");

	pwidth = y4m_si_get_width(&istream);
	pheight = y4m_si_get_height(&istream);
	chroma_ss = y4m_si_get_chroma(&istream);
	ss_h = y4m_chroma_ss_x_ratio(chroma_ss).d;
	ss_v = y4m_chroma_ss_y_ratio(chroma_ss).d;


	plane0_l = y4m_si_get_plane_length(&istream, 0);
	plane1_l = y4m_si_get_plane_length(&istream, 1);
	plane2_l = y4m_si_get_plane_length(&istream, 2);

	yuv[0] = malloc(plane0_l);
	if	(yuv[0] == NULL)
		mjpeg_error_exit1("malloc(%d) plane 0", plane0_l);
	yuv[1] = malloc(plane1_l);
	if	(yuv[1] == NULL)
		mjpeg_error_exit1(" malloc(%d) plane 1", plane1_l);
	yuv[2] = malloc(plane2_l);
	if	(yuv[2] == NULL)
		mjpeg_error_exit1(" malloc(%d) plane 2\n", plane2_l);

	while	(y4m_read_frame(fdin,&istream,&iframe,yuv) == Y4M_OK)
		{
		for	(i = 0, cp = yuv[0]; i < plane0_l; i++, cp++)
			y_stats[*cp]++; /* Y' */
		for	(i = 0, cp = yuv[1]; i < plane1_l; i++, cp++)
			u_stats[*cp]++;	/* U */
		for	(i = 0, cp = yuv[2]; i < plane2_l; i++, cp++)
			v_stats[*cp]++;	/* V */
#ifdef HAVE_SDLgfx
			
		if (do_vectorscope >= 1 )
		{
		
		for (i=0; i<260; i++) /* Resetting the vectorfield */
			for (j=0;j<260;j++)
				vectorfield[i][j]=0;

		cpx = yuv[1];
		cpy = yuv[2];

		for (i=0; i < (pheight/ss_h); i++)
			{
			for (j = 0; j < (pwidth/ss_v); j++)
				{
					cpx++;
					cpy++;

					/* Have no idea why I have to multiply it with that values
					   But than the vectorsscope works correct. If someone has
						a explantion or better fix tell me. Bernhard */
					temp_x = round( 128+ ((*cpx-128) * 0.7857) );
					temp_y = round( 128+ ((*cpy-128) * 1.1143) );
					vectorfield[temp_x][temp_y*-1]=1;
				}

				/* Here we got to the n'th next line if needed */
				i   = i + (do_vectorscope-1);
				cpy = cpy + (pwidth/ss_v) * (do_vectorscope-1);
				cpx = cpx + (pwidth/ss_v) * (do_vectorscope-1);
			}

		}
		make_stat(); /* showing the sats */

		SDL_UpdateRect(screen,0,0,0,0); /* updating all */

		/* Events for SDL */
		HandleEvent();
#endif
		}
	y4m_fini_frame_info(&iframe);
	y4m_fini_stream_info(&istream);

	if	(textout)
		{
		for	(i = 0; i < 255; i++)
			printf("Y %d %lld\n", i, y_stats[i]);
		for	(i = 0; i < 255; i++)
			printf("U %d %lld\n", i, u_stats[i]);
		for	(i = 0; i < 255; i++)
			printf("V %d %lld\n", i, v_stats[i]);
		}
	exit(0);
	}
Пример #9
0
/*
 * Regenerate the set of PID directories in the root directory of the file
 * system.  Add new directories and delete old directories as appropriate;
 * leave unchanged those that should remain the same.
 */
static void
construct_pid_dirs(void)
{
	/*
	 * We have to make two passes.  Otherwise, we would trigger a vtreefs
	 * assert when we add an entry for a PID before deleting the previous
	 * entry for that PID.  While rare, such rapid PID reuse does occur in
	 * practice.
	 */
	struct inode *root, *node;
	struct inode_stat stat;
	char name[PNAME_MAX+1];
	pid_t pid;
	int i;

	root = get_root_inode();

	/* First pass: delete old entries. */
	for (i = 0; i < NR_PROCS + NR_TASKS; i++) {
		/* Do we already have an inode associated with this slot? */
		node = get_inode_by_index(root, i);
		if (node == NULL)
			continue;

		/*
		 * If the process slot is not in use, delete the associated
		 * inode.
		 */
		if (!slot_in_use(i)) {
			delete_inode(node);

			continue;
		}

		/* Otherwise, get the process ID. */
		if (i < NR_TASKS)
			pid = (pid_t)(i - NR_TASKS);
		else
			pid = mproc[i - NR_TASKS].mp_pid;

		/*
		 * If there is an old entry, see if the pid matches the current
		 * entry, and the owner is still the same.  Otherwise, delete
		 * the old entry first.  We reconstruct the entire subtree even
		 * if only the owner changed, for security reasons: if a
		 * process could keep open a file or directory across the owner
		 * change, it might be able to access information it shouldn't.
		 */
		if (pid != (pid_t)get_inode_cbdata(node) ||
		    !check_owner(node, i))
			delete_inode(node);
	}

	/* Second pass: add new entries. */
	for (i = 0; i < NR_PROCS + NR_TASKS; i++) {
		/* If the process slot is not in use, skip this slot. */
		if (!slot_in_use(i))
			continue;

		/*
		 * If we have an inode associated with this slot, we have
		 * already checked it to be up-to-date above.
		 */
		if (get_inode_by_index(root, i) != NULL)
			continue;

		/* Get the process ID. */
		if (i < NR_TASKS)
			pid = (pid_t)(i - NR_TASKS);
		else
			pid = mproc[i - NR_TASKS].mp_pid;

		/* Add the entry for the process slot. */
		snprintf(name, PNAME_MAX + 1, "%d", pid);

		make_stat(&stat, i, NO_INDEX);

		node = add_inode(root, name, i, &stat, nr_pid_entries,
		    (cbdata_t)pid);

		if (node == NULL)
			out_of_inodes();
	}
}
Пример #10
0
/* registes usage of .imc */
static void imc_stat_init(IMC_Unit * unit) {
    imcsets[0] = imcsets[1] = imcsets[2] = imcsets[3] = 0;
    make_stat(unit, imcsets, 0);
    memset(&ostat, 0, sizeof(ostat));
}