README file for ID-handler (version 1.0 13-Jun-87) ================================================== This program and source are freely distributable, provided the file headers remain intact (i.e., my name is on them!!!). Ed Puckett accepts no responsibility for others' use of this program. ...but you shouldn't have any problems! WHAT IS THIS? ------------- ID-handler is an AmigaDOS device. It supports OPEN, CLOSE and READ. It is used to generate unique identifiers. Every time someone opens ID:, it generates a new 16 digit decimal number. This number can then be read (in ASCII) from the FileHandle obtained by opening ID:. EOF returns on all reads subsequent to reading the last digit. ID: starts with number 0000000000000000 and proceeds in sequence. You are guaranteed to get a unique number from it since it is a handler, and communication with it from two processes cannot collide. USAGE ----- You can use TYPE to access ID:, as in: TYPE ID: However, typical usage is in a program: char *gensym (sym, buf, bufsize) char *sym, *buf; int bufsize; { int symlen; BPTR fh; symlen= strlen (sym); if ( ((symlen + 1 + 16) > bufsize) || ((fh= Open ("ID:", MODE_OLDFILE)) == 0) ) return NULL; strcpy (buf, sym); Read (fh, (buf + symlen), 16); /* append digits to symbol */ buf[symlen + 16]= '\0'; Close (fh); return buf; } INSTALLATION ------------ 1. Perform the following: Copy ID-handler-l L:ID-handler-loader Copy ID-handler L:ID-handler 2. Add to S:Startup-Sequence (do not include !'s - they denote start of line): !Mount ID: !Type >NIL: ID: 3. Add to DEVS:Mountlist (do not include !'s - they denote start of line): !ID: Handler = L:ID-handler-loader ! Stacksize = 1000 ! Priority = 5 !# 4. Reboot NOTES ON INSTALLATION --------------------- * You can skip the reboot, and just perform the "Mount" and "Dir" from the startup-sequence manually. * After the "Type", the ID-handler is loaded into the system, and the files "L:ID-handler-loader" and "L:ID-handler" will not be accessed until the next reboot. This means you may remove them from L: if you want (until next reboot). I do this because I copy L: into Ram:. * TO CHANGE THE HANDLER NAME: change "ID:" to whatever you want (e.g., "NUM:") in the following 2 files: DEVS:Mountlist (1 occurrence) S:Startup-Sequence (2 occurrences) * Feel free to shorten or otherwise change the names "ID-handler-loader" and "ID-handler". Just be sure to reflect those changes in "S:Startup-Sequence" and "DEVS:Mountlist". WHAT IS THIS SILLY "LOADER" FILE? --------------------------------- According to _The_AmigaDOS_Manual_ (Bantam Books, Feb 1986), page 291: If you write your device handler in C, you cannot use the automatic load and process creation provided by the kernel. In this case you must load the code yourself . . . . Well, I know others have gotten around this, and I did, too. However, in my "prelude" version of the handler, I noticed that the handler would take about 3 seconds to "Mount" (after first access to it). This made me very nervous - visions of wild linking through memory, etc. The loader version mounts almost immediately. Anyway, due to my (possibly unfounded) paranoia, I instead use the BCPL-like assembly module "ID-handler-loader" which LoadSeg()'s ID-handler. There are undoubtedly better ways of handling this, but this works and, for me, it is not too annoying to put up with the extra file. COMPILATION ----------- The supplied C source files were compiled with Lattice v3.03. The assembly programs were assembled using the Commodore Assembler. I use an EXECUTE file "cc" to drive the compiler. It is supplied. INQUIRIES / COMMENTS / SUGGESTIONS ---------------------------------- Ed Puckett US Mail: MIT Branch PO - PO Box 61 Cambridge, MA 02139 E Mail: ...!ihnp4!mit-eddie!mit-oz!qix