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 librararies 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: datatyping.c /main/3 1995/10/27 10:39:52 rswiston $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company
26 * (c) Copyright 1993, 1994 International Business Machines Corp.
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
28 * (c) Copyright 1993, 1994 Novell, Inc.
35 #define ApplicationClass "DtDatatyping"
39 static void DisplayTypeInfo(int, char**);
41 int main(int argc, char **argv)
43 XtAppContext appContext;
44 Widget toplevel, form;
48 toplevel = XtAppInitialize(&appContext, ApplicationClass, NULL, 0,
49 &argc, argv, NULL, NULL, 0);
52 printf("%s: No files specified.\n", argv[0]);
56 form = XmCreateForm(toplevel, "form", NULL, 0);
59 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
60 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
61 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
62 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
63 XtSetArg(args[n], XmNeditable, False); n++;
64 XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
65 XtSetArg(args[n], XmNrows, 25); n++;
66 XtSetArg(args[n], XmNcolumns, 90); n++;
67 text = XmCreateScrolledText(form, "text", args, n);
70 XtRealizeWidget(toplevel);
72 if (DtAppInitialize(appContext, XtDisplay(toplevel), toplevel, argv[0],
73 ApplicationClass) == False) {
74 printf("%s: Couldn't initialize Dt\n", argv[0]);
80 DisplayTypeInfo(argc, argv);
82 XtAppMainLoop(appContext);
85 static void DisplayTypeInfo(int argc, char **argv)
94 sprintf(str, "%-30s\t%-10s\t%-8s\t%-20s\n",
99 XmTextInsert(text, XmTextGetLastPosition(text), str);
101 sprintf(str, "%-30s\t%-10s\t%-8s\t%-20s\n",
102 "-------------------",
106 XmTextInsert(text, XmTextGetLastPosition(text), str);
108 for(i=1; i < argc; i++) {
109 char *file = argv[i];
111 /* find out the Dts data type */
112 datatype = DtDtsFileToDataType(file);
115 /* find the icon attribute for the data type */
116 icon = DtDtsDataTypeToAttributeValue(datatype, DtDTS_DA_ICON, file);
119 /* Directly find the action attribute for a file */
121 actions = DtDtsFileToAttributeValue(file, DtDTS_DA_ACTION_LIST);
123 sprintf(str, "%-30s\t%-10s\t%-8s\t%s\n",
125 datatype?datatype:"unknown",
127 actions?actions:"unknown");
128 XmTextInsert(text, XmTextGetLastPosition(text), str);
130 /* Free the space allocated by Dts */
132 DtDtsFreeAttributeValue(icon);
133 DtDtsFreeAttributeValue(actions);
134 DtDtsFreeDataType(datatype);