File: psstat.c

package info (click to toggle)
diablo 1.16.test2-1
  • links: PTS
  • area: non-free
  • in suites: slink
  • size: 1,504 kB
  • ctags: 1,603
  • sloc: ansic: 17,654; perl: 2,054; sh: 260; csh: 118; makefile: 73
file content (53 lines) | stat: -rw-r--r-- 816 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

/*
 * LIB/PSSTAT.C	- command line status / shows up in ps
 *
 */

#include "defs.h"

Prototype void SetStatusLine(char *ptr, int len);
Prototype void vstprintf(const char *ctl, va_list va);
Prototype void stprintf(const char *ctl, ...);

char	*ArgvBuf;
int	ArgvLen;

void
SetStatusLine(char *ptr, int len)
{
    ArgvBuf = ptr;
    ArgvLen = len;
    memset(ptr, 0, len);
}

/*
 * If we have proctitle(), stprintf() is macro'd to it directly, else
 * we fudge it here.
 */

#if HAS_PROC_TITLE == 0

void
stprintf(const char *ctl, ...)
{
    va_list va;

    va_start(va, ctl);
    vstprintf(ctl, va);
    va_end(va);
}

void
vstprintf(const char *ctl, va_list va)
{
    int n;
    if (ArgvBuf) {
	n = vsnprintf(ArgvBuf, ArgvLen, ctl, va);
	if (n < ArgvLen)
	    memset(ArgvBuf + n, 0, ArgvLen - n);
    }
}

#endif