xref: /freebsd/contrib/sendmail/libsm/t-cf.c (revision a90b9d0159070121c221b966469c3e36d912bf82)
1 /*
2  * Copyright (c) 2001 Proofpoint, Inc. and its suppliers.
3  *	All rights reserved.
4  *
5  * By using this file, you agree to the terms and conditions set
6  * forth in the LICENSE file which can be found at the top level of
7  * the sendmail distribution.
8  *
9  */
10 
11 #include <sm/gen.h>
12 SM_IDSTR(id, "@(#)$Id: t-cf.c,v 1.8 2013-11-22 20:51:43 ca Exp $")
13 
14 #include <errno.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <sm/cf.h>
19 
20 int
21 main(argc, argv)
22 	int argc;
23 	char **argv;
24 {
25 	SM_CF_OPT_T opt;
26 	int err;
27 
28 	if (argc != 3)
29 	{
30 		fprintf(stderr, "Usage: %s .cf-file option\n", argv[0]);
31 		exit(1);
32 	}
33 	opt.opt_name = argv[2];
34 	opt.opt_val = NULL;
35 	err = sm_cf_getopt(argv[1], 1, &opt);
36 	if (err)
37 	{
38 		fprintf(stderr, "%s: %s\n", argv[1], strerror(err));
39 		exit(1);
40 	}
41 	if (opt.opt_val == NULL)
42 		printf("Error: option \"%s\" not found\n", opt.opt_name);
43 	else
44 		printf("%s=%s\n", opt.opt_name, opt.opt_val);
45 	return 0;
46 }
47