|
|
The tm structure is used by various time functions in libc (asctime, asctime_r, ascftime, getdate, gmtime, gmtime_r, localtime, localtime_r, mktime, strftime, strptime, wcsftime).
The tm structure on SCO OpenServer has two elements at the end of the structure that are not present on UnixWare and SCO UnixWare 1 and 2:
long tm_tzadj; /* seconds from UTC (east < 0) */ char tm_name[LTZNMAX]; /* name of timezone */
On UnixWare, these values are available only in the external
variables timezone
and tzname
, respectively; these
external variables are also available on SCO OpenServer.
Portable applications should depend only on the external variables, not
on the structure elements.
On SCO OpenServer, the length parameter is defined as type size_t (an unsigned integer), while on UnixWare and SCO UnixWare 1 and 2 it is type int.
The usage of these routines on SCO OpenServer and UnixWare is shown differently on the manual pages.
From the SCO OpenServer manual page:
This code fragment reads in strings and either finds the corresponding node and prints out the string and its length, or prints an error message.#include <stdio.h> #include <stdlib.h>
#define TABSIZE 1000
struct node { /* these are stored in the table */ char *string; int length; }; struct node table[TABSIZE]; /* table to be searched */ . . . { struct node *node_ptr, node; int node_compare( ); /* routine to compare 2 nodes */ char str_space[20]; /* space to read string into */ . . . node.string = str_space; while (scanf("%s", node.string) != EOF) { node_ptr = (struct node *)bsearch((char *)(&node), (char *)table, TABSIZE, sizeof(struct node), node_compare); if (node_ptr != NULL) { (void)printf("string = %20s, length = %d\n", node_ptr->string, node_ptr->length); } else { (void)printf("not found: %s\n", node.string); } } } /* This routine compares two nodes based on an alphabetical ordering of the string field. */ int node_compare(node1, node2) char *node1, *node2; { return (strcmp( ((struct node *)node1)->string, ((struct node *)node2)->string)); }
And, from the UnixWare manual page:
#include <stdio.h> #include <stdlib.h> #include <string.h>struct node { /* these are stored in the table */ char *string; int length; }; static struct node table[] = /* table to be searched */ { { "asparagus", 10 }, { "beans", 6 }, { "tomato", 7 }, { "watermelon", 11 }, };
main() { struct node *node_ptr, node; /* routine to compare 2 nodes */ static int node_compare(const void *, const void *); char str_space[20]; /* space to read string into */
node.string = str_space; while (scanf("%20s", node.string) != EOF) { node_ptr = bsearch( &node, table, sizeof(table)/sizeof(struct node), sizeof(struct node), node_compare); if (node_ptr != NULL) { (void) printf("string = %20s, length = %d\n", node_ptr->string, node_ptr->length); } else { (void)printf("not found: %20s\n", node.string); } } return(0); }
/* routine to compare two nodes based on an */ /* alphabetical ordering of the string field */ static int node_compare(const void *node1, const void *node2) { return (strcmp( ((const struct node *)node1)->string, ((const struct node *)node2)->string)); }
On SCO OpenServer, the bsearch manual page contains the following notes
not on the UnixWare manual page:
For compatibility with the System V Interface Definition (SVID),
include the search.h header file instead of stdlib.h.
The pointers to the key and the element at the base of the table
should be of type
pointer-to-element, and cast to type pointer-to-character.
Although bsearch is declared as type pointer-to-character, the value
returned should be cast into type pointer-to-element.
The following values for the name argument to confstr (defined in unistd.h) are valid on UnixWare and SCO UnixWare 1 and 2, but not on SCO OpenServer:
_CS_HOSTNAME 2 /* name of node */ _CS_RELEASE 3 /* release of operating _CS_VERSION 4 /* version field of utsname _CS_MACHINE 5 /* kind of machine */ _CS_ARCHITECTURE 6 /* instruction set arch */ _CS_HW_SERIAL 7 /* hardware serial number */ _CS_HW_PROVIDER 8 /* hardware manufacturer */ _CS_SRPC_DOMAIN 9 /* secure RPC domain */ _CS_INITTAB_NAME 10 /* name of inittab file used _CS_SYSNAME 11 /* name of operating system
The RTLD_NEXT argument for the handle parameter is unsupported on SCO OpenServer.
While the eaccess routine is supported in libgen on UnixWare 7, it is always more efficient to use:
access(path, EFF_ONLY_OK | mode)than to call another function to check effective UID/GIDs. See access(2).
The UnixWare and SCO OpenServer implementations of fnmatch differ in the header file declarations of flags and return values found in fnmatch.h. Basically, the UnixWare interface is a superset of the SCO OpenServer interface. Some constants are defined with different values; these are managed by the UnixWare kernel for SCO OpenServer applications, and the Binary Compatibility Module for UnixWare and OpenServer Development Kit applications running on SCO OpenServer.
The UnixWare interface supports these additional flags:
#define FNM_BADRANGE 0x008 /* accept [m-a] ranges as [ma] */ #define FNM_BKTESCAPE 0x010 /* allow in []s to quote next anything */ #define FNM_EXTENDED 0x020 /* use full ksh-style patterns */ #define FNM_RETMIN 0x040 /* return length of minimum match */ #define FNM_RETMAX 0x080 /* return length of maximum match */ #define FNM_REUSE 0x100 /* reusing this FNM */ #define FNM_COMPONENT 0x200 /* only matching a component */ #define FNM_SUBEXPR 0x400 /* fill fnm_nsub, fnm_so[], fnm_eo[] */ #define FNM_UNANCHORED 0x800 /* match need not include string start */ #define FNM_NSUBEXPR 10 /* length of fnm_so[] and fnm_eo[] */
Also, the UnixWare interface supports one additional error:
#define FNM_ERROR (-4) /* internal error; probably allocation failure */
A portable application should use only those flags common to the two systems, or first determine the system on which it is running and then use flags appropriate to that system.
The constants used as argument values for ftw and nftw (and defined in ftw.h) on SCO OpenServer and UnixWare are slightly different. A portable program should only use those values common to the two systems or first determine the system on which it is running before issuing the call with appropriate values.
The UnixWare values are a superset of the SCO OpenServer values; the extensions provided on UnixWare are:
#define FTW_ERR 8 /* FTW_ERRORS only; internal nftw() failure */ #define _FTW_FINDDIR 020 /* continue even if getcwd() fails */ #define FTW_TRYCHDIR (FTW_CHDIR|_FTW_FINDDIR) /* for nftw() to try getcwd */ #define FTW_ERRORS 040 /* call fcn for nftw() internal errors, too */
SCO OpenServer and UnixWare have different constant and structure definitions in glob.h for the glob(3C) routine.
While the glob_t structure has elements on both systems not found on the other, these elements are for system use only, and should not affect application compatibility.
/* UnixWare glob_t structure */ typedef struct { struct gl_str *gl_str; /* for memory management */ char **gl_pathv; /* list of matched pathnames */ size_t gl_pathc; /* length of gl_pathv[] (less 1) */ size_t gl_offs; /* slots to reserve in gl_pathv[] */ } glob_t;/* SCO OpenServer glob_t structure */ typedef struct { size_t gl_pathc; /* count of paths matched by pattern */ char **gl_pathv; /* pointer to list of matched pathnames */ size_t gl_offs; /* slots to reserve in gl_pathv[] */ /* Internal SCO variables */ size_t gl_vnum; /* Number of entries in gl_pathv */ size_t gl_vmax; /* Maximum entries in gl_pathv */ } glob_t;
The manifest constants supported on UnixWare are a superset of those provided on SCO OpenServer. The additional constants are:
#define GLOB_FULLMARK 0x0080 /* append "/", "@", "*", "|" like ls(1) */ #define GLOB_NOCOLLATE 0x0100 /* use "C" sorting order */ #define GLOB_OKAYDOT 0x0200 /* permit leading . to match specials */ #define GLOB_BADRANGE 0x0400 /* accept [m-a] ranges as [ma] */ #define GLOB_BKTESCAPE 0x0800 /* allow in []s to quote next anything */ #define GLOB_EXTENDED 0x1000 /* use full ksh-style patterns */
Some constants are defined with different values; these are managed by the UnixWare kernel for SCO OpenServer applications, and the Binary Compatibility Module for UnixWare and OpenServer Development Kit applications running on SCO OpenServer.
The implementation of iconv on SCO OpenServer supports a flag mechanism that is not supported by UnixWare (or by the X/Open standard). This mechanism allows you to set a flag in a state field in the conversion descriptor used as input to iconv.
These flags (_ICONV_DELETE and _ICONV_COMP) and the state field in the conversion descriptor are not supported by UnixWare and the UnixWare and OpenServer Development Kit. SCO OpenServer binaries that run on UnixWare will fail if they attempt to set the conversion descriptor state field with these flags.
On SCO OpenServer, it is necessary to include nan.h, math.h, and ieeefp.h to compile a program using these functions. On UnixWare, nan.h does not exist, so include only math.h and ieeefp.h.
On SCO OpenServer, the size of the jmp_buf used by longjmp and setjmp is defined in setjmp.h as 6; on UnixWare, it is 10. This presents no problem for source code portability. SCO OpenServer binaries that use jmp_buf will run correctly on UnixWare 7, and UnixWare and OpenServer Development Kit-compiled binaries will run correctly on SCO OpenServer systems with the Binary Compatibility Module installed.
The SCO OpenServer implementation of mallinfo is available only in libc.a.
The header file langinfo.h on UnixWare contains a larger set of manifest constants than the same header file on SCO OpenServer. A portable application should only expect the constants that are defined on both systems to be available.
The additional constants defined on UnixWare in langinfo.h are:
#define _MAXSTRMSG 57 /* Maximum number of strings in langinfo */ #define QUITSTR 58 /* "yes, go away" answer */ #define QUITEXPR 59 /* "go away" response ERE string */ #define DATECMD_FMT 60 /* format string used by date(1) */ #define CHARCLASS 61 /* all valid wctype() strings, ;-separated */
Also, some constants are defined with different values; these are managed by the UnixWare kernel for SCO OpenServer applications, and the Binary Compatibility Module for UnixWare and OpenServer Development Kit applications running on SCO OpenServer.
Several routines ( ) make use of the passwd structure defined in
pwd.h.
This structure contains two members (pw_uid
and pw_gid)
whose types (uid_t
and gid_t,
respectively) are
defined differently depending on the operating system.
On UnixWare and SCO UnixWare 1 and 2, uid_t
and gid_t
are both
defined as long;
on
SCO OpenServer, they are both unsigned short
.
The SCO OpenServer implementation makes up for this difference by adding
two pad fields to the passwd structure, as shown below:
uid_t pw_uid; /* user ID */ short __pad1; /* padded space */ gid_t pw_gid; /* group ID */ short __pad2; /* padded space */
On SCO OpenServer, the sigset_t data type (use by the functions sigaddset, sigdelset, sigemptyset, sigfillset, and sigismember) is declared a long in sys/signal.h. On UnixWare, it is declared as follows:
typedef struct { /* signal set type */ unsigned int sa_sigbits[4]; } sigset_t;
When running a UnixWare and OpenServer Development Kit-compiled binary on SCO OpenServer, the Binary Compatibility Module puts the data in the SCO OpenServer structure before executing the function. Similarly, the UnixWare 7 kernel will put data from an SCO OpenServer binary into the UnixWare structure.
Also see ``setcontext(2) binary compatibility notes''.
The following UnixWare sysconf commands are not supported on SCO OpenServer, and a UnixWare and OpenServer Development Kit-compiled binary will get ENOSYS if it attempts to use these commands on SCO OpenServer:
_SC_LOGNAME_MAX _SC_NACLS_MAX _SC_NPROCESSORS_CONF _SC_NPROCESSORS_ONLN _SC_NPROCESSES _SC_TOTAL_MEMORY _SC_USEABLE_MEMORY _SC_GENERAL_MEMORY _SC_DEDICATED_MEMORY _SC_NCGS_CONF _SC_NCGS_ONLN _SC_MAX_CPUS_PER_CG _SC_CG_SIMPLE_IMPL _SC_CACHE_LINE _SC_AES_OS_VERSION
The following SCO OpenServer sysconf commands are not supported on UnixWare, and are not available to UnixWare and OpenServer Development Kit-compiled programs:
_SC_32BIT_INODES _SC_FSYNC _SC_KERNEL_PROC _SC_KERNEL_PROC_MAX _SC_KERNEL_REGION _SC_KERNEL_REGION_MAX _SC_KERNEL_FILE _SC_KERNEL_FILE_MAX _SC_KERNEL_INODE _SC_KERNEL_INODE_MAX _SC_KERNEL_S5INODE _SC_KERNEL_S5INODE_MAX _SC_KERNEL_DISK _SC_KERNEL_DISK_MAX _SC_KERNEL_CLIST _SC_KERNEL_CLIST_MAX _SC_KERNEL_DMABUF _SC_KERNEL_DMABUF_MAX _SC_KERNEL_MOUNT _SC_KERNEL_MOUNT_MAX _SC_KERNEL_FLCKREC _SC_KERNEL_FLCKREC_MAX _SC_KERNEL_PINODE _SC_KERNEL_PINODE_MAX _SC_MAPPED_FILES
The following UnixWare 7 sysconf commands are not supported on SCO UnixWare 2.1.X, and a UnixWare and OpenServer Development Kit-compiled binary will get ENOSYS if it attempts to use these commands on SCO UnixWare 2.1.X:
_SC_TOTAL_MEMORY _SC_USEABLE_MEMORY _SC_GENERAL_MEMORY _SC_DEDICATED_MEMORY _SC_NCGS_CONF _SC_NCGS_ONLN _SC_MAX_CPUS_PER_CG _SC_CG_SIMPLE_IMPL _SC_CACHE_LINE
Note that the file accessed by ttyslot on SCO OpenServer is /var/utmp, while on UnixWare it is /var/adm/utmp. For SCO OpenServer binaries on UnixWare 7, the kernel directs the program to the proper file. For UnixWare and OpenServer Development Kit-compiled binaries on SCO OpenServer, the Binary Compatibility Module maps the file names.