• Keine Ergebnisse gefunden

errno, _doserrno, sys_errlist, sys_nerr

Im Dokument Reference Guide (Seite 36-41)

Names Usage

Declared in

errno, _doserrno, sys_errlist, sys_nerr extern int errno;

extern int _doserrno;

extern char * sys_errlist[ ];

extern int sys_nerr;

errno.h dos.h

(errno, _doserrno, sys_errlist, sys_nerr) Ldoserrno)

Description

22

Three of these variables (errno, sys_errlist, and sys_nerr) are used by the perror function to print error messages when certain library routines fail to accomplish their appointed tasks. _doserrno is a variable that maps many MS-DOS error codes to errno; however, perror does not use _doserrno directly.

_doserrno: When an MS-DOS system call results in an error, _doserrno is set to the actual MS-DOS error code.

errno is a parallel error variable inherited from UNIX.

errno: Whenever an error in a system call occurs, errno is set to indicate the type of error. Sometimes errno and _doserrno are equivalent. Other times, errno does not contain the actual DOS error code (which is contained in _doserrno). Still other errors might occur which set only errno, not _doserrno.

sys_errlist: To provide more control over message formatting, the array of message strings is provided in sys_errlist. errno can be used as an index into the array to find the string corresponding to the error number. The string does not include any newline character.

sys_nerr: This variable is defined as the number of error message strings in sys _errlist.

The following table gives mnemonics for the values stored in sys_errlist and their meanings.

mnemonic Attempt to remove CurDir Domain error

EINVMEM

Invalid memory block address Too many open files

N a more files N a such device

No such file or directory, Exec format error

N a such file or directory Not enough core

Path not found Not same device Result out of range Cross-device link

mnemonic MS-DOS error code EINVAL Bad function

E2BIG Bad environ EACCES Access denied EACCES Bad access EACCES Is current dir

EBADF Bad handle

EFAULT Reserved EINVAL Bad data EMFILE Too many open ENOENT File not found ENOENT Path not found ENOENT N a more files ENOEXEC Bad format ENOMEM Mcb destroyed ENOMEM Out of memory ENOMEM Bad block EXDEV Bad drive EXDEV Not same device

Jmode

Name Usage Declared in Description

24

Refer to the Microsoft MS-DOS Programmer's Reference Manual for more information about MS-DOS error returns.

Jmode - default file-translation mode extern int Jmode;

fcntl.h

This variable determines in which mode (text or binary) files will be opened and translated. The value of Jmode is a_TEXT by default, which specifies that files will be read in text mode. If Jmode is set to a_BINARY, the files are opened and read in binary mode. (a_TEXT and a_BINARY are defined in fcntl.h.)

In text mode, on input, carriage-return/line-feed (CR/LF) combinations are translated to a single line-feed character (LF). On output, the reverse is true: LF characters are translated to CR/LF combinations.

In binary mode, no such translation occurs.

You can override the default mode as set by Jmode by specifying a t (for text mode) or b (for binary mode) in the argument type in the library routines fop en, fdopen, and freopen. Also, in the routine open, the argument access can include either a_BINARY or a_TEXT, which will explicitly define the file being opened (given by the open pathname argument) to be in either binary or text mode.

Turbo C Reference Guide

-PSp, envtron ·

Names Usage Declared in Description

-psp, environ

extern unsigned int -psp;

extern char * environ[ ];

dos.h (-psp) dos.h (environ)

-psp: This variable contains the segment address of the program segment prefix (PSP) for the current program.

The PSP is an MS-DOS process descriptor; it contains initial DOS information about the program.

Refer to the Microsoft MS-DOS Programmer's Reference Manual for more information on the PSP.

environ: This is an array of strings; it is used to access and alter a process environment. Each string is of the form

envvar

=

varvalue

where envvar is the name of an environment variable (such as PATH), and varvalue is the string value to which envvar is set (such as c: \BIN; C : \008). The string varvalue may be empty.

When a program begins execution, the MS-DOS environment settings are passed directly to the program.

Note that envp, the third argument to main, is equal to the initial setting of environ.

The environ array can be accessed by getenv; however, the putenv function is the only routine that should be used to add, change or delete the environ array entries.

(This is because modification can resize and relocate the process environment array, but environ is automatically adjusted so that it always points to the array.)

stklen

Name Usage Description

_stklen - stack length variable int _stklen;

In large data models (compact, large, and huge), _stklen is the exact stack size in bytes.

In small data models (tiny, small, and medium), the startup code uses _stklen to compute the minimum size of the DATA segment. The DATA segment includes initialized global data, uninitialized data, and the stack.

min DATA segment size = size of DATA segment + size of -BSS segment +

stklen-+ MINSTACK(128 words)

If the memory available is less than this, the startup aborts the program. The maximum DATA segment size is, of course, 64K.

. . .

Im Dokument Reference Guide (Seite 36-41)