Relocate and export sanitize() function

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-01-15 23:06:45 +01:00
parent 618744cc52
commit 698f736b65
3 changed files with 26 additions and 23 deletions
-23
View File
@@ -22,7 +22,6 @@
*/
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -44,28 +43,6 @@
uev_t api_watcher;
/* Allowed characters in job/id/name */
static int isallowed(int ch)
{
return isprint(ch);
}
/* Sanitize user input, make sure to NUL terminate. */
static char *sanitize(char *arg, size_t len)
{
size_t i = 0;
while (isallowed(arg[i]) && i < len)
i++;
if (i + 1 < len) {
arg[i + 1] = 0;
return arg;
}
return NULL;
}
static int call(int (*action)(svc_t *), char *buf, size_t len)
{
int result = 0;