/******************************************************************
 *
 * Project : AutoPass.c
 *
 * Syntax  : AutoPass <UserID> <Passwd>
 *
 * Short   : Automatic login for MultiUserFileSystem
 *
 * Author  : Bjorn Reese (breese@imada.ou.dk)
 * Date    : 02.04.94
 *
 * Compile : (SAS/C 6.3) sc LINK AutoPass.c
 *           Remember the MultiUser includes
 *
 * This program is Public Domain. No warrenties whatever are given.
 *
 ******************************************************************/

#include <stdio.h>
#include <proto/exec.h>
#include <dos/dos.h>
#include <utility/tagitem.h>
#include <clib/multiuser_protos.h>
#include <libraries/multiuser.h>
#include <proto/multiuser.h>


char const *version = "$VER: AutoPass V1.0 by Bjørn Reese (02.04.94)";

int CXBRK(void) {return(0);}
int chkabort(void) {return(0);}

void main(int argc, char *argv[]) {

	struct muBase *muBase;

	struct TagItem muTags[] = {
		muT_UserID, NULL,
		muT_Password, NULL,
		muT_Graphical, FALSE,
		muT_Global, TRUE,
		TAG_DONE
	};


	if (argc == 3) {
		if (muBase = (struct muBase *)OpenLibrary(MULTIUSERNAME, MULTIUSERVERSION)) {

			muTags[0].ti_Data = (ULONG)argv[1];
			muTags[1].ti_Data = (ULONG)argv[2];
			if (!muLoginA(muTags))
				printf("Error: Invalid UserID or Password\n");

			CloseLibrary((struct Library *) muBase);

		} else {

			printf("Error: Can't open multiuser.library\n");

		}

	} else {

		printf ("AutoPass V1.0 by Bjørn Reese\nSyntax: AutoPass <UserID> <Password>\n");

	}

} /* main */
