source: trunk/athena/bin/neos/fxcreate.c @ 13635

Revision 13635, 2.6 KB checked in by danw, 25 years ago (diff)
NEOS clients, from athena/lib/neos/clients
Line 
1/**********************************************************************
2 * File Exchange fxcreate client
3 *
4 * $Id: fxcreate.c,v 1.1 1999-09-28 22:10:57 danw Exp $
5 *
6 * Copyright 1989, 1990 by the Massachusetts Institute of Technology.
7 *
8 * For copying and distribution information, please see the file
9 * <mit-copyright.h>.
10 **********************************************************************/
11
12#include <mit-copyright.h>
13
14#ifndef lint
15static char rcsid_fxcreate_c[] = "$Id: fxcreate.c,v 1.1 1999-09-28 22:10:57 danw Exp $";
16#endif /* lint */
17
18#include <stdio.h>
19#include <fx/fxcl.h>
20
21FX *
22create_course(fxp, module, course)
23     FX *fxp;
24     char *module, *course;
25{
26  long code;
27
28  code = fx_create(fxp, course);
29  fx_close(fxp);
30  if (code) {
31    com_err(module, code, "trying to create %s", course);
32    exit(1);
33  }
34  if ((fxp = fx_open(course, &code)) == NULL) {
35    com_err(module, code, "while connecting to new course.");
36    exit(1);
37  }
38  /* "*.*" works and "*" doesn't because the current acl lib is weird */
39  if (code = fx_acl_add(fxp, ACL_TURNIN, "*.*"))
40    com_err(module, code, "allowing public turnin access.");
41  return(fxp);
42}
43
44main(argc, argv)
45  int argc;
46  char *argv[];
47{
48  FX *fxp;
49  long code, code2;
50  int i, verbose = 1, specified = 0, created = 0;
51  char *course = NULL;
52  static char USAGE[] = "Usage: %s [ options ] course [ grader ... ]\n";
53
54  if (argc < 2) {
55    fprintf(stderr, USAGE, argv[0]);
56    exit(1);
57  }
58
59  /* First authenticate to the fxserver */
60  if ((fxp = fx_open("", &code)) == NULL) {
61    com_err(argv[0], code, "while connecting.");
62    exit(1);
63  }
64
65  for(i=1; i<argc; i++) {
66    if (argv[i][0] == '-') {
67      switch(argv[i][1]) {
68      case 'q':
69        verbose = 0;
70        break;
71      case 'v':
72        verbose = 1;
73        break;
74      case 'c':
75        course = argv[++i];
76        specified++;
77        fxp = create_course(fxp, argv[0], course);
78        if (verbose) printf("Created %s file exchange.\n", course);
79        break;
80      default:
81        fprintf(stderr, USAGE, argv[0]);
82        exit(1);
83      }
84      continue;
85    }
86
87    if (!specified) {
88      course = argv[i];
89      specified++;
90      fxp = create_course(fxp, argv[0], course);
91      if (verbose) printf("Created %s file exchange.\n", course);
92      continue;
93    }
94
95    if (code = fx_acl_add(fxp, ACL_GRADER, argv[i]))
96      com_err(argv[0], code, "giving %s grader access.", argv[i]);
97    if (code2 = fx_acl_add(fxp, ACL_MAINT, argv[i]))
98      com_err(argv[0], code2, "giving %s maintainer access.", argv[i]);
99    if (verbose && !code && !code2) {
100      printf("\tAdded %s to access control lists for %s.\n",
101             full_name(argv[i]), course);
102    }
103  }
104  fx_close(fxp);
105  exit(0);
106}
Note: See TracBrowser for help on using the repository browser.