AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADER([config.h])
+AC_ARG_ENABLE([bindings],
+ [AC_HELP_STRING([--enable-bindings],
+ [enable python bindings [default=no]])],
+ [
+ if test "x$enableval" = xno; then
+ with_bindings=false
+ else
+ with_bindings=true
+ fi
+ ],
+ [with_bindings = false])
+AM_CONDITIONAL([WITH_BINDINGS], [test x$with_bindings = xtrue])
+
# Process command line options
AC_ARG_ENABLE([debug],
[AC_HELP_STRING([--enable-debug],
src/daemon/Makefile
src/tools/Makefile
src/pam/Makefile
+ src/bindings/Makefile
scripts/Makefile
scripts/init.d/cgconfig
scripts/init.d/cgred
#error "Only <libcgroup.h> should be included directly."
#endif
+#ifndef SWIG
#include <features.h>
+#endif
__BEGIN_DECLS
#error "Only <libcgroup.h> should be included directly."
#endif
+#ifndef SWIG
#include <features.h>
+#endif
__BEGIN_DECLS
#error "Only <libcgroup.h> should be included directly."
#endif
+#ifndef SWIG
#include <features.h>
#include <sys/types.h>
#include <stdbool.h>
+#endif
__BEGIN_DECLS
#error "Only <libcgroup.h> should be included directly."
#endif
+#ifndef SWIG
#include <features.h>
+#endif
__BEGIN_DECLS
#error "Only <libcgroup.h> should be included directly."
#endif
+#ifndef SWIG
#include <sys/types.h>
#include <stdio.h>
#include <features.h>
+#endif
__BEGIN_DECLS
#include <libcgroup/groups.h>
+#ifndef SWIG
#include <features.h>
#include <stdbool.h>
+#endif
__BEGIN_DECLS
-SUBDIRS = . daemon pam tools
+if WITH_BINDINGS
+BINDINGS_SUBDIR = bindings
+endif
+
+SUBDIRS = . daemon pam tools $(BINDINGS_SUBDIR)
# generate parse.h from parse.y
AM_YFLAGS = -d
--- /dev/null
+SUBDIRS = .
+INCLUDES = -I$(top_srcdir)/include
+
+lib_LTLIBRARIES = _libcgroup.la
+_libcgroup_la_SOURCES = libcgroup.c
+_libcgroup_la_LDFLAGS = $(shell python-config --ldflags) -module -avoid-version
+_libcgroup_la_CFLAGS = $(shell python-config --cflags)
+_libcgroup_la_LIBADD = $(top_builddir)/src/.libs/libcgroup.la
+SWIG=swig
+
+
+libcgroup.c: libcgroup.p $(top_srcdir)/include/libcgroup.h
+ cp libcgroup.p libcgroup.i
+ $(CC) $(INCLUDES) -DSWIG -nostdinc -E $(top_srcdir)/include/libcgroup.h >> libcgroup.i
+ $(SWIG) -python -o libcgroup.c libcgroup.i
--- /dev/null
+%module libcgroup
+%{
+#include "libcgroup.h"
+%}
+
+#ifdef __cplusplus
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS }
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+
+%include typemaps.i
+%include cpointer.i
+%pointer_functions(int, intp);
+%typemap (in) void** (void *temp) {
+ void *arg;
+ if ((arg = PyCObject_AsVoidPtr($input)) != NULL) {
+ $1 = &arg;
+ } else
+ $1 = &temp;
+}
+
+%typemap (argout) void** {
+ PyObject *obj = PyCObject_FromVoidPtr(*$1, NULL);
+ $result = PyTuple_Pack(2, $result, obj);
+}
+
--- /dev/null
+#!/usr/bin/python
+
+from libcgroup import *
+from ctypes import *
+
+ret = cgroup_init()
+if (ret != 0):
+ print cgroup_strerror(ret)
+ exit(1)
+
+#
+# Add the correct controllers based on the mount point
+#
+cg_stat = cgroup_stat()
+tree_handle = c_void_p()
+info = cgroup_file_info()
+lvl = new_intp()
+ret1, tree_handle = cgroup_walk_tree_begin("memory", "/", 0, tree_handle, info, lvl)
+root_len = len(info.full_path) - 1
+while ret1 != ECGEOF:
+ if (info.type == CGROUP_FILE_TYPE_DIR):
+ dir = info.full_path[root_len:]
+ print "\nDirectory %s\n" %(dir)
+
+ p = c_void_p()
+ ret, p = cgroup_read_stats_begin("memory", dir, p, cg_stat)
+ while ret != ECGEOF:
+ print "%s:%s" %(cg_stat.name, cg_stat.value.strip('\n'))
+ ret, p = cgroup_read_stats_next(p, cg_stat)
+
+ cgroup_read_stats_end(p)
+ ret1, tree_handle = cgroup_walk_tree_next(0, tree_handle, info, intp_value(lvl))
+
+cgroup_walk_tree_end(tree_handle)
+delete_intp(lvl)