1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* Glenn Fowler <gsf@research.att.com> * 1N/A* David Korn <dgk@research.att.com> * 1N/A* Phong Vo <kpv@research.att.com> * 1N/A***********************************************************************/ 1N/A * generate a temp file / name 1N/A * [<dir>/][<pfx>]<bas>.<suf> 1N/A * pathtmp(a,b,c,d) pathtemp(a,L_tmpnam,b,c,0) 1N/A * tmpfile() char*p=pathtemp(0,0,0,"tf",&sp); 1N/A * tmpnam(0) static char p[L_tmpnam]; 1N/A * pathtemp(p,sizeof(p),0,"tn",0) 1N/A * tmpnam(p) pathtemp(p,L_tmpnam,0,"tn",0) 1N/A * tempnam(d,p) pathtemp(0,d,p,0) 1N/A * mktemp(p) pathtemp(0,0,p,0) 1N/A * if buf==0 then space is malloc'd 1N/A * dir and pfx may be 0 1N/A * if pfx contains trailing X's then it is a mktemp(3) template 1N/A * otherwise only first 5 chars of pfx are used 1N/A * if fdp!=0 then the path is opened O_EXCL and *fdp is the open fd 1N/A * malloc'd space returned by successful pathtemp() calls 1N/A * must be freed by the caller 1N/A * generated names are pseudo-randomized to avoid both 1N/A * / as first pfx char provides tmp file generation control 1N/A * 0 returned for unknown ops 1N/A * /cycle dir specifies TMPPATH cycle control 1N/A * automatic (default) cycled with each tmp file 1N/A * manual cycled by application with dir=(nil) 1N/A * (nil) cycle TMPPATH 1N/A * /prefix dir specifies the default prefix (default ast) 1N/A * /seed dir specifies pseudo-random generator seed 1N/A * 0 or "0" to re-initialize 1N/A * /TMPPATH dir overrides the env value 1N/A * /TMPDIR dir overrides the env value 1N/A for (l = m; l &&
pfx[l -
1] ==
'X'; l--);
1N/A while (s < x && (n = *d++))
1N/A if (s < x && s > b && *(s -
1) !=
'/')
1N/A if (n ==
'/' || n ==
'\\' || n == z)
1N/A * get a quasi-random coefficient 1N/A * Knuth vol.2, page.16, Thm.A 1N/A * generate a pseudo-random name