home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / comm / maxs / max_e.lha / MAXDoor.e < prev   
Text File  |  1996-09-29  |  7KB  |  330 lines

  1. /*
  2. ** Conversion of DoorStarter.asm into Amiga E
  3. ** By Mr Tickle/sPEARhEAD
  4. **
  5. ** Use it, credit me if you like, i dont care if you dont, but it would
  6. ** be *NICE*.
  7. **
  8. ** Contact me at: the.moosuck@borghome.demon.co.uk
  9. */
  10.  
  11. MODULE 'exec/tasks',
  12.        'exec/ports',
  13.        'exec/nodes',
  14.        'exec/lists',
  15.        'exec/types',
  16.        'amigalib/ports'
  17.  
  18. OBJECT doormsg
  19.   door_msg:mn,
  20.   command:INT,
  21.   data:INT,
  22.   string[80]:ARRAY OF CHAR,
  23.   carrier:INT
  24. ENDOBJECT
  25.  
  26. -> PROC main() is simply the startup code... write your door in
  27. -> PROC theDoor()
  28.  
  29. -> These are all neaded by the startup code
  30. DEF msgportname[12]:STRING, msgportname2[10]:STRING, mport=NIL:PTR TO mp,
  31.     ourtask,cport=NIL:PTR TO mp, lost_carrier=0, wherefrom:PTR TO CHAR,
  32.     p1:doormsg
  33.  
  34. PROC main()
  35.  
  36.   -> Grab the node number
  37.   StringF(msgportname,'DoorControl\c',Char(arg))
  38.   StringF(msgportname2,'DoorReply\c',Char(arg))
  39.  
  40.   -> Make msg port & msg:
  41.   IF(mport:=createPort(msgportname2,0))
  42.  
  43.     ourtask:=FindTask(NIL)
  44.  
  45.     p1.door_msg.ln.type:=NT_MESSAGE
  46.     p1.door_msg.replyport:=mport
  47.     p1.door_msg.length:=SIZEOF doormsg
  48.  
  49.     -> Find  M A X's BBS door control port prt:
  50.  
  51.     Forbid()
  52.     cport:=FindPort(msgportname)
  53.     Permit()
  54.     IF(cport>0)
  55.       
  56.       -> Startup code complete!
  57.       theDoor()
  58.  
  59.       -> Closedown code
  60.       p1.command:=20
  61.       p1.data:=0
  62.       putWaitMsg(p1)
  63.     ELSE
  64.       WriteF('This is a door for MAXs BBS systems!\n')
  65.     ENDIF
  66.  
  67.     -> Clean up and return
  68.     deletePort(mport)           -> Free port
  69.   ENDIF
  70. ENDPROC
  71.  
  72. /**************************
  73. ** WRITE YOUR DOOR HERE! **
  74. **************************/
  75.  
  76. PROC theDoor()
  77.  
  78.   -> E-Strings for input and output...
  79.   DEF str[256]:STRING, istr[256]:STRING, blah1, blah2
  80.   
  81.   -> How to print bilge
  82.   StringF(str,'\n\n\c[32mHello there! welcome to the AmigaE door!\n',27)
  83.   mxPrint(str)
  84.  
  85.   -> Test carrier
  86.   IF(lost_carrier=1) THEN RETURN
  87.  
  88.   -> How to read bilge
  89. inputloop:
  90.   mxPrint('Enter some shit (CR to skip):\n')
  91.   mxInput(20,istr)
  92.   
  93.   -> Test carrier
  94.   IF(lost_carrier=1) THEN RETURN
  95.  
  96.   IF(StrLen(istr)>0)
  97.     StringF(str,'You entered: \s\n',istr)
  98.     mxPrint(str)
  99.     JUMP inputloop
  100.   ENDIF
  101.  
  102.   -> How to print a file
  103.   mxPrint('Enter a textfile to print:\n')
  104.   mxInput(40,istr)
  105.   mxPrintFile(istr)
  106.   
  107.   -> Test carrier
  108.   IF(lost_carrier=1) THEN RETURN
  109.  
  110.  
  111.   -> How to see if a file is online
  112.   mxPrint('Type a filename to check:\n')
  113.   mxInput(40,istr)
  114.   IF(mxCheckFile(istr)=1) -> Note: DO NOT CHECK FOR TRUE/FALSE, CHECK FOR 1
  115.     mxPrint('The file is online!\n\n')
  116.   ELSE
  117.     mxPrint('The file is not online!\n\n')
  118.   ENDIF
  119.   
  120.   -> Test carrier
  121.   IF(lost_carrier=1) THEN RETURN
  122.  
  123.   -> Userinfo
  124.   mxPrint('Here is some interesting information:\n')
  125.   mxGetStrInfo(1,istr)   -> 1 = Name
  126.   StringF(str,'Name: \s\n',istr)
  127.   mxPrint(str)
  128.   
  129.   mxGetStrInfo(2,istr)   -> 2 = Password
  130.   StringF(str,'Password: \s\n',istr)
  131.   mxPrint(str)
  132.   
  133.   mxGetStrInfo(3,istr)   -> 3 = Suburb
  134.   StringF(str,'Suburb: \s\n',istr)
  135.   mxPrint(str)
  136.   
  137.   mxGetStrInfo(100,istr) -> 100 = Phone #
  138.   StringF(str,'Phone number: \s\n',istr)
  139.   mxPrint(str)
  140.  
  141.   mxGetStrInfo(101,istr) -> 101 = Computer
  142.   StringF(str,'Computer: \s\n',istr)
  143.   mxPrint(str)
  144.   
  145.   mxGetStrInfo(102,istr) -> 102 = Comment
  146.   StringF(str,'Comment: \s\n',istr)
  147.   mxPrint(str)
  148.   
  149.   mxGetStrInfo(7,istr)   -> 7 = Door path
  150.   StringF(str,'Door path: \s\n',istr)
  151.   mxPrint(str)
  152.       
  153.   mxGetStrInfo(8,istr)   -> 8 = BBS path
  154.   StringF(str,'BBS path: \s\n',istr)
  155.   mxPrint(str)
  156.   
  157.   mxGetStrInfo(9,istr)   -> 9 = Date
  158.   StringF(str,'Date: \s\n',istr)
  159.   mxPrint(str)
  160.   
  161.   mxGetStrInfo(10,istr)  -> 10 = Time
  162.   StringF(str,'Time: \s\n',istr)
  163.   mxPrint(str)  
  164.   
  165.   -> Test carrier
  166.   IF(lost_carrier=1) THEN RETURN
  167.  
  168.   -> How to twit
  169.   mxPrint('Whack <SPACE> to twit yerself...\n')
  170.   IF(blah1:=mxHotKey())=$20
  171.     mxTwit()
  172.     RETURN -> *ALWAYS* return from iansDoor() if carrier lost!
  173.   ENDIF
  174.  
  175.   mxPrint('OK, dont then!\n')
  176.  
  177.   -> how to read user information values
  178.   mxPrint('Enter the data number to get a user int value (1 - 110, CR - skip): ')  
  179.   mxInput(3,istr)
  180.   IF(StrLen(istr)>0)
  181.     blah1:=mxGetIntInfo(Val(istr))
  182.     StringF(str,'Return value is: \d\n\n',blah1)
  183.     mxPrint(str)
  184.   ENDIF
  185.  
  186.   -> Test carrier
  187.   IF(lost_carrier=1) THEN RETURN
  188.  
  189.   -> how to write user information values
  190.   mxPrint('Enter the data number of the user int to change (1 - 15, CR - skip): ')
  191.   mxInput(2,istr)
  192.   IF(StrLen(istr)>0)
  193.     blah1:=Val(istr)
  194.     mxPrint('Enter a value to change it to: ')
  195.     mxInput(5,istr)
  196.     mxChangeUserInt(blah1,Val(istr))
  197.   ENDIF
  198.  
  199.   -> Test carrier
  200.   IF(lost_carrier=1) THEN RETURN
  201.  
  202.   -> how to do menu functions
  203.   mxPrint('Enter a menu function number (1 - 33, CR - skip): ')
  204.   mxInput(3,istr)
  205.   IF(StrLen(istr)>0)
  206.     blah1:=Val(istr)
  207.     mxPrint('Enter the extra value to use with this funct: ')
  208.     mxInput(5,istr)
  209.     blah2:=Val(istr)
  210.     mxPrint('Enter the Name/Filename/Dest string: ')
  211.     mxInput(42,istr)
  212.     mxMenuFunct(blah1,blah2,istr)    
  213.   ENDIF
  214.   
  215.   -> Test carrier
  216.   IF(lost_carrier=1) THEN RETURN
  217.  
  218.   mxPrint('\n\nPress any key to return to the BBS!\n')
  219.   mxHotKey()
  220. ENDPROC
  221.  
  222. -> Print a string
  223. PROC mxPrint(str:PTR TO CHAR)
  224.   p1.command:=1
  225.   p1.data:=0
  226.   doCopy(p1.string,str)
  227.   putWaitMsg(p1)
  228. ENDPROC
  229.  
  230. -> Input a string. NOTE: buffer *MUST* point to an E-String!!!!
  231. PROC mxInput(maxlen:PTR TO INT,buffer)
  232.   DEF rt
  233.   p1.command:=6
  234.   p1.data:=maxlen
  235.   p1.string[]:=0
  236.   rt:=putWaitMsg(p1)
  237.   StrCopy(buffer,p1.string)
  238. ENDPROC
  239.  
  240. -> Reads a key
  241. -> Returns ASCII value
  242. -> IF(wherefrom=0) its from the local terminal
  243. -> IF(wherefrom=1) its from the remote terminal
  244. PROC mxHotKey()
  245.   DEF rt
  246.   p1.command:=8
  247.   p1.data:=0
  248.   p1.string[]:=0
  249.   rt:=putWaitMsg(p1)
  250.   wherefrom:=Char(p1.string-1)
  251. ENDPROC Char(p1.string)
  252.  
  253. -> Twit the user
  254. PROC mxTwit()
  255.   p1.command:=9
  256.   putWaitMsg(p1)
  257. ENDPROC
  258.  
  259. -> Print a text file
  260. PROC mxPrintFile(filename)
  261.   p1.command:=10
  262.   p1.data:=0
  263.   doCopy(p1.string,filename)
  264.   putWaitMsg(p1)
  265. ENDPROC
  266.  
  267. -> Check file is online
  268. -> 1 if yes, -1 if no
  269. PROC mxCheckFile(filename)
  270.   DEF rt
  271.   p1.command:=11
  272.   p1.data:=0
  273.   doCopy(p1.string,filename)
  274.   rt:=putWaitMsg(p1)
  275. ENDPROC p1.data  
  276.  
  277. -> Get user information values
  278. PROC mxGetIntInfo(type:PTR TO INT)
  279.   p1.command:=13
  280.   p1.data:=type
  281.   p1.string[]:=0
  282.   putWaitMsg(p1)
  283. ENDPROC p1.data
  284.  
  285. -> Get user/BBS strings
  286. -> buffer *MUST* point to an E-String
  287. PROC mxGetStrInfo(type,buffer)
  288.   p1.command:=14
  289.   p1.data:=type
  290.   p1.string[]:=0
  291.   putWaitMsg(p1)
  292.   StrCopy(buffer,p1.string)
  293. ENDPROC
  294.   
  295. -> Do a maxs bbs menu function
  296. PROC mxMenuFunct(menufunc,extra,string)
  297.   p1.command:=menufunc
  298.   p1.data:=extra
  299.   doCopy(p1.string,string)
  300.   putWaitMsg(p1)
  301. ENDPROC
  302.  
  303. -> Change a user int value
  304. -> MAXs BBS only!
  305. PROC mxChangeUserInt(uint,value)
  306.   p1.command:=200
  307.   p1.data:=uint
  308.   p1.string[]:=value
  309.   putWaitMsg(p1)
  310. ENDPROC
  311.       
  312. -> Wait for reply msg
  313. -> returns ptr to string
  314.  
  315. PROC putWaitMsg(msg:PTR TO doormsg)
  316.   DEF rmsg
  317.   PutMsg(cport,msg)
  318. waitloop:
  319.   WaitPort(mport)
  320.   IF(rmsg:=GetMsg(mport))=0 THEN JUMP waitloop
  321.   lost_carrier:=p1.carrier
  322. ENDPROC rmsg  
  323.  
  324. PROC doCopy(dest:PTR TO CHAR,src:PTR TO CHAR)
  325.   DEF c
  326.   FOR c:=0 TO StrLen(src)
  327.     PutChar(dest+c,Char(src+c))
  328.   ENDFOR
  329. ENDPROC
  330.