xref: /illumos-gate/usr/src/test/os-tests/tests/definit/definit_test.c (revision dd72704bd9e794056c558153663c739e2012d721)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
14  */
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <err.h>
19 #include <definit.h>
20 
21 int
22 main(int argc, char **argv)
23 {
24 	void *state;
25 	const char *p;
26 
27 	if (argc != 2) {
28 		fprintf(stderr, "Syntax: %s <init file>\n", argv[0]);
29 		exit(EXIT_FAILURE);
30 	}
31 
32 	if (definit_open(argv[1], &state) != 0)
33 		err(EXIT_FAILURE, "Open of %s failed.", argv[1]);
34 
35 	while ((p = definit_token(state)) != NULL)
36 		printf(":%s:\n", p);
37 
38 	definit_close(state);
39 
40 	return (0);
41 }
42