[PATCH] 1.1 Add standard options --h, -V

Main Forum
Jari Aalto
2012-10-22
2012-12-15
  • Jari Aalto

    Jari Aalto - 2012-10-22

    Please include following patch to next release. It adds stardard options:

      -h, -help
      -v, -version

    rom 7fe028ff0a71a1dfe69ab15126e039d37106ab57 Mon Sep 17 00:00:00 2001
    From: Jari Aalto <jari.aalto@cante.net>
    Date: Mon, 22 Oct 2012 11:12:07 +0300
    Subject:  apngopt.c: Add standard options -h, -help, -V, -version
    Organization: Private
    Content-Type: text/plain; charset="utf-8"
    Content-Transfer-Encoding: 8bit

    Signed-off-by: Jari Aalto <jari.aalto@cante.net>

    apngopt.c |   26 +++++++++++++++++++++++--
    1 files changed, 23 insertions(+), 3 deletions(-)

    diff -git a/apngopt.c b/apngopt.c
    index a240478..c4ceb5b 100644
    -- a/apngopt.c
    +++ b/apngopt.c
    @@ -2295,12 +2295,32 @@ int main(int argc, char** argv)
       unsigned char  * pOut1 = NULL;
       unsigned char  * pOut2 = NULL;
       unsigned short * pDelays = NULL;
    -
    -  printf("\nAPNG Optimizer 1.1\n\n");
    +  const char *version = "1.1";
    +  const char *program = "APNG Optimizer";
    +  const char *usage   = "Usage: apngopt anim.png \n";

       if (argc <= 1)
       {
    -    printf("Usage: apngopt anim.png \n");
    +    fprintf(stderr, "Error, missing APNG input file. See -h\n");
    +    return 1;
    +  }
    +
    +  if ( !strcmp(argv, "-h") || !strcmp(argv, "-help") )
    +  {
    +    fprintf(stdout, "%s %s\n", program, version);
    +    fprintf(stdout, usage);
    +    return 0;
    +  }
    +
    +  if ( !strcmp(argv, "-V") || !strcmp(argv, "-version") )
    +  {
    +    fprintf(stdout, "%s\n", version);
    +    return 0;
    +  }
    +
    +  if ( !strncmp(argv, "-", 1) )
    +  {
    +    fprintf(stderr, "Error, unknown option: %s\n", argv);
         return 1;
       }

    • 1.7.9
     
  • Max Stepin

    Max Stepin - 2012-10-22

    OK, I'll keep that in mind.

    Notice that version 1.1 is old, the current version is 1.2

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks