D\errno PR 9B ð EXTPROC('geterrno')
DUser S 12A
DBuffer S 32767A
DReturnPtr S \
DReturnInt S 9B ð
DFileDesc S 9B ð
Dtest_file S 2ð48A INZ('test.file')
DInitialDir S 2ð48A
Dtest_data S 12A INZ('Hello World!')
DBytesWrt S 9B ð
DBytesRead S 9B ð
DFileName S 2ð49A
DPrintLine S 1ððA
DNull C CONST(X'ðð')
C\
C\ Get and print the real user id with the getuid function.
C\
C eval ReturnInt = getuid
C\
C\ Check for error and report status.
C\
C if ReturnInt = -1
C eval PrintLine = 'Error getting real user id'
C exsr error
C eval \INLR = '1'
C return
C else
C move ReturnInt User
C eval PrintLine = 'The real user id is '
C + %TRIML(User)
C except
C endif
C\
C\ Get the current working directory and store it in Buffer.
C\
C eval ReturnPtr=getcwd(%ADDR(Buffer)
C : %SIZE(Buffer))
C\
C\ Check for error and report status.
C\
C if ReturnPtr = \NULL
C eval PrintLine = 'Error getting current directory'
C exsr error
C eval \INLR = '1'
C return
C else
C\
C\ Print current directory name remembering to scan for null terminator.
C\
C Null scan Buffer NullFound 5 ð
C eval InitialDir = %SUBST(Buffer:1:NullFound)
C eval PrintLine = 'Current Directory is '
C + InitialDir
C except
C endif
C\
C\ Create the file TEST_FILE for writing. If it does not exist,
C\ give the owner authority to read, write, and execute.
B-184 System API Programming V4R1