home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 138.lha / M4 / Sources / mktemp.c < prev   
C/C++ Source or Header  |  1986-11-20  |  770b  |  34 lines

  1. #include <stdio.h>
  2. /* mktemp(0 shamelessly swiped off our vax, didn't find */
  3. /* a (c) anywhere on this piece of code..               */
  4. char *
  5. mktemp(as)
  6. char *as;
  7. {
  8.         register char *s;
  9.         register int tmp;
  10.         register i;
  11.         extern int mytmpnum;
  12. loop:   tmp = mytmpnum%100000;
  13.         s = as;
  14.         while (*s++)
  15.                 ;
  16.         s--;
  17.         while (*--s == 'X') {
  18.                 *s = (tmp%10) + '0';
  19.                 tmp /= 10;
  20.         }
  21.         s++;
  22.         i = 'a';
  23.         while (access(as, 0) != -1) {
  24.                 if (i=='z')
  25.                         {
  26.                         mytmpnum+=1;
  27.                         goto loop;
  28.                         }
  29.                 *s = i++;
  30.         }
  31.         mytmpnum+=1;
  32.         return(as);
  33. }
  34.