Remove building with NOCRYPTO option
[minix.git] / external / bsd / nvi / dist / motif_l / m_util.c
blob444d5249ae0d89a1c154d9920549015ece4aed20
1 /*-
2 * Copyright (c) 1996
3 * Rob Zimmermann. All rights reserved.
4 * Copyright (c) 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #include <sys/cdefs.h>
13 #if 0
14 #ifndef lint
15 static const char sccsid[] = "Id: m_util.c,v 8.12 2003/11/05 17:10:00 skimo Exp (Berkeley) Date: 2003/11/05 17:10:00 ";
16 #endif /* not lint */
17 #else
18 __RCSID("$NetBSD: m_util.c,v 1.2 2014/01/26 21:43:45 christos Exp $");
19 #endif
21 #include <sys/types.h>
22 #include <sys/queue.h>
24 #include <X11/Intrinsic.h>
25 #include <X11/StringDefs.h>
26 #include <X11/Shell.h>
27 #include <X11/Xatom.h>
29 #include <bitstring.h>
30 #include <stdio.h>
31 #include <string.h>
33 #undef LOCK_SUCCESS
34 #include "../common/common.h"
35 #include "../ipc/ip.h"
36 #include "m_motif.h"
39 /* Widget hierarchy routines
41 * void XutShowWidgetTree( FILE *fp, Widget root, int indent )
42 * prints the widgets and sub-widgets beneath the named root widget
44 #ifdef DEBUG
45 #if defined(__STDC__)
46 void XutShowWidgetTree( FILE *fp, Widget root, int indent )
47 #else
48 void XutShowWidgetTree( fp, root, indent )
49 FILE *fp;
50 Widget root;
51 int indent;
52 #endif
54 #if ! defined(DECWINDOWS)
55 WidgetList l, l2;
56 int i, count = 0;
58 /* print where we are right now */
59 fprintf( fp,
60 "%*.*swidget => 0x%x name => \"%s\"\n\r",
61 indent,
62 indent,
63 "",
64 root,
65 XtName(root) );
67 /* get the correct widget values */
68 XtVaGetValues( root, XtNchildren, &l, 0 );
69 XtVaGetValues( root, XtNchildren, &l2, 0 );
70 XtVaGetValues( root, XtNnumChildren, &count, 0 );
72 /* print the sub-widgets */
73 for ( i=0; i<count; i++ ) {
74 XutShowWidgetTree( fp, l[i], indent+4 );
77 /* tidy up if this thing contained children */
78 if ( count > 0 ) {
79 /* we may or may not have to free the children */
80 if ( l != l2 ) {
81 XtFree( (char *) l );
82 XtFree( (char *) l2 );
85 #endif
87 #endif
90 /* Utilities for converting X resources...
92 * __XutConvertResources( Widget, String root, XutResource *, int count )
93 * The resource block is loaded with converted values
94 * If the X resource does not exist, no change is made to the value
95 * 'root' should be the application name.
97 * PUBLIC: void __XutConvertResources __P((Widget, String, XutResource *, int));
99 void __XutConvertResources(Widget wid, String root, XutResource *resources, int count)
101 int i;
102 XrmValue from, to;
103 String kind;
104 Boolean success = True;
106 /* for each resource */
107 for (i=0; i<count; i++) {
109 /* is there a value in the database? */
110 from.addr = XGetDefault( XtDisplay(wid), root, resources[i].name );
111 if ( from.addr == NULL || *from.addr == '\0' )
112 continue;
114 /* load common parameters */
115 from.size = strlen( from.addr );
116 to.addr = resources[i].value;
118 /* load type-specific parameters */
119 switch ( resources[i].kind ) {
120 case XutRKinteger:
121 to.size = sizeof(int);
122 kind = XtRInt;
123 break;
125 case XutRKboolean:
126 /* String to Boolean */
127 to.size = sizeof(Boolean);
128 kind = XtRBoolean;
129 break;
131 case XutRKfont:
132 /* String to Font structure */
133 to.size = sizeof(XFontStruct *);
134 kind = XtRFontStruct;
135 break;
137 case XutRKpixelBackup:
138 /* String to Pixel backup algorithm */
139 if ( success ) continue;
140 /* FALL through */
142 case XutRKpixel:
143 /* String to Pixel */
144 to.size = sizeof(Pixel);
145 kind = XtRPixel;
146 break;
148 case XutRKcursor:
149 /* String to Cursor */
150 to.size = sizeof(int);
151 kind = XtRCursor;
152 break;
154 default:
155 return;
158 /* call the converter */
159 success = XtConvertAndStore( wid, XtRString, &from, kind, &to );