]>
Commit | Line | Data |
---|---|---|
7ac48069 | 1 | /* $Id $ |
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 | |
a43ce477 | 14 | #include <stdlib.h> |
7ac48069 | 15 | #include <string.h> |
16 | ||
17 | RCSID("$Header$"); | |
18 | ||
19 | int mr_access_internal(int argc, char **argv); | |
612ef603 | 20 | |
21 | /* | |
22 | * Check access to a named query. | |
23 | */ | |
5eaef520 | 24 | int mr_access(char *name, int argc, char **argv) |
612ef603 | 25 | { |
44d12d58 | 26 | char **nargv = malloc(sizeof(char *) * (argc + 1)); |
27 | int status = 0; | |
5eaef520 | 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; | |
612ef603 | 34 | } |
5eaef520 | 35 | |
612ef603 | 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 | */ | |
5eaef520 | 40 | int mr_access_internal(int argc, char **argv) |
612ef603 | 41 | { |
5eaef520 | 42 | int status; |
43 | mr_params params_st; | |
44d12d58 | 44 | mr_params *params = NULL; |
5eaef520 | 45 | mr_params *reply = NULL; |
46 | ||
47 | CHECK_CONNECTED; | |
48 | ||
49 | params = ¶ms_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; | |
612ef603 | 55 | |
5eaef520 | 56 | if ((status = mr_do_call(params, &reply)) == 0) |
57 | status = reply->mr_status; | |
612ef603 | 58 | |
5eaef520 | 59 | mr_destroy_reply(reply); |
612ef603 | 60 | |
5eaef520 | 61 | return status; |
612ef603 | 62 | } |