popt cannot parse argv[0]. This is proper behavior if you're only using popt to parse command line arguments (even this is debateable, as one can have one binary application that is either hardlinked or simlinked to different names, and the application switches on argv[0] to act differently. Think collage.), but if you want to use popt to parse configuration files, it would be good to be able to parse argv[0].
rpm uses popt to parse options, and does logic based on argv[0] tests. The "trick" is to call poptGetContext with different values for the 1st and 4th args, and to make heavy use of nested "struct poptOption" tables using POPT_ARG_INCLUDE_TABLES to eliminate redundancy. Otherwise, I need an explicit example of what you are trying to do to even consider an implementation. Feel free to reopen with a more explicit example ...
MKJ wrote a nice program 'ttywatch'. It uses popt to parse a configuration file (see below). Essentially, each line is read in and placed in argv, and then parsed using popt. As argv[0] can't be parsed, the first argument (-- name) actually has to be shifted by one, and a dummy value put in argv[0]. See MKJ for further details, and look at ttywatch in your CVS to see what he did. ### A sample configuration follows: # # --name m1 # --name m2 --port /dev/ttyS1 --bps 9600 # --name m3 --port /dev/ttyS2 --bps 57600 # ### ### machine one (m1) is connected to ttyS0 and talks 115200 bps (default) ### its log is kept in /var/log/ttywatch/m1 ### /dev/m1 is a link to /dev/ttyS0 ### machine two (m2) is connected to ttyS1 and talks 9600 bps ### its log is kept in /var/log/ttywatch/m2 ### machine three (m3) is connected to ttyS2 and talks 57600 bps ### its log is kept in /var/log/ttywatch/m3 ### --name ttyS0
Per MKJ, the functionality is apparently already in popt, but not documented. He promises to send me a doco patch. Please reopen if on or the other of us Johnson's fails to fix :-)