home *** CD-ROM | disk | FTP | other *** search
- Well, you've decided to try looking at the code for this little set of
- programs have you, Good luck, you'll need it
-
- Outline program description
- There are two components, psion which is a program that runs on the
- sun and is composed of a number of source files under the code
- directory and suncom which is a program that runs on the psion and is
- comprised of one source code file in the suncom directory
-
- Compilation
- The psion program should just compile directly on a Solaris 2.x
- machine and it should compile on a Solaris 1 machine, just ensure that
- you have all the files from the SCCS (if you have the full source) and
- use the Makefile provided. I haven't put any clever things in place
- like auto conf files etc to handle different vendors machines as I
- only have access to Sun machines (Well what do you expect for a Sun
- employe)
- The suncom program needs to be compiled in a different way because
- unix and dos have different understandings of how lines end (CR/LF vs
- CR) and I write the suncom program on the Sun and manage it under SCCS
- the first stage is to convert the end of line stuff. Suns have a
- program called unix2dos that does this. If your machine does not
- support this it should have something equivalent (assuming its a real
- unix machine). Once the program has been converted it needs to be
- compiled using the psion software development environment (Available
- from psion for around 300 pounds I think) I do this using SunPC a pc
- emulation which runs on my workstation. to compile suncom just type
- tsc /m suncom (assuming the compilers, redirect files etc are
- correctly setup) and it will produce the file suncom.img. I then cheat
- a little for ease of use and transfer the suncom.img file to the psion
- using the psion mclink software, also running under the pc emulation,
- it's just quicker and easier as I already have the PC emulation up and
- running, certainly there are other ways, older versions of suncom or
- xmodem could equaly well be used
-
- Protocols
- A brief description of the protocols used betweern the sun and psion
- (low and high level) is provided in the file protocols in the code
- directory.
-
- Suncom internal structure
- Suncom is a very simple program it is intended to be used as a server
- process. The main code routine gets a line of data representing the
- command (a two character string) and then runs through a very large
- set of if statements (effectivly this is realy a switch) to determine
- which function to call.
- One critical point to note is that most commands dont have an
- associated path name, they rely instead on a pathname (the string is
- sunname internaly) that is set using another call. This should in
- theory reduce the data transfered is a sequence of commands are called
- that use the same pathname (e.g. file status, file size, get is a
- reasonable sequence)
- You should nots that some routines inside suncom are left over and
- don't get called by the current version of psion. They are left in
- there for compatibility with older versions of the same release or are
- just there due to me being lazy and not removing them.
-
- Psion internal structure
- The internal structure of the psion program is somewhat more
- complicated. There are a set of routines matching the suncom routines
- to do the low level transfers, These are all named with the two letter
- command code preceded by the letters ps. There are also higher level
- routines that call multiple lower lefel commands, for example to send
- a file to the psion the file must be removed on the pasion if it
- exists before the transfer occurs thus the put foutines check the
- files existance, remove it if required and then transfer the new file.
- All the routines that talk directy to the psion and their immediate
- higher level routings are in the pslib.c file
- The main code section is in the psmain.c file. This consists of the
- command interpreter and the internal routines it calls. These routines
- are prefixed with the characters cm.
- The command interpreter is designed to be easily extensibe, The commands
- are defined in a list containing the text of the command string, the
- function to call, the number of arguments the function can take (max and
- min) allong with information on usage and help. The interpreter recieves
- a string, breaks it down into arguments, does variable substiution and
- then calls the specified function. (See the man page for more information
- on this process). The command interpreter uses the unix argc and argv process
- to transfer parameters.
- Variables are held in a linked list comprising of the variable name and its value
- There issupport for multiple levels of variables allowing scripts to have their
- own sets of variables. This is implemented by having a linked list of variable
- levels, When a script is run a new level is created and variables are copied from
- the previous level to act as a starting point. Once the script is completed the
- current level of variables is destroyed and the previous level is used.
- The code for variables is in the file psvar.c
- File filters allowing automatic file conversion are also held in a linked list
- This is a single linked list and does not get duplicated when a script is
- started. The code for this list is held in the file psfilt.c
- The bacup code is held in the file psbackup.c This provides support for building
- a recursive list of files to backup and then operates on this list.
- The backup subsystem allows for the setting of excludsed files. These are also held
- in a linked list that does not get duplicated when scripts are run. The code to
- support this is in the file psexclude.c
-
- Programming notes
- If adding additional functions the existing structure should be followed. To
- protect against differing versions of pson and suncom new psion functions
- should have checks to compare the version number of the suncom with the
- required version. Code is provided to compare these (psvsncmp etc) Examples
- of this are provided in the cmcs code which checks that suncom has support
- for checksums.
-
- Unused code
- Looking at the code directory you will note that these is some code that
- provides functionality that is not available from the command interpreter.
- The best example of this is the code in psxmodem.c In most cases this is
- code that is is the process of being developed but has not yet been gotten
- working but has been integreated. Please feel free to play with this code
- but be warned, it may do some nasty things to either filesystem of the
- internal data structures of the programs
-
- Program Modifications
- The entire code is held under SCCS. If you are intending to modify or
- enhance the functionality of the system you will need the SCCS directories
- to help manage this, I would suggest thay you create a seperate SCCS branch.
- If you are just going to compile the code on your machine you will only need
- the smallcource distribution.
- If you add aditioinal functionality or fixes to the system I would be
- interested to know about the changes you make and integrate them into
- the next release. If a funcation is usefull to you it may be of use to
- others.
- One modification area I'd be very interested in is if anyone feels like
- taking on the challenge of creating a decent command interpreter or
- integrating the code into tcl (I'm afraid that I onbly hack this code
- around in my spare time, being a Sun SE it somewhat time consuming!)
-
- Porting to other platforms
- This code should port to any SVR4 based system with no changes and should
- conmpile and run on BSD based systems. The only area that may cause
- difficulties is in the psinitline code. This may contain ioctl settings
- that are non portable. I know that SGI machines have some problems with these
- and I'm not entirly sure that these settings come from BSD or SVR4.
-
- Support
- This is a unsupported product. Whilst I will try to help fix bugs and
- provide limited porting support I can't guarentee it. I will definatly
- try to help if people want to extend te functionality.
-
- Future compatibility
- I try to guarentee that minor version changes of psion and suncom will be
- compatable. I.e. if a new function is added to psion it checks that the
- version of suncom supports the functionality. Major version number changes
- can mean that anything changes usualy the low level protocols though this is
- minimised if possible. For moving between V2.x and V3.x for example the low
- level protocol was reved to provide limited checksum support. However
- it a new checksum format was implemented this would not nessiceraly require
- a major version number. The protocol would start using the existing protocol
- check that suncom supported the new checksum and then issued a command to
- switch to the new checksum mechanism.
- If you are interested the difference between V1 and V2 was that the
- script language moved from setting the drive, directory and filename seperatly
- to settinbg them at once. This means that script files had to be changed
- as well as the protocol. For V2 to V3 the scripting language remained the
- same
-