DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T a

⟦fcfc973ce⟧ TextFile

    Length: 2623 (0xa3f)
    Types: TextFile
    Names: »args.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« 
        └─⟦d846658bd⟧ 
            └─⟦this⟧ »osimis/smap/args.c« 

TextFile

/*
 * Copyright (c) 1988 University College London
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that the above copyright notice and this paragraph are
 * duplicated in all such forms and that any documentation,
 * advertising materials, and other materials related to such
 * distribution and use acknowledge that the software was developed
 * by the Department of Computer Science, University College London.
 * The name of the University may not be used to
 * endorse or promote products derived from this software without
 * specific prior written permission.
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

/* parses command line args or accepts args interactively */

/*
 * By George Pavlou, October 1988
 */

#include <stdio.h>
#include "config.h"
#include "defs.h"

extern char *hosts[], host[];
extern int   NofHosts;


int  parse_args (argc, argv)
int  argc;
char **argv;
{
    switch (argc) {
	case 1:
	    if (NofHosts == 0)
		error(NULLCP, "needs configuration file - specify host name");
	    if (strcmp(argv[0], "osimic") == 0)
	        return (mic_user_interface());
	    return (user_interface());

	case 2:
	    strcpy(host, argv[1]);
	    if (strcmp(host, "all") == 0) {
	        if (strcmp(argv[0], "osimic") == 0) {
	            fprintf(stderr, "usage: %s [<host>]\n", argv[0]);
		    exit(1);
		}
		if (NofHosts == 0)
		    error(NULLCP, "needs configuration file for option `all'");
		return (ALL);
	    }
            if (NofHosts && host2indx(host, hosts, NofHosts) == -1)
		return (NOTOK);
	    return (HOST);

	default:
	    if (strcmp(argv[0], "osimic") == 0)
	        fprintf(stderr, "usage: %s [<host>]\n", argv[0]);
	    else
	        fprintf(stderr, "usage: %s [<host> | all]\n", argv[0]);
	    exit(1);
    }
}


static int  user_interface ()
{
    int i;

    printf("Supported hosts:\n");
    for (i = 0; i < NofHosts; i++)
	printf("    %s\n", hosts[i]);
    printf("    all\nhost?  ");
    scanf("%s", host);
    putc('\n', stdout);

    if (strcmp(host, "all") == 0)
	return (ALL);
    else 
    if (host2indx(host, hosts, NofHosts) == NOTOK)
	return (NOTOK);
    return (HOST);
}


static int  mic_user_interface ()
{
    int i;

    printf("Supported hosts:\n");
    for (i = 0; i < NofHosts; i++)
	printf("    %s\n", hosts[i]);
    printf("host?  ");
    scanf("%s", host);

    if (host2indx(host, hosts, NofHosts) == NOTOK)
	return (NOTOK);
    return (HOST);
}