8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sendmail / libsmutil / cf.c
blob820a0837791cdcec4b5c515d1135c685d6911c6d
1 /*
2 * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
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.
9 */
11 #pragma ident "%Z%%M% %I% %E% SMI"
13 #include <sendmail.h>
14 SM_RCSID("@(#)$Id: cf.c,v 8.18.2.1 2002/09/24 21:48:23 ca Exp $")
15 #include <sendmail/pathnames.h>
18 ** GETCFNAME -- return the name of the .cf file to use.
20 ** Some systems (e.g., NeXT) determine this dynamically.
22 ** For others: returns submit.cf or sendmail.cf depending
23 ** on the modes.
25 ** Parameters:
26 ** opmode -- operation mode.
27 ** submitmode -- submit mode.
28 ** cftype -- may request a certain cf file.
29 ** conffile -- if set, return it.
31 ** Returns:
32 ** name of .cf file.
35 char *
36 getcfname(opmode, submitmode, cftype, conffile)
37 int opmode;
38 int submitmode;
39 int cftype;
40 char *conffile;
42 #if NETINFO
43 char *cflocation;
44 #endif /* NETINFO */
46 if (conffile != NULL)
47 return conffile;
49 if (cftype == SM_GET_SUBMIT_CF ||
50 ((submitmode != SUBMIT_UNKNOWN ||
51 opmode == MD_DELIVER ||
52 opmode == MD_ARPAFTP ||
53 opmode == MD_SMTP) &&
54 cftype != SM_GET_SENDMAIL_CF))
56 struct stat sbuf;
57 static char cf[MAXPATHLEN];
59 #if NETINFO
60 cflocation = ni_propval("/locations", NULL, "sendmail",
61 "submit.cf", '\0');
62 if (cflocation != NULL)
63 (void) sm_strlcpy(cf, cflocation, sizeof cf);
64 else
65 #endif /* NETINFO */
66 (void) sm_strlcpyn(cf, sizeof cf, 2, _DIR_SENDMAILCF,
67 "submit.cf");
68 if (cftype == SM_GET_SUBMIT_CF || stat(cf, &sbuf) == 0)
69 return cf;
71 #if NETINFO
72 cflocation = ni_propval("/locations", NULL, "sendmail",
73 "sendmail.cf", '\0');
74 if (cflocation != NULL)
75 return cflocation;
76 #endif /* NETINFO */
77 return _PATH_SENDMAILCF;