Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / DtSvc / DtUtil2 / GetMessage.c
1 /* $XConsortium: GetMessage.c /main/5 1996/06/21 17:22:13 ageorge $ */
2 /*
3  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
4  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
5  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
6  * (c) Copyright 1993, 1994 Novell, Inc.                                *
7  */
8 /*************************************<+>*************************************
9  *****************************************************************************
10  **
11  **   File:         GetMessage.c
12  **
13  **   Project:      DT
14  **
15  **   Description:  This file contains the library source code to get
16  **                 a localized message.
17  **
18  **
19  **   (c) Copyright 1992 by Hewlett-Packard Company
20  **
21  *
22  ****************************************************************************
23  ************************************<+>*************************************/
24
25 #include <stdio.h>
26 #include <nl_types.h>
27 #include "DtSvcLock.h"
28
29 #if !defined(NL_CAT_LOCALE)
30 #define NL_CAT_LOCALE 0
31 #endif
32
33 /*****************************************************************************
34  *
35  * Function: _DtGetMessage
36  *
37  * Parameters:
38  *
39  *   char       *filename -     Filename to open.
40  *
41  *   int        set -           The message catalog set number.
42  *
43  *   int        n -             The message number.
44  *
45  *   char       *s -            The default message if the message is not
46  *                              retrieved from a message catalog.
47  *
48  * Returns: the string for set 'set' and number 'n'.
49  *
50  *****************************************************************************/
51
52 char * 
53 _DtGetMessage(
54         char *filename,
55         int set,
56         int n,
57         char *s )
58 {
59         char *msg;
60         char *lang;
61         nl_catd catopen();
62         char *catgets();
63         static int first = 1;
64         static nl_catd nlmsg_fd;
65
66         _DtSvcProcessLock();
67         if ( first ) 
68         {
69                 first = 0;
70                 nlmsg_fd = catopen(filename, NL_CAT_LOCALE);
71         }
72         msg=catgets(nlmsg_fd,set,n,s);
73         _DtSvcProcessUnlock();
74         return (msg);
75 }