home *** CD-ROM | disk | FTP | other *** search
- /* Written by Don Gillies (gillies@cs.uiuc.edu)
- *
- * bootswitch.c -- the boot switch program
- * this INIT treats your CAPS LOCK keep like a boot-time switch on the macintosh.
- * if the CAPS LOCK key is down when the machine boots, then the init takes
- * a resource in the file "Finder Startup" and makes it accessible to the
- * finder so that it will run when the time comes. if the CAPS LOCK key is
- * up, then the finder startup will be skipped.
- */
-
- /* DETAILED INFORMATION FOR USERS OF THIS INIT:
- *
- * Instructions:
- *
- * BASIC USE (turning a set of startup files on/off)
- *
- * (1) Put this Init in your System Folder.
- * (2) Use the "Set Startup" menu in system 4.x, 5.x, or 6.x
- * to specify some startup file(s) in multifinder.
- * (3) Reboot macintosh. Notice that the startup file(s) run.
- * (4) Depress caps-lock key, reboot macintosh. Notice that
- * the startup file(s) DO NOT run.
- *
- * ADVANCED USE (selecting between two startup sets)
- *
- * (1) Put this INIT in your System Folder
- * (2) Use the "Set Startup" item in the "Special" menu in system
- * 4.x, 5.x, or 6.x to specify SET 1 of startup file(s) in multifinder
- * (3) Depress caps-lock key, reboot the macintosh. Now
- * specify SET 2 by selecting the appropriate icons and
- * clicking on "Set Startup" in multifinder
- * (4) Now the system behaves as follows at boot time:
- * CAPS LOCK UP - start SET 1
- * CAPS LOCK DEPRESSED - start SET 2
- * (5) To erase startup selections, drag the "Finder Startup"
- * file to the trash
- */
-
- #include <MacTypes.h>
- #include <OSUtil.h>
- #include <EventMgr.h>
- #include <SetUpA4.h>
- #define NIL 0
-
- Str255 fStartup = "\pFinder Startup";
- ResType rType = 0x666E6472; /* "fndr" */
- int r0 = 0;
- int r1 = 1;
- int r2 = 2;
-
- /* how it works.
- * R E S O U R C E S H U F F L I N G
- * "Finder Startup" file, "fndr" resource
- *
- * 1 resource in file 2 resources in file
- * caps-lock 0 -> 2 caps-lock 0 -> 2
- * 1 -> 0
- *
- * no key 2 -> 0 no key 0 -> 1
- * 2 -> 0
- */
-
- void main()
- {
- char data[18];
- int refNum, choices; /* resource file reference number */
- Handle handle0, handle1, handle2;
-
- RememberA0();
- SetUpA4();
-
- if(Button()) SysBeep(10); /* Beep, if install was cancelled */
- else if ((refNum = OpenResFile(fStartup)) != -1) /* Ready to modify resource file */
- {
- GetKeys(&data);
-
- handle0 = GetResource(rType, r0);
- handle1 = GetResource(rType, r1);
- handle2 = GetResource(rType, r2);
-
- choices = (handle0 != NIL) + (handle1 != NIL) + (handle2 != NIL);
-
- if (refNum != 1 && (data[7] & 02) != NIL) { /* CAPS LOCK DOWN */
- if (handle0 != NIL && handle1 != NIL) { /* two startups */
- SetResInfo(handle0, r2, 0);
- SetResInfo(handle1, r0, 0);
- ChangedResource(handle0);
- ChangedResource(handle1);
- }
- else if (choices == 1 && handle0 != NIL) {
- SetResInfo(handle0, r2, 0);
- ChangedResource(handle0);
- }
- }
- else { /* CAPS LOCK UP */
- if (handle0 != NIL && handle2 != NIL) {
- SetResInfo(handle0, r1, 0); /* 0 -> 1 */
- SetResInfo(handle2, r0, 0);
- ChangedResource(handle0);
- ChangedResource(handle2);
- }
- else if (choices == 1 && handle2 != NIL) { /* 0 -> 2 */
- SetResInfo(handle2, r0, 0);
- ChangedResource(handle2);
- }
- }
- CloseResFile(refNum);
- }
- RestoreA4();
- }
-