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),
