#include <stdio.h>
#ifdef OS2
#  include <string.h>
#endif

char *msql_tmpnam(baseName)
        char *baseName;
{
        static char buf[100];
        static int nr = 0;

        nr++;

#ifdef OS2
        if (nr == 999)
#endif
#ifdef WINNT
        if (nr == 999)
#endif
#ifdef UNIX
        if (nr == 9999999)
#endif
                nr = 1;

#ifdef OS2
        sprintf(buf, "tmp\\%s.%03d",
                     baseName ? baseName : "msql",
                     nr
               );
#endif
#ifdef WINNT
        sprintf(buf, "tmp\\%s.%03d",
                     baseName ? baseName : "msql",
                     nr
               );
#endif
#ifdef UNIX
        sprintf(buf, "/tmp/%s.%07d.%07d", baseName ? baseName:"msql", nr,
                getpid());
#endif
        return (char *)strdup(buf);
}

