예제 #1
0
void
genheader (str fname)
{
  str guard = makeguard (fname);

  aout << "// -*-c++-*-\n"
       << "/* This file was automatically generated by XMLRPCC. */\n\n"
       << "#ifndef " << guard << "\n"
       << "#define " << guard << " 1\n\n"
       << "#include \"xdrmisc.h\"\n";

  start_xml_guard ();
  aout << "#include \"okxmlxlate.h\"\n";
  end_xml_guard ();

  int last = rpc_sym::LITERAL;
  for (const rpc_sym *s = symlist.base (); s < symlist.lim (); s++) {
    if (last != s->type
	|| last == rpc_sym::PROGRAM
	|| last == rpc_sym::TYPEDEF
	|| last == rpc_sym::STRUCT
	|| last == rpc_sym::UNION
	|| last == rpc_sym::ENUM)
      aout << "\n";
    last = s->type;
    dumpsym (s);
  }

  start_xml_guard ();
  aout << "extern xml_rpc_file " << stripfname (fname, false)
       << "_rpc_file;\n";
  end_xml_guard ();

  dump_constant_collect_hook (fname);

  aout << "#endif /* !" << guard << " */\n";
}
예제 #2
0
파일: prstat.c 프로젝트: andreiw/polaris
/*
 * A routine to display the contents of the list on the screen
 */
static void
list_print(list_t *list)
{
	lwp_info_t *lwp;
	id_info_t *id;
	char usr[4], sys[4], trp[4], tfl[4];
	char dfl[4], lck[4], slp[4], lat[4];
	char vcx[4], icx[4], scl[4], sig[4];
	char psize[6], prssize[6], pmem[6], pcpu[6], ptime[12];
	char pstate[7], pnice[4], ppri[4];
	char pname[LOGNAME_MAX+1];
	char projname[PROJNAME_MAX+1];
	char zonename[ZONENAME_MAX+1];
	float cpu, mem;
	double loadavg[3] = {0, 0, 0};
	int i, lwpid;

	if (foreach_element(&set_tbl, &loadavg, psetloadavg) == 0) {
		/*
		 * If processor sets aren't specified, we display system-wide
		 * load averages.
		 */
		(void) getloadavg(loadavg, 3);
	}

	if (opts.o_outpmode & OPT_TTY)
		(void) putchar('\r');
	(void) putp(t_ulon);

	switch (list->l_type) {
	case LT_PROJECTS:
		if (opts.o_outpmode & OPT_LWPS)
			(void) printf(PROJECT_HEADER_LWP);
		else
			(void) printf(PROJECT_HEADER_PROC);
		break;
	case LT_TASKS:
		if (opts.o_outpmode & OPT_LWPS)
			(void) printf(TASK_HEADER_LWP);
		else
			(void) printf(TASK_HEADER_PROC);
		break;
	case LT_ZONES:
		if (opts.o_outpmode & OPT_LWPS)
			(void) printf(ZONE_HEADER_LWP);
		else
			(void) printf(ZONE_HEADER_PROC);
		break;
	case LT_USERS:
		if (opts.o_outpmode & OPT_LWPS)
			(void) printf(USER_HEADER_LWP);
		else
			(void) printf(USER_HEADER_PROC);
		break;
	case LT_LWPS:
		if (opts.o_outpmode & OPT_LWPS) {
			if (opts.o_outpmode & OPT_PSINFO)
				(void) printf(PSINFO_HEADER_LWP);
			if (opts.o_outpmode & OPT_MSACCT)
				(void) printf(USAGE_HEADER_LWP);
		} else {
			if (opts.o_outpmode & OPT_PSINFO)
				(void) printf(PSINFO_HEADER_PROC);
			if (opts.o_outpmode & OPT_MSACCT)
				(void) printf(USAGE_HEADER_PROC);
		}
		break;
	}

	(void) putp(t_uloff);
	(void) putp(t_eol);
	(void) putchar('\n');

	for (i = 0; i < list->l_used; i++) {
		switch (list->l_type) {
		case LT_PROJECTS:
		case LT_TASKS:
		case LT_USERS:
		case LT_ZONES:
			id = list->l_ptrs[i];
			/*
			 * CPU usage and memory usage normalization
			 */
			if (total_cpu >= 100)
				cpu = (100 * id->id_pctcpu) / total_cpu;
			else
				cpu = id->id_pctcpu;
			if (total_mem >= 100)
				mem = (100 * id->id_pctmem) / total_mem;
			else
				mem = id->id_pctmem;
			if (list->l_type == LT_USERS)
				pwd_getname(id->id_uid, pname, LOGNAME_MAX + 1);
			else if (list->l_type == LT_ZONES)
				getzonename(id->id_zoneid, zonename,
				    ZONENAME_MAX);
			else
				getprojname(id->id_projid, projname,
				    PROJNAME_MAX);
			Format_size(psize, id->id_size, 6);
			Format_size(prssize, id->id_rssize, 6);
			Format_pct(pmem, mem, 4);
			Format_pct(pcpu, cpu, 4);
			Format_time(ptime, id->id_time, 10);
			if (opts.o_outpmode & OPT_TTY)
				(void) putchar('\r');
			if (list->l_type == LT_PROJECTS)
				(void) printf(PROJECT_LINE, (int)id->id_projid,
				    id->id_nproc, psize, prssize, pmem, ptime,
				    pcpu, projname);
			else if (list->l_type == LT_TASKS)
				(void) printf(TASK_LINE, (int)id->id_taskid,
				    id->id_nproc, psize, prssize, pmem, ptime,
				    pcpu, projname);
			else if (list->l_type == LT_ZONES)
				(void) printf(ZONE_LINE, (int)id->id_zoneid,
				    id->id_nproc, psize, prssize, pmem, ptime,
				    pcpu, zonename);
			else
				(void) printf(USER_LINE, id->id_nproc, pname,
				    psize, prssize, pmem, ptime, pcpu);
			(void) putp(t_eol);
			(void) putchar('\n');
			break;
		case LT_LWPS:
			lwp = list->l_ptrs[i];
			if (opts.o_outpmode & OPT_LWPS)
				lwpid = lwp->li_info.pr_lwp.pr_lwpid;
			else
				lwpid = lwp->li_info.pr_nlwp +
				    lwp->li_info.pr_nzomb;
			pwd_getname(lwp->li_info.pr_uid, pname,
			    LOGNAME_MAX + 1);
			if (opts.o_outpmode & OPT_PSINFO) {
				Format_size(psize, lwp->li_info.pr_size, 6);
				Format_size(prssize, lwp->li_info.pr_rssize, 6);
				Format_state(pstate,
				    lwp->li_info.pr_lwp.pr_sname,
				    lwp->li_info.pr_lwp.pr_onpro, 7);
				if (strcmp(lwp->li_info.pr_lwp.pr_clname,
				    "RT") == 0 ||
				    strcmp(lwp->li_info.pr_lwp.pr_clname,
				    "SYS") == 0 ||
				    lwp->li_info.pr_lwp.pr_sname == 'Z')
					(void) strcpy(pnice, "  -");
				else
					Format_num(pnice,
					    lwp->li_info.pr_lwp.pr_nice - NZERO,
					    4);
				Format_num(ppri, lwp->li_info.pr_lwp.pr_pri, 4);
				Format_pct(pcpu,
				    FRC2PCT(lwp->li_info.pr_lwp.pr_pctcpu), 4);
				if (opts.o_outpmode & OPT_LWPS)
					Format_time(ptime,
					    lwp->li_info.pr_lwp.pr_time.tv_sec,
					    10);
				else
					Format_time(ptime,
					    lwp->li_info.pr_time.tv_sec, 10);
				if (opts.o_outpmode & OPT_TTY)
					(void) putchar('\r');
				stripfname(lwp->li_info.pr_fname);
				(void) printf(PSINFO_LINE,
				    (int)lwp->li_info.pr_pid, pname,
				    psize, prssize, pstate, ppri, pnice,
				    ptime, pcpu, lwp->li_info.pr_fname, lwpid);
				(void) putp(t_eol);
				(void) putchar('\n');
			}
			if (opts.o_outpmode & OPT_MSACCT) {
				Format_pct(usr, lwp->li_usr, 4);
				Format_pct(sys, lwp->li_sys, 4);
				Format_pct(slp, lwp->li_slp, 4);
				Format_num(vcx, lwp->li_vcx, 4);
				Format_num(icx, lwp->li_icx, 4);
				Format_num(scl, lwp->li_scl, 4);
				Format_num(sig, lwp->li_sig, 4);
				Format_pct(trp, lwp->li_trp, 4);
				Format_pct(tfl, lwp->li_tfl, 4);
				Format_pct(dfl, lwp->li_dfl, 4);
				Format_pct(lck, lwp->li_lck, 4);
				Format_pct(lat, lwp->li_lat, 4);
				if (opts.o_outpmode & OPT_TTY)
					(void) putchar('\r');
				stripfname(lwp->li_info.pr_fname);
				(void) printf(USAGE_LINE,
				    (int)lwp->li_info.pr_pid, pname,
				    usr, sys, trp, tfl, dfl, lck,
				    slp, lat, vcx, icx, scl, sig,
				    lwp->li_info.pr_fname, lwpid);
				(void) putp(t_eol);
				(void) putchar('\n');
			}
			break;
		}
	}

	if (opts.o_outpmode & OPT_TTY)
		(void) putchar('\r');
	if (opts.o_outpmode & OPT_TERMCAP) {
		switch (list->l_type) {
		case LT_PROJECTS:
		case LT_USERS:
		case LT_TASKS:
		case LT_ZONES:
			while (i++ < opts.o_nbottom) {
				(void) putp(t_eol);
				(void) putchar('\n');
			}
			break;
		case LT_LWPS:
			while (i++ < opts.o_ntop) {
				(void) putp(t_eol);
				(void) putchar('\n');
			}
		}
	}

	if (opts.o_outpmode & OPT_TTY)
		(void) putchar('\r');

	if ((opts.o_outpmode & OPT_SPLIT) && list->l_type == LT_LWPS)
		return;

	(void) printf(TOTAL_LINE, total_procs, total_lwps,
	    loadavg[LOADAVG_1MIN], loadavg[LOADAVG_5MIN],
	    loadavg[LOADAVG_15MIN]);
	(void) putp(t_eol);
	(void) putchar('\n');
	if (opts.o_outpmode & OPT_TTY)
		(void) putchar('\r');
	(void) putp(t_eol);
	(void) fflush(stdout);
}