+ int suffixlen;
+ char *xx = strstr(fname, "XXXXXX");
+ if (xx)
+ suffixlen = strlen(xx) - 6;
+ else
+ {
+ suffixlen = 0;
+ xx = fname + strlen(fname);
+ strcat(fname, "XXXXXX");
+ }
+ char tmp_char = xx[6];
+ sprintf(xx, "%06d", ((unsigned) rand()) % 1000000);
+ xx[6] = tmp_char;
+
+ int fd = creat(fname, 0666);