prutil.c revision 4944376cd5de3dcd3b4feeaad9cbedbc024d1474
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/resource.h>
#include <sys/priocntl.h>
#include <sys/rtpriocntl.h>
#include <sys/tspriocntl.h>
#include <zone.h>
#include <libintl.h>
#include <limits.h>
#include <wchar.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdio_ext.h>
#include <errno.h>
#include <ctype.h>
#include <poll.h>
#include <project.h>
#include "prfile.h"
#include "prstat.h"
#include "prutil.h"
static char PRG_FMT[] = "%s: ";
static char ERR_FMT[] = ": %s\n";
static char *progname;
static char projbuf[PROJECT_BUFSZ];
#define RLIMIT_NOFILE_MAX 32767
/*PRINTFLIKE1*/
void
{
}
/*PRINTFLIKE1*/
void
{
exit(1);
}
void
{
if (p == NULL)
p = arg0;
else
p++;
progname = p;
}
void
Usage()
{
"Usage:\tprstat [-acHJLmRtTvZ] [-u euidlist] [-U uidlist]\n"
"\t[-p pidlist] [-P cpulist] [-C psrsetlist] [-h lgrouplist]\n"
"\t[-j projidlist] [-k taskidlist] [-z zoneidlist]\n"
"\t[-s key | -S key] [-n nprocs[,nusers]] [-d d|u]\n"
"\t[interval [counter]]\n"));
exit(1);
}
int
Atoi(char *p)
{
int i;
char *q;
errno = 0;
i = (int)strtol(p, &q, 10);
if (errno != 0 || q == p || i < 0 || *q != '\0')
/*NOTREACHED*/
else
return (i);
return (0); /* keep gcc happy */
}
void
{
char tag = 'K';
if (size >= 10000) {
tag = 'M';
if (size >= 10000) {
tag = 'G';
}
}
}
void
{
}
void
{
if (val > (float)100)
val = 100;
if (val < 0)
val = 0;
if (val < (float)9.95)
else
}
void
{
if (num >= 100000) {
} else {
if (num >= 1000)
else
}
}
void
{
switch (state) {
case 'S':
break;
case 'R':
break;
case 'Z':
break;
case 'T':
break;
case 'I':
break;
case 'W':
break;
case 'O':
break;
default:
break;
}
}
void *
{
int cnt = 0;
return (ptr);
goto eagain;
}
/*NOTREACHED*/
return (NULL); /* keep gcc happy */
}
void *
{
}
void *
{
}
int
{
int fd_limit;
return (fd_limit);
else
}
void
{
return;
}
}
void
{
else
}
void
{
char zone_name[ZONENAME_MAX];
else
}
/*
* Remove all unprintable characters from process name
*/
void
stripfname(char *buf)
{
int length;
char *cp;
if (length <= 0) {
*cp = '\0';
break;
}
*cp = '\0';
break;
}
length = 0;
}
}
}