smith@umn-cs.UUCP (03/12/86)
# # This is a sh archive containing source and binhex of a trivial # desk accessory. I'm posting it because it might be simple enough to be # understood by others who may need to write a trivial desk accessory. # echo x - dobreak.txt cat >dobreak.txt <<'!Funky!Stuff!' DoBreak is an example of a trivial desk accessory, coded as much as possible in Aztec C. The source code shows the minimum amount of hacking around you have to do to get some instructions to execute as a desk accessory. It might be small enough to make the minimum requirements of a desk accessory understandable. What does DoBreak really do? Well, it simply sends a break out the Modem port. It doesn't open the port, nor does it do anything to the port settings. I've used it from my own programs that use the modem port, from MacTerminal, and from the Finder without ill effects. The Mac I use here is connected through an allegedly intelligent dataswitch; I need to send it a break every now and then to keep it under control. DoBreak also hides the cursor while it runs; that's about the only way you can tell it really ran. The DoBreak accessory does everything when it is Opened; i.e. right when you select it from the menu. DoBreak ignores the ParamBlock and the Device Table entry passed to it; you'd better look at Aztec's Explorer DA example if you need those things. All other events and actions are ignored. Rick Smith University of Minnesota !Funky!Stuff! echo x - dobreak.c cat >dobreak.c <<'!Funky!Stuff!' /* dobreak.c * 11 March 1986 * * Trivial Desk Accessory to send Break to the Modem * * Rick Smith, March 1986 * partial support is acknowledged to the MEIS Center and * the Productivity Center of the University of Minnesota. * * This is an example of an incredibly simple desk accessory. When you * select it from the apple menu it calls five toolbox routines and then * exits. * * This accessory exists because I use a Mac connected to a Develcon * Dataswitch. I often need to send the Develcon a break in order to * reset my connection. This DA hides the cursor, sends a break for * 30 ticks, restores the cursor, and exits. * * In case it isn't obvious, anyone should feel free to cannibalize this * code however they want. If anyone makes money off of it, they'll * have earned it. * * Aztec C (version 1.06G) compilation/link/install instructions: set -x cc -bu dobreak.c ln -an DoBreak -o dobreak.drvr dobreak.o -lc cprsrc DRVR 31 dobreak.drvr sys:system * If you already have a driver or DA #31, 'cprsrc' will prompt you * to find if you want the existing one overwritten. If you're cautious * you can install the DA into a Font/DA Mover desk accessory file instead. */ /* Define header for Desk Accessory */ #asm main dc.w 0 ;desk accessory flags dc.w 0 ;no polling dc.w 0 ;event mask: allow nothing dc.w 0 ;no menu dc.w open_-main ;open: do all the work dc.w nop_-main ;for devices only dc.w nop_-main ;control: no events to handle dc.w nop_-main ;for devices only dc.w nop_-main ;close: nothing to shut down dc.b 8 dc.b "DoBreak " ds 0 ;for alignment public _Uend_,_Dorg_,_Cend_ save_ ;save pointers & set up globals lea main+(_Uend_-_Dorg_)+(_Cend_-main),a4 move.l a0,Pbp_ ;save param block pointer rts restore_ move.l Pbp_,a0 rts #endasm #define _DRIVER #include <types.h> #include <quickdraw.h> #include <pb.h> #include <desk.h> #include <serial.h> #define NULL (0L) #define DELTIME 30 #define MODEMREF -6 ParmBlkPtr Pbp; open() { long grub; /* scratch word for doing delay */ save(); HideCursor(); SerSetBreak((short) MODEMREF); Delay((long) DELTIME, &grub); SerClrBreak((short) MODEMREF); ShowCursor(); restore(); return(0); } nop() { return(0); } !Funky!Stuff! echo x - dobreak.hqx cat >dobreak.hqx <<'!Funky!Stuff!' (This file must be converted with BinHex 4.0) :"d4[3R*PB@X!4%C*6%406eB!N!J"fF1N!*!%!3#3!`'H!*!$RJ#3!cYd)(GTC$X JN!`[+L"hD@jNEhFJ583J+Lm0H`dJN!4MD'&b)'0S1b#3"#mU)'0SBA*KBh4PFL" dHA"PC#`JD@BJB@jj)#S[$3dJN!4TCL!SCACPER3J)6dJ48Y&@5N0)*!)BA"dCAK d+'9fC@jd,#"PF(4b,#"hF(4b,#"hD@3T1`dJN!4cGfPdBfJJ+'9fC@jd+5!JH`d JN!CMBA0P)%928%911JdJN!KcG'&bG("[FR3SGfPN+6X0)*!)BR*PB@Xl$5#3"Q0 KFf8J48Y&@3#3!jS!N!NX!')!BJ"L!'))4'p#FQ9KDb!!5IS!I#P)rra1G5"Xrra 1G8j@rraKkUK52ccrqNkk!%"86dKZrr`[2!#3!aj1ZJ!L8%mr22rk6VS!+P42U&0 KbR!!6Pj1G8j@!!"`!%jH6R8JE`!%S$XJE`!)))"1GA!-B!*`#dj@rmiJ6c&Z!!J !'$&!!"UJ"%jH6R8!N!B"!*!$!Ci!N!1H!*!$1`!!c"`!A!#3!a`!-J!!4&*@8J# 3!`S!$!!!)!#3"`J!4'p#FQ9KDp',!: !Funky!Stuff!