blob: ea3c72288cf4f0e85c88fa64863ab65da0ef4ca4 [file] [log] [blame]
Jorge Lucangeli Obesa6b034d2012-08-07 15:29:20 -07001/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6#include <ctype.h>
7#include <string.h>
8
9#include "util.h"
10
11#include "libsyscalls.h"
12
13int lookup_syscall(const char *name)
14{
15 const struct syscall_entry *entry = syscall_table;
16 for (; entry->name && entry->nr >= 0; ++entry)
17 if (!strcmp(entry->name, name))
18 return entry->nr;
19 return -1;
20}
21
22const char *lookup_syscall_name(int nr)
23{
24 const struct syscall_entry *entry = syscall_table;
25 for (; entry->name && entry->nr >= 0; ++entry)
26 if (entry->nr == nr)
27 return entry->name;
28 return NULL;
29}
30
31char *strip(char *s)
32{
33 char *end;
34 while (*s && isblank(*s))
35 s++;
36 end = s + strlen(s) - 1;
37 while (end >= s && *end && (isblank(*end) || *end == '\n'))
38 end--;
39 *(end + 1) = '\0';
40 return s;
41}