Browse Prior Art Database

Algorithm to Support the Emulation of the UNIX MKTEMP() System Call in OS/2

IP.com Disclosure Number: IPCOM000112343D
Original Publication Date: 1994-Apr-01
Included in the Prior Art Database: 2005-Mar-27
Document File: 2 page(s) / 57K

Publishing Venue

IBM

Related People

Chang, D: AUTHOR [+3]

Abstract

The emulation of UNIX* system calls is an accepted approach to porting UNIX C source code to OS/2**. The differences between these two operating systems makes the emulation of some Unix system calls particularly challenging. The mktemp() function used in UNIX to generate unique random names is one of these. This function used to dynamically generate unique random names has no equivalent in OS/2. This invention provides an algorithm that can be used to obtain a very close emulation of the mktemp() function in OS/2.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

Algorithm to Support the Emulation of the UNIX MKTEMP() System Call
in OS/2

      The emulation of UNIX* system calls is an accepted approach to
porting UNIX C source code to OS/2**.  The differences between these
two operating systems makes the emulation of some Unix system calls
particularly challenging.  The mktemp() function used in UNIX to
generate unique random names is one of these.  This function used to
dynamically generate unique random names has no equivalent in OS/2.
This invention provides an algorithm that can be used to obtain a
very close emulation of the mktemp() function in OS/2.

      The detailed algorithm for an OS/2 emulation of the UNIX
mktemp() system call is shown below in pseudocode.

/* mktemp() - Replaces the contents of the string pointed by the
     Template parameter with a unique file name.  Template must
     contain a file name with six trailing Xs.  This function
     replaces the Xs with a randomly generated character sequence.
     If the input is invalid, the Template is set to NULL and
     NULL is returned.                                           */

char * mktemp(char * Template)
 {
     char * retaddr = Template;  /* Return value variable.  */
     char * temp;                /* Temporary string pointer.  */

/* First make sure that Template has six trailing Xs and
     make sure that the length of that string is at least six
     bytes                                                         */

         IF strlen(Template) > 5
            THEN
              BEGIN
                Check each of the last 6 characters in the Template
                 IF any of them is not 'X'
                   THEN
                     BEGIN
                       Set Template to NULL
                       Set retaddr to NULL
                     END
         ...