Functions to Change for Interix


This section describes functions that need to be changed or removed before codewill compile under Interix. These functions include the following:

  • Math routines. (See Math Routines later in this section.)

  • Regular expressions. (See Regular Expressions later in this section.)

  • System and C library and other platform-specific APIs. (See System/C Library and Miscellaneous APIs later in this section.)

  • Extended UNIX Code (EUC) characters are not supported by Interix and should not be used.

  • Wide character-type APIs are not supported by Interix and should not be used.

  • Multibyte character-type APIs (ISO/ANSI C and UNIX98) are not supportedby Interix and should not be used.

  • Long-long character type (64-bit integer) APIs are not supported by Interixand should not be used.

  • Message handling APIs are not supported by Interix and should not be used.

Math Routines

There are two sets of mathematical routines not supported by Interix: IEEE floating-point environment control routines and conversion routines.

Interix does not support IEEE floating-point environment control routines,as shown in Table 10.22.

Table 10.22: IEEE Floating-Point Environment Control Routines Not Supported by Interix

Function Name

Suggested Interix Replacement

fpclass

No equivalent in Interix.

fpgetmask

No equivalent in Interix.

fpgetround

No equivalent in Interix.

fpgetsticky

No equivalent in Interix.

fpsetmask

No equivalent in Interix.

fpsetround

No equivalent in Interix.

fpsetsticky

No equivalent in Interix.

Interix does not support conversion routines (such as converting decimal recordto double), as shown in Table 10.23.

Table 10.23: Conversion Routines Not Supported by Interix

Function Name

Suggested Interix Replacement

decimal_to_double

No equivalent in Interix.

decimal_to_extended

No equivalent in Interix.

decimal_to_floating

No equivalent in Interix.

decimal_to_quadruple

No equivalent in Interix.

decimal_to_single

No equivalent in Interix.

double_to_decimal

No equivalent in Interix.

econvert

No equivalent in Interix.

extended_to_decimal

No equivalent in Interix.

fconvert

No equivalent in Interix.

file_to_decimal

No equivalent in Interix.

floating_to_decimal

No equivalent in Interix.

func_to_decimal

No equivalent in Interix.

gconvert

No equivalent in Interix.

qeconvert

No equivalent in Interix.

qfconvert

No equivalent in Interix.

qgconvert

No equivalent in Interix.

quadruple_to_decimal

No equivalent in Interix.

seconvert

No equivalent in Interix.

sfconvert

No equivalent in Interix.

sgconvert

No equivalent in Interix.

single_to_decimal

No equivalent in Interix.

string_to_decimal

No equivalent in Interix.

Regular Expressions

Interix does not support some of the regular expression function calls. However, Table 10.24 on the next page lists functions that can be used to replace them.

Table 10.24: Regular Expression Function Calls Not Supported by Interix

Function Name

Description

Suggested Interix Replacement

re_comp

Compiles and executes a regular expression and returns a character pointer to NULL on success.

regcomp(), regexec()

re_exec

Compiles and executes a regular expression and returns an integer of 0 or 1 on success.

regcomp(), regexec()

regcmp

Compiles a regular expression and returns a pointer to a compiled form.

regcomp()

regex

Executes a regular expression.

regexec()

System/C Library and Miscellaneous APIs

Under this category are many specialized, platform-specific APIs, includingthe following:

  • Command-line and shell APIs. (See the following section.)

  • String manipulation functions. (See the following section.)

  • BSD string and bit functions. (See the following section.)

  • Time handling APIs. (See the following section.)

  • Other system/C library functions. (See the following section.)

  • Kernel calls.

    Kernel calls are not supported by Interix and should not be used.

Command-Line and Shell APIs

Interix does not support calls to obtain information about legal user shells fromthe /etc/shells file, nor does it support the implementation of the popt command-line parser.

Make these changes in Interix for code that uses this feature:

  1. Create an /etc/shells file containing the legal Interix shells /bin/csh, /bin/ksh,/bin/sh, /bin/tcsh.

  2. Add to this file any additional legal shells that have been ported, suchas /bin/bash.

  3. Write functions named endusershell , getusershell , and setusershell , as described in Table 10.25.

Table 10.25: Functions to Implement the Command-Line and Shell APIs in Interix

Function Name

Description

Suggested Interix Replacement

endusershell

Closes the file of legal user shells (/etc/shells).

Create endusershell routine to wrap the standard close() file routine.

getusershell

Gets legal user shells from/etc/shells.

Create getusershell routine to wrap the standard read() file routine.

popt

Parses command-line options.

getopt()

setusershell

Rewinds the file of legal user shells (/etc/shells).

Create setusershell routine to wrap the standard lseek () file routine to set /etc/shells file back to beginning.

String Manipulation Functions

Interix supports most of the standard string handling functions. Interix does not support atoq , memmem , stpcpy , stpncpy , strfmon , strfry , strnlen , and strtows , which need to be replaced as shown in Table 10.26.

Table 10.26: String Handling Functions Not Supported by Interix

Function Name

Description

Suggested Interix Replacement

memmem

Finds the start of the first occurrence of a substring in the memory area.

strstr ()

stpcpy

Copies the source string, including the terminating ˜\0 character, to the destination.

strcpy ()

stpncpy

Copies at most num characters from the source string, including the terminating ˜\0 character, to the destination.

strncpy ()

strfmon

Formats specified amounts according to the format specification and places the result in a character array of size max .

sprintf()

strfry

Randomizes the contents of the string by using rand() to randomly swap characters in the string.

Customize strfry by using rand() .

strnlen

Returns the number of characters in the string, not including the terminating ˜\0 character, but at most maxlen .

strlen()

BSD String and Bit Functions

String interfaces specified by ANSI/ISO C are in String.h. String interfaces found only in the Single UNIX Specification are in Strings.h. The Strings.h file contentsare described in Table 10.27.

Table 10.27: String Interfaces Found in the Strings.h File

Function Name

Description

Suggested Interix Replacement

bcmp

Compares two strings.

strcmp()

bcopy

Copies at most n characters from src string to dest .

strncpy()

bzero

Places len value of 0 bytes in the string.

memset (string, 0, len)

ffs

Finds the first bit set (beginning with the least significant bit) and returns the index of that bit.

Interix supports ffs .

The Interix SDK also supports the BSD 4.4 strsep() and strcasestri() routines.

Time Handling APIs

The time functions that are not supported by Interix and that cannot be implemented by some other Interix API or set of API calls are adjtime , adjtimex , ntp_adjtime , and tzsetwall .

Other System/C Library Functions

Interix does not support some of the system/C library functions. Table 10.28 summarizes these functions.

Table 10.28: System/C Library Functions Not Supported by Interix

Function Name

Description

Suggested Interix Replacement

on_exit

Registers a function to be called at normal program termination.

atexit(void (*function)(void))
Note: This function does not provide for argument passing as on_exit does.

quotactl

Manipulates disk quotas.

No support or equivalent in Interix.

stime

Sets time.

No support or equivalent in Interix.




UNIX Application Migration Guide
Unix Application Migration Guide (Patterns & Practices)
ISBN: 0735618380
EAN: 2147483647
Year: 2003
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net