| 1 | /* $Cambridge: exim/src/exim_monitor/em_xs.c,v 1.2 2005/01/04 10:00:42 ph10 Exp $ */ |
| 2 | |
| 3 | /************************************************* |
| 4 | * Exim Monitor * |
| 5 | *************************************************/ |
| 6 | |
| 7 | /* Copyright (c) University of Cambridge, 1995 - 2005 */ |
| 8 | /* See the file NOTICE for conditions of use and distribution. */ |
| 9 | |
| 10 | /* This file contains a number of subroutines that are in effect |
| 11 | just alternative packaging for calls to various X functions that |
| 12 | happen to be convenient for this program. */ |
| 13 | |
| 14 | #include "em_hdr.h" |
| 15 | |
| 16 | |
| 17 | |
| 18 | /************************************************* |
| 19 | * xs_SetValues * |
| 20 | *************************************************/ |
| 21 | |
| 22 | /* Unpick a variable-length argument list and set up an |
| 23 | appropriate call to XtSetValues. To make it reasonably |
| 24 | efficient, we keep a working Arg structure of length 15; |
| 25 | the largest call in eximon sets 11 values. The code uses |
| 26 | malloc/free if more, just in case there is ever a longer |
| 27 | one that gets overlooked. */ |
| 28 | |
| 29 | static Arg xs_temparg[15]; |
| 30 | |
| 31 | void xs_SetValues(Widget w, Cardinal num_args, ...) |
| 32 | { |
| 33 | int i; |
| 34 | va_list ap; |
| 35 | Arg *aa = (num_args > 15)? (Arg *)malloc(num_args*sizeof(Arg)) : xs_temparg; |
| 36 | va_start(ap, num_args); |
| 37 | for (i = 0; i < num_args; i++) |
| 38 | { |
| 39 | aa[i].name = va_arg(ap, String); |
| 40 | aa[i].value = va_arg(ap, XtArgVal); |
| 41 | } |
| 42 | XtSetValues(w, aa, num_args); |
| 43 | if (num_args > 15) free(aa); |
| 44 | } |
| 45 | |
| 46 | /* End of em_xs.c */ |