]> andersk Git - moira.git/blob - lib/mr_access.c
e2fc6df84cd2cd6a47a47e608caa767d92864331
[moira.git] / lib / mr_access.c
1 /*
2  *      $Source$
3  *      $Author$
4  *      $Header$
5  *
6  *      Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
7  *      For copying and distribution information, please see the file
8  *      <mit-copyright.h>.
9  */
10
11 #ifndef lint
12 static char *rcsid_mr_access_c = "$Header$";
13 #endif
14
15 #include <mit-copyright.h>
16 #include "mr_private.h"
17 #include <string.h>
18 #include <stdlib.h>
19
20 /*
21  * Check access to a named query.
22  */
23 int mr_access(char *name, int argc, char **argv)
24 {
25   char **nargv = malloc(sizeof(char *) * (argc + 1));
26   int status = 0;
27
28   nargv[0] = name;
29   memcpy(nargv + 1, argv, sizeof(char *) * argc);
30   status = mr_access_internal(argc + 1, nargv);
31   free(nargv);
32   return status;
33 }
34
35 /*
36  * Check access to a named query, where the query name is argv[0]
37  * and the arguments are the rest of argv[].
38  */
39 int mr_access_internal(int argc, char **argv)
40 {
41   int status;
42   mr_params params_st;
43   mr_params *params = NULL;
44   mr_params *reply = NULL;
45
46   CHECK_CONNECTED;
47
48   params = &params_st;
49   params->mr_version_no = sending_version_no;
50   params->mr_procno = MR_ACCESS;
51   params->mr_argc = argc;
52   params->mr_argl = NULL;
53   params->mr_argv = argv;
54
55   if ((status = mr_do_call(params, &reply)) == 0)
56     status = reply->mr_status;
57
58   mr_destroy_reply(reply);
59
60   return status;
61 }
This page took 0.298959 seconds and 3 git commands to generate.