Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,144 @@
/* $XConsortium: Info.c /main/1 1996/03/25 19:10:11 barstow $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*
* This file contains the main program for: dtinfo_start
*/
#include <stdlib.h>
#include <sys/param.h> /* MAXHOSTNAMELEN */
#include <Tt/tt_c.h>
#include <Dt/Info.h>
#include <Dt/Connect.h>
/*
* External declaration for Xegethostname
*/
extern int Xegetshorthostname (char * hostname, unsigned int size);
/*
* Static variables
*/
static const char * DTINFOLIBDEFAULT_NAME = "DTINFOLIBDEFAULT";
static const char * DTINFOLIBDEFAULT_DEFAULT = "cde";
static const char * SHOW_INFO_OP_NAME = "DtInfo_ShowInfoAtLoc";
static const char * SHOW_INFO_DEFAULT_ACTION = "DtInfoStartAtLoc";
static const char * LOCALE_NAME = "LANG";
static const char * DEFAULT_LOCALE = "C";
static const char * STRING_ARG_TYPE = "string";
/*
* Forward declarations for static functions
*/
static DtInfoShowStatus ConnectToMessageServer ();
/*
* Public functions
*/
DtInfoShowStatus
DtInfoShowTopic (
const char * info_lib, /* the InfoLib */
const char * locator) /* the generalized locator
format */
{
Tt_message message;
Tt_status status;
DtInfoShowStatus ret_val;
const char * file = info_lib;
const char * locale;
char host[MAXHOSTNAMELEN];
/*
* Check the arguments
*/
if (!locator)
return (DtINFO_SHOW_BAD_LOCATOR);
if ((ret_val = ConnectToMessageServer ()) != DtINFO_SHOW_OK)
return (ret_val);
if (!file) {
if ((file = getenv (DTINFOLIBDEFAULT_NAME)) == NULL)
file = DTINFOLIBDEFAULT_DEFAULT;
}
if ((locale = getenv (LOCALE_NAME)) == NULL)
locale = DEFAULT_LOCALE;
message = tt_message_create ();
status = tt_ptr_error (message);
if (status != TT_OK)
return (DtINFO_SHOW_MSG_CREATE_FAIL);
/*
* Initialize message
*/
tt_message_class_set (message, TT_REQUEST);
tt_message_scope_set (message, TT_SESSION);
tt_message_address_set (message, TT_PROCEDURE);
tt_message_session_set (message, tt_default_session());
tt_message_op_set (message, SHOW_INFO_OP_NAME);
tt_message_file_set (message, info_lib);
/*
* Add the arguments
*/
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE,
SHOW_INFO_DEFAULT_ACTION);
if ((Xegetshorthostname (host, MAXHOSTNAMELEN)) != 0)
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, NULL);
else
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, host);
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, locale);
tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, locator);
/*
* Send it
*/
status = tt_message_send (message);
if (status != TT_OK)
return (DtINFO_SHOW_MSG_SEND_FAIL);
return (DtINFO_SHOW_OK);
}
static DtInfoShowStatus
ConnectToMessageServer ()
{
char * procid;
Tt_status status;
procid = tt_default_procid ();
status = tt_ptr_error (procid);
if (status == TT_OK) {
tt_free (procid);
}
if ((status == TT_ERR_NOMP) || (status == TT_ERR_PROCID)) {
procid = tt_open ();
status = tt_ptr_error (procid);
if (status != TT_OK) {
return (DtINFO_SHOW_TT_OPEN_FAIL);
}
}
return (DtINFO_SHOW_OK);
}