aboutsummaryrefslogtreecommitdiff
path: root/pevent/util.h
diff options
context:
space:
mode:
authorSteven Rosted <srostedt@redhat.com>2012-04-18 10:46:58 -0700
committerChris E Ferron <chris.e.ferron@linux.intel.com>2012-04-18 10:46:58 -0700
commit5ba2a6c71e1f5d8fbed96afa57d954b8a5b0ec27 (patch)
tree91bd2a6907ef3d27c4ac21bc337e9f22b9696ee7 /pevent/util.h
parent99f24ee04fe5b1ac4c4ee3ef11a0a6239318c4fc (diff)
downloadpowertop-2.0-v2-5ba2a6c71e1f5d8fbed96afa57d954b8a5b0ec27.tar.gz
Add libparseevents.a
This is a quick hack to make powertop use the libparseevents to parse out the fields from the events stored in the binary format. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'pevent/util.h')
-rw-r--r--pevent/util.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/pevent/util.h b/pevent/util.h
new file mode 100644
index 0000000..ccd6e95
--- /dev/null
+++ b/pevent/util.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
+ *
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ *
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+#ifndef __UTIL_H
+#define __UTIL_H
+
+#include <ctype.h>
+
+static inline char *strim(char *string)
+{
+ char *ret;
+
+ if (!string)
+ return NULL;
+ while (*string) {
+ if (!isspace(*string))
+ break;
+ string++;
+ }
+ ret = string;
+
+ string = ret + strlen(ret) - 1;
+ while (string > ret) {
+ if (!isspace(*string))
+ break;
+ string--;
+ }
+ string[1] = 0;
+
+ return ret;
+}
+
+static inline int has_text(const char *text)
+{
+ if (!text)
+ return 0;
+
+ while (*text) {
+ if (!isspace(*text))
+ return 1;
+ text++;
+ }
+
+ return 0;
+}
+
+#endif