WATCOM C Library Reference : _bgetcmd, _bheapseg, _bios_disk, _bios_equiplist

 

 

 

 

_bgetcmd

 

Synopsis : #include <process.h> 

              int _bget cmd( char *cmd_line, int len );

Description : The _bgetcmd function causes the command line information, with the program name removed, to be copied to cmd_line. The argument len specifies the size of cmd_line.

 

The information is terminated with a '\0' character. This provides a method of obtaining the original parameters to a program unchanged (with the white space intact).


This information can also be obtained by examining the vector of program parameters passed to the main function in the program.

 


Returns : If cmd line is NULL then the number of bytes required to store the command line, excluding the terminating NULL character, is returned; otherwise the number of bytes stored in cmd line, excluding the terminating NULL character, is returned.


See Also : abort, atexit, exec Functions, exit, _exit, get_cmd, getenv, main, onexit, putenv, spawn Functions, system

Example : Suppose a program were invoked with the command line

    myprog arg-1 ( my stuff ) here
where that program contains

 

#include <stdio.h> 

#include <stdlib.h> 

#include <process.h>


void main( )

{
    char *cmdline;

    int cmdlen;


    cmdlen = _bgetcmd( NULL, 0 ) + 1;

    cmdline = malloc( cmdlen );

    if( cmdline != NULL) {
        cmdlen = _bgetcmd ( cmdline, cmdlen ) ;

        printf( "%s\n", cmdline );

    }

}

 

produces the following :

arg-1 ( my stuff ) here

 


Classification : WATCOM
Systems : All

 

 

 

_bheapseg

 

Synopsis : #include <malloc.h> 

              __segment bheapseg ( size_t size );


Description : The bheapseg function allocates a based-heap segment of at least size bytes.

 

The argument size indicates the initial size for the heap. The heap will automatically be enlarged as needed if there is not enough space available within the heap to satisfy an allocation request by _bcalloc_bexpand_bmalloc, or _brealloc.


The value returned by _bheapseg is the segment value or selector for the based heap. This Value must be saved and used as an argument to other based heap functions to indicate which based heap to operate upon.


Each call to _bheapseg allocates a new based heap.

 


Returns : The value returned by _bheapseg is the segment value or selector for the based heap. This value must be saved and used as an argument to other based heap functions to indicate which based heap to operate upon.

 

A special value of _NULLSEG is returned if the segmente could not be allocated.



See Also : _bfreeseg, _bcalloc, _bexpand, _bmalloc, _brealloc

Example :
#include <stdio.h> 

#include <stdlib.h> 

#include <malloc.h>


struct list {
    struct list __based (__self) *next;

    int     value;

};


void main( )

{
    int     i; 

    __segment seg;

    struct list __based (seg) *head;

    struct list __based (seg) *p;


    /* allocate based heap */

    seg = _bheapseg ( 1024 );

    if( seg == _NULLSEG ) {

        printf( "Unable to allocate based heap\n" );

        exit ( 1 );

    }
    /* create a linked list in the based heap */

    head = 0;

    for ( i = 1; i < 10; i++ ) {
        P = _bralloc( seg, sizeof( struct list ) );

        if( p == _NULLOFF ) {
            printf( "_bmalloc failed\n" );

            break;

        }
        p->next = head;

        p->value = i;

        head = p;

    }

 

    /* traverse1 the linked list, printing out values */

    for( p = head; p != 0; p = p->next ) {
        printf( "Value = %d\n", p->value );

    }


    /* free all the elements of the linked list */

    for( ; p = head; ) {

        head = p->next;

        _bfree ( seg, p );

    }


    /* free the based heap */

    _bfreeseg( seg );

}

 

 

Classification : WATCOM
Systems : DOS/16, Win/16, QNX/16, OS/2 1.x(all)


 

 

 

_bios_disk

 

Synopsis : #include <bios.h> 

              unsigned short _bios_disk( unsigned service,  struct diskinfo_t *diskinfo );

              struct diskinfo_t {                          /* disk parameters   */ 

                      unsigned drive;                     /* drive number       */

                      unsigned head;                     /* head number       */

                      unsigned track;                     /* track number       */

                      unsigned sector;                   /* sector number      */ 

                      unsigned nsectors;                /* number of sectors  */

                      void __far *buffer;                 /* buffer address       */

              };   


Description : The _bios_disk function uses INT 0x13 to provide access to the BIOS disk functions.

Information for the desired service is passed the diskinfo_t structure pointed to by diskinfo. The value for service can be one of the following values:


Value               Meaning
_DISK_RESET      Forces the disk controller to do a reset on the disk. This request does not use the diskinfo argument.

 

_DISK_STATUS    Obtains the status of the last disk operation.


_DISK_READ       Reads the specified number of sectors from the disk. This request users all of the information passed in the diskinfo structure.


_DISK_WRITE      Writes the specified amount of data to the disk. This request uses allne the information passed in the diskinfo structure.


_DISK_VERIFY     Checks the disk to be sure the specified sectors exist and can be read. 

A CRC (cyclic redundancy check) test is performed. This request all of the information passed in the diskinfo structure except for the buffer field.


_DISK_FORMAT    Formats the specified track on the disk. The head and track fields indicate the track to be formatted. Only one track can be formatted per call. The buffer field points to a set of sector markers, whose format depends on the type of disk drive. This service has no return value.

 

 


Returns : The _bios_disk function returns status information in the high-order byte when service is _DISK_STATUS, _DISK_READ, _DISK_WRITE, or _DISK_VERIFY. The possible values are:

 

Value                 Meaning
0x00                  Operation successful

0x01                  Bad command

0x02                  Address mark not found

0x03                  Attempt to write to write-protected disk

0x04                  Sector not found

0x05                  Reset failed

0x06                  Disk changed since last operation

0x07                  Drive parameter activity failed

0x08                  DMA overrun

0x09                  Attempt to DMA across 64K boundary

0x0A                  Bad sector detected

0x0B                  Bad track detected

0x0C                  Unsupported track

0x10                  Data read (CRC/ECC) error

0x11                  CRC/ECC corrected data error

0x20                  Controller failure

0x40                  Seek operation failed

0x80                  Disk timed out or failed to respond

0xAA                  Drive not ready

0xBB                  Undefined error occurred

0xCC                  Write fault occurred

0xE0                   Status error

0xFF                   Sense operation failed
 

 

Example :
#include <stdio.h> 

#include <bios.h>


void main( )

{
    struct diskinfo_t di;

    unsigned short status;
   

    di.drive = di.head = di.track = di.sector = 0;

    di.nsectors = 1;

    di.buffer = NULL;

    status = _bios_disk ( _DISK_VERIFY, &di );

    printf( "Status = 0x%4.4X\n", status );

}

 


Classification : BIOS
Systems : DOS, Win, NT, DOS/PM

 

 

 

_bios_equiplist

 

Synopsis : #include <bios.h> 

              unsigned short _bios_equiplist ( void );

Description : The _bios_equiplist function uses INT 0x11 to determine what hardware and peripherals are installed on the machine.


Returns : The _bios_equiplist function returns a set of bits indicating what is current installed on the machine. Those bits are defined as follows: 

Bit                Meaning

bit 0              Set to 1 if system boots from disk

bit 1              Set to 1 if a math coprocessor is installed

bits 2-3          Indicates motherboard RAM size

bits 4-5          Initial video mode

bits 6-7          Number of diskette drives

bit 8              Set to 1 if machine does not have DMA

bits 9-11         Number of serial ports

bit 12             Set to 1 if a game port is attached

bit 13             Set to 1 if a serial printer is attached

bits 14-15        Number of parallel printers installed

       


Example :
#include <stdio.h> 

#include <bios.h>


void main( )

{
    unsigned short equipment;


    equipment = _bios_equiplist( );

    printf( "Equipment flags = 0x%4.4X\n", equipment );

}

 

Classification : BIOS
Systems : DOS, Win, NT, DOS/PM

 

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

728x90
반응형
Posted by 전화카드
,