예제 #1
0
파일: output.c 프로젝트: joelnitta/moorea
void print_ancestor_line(node *n){
  node *lt,*rt;

  if( ! is_terminal(n) ){
    lt=get_terminal(n,LEFT);
    rt=get_terminal(n,RIGHT);

    dprint(RES_FILE,"%-20s %-20s ",lt->name,rt->name);
    if( n->name == NULL )
       dprint(RES_FILE , "%-20s ", "-");
    else
       dprint(RES_FILE , "%-20s ", n->name);

    if(EDGE_LENS_ARE_INTEGERS == TRUE ){
       dprint(RES_FILE,"%10.3f +/- %-10.3f",n->mpl,prob2normval(1-PROB_LIMIT) * sqrt(n->var));
    }
    else{
       dprint(RES_FILE,"%10.3f +/- %-10s",n->mpl,STAT_MISSING);
    }
    dprint(RES_FILE , "%12d " , n->num_of_terminals);

    //printf("chis: %f free:%d prob:%f\n", n->chi_sq, n->num_of_children-1, n->prob);

	if(EDGE_LENS_ARE_INTEGERS == FALSE){
	      dprint(RES_FILE,"%14s",STAT_MISSING);
	}
	else if( n->accepted == FALSE )
      		dprint(RES_FILE,"%8s, %s%f",REJ_WORD, "prob=",(double)n->prob);
    	else
      		dprint(RES_FILE,"%8s",ACC_WORD);
    dprint(RES_FILE,"\n");
  }
}
예제 #2
0
/**
 * Get the end of a chain of references. If the final one is not
 * found, we return the reference just before that.
 */
static int get_terminal(git_reference **out, git_repository *repo, const char *ref_name, int nesting)
{
	git_reference *ref;
	int error = 0;

	if (nesting > MAX_NESTING_LEVEL) {
		giterr_set(GITERR_REFERENCE, "Reference chain too deep (%d)", nesting);
		return GIT_ENOTFOUND;
	}

	/* set to NULL to let the caller know that they're at the end of the chain */
	if ((error = git_reference_lookup(&ref, repo, ref_name)) < 0) {
		*out = NULL;
		return error;
	}

	if (git_reference_type(ref) == GIT_REF_OID) {
		*out = ref;
		error = 0;
	} else {
		error = get_terminal(out, repo, git_reference_symbolic_target(ref), nesting + 1);
		if (error == GIT_ENOTFOUND && !*out)
			*out = ref;
		else
			git_reference_free(ref);
	}

	return error;
}
예제 #3
0
파일: output.c 프로젝트: joelnitta/moorea
void print_ancestor_age_line(node *n){
  node *lt,*rt;
  double min, max;

  if( ! is_terminal(n) ){
    lt=get_terminal(n,LEFT);
    rt=get_terminal(n,RIGHT);

    dprint(RES_FILE,"%-20s %-20s ", lt->name,rt->name);

    if( n->name == NULL )
       dprint(RES_FILE , "%-20s ", "-");
    else
       dprint(RES_FILE , "%-20s ", n->name);

    dprint(RES_FILE,"%10.3f ",n->fix->calc_age);
    dprint(RES_FILE,"%11d ",n->num_of_terminals);
    dprint(RES_FILE,"%16.3f ",n->mpl);
    dprint(RES_FILE,"%14f ",n->mpl / n->fix->calc_age);
    min = n->fix->minage;
    max = n->fix->maxage;
    
    if( is_fixnode(n)==TRUE && is_forced_fixnode(n) == FALSE){
      min = max = n->fix->fixage;
    }
    if( is_minnode(n)==FALSE && !(is_fixnode(n) == TRUE && is_forced_fixnode(n)==FALSE) )
      dprint(RES_FILE,"%11s " ,"-");
    else
      dprint(RES_FILE,"%11.1f " ,min);
    if( is_maxnode(n)==FALSE && !(is_fixnode(n) == TRUE && is_forced_fixnode(n) == FALSE) )
      dprint(RES_FILE,"%11s " ,"-");
    else
      dprint(RES_FILE,"%11.1f ",max);

    dprint(RES_FILE,"\n");
  }
}
예제 #4
0
static struct frame *
frame_for_x_selection (Lisp_Object object)
{
  Lisp_Object tail;
  struct frame *f;

  if (NILP (object))
    {
      f = XFRAME (selected_frame);
      if (FRAME_MAC_P (f) && FRAME_LIVE_P (f))
	return f;

      for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
	{
	  f = XFRAME (XCAR (tail));
	  if (FRAME_MAC_P (f) && FRAME_LIVE_P (f))
	    return f;
	}
    }
  else if (TERMINALP (object))
    {
      struct terminal *t = get_terminal (object, 1);
      if (t->type == output_mac)
	{
	  for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
	    {
	      f = XFRAME (XCAR (tail));
	      if (FRAME_LIVE_P (f) && f->terminal == t)
		return f;
	    }
	}
    }
  else if (FRAMEP (object))
    {
      f = XFRAME (object);
      if (FRAME_MAC_P (f) && FRAME_LIVE_P (f))
	return f;
    }

  return NULL;
}
예제 #5
0
/*
 * Starting with the reference given by `ref_name`, follows symbolic
 * references until a direct reference is found and updated the OID
 * on that direct reference to `oid`.
 */
int git_reference__update_terminal(
	git_repository *repo,
	const char *ref_name,
	const git_oid *oid,
	const git_signature *sig,
	const char *log_message)
{
	git_reference *ref = NULL, *ref2 = NULL;
	git_signature *who = NULL;
	const git_signature *to_use;
	int error = 0;

	if (!sig && (error = git_reference__log_signature(&who, repo)) < 0)
		return error;

	to_use = sig ? sig : who;
	error = get_terminal(&ref, repo, ref_name, 0);

	/* found a dangling symref */
	if (error == GIT_ENOTFOUND && ref) {
		assert(git_reference_type(ref) == GIT_REF_SYMBOLIC);
		giterr_clear();
		error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use,
					  log_message, NULL, NULL);
	} else if (error == GIT_ENOTFOUND) {
		giterr_clear();
		error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
					  log_message, NULL, NULL);
	}  else if (error == 0) {
		assert(git_reference_type(ref) == GIT_REF_OID);
		error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use,
					  log_message, &ref->target.oid, NULL);
	}

	git_reference_free(ref2);
	git_reference_free(ref);
	git_signature_free(who);
	return error;
}
예제 #6
0
Process *get_process(pid_t pid) {
  /* TODO: Add test for invalid pid. Right now, we get a lot of errors and some
   * structure.*/
  Process *retval = (Process *)calloc(1, sizeof(Process));
  unsigned int *uids = NULL;
  unsigned int *gids = NULL;
  retval->pid = pid;
  retval->ppid = get_ppid(pid);
  retval->name = get_procname(pid);
  retval->exe = get_exe(pid);
  retval->cmdline = get_cmdline(pid);
  retval->create_time = get_create_time(pid);
  uids = get_ids(pid, "Uid:");
  if (uids) {
    retval->uid = uids[0];
    retval->euid = uids[1];
    retval->suid = uids[2];
    retval->username =
        get_username(retval->uid); /* Uses real uid and not euid */
  } else {
    retval->uid = retval->euid = retval->suid = 0;
    retval->username = NULL;
  }

  gids = get_ids(pid, "Gid:");
  if (uids) {
    retval->gid = gids[0];
    retval->egid = gids[1];
    retval->sgid = gids[2];
  } else {
    retval->uid = retval->euid = retval->suid = 0;
  }

  retval->terminal = get_terminal(pid);
  free(uids);
  free(gids);
  return retval;
}
예제 #7
0
Process *
get_process(unsigned pid)
{
  Process *retval = calloc(1, sizeof(Process));
  unsigned int *uids = NULL;
  unsigned int *gids = NULL;
  retval->pid = pid;
  retval->ppid = get_ppid(pid);
  retval->name = get_procname(pid);
  retval->exe = get_exe(pid);
  retval->cmdline = get_cmdline(pid);
  retval->create_time = get_create_time(pid);
  uids = get_ids(pid, "Uid:");
  if (uids) {
    retval->uid = uids[0];
    retval->euid = uids[1];
    retval->suid = uids[2];
    retval->username = get_username(retval->uid); /* Uses real uid and not euid */
  } else {
    retval->uid = retval->euid = retval->suid = 0;
    retval->username = NULL;
  }

  gids = get_ids(pid, "Gid:");
  if (uids) {
    retval->gid = gids[0];
    retval->egid = gids[1];
    retval->sgid = gids[2];
  } else {
    retval->uid = retval->euid = retval->suid = 0;
  }

  retval->terminal = get_terminal(pid);
  if (uids) free(uids);
  if (gids) free(gids);
  return retval;
}
예제 #8
0
/** Get all data from the procentry64 structure
 *
 * This is a poorly named function.  It gets as much data out of the
 * procentry64 structure as possible and places it in the psi_process
 * structure.
 */
static int
set_bulk(struct psi_process *proci, const struct procentry64 *procent)
{
    int pagesize;
    int r;

    proci->name = psi_strdup(procent->pi_comm);
    if (proci->name == NULL)
        return -1;
    proci->name_status = PSI_STATUS_OK;
    proci->exe = proci->name;
    proci->exe_status = PSI_STATUS_OK;

    proci->euid = procent->pi_cred.crx_uid;
    proci->euid_status = PSI_STATUS_OK;
    proci->ruid = procent->pi_cred.crx_ruid;
    proci->ruid_status = PSI_STATUS_OK;
    proci->egid = procent->pi_cred.crx_gid;
    proci->egid_status = PSI_STATUS_OK;
    proci->rgid = procent->pi_cred.crx_rgid;
    proci->rgid_status = PSI_STATUS_OK;

    proci->ppid = procent->pi_ppid;
    proci->ppid_status = PSI_STATUS_OK;
    proci->pgrp = procent->pi_pgrp;
    proci->pgrp_status = PSI_STATUS_OK;
    proci->sid = procent->pi_sid;
    proci->sid_status = PSI_STATUS_OK;

    proci->priority = procent->pi_ppri;
    proci->priority_status = PSI_STATUS_OK;
    proci->nice = procent->pi_nice;
    proci->nice_status = PSI_STATUS_OK;
    proci->start_time.tv_sec = procent->pi_start;
    proci->start_time.tv_nsec = 0;
    proci->start_time_status = PSI_STATUS_OK;
    proci->status = procent->pi_state;
    proci->status_status = PSI_STATUS_OK;
    proci->nthreads = procent->pi_thcount;
    proci->nthreads_status = PSI_STATUS_OK;

    r = get_terminal(procent->pi_ttyd, &proci->terminal);
    if (r == -1)
        return -1;
    else if (r == -2)
        proci->terminal_status = PSI_STATUS_PRIVS;
    else
        proci->terminal_status = PSI_STATUS_OK;

    /* The ru_utime and ru_stime members are `struct timeval64' which claims
     * to contain microseconds in `tv_usec'.  However all evidence suggests
     * that it really is nanoseconds: (i) the values stored in it are larger
     * then 1e6 and (ii) the results do match with ps(1) when treated as
     * nanoseconds, but not when treated as micoseconds. */
    proci->utime.tv_sec = procent->pi_ru.ru_utime.tv_sec;
    proci->utime.tv_nsec = procent->pi_ru.ru_utime.tv_usec;
    proci->utime_status = PSI_STATUS_OK;
    proci->stime.tv_sec = procent->pi_ru.ru_stime.tv_sec;
    proci->stime.tv_nsec = procent->pi_ru.ru_stime.tv_usec;
    proci->stime_status = PSI_STATUS_OK;

    /* There is a procent.pi_cpu which claims to be a tick count for the first
     * thread, but I trust this more. */
    proci->cputime.tv_sec = proci->utime.tv_sec + proci->stime.tv_sec;
    proci->cputime.tv_sec +=
        (proci->utime.tv_nsec + proci->stime.tv_nsec)/1000000000;
    proci->cputime.tv_nsec =
        (proci->utime.tv_nsec + proci->stime.tv_nsec)%1000000000;
    proci->cputime_status = PSI_STATUS_OK;

    pagesize = getpagesize();
    proci->rss = (procent->pi_drss + procent->pi_trss) * pagesize;
    proci->rss_status = PSI_STATUS_OK;
    /* This is the same size as returned by ps(1) for VSZ.  I don't believe
     * it's correct however, it only contains the data sections of the virtual
     * memory and omits the text size.  None of the other values seem to give
     * something useful either tho and there is something to be said for
     * showing what ps shows.  You can see the real value (in pagesizes) by
     * using "svmon -P <pid>" and look in the "Virtual" column. */
    proci->vsz = procent->pi_dvm * pagesize;
    proci->vsz_status = PSI_STATUS_OK;

    return 0;
}