xref: /netbsd-src/external/bsd/mdocml/dist/test-getsubopt.c (revision 544c191c349c1704c9d5e679d12ec15cff579663)
1*544c191cSchristos /*	Id: test-getsubopt.c,v 1.6 2018/08/15 14:37:41 schwarze Exp 	*/
2fec65c98Schristos /*
3fec65c98Schristos  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4fec65c98Schristos  *
5fec65c98Schristos  * Permission to use, copy, modify, and distribute this software for any
6fec65c98Schristos  * purpose with or without fee is hereby granted, provided that the above
7fec65c98Schristos  * copyright notice and this permission notice appear in all copies.
8fec65c98Schristos  *
9fec65c98Schristos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10fec65c98Schristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11fec65c98Schristos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12fec65c98Schristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13fec65c98Schristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14fec65c98Schristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15fec65c98Schristos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16fec65c98Schristos  */
17fec65c98Schristos 
18c5f73b34Sjoerg #include <stdlib.h>
19c5f73b34Sjoerg 
20*544c191cSchristos /*
21*544c191cSchristos  * NetBSD declared this function in the wrong header before August 2018.
22*544c191cSchristos  * No harm is done by allowing that, too:
23*544c191cSchristos  * The only file using it, main.c, also includes unistd.h, anyway.
24*544c191cSchristos  */
25*544c191cSchristos #include <unistd.h>
26*544c191cSchristos 
27c5f73b34Sjoerg int
main(void)2870f041f9Sjoerg main(void)
29c5f73b34Sjoerg {
3070f041f9Sjoerg 	char buf[] = "k=v";
3170f041f9Sjoerg 	char *options = buf;
3270f041f9Sjoerg 	char token0[] = "k";
3370f041f9Sjoerg 	char *const tokens[] = { token0, NULL };
3470f041f9Sjoerg 	char *value = NULL;
359ff1f2acSchristos 	return ! (getsubopt(&options, tokens, &value) == 0
369ff1f2acSchristos 	    && value == buf+2 && options == buf+3);
37c5f73b34Sjoerg }
38