summaryrefslogtreecommitdiffstats
path: root/src/tools/tools-common.h
diff options
context:
space:
mode:
authorJan Safranek <jsafrane@redhat.com>2009-03-13 15:16:19 +0100
committerJan Safranek <jsafrane@redhat.com>2009-03-26 09:34:18 +0100
commitf8e05fc8c129a13fed256b03a23537ef94c77152 (patch)
treec64ea7d9f7daeefd307feec1bcb90ea5e3e6d600 /src/tools/tools-common.h
parent04bb98f8bd9751dd8a514b0e3a6c4862ceabeae9 (diff)
downloadlibcg-f8e05fc8c129a13fed256b03a23537ef94c77152.tar.gz
libcg-f8e05fc8c129a13fed256b03a23537ef94c77152.tar.xz
libcg-f8e05fc8c129a13fed256b03a23537ef94c77152.zip
Distribute files to various subdirectories
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Diffstat (limited to 'src/tools/tools-common.h')
-rw-r--r--src/tools/tools-common.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h
new file mode 100644
index 0000000..3437973
--- /dev/null
+++ b/src/tools/tools-common.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright Red Hat, Inc. 2009
+ *
+ * Author: Vivek Goyal <vgoyal@redhat.com>
+ * Jan Safranek <jsafrane@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#ifndef __TOOLS_COMMON
+
+#define __TOOLS_COMMON
+
+#include "config.h"
+#include <libcgroup.h>
+
+#ifdef CGROUP_DEBUG
+#define cgroup_dbg(x...) printf(x)
+#else
+#define cgroup_dbg(x...) do {} while (0)
+#endif
+
+/**
+ * Auxiliary specifier of group, used to store parsed command line options.
+ */
+struct cgroup_group_spec {
+ char path[FILENAME_MAX];
+ char *controllers[CG_CONTROLLER_MAX];
+};
+
+
+/**
+ * Parse command line option with group specifier into provided data structure.
+ * The option must have form of 'controller1,controller2,..:group_name'.
+ *
+ * The parsed list of controllers and group name is added at the end of
+ * provided cdptr.
+ *
+ * @param cdptr Target data structure to fill. New item is allocated and added
+ * at the end.
+ * @param optarg Argument to parse.
+ * @return 0 on success, != 0 on error.
+ */
+int parse_cgroup_spec(struct cgroup_group_spec *cdptr[], char *optarg);
+
+
+#endif /* TOOLS_COMMON */