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