Watcom C Library : _getcolor, _getcurrentposition, _getcurrentposition_w, getcwd, getenv, _getfillmask
Watcom C Reference/G - H - I 2021. 6. 28. 21:53
Watcom C Library Reference : _getcolor, _getcurrentposition, _getcurrentposition_w, getcwd, getenv, _getfillmask
_getcolor
Synopsis : #include <graph.h>
short _FAR _getcolor( void );
Description : The _getcolor function returns the pixel value for the current color. This is the color used for displaying graphics output. The default color value is one less than the maximum number of colors in the current video mode.
Returns : The _getcolor function returns the pixel value for the current color.
See Also : _setcolor
Example :
#include <conio.h>
#include <graph.h>
void main( )
{
int col, old_col;
_setvideomode ( _VRES16COLOR );
old_col = _getcolor( );
for ( col = 0; col < 16; ++col ) {
_setcolor( col );
_rectangle( _GFILLINTERIOR, 100, 100, 540, 380);
getch( );
}
_setcolor ( old_col );
_setvideomode( _DEFAULTMODE );
}
Classification : PC Graphics
Systems : DOS, QNX
_getcurrentposition, _getcurrentposition_w
Synopsis : #include <graph.h>
struct xycoord _FAR _getcurrentposition( void );
struct _wxycoord _FAR _getcurrentposition_w( void );
Description : The _getcurrentposition functions return the current output position for graphics.
The _getcurrentposition function returns the point in view coordinates. The _getcurrentposition_w function returns the point in window coordinates.
The current position defaults to the origin, (0, 0), when a new video mode is selected. It is changed by successful calls to the _arc, _moveto and _lineto functions as well as the _setviewport function.
Note that the output position for graphics output differs from that for text output. The output position for text output can be set by use of the _settextposition function.
Returns : The _getcurrentposition functions return the current output position for graphics.
See Also : _moveto, _settextposition
Example :
#include <conio.h>
#include <graph.h>
void main( )
{
struct xycoord old_pos;
_setvideomode( _VRES16COLOR );
old_pos = _getcurrentposition( );
_moveto ( 100, 100 );
_lineto ( 540, 100 );
_lineto ( 320, 380 );
_lineto ( 100, 100 );
_moveto( old_pos.xcoord, old_pos.ycoord );
getch( );
_setvideomode( _DEFAULTMODE );
}
Classification : PC Graphics
Systems : _getcurrentposition - DOS, QNX
_getcurrentposition_w - DOS, QNX
getcwd
Synopsis : #include <direct.h>
char *getcwd( char *buffer, int size );
Description : The getcwd function returns the name of the current working directory. The buffer address is either NULL or is the location at which a string containing the name of the current working directory is placed. In the latter case, the value of size is the length (including the delimiting 10' character) which can be be used to store this name.
The maximum size that might be required for buff is PATH_MAX + 1 bytes.
Extension: When buffer has a value of NULL, a string is allocated to contain the name of the current working directory. This string may be freed using the free function.
Returns : The getcwd function returns the address of the string containing the name of the current working directory, unless an error occurs, in which case NULL is returned.
Errors : When an error has occurred, errno contains a value indicating the type of error that has been detected.
Constant | Meaning |
EINVAL | The argument size is negative. |
ENOMEM | Not enough memory to allocate a buffer. |
ERANGE | The buffer is too small (specified by size) to contain the name of the current working directory. |
See Also : chdir, mkdir, rmdir
Example :
#include <stdio.h>
#include <stdlib.h>
#include <direct.h>
void main( )
{
char *cwd;
cwd = getcwd ( NULL, 0 );
if( cwd != NULL ) {
printf( "My working directory is %s\n", cwd );
free( cwd);
}
}
produces the following :
My working directory is C:\PROJECT\C
Classification : POSIX 1003.1 with extensions
Systems : All
getenv
Synopsis : #include <stdlib.h>
char *getenv( const char *name );
Description : The getenv function searches the environment list for an entry matching the string pointed to by name. The matching is case-insensitive; all lowercase letters are treated as if they were in upper case.
Entries can be added to the environment list with the DOS set command or with the putenv or setenv functions. All entries in the environment list can be displayed by using the DOS set command with no arguments.
To assign a string to a variable and place it in the environment list:
C>SET INCLUDE=C:\WATCOM\H
To see what variables are in the environment list, and their current assignments:
C>SET
COMSPEC=C:\COMMAND.COM
PATH=C:\;C:\WATCOM
INCLUDE=C:\WATCOM\H
Returns : The getenv function returns a pointer to the string assigned to the environment variable if found, and NULL if no match was found. Note: the value returned should be duplicated if you intend to modify the contents of the string.
See Also : clearenv, exec Functions, putenv, _searchenv, setenv, spawn Functions, system
Example :
#include <stdio.h>
#include <stdlib.h>
void main( )
{
char *path;
path = getenv( "INCLUDE" );
if ( path != NULL )
printf( "INCLUDE=%s\n", path);
}
Classification : ANSI
Systems : All
_getfillmask
Synopsis : #include <graph.h>
unsigned char _FAR *_FAR _getfillmask( unsigned char _FAR *mask );
Description : The _getfillmask function copies the current fill mask into the area located by the argument mask. The fill mask is used by the _ellipse, _floodfill, _pie, _polygon and _rectangle functions that fill an area of the screen.
The fill mask is an eight-byte array which is interpreted as a square pattern (8 by 8) of 64 bits. Each bit in the mask corresponds to a pixel. When a region is filled, each point in the region is mapped onto the fill mask. When a bit from the mask is one, the pixel value of the corresponding point is set using the current plotting action with the current color; when the bit is zero, the pixel value of that point is not affected.
When the fill mask is not set, a fill operation will set all points in the fill region to have a pixel value of the current color.
Returns : If no fill mask has been set, NULL is returned; otherwise, the _getfillmask function returns mask.
See Also : _floodfili, _setfillmask, _setplotaction
Example :
#include <conio.h>
#include <graph.h>
char old_mask[8];
char new_mask[8] = { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 };
void main( )
{
_setvideomode ( _VRES16COLOR );
_getfillmask ( old_mask );
_setfillmask ( new_mask );
_rectangle( _GFILLINTERIOR, 100, 100, 540, 380 );
_setfillmask ( old_mask );
getch( );
_setvideomode( _DEFAULTMODE );
}
Classification : PC Graphics
Systems : DOS, QNX
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)