pss.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 implementation
*/
static const char id[] = "\n@(#)$Id: pss library (AT&T Research) 2011-05-09 $\0\n";
static const char lib[] = "std:pss";
#include "psslib.h"
/*
* open a pss stream
*/
{
if (!disc)
return 0;
goto bad;
goto bad;
{
return 0;
}
return pss;
bad:
if (vm)
return 0;
}
/*
* close a pss stream
*/
int
{
int r;
return -1;
return r;
}
/*
* return the pss entry for pid
* if pid==0 then return the next pid
*/
{
Pssmatch_t* mp;
unsigned long x;
int i;
for (;;)
{
return 0;
{
return 0;
}
return 0;
if (!i)
{
goto next;
}
if (pid)
else
{
{
goto next;
goto next;
{
case PSS_ATTACHED:
goto next;
break;
case PSS_DETACHED:
goto next;
break;
}
{
case PSS_LEADER:
goto next;
goto next;
break;
case PSS_NOLEADER:
goto next;
goto next;
break;
}
}
{
do
{
{
case PSS_gid:
break;
case PSS_pgrp:
break;
case PSS_sid:
break;
case PSS_tgrp:
break;
case PSS_tty:
break;
case PSS_uid:
break;
default:
return 0;
}
break;
if (!mp)
goto next;
}
}
break;
next:
if (flags & PSS_UNMATCHED)
{
break;
}
if (pid)
return 0;
}
return 0;
{
}
return pe;
}
/*
* save entry data
*/
{
return pe;
}
/*
* add name,dev to the tty hash
*/
int
{
{
{
return -1;
}
}
return 0;
}
/*
* scan /dev and enter in the tty hash
*/
static void
{
char* base;
char* name;
{
return;
}
for (;;)
{
{
continue;
if (!sub && (ent->d_name[0] != 'c' && ent->d_name[0] != 't' && ent->d_name[0] != 'p' && ent->d_name[0] != 'v' || ent->d_name[1] != 'o' && ent->d_name[1] != 't'))
continue;
continue;
{
continue;
{
*base++ = '/';
}
else
{
sub = 0;
}
continue;
}
{
return;
}
}
if (!sub)
break;
sub = 0;
}
}
/*
* return dev given tty base name
*/
{
register const char* s;
s = name;
if (*s == '?' || *s == '-')
return PSS_NODEV;
{
{
{
}
}
}
}
/*
* return tty base name given tty dev
*/
char*
{
char* s;
return s;
return "?";
}