summaryrefslogtreecommitdiff
path: root/src/Callback.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2019-07-07 19:55:21 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2019-07-07 19:55:21 -0400
commit650398b40bf500698cfe1f040df9e9d217e9c807 (patch)
tree03dddcc0bb377ef76a96ce54400008e2dba9f919 /src/Callback.c
parent1737661309d55aa33e668142cf3301a8e94ff44d (diff)
indent'd like "x-indent.sh", but with a more complete set of typedefs - see
https://github.com/ThomasDickey/cindent-snapshots/blob/master/scripts/xxx-profile Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src/Callback.c')
-rw-r--r--src/Callback.c705
1 files changed, 368 insertions, 337 deletions
diff --git a/src/Callback.c b/src/Callback.c
index 72cbc3d..b1c9d7f 100644
--- a/src/Callback.c
+++ b/src/Callback.c
@@ -82,35 +82,34 @@ static _Xconst _XtString XtNxtCallCallback = "xtCallCallback";
/* However it doesn't contain a final NULL record */
#define ToList(p) ((XtCallbackList) ((p)+1))
-static InternalCallbackList* FetchInternalList(
- Widget widget,
- _Xconst char *name)
+static InternalCallbackList *
+FetchInternalList(Widget widget,
+ _Xconst char *name)
{
XrmQuark quark;
int n;
CallbackTable offsets;
- InternalCallbackList* retval = NULL;
+ InternalCallbackList *retval = NULL;
quark = StringToQuark(name);
LOCK_PROCESS;
offsets = (CallbackTable)
- widget->core.widget_class->core_class.callback_private;
-
- for (n = (int)(long) *(offsets++); --n >= 0; offsets++)
- if (quark == (*offsets)->xrm_name) {
- retval = (InternalCallbackList *)
- ((char *) widget - (*offsets)->xrm_offset - 1);
- break;
- }
+ widget->core.widget_class->core_class.callback_private;
+
+ for (n = (int) (long) *(offsets++); --n >= 0; offsets++)
+ if (quark == (*offsets)->xrm_name) {
+ retval = (InternalCallbackList *)
+ ((char *) widget - (*offsets)->xrm_offset - 1);
+ break;
+ }
UNLOCK_PROCESS;
return retval;
}
-
-void _XtAddCallback(
- InternalCallbackList* callbacks,
- XtCallbackProc callback,
- XtPointer closure)
+void
+_XtAddCallback(InternalCallbackList * callbacks,
+ XtCallbackProc callback,
+ XtPointer closure)
{
register InternalCallbackList icl;
register XtCallbackList cl;
@@ -120,16 +119,19 @@ void _XtAddCallback(
count = icl ? icl->count : 0;
if (icl && icl->call_state) {
- icl->call_state |= _XtCBFreeAfterCalling;
- icl = (InternalCallbackList)
- __XtMalloc((Cardinal) (sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t) (count + 1)));
- (void) memmove((char *)ToList(icl), (char *)ToList(*callbacks),
- sizeof(XtCallbackRec) * (size_t) count);
- } else {
- icl = (InternalCallbackList)
- XtRealloc((char *) icl, (Cardinal)(sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t) (count + 1)));
+ icl->call_state |= _XtCBFreeAfterCalling;
+ icl = (InternalCallbackList)
+ __XtMalloc((Cardinal) (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (size_t) (count +
+ 1)));
+ (void) memmove((char *) ToList(icl), (char *) ToList(*callbacks),
+ sizeof(XtCallbackRec) * (size_t) count);
+ }
+ else {
+ icl = (InternalCallbackList)
+ XtRealloc((char *) icl, (Cardinal) (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) *
+ (size_t) (count + 1)));
}
*callbacks = icl;
icl->count = (unsigned short) (count + 1);
@@ -138,29 +140,28 @@ void _XtAddCallback(
cl = ToList(icl) + count;
cl->callback = callback;
cl->closure = closure;
-} /* _XtAddCallback */
+} /* _XtAddCallback */
-void _XtAddCallbackOnce(
- register InternalCallbackList*callbacks,
- XtCallbackProc callback,
- XtPointer closure)
+void
+_XtAddCallbackOnce(register InternalCallbackList * callbacks,
+ XtCallbackProc callback,
+ XtPointer closure)
{
register XtCallbackList cl = ToList(*callbacks);
register int i;
- for (i=(*callbacks)->count; --i >= 0; cl++)
- if (cl->callback == callback && cl->closure == closure)
- return;
+ for (i = (*callbacks)->count; --i >= 0; cl++)
+ if (cl->callback == callback && cl->closure == closure)
+ return;
_XtAddCallback(callbacks, callback, closure);
-} /* _XtAddCallbackOnce */
-
-void XtAddCallback(
- Widget widget,
- _Xconst char* name,
- XtCallbackProc callback,
- XtPointer closure
- )
+} /* _XtAddCallbackOnce */
+
+void
+XtAddCallback(Widget widget,
+ _Xconst char *name,
+ XtCallbackProc callback,
+ XtPointer closure)
{
InternalCallbackList *callbacks;
XtAppContext app = XtWidgetToApplicationContext(widget);
@@ -168,35 +169,37 @@ void XtAddCallback(
LOCK_APP(app);
callbacks = FetchInternalList(widget, name);
if (!callbacks) {
- XtAppWarningMsg(app,
- XtNinvalidCallbackList,XtNxtAddCallback,XtCXtToolkitError,
- "Cannot find callback list in XtAddCallback",
- NULL, NULL);
- UNLOCK_APP(app);
- return;
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList, XtNxtAddCallback,
+ XtCXtToolkitError,
+ "Cannot find callback list in XtAddCallback", NULL,
+ NULL);
+ UNLOCK_APP(app);
+ return;
}
_XtAddCallback(callbacks, callback, closure);
if (!_XtIsHookObject(widget)) {
Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
- if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
- XtChangeHookDataRec call_data;
- call_data.type = XtHaddCallback;
- call_data.widget = widget;
- call_data.event_data = (XtPointer) name;
- XtCallCallbackList(hookobj,
- ((HookObject)hookobj)->hooks.changehook_callbacks,
- (XtPointer)&call_data);
- }
+ if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHaddCallback;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject) hookobj)->hooks.
+ changehook_callbacks, (XtPointer) & call_data);
+ }
}
UNLOCK_APP(app);
-} /* XtAddCallback */
+} /* XtAddCallback */
/* ARGSUSED */
-static void AddCallbacks(
- Widget widget _X_UNUSED,
- InternalCallbackList *callbacks,
- XtCallbackList newcallbacks)
+static void
+AddCallbacks(Widget widget _X_UNUSED,
+ InternalCallbackList * callbacks,
+ XtCallbackList newcallbacks)
{
register InternalCallbackList icl;
register int i, j;
@@ -204,122 +207,136 @@ static void AddCallbacks(
icl = *callbacks;
i = icl ? icl->count : 0;
- for (j=0, cl = newcallbacks; cl->callback; cl++, j++);
+ for (j = 0, cl = newcallbacks; cl->callback; cl++, j++);
if (icl && icl->call_state) {
- icl->call_state |= _XtCBFreeAfterCalling;
- icl = (InternalCallbackList) __XtMalloc((Cardinal)(sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t) (i+j)));
- (void) memmove((char *)ToList(*callbacks), (char *)ToList(icl),
- sizeof(XtCallbackRec) * (size_t) i);
- } else {
- icl = (InternalCallbackList) XtRealloc((char *) icl,
- (Cardinal)(sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t) (i+j)));
+ icl->call_state |= _XtCBFreeAfterCalling;
+ icl =
+ (InternalCallbackList)
+ __XtMalloc((Cardinal)
+ (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (size_t) (i + j)));
+ (void) memmove((char *) ToList(*callbacks), (char *) ToList(icl),
+ sizeof(XtCallbackRec) * (size_t) i);
+ }
+ else {
+ icl = (InternalCallbackList) XtRealloc((char *) icl,
+ (Cardinal) (sizeof
+ (InternalCallbackRec)
+ +
+ sizeof(XtCallbackRec)
+ * (size_t) (i + j)));
}
*callbacks = icl;
- icl->count = (unsigned short) (i+j);
+ icl->count = (unsigned short) (i + j);
icl->is_padded = 0;
icl->call_state = 0;
- for (cl = ToList(icl) + i; --j >= 0; )
- *cl++ = *newcallbacks++;
-} /* AddCallbacks */
-
-void XtAddCallbacks(
- Widget widget,
- _Xconst char* name,
- XtCallbackList xtcallbacks
- )
+ for (cl = ToList(icl) + i; --j >= 0;)
+ *cl++ = *newcallbacks++;
+} /* AddCallbacks */
+
+void
+XtAddCallbacks(Widget widget,
+ _Xconst char *name,
+ XtCallbackList xtcallbacks)
{
- InternalCallbackList* callbacks;
+ InternalCallbackList *callbacks;
Widget hookobj;
XtAppContext app = XtWidgetToApplicationContext(widget);
LOCK_APP(app);
callbacks = FetchInternalList(widget, name);
if (!callbacks) {
- XtAppWarningMsg(app,
- XtNinvalidCallbackList,XtNxtAddCallback,XtCXtToolkitError,
- "Cannot find callback list in XtAddCallbacks",
- NULL, NULL);
- UNLOCK_APP(app);
- return;
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList, XtNxtAddCallback,
+ XtCXtToolkitError,
+ "Cannot find callback list in XtAddCallbacks", NULL,
+ NULL);
+ UNLOCK_APP(app);
+ return;
}
AddCallbacks(widget, callbacks, xtcallbacks);
hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
- XtChangeHookDataRec call_data;
-
- call_data.type = XtHaddCallbacks;
- call_data.widget = widget;
- call_data.event_data = (XtPointer) name;
- XtCallCallbackList(hookobj,
- ((HookObject)hookobj)->hooks.changehook_callbacks,
- (XtPointer)&call_data);
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHaddCallbacks;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject) hookobj)->hooks.changehook_callbacks,
+ (XtPointer) & call_data);
}
UNLOCK_APP(app);
-} /* XtAddCallbacks */
+} /* XtAddCallbacks */
-void _XtRemoveCallback (
- InternalCallbackList *callbacks,
- XtCallbackProc callback,
- XtPointer closure)
+void
+_XtRemoveCallback(InternalCallbackList * callbacks,
+ XtCallbackProc callback,
+ XtPointer closure)
{
register InternalCallbackList icl;
register int i, j;
register XtCallbackList cl, ncl, ocl;
icl = *callbacks;
- if (!icl) return;
+ if (!icl)
+ return;
cl = ToList(icl);
- for (i=icl->count; --i >= 0; cl++) {
- if (cl->callback == callback && cl->closure == closure) {
- if (icl->call_state) {
- icl->call_state |= _XtCBFreeAfterCalling;
- if (icl->count == 1) {
- *callbacks = NULL;
- } else {
- j = icl->count - i - 1;
- ocl = ToList(icl);
- icl = (InternalCallbackList)
- __XtMalloc((Cardinal) (sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t) (i + j)));
- icl->count = (unsigned short) (i + j);
- icl->is_padded = 0;
- icl->call_state = 0;
- ncl = ToList(icl);
- while (--j >= 0)
- *ncl++ = *ocl++;
- while (--i >= 0)
- *ncl++ = *++cl;
- *callbacks = icl;
- }
- } else {
- if (--icl->count) {
- ncl = cl + 1;
- while (--i >= 0)
- *cl++ = *ncl++;
- icl = (InternalCallbackList)
- XtRealloc((char *) icl, (Cardinal) (sizeof(InternalCallbackRec)
- + sizeof(XtCallbackRec) * icl->count));
- icl->is_padded = 0;
- *callbacks = icl;
- } else {
- XtFree((char *) icl);
- *callbacks = NULL;
- }
- }
- return;
- }
- }
-} /* _XtRemoveCallback */
-
-void XtRemoveCallback (
- Widget widget,
- _Xconst char* name,
- XtCallbackProc callback,
- XtPointer closure
- )
+ for (i = icl->count; --i >= 0; cl++) {
+ if (cl->callback == callback && cl->closure == closure) {
+ if (icl->call_state) {
+ icl->call_state |= _XtCBFreeAfterCalling;
+ if (icl->count == 1) {
+ *callbacks = NULL;
+ }
+ else {
+ j = icl->count - i - 1;
+ ocl = ToList(icl);
+ icl = (InternalCallbackList)
+ __XtMalloc((Cardinal) (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) *
+ (size_t) (i + j)));
+ icl->count = (unsigned short) (i + j);
+ icl->is_padded = 0;
+ icl->call_state = 0;
+ ncl = ToList(icl);
+ while (--j >= 0)
+ *ncl++ = *ocl++;
+ while (--i >= 0)
+ *ncl++ = *++cl;
+ *callbacks = icl;
+ }
+ }
+ else {
+ if (--icl->count) {
+ ncl = cl + 1;
+ while (--i >= 0)
+ *cl++ = *ncl++;
+ icl = (InternalCallbackList)
+ XtRealloc((char *) icl,
+ (Cardinal) (sizeof(InternalCallbackRec)
+ +
+ sizeof(XtCallbackRec) *
+ icl->count));
+ icl->is_padded = 0;
+ *callbacks = icl;
+ }
+ else {
+ XtFree((char *) icl);
+ *callbacks = NULL;
+ }
+ }
+ return;
+ }
+ }
+} /* _XtRemoveCallback */
+
+void
+XtRemoveCallback(Widget widget,
+ _Xconst char *name,
+ XtCallbackProc callback,
+ XtPointer closure)
{
InternalCallbackList *callbacks;
Widget hookobj;
@@ -328,33 +345,33 @@ void XtRemoveCallback (
LOCK_APP(app);
callbacks = FetchInternalList(widget, name);
if (!callbacks) {
- XtAppWarningMsg(app,
- XtNinvalidCallbackList,XtNxtRemoveCallback,XtCXtToolkitError,
- "Cannot find callback list in XtRemoveCallback",
- NULL, NULL);
- UNLOCK_APP(app);
- return;
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList, XtNxtRemoveCallback,
+ XtCXtToolkitError,
+ "Cannot find callback list in XtRemoveCallback", NULL,
+ NULL);
+ UNLOCK_APP(app);
+ return;
}
_XtRemoveCallback(callbacks, callback, closure);
hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
- XtChangeHookDataRec call_data;
-
- call_data.type = XtHremoveCallback;
- call_data.widget = widget;
- call_data.event_data = (XtPointer) name;
- XtCallCallbackList(hookobj,
- ((HookObject)hookobj)->hooks.changehook_callbacks,
- (XtPointer)&call_data);
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHremoveCallback;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject) hookobj)->hooks.changehook_callbacks,
+ (XtPointer) & call_data);
}
UNLOCK_APP(app);
-} /* XtRemoveCallback */
-
+} /* XtRemoveCallback */
-void XtRemoveCallbacks (
- Widget widget,
- _Xconst char* name,
- XtCallbackList xtcallbacks)
+void
+XtRemoveCallbacks(Widget widget,
+ _Xconst char *name,
+ XtCallbackList xtcallbacks)
{
InternalCallbackList *callbacks;
Widget hookobj;
@@ -366,83 +383,87 @@ void XtRemoveCallbacks (
LOCK_APP(app);
callbacks = FetchInternalList(widget, name);
if (!callbacks) {
- XtAppWarningMsg(app,
- XtNinvalidCallbackList,XtNxtRemoveCallback,XtCXtToolkitError,
- "Cannot find callback list in XtRemoveCallbacks",
- NULL, NULL);
- UNLOCK_APP(app);
- return;
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList, XtNxtRemoveCallback,
+ XtCXtToolkitError,
+ "Cannot find callback list in XtRemoveCallbacks", NULL,
+ NULL);
+ UNLOCK_APP(app);
+ return;
}
icl = *callbacks;
if (!icl) {
- UNLOCK_APP(app);
- return;
+ UNLOCK_APP(app);
+ return;
}
i = icl->count;
cl = ToList(icl);
if (icl->call_state) {
- icl->call_state |= _XtCBFreeAfterCalling;
- icl = (InternalCallbackList)__XtMalloc((Cardinal)(sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t) i));
- icl->count = (unsigned short) i;
- icl->call_state = 0;
+ icl->call_state |= _XtCBFreeAfterCalling;
+ icl =
+ (InternalCallbackList)
+ __XtMalloc((Cardinal)
+ (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (size_t) i));
+ icl->count = (unsigned short) i;
+ icl->call_state = 0;
}
ccl = ToList(icl);
while (--i >= 0) {
- *ccl++ = *cl;
- for (rcl=xtcallbacks; rcl->callback; rcl++) {
- if (cl->callback == rcl->callback && cl->closure == rcl->closure) {
- ccl--;
- icl->count--;
- break;
- }
- }
- cl++;
+ *ccl++ = *cl;
+ for (rcl = xtcallbacks; rcl->callback; rcl++) {
+ if (cl->callback == rcl->callback && cl->closure == rcl->closure) {
+ ccl--;
+ icl->count--;
+ break;
+ }
+ }
+ cl++;
}
if (icl->count) {
- icl = (InternalCallbackList)
- XtRealloc((char *)icl, (Cardinal) (sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * icl->count));
- icl->is_padded = 0;
- *callbacks = icl;
- } else {
- XtFree((char *)icl);
- *callbacks = NULL;
+ icl = (InternalCallbackList)
+ XtRealloc((char *) icl, (Cardinal) (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) *
+ icl->count));
+ icl->is_padded = 0;
+ *callbacks = icl;
+ }
+ else {
+ XtFree((char *) icl);
+ *callbacks = NULL;
}
hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
- XtChangeHookDataRec call_data;
-
- call_data.type = XtHremoveCallbacks;
- call_data.widget = widget;
- call_data.event_data = (XtPointer) name;
- XtCallCallbackList(hookobj,
- ((HookObject)hookobj)->hooks.changehook_callbacks,
- (XtPointer)&call_data);
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHremoveCallbacks;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject) hookobj)->hooks.changehook_callbacks,
+ (XtPointer) & call_data);
}
UNLOCK_APP(app);
-} /* XtRemoveCallbacks */
-
+} /* XtRemoveCallbacks */
-void _XtRemoveAllCallbacks (
- InternalCallbackList *callbacks)
+void
+_XtRemoveAllCallbacks(InternalCallbackList * callbacks)
{
register InternalCallbackList icl = *callbacks;
if (icl) {
- if (icl->call_state)
- icl->call_state |= _XtCBFreeAfterCalling;
- else
- XtFree((char *) icl);
- *callbacks = NULL;
+ if (icl->call_state)
+ icl->call_state |= _XtCBFreeAfterCalling;
+ else
+ XtFree((char *) icl);
+ *callbacks = NULL;
}
-} /* _XtRemoveAllCallbacks */
+} /* _XtRemoveAllCallbacks */
-void XtRemoveAllCallbacks(
- Widget widget,
- _Xconst char* name)
+void
+XtRemoveAllCallbacks(Widget widget, _Xconst char *name)
{
InternalCallbackList *callbacks;
Widget hookobj;
@@ -451,52 +472,57 @@ void XtRemoveAllCallbacks(
LOCK_APP(app);
callbacks = FetchInternalList(widget, name);
if (!callbacks) {
- XtAppWarningMsg(app,
- XtNinvalidCallbackList,XtNxtRemoveAllCallback,XtCXtToolkitError,
- "Cannot find callback list in XtRemoveAllCallbacks",
- NULL, NULL);
- UNLOCK_APP(app);
- return;
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList, XtNxtRemoveAllCallback,
+ XtCXtToolkitError,
+ "Cannot find callback list in XtRemoveAllCallbacks",
+ NULL, NULL);
+ UNLOCK_APP(app);
+ return;
}
_XtRemoveAllCallbacks(callbacks);
hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
- XtChangeHookDataRec call_data;
-
- call_data.type = XtHremoveAllCallbacks;
- call_data.widget = widget;
- call_data.event_data = (XtPointer) name;
- XtCallCallbackList(hookobj,
- ((HookObject)hookobj)->hooks.changehook_callbacks,
- (XtPointer)&call_data);
+ XtChangeHookDataRec call_data;
+
+ call_data.type = XtHremoveAllCallbacks;
+ call_data.widget = widget;
+ call_data.event_data = (XtPointer) name;
+ XtCallCallbackList(hookobj,
+ ((HookObject) hookobj)->hooks.changehook_callbacks,
+ (XtPointer) & call_data);
}
UNLOCK_APP(app);
-} /* XtRemoveAllCallbacks */
+} /* XtRemoveAllCallbacks */
-InternalCallbackList _XtCompileCallbackList(
- XtCallbackList xtcallbacks)
+InternalCallbackList
+_XtCompileCallbackList(XtCallbackList xtcallbacks)
{
register int n;
register XtCallbackList xtcl, cl;
register InternalCallbackList callbacks;
- for (n=0, xtcl=xtcallbacks; xtcl->callback; n++, xtcl++) {};
- if (n == 0) return (InternalCallbackList) NULL;
+ for (n = 0, xtcl = xtcallbacks; xtcl->callback; n++, xtcl++) {
+ };
+ if (n == 0)
+ return (InternalCallbackList) NULL;
- callbacks = (InternalCallbackList) __XtMalloc((Cardinal) (sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t) n));
+ callbacks =
+ (InternalCallbackList)
+ __XtMalloc((Cardinal)
+ (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (size_t) n));
callbacks->count = (unsigned short) n;
callbacks->is_padded = 0;
callbacks->call_state = 0;
cl = ToList(callbacks);
while (--n >= 0)
- *cl++ = *xtcallbacks++;
- return(callbacks);
-} /* _XtCompileCallbackList */
-
+ *cl++ = *xtcallbacks++;
+ return (callbacks);
+} /* _XtCompileCallbackList */
-XtCallbackList _XtGetCallbackList(
- InternalCallbackList *callbacks)
+XtCallbackList
+_XtGetCallbackList(InternalCallbackList * callbacks)
{
int i;
InternalCallbackList icl;
@@ -504,28 +530,33 @@ XtCallbackList _XtGetCallbackList(
icl = *callbacks;
if (!icl) {
- static XtCallbackRec emptyList[1] = { {NULL, NULL} };
- return (XtCallbackList)emptyList;
+ static XtCallbackRec emptyList[1] = { {NULL, NULL} };
+ return (XtCallbackList) emptyList;
}
if (icl->is_padded)
- return ToList(icl);
+ return ToList(icl);
i = icl->count;
if (icl->call_state) {
XtCallbackList ocl;
- icl->call_state |= _XtCBFreeAfterCalling;
- ocl = ToList(icl);
- icl = (InternalCallbackList) __XtMalloc((Cardinal)(sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t) (i+1)));
- icl->count = (unsigned short) i;
- icl->call_state = 0;
- cl = ToList(icl);
- while (--i >= 0)
- *cl++ = *ocl++;
- } else {
- icl = (InternalCallbackList) XtRealloc((char *)icl,
- (Cardinal)(sizeof(InternalCallbackRec) +
- sizeof(XtCallbackRec) * (size_t)(i+1)));
- cl = ToList(icl) + i;
+
+ icl->call_state |= _XtCBFreeAfterCalling;
+ ocl = ToList(icl);
+ icl = (InternalCallbackList)
+ __XtMalloc((Cardinal)
+ (sizeof(InternalCallbackRec) +
+ sizeof(XtCallbackRec) * (size_t) (i + 1)));
+ icl->count = (unsigned short) i;
+ icl->call_state = 0;
+ cl = ToList(icl);
+ while (--i >= 0)
+ *cl++ = *ocl++;
+ }
+ else {
+ icl = (InternalCallbackList)
+ XtRealloc((char *) icl, (Cardinal) (sizeof(InternalCallbackRec)
+ + sizeof(XtCallbackRec)
+ * (size_t) (i + 1)));
+ cl = ToList(icl) + i;
}
icl->is_padded = 1;
cl->callback = (XtCallbackProc) NULL;
@@ -534,11 +565,10 @@ XtCallbackList _XtGetCallbackList(
return ToList(icl);
}
-void XtCallCallbacks(
- Widget widget,
- _Xconst char* name,
- XtPointer call_data
- )
+void
+XtCallCallbacks(Widget widget,
+ _Xconst char *name,
+ XtPointer call_data)
{
InternalCallbackList *callbacks;
InternalCallbackList icl;
@@ -550,107 +580,107 @@ void XtCallCallbacks(
LOCK_APP(app);
callbacks = FetchInternalList(widget, name);
if (!callbacks) {
- XtAppWarningMsg(app,
- XtNinvalidCallbackList,XtNxtCallCallback,XtCXtToolkitError,
- "Cannot find callback list in XtCallCallbacks",
- NULL, NULL);
- UNLOCK_APP(app);
- return;
+ XtAppWarningMsg(app,
+ XtNinvalidCallbackList, XtNxtCallCallback,
+ XtCXtToolkitError,
+ "Cannot find callback list in XtCallCallbacks", NULL,
+ NULL);
+ UNLOCK_APP(app);
+ return;
}
icl = *callbacks;
if (!icl) {
- UNLOCK_APP(app);
- return;
+ UNLOCK_APP(app);
+ return;
}
cl = ToList(icl);
if (icl->count == 1) {
- (*cl->callback) (widget, cl->closure, call_data);
- UNLOCK_APP(app);
- return;
+ (*cl->callback) (widget, cl->closure, call_data);
+ UNLOCK_APP(app);
+ return;
}
ostate = icl->call_state;
icl->call_state = _XtCBCalling;
for (i = icl->count; --i >= 0; cl++)
- (*cl->callback) (widget, cl->closure, call_data);
+ (*cl->callback) (widget, cl->closure, call_data);
if (ostate)
- icl->call_state |= ostate;
+ icl->call_state |= ostate;
else if (icl->call_state & _XtCBFreeAfterCalling)
- XtFree((char *)icl);
+ XtFree((char *) icl);
else
- icl->call_state = ostate;
+ icl->call_state = ostate;
UNLOCK_APP(app);
-} /* XtCallCallbacks */
-
+} /* XtCallCallbacks */
-XtCallbackStatus XtHasCallbacks(
- Widget widget,
- _Xconst char* callback_name
- )
+XtCallbackStatus
+XtHasCallbacks(Widget widget,
+ _Xconst char *callback_name)
{
InternalCallbackList *callbacks;
XtCallbackStatus retval = XtCallbackHasSome;
+
WIDGET_TO_APPCON(widget);
LOCK_APP(app);
callbacks = FetchInternalList(widget, callback_name);
if (!callbacks)
- retval = XtCallbackNoList;
+ retval = XtCallbackNoList;
else if (!*callbacks)
- retval = XtCallbackHasNone;
+ retval = XtCallbackHasNone;
UNLOCK_APP(app);
return retval;
-} /* XtHasCallbacks */
+} /* XtHasCallbacks */
-
-void XtCallCallbackList(
- Widget widget,
- XtCallbackList callbacks,
- XtPointer call_data)
+void
+XtCallCallbackList(Widget widget,
+ XtCallbackList callbacks,
+ XtPointer call_data)
{
register InternalCallbackList icl;
register XtCallbackList cl;
register int i;
char ostate;
+
WIDGET_TO_APPCON(widget);
LOCK_APP(app);
if (!callbacks) {
- UNLOCK_APP(app);
- return;
+ UNLOCK_APP(app);
+ return;
}
- icl = (InternalCallbackList)callbacks;
+ icl = (InternalCallbackList) callbacks;
cl = ToList(icl);
if (icl->count == 1) {
- (*cl->callback) (widget, cl->closure, call_data);
- UNLOCK_APP(app);
- return;
+ (*cl->callback) (widget, cl->closure, call_data);
+ UNLOCK_APP(app);
+ return;
}
ostate = icl->call_state;
icl->call_state = _XtCBCalling;
for (i = icl->count; --i >= 0; cl++)
- (*cl->callback) (widget, cl->closure, call_data);
+ (*cl->callback) (widget, cl->closure, call_data);
if (ostate)
- icl->call_state |= ostate;
+ icl->call_state |= ostate;
else if (icl->call_state & _XtCBFreeAfterCalling)
- XtFree((char *)icl);
+ XtFree((char *) icl);
else
- icl->call_state = 0;
+ icl->call_state = 0;
UNLOCK_APP(app);
-} /* XtCallCallbackList */
+} /* XtCallCallbackList */
-void _XtPeekCallback(
- Widget widget _X_UNUSED,
- XtCallbackList callbacks,
- XtCallbackProc *callback,
- XtPointer *closure)
+void
+_XtPeekCallback(Widget widget _X_UNUSED,
+ XtCallbackList callbacks,
+ XtCallbackProc * callback,
+ XtPointer * closure)
{
register InternalCallbackList icl = (InternalCallbackList) callbacks;
register XtCallbackList cl;
if (!callbacks) {
- *callback = (XtCallbackProc) NULL;
- return;
+ *callback = (XtCallbackProc) NULL;
+ return;
}
cl = ToList(icl);
*callback = cl->callback;
@@ -658,43 +688,44 @@ void _XtPeekCallback(
return;
}
-void _XtCallConditionalCallbackList(
- Widget widget,
- XtCallbackList callbacks,
- XtPointer call_data,
- _XtConditionProc cond_proc)
+void
+_XtCallConditionalCallbackList(Widget widget,
+ XtCallbackList callbacks,
+ XtPointer call_data,
+ _XtConditionProc cond_proc)
{
register InternalCallbackList icl;
register XtCallbackList cl;
register int i;
char ostate;
+
WIDGET_TO_APPCON(widget);
LOCK_APP(app);
if (!callbacks) {
- UNLOCK_APP(app);
- return;
+ UNLOCK_APP(app);
+ return;
}
- icl = (InternalCallbackList)callbacks;
+ icl = (InternalCallbackList) callbacks;
cl = ToList(icl);
if (icl->count == 1) {
- (*cl->callback) (widget, cl->closure, call_data);
- (void) (*cond_proc)(call_data);
- UNLOCK_APP(app);
- return;
+ (*cl->callback) (widget, cl->closure, call_data);
+ (void) (*cond_proc) (call_data);
+ UNLOCK_APP(app);
+ return;
}
ostate = icl->call_state;
icl->call_state = _XtCBCalling;
for (i = icl->count; --i >= 0; cl++) {
- (*cl->callback) (widget, cl->closure, call_data);
- if (! (*cond_proc)(call_data))
- break;
+ (*cl->callback) (widget, cl->closure, call_data);
+ if (!(*cond_proc) (call_data))
+ break;
}
if (ostate)
- icl->call_state |= ostate;
+ icl->call_state |= ostate;
else if (icl->call_state & _XtCBFreeAfterCalling)
- XtFree((char *)icl);
+ XtFree((char *) icl);
else
- icl->call_state = 0;
+ icl->call_state = 0;
UNLOCK_APP(app);
}