]>
Commit | Line | Data |
---|---|---|
fa59b86f | 1 | /* $Id$ |
7ac48069 | 2 | * |
3 | * Check access to a Moira query | |
612ef603 | 4 | * |
7ac48069 | 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>. | |
612ef603 | 8 | */ |
9 | ||
babbc197 | 10 | #include <mit-copyright.h> |
7ac48069 | 11 | #include <moira.h> |
8defc06b | 12 | #include "mr_private.h" |
7ac48069 | 13 | |
a3bbcc2b | 14 | #include <errno.h> |
a43ce477 | 15 | #include <stdlib.h> |
7ac48069 | 16 | #include <string.h> |
17 | ||
18 | RCSID("$Header$"); | |
19 | ||
20 | int mr_access_internal(int argc, char **argv); | |
612ef603 | 21 | |
22 | /* | |
23 | * Check access to a named query. | |
24 | */ | |
5eaef520 | 25 | int mr_access(char *name, int argc, char **argv) |
612ef603 | 26 | { |
44d12d58 | 27 | char **nargv = malloc(sizeof(char *) * (argc + 1)); |
28 | int status = 0; | |
5eaef520 | 29 | |
a3bbcc2b | 30 | if (!nargv) |
31 | return ENOMEM; | |
5eaef520 | 32 | nargv[0] = name; |
33 | memcpy(nargv + 1, argv, sizeof(char *) * argc); | |
34 | status = mr_access_internal(argc + 1, nargv); | |
35 | free(nargv); | |
36 | return status; | |
612ef603 | 37 | } |
5eaef520 | 38 | |
612ef603 | 39 | /* |
40 | * Check access to a named query, where the query name is argv[0] | |
41 | * and the arguments are the rest of argv[]. | |
42 | */ | |
5eaef520 | 43 | int mr_access_internal(int argc, char **argv) |
612ef603 | 44 | { |
5eaef520 | 45 | int status; |
46 | mr_params params_st; | |
44d12d58 | 47 | mr_params *params = NULL; |
5eaef520 | 48 | mr_params *reply = NULL; |
49 | ||
50 | CHECK_CONNECTED; | |
51 | ||
52 | params = ¶ms_st; | |
53 | params->mr_version_no = sending_version_no; | |
54 | params->mr_procno = MR_ACCESS; | |
55 | params->mr_argc = argc; | |
56 | params->mr_argl = NULL; | |
57 | params->mr_argv = argv; | |
612ef603 | 58 | |
5eaef520 | 59 | if ((status = mr_do_call(params, &reply)) == 0) |
60 | status = reply->mr_status; | |
612ef603 | 61 | |
5eaef520 | 62 | mr_destroy_reply(reply); |
612ef603 | 63 | |
5eaef520 | 64 | return status; |
612ef603 | 65 | } |