]> andersk Git - moira.git/blobdiff - lib/mr_access.c
Command line printer manipulation client, and build goo.
[moira.git] / lib / mr_access.c
index e2fc6df84cd2cd6a47a47e608caa767d92864331..ac70e3e79149dc1bab626c31b3ee48d0a786f4b2 100644 (file)
@@ -1,61 +1,46 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
+ *
+ * Check access to a Moira query
  *
- *     Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_access_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
 #include "mr_private.h"
-#include <string.h>
+
+#include <errno.h>
 #include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
 
 /*
  * Check access to a named query.
  */
 int mr_access(char *name, int argc, char **argv)
 {
-  char **nargv = malloc(sizeof(char *) * (argc + 1));
-  int status = 0;
-
-  nargv[0] = name;
-  memcpy(nargv + 1, argv, sizeof(char *) * argc);
-  status = mr_access_internal(argc + 1, nargv);
-  free(nargv);
-  return status;
-}
-
-/*
- * Check access to a named query, where the query name is argv[0]
- * and the arguments are the rest of argv[].
- */
-int mr_access_internal(int argc, char **argv)
-{
+  mr_params params, reply;
   int status;
-  mr_params params_st;
-  mr_params *params = NULL;
-  mr_params *reply = NULL;
 
   CHECK_CONNECTED;
 
-  params = &params_st;
-  params->mr_version_no = sending_version_no;
-  params->mr_procno = MR_ACCESS;
-  params->mr_argc = argc;
-  params->mr_argl = NULL;
-  params->mr_argv = argv;
+  params.u.mr_procno = MR_ACCESS;
+  params.mr_argc = argc + 1;
+  params.mr_argv = malloc(sizeof(char *) * (argc + 1));
+  if (!params.mr_argv)
+    return ENOMEM;
+  params.mr_argv[0] = name;
+  memcpy(params.mr_argv + 1, argv, sizeof(char *) * argc);
+  params.mr_argl = NULL;
 
-  if ((status = mr_do_call(params, &reply)) == 0)
-    status = reply->mr_status;
+  if ((status = mr_do_call(&params, &reply)) == MR_SUCCESS)
+    status = reply.u.mr_status;
 
   mr_destroy_reply(reply);
+  free(params.mr_argv);
 
   return status;
 }
This page took 0.203731 seconds and 4 git commands to generate.