VirtualBox

Changeset 14326

Show
Ignore:
Timestamp:
11/18/08 21:04:36 (2 months ago)
Author:
vboxsync
Message:

getopt: sample code corrections. (hope they are right)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/iprt/getopt.h

    r8245 r14326  
    171171 * int main(int argc, char *argv[]) 
    172172 * { 
    173  *      static const RTOPTIONDEF g_aOptions[] = 
     173 *      static const RTOPTIONDEF s_aOptions[] = 
    174174 *      { 
    175175 *          { "--optwithstring",    's', RTGETOPT_REQ_STRING }, 
     
    181181 *      int i = 1; 
    182182 *      RTOPTIONUNION ValueUnion; 
    183  *      while ((ch = RTGetOpt(argc, argv, g_aOptions, RT_ELEMENTS(g_aOptions), &i, &ValueUnion))) 
     183 *      while ((ch = RTGetOpt(argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), &i, &ValueUnion))) 
    184184 *      { 
    185  *          if (ch < 0) { .... error } 
    186  * 
    187185 *          // for options that require an argument, ValueUnion has received the value 
    188186 *          switch (ch) 
     
    199197 *                  g_fOptVerbose = true; 
    200198 *                  break; 
     199 * 
     200 *              default: 
     201 *                  if (ch > 0) 
     202 *                      Error("missing case: %c\n", ch); 
     203 *                  else if (ValueUnion.pDef) 
     204 *                      Error("%s: %Rrc, ValueUnion.pDef->pszLong); 
     205 *                  else 
     206 *                      Error("%Rrc, ValueUnion.pDef->pszLong); 
     207 *                  return 1; 
    201208 *          } 
    202209 *      } 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy