home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / dec93 / os20 / util / multiuser.lha / MultiUser / C.src / Logout.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-21  |  2.1 KB  |  80 lines

  1. /************************************************************
  2. * MultiUser - MultiUser Task/File Support System                *
  3. * ---------------------------------------------------------    *
  4. * Logout                                                                        *
  5. * ---------------------------------------------------------    *
  6. * © Copyright 1993 by Geert Uytterhoeven                            *
  7. * All Rights Reserved.                                                    *
  8. ************************************************************/
  9.  
  10.  
  11. #include <exec/types.h>
  12. #include <dos/dos.h>
  13. #include <proto/exec.h>
  14. #include <proto/dos.h>
  15. #include <utility/tagitem.h>
  16. #include <libraries/multiuser.h>
  17. #include <proto/multiuser.h>
  18.  
  19. #include "Logout_rev.h"
  20.  
  21.  
  22. char __VersTag__[] = VERSTAG;
  23.  
  24.  
  25. int __saveds Start(char *arg)
  26. {
  27.     struct ExecBase *SysBase;
  28.     struct DosLibrary *DOSBase;
  29.     struct muBase *muBase = NULL;
  30.     struct RDArgs *args;
  31.     LONG argarray[] = {
  32.         NULL, NULL, NULL, NULL, NULL, NULL
  33.     };
  34.     struct TagItem tags[6];
  35.     struct Task *task = NULL;
  36.     int rc = RETURN_ERROR;
  37.  
  38.     SysBase = *(struct ExecBase **)4;
  39.  
  40.     if ((!(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37))) ||
  41.          (!(muBase = (struct muBase *)OpenLibrary("multiuser.library", 39)))) {
  42.         rc = RETURN_FAIL;
  43.         goto Exit;
  44.     }
  45.  
  46.     args = ReadArgs("GUI/S,TASK/K,GLOBAL/S,QUIET/S,PROCESS/K/N,ALL/S",
  47.                          argarray, NULL);
  48.     if (!args)
  49.         PrintFault(IoErr(), NULL);
  50.     else if (argarray[1] && argarray[4])
  51.         PutStr("You can't specify both TASK and PROCESS\n");
  52.     else if (argarray[1] && !(task = FindTask((char *)argarray[1])))
  53.         VPrintf("Couldn't find task '%s'\n", (ULONG *)&argarray[1]);
  54.     else if (argarray[4] &&
  55.                 !(task = (struct Task *)FindCliProc((ULONG)*(ULONG *)argarray[4])))
  56.         VPrintf("Couldn't find process %ld\n", (ULONG *)argarray[4]);
  57.     else {
  58.         tags[0].ti_Tag = muT_Graphical;
  59.         tags[0].ti_Data = argarray[0];
  60.         tags[1].ti_Tag = muT_Task;
  61.         tags[1].ti_Data = (ULONG)task;
  62.         tags[2].ti_Tag = muT_Global;
  63.         tags[2].ti_Data = argarray[2];
  64.         tags[3].ti_Tag = muT_Quiet;
  65.         tags[3].ti_Data = argarray[3];
  66.         tags[4].ti_Tag = muT_All;
  67.         tags[4].ti_Data = argarray[5];
  68.         tags[5].ti_Tag = TAG_DONE;
  69.         muLogoutA(tags);
  70.         rc = RETURN_OK;
  71.     }
  72.     FreeArgs(args);
  73.  
  74. Exit:
  75.     CloseLibrary((struct Library *)muBase);
  76.     CloseLibrary((struct Library *)DOSBase);
  77.  
  78.     return(rc);
  79. }
  80.