~ubuntu-branches/ubuntu/maverick/libcgroup/maverick-proposed

« back to all changes in this revision

Viewing changes to src/tools/tools-common.h

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2009-08-26 11:29:17 UTC
  • Revision ID: james.westby@ubuntu.com-20090826112917-402ews2uj6v350d2
Tags: upstream-0.34
ImportĀ upstreamĀ versionĀ 0.34

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright Red Hat, Inc. 2009
 
3
 *
 
4
 * Author:      Vivek Goyal <vgoyal@redhat.com>
 
5
 *              Jan Safranek <jsafrane@redhat.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify it
 
8
 * under the terms of version 2.1 of the GNU Lesser General Public License
 
9
 * as published by the Free Software Foundation.
 
10
 *
 
11
 * This program is distributed in the hope that it would be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
14
 *
 
15
 */
 
16
 
 
17
#ifndef __TOOLS_COMMON
 
18
 
 
19
#define __TOOLS_COMMON
 
20
 
 
21
#include "config.h"
 
22
#include <libcgroup.h>
 
23
 
 
24
#ifdef CGROUP_DEBUG
 
25
#define cgroup_dbg(x...) printf(x)
 
26
#else
 
27
#define cgroup_dbg(x...) do {} while (0)
 
28
#endif
 
29
 
 
30
/**
 
31
 * Auxiliary specifier of group, used to store parsed command line options.
 
32
 */
 
33
struct cgroup_group_spec {
 
34
        char path[FILENAME_MAX];
 
35
        char *controllers[CG_CONTROLLER_MAX];
 
36
};
 
37
 
 
38
 
 
39
/**
 
40
 * Parse command line option with group specifier into provided data structure.
 
41
 * The option must have form of 'controller1,controller2,..:group_name'.
 
42
 *
 
43
 * The parsed list of controllers and group name is added at the end of
 
44
 * provided cdptr.
 
45
 *
 
46
 * @param cdptr Target data structure to fill. New item is allocated and added
 
47
 *              at the end.
 
48
 * @param optarg Argument to parse.
 
49
 * @return 0 on success, != 0 on error.
 
50
 */
 
51
int parse_cgroup_spec(struct cgroup_group_spec *cdptr[], char *optarg);
 
52
 
 
53
/**
 
54
 * Free a single cgroup_group_spec structure.
 
55
 *      @param cl The structure to free from memory
 
56
 */
 
57
void cgroup_free_group_spec(struct cgroup_group_spec *cl);
 
58
 
 
59
#endif /* TOOLS_COMMON */