Minijail: extract utility functions.

Extract utility functions and add them, together with logging,
to a separate util.(c|h) file.

BUG=chromium-os:33361
TEST=unit tests
TEST=security_Minijail0, security_Minijail_seccomp, platform_CrosDisksArchive.

Change-Id: Ied436a7b27f14ef87198b7bf007634b28cbbd480
Reviewed-on: https://gerrit.chromium.org/gerrit/29492
Tested-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: Elly Jones <ellyjones@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Commit-Ready: Jorge Lucangeli Obes <jorgelo@chromium.org>
diff --git a/syscall_filter.c b/syscall_filter.c
index c075d66..e96ad60 100644
--- a/syscall_filter.c
+++ b/syscall_filter.c
@@ -1,22 +1,19 @@
-/* parser.c
- * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
- *
- * Syscall filter syntax parser.
  */
 
-#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "syscall_filter.h"
 
-#include "libsyscalls.h"
-#include "logging.h"
+#include "util.h"
 
 #define MAX_LINE_LENGTH 1024
+#define ONE_INSTR	1
+#define TWO_INSTRS	2
 
 int str_to_op(const char *op_str)
 {
@@ -29,9 +26,6 @@
 	}
 }
 
-#define ONE_INSTR	1
-#define TWO_INSTRS	2
-
 struct sock_filter *new_instr_buf(size_t count)
 {
 	struct sock_filter *buf = calloc(count, sizeof(struct sock_filter));
@@ -317,27 +311,6 @@
 	return head;
 }
 
-int lookup_syscall(const char *name)
-{
-	const struct syscall_entry *entry = syscall_table;
-	for (; entry->name && entry->nr >= 0; ++entry)
-		if (!strcmp(entry->name, name))
-			return entry->nr;
-	return -1;
-}
-
-char *strip(char *s)
-{
-	char *end;
-	while (*s && isblank(*s))
-		s++;
-	end = s + strlen(s) - 1;
-	while (end >= s && *end && (isblank(*end) || *end == '\n'))
-		end--;
-	*(end + 1) = '\0';
-	return s;
-}
-
 int compile_filter(FILE *policy, struct sock_fprog *prog)
 {
 	char line[MAX_LINE_LENGTH];