VirtualBox

Changeset 14326 in vbox


Ignore:
Timestamp:
Nov 18, 2008 8:04:36 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
39527
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 *      }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette