United States    
COMPAQ STORE | PRODUCTS |
SERVICES | SUPPORT | CONTACT US | SEARCH
Compaq C

Compaq C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index

Running this example produces the following result:


[A] is a member of the character class alnum 
[A] is a member of the character class alpha 
[A] is not a member of the character class cntrl 
[A] is not a member of the character class digit 
[A] is a member of the character class graph 
[A] is not a member of the character class lower 
[A] is a member of the character class print 
[A] is not a member of the character class punct 
[A] is not a member of the character class space 
[A] is a member of the character class upper 
[A] is a member of the character class xdigit 


wcwidth

Determines the number of printing positions on a display device required for the specified wide character.

Format

#include <wchar.h>

int wcwidth (wchar_t wc);


Arguments

wc

A wide character.

Description

This function determines the number of column positions needed for the specified wide character wc. The value of wc must be a valid wide character in the current locale.

Return Values

x The number of printing positions required for wc.
0 If wc is a null character.
--1 Indicates that wc does not represent a valid printing wide character.

wmemchr

Locates the first occurence of a specified wide character in an array of wide characters.

Format

#include <wchar.h>

wchar_t wmemchr (const wchar_t *s, wchar_t c, size_t n);

Function Variants This function also has variants named _wmemchr32 and _wmemchr64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Arguments

s

A pointer to an array of wide characters to be searched.

c

The wide character value to search for.

n

The maximum number of wide characters in the array to be searched.

Description

This function locates the first occurrence of the specified wide character in the initial n wide characters of the array pointed to by s.

Return Values

x A pointer to the first occurrence of the wide character in the array.
NULL The specified wide character does not occur in the array.

wmemcmp

Compares two arrays of wide characters.

Format

#include <wchar.h>

int wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n);


Arguments

s1, s2

Pointers to wide-character arrays.

n

The maximum number of wide characters to be compared.

Description

This function compares the first n wide characters of the array pointed to by s1 with the first n wide characters of the array pointed to by s2. The wide characters are compared not according to locale-dependent collation rules, but as integral objects of type wchar_t .

Return Values

0 Arrays are equal.
Positive value The first array is greater than the second.
Negative value The first array is less than the second.

wmemcpy

Copies a specified number of wide characters from one wide-character array to another.

Format

#include <wchar.h>

wchar_t wmemcpy (wchar_t *s1, const wchar_t *s2, size_t n);

Function Variants This function also has variants named _wmemcpy32 and _wmemcpy64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Arguments

s1

A pointer to the destination array.

s2

A pointer to the source array.

n

The number of wide characters to be copied.

Description

This function copies n wide characters from the array pointed to by s2 to the array pointed to by s1.

Return Values

x The value of s1.

wmemmove

Copies a specified number of wide characters from one wide-character array to another.

Format

#include <wchar.h>

wchar_t wmemmove (wchar_t *s1, const wchar_t *s2, size_t n);

Function Variants This function also has variants named _wmemmove32 and _wmemmove64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Arguments

s1

A pointer to the destination array.

s2

A pointer to the source array.

n

The number of wide characters to be moved.

Description

This function copies n wide characters from the location pointed to by s2 to the location pointed to by s1.

The wmemmove and wmemcpy routines perform the same function, except that wmemmove ensures that the original contents of the source array are copied to the destination array even if the two arrays overlap. Where such overlap is possible, programs that require portability should use wmemmove , not wmemcopy .


Return Values

x The value of s1.

wmemset

Sets a specified value to a specified number of wide characters in an array of wide characters.

Format

#include <wchar.h>

wchar_t wmemset (wchar_t *s, wchar_t c, size_t n);

Function Variants This function also has variants named _wmemset32 and _wmemset64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Arguments

s

A pointer to the array of wide characters.

c

The value to be placed in the first n wide characters of the array.

n

The number of wide characters to be set to the specified value c.

Description

This function copies the value of c into each of the first n wide characters of the array pointed to by s.

Return Values

x The value of s.

wprintf

Performs formatted output from the standard output (stdout). See Chapter 2 for information on format specifiers.

Format

#include <wchar.h>

int wprintf (const wchar_t *format, ...);


Arguments

format

A pointer to a wide-character string containing the format specifications. For more information about format and conversion specifications and their corresponding arguments, see Chapter 2.

...

Optional expressions whose resultant types correspond to conversion specifications given in the format specification.

If no conversion specifications are given, the output sources can be omitted. Otherwise, the function calls must have exactly as many output sources as there are conversion specifications, and the conversion specifications must match the types of the output sources.

Conversion specifications are matched to output sources in left-to-right order. Excess output pointers, if any, are ignored.


Description

This function is equivalent to the fwprintf function with the stdout argument interposed before the wprintf arguments.

Return Values

n The number of wide characters written.
Negative value Indicates an error. The function sets errno to one of the following:
  • EILSEQ -- Invalid character detected.
  • EINVAL -- Insufficient arguments.
  • ENOMEM -- Not enough memory available for conversion.
  • ERANGE -- Floating-point calculations overflow.
  • EVMSERR -- Nontranslatable VMS error. vaxc$errno contains the VMS error code. This might indicate that conversion to a numeric value failed because of overflow.

The function can also set errno to the following as a result of errors returned from the I/O subsystem:

  • EBADF -- The file descriptor is not valid.
  • EIO -- I/O error.
  • ENOSPC -- No free space on the device containing the file.
  • ENXIO -- Device does not exist.
  • EPIPE -- Broken pipe.
  • ESPIPE -- Illegal seek in a file opened for append.
  • EVMSERR -- Nontranslatable VMS error. vaxc$errno contains the VMS error code. This indicates that an I/O error occurred for which there is no equivalent C error code.

wrapok

In the UNIX system environment, allows the wrapping of a word from the right border of the window to the beginning of the next line. This routine is provided only for UNIX software compatibility and serves no function in the OpenVMS environment.

Format

#include <curses.h>

wrapok (WINDOW *win, bool boolf);


Arguments

win

A pointer to the window.

boolf

A Boolean TRUE or FALSE value. If boolf is FALSE, scrolling is not allowed. This is the default setting. The bool type is defined in the <curses.h> header file as follows:


#define bool int 


write

Writes a specified number of bytes from a buffer to a file.

Format

#include <unistd.h>

ssize_t write (int file_desc, void *buffer, size_t nbytes); (ISO POSIX-1)

int write (int file_desc, void *buffer, int nbytes); (COMPATABILITY)


Arguments

file_desc

A file descriptor that refers to a file currently opened for writing or updating.

buffer

The address of contiguous storage from which the output data is taken.

nbytes

The maximum number of bytes involved in the write operation.

Description

If the write is to an RMS record file and the buffer contains embedded new-line characters, more than one record may be written to the file. Even if there are no embedded new-line characters, if nbytes is greater than the maximum record size for the file, more than one record will be written to the file. The write function always generates at least one record.

If the write is to a mailbox and the third argument, nbytes, specifies a length of 0, an end-of-file message is written to the mailbox. This occurs for mailboxes created by the application using SYS$CREMBX, but not for mailboxes created to implement POSIX pipes. For more information, see Chapter 5.


Return Values

x The number of bytes written.
--1 Indicates errors, including undefined file descriptors, illegal buffer addresses, and physical I/O errors.

wscanf

Reads input from the standard input (stdin) under control of the wide-character format string.

Format

#include <wchar.h>

int wscanf (const wchar_t *format, ...);


Arguments

format

A pointer to a wide-character string containing the format specifications. For more information about format and conversion specifications and their corresponding arguments, see Chapter 2.

...

Optional expressions whose results correspond to conversion specifications given in the format specification.

If no conversion specifications are given, you can omit the input pointers. Otherwise, the function calls must have exactly as many input pointers as there are conversion specifications, and the conversion specifications must match the types of the input pointers.

Conversion specifications are matched to input sources in left-to-right order. Excess input pointers, if any, are ignored.


Description

This function is equivalent to the fwscanf function with the stdin arguments interposed before the wscanf arguments.

Return Values

n The number of input items assigned. The number can be less than provided for, even zero, in the event of an early matching failure.
EOF Indicates an error. An input failure occurred before any conversion.


Appendix A
Compaq C Socket Routine Reference

This appendix describes the aspects of the Compaq C language that pertain to the writing of Internet application programs for the TCP/IP Services for OpenVMS product (formerly the VMS/ULTRIX Connection). TCP/IP Services for OpenVMS is the Compaq implementation of the TCP/IP (Transmission Control Protocol/Internet Protocol) protocol.

For a description of Internet details, such as protocols, protocol types, and sockets, see the TCP/IP Services for OpenVMS System Management. For more information on how to write socket programs, see the UNIX Supplementary Documents, System Manager.

A.1 Porting Considerations

This section contains information that you should consider when writing Internet application programs for the TCP/IP Services for OpenVMS. These considerations will help to make your programs more portable.

A.1.1 Calling an IPC Routine from an AST State

Calls to various Interprocess Communication (IPC) routines use a static area within which they return information. The OpenVMS environment allows an asynchronous system trap (AST) routine to interrupt an IPC routine during its execution. In addition, the ASTs of more privileged modes can interrupt ASTs of less privileged modes. Therefore, caution needs to be observed when calling an IPC routine from an AST state, while a similar IPC routine is being called from a non-AST state or a less privileged mode.

The IPC routines that use a static area are:

In VMS Version 5.2, sockets should not be created or destroyed within ASTs.

A.1.2 Calling from KERNEL or EXEC Modes

Several IPC routines access files in order to retrieve their information. These routines should not be called from either the KERNEL or EXEC modes when ASTs are disabled. These IPC routines are:

A.1.3 Event Flags

IPC routines may use event flags during their operation. The event flags are assigned by using the library routine LIB$GET_EF and are released when the routine no longer needs them.

A.1.4 Suppressing Compaq C Compilation Warnings

Certain parameters to the IPC routines may require type casting to suppress Compaq C compilation warnings. Type casting is required because of parameter prototyping, which the Compaq C header ( .h ) files have in order to be ANSI compliant. These header files are unlike UNIX header files, whose IPC routines are not parameter prototyped.

A.1.5 Header Files

It is acceptable to include header files on an OpenVMS system without using angle brackets (< >) or double quotes (" "). For example, #include types . This form of the #include preprocessor directive is possible on OpenVMS systems because all header files are located in a text library in SYS$LIBRARY. On UNIX systems, however, header files must be specified with angle brackets (< >) or double quotes (" ") and any subdirectories that are needed to locate a header file. For example, to include the header file socket.h , use the following form of the #include directive:


#include <sys/socket.h> 

A.2 Compaq C Structures

The socket routines make use of several Compaq C structures. Table A-1 lists these structures and the header files in which they are defined.

Table A-1 Structures Used by Socket Routines
Structure Name Header File
in_addr <in.h>
sock_addr_in <in.h>
hostent <netdb.h>
netent <netdb.h>
servent <netdb.h>
linger <socket.h>
sock_addr <socket.h>
msghdr <socket.h>
timeval <socket.h>
iovec <uio.h>

A.3 Internet Protocols

The Internet protocol family is a collection of protocols layered on the Internet Protocol (IP) transport layer, and using the Internet address format. This section describes the Transmission Control Protocol and User Datagram Protocol.

A.3.1 Transmission Control Protocol

The Transmission Control Protocol (TCP) provides a reliable, flow-controlled, two-way transmission of data. It is a byte-stream protocol used to support the SOCK_STREAM abstraction. TCP uses the standard Internet address format and, in addition, provides a per host collection of port addresses. Thus, each address is composed of an Internet address specifying the host and network with a specific TCP port on the host identifying the peer entity.

Sockets utilizing the TCP protocol are either active or passive. Active sockets initiate connections to passive sockets. By default, TCP sockets are created active; to create a passive socket the listen system call must be used after binding the socket with the bind system call. Only passive sockets may use the accept call to accept incoming connections. Only active sockets may use the connect call to initiate connections.

Passive sockets may underspecify their location to match incoming connection requests from multiple networks. This technique, called wildcard addressing, allows a single server to provide service to clients on multiple networks. To create a socket that listens to all hosts on any network, the Internet address inaddr_any must be bound. The TCP port must be specified at this time. If the Internet address is not INADDR and the port is not specified, the system will assign a port. Once a connection has been established, the socket's address is fixed by the peer entity's location. The address assigned to the socket is the address associated with the network interface through which packets are being transmitted and received. Normally this address corresponds to the peer entity's network.

TCP supports one socket option that is set with setsockopt and tested with getsockopt . Under most circumstances, TCP sends data when it is presented; when outstanding data has not yet been acknowledged, it gathers small amounts of output to be sent in a single packet once an acnowledgement is received. For a small number of clients, such as window systems that send a stream of mouse events that receive no replies, this packetization may cause significant delays. Therefore, TCP provides a Boolean option, tcp_nodelay (from <netinet/tcp.h> ), to defeat this algorithm. The option level for the setsockopt call is the protocol number for TCP, which is available from getprotobyname .


Previous Next Contents Index
  

1.800.AT.COMPAQ

privacy and legal statement