/*
 * Copyright 1990 by Baylor College of Medicine ALL RIGHTS RESERVED. 
 *
 * This program is subject to a license agreement between 
 * Baylor College of Medicine and MIT. Any use inconsistent with
 * said license and any use by persons other than the faculty, 
 * students and staff at MIT or any use on a computer not operated 
 * as part of the Athena Computing Environment (ACE) is expressly 
 * prohibited.
 */
#include <stdio.h>
#include <srvlib.h>
#include <pwd.h>

main(argc,argv)
	char *argv[] ;
{
	SrvContext *srv ;
	int i ;
	int port ;

	if (argc < 5)
	{
		fprintf(stderr,"Usage: %s <server name> <port> <database name> <user1> [<user 2> ... <user n>]\n",argv[0]) ;
		exit(-1) ;
	}

	port = atoi(argv[2]);

	srv = srv_init(argv[1],port,argv[3]) ;
	if (srv == NULL)
	{
		fprintf(stderr,"Can not communicate with db server\n") ;
		exit(-1) ;
	}
	for(i = 4; i < argc; i++)
	{
		struct passwd *pwd = getpwnam(argv[i]);
		
		if (pwd == NULL)
		{
			fprintf(stderr,"%s: User unknown\n",argv[i]);
		}
		else
		{
			srv_add_user(srv,pwd->pw_uid) ;
		}
	}

	srv_close(srv);
}
