home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
wps
/
editor
/
epmtools
/
epmsmp
/
doscalls.e
< prev
next >
Wrap
Text File
|
1993-02-23
|
33KB
|
780 lines
; The following contains examples of a number of DYNALINK calls to
; the OS/2 functions in DOSCALLS and DOSCALL1. Extract and use in
; your own routines.
; By Larry Margolis
/* [\toolktxx\c\include\doscalls.h]
Function Name Ordinal Value
------------- -------------
DBGETKVAR 109
DBGETOWNER 117
DBMEMFREE 116
DBMEMLOCK 112
DBMEMREALLOC 115
DBMEMUNLOCK 113
DBPHYSINFO 118
DBSEGALLOC 114
DOSALLOCHUGE 40
DOSALLOCSEG 34
DOSALLOCSHRSEG 35
DOSBEEP 50
DOSBUFRESET 56
DOSCALLBACK 157
DOSCHDIR 57
DOSCHGFILEPTR 58
DOSCLIACCESS 51
DOSCLOSE 59
DOSCLOSESEM 23
DOSCREATECSALIAS 43
DOSCREATESEM 24
DOSCWAIT 2
DOSDELETE 60
DOSDEVCONFIG 52
DOSDEVIOCTL 53
DOSDEVIOCTL2 99
DOSDUPHANDLE 61
DOSENTERCRITSEC 3
DOSENUMATTRIBUTE 204
DOSERROR 120
DOSEXIT 5
DOSEXITCRITSEC 6
DOSEXITLIST 7
DOSFILELOCKS 62
DOSFINDCLOSE 63
DOSFINDFIRST 64
DOSFINDNEXT 65
DOSFLAGPROCESS 15
DOSFREEMODULE 46
DOSFREESEG 39
DOSGETCP 130
DOSGETDATETIME 33
DOSGETENV 91
DOSGETHUGESHIFT 41
DOSGETINFOSEG 8
DOSGETMACHINEMODE 49
DOSGETMODHANDLE 47
DOSGETMODNAME 48
DOSGETPID 94
DOSGETPROCADDR 45
DOSGETPRTY 9
DOSGETSEG 121
DOSGETSHRSEG 36
DOSGETSTDA 119
DOSGETVERSION 92
DOSGIVESEG 37
DOSGLOBALSEG 132
DOSHOLDSIGNAL 13
DOSHUGEINCR 136
DOSHUGESHIFT 135
DOSICANONICALIZE 100
DOSICREATETHREAD 1
DOSIEXECPGM 4
DOSIRAMSEMWAKE 125
DOSIREAD 79
DOSISEMREQUEST 18
DOSISEMWAIT 21
DOSISETCP 131
DOSISYSSEMCLEAR 17
DOSISYSSEMSET 19
DOSIWRITE 87
DOSKILLPROCESS 10
DOSLIBINIT 96
DOSLOADMODULE 44
DOSLOCKSEG 122
DOSMAKEPIPE 16
DOSMEMAVAIL 127
DOSMKDIR 66
DOSMOVE 67
DOSMUXSEMWAIT 22
DOSNEWSIZE 68
DOSOPEN 70
DOSOPEN2 95
DOSOPENSEM 25
DOSPHYSICALDISK 129
DOSQPATHINFO 98
DOSSETPATHINFO 104
DOSPOKETESTDAEMON 104
DOSPORTACCESS 69
DOSPROFILE 133
DOSPTRACE 12
DOSQCURDIR 71
DOSQCURDISK 72
DOSQFHANDSTATE 73
DOSQFILEINFO 74
DOSQFILEMODE 75
DOSQFSINFO 76
DOSQHANDTYPE 77
DOSQPROCSTATUS 154
DOSQTRACEINFO 93
DOSQVERIFY 78
DOSREADPHYS 103
DOSREALLOCHUGE 42
DOSREALLOCSEG 38
DOSRESUMETHREAD 26
DOSRMDIR 80
DOSSELECTDISK 81
DOSSEMSETWAIT 20
DOSSENDSIGNAL 134
DOSSETCP 153
DOSSETDATETIME 28
DOSSETFGND 101
DOSSETFHANDSTATE 82
DOSSETFILEINFO 83
DOSSETFILEMODE 84
DOSSETFSINFO 97
DOSSETINFOSEG 128
DOSSETMAXFH 85
DOSSETPRTY 11
DOSSETSIGHANDLER 14
DOSSETVEC 89
DOSSETVERIFY 86
DOSSGSWITCH 54
DOSSGSWITCHME 55
DOSSGSWITCHPROC 124
DOSSICG 95
DOSSIZESEG 126
DOSSLEEP 32
DOSSUSPENDTHREAD 27
DOSSWAPTASKINIT 102
DOSSYSTEMSERVICE 88
DOSSYSTRACE 90
DOSTIMERASYNC 29
DOSTIMERSTART 30
DOSTIMERSTOP 31
DOSUNLOCKSEG 123
GETADDR 111
GETHEADERS 108
GETSELADDR 110
PANICWRITE 105
STRUCHECK 106
STRURESUPDATE 107
UNUSEDA 98
UNUSEDB 99
The following Operating System entry points are defined in the library
DOSCALL1. In this case, the procedures must be called by name rather than
ordinal value.
DOSREAD
DOSWRITE
DOSERRCLASS
DOSSEMREQUEST
DOSSEMCLEAR
DOSSEMWAIT
DOSSEMSET
DOSEXECPGM
DOSCREATETHREAD
DOSSUBSET
DOSSUBALLOC
DOSSUBFREE
DOSREADASYNC
DOSWRITEASYNC
DOSSEARCHPATH
DOSSCANENV
*/
/* Routines defined in this file: *******************************************
DosCalls #8: DosGetInfoSeg
DosCalls #20: DosSemSetWait
DosCalls #23: DosCloseSem
DosCalls #24: DosCreateSem
DosCalls #25: DosOpenSem
DosCalls #29: DosTimerAsynch
DosCalls #31: DosTimerStop
DosCalls #32: DosSleep
DosCalls #33: DosGetDateTime
DosCalls #34: DosAllocSeg
DosCalls #39: DosFreeSeg
DosCalls #44: DosLoadModule
DosCalls #46: DosFreeModule
DosCalls #50: DosBeep
DosCalls #58: DosChgFilePtr
DosCalls #59: DosClose
DosCalls #60: DosDelete
DosCalls #63: DosFindClose
DosCalls #64: DosFindFirst
DosCalls #65: DosFindNext
DosCalls #66: DosMkDir
DosCalls #67: DosMove
DosCalls #70: DosOpen
DosCalls #71: DosQCurDir
DosCalls #75: DosQFileMode
DosCalls #91: DosGetEnv
DosCalls #92: DosGetVersion
DosCalls #98: DosQPathInfo
DosCalls #126: DosSizeSeg
DosCalls #127: DosMemAvail
DosCalls #166: DosQSysInfo
DosCalls #201: DosCopy (OS/2 1.2)
DosCall1 DosSemClear
DosCall1 DosSemSet
DosCall1 DosSemWait
DosCall1 DosScanEnv
DosCall1 DosSearchPath
*****************************************************************************/
; DosCalls #8: DosGetInfoSeg
defc globalseg
globalseg = 12
localseg = 12
call dynalink('DOSCALLS', -- dynamic link library name
'#8', -- ordinal value for DosGetInfoSeg
selector(globalseg) || -- string selector
offset(globalseg) || -- string offset
selector(localseg) || -- string selector
offset(localseg) ) -- string offset
globalseg=itoa(globalseg,10)
start_t = peek(globalseg,4,4)
; localseg=itoa(localseg,10)
globinfo = peek(globalseg, 0, 24)
; insertline '; 'globinfo,.last+1
time = ltoa(substr(globinfo, 1,4), 10)
millisecs = ltoa(substr(globinfo, 5,4), 10)
hours = asc(substr(globinfo, 9,1))
minute = asc(substr(globinfo,10,1))
seconds = asc(substr(globinfo,11,1))
hundredsec= asc(substr(globinfo,12,1))
timezone = itoa(substr(globinfo,13,2), 10)
interval = ltoa(substr(globinfo,15,2)\0\0, 10)
day = asc(substr(globinfo,17,1))
month = asc(substr(globinfo,18,1))
year = itoa(substr(globinfo,19,2), 10)
weekday = asc(substr(globinfo,21,1))
major = asc(substr(globinfo,22,1))
minor = asc(substr(globinfo,23,1))
revision = asc(substr(globinfo,24,1))
; weekday = substr('SunMonTueWedThuFriSat',weekday*3+1,3)
Weekday = strip(substr('Sunday Monday Tuesday Wednesday ' ||
'Thursday Friday Saturday Sunday ',Weekday*10+1,10))
if timezone = -1 then timezone = '(No timezone set)'; endif
sayerror time millisecs' 'hours':'minute':'seconds'.'hundredsec' 'timezone interval' 'weekday year'/'month'/'day' OS/2 'major'.'minor'.'revision
; DosCalls #20: DosSemSetWait
; call DosSemSetWait(mail_sem, timeout) -- set sem and wait til cleared
result = dynalink('DOSCALLS', -- rc 0 (false) if sem. is clear
'#20',
selector(mail_sem)|| /* Semaphore handle */
offset(mail_sem)||
long(timeout)) /* Timeout */
if result then
sayerror 'Error' result 'trying to set semaphore.'
endif
; DosCalls #23: DosCloseSem
if poll_sem/=='' then -- If it was successfully created, then
; call DosCloseSem(poll_sem) -- Close the semaphore
result=dynalink('DOSCALLS',
'#23',
poll_sem) /* Semaphore handle */
poll_sem = ''
; DosCalls #24: DosCreateSem
semname='\SEM\MYNAME.EOS'\0 -- Pick a unique name. Note trailing x'0'
poll_sem='1234' -- reserve 4 bytes
; call DosCreateSem(Exclusive, @poll_sem, @semname) -- Create semaphore
result=dynalink('DOSCALLS',
'#24',
atoi(1)|| /* non-Exclusive semaphore */
selector(poll_sem)|| /* Semaphore handle */
offset(poll_sem)||
selector(semname)|| /* Semaphore name */
offset(semname))
if result then
messageNwait('Error' result 'trying to create semaphore. Polling inhibited.')
poll_sem='' -- set to null
else
poll_sem=substr(poll_sem,3,2) || substr(poll_sem,1,2) -- reverse words
endif
; We reversed the words of the returned semaphore handle, so that all the other calls
; can pass it directly to the dynalink.
; DosCalls #25: DosOpenSem
; call DosOpenSem(@poll_sem, @semname) -- Open semaphore
result=dynalink('DOSCALLS',
'#25',
selector(poll_sem)|| /* Semaphore handle */
offset(poll_sem)||
selector(semname)|| /* Semaphore name */
offset(semname))
if result then
messageNwait('Error' result 'trying to open semaphore. Press a key...')
return
endif
endif
poll_sem=substr(poll_sem,3,2) || substr(poll_sem,1,2) -- reverse words
; DosCalls #29: DosTimerAsynch
; call DosTimerAsynch(30000, poll_sem, @timer_handle) -- Start timer
result=dynalink('DOSCALLS',
'#29',
long(30000)|| /* Delay in millisec.s */
poll_sem || /* Semaphore handle */
selector(timer_handle)|| /* Semaphore name */
offset(timer_handle))
if result then
sayerror 'Error' result 'trying to start timer.'
endif
; DosCalls #31: DosTimerStop
; call DosTimerStop(timer_handle) -- stop the timer
result=dynalink('DOSCALLS',
'#31',
timer_handle)
if result then
sayerror 'Error' result 'trying to stop timer.'
endif
; DosCalls #32: DosSleep
delay=atol(1000) -- 1 second DOSSLEEP
call dynalink('DOSCALLS', '#32', substr(delay,3,2) || substr(delay,1,2))
; DosCalls #33: DosGetDateTime
datetime='12345678901234567890'
call dynalink('DOSCALLS', /* dynamic link library name */
'#33', /* ordinal value for DOSGETDATETIME*/
selector(datetime)|| /* string selector */
offset(datetime)) /* string offset */
return dec_to_string(datetime)
--> Hour24 Minutes Seconds Hund Day MonthNum Year0 Year1 TZ0 TZ1 WeekdayNum
; DosCalls #34: DosAllocSeg
filesbuffer = "??" -- initialize string pointer
r = dynalink('DOSCALLS', -- dynamic link library name
'#34', -- DosAllocSeg
atoi(min(len+1,65535)) || -- Number of Bytes requested
selector(filesbuffer) || -- string selector
offset(filesbuffer) || -- string offset
atoi(0)) -- Share information
if r then sayerror 'Error 'r' allocating memory segment; command halted.'; stop; endif
; DosCalls #39: DosFreeSeg
if free_the_buffer then
call dynalink('DOSCALLS', -- dynamic link library name
'#39', -- DosFreeSeg
filesbuffer)
; DosCalls #44: DosLoadModule
ObjNameBuf = copies(\0,255)
ModuleName = "LEXAM"\0 -- ASCIIZ string
ModuleHandle = "??" -- initialize string pointer
r = dynalink('DOSCALLS', -- dynamic link library name
'#44', -- DosLoadModule
selector(ObjNameBuf) || -- string selector
offset(ObjNameBuf) || -- string offset
atoi(255) || -- buffer length
selector(ModuleName) || -- string selector
offset(ModuleName) || -- string offset
selector(ModuleHandle) || -- string selector
offset(ModuleHandle) ) -- string offset
if r then
parse value ObjNameBuf with ObjName \0
sayerror 'Error' r 'from DosLoadModule; ObjName="'ObjName'"'
endif
; DosCalls #46: DosFreeModule
call dynalink('DOSCALLS', -- dynamic link library name
'#46', -- DosFreeModule
ModuleHandle)
; DosCalls #50: DosBeep
call dynalink('DOSCALLS', /* dynamic link library name */
'#50', /* ordinal value for DOSBEEP */
atoi(pitch)|| /* Hertz (25H-7FFFH) */
atoi(duration)) /* Length of sound in ms */
; DosCalls #58: DosChgFilePtr
newpointer = 1234 -- Reserve 4 bytes for a long
result = dynalink('DOSCALLS',
'#58', -- DosChgFilePtr
filehandle || -- Binary file handle
atol_swap(0) || -- Distance (offset to move)
atoi(2) || -- MoveType: relative to: 0=beginning of file; 1=current pointer; 2=end of file
selector(newpointer) || -- Address of the new pointer location (output)
offset(newpointer) )
; DosCalls #59: DosClose
result = dynalink('DOSCALLS',
'#59', /* dosclose */
atoi(fileid.lockhandle))
; DosCalls #60: DosDelete
return dynalink('DOSCALLS', /* dynamic link library name */
'#60', /* ordinal value for DOSDELETE */
selector(asciiz) || /* string selector */
offset(asciiz) || /* string offset */
atoi(0)|| /* reserved */
atoi(0)) /* reserved */
; DosCalls #63: DosFindClose
result=dynalink('DOSCALLS', -- dynamic link library name
'#63', -- ordinal value for DOSFINDCLOSE
dirhandle) -- Directory handle, returned by DosFindFirst(2)
; DosCalls #64: DosFindFirst
defc findfirst
parse arg filename .
filename = filename\0 -- ASCIIZ
DirHandle = atoi(1) -- To use the common handle
;; dirhandle = \xff\xff -- Ask system to assign us a handle
attribute = atoi(0) -- 0=normal; no subdirectories, hidden or system
resultbuf = copies(\0,255) -- Can be bigger in EPM 5.60 or above; use a buffer in earlier versions if more space is needed.
searchcnt = atoi(1) -- Search count; we're only asking for 1 file at a time here.
rc = dynalink('DOSCALLS', -- dynamic link library name
'#64', -- ordinal value for DosFindFirst
selector(filename) || -- string selector
offset(filename) || -- string offset
selector(DirHandle) || -- string selector
offset(DirHandle) || -- string offset
attribute ||
selector(resultbuf) || -- string selector
offset(resultbuf) || -- string offset
atoi(length(resultbuf)) ||
selector(searchcount) || -- Pointer to the count; system updates
offset(searchcount) ||
atol(0)) -- reserved
if rc = 0 then msg = 'NO_ERROR'
elseif rc = 2 then msg = 'ERROR_FILE_NOT_FOUND'
elseif rc = 3 then msg = 'ERROR_PATH_NOT_FOUND'
elseif rc = 6 then msg = 'ERROR_INVALID_HANDLE'
elseif rc = 18 then msg = 'ERROR_NO_MORE_FILES'
elseif rc = 26 then msg = 'ERROR_NOT_DOS_DISK'
elseif rc = 87 then msg = 'ERROR_INVALID_PARAMETER'
elseif rc = 108 then msg = 'ERROR_DRIVE_LOCKED'
elseif rc = 111 then msg = 'ERROR_BUFFER_OVERFLOW'
elseif rc = 113 then msg = 'ERROR_NO_MORE_SEARCH_HANDLES'
elseif rc = 206 then msg = 'ERROR_FILENAME_EXCED_RANGE'
endif
if rc then
sayerror 'Error' rc 'from DosFindFirst -' msg
return
endif
s = ''
do i=0 to 2
datetime = substr(resultbuf,4*i+1,4)
date = ltoa(substr(datetime,1,2)\0\0,10); time = ltoa(substr(datetime,3,2)\0\0,10)
year = date % 512; date = date // 512
month = date % 32; day = date // 32 % 1 -- %1 to drop fraction.
date = year+80'/'month'/'day
hour = time % 2048; time = time // 2048
min = time % 32; sec = time // 32 * 2 % 1
time = hour':'min':'sec
s = s date time
enddo
file_size = ltoa(substr(resultbuf,13,4),10)
filealloc = ltoa(substr(resultbuf,17,4),10)
fileattrib = itoa(substr(resultbuf,21,2),16)
namelen = asc(substr(resultbuf,23,1))
name = substr(resultbuf,24,namelen)
sayerror 'Create, access, write timestamps =' s
sayerror 'filesize='file_size', allocated size='filealloc', attributes='fileattrib', namelen='namelen', count='itoa(searchcount,10)
sayerror 'filename = "'name'"'
; DosCalls #65: DosFindNext
resultbuf = copies(\0, 300) -- Might need to allocate a buffer if < EPM 5.60
searchcnt = atoi(1) -- Search count; we're only asking for 1 file at a time here.
result=dynalink('DOSCALLS', -- dynamic link library name
'#65', -- ordinal value for DOSFINDNEXT
dirhandle || -- Directory handle, returned by DosFindFirst(2)
selector(resultbuf) || -- string selector
offset(resultbuf) || -- string offset
atoi(length(resultbuf)) ||
selector(searchcnt) || -- Pointer to the count; system updates
offset(searchcnt) )
if result = 0 then msg = 'NO_ERROR'
elseif result = 6 then msg = 'ERROR_INVALID_HANDLE'
elseif result = 18 then msg = 'ERROR_NO_MORE_FILES'
elseif result = 26 then msg = 'ERROR_NOT_DOS_DISK'
elseif result = 87 then msg = 'ERROR_INVALID_PARAMETER'
elseif result = 111 then msg = 'ERROR_BUFFER_OVERFLOW'
elseif result = 275 then msg = 'ERROR_EAS_DIDNT_FIT'
endif
; DosCalls #66: DosMkDir
result=dynalink('DOSCALLS', -- dynamic link library name
'#66', -- ordinal value for DOSMKDIR
selector(filename) || -- string selector
offset(filename) || -- string offset
atol(0)) -- reserved
; DosCalls #67: DosMove
rc=dynalink('DOSCALLS', /* dynamic link library name */
'#67', /* DosMove - move a file */
selector(oldfilez)||
offset(oldfilez) ||
selector(newfilez)||
offset(newfilez) ||
atol(0)) /* Reserved; must be 0 */
; DosCalls #70: DosOpen
newhandle='??'
actiontaken=atoi(1)
file=file\0
result = dynalink('DOSCALLS',
'#70', /* dosopen */
selector(file)||
offset(file)||
selector( newhandle )||
offset( newhandle )||
selector( actiontaken )||
offset( actiontaken )||
atol(0)|| -- File size
atoi(0)|| -- File attribute
atoi(17)|| -- Open flag (create if new; open if exists)
atoi(146)|| -- Open mode (private; deny read/write; get read/write access)
atol(0)) -- Reserved
; DosCalls #71: DosQCurDir
string = atoi(80) || substr('',1,80) /* create input strings for */
stringlen = substr('',1,4) /* DOSQCURDIR */
result=dynalink('DOSCALLS',
'#71',
atoi(0)|| /* Drive number - 1=A, etc */
selector(string)|| /* Directory path buffer */
offset(string)||
selector(stringlen)|| /* Directory path buffer length */
offset(stringlen))
sayerror 'len = ' hex_to_string(stringlen) 'current dir = ' string
; DosCalls #75: DosQFileMode
attrib=' '
cflag=dynalink('DOSCALLS', -- dynamic link library name
'#75', -- ordinal value for DOSQFILEMODE
selector(filename) || -- string selector
offset(filename) || -- string offset
selector(attrib) || -- string selector
offset(attrib) || -- string offset
atol(0)) -- reserved
; DosCalls #76: DosQFsInfo
infobuf=substr('',1,255)
rc = dynalink('DOSCALLS', -- dynamic link library name
'#76', -- ordinal value for DOSQFSINFO
atoi(drive_no) || -- drive #; 0=default; 1=A, ...
atoi(infolevel) || -- info level requested
selector(infobuf) || -- string selector
offset(infobuf) || -- string offset
atoi(length(infobuf))) -- length of buffer
; DosCalls #91: DosGetEnv
seg_ptr = 1234 /* 4-byte place to put a far pointer */
cmd_ptr = 1234
call dynalink('DOSCALLS', /* dynamic link library name */
'#91', /* ordinal value for DOSGETENV */
selector(seg_ptr) || /* pointer to env. segment */
offset(seg_ptr) ||
selector(cmd_ptr) || /* pointer to offset after */
offset(cmd_ptr) ) /* COMSPEC; we don't need */
env_seg=itoa(seg_ptr,10)
; DosCalls #92: DosGetVersion
verbuf = 'nn'
res= dynalink('DOSCALLS', /* dynamic link library name */
'#92', /* ordinal for DOSGETVERSION */
selector(verbuf) || /* string selector */
offset(verbuf)) /* string offset */
; major = asc(substr(verbuf,2,1))
; minor = asc(substr(verbuf,1,1))
; DosCalls #98: DosQPathInfo
pathname = 'H:\'\0
if arg(1) then pathname=arg(1)\0; endif
pathinfobuf = copies(\0,255)
pathinfobufsize = 255
PathInfoLevel = 5
ca = dynalink('DOSCALLS', /* dynamic link library name */
'#98', /* ordinal value for DOSQPATHINFO */
selector(pathname) || -- pathname to be queried
offset(pathname) ||
atoi(PathInfoLevel) || -- PathInfoLevel
selector(pathinfobuf) || -- buffer where info is to be returned
offset(pathinfobuf) ||
atoi(pathinfobufsize) || -- size of buffer
atol(0) ) -- (reserved)
sayerror 'result =' ca'; size='pathinfobufsize'; buf="'pathinfobuf'"'
; For level 1: (binary fields; convert as needed)
create_date = substr(pathinfobuf, 1, 2) -- bits 15-9 = year; 8-5 = month; 4-0 = day
create_time = substr(pathinfobuf, 3, 2) -- bits 15-11 = hour; 10-5 = minute; 4-0 = seconds
access_date = substr(pathinfobuf, 5, 2) -- like create_
access_time = substr(pathinfobuf, 7, 2)
update_date = substr(pathinfobuf, 9, 2) -- like create_
update_time = substr(pathinfobuf, 11, 2)
filesize = substr(pathinfobuf, 13, 4)
allocsize = substr(pathinfobuf, 17, 4)
fileattrib = substr(pathinfobuf, 21, 2)
; DosCalls #126: DosSizeSeg
size_out = '0000' -- result buffer
result=dynalink('DOSCALLS', -- dynamic link library name
'#126', -- ordinal value for DosSizeSeg
rightstr(ea_long,2), -- segment
selector(size_out) || -- string selector
offset(size_out)) -- string offset
sayerror 'rc = ' rc'; size = ' ltoa(size_out,10)
; DosCalls #127: DosMemAvail
string = '?????' /* result buffer */
result=dynalink('DOSCALLS', /* dynamic link library name */
'#127', /* ordinal value for DOSMEMAVAIL */
selector(string)|| /* string selector */
offset(string)) /* string offset */
sayerror 'memavail = ' string 'itoa(hex) = ' itoa(string,16)
; DosCalls #166: DosQSysInfo
index = 0
databuf = '??' -- result buffer
rc = '[not set]'
result=dynalink('DOSCALLS', -- dynamic link library name
'#166', -- ordinal value for DOSQSYSINFO
atoi(index) ||
selector(databuf) || -- string selector
offset(databuf) || -- string offset
atoi(2) ) -- buffer length
sayerror 'max path length =' itoa(databuf,10) 'result='result 'rc='rc
; OS/2 2.0 version (but don't know how to access it)
startindex = 5
endindex = 13
databuf_len = (endindex - startindex + 1) * 4 -- Reserve this many double-words
databuf = copies(\0, databuf_len) -- result buffer
result=dynalink('DOSCALLS', -- dynamic link library name
?? '#166', -- ordinal value for DOSQSYSINFO
atol(startindex) ||
atol(endindex) ||
selector(databuf) || -- string selector
offset(databuf) || -- string offset
atol(databuf_len) ) -- buffer length
sayerror 'Boot drive =' substr('ABCDEFGHIJKLMNOPQRSTUVWXYZ', ltoa(leftstr(databuf,4),10),1)
; DosCalls #201: DosCopy (OS/2 1.2)
elseif dos_version() >= 1020 then -- DOSCOPY is new in 1.2
rc=dynalink('DOSCALLS', /* dynamic link library name */
'#201', /* DosCopy - Copy a file */
selector(oldfilez)||
offset(oldfilez) ||
selector(newfilez)||
offset(newfilez) ||
atoi(0) || /* Mode */
atol(0)) /* Reserved; must be 0 */
; DosCall1 DosSemClear
res=dynalink('DOSCALL1',
'DOSSEMCLEAR',
poll_sem) /* Semaphore handle */
; DosCall1 DosSemSet
; call DosSemSet(poll_sem) -- Set semaphore; cleared by timer pop.
result=dynalink('DOSCALL1',
'DOSSEMSET',
poll_sem) /* Semaphore handle */
if result then
sayerror 'Error' result 'trying to set semaphore.'
endif
; DosCall1 DosSemWait
rc = dynalink('DOSCALL1', -- rc 0 (false) if sem. is clear
'DOSSEMWAIT',
poll_sem|| /* Semaphore handle */
long(1)) /* Timeout */
; DosCall1 DosScanEnv
varname = upcase(varname)\0 -- (see Get_env in DOSUTIL.E for a complete example)
result_ptr = 1234 -- 4-byte place to put a far pointer
rc = dynalink('DOSCALL1', -- rc 0 (false) if found
'DOSSCANENV',
selector(varname) ||
offset(varname) ||
selector(result_ptr) || -- string selector
offset(result_ptr)) -- string offset
; DosCall1 DosSearchPath
defc try =
pathz = 'DPATH'\0
filenamez = arg(1)\0
result_str = substr('',1,255)
rc = dynalink('DOSCALL1', -- rc 0 (false) if found
'DOSSEARCHPATH',
atoi(4) ||
selector(pathz) ||
offset(pathz) ||
selector(filenamez) || -- string selector
offset(filenamez) || -- string offset
selector(result_str) || -- string selector
offset(result_str) || -- string offset
atoi(255) ) -- buffer length
if rc then
sayerror 'RC='rc
else
parse value result_str with result_str \0
sayerror '"'result_str'"'
endif
; DosCall1 DosSearchPath
-- Assume filehandle is set from previous DosOpen
strng = 'Test output'\13\10'End of test.'\13\10 -- End lines with CR/LF
bytes_written = 00 -- Reserve two bytes
rc = dynalink('DOSCALL1',
'DOSWRITE',
filehandle || -- Binary file handle
selector(strng) || -- Buffer to write to file
offset(strng) ||
atoi(length(strng)) || -- Number of bytes to write.
selector(bytes_written) || -- string selector
offset(bytes_written) ) -- string offset
if rc then
sayerror 'DosWrite error; RC='rc
elseif length(strng)<>itoa(bytes_written,10) then
sayerror 'Only'itoa(bytes_written,10) 'bytes were written out!'
endif