keyword.c (88904) | keyword.c (90110) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; 37#else 38static const char rcsid[] = | 1/*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; 37#else 38static const char rcsid[] = |
39 "$FreeBSD: head/bin/ps/keyword.c 88904 2002-01-05 12:19:51Z peter $"; | 39 "$FreeBSD: head/bin/ps/keyword.c 90110 2002-02-02 06:48:10Z imp $"; |
40#endif 41#endif /* not lint */ 42 43#include <sys/param.h> 44#include <sys/time.h> 45#include <sys/resource.h> 46#include <sys/proc.h> 47#include <sys/sysctl.h> --- 5 unchanged lines hidden (view full) --- 53#include <stddef.h> 54#include <stdio.h> 55#include <stdlib.h> 56#include <string.h> 57#include <utmp.h> 58 59#include "ps.h" 60 | 40#endif 41#endif /* not lint */ 42 43#include <sys/param.h> 44#include <sys/time.h> 45#include <sys/resource.h> 46#include <sys/proc.h> 47#include <sys/sysctl.h> --- 5 unchanged lines hidden (view full) --- 53#include <stddef.h> 54#include <stdio.h> 55#include <stdlib.h> 56#include <string.h> 57#include <utmp.h> 58 59#include "ps.h" 60 |
61static VAR *findvar __P((char *)); 62static int vcmp __P((const void *, const void *)); | 61static VAR *findvar(char *); 62static int vcmp(const void *, const void *); |
63 64#ifdef NOTINUSE 65int utime(), stime(), ixrss(), idrss(), isrss(); 66 {{"utime"}, "UTIME", USER, utime, NULL, 4}, 67 {{"stime"}, "STIME", USER, stime, NULL, 4}, 68 {{"ixrss"}, "IXRSS", USER, ixrss, NULL, 4}, 69 {{"idrss"}, "IDRSS", USER, idrss, NULL, 4}, 70 {{"isrss"}, "ISRSS", USER, isrss, NULL, 4}, --- 114 unchanged lines hidden (view full) --- 185 {"vsize", "", "vsz"}, 186 {"vsz", "VSZ", NULL, 0, vsize, NULL, 5}, 187 {"wchan", "WCHAN", NULL, LJUST, wchan, NULL, 6}, 188 {"xstat", "XSTAT", NULL, 0, kvar, NULL, 4, KOFF(ki_xstat), USHORT, "x"}, 189 {""}, 190}; 191 192void | 63 64#ifdef NOTINUSE 65int utime(), stime(), ixrss(), idrss(), isrss(); 66 {{"utime"}, "UTIME", USER, utime, NULL, 4}, 67 {{"stime"}, "STIME", USER, stime, NULL, 4}, 68 {{"ixrss"}, "IXRSS", USER, ixrss, NULL, 4}, 69 {{"idrss"}, "IDRSS", USER, idrss, NULL, 4}, 70 {{"isrss"}, "ISRSS", USER, isrss, NULL, 4}, --- 114 unchanged lines hidden (view full) --- 185 {"vsize", "", "vsz"}, 186 {"vsz", "VSZ", NULL, 0, vsize, NULL, 5}, 187 {"wchan", "WCHAN", NULL, LJUST, wchan, NULL, 6}, 188 {"xstat", "XSTAT", NULL, 0, kvar, NULL, 4, KOFF(ki_xstat), USHORT, "x"}, 189 {""}, 190}; 191 192void |
193showkey() | 193showkey(void) |
194{ 195 VAR *v; 196 int i; 197 char *p, *sep; 198 199 i = 0; 200 sep = ""; 201 for (v = var; *(p = v->name); ++v) { --- 4 unchanged lines hidden (view full) --- 206 } 207 (void) printf("%s%s", sep, p); 208 sep = " "; 209 } 210 (void) printf("\n"); 211} 212 213void | 194{ 195 VAR *v; 196 int i; 197 char *p, *sep; 198 199 i = 0; 200 sep = ""; 201 for (v = var; *(p = v->name); ++v) { --- 4 unchanged lines hidden (view full) --- 206 } 207 (void) printf("%s%s", sep, p); 208 sep = " "; 209 } 210 (void) printf("\n"); 211} 212 213void |
214parsefmt(p) 215 char *p; | 214parsefmt(char *p) |
216{ 217 static struct varent *vtail; 218 219#define FMTSEP " \t,\n" 220 while (p && *p) { 221 char *cp; 222 VAR *v; 223 struct varent *vent; --- 13 unchanged lines hidden (view full) --- 237 vtail = vent; 238 } 239 } 240 if (!vhead) 241 errx(1, "no valid keywords"); 242} 243 244static VAR * | 215{ 216 static struct varent *vtail; 217 218#define FMTSEP " \t,\n" 219 while (p && *p) { 220 char *cp; 221 VAR *v; 222 struct varent *vent; --- 13 unchanged lines hidden (view full) --- 236 vtail = vent; 237 } 238 } 239 if (!vhead) 240 errx(1, "no valid keywords"); 241} 242 243static VAR * |
245findvar(p) 246 char *p; | 244findvar(char *p) |
247{ 248 VAR *v, key; 249 char *hp; 250 int vcmp(); 251 252 hp = strchr(p, '='); 253 if (hp) 254 *hp++ = '\0'; --- 13 unchanged lines hidden (view full) --- 268 warnx("%s: keyword not found", p); 269 eval = 1; 270 } else if (hp) 271 v->header = hp; 272 return (v); 273} 274 275static int | 245{ 246 VAR *v, key; 247 char *hp; 248 int vcmp(); 249 250 hp = strchr(p, '='); 251 if (hp) 252 *hp++ = '\0'; --- 13 unchanged lines hidden (view full) --- 266 warnx("%s: keyword not found", p); 267 eval = 1; 268 } else if (hp) 269 v->header = hp; 270 return (v); 271} 272 273static int |
276vcmp(a, b) 277 const void *a, *b; | 274vcmp(const void *a, const void *b) |
278{ 279 return (strcmp(((VAR *)a)->name, ((VAR *)b)->name)); 280} | 275{ 276 return (strcmp(((VAR *)a)->name, ((VAR *)b)->name)); 277} |