From 50dce522e4a5a09d43012b1d3d18ac80a5c16863 Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Tue, 9 Dec 2008 11:14:24 +0000 Subject: [PATCH] libcgroup: Improve parameter checking and usage in cgconfigparser From: Sripathi Kodi The following patch improves cgconfigparser's parameter checking and usage(). It provides: 1) Support for long options. Not really needed now, but good to have. 2) Improved usage() functionality. Signed-off-by: Sripathi Kodi Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@227 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- cgconfig.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/cgconfig.c b/cgconfig.c index 16ff63b8..fab3a720 100644 --- a/cgconfig.c +++ b/cgconfig.c @@ -23,21 +23,38 @@ #include #include #include +#include + + +static void usage(char *progname) +{ + printf("Usage: %s [OPTION] [FILE]\n", basename(progname)); + printf("Parse and load the specified cgroups configuration file\n"); + printf("\n"); + printf(" -h, --help Display this help\n"); + printf(" -l, --load=FILE Parse and load the cgroups configuration file\n"); + exit(2); +} int main(int argc, char *argv[]) { int c; char filename[PATH_MAX]; int ret; + static struct option options[] = { + {"help", 0, 0, 'h'}, + {"load", 1, 0, 'l'}, + {0, 0, 0, 0} + }; - if (argc < 2) { - fprintf(stderr, "usage is %s