xref: /illumos-gate/usr/src/cmd/mailx/lpaths.c (revision b31f5cf7caf42b613fba3556b30879385cb2348d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * University Copyright- Copyright (c) 1982, 1986, 1988
28  * The Regents of the University of California
29  * All Rights Reserved
30  *
31  * University Acknowledgment- Portions of this document are derived from
32  * software developed by the University of California, Berkeley, and its
33  * contributors.
34  */
35 
36 /*
37  * mailx -- a modified version of a University of California at Berkeley
38  *	mail program
39  */
40 
41 /*
42  *	libpath(file) - return the full path to the library file
43  */
44 
45 #include <stdio.h>	/* for declaration of sprintf */
46 #include <unistd.h>	/* for declaration of access */
47 #include "uparm.h"
48 #include <locale.h>
49 
50 #define	PATHSIZE	1024
51 
52 char *
53 libpath(char *file)
54 {
55 	static char	buf[PATHSIZE];
56 
57 	snprintf(buf, sizeof (buf), "%s/%s", LIBPATH, file);
58 	return (buf);
59 }
60 
61 /*
62  * Return the path to a potentially locale-specific help file.
63  */
64 char *
65 helppath(char *file)
66 {
67 	static char	buf[PATHSIZE];
68 	char *loc;
69 
70 	loc = setlocale(LC_MESSAGES, NULL);
71 	if (loc != NULL) {
72 		snprintf(buf, sizeof (buf), "%s/%s/LC_MESSAGES/%s",
73 			LOCALEPATH, loc, file);
74 		if (access(buf, 0) == 0)
75 			return (buf);
76 	}
77 	snprintf(buf, sizeof (buf), "%s/%s", LIBPATH, file);
78 	return (buf);
79 }
80