(ptrace) [PTRACE_TRACEME]: Notify the proc server that we are now traced.
[glibc.git] / manual / examples / testopt.c
blob8ebc9b6f7a3510d63907299aeb49b101fe4585ea
1 /*@group*/
2 #include <unistd.h>
3 #include <stdio.h>
5 int
6 main (int argc, char **argv)
8 int aflag = 0;
9 int bflag = 0;
10 char *cvalue = NULL;
11 int index;
12 int c;
14 opterr = 0;
15 /*@end group*/
17 /*@group*/
18 while ((c = getopt (argc, argv, "abc:")) != -1)
19 switch (c)
21 case 'a':
22 aflag = 1;
23 break;
24 case 'b':
25 bflag = 1;
26 break;
27 case 'c':
28 cvalue = optarg;
29 break;
30 case '?':
31 if (isprint (optopt))
32 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
33 else
34 fprintf (stderr,
35 "Unknown option character `\\x%x'.\n",
36 optopt);
37 return 1;
38 default:
39 abort ();
41 /*@end group*/
43 /*@group*/
44 printf ("aflag = %d, bflag = %d, cvalue = %s\n", aflag, bflag, cvalue);
46 for (index = optind; index < argc; index++)
47 printf ("Non-option argument %s\n", argv[index]);
48 return 0;
50 /*@end group*/