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: misc.c /main/5 1996/10/04 16:21:08 drk $ */
24 /* Copyright (c) 1991, 1992 UNIX System Laboratories, Inc. */
25 /* All Rights Reserved */
27 /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
28 /* UNIX System Laboratories, Inc. */
29 /* The copyright notice above does not evidence any */
30 /* actual or intended publication of such source code. */
36 #include <X11/Intrinsic.h>
37 #include <X11/IntrinsicP.h>
41 #include "exksh.h" /* which includes sys/types.h */
42 /* #include <sys/param.h> */
44 /* #include <search.h> */
49 static char use[] = "0x%lx";
57 return(strcmp(((struct symarray *) sym1)->str, ((struct symarray *) sym2)->str));
66 return((void *) strtoul(str, NULL, 0));
68 return((void *) fsym(str, -1));
80 static char xk_ret_buffer[1024];
83 for (i = 1; (i < argc) && argv[i] != NULL && argv[i][0] == '-'; i++) {
84 if (isdigit(argv[i][1])) {
87 ptr = (unsigned char *) argv[i] + 1;
88 xk_par_int(&ptr, &len, NULL);
90 errmsg = strdup(GETMESSAGE(10,1,
91 "An invalid length parameter was specified: %s"));
92 printerrf(argv[0], errmsg,
93 argv[i], NULL, NULL, NULL, NULL, NULL,
99 else if (argv[i][1] == 'l')
101 else if (argv[i][1] == 'p')
111 ptr = (unsigned char *) getaddr(argv[i++]);
113 if ( ((i < argc) && argv[i]) || printit) {
116 char buf[10 * BUFSIZ];
120 totlen = len + 1 + 1;
122 totlen = len + strlen(argv[i]) + 1 + 1;
123 dbuf = (char *) (totlen < (10 * BUFSIZ - 1)) ? buf : malloc(totlen);
127 sprintf(dbuf, "%s=0x", argv[i]);
128 p = dbuf + strlen(dbuf);
129 incr = longwise ? sizeof(long) : sizeof(char);
130 for (i=0; i < len; i += incr, p += 2 * incr)
131 sprintf(p, "%*.*x", incr * 2, incr * 2, longwise ? *((unsigned long *) (ptr + i)) : (unsigned long) (ptr[i]));
140 if (len > sizeof(unsigned long)) {
143 sprintf(tmpBuf, "%ld", (long)sizeof(unsigned long));
144 errmsg = strdup(GETMESSAGE(10,2,
145 "To set RET, the length must be less than: %s"));
146 printerrf(argv[0], errmsg,
147 tmpBuf, NULL, NULL, NULL, NULL, NULL, NULL,
152 sprintf(xk_ret_buffer, use, *((unsigned long *) ptr));
153 xk_ret_buf = xk_ret_buffer;
157 errmsg = strdup(GetSharedMsg(DT_UNDEF_SYMBOL));
158 printerrf(argv[0], errmsg, argv[--i], NULL, NULL, NULL,
159 NULL, NULL, NULL, NULL);