/**********************************************************************
* Locale.c,v 3.9VMS 1995/09/25 11:21 wilkinson
*
* Paul Lindner, University of Minnesota DCS
*
* Copyright 1994 by the Regents of the University of Minnesota
* see the file "Copyright" in the distribution for conditions of use.
**********************************************************************
* MODULE: Locale.c
* These routines make using the international messages facilities easier.
*
* This interface could be applied to methods other than X/Open coding
* (VMS etc..)
**********************************************************************
* Locale.c,v
* Revision 3.9VMS 1995/09/25 11:21 wilkinson
* Use __VMS instead of VMS as trigger for VMS items; handle initial server
* usage of ?locale() functions for VMS.
*
* Revision 3.9 1994/12/05 22:44:42 lindner
* Added VMS code from F. Macrides for specifying the default language
* via the GOPHERMSGS_DEFAULT definition in conf.h, for when a series of
* languages have been made available by setting the DCL logical
* LC_MESSAGES to the * wildcard.
*
* Added code for specifying the device where shared images of message
* files will be found, via the GOPHERMSGS_DEV definition in conf.h.
*
* Blocked potential ACCVIO's for VMSers who misunderstand how to set up
* the messaging and do it wrong.
*
* Revision 3.8 1994/11/24 08:10:20 lindner
* sundry compiler fixes
*
* Revision 3.7 1994/11/17 06:34:00 lindner
* Fixes for VMS internationalization
*
* Revision 3.6 1994/08/19 16:27:51 lindner
* Alan's mega-patch for Locale stuff
*
* Revision 3.5 1994/07/25 14:00:35 lindner
* Add std comments
*
*/
#ifdef NO_XPGCAT
/** if we're not using the X/Open message catalogs, we have to keep
track of the locale **/
String *msgLocale = NULL;
#endif /* NO_XPGCAT */
/*
** Emulate catgets() by securing a VMS message
*/
char *
catgets(junk1, junk2, code, msg_default)
int junk1;
int junk2;
int code;
char *msg_default;
{
struct dsc$descriptor_s buf_;
static
char buf[512];
int i;
int x;
/*
** This procedure secures the LC_MESSAGES logical or symbol or SYS$LANGUAGE
** system logical and inserts it into the GopherP_Dir:gopher_msg_%s.exe
** filespec. If not defined, "*" is inserted, triggering a wildcard search
** of message files. The filespec is then searched for, and for each
** matching filespec found, the message number 222 is retrieved and inserted
** into a menu list. If no menu list entries are retrieved, Gtxt() is
** disabled, causing the default message to be returned. If only one menu
** list entry is retrieved, the message file it came from is chosen as the
** process level message file and Gtxt() is enabled to read it. If more
** than one menu list entry is retrieved, the menu is offered to the user,
** and the choice they make is set as the process level message file and
** Gtxt() is enabled to read it.
*/
/* Scan for fname; on a hit, activate the image and get menu message */
wild_fab = cc$rms_fab;
wild_nam = cc$rms_nam;
wild_fab.fab$b_fac = FAB$M_GET;
wild_fab.fab$l_fop = FAB$V_NAM;
wild_fab.fab$l_nam = &wild_nam;
wild_fab.fab$l_dna = fname;
wild_fab.fab$b_dns = strlen(wild_fab.fab$l_dna);
wild_nam.nam$l_esa = expanded;
wild_nam.nam$l_rsa = result;
wild_nam.nam$b_ess = wild_nam.nam$b_rss = 255;
wild_fab.fab$l_fna = fullname;
wild_fab.fab$b_fns = fullname[0] = expanded[0] = result[0] = 0;
if ((status = SYS$PARSE(&wild_fab)) != RMS$_NORMAL)
return; /* The while loop will hang if wild_fab is invalid */
Gcatd = (nl_catd) 1; /* Always try to get the msg here. */
while (status!=RMS$_NMF && status!=RMS$_FNF) {
if ((( status = SYS$SEARCH(&wild_fab)) &1) != 1)
continue;
result[wild_nam.nam$b_rsl] = '\0';
if ((nl_catd)1 != catopen(result,0))
continue;
strcpy(command,Gtxt("",232));
if (strlen(command)) { /* An available language */
if (setlocale_LangDir == NULL) {
setlocale_LangDir = GDnew(32); /* 1st language */
GDsetTitle(setlocale_LangDir,"");
}
tmpgs = GSnew(); /* Store language menu item */
GSsetTitle(tmpgs, command);
strcpy(command+1,result);
GSsetType(tmpgs, command[0] = A_LANGUAGE);
GSsetPath(tmpgs, command);
GSsetHost(tmpgs,"0.0.0.0");
GSsetPort(tmpgs,GTXT_facility);
GDaddGS(setlocale_LangDir, tmpgs);
GSdestroy(tmpgs);
if (strcmp(GTXT_language+1,GOPHERMSGS_DEFAULT)==0) {
defaultLang = GDgetNumitems(setlocale_LangDir) - 1;
}
}
}
Gcatd = (nl_catd) -1; /* By default, never bother trying a message file */
if (setlocale_LangDir) {
/* We have one or more available languages */
if (GDgetNumitems(setlocale_LangDir)==1) {
status = 0; /* Only one choice */
rsetlocale(GSgetPort(GDgetEntry(setlocale_LangDir,0)));
GDdestroy(setlocale_LangDir);
setlocale_LangDir = NULL;
}
else if (defaultLang != -1) /* No choice for now. */
rsetlocale(GSgetPort(GDgetEntry(setlocale_LangDir,defaultLang)));
else { /* Two or more choices. */
status = setlocale_screen();
rsetlocale(GSgetPort(GDgetEntry(setlocale_LangDir,status)));
}
}
}
#else
/* Really chopped down setlocale() for server usage on OpenVMS
specialized parameters, too: setlocale(support_directory,lang);
This allows us to pass the directory where the GopherD.exe file
resides (by passing the pname pulled off the command line) and
the default language (specified in the configuration file or
by default in the user environment variable LC_MESSAGES).
*/
void
setlocale(char *x, char *y)
{
int status;
char fname[256];
strcpy(fname, x);
strcat(fname,"gopherd_msg");
if (y)
if (strlen(y)) {
strcat(fname,"_");
strcat(fname,y);
}
strcat(fname,".exe");
if ((nl_catd)1 != catopen(fname,0))
Gcatd = (nl_catd) -1; /* By default, never bother trying a message file */
rsetlocale(GTXT_facility);
}
#endif
void
Gtxtlocale(a,b)
char *a, *b;
{
setlocale(a,b);
}