2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Info.c /main/1 1996/03/25 19:10:11 barstow $
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
33 * This file contains the main program for: dtinfo_start
37 #include <sys/param.h> /* MAXHOSTNAMELEN */
40 #include <Dt/Connect.h>
43 * External declaration for Xegethostname
45 extern int Xegetshorthostname (char * hostname, unsigned int size);
51 static const char * DTINFOLIBDEFAULT_NAME = "DTINFOLIBDEFAULT";
53 static const char * DTINFOLIBDEFAULT_DEFAULT = "cde";
55 static const char * SHOW_INFO_OP_NAME = "DtInfo_ShowInfoAtLoc";
57 static const char * SHOW_INFO_DEFAULT_ACTION = "DtInfoStartAtLoc";
59 static const char * LOCALE_NAME = "LANG";
61 static const char * DEFAULT_LOCALE = "C";
63 static const char * STRING_ARG_TYPE = "string";
67 * Forward declarations for static functions
69 static DtInfoShowStatus ConnectToMessageServer ();
77 const char * info_lib, /* the InfoLib */
78 const char * locator) /* the generalized locator
83 DtInfoShowStatus ret_val;
84 const char * file = info_lib;
86 char host[MAXHOSTNAMELEN];
92 return (DtINFO_SHOW_BAD_LOCATOR);
94 if ((ret_val = ConnectToMessageServer ()) != DtINFO_SHOW_OK)
98 if ((file = getenv (DTINFOLIBDEFAULT_NAME)) == NULL)
99 file = DTINFOLIBDEFAULT_DEFAULT;
102 if ((locale = getenv (LOCALE_NAME)) == NULL)
103 locale = DEFAULT_LOCALE;
105 message = tt_message_create ();
106 status = tt_ptr_error (message);
108 return (DtINFO_SHOW_MSG_CREATE_FAIL);
113 tt_message_class_set (message, TT_REQUEST);
114 tt_message_scope_set (message, TT_SESSION);
115 tt_message_address_set (message, TT_PROCEDURE);
116 tt_message_session_set (message, tt_default_session());
117 tt_message_op_set (message, SHOW_INFO_OP_NAME);
118 tt_message_file_set (message, info_lib);
123 tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE,
124 SHOW_INFO_DEFAULT_ACTION);
126 if ((Xegetshorthostname (host, MAXHOSTNAMELEN)) != 0)
127 tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, NULL);
129 tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, host);
131 tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, locale);
132 tt_message_arg_add (message, TT_IN, STRING_ARG_TYPE, locator);
137 status = tt_message_send (message);
139 return (DtINFO_SHOW_MSG_SEND_FAIL);
141 return (DtINFO_SHOW_OK);
145 static DtInfoShowStatus
146 ConnectToMessageServer ()
151 procid = tt_default_procid ();
152 status = tt_ptr_error (procid);
153 if (status == TT_OK) {
157 if ((status == TT_ERR_NOMP) || (status == TT_ERR_PROCID)) {
159 status = tt_ptr_error (procid);
160 if (status != TT_OK) {
161 return (DtINFO_SHOW_TT_OPEN_FAIL);
165 return (DtINFO_SHOW_OK);