aboutsummaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-02-17 10:48:23 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-02-17 10:48:23 -0500
commitfba106f1736ec0accd04aaaa1ce731801e67812f (patch)
tree643239440909a7fd9a406f3141e11b59666765c1 /util.h
parenta5f716419f133132dfc6e1813aff7eb87344f526 (diff)
parse-events: Move strim() to util.h
Add a util.h file to hold small functions that may be useful for other files. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'util.h')
-rw-r--r--util.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/util.h b/util.h
new file mode 100644
index 0000000..342cfa1
--- /dev/null
+++ b/util.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 *
4 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation;
8 * version 2.1 of the License (not later!)
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */
21#ifndef __UTIL_H
22#define __UTIL_H
23
24#include <ctype.h>
25
26static inline char *strim(char *string)
27{
28 char *ret;
29
30 if (!string)
31 return NULL;
32 while (*string) {
33 if (!isspace(*string))
34 break;
35 string++;
36 }
37 ret = string;
38
39 string = ret + strlen(ret) - 1;
40 while (string > ret) {
41 if (!isspace(*string))
42 break;
43 string--;
44 }
45 string[1] = 0;
46
47 return ret;
48}
49
50#endif