RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   19-Feb-2009 20:55:51
  Branch: HEAD                             Handle: 2009021919555001

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               rpmz.c

  Log:
    - jbj: rpmz: stub in argv[0] processing to set operation mode.

  Summary:
    Revision    Changes     Path
    1.2783      +1  -0      rpm/CHANGES
    1.15        +38 -42     rpm/rpmio/rpmz.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2782 -r1.2783 CHANGES
  --- rpm/CHANGES       19 Feb 2009 18:57:22 -0000      1.2782
  +++ rpm/CHANGES       19 Feb 2009 19:55:50 -0000      1.2783
  @@ -1,5 +1,6 @@
   
   5.2a2 -> 5.2a3:
  +    - jbj: rpmz: stub in argv[0] processing to set operation mode.
       - jbj: rpmz: stub in RPMZ envvar option processing.
       - jbj: fix: eliminate a argvSplit() memory leak.
       - jbj: rpmz: gather args from multiple manifests (ala rpmwget).
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmz.c
  ============================================================================
  $ cvs diff -u -r1.14 -r1.15 rpmz.c
  --- rpm/rpmio/rpmz.c  19 Feb 2009 18:57:23 -0000      1.14
  +++ rpm/rpmio/rpmz.c  19 Feb 2009 19:55:51 -0000      1.15
  @@ -1654,6 +1654,37 @@
       return rc;
   }
   
  +/**
  + */
  +static rpmRC rpmzParseArgv0(rpmz z, /*...@null@*/ const char * argv0)
  +     /*...@*/
  +{
  +#ifdef       NOTYET
  +    enum format_type format_compress_auto = FORMAT_XZ;
  +#endif
  +    const char * s = strrchr(argv0, '/');
  +    const char * name = (s ? (s + 1) : argv0);
  +    rpmRC rc = RPMRC_OK;
  +
  +#ifdef       NOTYET
  +    if (strstr(name, "lz") != NULL) {
  +     format_compress_auto = FORMAT_LZMA;
  +     z->idio = z->odio = lzdio;
  +     z->osuffix = ".lzma";
  +     opt_format = FORMAT_LZMA;
  +    }
  +#endif
  +
  +    if (strstr(name, "cat") != NULL) {
  +     opt_mode = MODE_DECOMPRESS;
  +     opt_stdout = true;
  +    } else if (strstr(name, "un") != NULL) {
  +     opt_mode = MODE_DECOMPRESS;
  +    }
  +
  +    return rc;
  +}
  +
   int
   main(int argc, char *argv[])
        /*...@globals __assert_program_name,
  @@ -1672,45 +1703,10 @@
       __progname = "rpmz";
   /*...@=observertrans =readonlytrans @*/
   
  -    /* XXX TODO: Set modes and format based on argv[0]. */
  -#ifdef       NOTYET
  -     // Initialize those parts of *args that we need later.
  -     args->files_name = NULL;
  -     args->files_file = NULL;
  -     args->files_delim = '\0';
  -
  -     // Type of the file format to use when --format=auto or no --format
  -     // was specified.
  -    {        enum format_type format_compress_auto = FORMAT_XZ;
  -
  -     // Check how we were called.
  -     {
  -             // Remove the leading path name, if any.
  -             const char *name = strrchr(argv[0], '/');
  -             if (name == NULL)
  -                     name = argv[0];
  -             else
  -                     ++name;
  -
  -             // NOTE: It's possible that name[0] is now '\0' if argv[0]
  -             // is weird, but it doesn't matter here.
  -
  -             // The default file format is .lzma if the command name
  -             // contains "lz".
  -             if (strstr(name, "lz") != NULL)
  -                     format_compress_auto = FORMAT_LZMA;
  -
  -             // Operation mode
  -             if (strstr(name, "cat") != NULL) {
  -                     // Imply --decompress --stdout
  -                     opt_mode = MODE_DECOMPRESS;
  -                     opt_stdout = true;
  -             } else if (strstr(name, "un") != NULL) {
  -                     // Imply --decompress
  -                     opt_mode = MODE_DECOMPRESS;
  -             }
  -     }
  -#endif       /* NOTYET */
  +    /* Set modes and format based on argv[0]. */
  +    xx = rpmzParseArgv0(z, argv[0]);
  +    if (xx)
  +     goto exit;
   
       z->b = xmalloc(z->nb);
   #ifndef      DYING
  @@ -1728,9 +1724,9 @@
   
       /* Parse environment options. */
       /* XXX NULL uses "RPMZ" envvar. */
  -    rc = rpmzParseEnv(z, NULL);
  -    if (rc) {
  -    }
  +    xx = rpmzParseEnv(z, NULL);
  +    if (xx)
  +     goto exit;
   
       /* Parse CLI options. */
       /* XXX todo: needs to be earlier. */
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to