home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 9
/
FreshFishVol9-CD2.bin
/
bbs
/
util
/
sslib-5.103.lha
/
SSLib
/
SS.i
< prev
next >
Wrap
Text File
|
1994-12-12
|
18KB
|
488 lines
; The Special Support Library
; (c) 1993,1994 Martin Mares, MJSoft System Software
; --------------------------------------------------------------------------
; Fields marked with 'R' are read-only, 'P' are private...
; Library Version
SSVer equ 5
; Library Vector Offsets
_FuncOffset set -30
Func macro *fname
_LVO\1 equ _FuncOffset
_FuncOffset set _FuncOffset-6
endm
; Program startup and exit
Func StartupInit ; (A0=StartupStruct,D7=WbMsg)
Func ExitCleanup ; ()
Func ExitError ; (A0=Text,A1=Params)
Func DisplayError ; (A0=Text,A1=Params)
Func DosError ; (A0=optional text,A1=Params)
Func ReportError ; (D0=ErrorCode,A1/D2/D3=Params)
Func TestBreak ; ()
; Miscellaneous services
Func Printf ; (A0=Text,A1=Params)
Func Puts ; (A0=Text)
Func PutsNL ; (A0=Text)
Func FormatStr ; (A0=Format,A1=Data,A2=DestBuf)
Func StrCat ; (A0=Dest,A1=Source) -> A0=AfterPtr
Func StrToL ; (A0=String)
Func ParseArgs ; (A0=Src,A1=Tmpl,A2=ExHelp,A3=StoreTo,
; D0=Flags)
; General tracking services
Func CreateResList ; ()
Func GetResList ; ()
Func FreeResList ; ()
Func FreeAllResLists ; ()
Func TrackObject ; (D0=type)
Func FreeObject ; (A0=tracker)
Func TrackRoutine ; (A0=routine,A1=args)
Func TrackExtd ; (D0=type,D1=extsize)
Func TrackSlave ; (A0=master,A1=slave)
; Special tracking services
Func TrackAllocMem ; (D0=size,D1=requirements)
Func TrackAlloc ; (D0=size)
Func TrackOpen ; (A0=name,D0=openmode)
Func TrackLock ; (A0=name,D0=lockmode)
Func TrackPort ; ()
Func TrackIoRq ; (A0=OptionalPort,D0=size or 0)
Func TrackSignal ; ()
Func TrackDevice ; (A0=DevName,A1=IORQ,D0=unit,D1=flags,
; A2=ErrorTable)
Func TrackLibrary ; (A0=LibName,D0=version)
Func TrackDosObject ; (D0=Type,A0=Tags)
; File operations
Func LoadFile ; (A0=name)
Func ChkRead ; (A0=tracker,A1=buffer,D0=size)
Func ChkWrite ; (A0=tracker,A1=buffer,D0=size)
; Hashed trees
Func InitHashTree ; (D0=NumBranches,D1=Flags)
Func AddHashItem ; (A0=HashTree,A1=Name,D0=DataSize)
Func FindHashItem ; (A0=HashTree,A1=Name)
; Filename manipulation
Func AddExtension ; (A0=Source,A1=Dest,A2=Ext,D0=MaxSize)
Func SetExtension ; (A0=Source,A1=Dest,A2=Ext,D0=MaxSize)
Func GetExtension ; (A0=FileName)
Func RemExtension ; (A0=FileName)
; Next generation of names ...
Func ChkDoIO ; (A0=Messsage,A1=DeviceTracker)
Func SimpleRequest ; (A0=Msg,A1=Params,A2=Gadgets)
; Private functions allowing SS extensions
Func AddSSExtens ; (A0=ExtNode)
Func RemSSExtens ; (A0=ExtNode)
; Version 3: Memory allocation with pools
Func TrackPool ; (D0=Quantum,D1=Threshold,D2=Flags)
Func PoolAlloc ; (A0=Pool,D0=size)
Func PoolFree ; (A0=Pool,A1=Address,D0=Size)
Func TrackLinPool ; (D0=Quantum,D1=Flags)
Func LinearAlloc ; (A0=Pool,D1=size)
Func LinearAllocN ; (A0=Pool,D1=size)
; Version 4: Sorting and misc
Func MergeResLists ; ()
Func CallBlock ; (A0=Routine,D0=LeaveResources)
Func QuickSort ; (A0=Field,D0=NumEl,D1=ElSize,A1=CFunc)
Func SortStrings ; (A0=Field,D0=NumEl)
Func SortLongs ; (A0=Field,D0=NumEl)
Func SortList ; (A0=List,A1=CompFunc)
Func SortListName ; (A0=List)
Func TrackAllocPub ; (D0=Size)
Func RelinkObject ; (A0=Object)
Func TestStack ; ()
; Version 5: Buffered I/O
Func TrackOpenBuf ; (A0=name,D0=openmode,D1=bufsize)
Func TrackOpenBufFH ; (A0=name,D0=openmode,D1=bufsize,D2=fh)
Func TrackBufHandle ; (A0=name,D0=openmode,D1=bufsize)
Func ChkTryRead ; (A0=tracker,A1=buffer,D0=size)
Func BGetByte ; (A2=tracker)
Func BGetWord ; (A2=tracker)
Func BGetLong ; (A2=tracker)
Func BPutByte ; (D0=char,A3=tracker)
Func BPutWord ; (D0=char,A3=tracker)
Func BPutLong ; (D0=char,A3=tracker)
Func BPutChar ; (D0=char,A3=tracker)
Func BPutString ; (A0=string,A3=tracker)
Func BGetString ; (A0=buf,D0=size,A2=tracker)
Func BPuts ; (A0=string,A3=tracker)
Func BPutsNL ; (A0=string,A3=tracker)
Func BGets ; (A0=buf,D0=size,A2=tracker)
Func BPrintf ; (A0=string,A1=data,A3=tracker)
Func BRead ; (A0=tracker,A2=buffer,D0=size)
Func BWrite ; (A0=tracker,A3=buffer,D0=size)
Func BSeek ; (A2=tracker,D0=offset)
Func BRelSeek ; (A2=tracker,D0=offset)
Func BTell ; (A2=tracker)
Func BUnGetc ; (D0=char,A2=tracker)
Func BFlush ; (A2=tracker)
; And some additional services:
Func IPAlloc ; (D0=size)
Func IPFree ; (A1=address,D0=size)
; System Variables
_SysVarCnt set 0
SysVar macro *size,name
_SysVarCnt set _SysVarCnt-\1
\2 equ _SysVarCnt
endm
SysVar 0,ssbase ;R Library base
SysVar 4,sv_basesize ;P Size of system vars + user data above
SysVar 4,sv_wbmsg ;R Workbench message (0=CLI)
SysVar 4,sv_thistask ;R Pointer to task node
SysVar 4,sv_errsp ;R Stack pointer to program return address
SysVar 4,sv_checkbase ;P Base checkpoint - (0-BaseAddress)
SysVar 4,dosbase ;R Dos base
SysVar 4,intuitionbase ;R Intuition base
SysVar 4,gfxbase ;R Graphics base
SysVar 4,gadtoolsbase ;R Gadtools base
SysVar 4,utilitybase ;R Utility base
SysVar 4,stdin ; Standard input stream
SysVar 4,stdout ; Standard output stream
SysVar 4,stderr ; Standard error stream
SysVar 4,sv_errsw ; Error switches (bitmap)
SysVar 4,sv_progname ; Program name
SysVar 4,sv_errrc ; ReturnCode for error, default=10
SysVar 12,sv_reslistlist ;P A list of resource lists
SysVar 8,sv_callernode ;P Node of CallerList
SysVar 4,sv_rc ; ReturnCode
SysVar 4,sv_wbcon ;P Workbench console
SysVar 4,sv_template ;P Program template
SysVar 4,sv_extrahelp ;P Program extra help string
SysVar 4,sv_envvar ;R Environment variable name
SysVar 4,sv_exitrout ; Subroutine called before res.freeing
; (this pointer is cleared before calling)
SysVar 4,sv_msgrout ; Error message routine
; (this pointer is cleared before calling)
SysVar 4,sv_oldexcept ;P Pointer to original exception routine
SysVar 4,sv_flags ; Various flags (see below)
SysVar 4,sv_argdest ;P Address to store arguments at
SysVar 4,sv_iconbase ;P Pointer to IconBase
SysVar 4,sv_usertrk ; Pointer to UserTrkTypes structure or 0
SysVar 24,sv_mempool ;P Task memory pool
SysVar 4,sv_lowmem ; Routine to be called when out of mem.
SysVar 4,sv_stklimit ; The lowest allowed SP value
SysVar 4,sv_defstderr ;P Default stderr or 0
SysVar 4,sv_memattr ; Memory attributes for TrackAllocPub
SysVar 0,sv_sizeof ; Size of system variables block
; Flags in sv_flags
svfb_nowbargs equ 0 ; Ignore WB arguments
svfb_noprogname equ 1 ; Don't print program's name in CLI error msgs
svfb_errorreq equ 2 ; Always use requesters for error msgs
svfb_intrap equ 3 ;P Running trap handler
svfb_nostderr equ 4 ;P sst_nostderr specified
svfb_noiconarg equ 5 ; Don't pass names of multiselected icons as arg #1
svfb_nocliargs equ 6 ; Pass CLI arguments directly w/o processing
svfb_dontfree equ 7 ;P Don't free memory from task mempool
svfm_nowbargs equ 1
svfm_noprogname equ 2
svfm_errorreq equ 4
svfm_intrap equ 8
svfm_nostderr equ 16
svfm_noiconarg equ 32
svfm_nocliargs equ 64
svfm_dontfree equ 128
; SS.library Base
_LibCnt set LIB_SIZE
LibVar macro *size,name
ssb_\2 equ _LibCnt
_LibCnt set _LibCnt+\1
endm
LibVar 4,seglist ;P SegList
LibVar 2,ksversion ;R Kickstart version
LibVar 1,flags ; Some flags (see below)
LibVar 1,pad ;P Not used yet
LibVar 4,dosbase ;R DosBase
LibVar 4,intuibase ;R IntuitionBase
LibVar 4,gfxbase ;R GraphicsBase
LibVar 4,gadtoolsbase ;R GadtoolsBase
LibVar 4,utilitybase ;R UtilityBase
LibVar 12,callerlist ;P A list of callers -used for crash recovery
LibVar 1,cputype ;R CPU type (see tags for IDs)
LibVar 1,fputype ;R FPU type ( -- "" -- )
LibVar 16,extlist ;P SS Extensions
LibVar 2,opencnt ;P Private OpenCount
LibVar SS_SIZE,callis ;P Callerlist semaphore
LibVar 0,sizeof
; Flags in ssb_flags
SSB_allow30 equ 0 ;R KS 3.0 services can be used
; Startup structure
pa_varsize equ 0 ; Size of user's variables, incl. ssbase
pa_reqssver equ 2 ; Required version of ss.library
pa_firsttag equ 4 ; First tag
; Tag types
sstag_old equ $0000 ; Old SSLib tags
sstag_ext equ $4000 ; Extended tags
sstag_std equ $8000 ; Standard tags (two longwords)
sstag_new equ $C000 ; New tags (ignored when not understood)
sstag_nopar equ $0000 ; No parameters or special processing
sstag_wor