Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/tcl/plan9/plan9compat.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include "tclPort.h"
#include <stdlib.h>
#include <string.h>

int
mkstemp(char *template)
{
   char *s;
   int i, fd;

   s = strdup(template);
   if(s == NULL)
       return -1;
   for(i=0; i<20; i++){
       strcpy(s, template);
       mktemp(s);
       if((fd = creat(s, 0666)) >= 0){
           strcpy(template, s);
           free(s);
           return fd;
       }
   }
   free(s);
   return -1;
}

void
_tclPlan9InitEnv(void)
{
   char buf[512];
   if(getenv("PATH") == 0)
       putenv("PATH=:.:/bin");
   if(getenv("HOME") == 0){
      snprintf(buf, sizeof(buf), "HOME=%s", getenv("home"));
      putenv(buf);
   }
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.