freebsd-skq/contrib/sendmail/libsmutil/cf.c

77 lines
1.7 KiB
C
Raw Normal View History

2002-02-17 21:56:45 +00:00
/*
2014-01-26 20:46:55 +00:00
* Copyright (c) 2000-2002 Proofpoint, Inc. and its suppliers.
2002-02-17 21:56:45 +00:00
* 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.20 2013-11-22 20:51:50 ca Exp $")
2002-02-17 21:56:45 +00:00
#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;
{
2003-02-08 20:31:29 +00:00
#if NETINFO
char *cflocation;
#endif /* NETINFO */
2002-02-17 21:56:45 +00:00
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;
2002-06-11 21:12:04 +00:00
static char cf[MAXPATHLEN];
2002-02-17 21:56:45 +00:00
2003-02-08 20:31:29 +00:00
#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");
2002-02-17 21:56:45 +00:00
if (cftype == SM_GET_SUBMIT_CF || stat(cf, &sbuf) == 0)
return cf;
}
2003-02-08 20:31:29 +00:00
#if NETINFO
cflocation = ni_propval("/locations", NULL, "sendmail",
"sendmail.cf", '\0');
if (cflocation != NULL)
return cflocation;
#endif /* NETINFO */
2002-02-17 21:56:45 +00:00
return _PATH_SENDMAILCF;
}