]>
Commit | Line | Data |
---|---|---|
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 <errno.h> | |
15 | #include <stdlib.h> | |
16 | #include <string.h> | |
17 | ||
18 | RCSID("$Header$"); | |
19 | ||
20 | /* | |
21 | * Check access to a named query. | |
22 | */ | |
23 | int mr_access(char *name, int argc, char **argv) | |
24 | { | |
25 | mr_params params, reply; | |
26 | int status; | |
27 | ||
28 | CHECK_CONNECTED; | |
29 | ||
30 | params.u.mr_procno = MR_ACCESS; | |
31 | params.mr_argc = argc + 1; | |
32 | params.mr_argv = malloc(sizeof(char *) * (argc + 1)); | |
33 | if (!params.mr_argv) | |
34 | return ENOMEM; | |
35 | params.mr_argv[0] = name; | |
36 | memcpy(params.mr_argv + 1, argv, sizeof(char *) * argc); | |
37 | params.mr_argl = NULL; | |
38 | ||
39 | if ((status = mr_do_call(¶ms, &reply)) == MR_SUCCESS) | |
40 | status = reply.u.mr_status; | |
41 | ||
42 | mr_destroy_reply(reply); | |
43 | free(params.mr_argv); | |
44 | ||
45 | return status; | |
46 | } |