home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 18
/
aminetcdnumber181997.iso
/
Aminet
/
comm
/
maxs
/
max_e.lha
/
MAXDoor.e
< prev
Wrap
Text File
|
1996-09-29
|
7KB
|
330 lines
/*
** Conversion of DoorStarter.asm into Amiga E
** By Mr Tickle/sPEARhEAD
**
** Use it, credit me if you like, i dont care if you dont, but it would
** be *NICE*.
**
** Contact me at: the.moosuck@borghome.demon.co.uk
*/
MODULE 'exec/tasks',
'exec/ports',
'exec/nodes',
'exec/lists',
'exec/types',
'amigalib/ports'
OBJECT doormsg
door_msg:mn,
command:INT,
data:INT,
string[80]:ARRAY OF CHAR,
carrier:INT
ENDOBJECT
-> PROC main() is simply the startup code... write your door in
-> PROC theDoor()
-> These are all neaded by the startup code
DEF msgportname[12]:STRING, msgportname2[10]:STRING, mport=NIL:PTR TO mp,
ourtask,cport=NIL:PTR TO mp, lost_carrier=0, wherefrom:PTR TO CHAR,
p1:doormsg
PROC main()
-> Grab the node number
StringF(msgportname,'DoorControl\c',Char(arg))
StringF(msgportname2,'DoorReply\c',Char(arg))
-> Make msg port & msg:
IF(mport:=createPort(msgportname2,0))
ourtask:=FindTask(NIL)
p1.door_msg.ln.type:=NT_MESSAGE
p1.door_msg.replyport:=mport
p1.door_msg.length:=SIZEOF doormsg
-> Find M A X's BBS door control port prt:
Forbid()
cport:=FindPort(msgportname)
Permit()
IF(cport>0)
-> Startup code complete!
theDoor()
-> Closedown code
p1.command:=20
p1.data:=0
putWaitMsg(p1)
ELSE
WriteF('This is a door for MAXs BBS systems!\n')
ENDIF
-> Clean up and return
deletePort(mport) -> Free port
ENDIF
ENDPROC
/**************************
** WRITE YOUR DOOR HERE! **
**************************/
PROC theDoor()
-> E-Strings for input and output...
DEF str[256]:STRING, istr[256]:STRING, blah1, blah2
-> How to print bilge
StringF(str,'\n\n\c[32mHello there! welcome to the AmigaE door!\n',27)
mxPrint(str)
-> Test carrier
IF(lost_carrier=1) THEN RETURN
-> How to read bilge
inputloop:
mxPrint('Enter some shit (CR to skip):\n')
mxInput(20,istr)
-> Test carrier
IF(lost_carrier=1) THEN RETURN
IF(StrLen(istr)>0)
StringF(str,'You entered: \s\n',istr)
mxPrint(str)
JUMP inputloop
ENDIF
-> How to print a file
mxPrint('Enter a textfile to print:\n')
mxInput(40,istr)
mxPrintFile(istr)
-> Test carrier
IF(lost_carrier=1) THEN RETURN
-> How to see if a file is online
mxPrint('Type a filename to check:\n')
mxInput(40,istr)
IF(mxCheckFile(istr)=1) -> Note: DO NOT CHECK FOR TRUE/FALSE, CHECK FOR 1
mxPrint('The file is online!\n\n')
ELSE
mxPrint('The file is not online!\n\n')
ENDIF
-> Test carrier
IF(lost_carrier=1) THEN RETURN
-> Userinfo
mxPrint('Here is some interesting information:\n')
mxGetStrInfo(1,istr) -> 1 = Name
StringF(str,'Name: \s\n',istr)
mxPrint(str)
mxGetStrInfo(2,istr) -> 2 = Password
StringF(str,'Password: \s\n',istr)
mxPrint(str)
mxGetStrInfo(3,istr) -> 3 = Suburb
StringF(str,'Suburb: \s\n',istr)
mxPrint(str)
mxGetStrInfo(100,istr) -> 100 = Phone #
StringF(str,'Phone number: \s\n',istr)
mxPrint(str)
mxGetStrInfo(101,istr) -> 101 = Computer
StringF(str,'Computer: \s\n',istr)
mxPrint(str)
mxGetStrInfo(102,istr) -> 102 = Comment
StringF(str,'Comment: \s\n',istr)
mxPrint(str)
mxGetStrInfo(7,istr) -> 7 = Door path
StringF(str,'Door path: \s\n',istr)
mxPrint(str)
mxGetStrInfo(8,istr) -> 8 = BBS path
StringF(str,'BBS path: \s\n',istr)
mxPrint(str)
mxGetStrInfo(9,istr) -> 9 = Date
StringF(str,'Date: \s\n',istr)
mxPrint(str)
mxGetStrInfo(10,istr) -> 10 = Time
StringF(str,'Time: \s\n',istr)
mxPrint(str)
-> Test carrier
IF(lost_carrier=1) THEN RETURN
-> How to twit
mxPrint('Whack <SPACE> to twit yerself...\n')
IF(blah1:=mxHotKey())=$20
mxTwit()
RETURN -> *ALWAYS* return from iansDoor() if carrier lost!
ENDIF
mxPrint('OK, dont then!\n')
-> how to read user information values
mxPrint('Enter the data number to get a user int value (1 - 110, CR - skip): ')
mxInput(3,istr)
IF(StrLen(istr)>0)
blah1:=mxGetIntInfo(Val(istr))
StringF(str,'Return value is: \d\n\n',blah1)
mxPrint(str)
ENDIF
-> Test carrier
IF(lost_carrier=1) THEN RETURN
-> how to write user information values
mxPrint('Enter the data number of the user int to change (1 - 15, CR - skip): ')
mxInput(2,istr)
IF(StrLen(istr)>0)
blah1:=Val(istr)
mxPrint('Enter a value to change it to: ')
mxInput(5,istr)
mxChangeUserInt(blah1,Val(istr))
ENDIF
-> Test carrier
IF(lost_carrier=1) THEN RETURN
-> how to do menu functions
mxPrint('Enter a menu function number (1 - 33, CR - skip): ')
mxInput(3,istr)
IF(StrLen(istr)>0)
blah1:=Val(istr)
mxPrint('Enter the extra value to use with this funct: ')
mxInput(5,istr)
blah2:=Val(istr)
mxPrint('Enter the Name/Filename/Dest string: ')
mxInput(42,istr)
mxMenuFunct(blah1,blah2,istr)
ENDIF
-> Test carrier
IF(lost_carrier=1) THEN RETURN
mxPrint('\n\nPress any key to return to the BBS!\n')
mxHotKey()
ENDPROC
-> Print a string
PROC mxPrint(str:PTR TO CHAR)
p1.command:=1
p1.data:=0
doCopy(p1.string,str)
putWaitMsg(p1)
ENDPROC
-> Input a string. NOTE: buffer *MUST* point to an E-String!!!!
PROC mxInput(maxlen:PTR TO INT,buffer)
DEF rt
p1.command:=6
p1.data:=maxlen
p1.string[]:=0
rt:=putWaitMsg(p1)
StrCopy(buffer,p1.string)
ENDPROC
-> Reads a key
-> Returns ASCII value
-> IF(wherefrom=0) its from the local terminal
-> IF(wherefrom=1) its from the remote terminal
PROC mxHotKey()
DEF rt
p1.command:=8
p1.data:=0
p1.string[]:=0
rt:=putWaitMsg(p1)
wherefrom:=Char(p1.string-1)
ENDPROC Char(p1.string)
-> Twit the user
PROC mxTwit()
p1.command:=9
putWaitMsg(p1)
ENDPROC
-> Print a text file
PROC mxPrintFile(filename)
p1.command:=10
p1.data:=0
doCopy(p1.string,filename)
putWaitMsg(p1)
ENDPROC
-> Check file is online
-> 1 if yes, -1 if no
PROC mxCheckFile(filename)
DEF rt
p1.command:=11
p1.data:=0
doCopy(p1.string,filename)
rt:=putWaitMsg(p1)
ENDPROC p1.data
-> Get user information values
PROC mxGetIntInfo(type:PTR TO INT)
p1.command:=13
p1.data:=type
p1.string[]:=0
putWaitMsg(p1)
ENDPROC p1.data
-> Get user/BBS strings
-> buffer *MUST* point to an E-String
PROC mxGetStrInfo(type,buffer)
p1.command:=14
p1.data:=type
p1.string[]:=0
putWaitMsg(p1)
StrCopy(buffer,p1.string)
ENDPROC
-> Do a maxs bbs menu function
PROC mxMenuFunct(menufunc,extra,string)
p1.command:=menufunc
p1.data:=extra
doCopy(p1.string,string)
putWaitMsg(p1)
ENDPROC
-> Change a user int value
-> MAXs BBS only!
PROC mxChangeUserInt(uint,value)
p1.command:=200
p1.data:=uint
p1.string[]:=value
putWaitMsg(p1)
ENDPROC
-> Wait for reply msg
-> returns ptr to string
PROC putWaitMsg(msg:PTR TO doormsg)
DEF rmsg
PutMsg(cport,msg)
waitloop:
WaitPort(mport)
IF(rmsg:=GetMsg(mport))=0 THEN JUMP waitloop
lost_carrier:=p1.carrier
ENDPROC rmsg
PROC doCopy(dest:PTR TO CHAR,src:PTR TO CHAR)
DEF c
FOR c:=0 TO StrLen(src)
PutChar(dest+c,Char(src+c))
ENDFOR
ENDPROC