pss-ps.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* process status stream PSS_METHOD_ps implementation
*/
#include "psslib.h"
#else
#include <tm.h>
typedef struct State_s
{
unsigned long fields;
unsigned long now;
int scan;
int debug;
} State_t;
typedef struct Pso_s
{
unsigned long field;
const char* name;
} Pso_t;
{
};
static int
{
register unsigned long fields;
char* s;
{
return -1;
}
fields = 0;
return 1;
}
static int
{
return 1;
}
static int
{
register char* s;
register char* e;
register unsigned long fields;
int sep;
{
{
}
if (!pid)
{
else
{
break;
case PSS_ATTACHED|PSS_DETACHED:
break;
case PSS_DETACHED|PSS_LEADER:
break;
case PSS_ATTACHED|PSS_LEADER:
case PSS_ATTACHED:
break;
}
}
s += sfsprintf(s, e - s, " -o");
sep = ' ';
{
sep = ',';
}
if (pid)
{
}
else
return -1;
}
return 1;
}
static unsigned long
{
unsigned long n;
char* e;
for (;;)
{
if (*e && !isspace(*e))
switch (base)
{
case 8:
if (*e == '8' || *e == '9')
{
base = 10;
continue;
}
/*FALLTHROUGH*/
case 10:
if (isxdigit(*e))
{
base = 16;
continue;
}
break;
}
break;
}
while (*e && !isspace(*e))
e++;
*p = e;
return n;
}
static int
{
register unsigned long fields;
register char* s;
char* e;
char* t;
int c;
return -1;
{
while (isspace(*s))
s++;
if (!*s)
break;
{
case PSS_addr:
break;
case PSS_args:
return 1;
case PSS_sched:
break;
case PSS_command:
e = s;
break;
case PSS_cpu:
break;
case PSS_flags:
break;
case PSS_gid:
for (e = s; *e; e++)
if (isspace(*e))
{
*e++ = 0;
break;
}
break;
case PSS_job:
break;
case PSS_nice:
break;
case PSS_npid:
break;
case PSS_pgrp:
break;
case PSS_pid:
break;
case PSS_ppid:
break;
case PSS_pri:
break;
case PSS_proc:
break;
case PSS_refcount:
break;
case PSS_rss:
break;
case PSS_sid:
break;
case PSS_size:
break;
case PSS_start:
c = 0;
for (t = s; *s; s++)
c = 1;
break;
c = *s;
*s = 0;
{
}
*s = c;
if (e > s)
e = s;
break;
case PSS_state:
*e = 0;
break;
case PSS_tgrp:
break;
case PSS_time:
break;
case PSS_tty:
for (e = s; *e; e++)
if (isspace(*e))
{
*e++ = 0;
break;
}
break;
case PSS_uid:
for (e = s; *e; e++)
if (isspace(*e))
{
*e++ = 0;
break;
}
break;
case PSS_wchan:
break;
}
if (e == s)
while (*s && !isspace(*s))
s++;
else
s = e;
if (isspace(*s))
*s++ = 0;
}
return 1;
}
{
"ps",
"[-version?@(#)$Id: pss ps (AT&T Research) 2003-02-01 $\n]"
"[-author?Glenn Fowler <gsf@research.att.com>]",
0,
0,
0,
0,
};
#endif