]> andersk Git - moira.git/blame - clients/lib/error.c
If a user specified a member that isn't a LIST, a USER, or a foreign
[moira.git] / clients / lib / error.c
CommitLineData
d5a7ea17 1/* $Id$
2 *
3 * mrcl error interface
4 *
5 * Copyright (C) 1999 by the Massachusetts Institute of Technology
6 * For copying and distribution information, please see the file
7 * <mit-copyright.h>.
8 */
9
10#include <mit-copyright.h>
11#include <moira.h>
12#include <mrclient.h>
13#include "mrclient-internal.h"
14
15#include <stdarg.h>
16#include <stdlib.h>
17#include <stdio.h>
18
19#include <com_err.h>
20
21RCSID("$Header$");
22
23static char *mrcl_message = NULL;
24
25void mrcl_set_message(char *fmt, ...)
26{
27 int args, len;
28 char *p;
29 va_list ap;
30
31 free(mrcl_message);
32
33 /* Count "%s"s */
34 for (args = 0, p = strstr(fmt, "%s"); p; p = strstr(p + 2, "%s"))
35 args++;
36
37 /* Measure the output string. */
38 len = strlen(fmt) + 1;
39 va_start(ap, fmt);
40 while (args--)
41 {
42 p = va_arg(ap, char *);
43 len += strlen(p);
44 }
45 va_end(ap);
46
47 /* Malloc and print */
48 mrcl_message = malloc(len);
49 if (mrcl_message)
50 {
51 va_start(ap, fmt);
52 vsprintf(mrcl_message, fmt, ap);
53 va_end(ap);
54 }
55}
56
57char *mrcl_get_message(void)
58{
59 return mrcl_message;
60}
61
62void mrcl_clear_message(void)
63{
64 free(mrcl_message);
65 mrcl_message = NULL;
66}
67
68void mrcl_com_err(char *whoami)
69{
70 if (mrcl_message)
71 com_err(whoami, 0, "%s", mrcl_message);
72}
This page took 0.061867 seconds and 5 git commands to generate.