getopt_long.3 (c2025a76606b44c4d5367b7509fbc0285ae1e7f8) | getopt_long.3 (bd45f5676d4ee95d5460a9b62cd346c3e01fc614) |
---|---|
1.\" $OpenBSD: getopt_long.3,v 1.10 2004/01/06 23:44:28 fgsch Exp $ 2.\" $NetBSD: getopt_long.3,v 1.14 2003/08/07 16:43:40 agc Exp $ 3.\" 4.\" Copyright (c) 1988, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 32.\" $FreeBSD$ 33.\" | 1.\" $OpenBSD: getopt_long.3,v 1.10 2004/01/06 23:44:28 fgsch Exp $ 2.\" $NetBSD: getopt_long.3,v 1.14 2003/08/07 16:43:40 agc Exp $ 3.\" 4.\" Copyright (c) 1988, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 32.\" $FreeBSD$ 33.\" |
34.Dd April 1, 2000 | 34.Dd December 25, 2011 |
35.Dt GETOPT_LONG 3 36.Os 37.Sh NAME 38.Nm getopt_long , 39.Nm getopt_long_only 40.Nd get long options from command line argument list 41.Sh LIBRARY 42.Lb libc --- 191 unchanged lines hidden (view full) --- 234static struct option longopts[] = { 235 { "buffy", no_argument, NULL, 'b' }, 236 { "fluoride", required_argument, NULL, 'f' }, 237 { "daggerset", no_argument, \*[Am]daggerset, 1 }, 238 { NULL, 0, NULL, 0 } 239}; 240 241bflag = 0; | 35.Dt GETOPT_LONG 3 36.Os 37.Sh NAME 38.Nm getopt_long , 39.Nm getopt_long_only 40.Nd get long options from command line argument list 41.Sh LIBRARY 42.Lb libc --- 191 unchanged lines hidden (view full) --- 234static struct option longopts[] = { 235 { "buffy", no_argument, NULL, 'b' }, 236 { "fluoride", required_argument, NULL, 'f' }, 237 { "daggerset", no_argument, \*[Am]daggerset, 1 }, 238 { NULL, 0, NULL, 0 } 239}; 240 241bflag = 0; |
242while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) | 242while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) { |
243 switch (ch) { 244 case 'b': 245 bflag = 1; 246 break; 247 case 'f': 248 if ((fd = open(optarg, O_RDONLY, 0)) == -1) 249 err(1, "unable to open %s", optarg); 250 break; 251 case 0: 252 if (daggerset) { 253 fprintf(stderr,"Buffy will use her dagger to " 254 "apply fluoride to dracula's teeth\en"); 255 } 256 break; 257 default: 258 usage(); | 243 switch (ch) { 244 case 'b': 245 bflag = 1; 246 break; 247 case 'f': 248 if ((fd = open(optarg, O_RDONLY, 0)) == -1) 249 err(1, "unable to open %s", optarg); 250 break; 251 case 0: 252 if (daggerset) { 253 fprintf(stderr,"Buffy will use her dagger to " 254 "apply fluoride to dracula's teeth\en"); 255 } 256 break; 257 default: 258 usage(); |
259 } |
|
259} 260argc -= optind; 261argv += optind; 262.Ed 263.Sh IMPLEMENTATION DIFFERENCES 264This section describes differences to the 265.Tn GNU 266implementation --- 240 unchanged lines hidden --- | 260} 261argc -= optind; 262argv += optind; 263.Ed 264.Sh IMPLEMENTATION DIFFERENCES 265This section describes differences to the 266.Tn GNU 267implementation --- 240 unchanged lines hidden --- |