home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* */
- /* qe .. Queue enable. Enable jobs to be submitted to this queue. */
- /* */
- /* usage: qe qname */
- /* */
- /* Copyright (c) Vita Services 1990 */
- /* (c) Vita Fibres 1990 1991 */
- /* */
- /************************************************************************/
-
- #include "qbatch.h"
- int fpq = 0;
- uid_t uid;
- char *queuename;
- char queue[128];
- char buff [128];
- #include "config.h"
-
-
- main (argc, argv, envp)
- int argc;
- char *argv[], *envp[];
- {
- if (getuid() != 0)
- {
- fprintf (stderr, "Must be root to enable a queue\n");
- exit (-1);
- }
- if (argc == 1)
- {
- puts ("Usage qe queuename");
- qb_term (0);
- }
- if (strcmp(argv[1], "-v") == 0) q_version();
- queuename = argv[1];
- strcpy (queue, QUEUEPATH);
- strcat (queue, queuename);
- qb_setterm();
- fpq = open (queue, O_RDWR);
- if (fpq == -1)
- {
- fprintf (stderr, "Invalid queue name: %s\n", queuename);
- qb_term (-1);
- }
- uid = getuid();
- if (uid != 0)
- {
- fprintf (stderr, "Must be super user to disable a queue\n");
- qb_term (-1);
- }
- q_lock(fpq);
- read (fpq, &head, sizeof(head));
- if (bad_queue()) qb_exit(-1);
- if ((head.qh_flags&qh_enabled) == 0)
- {
- head.qh_flags += qh_enabled;
- }
- else
- {
- fprintf (stderr, "Queue %s is already enabled\n", queuename);
- qb_term (-1);
- }
- lseek (fpq, 0, SEEK_SET);
- write (fpq, &head, sizeof(head));
- q_unlock(fpq);
- close(fpq); fpq = 0;
- qb_term(0);
- }
-