| 1 |
/*--------------------------------------------------------------------- |
| 2 |
* $Date: 2009-08-18 15:23:20 $ $Revision: 1.2 $ |
| 3 |
*--------------------------------------------------------------------- |
| 4 |
* |
| 5 |
* |
| 6 |
* Copyright (c) 1988, Visual Edge Software Ltd. |
| 7 |
* |
| 8 |
* ALL RIGHTS RESERVED. Permission to use, copy, modify, and |
| 9 |
* distribute this software and its documentation for any purpose |
| 10 |
* and without fee is hereby granted, provided that the above |
| 11 |
* copyright notice appear in all copies and that both that |
| 12 |
* copyright notice and this permission notice appear in supporting |
| 13 |
* documentation, and that the name of Visual Edge Software not be |
| 14 |
* used in advertising or publicity pertaining to distribution of |
| 15 |
* the software without specific, written prior permission. The year |
| 16 |
* included in the notice is the year of the creation of the work. |
| 17 |
*-------------------------------------------------------------------*/ |
| 18 |
|
| 19 |
/* |
| 20 |
.VERSION |
| 21 |
090818 last modif |
| 22 |
*/ |
| 23 |
|
| 24 |
/* --------------------------------------------------------------------------- |
| 25 |
DESCRIPTION: |
| 26 |
Routines to handle user messages from the message catalog |
| 27 |
|
| 28 |
----------------------------------------------------------------------------*/ |
| 29 |
#include <stdio.h> |
| 30 |
#include <stdlib.h> |
| 31 |
|
| 32 |
#include "uimx_cat.h" |
| 33 |
|
| 34 |
extern char *UxCopyString(); |
| 35 |
extern void UxInitErrorHandler(); |
| 36 |
|
| 37 |
|
| 38 |
#ifdef XOPEN_CATALOG |
| 39 |
#if defined(sun4) || defined(SOLARIS) |
| 40 |
char *catgets(); |
| 41 |
|
| 42 |
#endif |
| 43 |
#include <nl_types.h> |
| 44 |
static nl_catd catd = -1; |
| 45 |
|
| 46 |
|
| 47 |
/* --------------------------------------------------------------------------- |
| 48 |
NAME: int UxCatOpen |
| 49 |
INPUT: None |
| 50 |
RETURNS: -1 if Open failed, > 0 otherwise |
| 51 |
DESCRIPTION: Opens the message catalog file which contains all the |
| 52 |
language dependant messages. |
| 53 |
CREATION: 15 Aug 1990 |
| 54 |
---------------------------------------------------------------------------*/ |
| 55 |
|
| 56 |
int UxCatOpen() |
| 57 |
{ |
| 58 |
catd = catopen(CAT_FILE, 0); |
| 59 |
return (catd); |
| 60 |
} |
| 61 |
|
| 62 |
/* --------------------------------------------------------------------------- |
| 63 |
NAME: void UxCatClose |
| 64 |
INPUT: None |
| 65 |
RETURNS: Nothing |
| 66 |
DESCRIPTION: Closes the message catalog file |
| 67 |
CREATION: 15 Aug 1990 |
| 68 |
---------------------------------------------------------------------------*/ |
| 69 |
|
| 70 |
void UxCatClose() |
| 71 |
{ |
| 72 |
catclose(catd); |
| 73 |
} |
| 74 |
|
| 75 |
/* --------------------------------------------------------------------------- |
| 76 |
NAME: char *UxCatGets(set_num, msg_num, default_str) |
| 77 |
INPUT: set_num -- Message set number |
| 78 |
msg_num -- Message number |
| 79 |
default_str -- default string to return if call fails |
| 80 |
RETURNS: A pointer to a message string |
| 81 |
DESCRIPTION: Retrieves a message from an open message catalog. |
| 82 |
CREATION: 15 Aug 1990 |
| 83 |
---------------------------------------------------------------------------*/ |
| 84 |
|
| 85 |
char *UxCatGets(set_num, msg_num, default_str) |
| 86 |
int set_num; |
| 87 |
int msg_num; |
| 88 |
char *default_str; |
| 89 |
{ |
| 90 |
char *result; |
| 91 |
|
| 92 |
if (catd == -1) |
| 93 |
return(default_str); |
| 94 |
result = catgets(catd, set_num, msg_num, default_str); |
| 95 |
if ( *result == '\0' ) |
| 96 |
return(default_str); |
| 97 |
return( result); |
| 98 |
} |
| 99 |
|
| 100 |
/* --------------------------------------------------------------------------- |
| 101 |
NAME: void UxMsg(type, msg, arg) |
| 102 |
INPUT: type -- Message display type |
| 103 |
msg -- Message to display (should come from the |
| 104 |
message catalog |
| 105 |
arg -- additional argument - optional |
| 106 |
RETURNS: |
| 107 |
DESCRIPTION: Calls UxMsg2 with the display type argument and with |
| 108 |
with any additional argument passed. |
| 109 |
CREATION: Aout 1990 |
| 110 |
---------------------------------------------------------------------------*/ |
| 111 |
|
| 112 |
#endif |
| 113 |
#ifdef RUNTIME |
| 114 |
|
| 115 |
char *UxInitCat() |
| 116 |
{ |
| 117 |
int n; |
| 118 |
|
| 119 |
char *AppName; |
| 120 |
#if !(defined(sun4) || defined(SOLARIS)) |
| 121 |
if (!getenv("LANG")) |
| 122 |
putenv("LANG=C"); |
| 123 |
#endif |
| 124 |
n = UxCatOpen(); |
| 125 |
AppName = UxCopyString(UxCatGets(MC_SYSTEM_NAME,MS_SYS_RUNTIME_RSRC_NAME, |
| 126 |
DS_MS_SYS_RUNTIME_RSRC_NAME)); |
| 127 |
UxInitErrorHandler(); |
| 128 |
return(AppName); |
| 129 |
} |
| 130 |
#endif |
| 131 |
|
| 132 |
|