summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/libsmutil/cf.c
blob: f313762f5577ab1b3595240a8ccab94fce84c2ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
 *	All rights reserved.
 *
 * By using this file, you agree to the terms and conditions set
 * forth in the LICENSE file which can be found at the top level of
 * the sendmail distribution.
 *
 */

#include <sendmail.h>
SM_RCSID("@(#)$Id: cf.c,v 8.19 2002/09/24 20:40:59 ca Exp $")
#include <sendmail/pathnames.h>

/*
**  GETCFNAME -- return the name of the .cf file to use.
**
**	Some systems (e.g., NeXT) determine this dynamically.
**
**	For others: returns submit.cf or sendmail.cf depending
**		on the modes.
**
**	Parameters:
**		opmode -- operation mode.
**		submitmode -- submit mode.
**		cftype -- may request a certain cf file.
**		conffile -- if set, return it.
**
**	Returns:
**		name of .cf file.
*/

char *
getcfname(opmode, submitmode, cftype, conffile)
	int opmode;
	int submitmode;
	int cftype;
	char *conffile;
{
#if NETINFO
	char *cflocation;
#endif /* NETINFO */

	if (conffile != NULL)
		return conffile;

	if (cftype == SM_GET_SUBMIT_CF ||
	    ((submitmode != SUBMIT_UNKNOWN ||
	      opmode == MD_DELIVER ||
	      opmode == MD_ARPAFTP ||
	      opmode == MD_SMTP) &&
	     cftype != SM_GET_SENDMAIL_CF))
	{
		struct stat sbuf;
		static char cf[MAXPATHLEN];

#if NETINFO
		cflocation = ni_propval("/locations", NULL, "sendmail",
					"submit.cf", '\0');
		if (cflocation != NULL)
			(void) sm_strlcpy(cf, cflocation, sizeof cf);
		else
#endif /* NETINFO */
			(void) sm_strlcpyn(cf, sizeof cf, 2, _DIR_SENDMAILCF,
					   "submit.cf");
		if (cftype == SM_GET_SUBMIT_CF || stat(cf, &sbuf) == 0)
			return cf;
	}
#if NETINFO
	cflocation = ni_propval("/locations", NULL, "sendmail",
				"sendmail.cf", '\0');
	if (cflocation != NULL)
		return cflocation;
#endif /* NETINFO */
	return _PATH_SENDMAILCF;
}
OpenPOWER on IntegriCloud