[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


blksize_t   st_blksize;
blkcnt_t    st_blocks;

According to the X/Open standard, st_blksize is the filesystem-specific preferred I/O blocksize for this file. On OpenVMS systems, st_blksize is set to the device buffer size multiplied by the disk cluster size. st_blocks is set to the allocated size of the file, in blocks. The blocksize used to calculate st_blocks is not necessarily the same as st_blksize and, in most cases, will not be the same.
  • In struct stat , member st_ino is of type ino_t . In previous C RTL versions, it was of type ino_t [3] (array of 3 ino_t ). Since ino_t has changed from a word to a quadword, the size of this member has increased by one word. The principal significance of this change is that it makes st_ino a scalar, which is how most open source applications define it.
  • The new definition of ino_t also affects applications that include the <dirent.h> header file. In struct dirent , member d_ino changes in the same way as the st_ino member of struct stat in <stat.h> .
  • Several macros that are not part of any standard were introduced in <stat.h> to facilitate access to the constituent parts of ino_t values:
    S_INO_NUM(ino), S_INO_SEQ(ino), and S_INO_RVN(ino) return the FILES-11 file number, sequence number, and relative volume number of ino, respectively, as unsigned short s.

    S_INO_RVN_RVN(ino) returns the byte of the RVN field containing the relative volume number;

    S_INO_RVN_NMX(ino) returns the byte of the RVN field containing the file number extension.

    Although individual components can be broken out like this, they are not part of the X/Open standard and should not be relied on in portable applications.
  • Semantic changes
    Values of type dev_t are now unique for each device across clusters. An algorithm based on device name and allocation class or SCSSYSTEMID (for single-pathed devices) calculates the device id value having these characteristics, an X/Open standard requirement. Typically, the combination of file number and device id uniquely identifies a file in a cluster.
    This change affects stat structure members st_dev and st_rdev . For compatibility with previous releases, st_rdev is set to either 0 or st_dev .

    Note (ALPHA, I64)

    On OpenVMS Alpha and I64 systems, the stat , fstat , utime , and utimes functions have been enhanced to take advantage of the new file-system support for POSIX compliant file timestamps.

    This support is available only on ODS-5 devices on OpenVMS Alpha systems beginning with a version of OpenVMS Alpha after Version 7.3.

    Before this change, the stat and fstat functions were setting the values of the st_ctime , st_mtime , and st_atime fields based on the following file attributes:
    st_ctime - ATR$C_CREDATE (file creation time)
    st_mtime - ATR$C_REVDATE (file revision time)
    st_atime - was always set to st_mtime because no support for file access time was available


    Also, for the file-modification time, utime and utimes were modifying the ATR$C_REVDATE file attribute, and ignoring the file-access-time argument.

    After the change, for a file on an ODS-5 device, the stat and fstat functions set the values of the st_ctime , st_mtime , and st_atime fields based on the following new file attributes:
    st_ctime - ATR$C_ATTDATE (last attribute modification time)
    st_mtime - ATR$C_MODDATE (last data modification time)
    st_atime - ATR$C_ACCDATE (last access time)


    If ATR$C_ACCDATE is zero, as on an ODS-2 device, the stat and fstat functions set st_atime to st_mtime .

    For the file-modification time, the utime and utimes functions modify both the ATR$C_REVDATE and ATR$C_MODDATE file attributes. For the file-access time, these functions modify the ATR$C_ACCDATE file attribute. Setting the ATR$C_MODDATE and ATR$C_ACCDATE file attributes on an ODS-2 device has no effect.

    For compatibility, the old behavior of stat , fstat , utime , and utimes remains the default, regardless of the kind of device.

    The new behavior must be explicitly enabled by defining the DECC$EFS_FILE_TIMESTAMPS logical name to ENABLE before invoking the application. Setting this logical does not affect the behavior of stat , fstat , utime , and utimes for files on an ODS-2 device.

    Return Values

    0 Indicates success.
    - 1 Indicates an error other than a privilege violation; errno is set to indicate the error.
    - 2 Indicates a privilege violation.

    statvfs (ALPHA, I64)

    Gets information about a device containing the specified file.

    Format

    #include <statvfs.h>

    int statvfs (const char *restrict path, struct statvfs *restrict buffer);


    Arguments

    path

    Any file on a mounted device.

    buffer

    Pointer to a statvfs structure to hold the returned information.

    Description

    The statvfs function returns descriptive information about the device containing the specified file. Read, write, or execute permission of the specified file is not required. The returned information is in the format of a statvfs structure, which is defined in the <statvfs.h> header file and contains the following members:
    unsigned long f_bsize - Preferred block size.

    unsigned long f_frsize - Fundamental block size.

    fsblkcnt_t f_blocks - Total number of blocks in units of f_frsize .

    fsblkcnt_t f_bfree - Total number of free blocks. If f_bfree would assume a meaningless value due to the misreporting of free block count by $GETDVI for a DFS disk, then f_bfree is set to the maximum block count.

    fsblkcnt_t f_bavail - Number of free blocks available. Set to the unused portion of the caller's disk quota.

    fsfilcnt_t f_files - Total number of file serial numbers (for example, inodes).

    fsfilcnt_t f_ffree - Total number of free file serial numbers. For OpenVMS systems, this value is calculated as freeblocks/clustersize.

    fsfilcnt_t f_favail - Number of file serial numbers available to a non-privileged process (0 for OpenVMS systems).

    unsigned long f_fsid - File system identifier. This identifier is based on the allocation-class device name. This gives a unique value based on device, as long as the device is locally mounted.

    unsigned long f_flag - Bit mask representing one or more of the following flags:
    ST_RONLY - The volume is read-only.
    ST_NOSUID - The volume has protected subsystems enabled.


    unsigned long f_namemax - Maximum length of a file name.
    char f_basetype[64] - Device-type name.
    char f_fstr[64] - Logical volume name.
    char __reserved[64] - Media type name.

    Upon successful completion, statvfs returns 0 (zero). Otherwise, it returns - 1 and sets errno to indicate the error.

    See also fstatvfs .


    Return Value

    0 Sucessful completion.
    - 1 Indicates an error. errno is set to one of the following:
    • EACCES - Search permission is denied for a component of the path prefix.
    • EIO - An I/O error occurred while reading the device.
    • EINTR - A signal was caught during execution of the function.
    • EOVERFLOW - One of the values to be returned cannot be represented correctly in the structure pointed to by buffer.
    • ENAMETOOLONG - The length of a component of the path parameter exceeds NAME_MAX, or the length of the path parameter exceeds PATH_MAX.
    • ENOENT - A component of path does not name an existing file, or path is an empty string.
    • ENOTDIR - A component of the path prefix of the path parameter is not a directory.

    strcasecmp

    Does a case-insensitive comparison of two 7-bit ASCII strings.

    Format

    #include <strings.h>

    int strcasecmp (const char *s1, const char *s2);


    Arguments

    s1

    The first of two strings to compare.

    s2

    The second of two strings to compare.

    Description

    The strcasecmp function is case-insensitive. The returned lexicographic difference reflects a conversion to lowercase.

    The strcasecmp function works for 7-bit ASCII compares only. Do not use this function for internationalized applications.


    Return Value

    n An integer value greater than, equal to, or less than 0 (zero), depending on whether the s1 string is greater than, equal to, or less than the s2 string.

    strcat

    Concatenates str_2, including the terminating null character, to the end of str_1.

    Format

    #include <string.h>

    char *strcat (char *str_1, const char *str_2);

    Function Variants The strcat function has variants named _strcat32 and _strcat64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

    Arguments

    str_1, str_2

    Pointers to null-terminated character strings.

    Description

    See strncat .

    Return Value

    x The address of the first argument, str_1, which is assumed to be large enough to hold the concatenated result.

    Example


    #include <string.h>
    #include <stdio.h>
    
    /* This program concatenates two strings using the strcat       */
    /* function, and then manually compares the result of strcat    */
    /* to the expected result.                                      */
    
    #define S1LENGTH 10
    #define S2LENGTH 8
    
    main()
    {
        static char s1buf[S1LENGTH + S2LENGTH] = "abcmnexyz";
        static char s2buf[] = " orthis";
        static char test1[] = "abcmnexyz orthis";
    
        int i;
        char *status;
    
        /* Take static buffer s1buf, concatenate static buffer      */
        /* s2buf to it, and compare the answer in s1buf with the    */
        /* static answer in test1.                                  */
    
        status = strcat(s1buf, s2buf);
        for (i = 0; i <= S1LENGTH + S2LENGTH - 2; i++) {
            /* Check for correct returned string.   */
    
            if (test1[i] != s1buf[i])
                printf("error in strcat");
        }
    }
    

    strchr

    Returns the address of the first occurrence of a given character in a null-terminated string. The terminating null character is considered to be part of the string.

    Format

    #include <string.h>

    char *strchr (const char *str, int character);

    Function Variants The strchr function has variants named _strchr32 and _strchr64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

    Arguments

    str

    A pointer to a null-terminated character string.

    character

    An object of type int .

    Description

    See strrchr .

    Return Values

    x The address of the first occurrence of the specified character.
    NULL Indicates that the character does not occur in the string.

    Example


    #include <stdio.h>
    #include <string.h>
    
    main()
    {
    
        static char s1buf[] = "abcdefghijkl lkjihgfedcba";
    
        int i;
    
        char *status;
    
    /*  This program checks the strchr function by incrementally   */
    /*  going through a string that ascends to the middle and then */
    /*  descends towards the end.                                  */
    
        for (i = 0; s1buf[i] != '\0' && s1buf[i] != ' '; i++) {
            status = strchr(s1buf, s1buf[i]);
    
    /* Check for pointer to leftmost character - test 1.           */
    
            if (status != &s1buf[i])
                printf("error in strchr");
        }
    }
    

    strcmp

    Compares two ASCII character strings and returns a negative, 0, or positive integer, indicating that the ASCII values of the individual characters in the first string are less than, equal to, or greater than the values in the second string.

    Format

    #include <string.h>

    int strcmp (const char *str_1, const char *str_2);


    Arguments

    str_1, str_2

    Pointers to character strings.

    Description

    The strings are compared until a null character is encountered or until the strings differ.

    Return Values

    < 0 Indicates that str_1 is less than str_2.
    = 0 Indicates that str_1 equals str_2.
    > 0 Indicates that str_1 is greater than str_2.

    strcoll

    Compares two strings and returns an integer that indicates if the strings differ and how they differ. The function uses the collating information in the LC_COLLATE category of the current locale to determine how the comparison is performed.

    Format

    #include <string.h>

    int strcoll (const char *s1, const char *s2);


    Arguments

    s1, s2

    Pointers to character strings.

    Description

    The strcoll function, unlike strcmp , compares two strings in a locale-dependent manner. Because no value is reserved for error indication, the application must check for one by setting errno to 0 before the function call and testing it after the call.

    See also strxfrm .


    Return Values

    < 0 Indicates that s1 is less than s2.
    = 0 Indicates that the strings are equal.
    > 0 Indicates that s1 is greater than s2.

    strcpy

    Copies all of source, including the terminating null character, into dest.

    Format

    #include <string.h>

    char *strcpy (char *dest, const char *source);

    Function Variants The strcpy function has variants named _strcpy32 and _strcpy64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

    Arguments

    dest

    Pointer to the destination character string.

    source

    Pointer to the source character string.

    Description

    The strcpy function copies source into dest, and stops after copying source's null character.

    The behavior of this function is undefined if the area pointed to by dest overlaps the area pointed to by source.


    Return Value

    x The address of dest.

    strcspn

    Returns the length of the prefix of a string that consists entirely of characters not in a specified set of characters.

    Format

    #include <string.h>

    size_t strcspn (const char *str, const char *charset);


    Arguments

    str

    A pointer to a character string. If this character string is a null string, 0 is returned.

    charset

    A pointer to a character string containing the set of characters.

    Description

    The strcspn function scans the characters in the string, stops when it encounters a character found in charset, and returns the length of the string's initial segment formed by characters not found in charset.

    If none of the characters match in the character strings pointed to by str and charset, strcspn returns the length of string.


    Return Value

    x The length of the segment.

    strdup

    Duplicates the specified string.

    Format

    #include <string.h>

    char *strdup (const char *s1);

    Function Variants The strdup function has variants named _strdup32 and _strdup64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

    Argument

    s1

    The string to be duplicated.

    Description

    The strdup function returns a pointer to a string that is an exact duplicate of the string pointed to by s1. The malloc function is used to allocate space for the new string. The strdup function is provided for compatibility with existing systems.

    Return Values

    x A pointer to the resulting string.
    NULL Indicates an error.

    strerror

    Maps the error number in error_code to a locale-dependent error message string.

    Format

    #include <string.h>

    char *strerror (int error_code); (ANSI C)

    char *strerror (int error_code[, int vms_error_code]); (HP C EXTENSION)


    Arguments

    error_code

    An error code.

    vms_error_code

    An OpenVMS error code.

    Description

    The strerror function uses the error number in error_code to retrieve the appropriate locale-dependent error message. The contents of the error message strings are determined by the LC_MESSAGES category of the program's current locale.

    When a program is not compiled with any standards-related feature-test macros (see Section 1.5.1), strerror has a second argument (vms_error_code), which is used in the following way:

    • If error_code is EVMSERR and there is a second argument, then that second argument is used as the vaxc$errno value.
    • If error_code is EVMSERR and there is no second argument, look at vaxc$errno to get the OpenVMS error condition.

    See the Example section.

    Use of the second argument is not included in the ANSI C definition of strerror and is, therefore, not portable.

    Because no return value is reserved to indicate an error, applications should set the value of errno to 0, call strerror , and then test the value of errno ; a nonzero value indicates an error condition.


    Return Value

    x A pointer to a buffer containing the appropriate error message. Do not modify this buffer in your programs. Moreover, calls to the strerror function may overwrite this buffer with a new message.

    Example


    #include <stdio.h>
    #include <errno.h>
    #include <string.h>
    #include <stdlib.h>
    #include <ssdef.h>
    
    main()
    {
        puts(strerror(EVMSERR));
        errno = EVMSERR;
        vaxc$errno = SS$_LINKEXIT;
        puts(strerror(errno));
        puts(strerror(EVMSERR, SS$_ABORT));
        exit(1);
    }
    

    Running this example produces the following output:


    nontranslatable vms error code: <none>
    network partner exited
    abort
    


    Previous Next Contents Index