tmpnam.c 294 B

1234567891011121314151617181920
  1. /*
  2. * pANS stdio -- tmpnam
  3. */
  4. #include "iolib.h"
  5. char *tmpnam(char *s){
  6. static char name[]="/tmp/tn000000000000";
  7. char *p;
  8. do{
  9. p=name+7;
  10. while(*p=='9') *p++='0';
  11. if(*p=='\0') return NULL;
  12. ++*p;
  13. }while(access(name, 0)==0);
  14. if(s){
  15. strcpy(s, name);
  16. return s;
  17. }
  18. return name;
  19. }