]> andersk Git - moira.git/blob - lib/mr_access.c
8d120694f0274b4ed556b73d622bbc088486b378
[moira.git] / lib / mr_access.c
1 /* $Id$
2  *
3  * Check access to a Moira query
4  *
5  * Copyright (C) 1987-1998 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 "mr_private.h"
13
14 #include <stdlib.h>
15 #include <string.h>
16
17 RCSID("$Header$");
18
19 int mr_access_internal(int argc, char **argv);
20
21 /*
22  * Check access to a named query.
23  */
24 int mr_access(char *name, int argc, char **argv)
25 {
26   char **nargv = malloc(sizeof(char *) * (argc + 1));
27   int status = 0;
28
29   nargv[0] = name;
30   memcpy(nargv + 1, argv, sizeof(char *) * argc);
31   status = mr_access_internal(argc + 1, nargv);
32   free(nargv);
33   return status;
34 }
35
36 /*
37  * Check access to a named query, where the query name is argv[0]
38  * and the arguments are the rest of argv[].
39  */
40 int mr_access_internal(int argc, char **argv)
41 {
42   int status;
43   mr_params params_st;
44   mr_params *params = NULL;
45   mr_params *reply = NULL;
46
47   CHECK_CONNECTED;
48
49   params = &params_st;
50   params->mr_version_no = sending_version_no;
51   params->mr_procno = MR_ACCESS;
52   params->mr_argc = argc;
53   params->mr_argl = NULL;
54   params->mr_argv = argv;
55
56   if ((status = mr_do_call(params, &reply)) == 0)
57     status = reply->mr_status;
58
59   mr_destroy_reply(reply);
60
61   return status;
62 }
This page took 0.032445 seconds and 3 git commands to generate.