From 3b09fd0c50de2188a0772d329061bb2444e0f091 Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Wed, 25 Feb 2009 13:04:34 +0000 Subject: libcgroup: Move parse_cgroup_data to separate .c file From: Jan Safranek Cgclassify could benefit from parsing of -g command line option, let's move it to separate file, where both cgexec and cgclassify can use it. The data structures and function names are also more descriptive now. I added also the copyright notice and license to the new files. Signed-off-by: Jan Safranek Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@339 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tools-common.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tools-common.h (limited to 'tools-common.h') diff --git a/tools-common.h b/tools-common.h new file mode 100644 index 0000000..cd16804 --- /dev/null +++ b/tools-common.h @@ -0,0 +1,48 @@ +/* + * Copyright Red Hat, Inc. 2009 + * + * Author: Vivek Goyal + * Jan Safranek + * + * 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 +#include "libcgroup-internal.h" + +/** + * 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 */ -- cgit