[sanexx-commit] SF.net SVN: sanexx: [6]
Status: Pre-Alpha
Brought to you by:
paddy_hack
|
From: <pad...@us...> - 2006-02-25 14:55:31
|
Revision: 6 Author: paddy_hack Date: 2006-02-25 06:55:19 -0800 (Sat, 25 Feb 2006) ViewCVS: http://svn.sourceforge.net/sanexx/?rev=6&view=rev Log Message: ----------- r11@qed: olaf | 2006-02-25 23:52:32 +0900 Added common command-line options to pass the first test. Modified Paths: -------------- trunk/src/Makefile.am trunk/src/scanimage.cc Property Changed: ---------------- / Property changes on: ___________________________________________________________________ Name: svk:merge - 52428bda-890d-0410-88ad-be188b7e1831:/local:10 + 52428bda-890d-0410-88ad-be188b7e1831:/local:11 Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2006-02-25 14:55:01 UTC (rev 5) +++ trunk/src/Makefile.am 2006-02-25 14:55:19 UTC (rev 6) @@ -28,7 +28,8 @@ scanimage___CPPFLAGS = \ -I$(top_srcdir)/include scanimage___LDFLAGS = \ - $(SANEXX_LIBS) + $(SANEXX_LIBS) \ + -lboost_program_options scanimage___SOURCES = \ scanimage.cc Modified: trunk/src/scanimage.cc =================================================================== --- trunk/src/scanimage.cc 2006-02-25 14:55:01 UTC (rev 5) +++ trunk/src/scanimage.cc 2006-02-25 14:55:19 UTC (rev 6) @@ -27,10 +27,70 @@ #include <sane++> #include <cstdlib> +#include <cstring> +#include <libgen.h> +#include <iostream> +#include <boost/program_options.hpp> + +using namespace std; +namespace po = boost::program_options; + + +int display_help (const char *program_name, + const po::options_description& desc); +int display_version (const char *program_name); + + int main (int argc, char *argv[]) { + const char *program_name = basename (strdup (argv[0])); + + po::options_description common ("Common options"); + common.add_options () + ("help,h", + "display this help message and exit") + ("version", + "display version information and exit") + ; + + po::variables_map vm; + po::store (po::parse_command_line (argc, argv, common), vm); + po::notify (vm); + + if (vm.count ("help")) { + return display_help (program_name, common); + } + + if (vm.count ("version")) { + return display_version (program_name); + } + return EXIT_SUCCESS; } + + +int +display_help (const char *program_name, + const po::options_description& desc) +{ + cout << desc << endl; + return EXIT_SUCCESS; +} + +int +display_version (const char *program_name) +{ + cout << program_name + << " (" PACKAGE ") " + << PACKAGE_VERSION + << endl + << "Written by Olaf Meeuwissen." << endl + << endl + << "Copyright (C) 2006 Olaf Meeuwissen" << endl + << "DISCLAIMER GOES HERE" << endl; + + return EXIT_SUCCESS; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |