MAXShell v1.01 - A door for running CLI based programs under M A X's BBS ~~~~~~~~~~~~~~ Based on TrShell, by Timothy Aston. Max's adaption by MPS '95! At last! Now Max's sysops can access a FULL remote CLI and access the huge range of CLI based doors available, such as Hack & Slash, Global War 2, and Contris! This door is pretty much a conversion of the original TAShell for TransAmiga BBS, by Timothy Aston (Which used much of the remote CLI code from the FIFO distribution), to a Max's compatible door. Extra Max's specific functionality has also been added. To run this door, you will need Matthew Dillon's 'fifo.library' and 'fifo-handler' installed. Just copy the included 'fifo.library' to libs: and 'fifo-handler' to l:, then add 'run >nil: ] [-c] [-d] [-e] [-f] ~~~~~~ [-s] [-t] Where: is an optional shell startup script. Use this for running games, etc. An example startup script could be: -----------------------------CUT HERE----------------------------- cd doors:globalwar globalwar %f ACCESS %l PAGELENGTH %p TIMELEFT %k endcli -----------------------------CUT HERE----------------------------- Max's autoinserts can be used in the script for supplying needed parameters to shell programs. (For example, the above will supply the user name to Global War, as needed). Note the ENDCLI - This is very important, or users will exit to the shell after quitting Global War! Also note that all scripts must be in DOORS:MAXSHELL/, and you obviously don't supply the path for this reason. The reason I did this was Max's Filename/Name/Dest/Path field doesn't have much room, so this will save characters! If a startup script filename isn't supplied, MAXShell will just give a shell... -c is a switch to filter out ^C's from the user. Same goes for the -d, -e and -f. You should always have -c and -d enabled, or users can break out of the startup script if they're quick enough, and enter CLI! -s is a switch to enable an additional conversion to the user name (%f). The supplied character will replace spaces in the user name. This prevents problems with command line parsing and spaces in certain programs. I suppose you could have used "%f" instead of %f in the script, but it's there if you want the feature! -t is a switch to enable an additional conversion to the user's remaining time (%k). The time value will me made to be 5 minutes lower. This will allow the CLI based program to exit (Based on this time limit) before the BBS will hang up, avoiding problems. Of course, this is only useful if the program supports time limits in the first place! (The usage is also shown when MAXShell isn't run as a door, ie. run from the CLI). Examples on BBS use of MAXShell: (Noticed that I made an MS: assign to DOORS:MAXSHELL - This is to save more characters in the Filename/Name/Dest/Path field, you'll probably run out of space if you don't do something similar!) Global War 2: (Assuning above example gw-startup is in DOORS:MAXSHELL/) Key: Function: Extra: Lo acc: Hi acc: G 34 0 10 10000 Filename/Name/Dest/Path: MS:MAXSHELL GW-STARTUP -c -d -s_ -t Standard CLI: Key: Function: Extra: Lo acc: Hi acc: Filename/Name/Dest/Path: ! 34 0 10000 10000 MS:MAXSHELL Notes: * Make sure you have a standard AmigaDOS shell (I had ZShell ~~~~~~ in my shell-startup, but will not work with FIFO: as far as I could see (In other words, the computer came up with some alert, and after I removed 'zsh' from my shell-startup, it didn't happen again!) * Yep, that bug mentioned below (By Tim Aston) does occur in my conversion, and yep, you guessed it, I haven't got the faintest clue on why it occurs! The solution is to use a different FIFO every time by creating the FIFO name via something like time() to make it unique every time a new one is opened! This is what I did in converting, and what was originally done in the TA scripts that invoked TaShell (TAShell doesn't run stand-alone like MAXShell does). * If a user drops carrier, the program simply sends a ^C to the FIFO shell, and exits. This is not always sufficient to stop the running shell program. MAXShell will return correctly, but the shell process will still be left running. This caused complications with the temporary shell-startup script I use (With the converted Max's auto-inserts), as it will still be in use (By the non-exiting shell), and thus can't be removed or changed (Which I needed to do: when another user accesses the door, the converted script must reflect the new username). A similar workaround was used as above to make a unique temporary filename every time. Don't worry about about RAM: filling up though, the problem only occurs when someone hangs up, or you twit the user. (And even then, only in certain cases). One 'locked-out' file occurs for each lost-carrier/twit. (Again, only in certain cases). This problem exists in the original TaShell also... If anyone knows a better way of handling this I'd like to know! * Max's special conversion characters (@, |, %) are not supported at this time - They were causing many problems, so they are printed verbatim. If you want to have support them, you can always have a go at modifying this source code! % should be reasonably easy to get working properly. The only precaution is to make sure that the program handles the % across a 'split' between blocks of output to the Max's screen... This has been implemented for escape codes already. * Some people have reported 'Stack Overflow' requesters when running MAXShell. This seemed to occur only when Max's is started from the Workbench, when I investigated the problem. As far as I can see, it is because new programs spawned from Max's when started from WB only have a stack of 4096 bytes, which is not enough for MAXShell. Under CLI, the new program spawned from Max's inherits the stack from the parent CLI (That Max's was run from). So, run Max's from the CLI (Make sure your CLI stack is at least 32768!) and you should have no problems. As from v1.01, I've compiled the program with the StackExtend option, so now, if the program runs out of stack, more should be automatically allocated. It should run from WB now! * Another wierd bug: The CLI process number below MAXShell's CLI will be suspended until MAXShell's CLI finishes. God knows why, it doesn't seem to harm anything, so I can't be bothered figuring this one out! Of course, as above, you could always try... * You might find that Max's Filename/Name/Dest/Path is too small for my command line examples. The best way is to make an MS: assign and/or rename MAXShell to MS, so to run it, only MS:MS is needed for the name, saving valuable characters. * Some doors require a RAW console for correct keyboard input, and don't set the shell to RAW mode automatically (It is an option in DLG's shell, so some programmers don't bother). Knot is an example of such a game that needs a RAW shell. I've included a little utility called MakeRaw, written by Christopher Masto, which sets the shell to RAW mode - Just include MR in your script, just before running the game. See MR.doc for more info. * Finally, the user's PAUSE flag is set to OFF during the duration of the door (To stop games like Hack & Slash having annoying 'Press Return...' prompts every screenfull of text), and returned to the user's original setting before exiting to the BBS. The PAUSE flag will stay OFF, if the user hangs up or is twitted. Contact: For whatever reason, contact me (Matthew Poole, Alias: MPS) via: ~~~~~~~~ EMAIL: mp@deakin.edu.au. BBS: See advertisement for my BBS below. MAX'sNET: 86:352/100 Finally: This program is hereby FREEWARE! You need not pay for it, as ~~~~~~~~ it's just something I hacked up to add a much needed feature to Max's BBS! Just be sure to distribute the files/archive as is, and if you change it, why not send the alterations you made to me, so I could incorporate them into the next version... I'm curious why someone hasn't done this door for Max's BBS before, as it was a pretty straightforward task even for me, (Well, I DID have the TAShell source, I suppose...) and I'm not what you'd call the best coder in the world, or the most knowledgable Max's guy around! Which reminds me, I must thank Greg Fitch for putting me on the right track about obtaining Max's user values. Call his BBS: Xyonics on (07)808-4806. I'm also (As you might have guessed!) distributing source as well. I hope I start a trend in doing this, as I found it difficult to find C source concerning Max's BBS, so would like to pass on the knowledge I gained in doing this door. All I ask is to credit me if you change the code, etc. and perhaps a bit of extra access on your BBS and/or perhaps a free registration of a shareware program you wrote. Have fun with MAXShell! Catch ya later, MPS! Program History: ~~~~~~~~~~~~~~~~ v1.0 - Initial Release v1.01 - Stack Overflow problem hopefully fixed (Compiled with StackExtend option in SAS/C). - Some display problems fixed (Partial escape codes, codes unsupported by Max's). - Improved Docs (Corrected, updated, and in a separate file). - Other stuff I've forgotten. BBS Advertisement: ~~~~~~~~~~~~~~~~~~ Here is the original TrShell.c introduction: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TrShell, by Timothy Aston This is put in the public domain as a simple example of how to use transamiga.library with TransAmiga. This was written with DICE but should easily be modified to other compilers. You should note however, that DICE opens most libraries automatically (including fifo.library). SAS users will probably have to generate #pragmas for transamiga.library and fifo.library. fifo.h is included with the FIFO distribution. BTW: Note that there does seem to be a persistent bug in this, it doesn't fully release the FIFO, any attempt to restart it with an already used FIFO name causes NewShell to hang. If you can figure out why this is, I'd really like to know.