~ubuntu-branches/ubuntu/maverick/eglibc/maverick-security

« back to all changes in this revision

Viewing changes to manual/testopt.c.texi

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-05-30 11:05:12 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100530110512-axurnekxr2yygcf2
Tags: 2.12-0ubuntu1
* Build eglibc_2.12.orig.tar.gz, based on 2.12 branch (r10591).
* Merge with Debian (r4299, trunk).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
@group
2
 
#include <ctype.h>
3
 
#include <stdio.h>
4
 
#include <stdlib.h>
5
 
#include <unistd.h>
6
 
 
7
 
int
8
 
main (int argc, char **argv)
9
 
@{
10
 
  int aflag = 0;
11
 
  int bflag = 0;
12
 
  char *cvalue = NULL;
13
 
  int index;
14
 
  int c;
15
 
 
16
 
  opterr = 0;
17
 
@end group
18
 
 
19
 
@group
20
 
  while ((c = getopt (argc, argv, "abc:")) != -1)
21
 
    switch (c)
22
 
      @{
23
 
      case 'a':
24
 
        aflag = 1;
25
 
        break;
26
 
      case 'b':
27
 
        bflag = 1;
28
 
        break;
29
 
      case 'c':
30
 
        cvalue = optarg;
31
 
        break;
32
 
      case '?':
33
 
        if (optopt == 'c')
34
 
          fprintf (stderr, "Option -%c requires an argument.\n", optopt);
35
 
        else if (isprint (optopt))
36
 
          fprintf (stderr, "Unknown option `-%c'.\n", optopt);
37
 
        else
38
 
          fprintf (stderr,
39
 
                   "Unknown option character `\\x%x'.\n",
40
 
                   optopt);
41
 
        return 1;
42
 
      default:
43
 
        abort ();
44
 
      @}
45
 
@end group
46
 
 
47
 
@group
48
 
  printf ("aflag = %d, bflag = %d, cvalue = %s\n",
49
 
          aflag, bflag, cvalue);
50
 
 
51
 
  for (index = optind; index < argc; index++)
52
 
    printf ("Non-option argument %s\n", argv[index]);
53
 
  return 0;
54
 
@}
55
 
@end group