library: re-arrange escape commands

escaped_copy(): only appears in ps, moved to ps/output.c
escape_strlist() only used in escape.c made static
escape_command() used in library, made internal
procps.h no longer includes escape.h

escape_str() used by library and ps so needs to be exported
definition put into procps.h including the odd define required.
Far from ideal to have it this way, will look at it another time
to have it all in, all out or split nicer so its not in the API;
perhaps a lib/ file?
This commit is contained in:
Craig Small
2016-04-17 14:45:19 +10:00
parent 887bb51016
commit d916d5db86
5 changed files with 21 additions and 32 deletions

View File

@ -115,6 +115,17 @@ static void get_memory_total()
procps_meminfo_unref(&mem_info);
}
// copy an already 'escaped' string,
static int escaped_copy(char *restrict dst, const char *restrict src, int bufsize, int *maxroom){
int n;
if (bufsize > *maxroom+1)
bufsize = *maxroom+1;
n = snprintf(dst, bufsize, "%s", src);
if (n >= bufsize)
n = bufsize-1;
*maxroom -= n;
return n;
}
/***************************************************************************/
/************ Lots of format functions, starting with the NOP **************/
@ -949,7 +960,6 @@ setREL1(TIME_START)
}
#ifdef SIGNAL_STRING
static int help_pr_sig(char *restrict const outbuf, const char *restrict const sig){
long len = 0;
len = strlen(sig);
@ -961,13 +971,6 @@ static int help_pr_sig(char *restrict const outbuf, const char *restrict const s
return snprintf(outbuf, COLWID, "<%s", sig+len-8);
return snprintf(outbuf, COLWID, "%s", sig+len-8);
}
#else
static int help_pr_sig(unsigned long long sig){
if(wide_signals) return snprintf(outbuf, COLWID, "%016Lx", sig);
if(sig>>32) return snprintf(outbuf, COLWID, "<%08Lx", sig&0xffffffffLL);
return snprintf(outbuf, COLWID, "%08Lx", sig&0xffffffffLL);
}
#endif
// This one is always thread-specific pending. (from Dragonfly BSD)
static int pr_tsig(char *restrict const outbuf, const proc_t *restrict const pp){