home *** CD-ROM | disk | FTP | other *** search
- /*
- Lightning Dial! by David R. Stromberger.
- Copyright (C) 1989
-
- Cornerstone Software.
- E. 18625 Riverway
- Greenacres Wa, 99016
- (509) 928-8670
-
- This source code was written for the MANX 3.6a C compiler and is
- compiled as follows:
-
- cc +l ldial
- ln ldial -lc32
-
- Lightning Dial! was written to demonstrate how easy it is to use
- the serial port. You may copy and modify this code 'till you drop.
- */
-
-
- #include <stdio.h> /* standard stuff like getchar() */
- #include <exec/types.h> /* lots of defines for things like VOID */
- #include <devices/serial.h> /* serial port info */
- #include <exec/exec.h> /* memory handling. MEMF_PUBLIC ect... */
- #include <intuition/intuition.h> /* intuition info... what else? */
- #include <hardware/cia.h> /* for the hangup routine */
- #include <exec/io.h>
- #include <exec/memory.h>
- #include <libraries/dos.h>
-
-
- #undef FOREVER /* destroy the define that intuiton
- does and make our own.
- */
- #define FOREVER for(;;) /* a forever loop, never end */
-
- struct IntuitionBase *IntuitionBase; /* pointer to intuition */
- struct GfxBase *GfxBase; /* pointer to gfx lib */
- extern struct MsgPort *CreatePort(); /* make Manx warnings shut up */
- struct IOExtSer *WriteSer_Req; /* the serial device name,stuct */
- struct IOExtSer *ReadSer_Req; /* for reading from the modem */
- struct Window *wd; /* pointer to the window */
- struct RastPort *rpG; /* pointer to a rastport */
- char rs_out[1]; /* output character buffer */
- char rs_in[1]; /* input character buffer which we
- don't use here, but it's there
- in the case that you may
- want to expand on this system.
- */
-
- int nodialflag,ticks,dloop; /* some stuff */
- char phonenumber[20]; /* # to dial */
-
- /* start of some fancy POWERWINDOWS code */
-
- SHORT BorderVectors1[] = {
- 0,0,
- 18,0,
- 18,11,
- 0,11,
- 0,0
- };
- struct Border Border1 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors1, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget11 = {
- NULL, /* next gadget */
- 102,54, /* origin XY of hit box relative to window TopLeft */
- 17,10, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY, /* activation flags */
- BOOLGADGET, /* gadget type flags */
- (APTR)&Border1, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- NULL, /* SpecialInfo structure */
- 11, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- SHORT BorderVectors2[] = {
- 0,0,
- 18,0,
- 18,11,
- 0,11,
- 0,0
- };
- struct Border Border2 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors2, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget10 = {
- &Gadget11, /* next gadget */
- 102,41, /* origin XY of hit box relative to window TopLeft */
- 17,10, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY, /* activation flags */
- BOOLGADGET, /* gadget type flags */
- (APTR)&Border2, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- NULL, /* SpecialInfo structure */
- 10, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- SHORT BorderVectors3[] = {
- 0,0,
- 18,0,
- 18,11,
- 0,11,
- 0,0
- };
- struct Border Border3 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors3, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget9 = {
- &Gadget10, /* next gadget */
- 102,27, /* origin XY of hit box relative to window TopLeft */
- 17,10, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY, /* activation flags */
- BOOLGADGET, /* gadget type flags */
- (APTR)&Border3, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- NULL, /* SpecialInfo structure */
- 9, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- SHORT BorderVectors4[] = {
- 0,0,
- 18,0,
- 18,11,
- 0,11,
- 0,0
- };
- struct Border Border4 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors4, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget8 = {
- &Gadget9, /* next gadget */
- 102,14, /* origin XY of hit box relative to window TopLeft */
- 17,10, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY, /* activation flags */
- BOOLGADGET, /* gadget type flags */
- (APTR)&Border4, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- NULL, /* SpecialInfo structure */
- 8, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- UBYTE Gadget7SIBuff[4] =
- "180";
- struct StringInfo Gadget7SInfo = {
- Gadget7SIBuff, /* buffer where text will be edited */
- NULL, /* optional undo buffer */
- 0, /* character position in buffer */
- 4, /* maximum number of characters to allow */
- 0, /* first displayed character buffer position */
- 0,0,0,0,0, /* Intuition initialized and maintained variables */
- 0, /* Rastport of gadget */
- 0, /* initial value for integer gadgets */
- NULL /* alternate keymap (fill in if you set the flag) */
- };
-
- SHORT BorderVectors5[] = {
- 0,0,
- 40,0,
- 40,9,
- 0,9,
- 0,0
- };
- struct Border Border5 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors5, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget7 = {
- &Gadget8, /* next gadget */
- 121,67, /* origin XY of hit box relative to window TopLeft */
- 39,8, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY, /* activation flags */
- STRGADGET, /* gadget type flags */
- (APTR)&Border5, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- (APTR)&Gadget7SInfo, /* SpecialInfo structure */
- 7, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- SHORT BorderVectors6[] = {
- 0,0,
- 35,0,
- 35,49,
- 0,49,
- 0,0
- };
- struct Border Border6 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 1,2,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors6, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct IntuiText IText1 = {
- 3,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 1,21, /* XY origin relative to container TopLeft */
- NULL, /* font pointer or NULL for default */
- (UBYTE *)"HOLD", /* pointer to text */
- NULL /* next IntuiText structure */
- };
-
- struct Gadget Gadget6 = {
- &Gadget7, /* next gadget */
- 55,15, /* origin XY of hit box relative to window TopLeft */
- 34,48, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY, /* activation flags */
- BOOLGADGET, /* gadget type flags */
- (APTR)&Border6, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- &IText1, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- NULL, /* SpecialInfo structure */
- 6, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- UBYTE Gadget5SIBuff[17] =
- "Stromberger";
- struct StringInfo Gadget5SInfo = {
- Gadget5SIBuff, /* buffer where text will be edited */
- NULL, /* optional undo buffer */
- 0, /* character position in buffer */
- 17, /* maximum number of characters to allow */
- 0, /* first displayed character buffer position */
- 0,0,0,0,0, /* Intuition initialized and maintained variables */
- 0, /* Rastport of gadget */
- 0, /* initial value for integer gadgets */
- NULL /* alternate keymap (fill in if you set the flag) */
- };
-
- SHORT BorderVectors7[] = {
- 0,0,
- 239,0,
- 239,9,
- 0,9,
- 0,0
- };
- struct Border Border7 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors7, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget5 = {
- &Gadget6, /* next gadget */
- 121,55, /* origin XY of hit box relative to window TopLeft */
- 238,8, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY+STRINGCENTER, /* activation flags */
- STRGADGET, /* gadget type flags */
- (APTR)&Border7, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- (APTR)&Gadget5SInfo, /* SpecialInfo structure */
- 5, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- UBYTE Gadget4SIBuff[17] =
- "David R.";
- struct StringInfo Gadget4SInfo = {
- Gadget4SIBuff, /* buffer where text will be edited */
- NULL, /* optional undo buffer */
- 0, /* character position in buffer */
- 17, /* maximum number of characters to allow */
- 0, /* first displayed character buffer position */
- 0,0,0,0,0, /* Intuition initialized and maintained variables */
- 0, /* Rastport of gadget */
- 0, /* initial value for integer gadgets */
- NULL /* alternate keymap (fill in if you set the flag) */
- };
-
- SHORT BorderVectors8[] = {
- 0,0,
- 239,0,
- 239,9,
- 0,9,
- 0,0
- };
- struct Border Border8 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors8, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget4 = {
- &Gadget5, /* next gadget */
- 121,42, /* origin XY of hit box relative to window TopLeft */
- 238,8, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY+STRINGCENTER, /* activation flags */
- STRGADGET, /* gadget type flags */
- (APTR)&Border8, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- (APTR)&Gadget4SInfo, /* SpecialInfo structure */
- 4, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- UBYTE Gadget3SIBuff[17] =
- "By:";
- struct StringInfo Gadget3SInfo = {
- Gadget3SIBuff, /* buffer where text will be edited */
- NULL, /* optional undo buffer */
- 0, /* character position in buffer */
- 17, /* maximum number of characters to allow */
- 0, /* first displayed character buffer position */
- 0,0,0,0,0, /* Intuition initialized and maintained variables */
- 0, /* Rastport of gadget */
- 0, /* initial value for integer gadgets */
- NULL /* alternate keymap (fill in if you set the flag) */
- };
-
- SHORT BorderVectors9[] = {
- 0,0,
- 239,0,
- 239,9,
- 0,9,
- 0,0
- };
- struct Border Border9 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors9, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget3 = {
- &Gadget4, /* next gadget */
- 121,28, /* origin XY of hit box relative to window TopLeft */
- 238,8, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY+STRINGCENTER, /* activation flags */
- STRGADGET, /* gadget type flags */
- (APTR)&Border9, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- (APTR)&Gadget3SInfo, /* SpecialInfo structure */
- 3, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- UBYTE Gadget2SIBuff[17] =
- "Lightning Dial!";
- struct StringInfo Gadget2SInfo = {
- Gadget2SIBuff, /* buffer where text will be edited */
- NULL, /* optional undo buffer */
- 0, /* character position in buffer */
- 17, /* maximum number of characters to allow */
- 0, /* first displayed character buffer position */
- 0,0,0,0,0, /* Intuition initialized and maintained variables */
- 0, /* Rastport of gadget */
- 0, /* initial value for integer gadgets */
- NULL /* alternate keymap (fill in if you set the flag) */
- };
-
- SHORT BorderVectors10[] = {
- 0,0,
- 239,0,
- 239,9,
- 0,9,
- 0,0
- };
- struct Border Border10 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 3,0,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors10, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct Gadget Gadget2 = {
- &Gadget3, /* next gadget */
- 121,15, /* origin XY of hit box relative to window TopLeft */
- 238,8, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY+STRINGCENTER, /* activation flags */
- STRGADGET, /* gadget type flags */
- (APTR)&Border10, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- NULL, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- (APTR)&Gadget2SInfo, /* SpecialInfo structure */
- 2, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- SHORT BorderVectors11[] = {
- 0,0,
- 35,0,
- 35,49,
- 0,49,
- 0,0
- };
- struct Border Border11 = {
- -1,-1, /* XY origin relative to container TopLeft */
- 1,2,JAM1, /* front pen, back pen and drawmode */
- 5, /* number of XY vectors */
- BorderVectors11, /* pointer to XY vectors */
- NULL /* next border in list */
- };
-
- struct IntuiText IText2 = {
- 3,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 2,21, /* XY origin relative to container TopLeft */
- NULL, /* font pointer or NULL for default */
- (UBYTE *)"BYE!", /* pointer to text */
- NULL /* next IntuiText structure */
- };
-
- struct Gadget Gadget1 = {
- &Gadget2, /* next gadget */
- 11,15, /* origin XY of hit box relative to window TopLeft */
- 34,48, /* hit box width and height */
- NULL, /* gadget flags */
- RELVERIFY, /* activation flags */
- BOOLGADGET, /* gadget type flags */
- (APTR)&Border11, /* gadget border or image to be rendered */
- NULL, /* alternate imagery for selection */
- &IText2, /* first IntuiText structure */
- NULL, /* gadget mutual-exclude long word */
- NULL, /* SpecialInfo structure */
- 1, /* user-definable data */
- NULL /* pointer to user-definable data */
- };
-
- #define GadgetList1 Gadget1
-
- struct IntuiText IText8 = {
- 1,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 196,67, /* XY origin relative to container TopLeft */
- NULL, /* font pointer or NULL for default */
- (UBYTE *)"LIGHTNING DIAL!", /* pointer to text */
- NULL /* next IntuiText structure */
- };
-
- struct IntuiText IText7 = {
- 1,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 22,67, /* XY origin relative to container TopLeft */
- NULL, /* font pointer or NULL for default */
- (UBYTE *)"Wait ~Ticks:", /* pointer to text */
- &IText8 /* next IntuiText structure */
- };
-
- struct IntuiText IText6 = {
- 1,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 102,55, /* XY origin relative to container TopLeft */
- NULL, /* font pointer or NULL for default */
- (UBYTE *)"4:", /* pointer to text */
- &IText7 /* next IntuiText structure */
- };
-
- struct IntuiText IText5 = {
- 1,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 102,42, /* XY origin relative to container TopLeft */
- NULL, /* font pointer or NULL for default */
- (UBYTE *)"3:", /* pointer to text */
- &IText6 /* next IntuiText structure */
- };
-
- struct IntuiText IText4 = {
- 1,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 102,28, /* XY origin relative to container TopLeft */
- NULL, /* font pointer or NULL for default */
- (UBYTE *)"2:", /* pointer to text */
- &IText5 /* next IntuiText structure */
- };
-
- struct IntuiText IText3 = {
- 1,0,JAM2, /* front and back text pens, drawmode and fill byte */
- 102,15, /* XY origin relative to container TopLeft */
- NULL, /* font pointer or NULL for default */
- (UBYTE *)"1:", /* pointer to text */
- &IText4 /* next IntuiText structure */
- };
-
- #define IntuiTextList1 IText3
-
- struct NewWindow NewWindowStructure1 = {
- 127,65, /* window XY origin relative to TopLeft of screen */
- 377,78, /* window width and height */
- 1,2, /* detail and block pens */
- GADGETUP+GADGETDOWN, /* IDCMP flags */
- WINDOWDRAG+WINDOWDEPTH+ACTIVATE+NOCAREREFRESH, /* other window flags */
- &Gadget1, /* first gadget in gadget list */
- NULL, /* custom CHECKMARK imagery */
- (UBYTE *)"(C) 1989 CORNERSTONE SOFTWARE", /* window title */
- NULL, /* custom screen pointer */
- NULL, /* custom bitmap */
- 5,5, /* minimum width and height */
- -1,-1, /* maximum width and height */
- WBENCHSCREEN /* destination screen type */
- };
-
-
- /* end of PowerWindows source generation */
-
-
-
-
-
-
- VOID /* open the serial device. */
- Open_Serial()
- {
-
- /*
- just read "Amiga Programmers Handbook Volume II" if you want to know
- what all this stuff does.
-
- This program has two serial ports, one for reading, and one for
- writing. This will allow you to expand on this program with little
- trouble.
- */
-
- ReadSer_Req = (struct IOExtSer *)AllocMem((long)sizeof(*ReadSer_Req),MEMF_PUBLIC|MEMF_CLEAR);
- ReadSer_Req->io_SerFlags = SERF_SHARED|SERF_XDISABLED;
- ReadSer_Req->IOSer.io_Message.mn_ReplyPort = CreatePort("Read_RS",0);
- if(OpenDevice(SERIALNAME,NULL,ReadSer_Req,NULL))
- {
- puts("Can not open Read device.\n");
- DeletePort(ReadSer_Req->IOSer.io_Message.mn_ReplyPort);
- FreeMem(ReadSer_Req,(long)sizeof(*ReadSer_Req));
- exit(TRUE);
- }
- ReadSer_Req->IOSer.io_Command = CMD_READ;
- ReadSer_Req->IOSer.io_Length = 1L;
- ReadSer_Req->IOSer.io_Data = (APTR) &rs_in[0];
- WriteSer_Req = (struct IOExtSer *)AllocMem((long)sizeof(*WriteSer_Req),MEMF_PUBLIC|MEMF_CLEAR);
- WriteSer_Req->io_SerFlags = SERF_SHARED|SERF_XDISABLED;
- WriteSer_Req->IOSer.io_Message.mn_ReplyPort = CreatePort("Write_RS",0);
- if(OpenDevice(SERIALNAME,NULL,WriteSer_Req,NULL))
- {
- puts("Can not open Write device.\n");
- DeletePort(WriteSer_Req->IOSer.io_Message.mn_ReplyPort);
- FreeMem(WriteSer_Req,(long)sizeof(*WriteSer_Req));
- DeletePort(ReadSer_Req->IOSer.io_Message.mn_ReplyPort);
- FreeMem(ReadSer_Req,(long)sizeof(*ReadSer_Req));
- exit(TRUE);
- }
- WriteSer_Req->IOSer.io_Command = CMD_WRITE;
- WriteSer_Req->IOSer.io_Length = 1L;
- WriteSer_Req->IOSer.io_Data = (APTR) &rs_out[0];
- ReadSer_Req->io_SerFlags = SERF_SHARED|SERF_XDISABLED;
- ReadSer_Req->io_Baud = 1200L;
- ReadSer_Req->io_ReadLen = 8;
- ReadSer_Req->io_WriteLen = 8;
- ReadSer_Req->io_CtlChar = 1L;
- ReadSer_Req->IOSer.io_Command = SDCMD_SETPARAMS;
- DoIO(ReadSer_Req);
- ReadSer_Req->IOSer.io_Command = CMD_READ;
- BeginIO(ReadSer_Req);
- }
-
- VOID
- Close_Serial() /* close the serial port to be clean */
- {
- AbortIO(WriteSer_Req); /* make sure no messages are pending */
- CloseDevice(WriteSer_Req); /* close the write device */
- DeletePort(WriteSer_Req->IOSer.io_Message.mn_ReplyPort); /* kill it */
- FreeMem(WriteSer_Req,(long)sizeof(*WriteSer_Req)); /* free the mem */
-
- AbortIO(ReadSer_Req); /* do same as above exect for readser */
- CloseDevice(ReadSer_Req);
- DeletePort(ReadSer_Req->IOSer.io_Message.mn_ReplyPort);
- FreeMem(ReadSer_Req,(long)sizeof(*ReadSer_Req));
- }
-
- VOID
- Send_Char(character) /* send a character to the modem */
- char character;
- {
- rs_out[0] = character; /* put it in the buffer */
- DoIO(WriteSer_Req); /* dump it to the modem */
- }
-
- VOID /* dial a phone number */
- Dial(phone_number)
- char *phone_number; /* pointer to a phone number to dial */
- {
- int index=0;
- while(phone_number[index] != NULL) /* send it char by char */
- {
- Send_Char(phone_number[index]);
- index+=1;
- }
- }
-
- VOID
- DTR() /* hang up the modem via DTR bit */
- {
- struct CIA *cia_ptr; /* initialize a pointer to a CIA structure */
- cia_ptr = 0xBFD000; /* point at the cia register A (see the RKM ) */
- cia_ptr->ciaddra |= CIAF_COMDTR;
-
- cia_ptr->ciapra |= CIAF_COMDTR; /* set DTR to low value */
- Delay(5L);
- cia_ptr->ciapra &= ~CIAF_COMDTR; /* set DTR to high value */
- }
-
- VOID /* finish up and return to CLI */
- Go2Bed()
- {
- DTR(); /* make sure we don't try to dial again */
- Close_Serial(); /* close the serial ports */
- CloseLibrary(GfxBase);
- CloseLibrary(IntuitionBase); /* close the library we opened */
- CloseWindow(wd); /* close the window */
- exit(TRUE); /* exit to CLI */
- }
-
- VOID /* handle an intuition event */
- HandleEvent(object)
- struct Gadget *object;
- {
- long id;
-
- id = object->GadgetID; /* get the message */
-
- switch(id)
- {
- case 1: /* quit the program */
- Go2Bed(); /* good bye, and good night */
- break;
- case 6: /* hold button */
- nodialflag=!nodialflag; /* toggle dialing on and off */
- dloop=ticks;
- DTR(); Delay(25L); DTR();
- break;
- case 7: /* modify ticks */
- ticks = atol(Gadget7SIBuff);
- break;
- case 8: /* phone 1 */
- strcpy(phonenumber,Gadget2SIBuff); /* establish new phone num */
- nodialflag = FALSE;
- dloop=ticks;
- SetWindowTitles(wd,phonenumber,-1);
- break;
- case 9: /* phone 2 */
- nodialflag = FALSE;
- strcpy(phonenumber,Gadget3SIBuff); /* establish new phone num */
- dloop=ticks;
- SetWindowTitles(wd,phonenumber,-1);
- break;
- case 10: /* phone 3 */
- strcpy(phonenumber,Gadget4SIBuff); /* establish new phone num */
- nodialflag = FALSE;
- dloop=ticks;
- SetWindowTitles(wd,phonenumber,-1);
- break;
- case 11: /* phone 4 */
- strcpy(phonenumber,Gadget5SIBuff); /* establish new phone num */
- nodialflag = FALSE;
- dloop=ticks;
- SetWindowTitles(wd,phonenumber,-1);
- break;
- }
- }
-
- /** =============================================================== **/
-
- VOID /* main program, put it all together */
- main() /* get some args from CLI */
- {
- struct IntuiMessage *ms; /* pointer to an intuimessage structure */
- ULONG class;
- struct Gadget *object; /* gadget pointer */
-
-
-
- ticks = 180; /* default ticks */
-
- Open_Serial(); /* don't forget to open it up first */
- IntuitionBase=OpenLibrary("intuition.library",0L); /* open intuition */
- GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L);
-
- wd = OpenWindow(&NewWindowStructure1); /* open the window */
- rpG = wd->RPort; /* get a rastport pointer for the window */
- PrintIText(rpG,&IntuiTextList1,0L,0L); /* Print the text */
-
- nodialflag = TRUE; /* don't dial right off the bat */
-
- FOREVER
- { /* if its ok to dial... */
- if((nodialflag == FALSE)&&(phonenumber[0] != NULL))
- {
- Dial("ATDT"); /* at command */
- Dial(phonenumber); /* the number */
- Dial("\r");
- }
-
- for(dloop=0;dloop<ticks;dloop++) /* loop 'ticks' times */
- { /* get a message */
- if((ms=(struct IntuiMessage *)GetMsg(wd->UserPort))!=NULL)
- {
- object = (struct Gadget *)(ms->IAddress); /* Gadget */
- class = ms->Class;
- ReplyMsg(ms);
- if (( class == GADGETUP ) || /* Gagdets */
- ( class == GADGETDOWN ))
- { /* handle the message */
- HandleEvent(object);
- }
- }
- Delay(1L); /* tick */
- } /* if its ok to dial, then we need to do this first */
- if((nodialflag == FALSE)&&(phonenumber[0] != NULL))
- {
- DTR(); /* hang up the phone via dropping DTR */
- Delay(25L); /* let modem recover */
- }
- }
- }