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:
@ -20,7 +20,8 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include "procps.h"
|
||||
#include <proc/procps.h>
|
||||
|
||||
#include "escape.h"
|
||||
#include "readproc.h"
|
||||
|
||||
@ -162,7 +163,7 @@ int escape_str(char *restrict dst, const char *restrict src, int bufsize, int *m
|
||||
// escape an argv or environment string array
|
||||
//
|
||||
// bytes arg means sizeof(buf)
|
||||
int escape_strlist(char *restrict dst, char *restrict const *restrict src, size_t bytes, int *cells){
|
||||
static int escape_strlist(char *restrict dst, char *restrict const *restrict src, size_t bytes, int *cells){
|
||||
size_t i = 0;
|
||||
|
||||
for(;;){
|
||||
@ -218,15 +219,3 @@ int escape_command(char *restrict const outbuf, const proc_t *restrict const pp,
|
||||
return end; // bytes, not including the NUL
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
// copy an already 'escaped' string,
|
||||
// using the traditional escape.h calling conventions
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user