Diff for /Amaya/amaya/AHTURLTools.c between versions 1.155 and 1.156

version 1.155, 2002/11/13 10:33:52 version 1.156, 2002/11/13 11:21:30
Line 2415  char *GetTempName (const char *dir, cons Line 2415  char *GetTempName (const char *dir, cons
   
   static char tmpbufmem[FILENAME_MAX];    static char tmpbufmem[FILENAME_MAX];
   int len;    int len;
   int count;  
   int i;    int i;
   
   if (!dir || *dir == EOS || !TtaDirExists (dir))    if (!dir || *dir == EOS || !TtaDirExists (dir))
Line 2423  char *GetTempName (const char *dir, cons Line 2422  char *GetTempName (const char *dir, cons
   
   /* make sure that the name is no bigger than FILENAME_MAX */    /* make sure that the name is no bigger than FILENAME_MAX */
   
   len = strlen (dir) + 8;    len = strlen (dir);
   if (len > FILENAME_MAX)    if (len + L_tmpnam > FILENAME_MAX)
     return NULL;      return NULL;
   
   /* copy the dir name, and add a DIR_SEP if it's missing */    /* copy the dir name, and add a DIR_SEP if it's missing */
   if (dir[strlen (dir) - 1] == DIR_SEP)    if (dir[strlen (dir) - 1] == DIR_SEP)
     strcpy (tmpbufmem, dir);      strcpy (tmpbufmem, dir);
   else    else
     {
     sprintf (tmpbufmem, "%s%c", dir, DIR_SEP);      sprintf (tmpbufmem, "%s%c", dir, DIR_SEP);
           len++;
     }
   
   /* copy the prefix (no more than L_tmpnam chars, to respect posix) */    /* copy the prefix (no more than L_tmpnam chars, to respect posix). Save
   if (prefix && (len + strlen (prefix) > FILENAME_MAX))       space for the 6 X and EOS chars that will become the random bits */
     return NULL;    if (prefix)
     { 
   snprintf (&tmpbufmem[strlen (tmpbufmem)], L_tmpnam, "%s", prefix);        i = 0;
             while (prefix[i] != EOL && i < L_tmpnam - 8)
   /* make sure that the prefix has at least 6 chars for the temporary name */              tmpbufmem[len++] = prefix[i++];
               tmpbufmem[len] = EOS;
   len = strlen (prefix);    }
   if (len < L_tmpnam)  
     {    /* Add the 6 X chars */
       i = strlen (tmpbufmem);    len = strlen (tmpbufmem);
       count = 0;    i = 0;
       while (len < L_tmpnam && count < 6)    while (i < 6)
         {    {
           tmpbufmem[i++] = 'X';          tmpbufmem[len++] = 'X';
           len++;          i++;
           count++;    }      
         }    tmpbufmem[len] = EOS;
     }  
   tmpbufmem[i] = EOS;  
   
   AM_gen_tempname (tmpbufmem);    AM_gen_tempname (tmpbufmem);
   

Removed from v.1.155  
changed lines
  Added in v.1.156


Webmaster