|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 5800 (0x16a8)
Types: TextFile
Names: »service.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/quipu/service.c«
/* service.c - */
#ifndef lint
static char *rcsid = "$Header: /f/osi/quipu/RCS/service.c,v 6.0 89/03/18 23:41:53 mrose Rel $";
#endif
/*
* $Header: /f/osi/quipu/RCS/service.c,v 6.0 89/03/18 23:41:53 mrose Rel $
*
*
* $Log: service.c,v $
* Revision 6.0 89/03/18 23:41:53 mrose
* Release 5.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
#include "quipu/util.h"
#include "quipu/commonarg.h"
#include "quipu/dua.h"
#define MAXSERV 20
static char default_service [BUFSIZ] = 0;
static char * serv_vec [MAXSERV];
static int serv_argc;
static int default_serv_set = 0;
extern DN user_name;
static char do_shuffle;
int copy_flag;
set_default_service (opt)
PS opt;
{
if (default_service [0] == 0) {
serv_argc = 0;
return (OK);
}
if ((serv_argc = sstr2arg (default_service, MAXSERV, serv_vec, " \t")) == -1) {
ps_print (opt,"Invalid default service controls");
return (NOTOK);
} else {
default_serv_set = 1;
return (OK);
}
}
int get_default_service (ca)
CommonArgs * ca;
{
PS opt;
char buffer [LINESIZE];
extern int sizelimit;
static CommonArgs sca = default_common_args;
*ca = sca; /* struct copy */
ca->ca_servicecontrol.svc_sizelimit = sizelimit;
if ((opt = ps_alloc (str_open)) == NULLPS) {
(void) fprintf (stderr,"ps_alloc error\n");
return (NOTOK);
}
if (str_setup (opt, buffer, LINESIZE, 1) == NOTOK) {
(void) fprintf (stderr,"ps_setup error\n");
return (NOTOK);
}
if (! default_serv_set)
if (set_default_service (opt) != OK) {
(void) fprintf (stderr,"error (1) - %s\n",buffer);
ps_free (opt);
return (NOTOK);
}
do_shuffle = FALSE;
if (do_service_control (opt,serv_argc, serv_vec, ca) < 0) {
(void) fprintf (stderr,"error (2) - %s\n",buffer);
ps_free (opt);
return (NOTOK);
}
ps_free (opt);
return (OK);
}
int service_control (opt,argc, argv, ca)
PS opt;
int argc;
char **argv;
CommonArgs *ca;
{
if (get_default_service (ca) != OK) {
ps_print (opt,"default service error - check quipurc\n");
return (-1);
}
do_shuffle = TRUE;
return (do_service_control (opt,argc, argv, ca));
}
int do_service_control (opt,argc, argv, ca)
PS opt;
int argc;
char **argv;
CommonArgs *ca;
{
ServiceControl *sc;
int shuffle_up ();
int x;
char shuffle;
sc = &(ca->ca_servicecontrol);
copy_flag = TRUE;
for (x = 0; x < argc; x++) {
shuffle = do_shuffle;
if (test_arg (argv[x], "-preferchain",3))
sc->svc_options |= SVC_OPT_PREFERCHAIN;
else if (test_arg (argv[x], "-nopreferchain",5))
sc->svc_options &= ~SVC_OPT_PREFERCHAIN;
else if (test_arg (argv[x], "-localscope",3))
sc->svc_options |= SVC_OPT_LOCALSCOPE;
else if (test_arg (argv[x], "-nolocalscope",3))
sc->svc_options &= (~SVC_OPT_LOCALSCOPE);
else if (test_arg (argv[x], "-dontusecopy",5)) {
copy_flag = FALSE;
sc->svc_options |= SVC_OPT_DONTUSECOPY;
} else if (test_arg (argv[x], "-usecopy",1)) {
copy_flag = TRUE;
sc->svc_options &= (~SVC_OPT_DONTUSECOPY);
}
else if (test_arg (argv[x], "-dontdereferencealias",5))
sc->svc_options |= SVC_OPT_DONTDEREFERENCEALIAS;
else if (test_arg (argv[x], "-dereferencealias",3))
sc->svc_options &= (~SVC_OPT_DONTDEREFERENCEALIAS);
else if (test_arg (argv[x], "-low",3))
sc->svc_prio = SVC_PRIO_LOW;
else if (test_arg (argv[x], "-medium",2))
sc->svc_prio = SVC_PRIO_MED;
else if (test_arg (argv[x], "-high",1))
sc->svc_prio = SVC_PRIO_HIGH;
else if (test_arg (argv[x], "-timelimit",2)) {
if (x + 1 == argc) {
ps_printf (opt, "We need a number for timelimit.\n");
return (-1);
} else {
shuffle_up (argc, argv, x);
argc--;
if ((sc->svc_timelimit = atoi (argv[x])) < -1) {
ps_printf (opt, "We need a posative number for timelimit.\n");
return (-1);
}
}
} else if (test_arg (argv[x], "-notimelimit",3))
sc->svc_timelimit = -1;
else if (test_arg (argv[x], "-sizelimit",3)) {
if (x + 1 == argc) {
ps_printf (opt, "We need a number for sizelimit.\n");
return (-1);
} else {
shuffle_up (argc, argv, x);
argc--;
if ((sc->svc_sizelimit = atoi (argv[x])) < -1) {
ps_printf (opt, "We need a posative number for sizelimit.\n");
return (-1);
}
}
} else if (test_arg (argv[x], "-nosizelimit",4))
sc->svc_sizelimit = -1;
else if (test_arg (argv[x], "-nochaining",4))
sc->svc_options |= SVC_OPT_CHAININGPROHIBIT;
else if (test_arg (argv[x], "-chaining",3))
sc->svc_options &= (~SVC_OPT_CHAININGPROHIBIT);
else if (test_arg (argv[x], "-sequence",2)) {
if (x + 1 == argc) {
ps_printf (opt, "We need a sequence name.\n");
return (-1);
} else {
shuffle_up (argc, argv, x);
argc--;
set_sequence (argv[x]);
}
} else if (test_arg (argv[x], "-nosequence",4))
unset_sequence();
else if (do_shuffle)
shuffle = FALSE;
else {
ps_printf (opt,"unknown service option %s\n",argv[x]);
return (-1);
}
if (shuffle)
shuffle_up (argc--, argv, x--);
}
return (argc);
}
shuffle_up (argc, argv, start)
register int argc;
char **argv;
register int start;
{
register int x;
for (x = start; x < argc; x++)
if (x == argc - 1) /* if it is the last one, then stick
* a 0 in */
argv[x] = 0;
else /* oterwise put the next one in it's place. */
argv[x] = argv[x + 1];
}
new_service (ptr)
char * ptr;
{
if (ptr != 0) {
if (*default_service != 0)
(void) strcat (default_service," ");
(void) strcat (default_service,ptr);
}
}