Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
Add CLI version reporting option.
Browse files Browse the repository at this point in the history
  • Loading branch information
keithmarshall committed Jan 8, 2010
1 parent cb97888 commit b4ca4aa
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 12 deletions.
21 changes: 21 additions & 0 deletions mingw-get/ChangeLog
@@ -1,3 +1,24 @@
2010-01-08 Keith Marshall <keithmarshall@users.sourceforge.net>

Add CLI version reporting option.

* configure.ac: Update copyright notice for new year.
(COPYRIGHT_HOLDER): New AC_SUBST variable; define it.
(YEARS_OF_ISSUE): New AC_SUBST variable; define it.
(AC_CONFIG_FILES): Add `version.c'; source it from...

* version.c.in: ...this new file.

* Makefile.in: Update copyright notice for new year.
(mingw-get$(EXEEXT)): Add dependency on `version.$(OBJEXT)'.
(distclean): Add `version.c'.

* configure: Regenerated.

* src/clistub.c: Update copyright notice for new year.
(options): New array of `struct option'; define and use it as the
reference for `argv' parsing with `getopt_long_only()'.

2009-12-17 Keith Marshall <keithmarshall@users.sourceforge.net>

Add CLI support for "update" action.
Expand Down
8 changes: 4 additions & 4 deletions mingw-get/Makefile.in
@@ -1,9 +1,9 @@
# @configure_input@
#
# $Id: Makefile.in,v 1.4 2009-11-23 20:44:23 keithmarshall Exp $
# $Id: Makefile.in,v 1.5 2010-01-08 17:44:16 keithmarshall Exp $
#
# Written by Keith Marshall <keithmarshall@users.sourceforge.net>
# Copyright (C) 2009, MinGW Project
# Copyright (C) 2009, 2010, MinGW Project
#
#
# Makefile template for mingw-get
Expand Down Expand Up @@ -65,7 +65,7 @@ all: pkginfo$(EXEEXT) mingw-get$(EXEEXT) mingw-get-0.dll
pkginfo$(EXEEXT): driver.$(OBJEXT) pkginfo.$(OBJEXT)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $+

mingw-get$(EXEEXT): clistub.$(OBJEXT)
mingw-get$(EXEEXT): clistub.$(OBJEXT) version.$(OBJEXT)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $+

mingw-get-0.dll: $(CORE_DLL_OBJECTS)
Expand Down Expand Up @@ -99,6 +99,6 @@ clean:
rm -f *.$(OBJEXT) *.dll pkginfo$(EXEEXT) mingw-get$(EXEEXT)

distclean: clean
rm -f config.* Makefile
rm -f config.* version.c Makefile

# $RCSfile: Makefile.in,v $: end of file
11 changes: 7 additions & 4 deletions mingw-get/configure.ac
@@ -1,9 +1,9 @@
# configure.ac -*- autoconf -*- vim: filetype=config
#
# $Id: configure.ac,v 1.1 2009-10-31 21:08:41 keithmarshall Exp $
# $Id: configure.ac,v 1.2 2010-01-08 17:44:20 keithmarshall Exp $
#
# Written by Keith Marshall <keithmarshall@users.sourceforge.net>
# Copyright (C) 2009, MinGW Project
# Copyright (C) 2009, 2010, MinGW Project
#
#
# Configuration script for mingw-get
Expand All @@ -22,7 +22,10 @@
# MinGW Project, accept liability for any damages, however caused,
# arising from the use of this software.
#
AC_INIT([mingw-get],[0.0],[http://mingw.org/reporting_bugs])
AC_INIT([mingw-get],[0.1-alpha-1],[http://mingw.org/reporting_bugs])

AC_SUBST([COPYRIGHT_HOLDER],["MinGW Project"])
AC_SUBST([YEARS_OF_ISSUE],["2009, 2010"])

# We need both C and C++ compilers; check how to invoke them
#
Expand All @@ -40,7 +43,7 @@

# Create a makefile
#
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([version.c Makefile])
AC_OUTPUT
#
# $RCSfile: configure.ac,v $: end of file
52 changes: 48 additions & 4 deletions mingw-get/src/clistub.c
@@ -1,10 +1,10 @@
/*
* clistub.c
*
* $Id: clistub.c,v 1.2 2009-11-12 22:33:26 keithmarshall Exp $
* $Id: clistub.c,v 1.3 2010-01-08 17:44:21 keithmarshall Exp $
*
* Written by Keith Marshall <keithmarshall@users.sourceforge.net>
* Copyright (C) 2009, MinGW Project
* Copyright (C) 2009, 2010, MinGW Project
*
*
* Initiation stub for command line invocation of mingw-get
Expand Down Expand Up @@ -35,6 +35,7 @@
#include <stdlib.h>
#include <libgen.h>
#include <process.h>
#include <getopt.h>

#define EXIT_FATAL EXIT_FAILURE + 1

Expand Down Expand Up @@ -154,12 +155,55 @@ wchar_t *AppPathNameW( const wchar_t *relpath )
return retpath;
}

extern const char *version_identification;

int main( int argc, char **argv )
{
wchar_t *approot; /* where this application is installed */

if( argc > 1 )
{
/* The user specified arguments on the command line...
* Interpret any which specify processing options for this application,
* (these are all specified in GNU `long only' style).
*/
struct option options[] =
{
/* Option Name Argument Category Store To Return Value
* ---------------------- ------------------ -------- ------------
*/
{ "version", no_argument, NULL, 'V' },

/* This list must be terminated by a null definition...
*/
{ NULL, 0, NULL, 0 }
};

int opt, offset;
while( (opt = getopt_long_only( argc, argv, "V", options, &offset )) != -1 )
switch( opt )
{
case 'V':
/* This is a request to display the version of the application;
* emit the requisite informational message, and quit.
*/
printf( version_identification );
return 0;

default:
/* User specified an invalid or unsupported option...
*/
if( opt != '?' )
fprintf( stderr, "%s: option '-%s' not yet supported\n",
basename( *argv ), options[offset].name
);
return EXIT_FAILURE;
}
}

/* Establish the installation path for the mingw-get application...
*/
wchar_t *approot = AppPathNameW( NULL );
if( approot != NULL )
if( (approot = AppPathNameW( NULL )) != NULL )
{
/* ...and set up the APPROOT environment variable to refer to
* the associated installation prefix...
Expand Down
16 changes: 16 additions & 0 deletions mingw-get/version.c.in
@@ -0,0 +1,16 @@
/*
* @configure_input@
*
* $Id: version.c.in,v 1.1 2010-01-08 17:44:20 keithmarshall Exp $
*
*/
const char *version_identification =
"@PACKAGE_NAME@ version @PACKAGE_VERSION@\n"
"Copyright (C) @YEARS_OF_ISSUE@, @COPYRIGHT_HOLDER@\n"
"\n"
"This is free software; see the product documentation, or source code,\n"
"for copying and redistribution conditions. There is NO WARRANTY; not\n"
"even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY\n"
"PARTICULAR PURPOSE.\n\n";

/* $RCSfile: version.c.in,v $: end of file */

0 comments on commit b4ca4aa

Please sign in to comment.