getopt help required

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rishi

    getopt help required

    suppose i have a program in which there are two arguements 'a' and 'b'

    the program is such that i will work iff
    -either 'a' or 'b' is present as an option to it
    -both 'a' and 'b' cant be present sameltaneously
    -either of the two should be there

    I want to know is there any way in the function getopt or getopt_long
    that can help me in doing this


    Thanks in advance

  • Daniel Kraft

    #2
    Re: getopt help required

    Rishi wrote:
    suppose i have a program in which there are two arguements 'a' and 'b'
    >
    the program is such that i will work iff
    -either 'a' or 'b' is present as an option to it
    -both 'a' and 'b' cant be present sameltaneously
    -either of the two should be there
    >
    I want to know is there any way in the function getopt or getopt_long
    that can help me in doing this
    Well, I'm not sure this is on topic here (comp.unix.prog rammer might be
    better), but AFAIK getopt can set a boolean flag on encountering an
    option; just do this, and check afterwards your conditions against the
    two flag-variables and take appropriate action.

    Daniel

    --
    Done: Bar-Sam-Val-Wiz, Dwa-Elf-Hum-Orc, Cha-Law, Fem-Mal
    Underway: Ran-Gno-Neu-Fem
    To go: Arc-Cav-Hea-Kni-Mon-Pri-Rog-Tou

    Comment

    • Kenny McCormack

      #3
      Re: getopt help required

      In article <f97003a2-b0f7-4115-9c48-7df8bee47bc8@j2 8g2000hsj.googl egroups.com>,
      Rishi <postrishi@gmai l.comwrote:
      >suppose i have a program in which there are two arguements 'a' and 'b'
      >
      >the program is such that i will work iff
      >-either 'a' or 'b' is present as an option to it
      >-both 'a' and 'b' cant be present sameltaneously
      >-either of the two should be there
      >
      >I want to know is there any way in the function getopt or getopt_long
      >that can help me in doing this
      >
      >
      >Thanks in advance
      Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

      --
      Useful clc-related links:





      Comment

      • Malcolm McLean

        #4
        Re: getopt help required


        "Rishi" <postrishi@gmai l.comwrote in message
        news:f97003a2-b0f7-4115-9c48-7df8bee47bc8@j2 8g2000hsj.googl egroups.com...
        suppose i have a program in which there are two arguements 'a' and 'b'
        >
        the program is such that i will work iff
        -either 'a' or 'b' is present as an option to it
        -both 'a' and 'b' cant be present sameltaneously
        -either of the two should be there
        >
        I want to know is there any way in the function getopt or getopt_long
        that can help me in doing this
        >
        I've got an options parser on my website that may do what you want.

        --
        Free games and programming goodies.


        Comment

        • Mark Bluemel

          #5
          Re: getopt help required

          Rishi wrote:
          suppose i have a program in which there are two arguements 'a' and 'b'
          >
          the program is such that i will work iff
          -either 'a' or 'b' is present as an option to it
          -both 'a' and 'b' cant be present sameltaneously
          -either of the two should be there
          >
          I want to know is there any way in the function getopt or getopt_long
          that can help me in doing this
          getopt is not part of the language, it's a Posix library function, so
          it's not really on-topic here.


          Depending on whether you really want the Posix version or the GNU
          variant, you'd need to look in slightly different places.

          As far as I can see from a brief examination, neither provide an easy
          way of making options/arguments mutually exclusive.

          Comment

          • Keith Thompson

            #6
            Re: getopt help required

            Rishi <postrishi@gmai l.comwrites:
            suppose i have a program in which there are two arguements 'a' and 'b'
            >
            the program is such that i will work iff
            -either 'a' or 'b' is present as an option to it
            -both 'a' and 'b' cant be present sameltaneously
            -either of the two should be there
            >
            I want to know is there any way in the function getopt or getopt_long
            that can help me in doing this
            Ask in comp.unix.progr ammer.

            --
            Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
            Nokia
            "We must do something. This is something. Therefore, we must do this."
            -- Antony Jay and Jonathan Lynn, "Yes Minister"

            Comment

            • Antoninus Twink

              #7
              Re: getopt help required

              On 18 Feb 2008 at 17:21, Keith Thompson wrote:
              Rishi <postrishi@gmai l.comwrites:
              >suppose i have a program in which there are two arguements 'a' and 'b'
              >>
              >the program is such that i will work iff
              >-either 'a' or 'b' is present as an option to it
              >-both 'a' and 'b' cant be present sameltaneously
              >-either of the two should be there
              >>
              >I want to know is there any way in the function getopt or getopt_long
              >that can help me in doing this
              >
              Ask in comp.unix.progr ammer.
              Ah, how the warmth and friendliness shine from every one of Kiki's
              words!

              Comment

              Working...