home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
- * MultiUser - MultiUser Task/File Support System *
- * --------------------------------------------------------- *
- * Login *
- * --------------------------------------------------------- *
- * © Copyright 1993-1994 Geert Uytterhoeven *
- * All Rights Reserved. *
- ************************************************************/
-
-
- #include <exec/types.h>
- #include <dos/dos.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <utility/tagitem.h>
- #include <libraries/multiuser.h>
- #include <proto/multiuser.h>
-
- #include "Login_rev.h"
-
- #include "Locale.h"
-
- char __VersTag__[] = VERSTAG;
-
-
- int __saveds Start(char *arg)
- {
- struct ExecBase *SysBase;
- struct DosLibrary *DOSBase;
- struct muBase *muBase = NULL;
- struct RDArgs *args;
- LONG argarray[] = {
- #define argUSERID 0
- #define argGUI 1
- #define argTASK 2
- #define argOWN 3
- #define argGLOBAL 4
- #define argPROCESS 5
- NULL, NULL, NULL, NULL, NULL, NULL
- };
- struct TagItem tags[6];
- struct Task *task = NULL;
- int rc = RETURN_ERROR;
- struct LocaleInfo li;
-
- SysBase = *(struct ExecBase **)4;
-
- if ((!(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37))) ||
- (!(muBase = (struct muBase *)OpenLibrary("multiuser.library", 39)))) {
- rc = ERROR_INVALID_RESIDENT_LIBRARY;
- goto Exit;
- }
-
- OpenLoc(&li);
-
- args = ReadArgs("USERID,GUI/S,TASK/K,OWN/S,GLOBAL/S,PROCESS/K/N", argarray,
- NULL);
- if (!args)
- PrintFault(IoErr(), NULL);
- else if (argarray[argTASK] && argarray[argPROCESS])
- PutStr(GetLocS(&li,MSG_BOTH_TASKPROC));
- else if (argarray[argUSERID] && argarray[argOWN])
- PutStr(GetLocS(&li,MSG_BOTH_USERIDOWN));
- else if (argarray[argTASK] && !(task = FindTask((char *)argarray[argTASK])))
- VPrintf(GetLocS(&li,MSG_TASKNOTFOUND), (ULONG *)&argarray[argTASK]);
- else if (argarray[argPROCESS] &&
- !(task = (struct Task *)FindCliProc((ULONG)*(ULONG *)argarray[argPROCESS])))
- VPrintf(GetLocS(&li,MSG_PROCNOTFOUND), (ULONG *)argarray[argPROCESS]);
- else {
- tags[0].ti_Tag = muT_Graphical;
- tags[0].ti_Data = argarray[argGUI];
- tags[1].ti_Tag = muT_Task;
- tags[1].ti_Data = (LONG)task;
- tags[2].ti_Tag = muT_Own;
- tags[2].ti_Data = argarray[argOWN];
- tags[3].ti_Tag = muT_Global;
- tags[3].ti_Data = argarray[argGLOBAL];
- tags[4].ti_Tag = muT_UserID;
- tags[4].ti_Data = argarray[argUSERID];
- tags[5].ti_Tag = TAG_DONE;
- if (muLoginA(tags)) {
- PutStr(GetLocS(&li,MSG_LOGINOK));
- rc = RETURN_OK;
- } else {
- PutStr(GetLocS(&li,MSG_LOGINFAIL));
- }
- }
- FreeArgs(args);
-
- CloseLoc(&li);
-
- Exit:
- CloseLibrary((struct Library *)muBase);
- CloseLibrary((struct Library *)DOSBase);
-
- return(rc);
- }
-