checkpoint

This commit is contained in:
albert
2002-12-21 06:22:00 +00:00
parent b8c8125f63
commit 1158fdd1b1
7 changed files with 40 additions and 31 deletions

View File

@ -24,5 +24,5 @@ I think these are the most important options:
-f full format
s signal format
u user-oriented format
--forest ASCII art forest (process heirarchy)
--forest ASCII art forest (process hierarchy)
c show true command name

View File

@ -1,108 +0,0 @@
/*
* Copyright 1998-2002 by Albert Cahalan; all rights resered.
* This file may be used subject to the terms and conditions of the
* GNU Library General Public License Version 2, or any later version
* at your option, as published by the Free Software Foundation.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*/
#include <sys/types.h>
#include "../proc/procps.h"
#include "common.h"
/* sanitize a string, without the nice BSD library function: */
/* strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH) */
int octal_escape_str(char *restrict dst, const char *restrict src, size_t n){
unsigned char c;
char d;
size_t i;
const char codes[] =
"Z------abtnvfr-------------e----"
" *******************************" /* better: do not print any space */
"****************************\\***"
"*******************************-"
"--------------------------------"
"********************************"
"********************************"
"********************************";
for(i=0; i<n;){
c = (unsigned char) *(src++);
d = codes[c];
switch(d){
case 'Z':
goto leave;
case '*':
i++;
*(dst++) = c;
break;
case '-':
if(i+4 > n) goto leave;
i += 4;
*(dst++) = '\\';
*(dst++) = "01234567"[c>>6];
*(dst++) = "01234567"[(c>>3)&07];
*(dst++) = "01234567"[c&07];
break;
default:
if(i+2 > n) goto leave;
i += 2;
*(dst++) = '\\';
*(dst++) = d;
break;
}
}
leave:
*(dst++) = '\0';
return i;
}
/* sanitize a string via one-way mangle */
int simple_escape_str(char *restrict dst, const char *restrict src, size_t n){
unsigned char c;
size_t i;
const char codes[] =
"Z-------------------------------"
"********************************"
"********************************"
"*******************************-"
"--------------------------------"
"********************************"
"********************************"
"********************************";
for(i=0; i<n;){
c = (unsigned char) *(src++);
switch(codes[c]){
case 'Z':
goto leave;
case '*':
i++;
*(dst++) = c;
break;
case '-':
i++;
*(dst++) = '?';
break;
}
}
leave:
*(dst++) = '\0';
return i;
}
/* escape a string as desired */
int escape_str(char *restrict dst, const char *restrict src, size_t n){
return simple_escape_str(dst, src, n);
}
/* escape an argv or environment string array */
int escape_strlist(char *restrict dst, const char *restrict const *restrict src, size_t n){
size_t i = 0;
while(*src){
i += simple_escape_str(dst+i, *src, n-i);
if((n-i > 1) && src[1]) dst[i++] = ' ';
src++;
}
return i;
}

View File

@ -42,7 +42,7 @@ const char *help_message =
"-V,V show version L list format codes f ASCII art forest\n"
"-m,m show threads S children in sum -y change -l format\n"
"-n,N set namelist file c true command name n numeric WCHAN,UID\n"
"-w,w wide output e show environment -H process heirarchy\n"
"-w,w wide output e show environment -H process hierarchy\n"
;

View File

@ -11,7 +11,7 @@ DIRS += ps/
# a file to create
ALL += ps/ps
PS_C := display escape global help output parser select sortformat
PS_C := display global help output parser select sortformat
PSNAMES := $(addprefix ps/,$(PS_C))
PSOBJ := $(addsuffix .o,$(PSNAMES))
PSSRC := $(addsuffix .c,$(PSNAMES))

View File

@ -253,7 +253,7 @@ static const char *parse_sysv_option(void){
selection_list->typecode = SEL_RGID;
return NULL; /* can't have any more options */
case 'H': /* another nice HP/UX feature */
trace("-H Process heirarchy (like ASCII art forest option)\n");
trace("-H Process hierarchy (like ASCII art forest option)\n");
forest_type = 'u';
break;
case 'L': /* */