/* $Revision Header built automatically *************** (do not edit) ************
**
** © Copyright by Lars Eilebrecht (Shadowfox)
**
** File             : Work:Program/SC/PRG/ShadowStart/ShadowStart.c
** Created on       : Mittwoch, 16.11.94 17:23:09
** Created by       : Lars Eilebrecht
** Current revision : V1.0
**
**
** Purpose
** -------
**     Disable "WBStartup" and/or "User-Startup" during startup.
**
** Revision V1.0
** --------------
** created on Mittwoch, 16.11.94 17:23:09  by  Lars Eilebrecht.   LogMessage :
**     --- Initial release ---
**
*********************************************************************************/
#define REVISION "1.0"
#define REVDATE  "16.11.94"
#define REVTIME  "17:23:09"
#define AUTHOR   "Lars Eilebrecht"
#define VERNUM   1
#define REVNUM   0
#define TITLE "ShadowStart "REVISION" ("REVDATE") © by Lars Eilebrecht (Shadowfox)"

#include <stdio.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <libraries/lowlevel.h>
#include <libraries/dos.h>

#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>

#include <proto/lowlevel.h>
#include <proto/dos.h>

static const char *ver ="$VER: "TITLE"\0";


int main (int argc, char **argv)
{
  if(!LowLevelBase)                             // do we have 3.x?
  {
    printf("ShadowStart: Sorry, this program needs Kickstart 3.x!\n");
    return RETURN_FAIL;
  }
  else
  {
    struct KeyQuery spacebar =                  // declare KeyQuery-struct
                      {
                        (UWORD)64,              // rawkeycode for spacebar
                        FALSE,                  // not pressed yet...
                      };

    if(Rename("SYS:_WBStartup","SYS:WBStartup"))// rename to original names...
      Rename("SYS:_WBStartup.info","SYS:WBStartup.info");
    Rename("SYS:S/_User-Startup","SYS:S/User-Startup");

    QueryKeys(&spacebar,(UBYTE)1);              // dirty spacebar check ;-)
    if(spacebar.kq_Pressed)                     // Was it pressed? Silent exit, if not...
    {
      struct Library *IntuitionBase;

      if (IntuitionBase=OpenLibrary("intuition.library",37))
      {
        LONG result;
        struct EasyStruct shadowES =            // declare EasyRequest-struct
                          {
                            sizeof(struct EasyStruct),
                            0, // no flags
                            "ShadowStart "REVISION" ("REVDATE") © by Lars `SFX' Eilebrecht",
                            "\nSelect items to disable during startup.\n",
                            "WBStartup + User-Startup|WBStartup|User-Startup|Cancel",
                          };

        result=EasyRequest(NULL,&shadowES,NULL);
        switch (result)
        {                 // note: success of rename-operation isn't checked...
          case 1: 
            Rename("SYS:WBStartup","SYS:_WBStartup");
            Rename("SYS:WBStartup.info","SYS:_WBStartup.info");
            Rename("SYS:S/User-Startup","SYS:S/_User-Startup");
            break;
          case 2:
            Rename("SYS:WBStartup","SYS:_WBStartup");
            Rename("SYS:WBStartup.info","SYS:_WBStartup.info");
            break;
          case 3:
            Rename("SYS:S/User-Startup","SYS:S/_User-Startup");
            break;
        }
        CloseLibrary(IntuitionBase);
      }
    }
    return 0;
  }
}
