1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
|
Rebased from an maintained fork of motif :
https://github.com/dimmus/motif/blob/master/src/examples/lib/Xmd/RegEdit.c
https://github.com/kraxel/fbida/pull/6.patch
--- a/RegEdit.c
+++ b/RegEdit.c
@@ -34,19 +34,19 @@
/* static forward. move from global in the original Editres code */
-static void _XEditResCheckMessages();
-static void _XEditResPutString8();
-static void _XEditResPut8();
-static void _XEditResPut16();
-static void _XEditResPut32();
-static void _XEditResPutWidgetInfo();
-static void _XEditResResetStream();
-static Boolean _XEditResGet8();
-static Boolean _XEditResGet16();
-static Boolean _XEditResGetSigned16();
-static Boolean _XEditResGet32();
-static Boolean _XEditResGetString8();
-static Boolean _XEditResGetWidgetInfo();
+static void _XEditResCheckMessages(Widget w, XtPointer data, XEvent *event, Boolean *cont);
+static void _XEditResPutString8(ProtocolStream *stream, char *str);
+static void _XEditResPut8(ProtocolStream *stream, unsigned int value);
+static void _XEditResPut16(ProtocolStream *stream, unsigned int value);
+static void _XEditResPut32(ProtocolStream *stream, unsigned long value);
+static void _XEditResPutWidgetInfo(ProtocolStream *stream, WidgetInfo *info);
+static void _XEditResResetStream(ProtocolStream *stream);
+static Boolean _XEditResGet8(ProtocolStream *stream, unsigned char *val);
+static Boolean _XEditResGet16(ProtocolStream *stream, unsigned short *val);
+static Boolean _XEditResGetSigned16(ProtocolStream *stream, short *val);
+static Boolean _XEditResGet32(ProtocolStream *stream, unsigned long *val);
+static Boolean _XEditResGetString8(ProtocolStream *stream, char **str);
+static Boolean _XEditResGetWidgetInfo(ProtocolStream *stream, WidgetInfo *info);
/* the only entry point here */
void
@@ -140,16 +140,24 @@ static Atom res_editor_command, res_editor_protocol, client_value;
static Globals globals;
-static void SendFailure(), SendCommand(), InsertWidget(), ExecuteCommand();
-static void FreeEvent(), ExecuteSetValues(), ExecuteGetGeometry();
-static void ExecuteGetResources();
-
-static void GetCommand();
-static void LoadResources();
-static Boolean IsChild();
-static void DumpChildren();
-static char *DumpWidgets(), *DoSetValues(), *DoFindChild();
-static char *DoGetGeometry(), *DoGetResources();
+static void SendFailure(Widget w, Atom sel, ResIdent ident, char *message);
+static void SendCommand(Widget w, Atom sel, ResIdent ident, EditresCommand command, ProtocolStream *stream);
+static void InsertWidget(ProtocolStream *stream, Widget w);
+static void ExecuteCommand(Widget w, Atom sel, ResIdent ident, EditresEvent *event);
+static void FreeEvent(EditresEvent *event);
+static void ExecuteSetValues(Widget w, SetValuesEvent *sv_event, WidgetInfo *entry, ProtocolStream *stream, unsigned short *count);
+static void ExecuteGetGeometry(Widget w, ProtocolStream *stream);
+static void ExecuteGetResources(Widget w, ProtocolStream *stream);
+
+static void GetCommand(Widget w, XtPointer data, Atom *selection, Atom *type, XtPointer value, unsigned long *length, int *format);
+static void LoadResources(Widget w);
+static Boolean IsChild(Widget top, Widget parent, Widget child);
+static void DumpChildren(Widget w, ProtocolStream *stream, unsigned short *count);
+static char *DumpWidgets(Widget w, EditresEvent *event, ProtocolStream *stream);
+static char *DoSetValues(Widget w, EditresEvent *event, ProtocolStream *stream);
+static char *DoFindChild(Widget w, EditresEvent *event, ProtocolStream *stream);
+static char *DoGetGeometry(Widget w, EditresEvent *event, ProtocolStream *stream);
+static char *DoGetResources(Widget w, EditresEvent *event, ProtocolStream *stream);
/************************************************************
*
@@ -170,11 +178,7 @@ static char *DoGetGeometry(), *DoGetResources();
/* ARGSUSED */
static void
-_XEditResCheckMessages(w, data, event, cont)
-Widget w;
-XtPointer data;
-XEvent *event;
-Boolean *cont;
+_XEditResCheckMessages(Widget w, XtPointer data, XEvent *event, Boolean *cont)
{
Time time;
ResIdent ident;
@@ -208,7 +212,7 @@ Boolean *cont;
if (c_event->data.l[3] != CURRENT_PROTOCOL_VERSION) {
_XEditResResetStream(&globals.stream);
_XEditResPut8(&globals.stream, CURRENT_PROTOCOL_VERSION);
- SendCommand(w, res_comm, ident, ProtocolMismatch, &globals.stream);
+ SendCommand(w, res_comm, ident, (EditresCommand)ProtocolMismatch, &globals.stream);
return;
}
@@ -231,12 +235,7 @@ Boolean *cont;
#define ERROR_MESSAGE ("Client: Improperly formatted protocol request")
static EditresEvent *
-BuildEvent(w, sel, data, ident, length)
-Widget w;
-Atom sel;
-XtPointer data;
-ResIdent ident;
-unsigned long length;
+BuildEvent(Widget w, Atom sel, XtPointer data, ResIdent ident, unsigned long length)
{
EditresEvent * event;
ProtocolStream alloc_stream, *stream;
@@ -253,7 +252,7 @@ unsigned long length;
*/
if (length < HEADER_SIZE) {
- SendFailure(w, sel, ident, Failure, ERROR_MESSAGE);
+ SendFailure(w, sel, ident, ERROR_MESSAGE);
return(NULL);
}
@@ -375,8 +374,7 @@ unsigned long length;
*/
static void
-FreeEvent(event)
-EditresEvent * event;
+FreeEvent(EditresEvent *event)
{
if (event->any_event.widgets != NULL) {
XtFree((char *)event->any_event.widgets->ids);
@@ -401,12 +399,7 @@ EditresEvent * event;
/* ARGSUSED */
static void
-GetCommand(w, data, selection, type, value, length, format)
-Widget w;
-XtPointer data, value;
-Atom *selection, *type;
-unsigned long *length;
-int * format;
+GetCommand(Widget w, XtPointer data, Atom *selection, Atom *type, XtPointer value, unsigned long *length, int *format)
{
ResIdent ident = (ResIdent) (long) data;
EditresEvent * event;
@@ -433,13 +426,9 @@ int * format;
/* ARGSUSED */
static void
-ExecuteCommand(w, sel, ident, event)
-Widget w;
-Atom sel;
-ResIdent ident;
-EditresEvent * event;
+ExecuteCommand(Widget w, Atom sel, ResIdent ident, EditresEvent *event)
{
- char * (*func)();
+ char * (*func)(Widget w, EditresEvent *event, ProtocolStream *stream);
char * str;
if (globals.block == BlockAll) {
@@ -481,7 +470,7 @@ EditresEvent * event;
_XEditResResetStream(&globals.stream);
if ((str = (*func)(w, event, &globals.stream)) == NULL)
- SendCommand(w, sel, ident, PartialSuccess, &globals.stream);
+ SendCommand(w, sel, ident, (EditresCommand)PartialSuccess, &globals.stream);
else {
SendFailure(w, sel, ident, str);
XtFree(str);
@@ -502,13 +491,8 @@ EditresEvent * event;
/* ARGSUSED */
static Boolean
-ConvertReturnCommand(w, selection, target,
- type_ret, value_ret, length_ret, format_ret)
-Widget w;
-Atom * selection, * target, * type_ret;
-XtPointer *value_ret;
-unsigned long * length_ret;
-int * format_ret;
+ConvertReturnCommand(Widget w, Atom *selection, Atom *target,
+ Atom *type_ret, XtPointer *value_ret, unsigned long *length_ret, int *format_ret)
{
/*
* I assume the intrinsics give me the correct selection back.
@@ -533,10 +517,7 @@ int * format_ret;
/* ARGSUSED */
static void
-CommandDone(widget, selection, target)
-Widget widget;
-Atom *selection;
-Atom *target;
+CommandDone(Widget widget, Atom *selection, Atom *target)
{
/* Keep the toolkit from automaticaly freeing the selection value */
}
@@ -551,15 +532,11 @@ Atom *target;
*/
static void
-SendFailure(w, sel, ident, str)
-Widget w;
-Atom sel;
-ResIdent ident;
-char * str;
+SendFailure(Widget w, Atom sel, ResIdent ident, char *str)
{
_XEditResResetStream(&globals.stream);
_XEditResPutString8(&globals.stream, str);
- SendCommand(w, sel, ident, Failure, &globals.stream);
+ SendCommand(w, sel, ident, (EditresCommand)Failure, &globals.stream);
}
/* Function Name: BuildReturnPacket
@@ -571,10 +548,7 @@ char * str;
*/
static XtPointer
-BuildReturnPacket(ident, command, stream)
-ResIdent ident;
-EditresCommand command;
-ProtocolStream * stream;
+BuildReturnPacket(ResIdent ident, EditresCommand command, ProtocolStream *stream)
{
long old_alloc, old_size;
unsigned char * old_current;
@@ -619,12 +593,7 @@ ProtocolStream * stream;
*/
static void
-SendCommand(w, sel, ident, command, stream)
-Widget w;
-Atom sel;
-ResIdent ident;
-EditresCommand command;
-ProtocolStream * stream;
+SendCommand(Widget w, Atom sel, ResIdent ident, EditresCommand command, ProtocolStream *stream)
{
BuildReturnPacket(ident, command, stream);
globals.command_stream = stream;
@@ -656,9 +625,7 @@ ProtocolStream * stream;
*/
static int
-FindChildren(parent, children, normal, popup)
-Widget parent, **children;
-Boolean normal, popup;
+FindChildren(Widget parent, Widget **children, Boolean normal, Boolean popup)
{
CompositeWidget cw = (CompositeWidget) parent;
int i, num_children, current = 0;
@@ -698,8 +665,7 @@ Boolean normal, popup;
*/
static Boolean
-IsChild(top, parent, child)
-Widget top, parent, child;
+IsChild(Widget top, Widget parent, Widget child)
{
int i, num_children;
Widget * children;
@@ -728,9 +694,7 @@ Widget top, parent, child;
*/
static char *
-VerifyWidget(w, info)
-Widget w;
-WidgetInfo *info;
+VerifyWidget(Widget w, WidgetInfo *info)
{
Widget top;
@@ -774,10 +738,7 @@ WidgetInfo *info;
*/
static char *
-DoSetValues(w, event, stream)
-Widget w;
-EditresEvent * event;
-ProtocolStream * stream;
+DoSetValues(Widget w, EditresEvent *event, ProtocolStream *stream)
{
char * str;
register unsigned i;
@@ -819,9 +780,7 @@ ProtocolStream * stream;
/* ARGSUSED */
static void
-HandleToolkitErrors(name, type, class, msg, params, num_params)
-String name, type, class, msg, *params;
-Cardinal * num_params;
+HandleToolkitErrors(String name, String type, String class, String msg, String *params, Cardinal *num_params)
{
SVErrorInfo * info = &globals.error_info;
char buf[BUFSIZ];
@@ -863,12 +822,7 @@ Cardinal * num_params;
*/
static void
-ExecuteSetValues(w, sv_event, entry, stream, count)
-Widget w;
-SetValuesEvent * sv_event;
-WidgetInfo * entry;
-ProtocolStream * stream;
-unsigned short * count;
+ExecuteSetValues(Widget w, SetValuesEvent *sv_event, WidgetInfo *entry, ProtocolStream *stream, unsigned short *count)
{
XtErrorMsgHandler old;
@@ -907,10 +861,7 @@ unsigned short * count;
/* ARGSUSED */
static char *
-DumpWidgets(w, event, stream)
-Widget w;
-EditresEvent * event; /* UNUSED */
-ProtocolStream * stream;
+DumpWidgets(Widget w, EditresEvent *event, ProtocolStream *stream)
{
unsigned short count = 0;
@@ -950,8 +901,7 @@ ProtocolStream * stream;
* go that far. Then, we test whether it is an applicationShellWidget
* class by looking for an explicit class name. Seems pretty safe.
*/
-static Bool isApplicationShell(w)
- Widget w;
+static Bool isApplicationShell(Widget w)
{
register WidgetClass c;
@@ -965,10 +915,7 @@ static Bool isApplicationShell(w)
}
static void
-DumpChildren(w, stream, count)
-Widget w;
-ProtocolStream * stream;
-unsigned short *count;
+DumpChildren(Widget w, ProtocolStream *stream, unsigned short *count)
{
int i, num_children;
Widget *children;
@@ -1024,10 +971,7 @@ unsigned short *count;
*/
static char *
-DoGetGeometry(w, event, stream)
-Widget w;
-EditresEvent * event;
-ProtocolStream * stream;
+DoGetGeometry(Widget w, EditresEvent *event, ProtocolStream *stream)
{
unsigned i;
char * str;
@@ -1061,9 +1005,7 @@ ProtocolStream * stream;
*/
static void
-ExecuteGetGeometry(w, stream)
-Widget w;
-ProtocolStream * stream;
+ExecuteGetGeometry(Widget w, ProtocolStream *stream)
{
int i;
Boolean mapped_when_man;
@@ -1137,9 +1079,7 @@ ProtocolStream * stream;
*/
static Boolean
-PositionInChild(child, x, y)
-Widget child;
-int x, y;
+PositionInChild(Widget child, int x, int y)
{
Arg args[6];
Cardinal num;
@@ -1192,9 +1132,7 @@ int x, y;
*/
static Widget
-_FindChild(parent, x, y)
-Widget parent;
-int x, y;
+_FindChild(Widget parent, int x, int y)
{
Widget * children;
int i = FindChildren(parent, &children, TRUE, FALSE);
@@ -1224,10 +1162,7 @@ int x, y;
*/
static char *
-DoFindChild(w, event, stream)
-Widget w;
-EditresEvent * event;
-ProtocolStream * stream;
+DoFindChild(Widget w, EditresEvent *event, ProtocolStream *stream)
{
char * str;
Widget parent, child;
@@ -1264,10 +1199,7 @@ ProtocolStream * stream;
*/
static char *
-DoGetResources(w, event, stream)
-Widget w;
-EditresEvent * event;
-ProtocolStream * stream;
+DoGetResources(Widget w, EditresEvent *event, ProtocolStream *stream)
{
unsigned int i;
char * str;
@@ -1302,9 +1234,7 @@ ProtocolStream * stream;
*/
static void
-ExecuteGetResources(w, stream)
-Widget w;
-ProtocolStream * stream;
+ExecuteGetResources(Widget w, ProtocolStream *stream)
{
XtResourceList norm_list, cons_list;
Cardinal num_norm, num_cons;
@@ -1365,9 +1295,7 @@ ProtocolStream * stream;
*/
static void
-InsertWidget(stream, w)
-ProtocolStream * stream;
-Widget w;
+InsertWidget(ProtocolStream *stream, Widget w)
{
Widget temp;
unsigned long * widget_list;
@@ -1408,9 +1336,7 @@ Widget w;
*/
static void
-_XEditResPutString8(stream, str)
-ProtocolStream * stream;
-char * str;
+_XEditResPutString8(ProtocolStream *stream, char *str)
{
int i, len = strlen(str);
@@ -1427,9 +1353,7 @@ char * str;
*/
static void
-_XEditResPut8(stream, value)
-ProtocolStream * stream;
-unsigned int value;
+_XEditResPut8(ProtocolStream *stream, unsigned int value)
{
unsigned char temp;
@@ -1455,9 +1379,7 @@ unsigned int value;
*/
static void
-_XEditResPut16(stream, value)
-ProtocolStream * stream;
-unsigned int value;
+_XEditResPut16(ProtocolStream *stream, unsigned int value)
{
_XEditResPut8(stream, (value >> XER_NBBY) & BYTE_MASK);
_XEditResPut8(stream, value & BYTE_MASK);
@@ -1471,9 +1393,7 @@ unsigned int value;
*/
static void
-_XEditResPut32(stream, value)
-ProtocolStream * stream;
-unsigned long value;
+_XEditResPut32(ProtocolStream *stream, unsigned long value)
{
int i;
@@ -1489,9 +1409,7 @@ unsigned long value;
*/
static void
-_XEditResPutWidgetInfo(stream, info)
-ProtocolStream * stream;
-WidgetInfo * info;
+_XEditResPutWidgetInfo(ProtocolStream *stream, WidgetInfo *info)
{
unsigned int i;
@@ -1513,8 +1431,7 @@ WidgetInfo * info;
*/
static void
-_XEditResResetStream(stream)
-ProtocolStream * stream;
+_XEditResResetStream(ProtocolStream *stream)
{
stream->current = stream->top;
stream->size = 0;
@@ -1545,9 +1462,7 @@ ProtocolStream * stream;
*/
static Boolean
-_XEditResGet8(stream, val)
-ProtocolStream * stream;
-unsigned char * val;
+_XEditResGet8(ProtocolStream *stream, unsigned char *val)
{
if (stream->size < (stream->current - stream->top))
return(FALSE);
@@ -1565,9 +1480,7 @@ unsigned char * val;
*/
static Boolean
-_XEditResGet16(stream, val)
-ProtocolStream * stream;
-unsigned short * val;
+_XEditResGet16(ProtocolStream *stream, unsigned short *val)
{
unsigned char temp1, temp2;
@@ -1586,9 +1499,7 @@ unsigned short * val;
*/
static Boolean
-_XEditResGetSigned16(stream, val)
-ProtocolStream * stream;
-short * val;
+_XEditResGetSigned16(ProtocolStream *stream, short *val)
{
unsigned char temp1, temp2;
@@ -1615,9 +1526,7 @@ short * val;
*/
static Boolean
-_XEditResGet32(stream, val)
-ProtocolStream * stream;
-unsigned long * val;
+_XEditResGet32(ProtocolStream *stream, unsigned long *val)
{
unsigned short temp1, temp2;
@@ -1637,9 +1546,7 @@ unsigned long * val;
*/
static Boolean
-_XEditResGetString8(stream, str)
-ProtocolStream * stream;
-char ** str;
+_XEditResGetString8(ProtocolStream *stream, char **str)
{
unsigned short len;
register unsigned i;
@@ -1670,9 +1577,7 @@ char ** str;
*/
static Boolean
-_XEditResGetWidgetInfo(stream, info)
-ProtocolStream * stream;
-WidgetInfo * info;
+_XEditResGetWidgetInfo(ProtocolStream *stream, WidgetInfo *info)
{
unsigned int i;
@@ -1708,14 +1613,10 @@ WidgetInfo * info;
/* ARGSUSED */
static Boolean
-CvtStringToBlock(dpy, args, num_args, from_val, to_val, converter_data)
-Display * dpy;
-XrmValue * args;
-Cardinal * num_args;
-XrmValue * from_val, * to_val;
-XtPointer * converter_data;
+CvtStringToBlock(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *from_val, XrmValue *to_val, XtPointer *converter_data)
{
char ptr[BUFSIZ];
+ ptr[0]='\0';
static EditresBlock block;
/* XmuCopyISOLatin1Lowered(ptr, from_val->addr);*/
@@ -1763,8 +1664,7 @@ XtPointer * converter_data;
*/
static void
-LoadResources(w)
-Widget w;
+LoadResources(Widget w)
{
static XtResource resources[] = {
{"editresBlock", "EditresBlock", XtREditresBlock, sizeof(EditresBlock),
|