version 1.25 | | version 1.26 |
---|
| | |
/* | | /* |
* static char *rcsid_porting_c = | | * static char *rcsid_porting_c = |
* "$Id: porting.c,v 1.25 2005/04/27 06:39:50 mwedel Exp $"; | | * "$Id: porting.c,v 1.26 2005/08/12 08:18:59 ryo_saeba Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
* at some unix variants. | | * at some unix variants. |
*/ | | */ |
| | |
char *tempnam_local(char *dir, char *pfx) | | char *tempnam_local(const char *dir, const char *pfx) |
{ | | { |
char *f, *name; | | char *name; |
pid_t pid=getpid(); | | pid_t pid=getpid(); |
| | |
/* HURD does not have a hard limit, but we do */ | | /* HURD does not have a hard limit, but we do */ |
| | |
* already exists - if so, we'll just keep looking - eventually we should | | * already exists - if so, we'll just keep looking - eventually we should |
* find one that is free. | | * find one that is free. |
*/ | | */ |
if ((f = (char *)dir)!=NULL) { | | if (dir!=NULL) { |
do { | | do { |
#ifdef HAVE_SNPRINTF | | #ifdef HAVE_SNPRINTF |
(void)snprintf(name, MAXPATHLEN, "%s/%s%hx.%d", f, pfx, pid, curtmp); | | (void)snprintf(name, MAXPATHLEN, "%s/%s%hx.%d", dir, pfx, pid, curtmp); |
#else | | #else |
(void)sprintf(name,"%s/%s%hx%d", f, pfx, pid, curtmp); | | (void)sprintf(name,"%s/%s%hx%d", dir, pfx, pid, curtmp); |
#endif | | #endif |
curtmp++; | | curtmp++; |
} while (access(name, F_OK)!=-1); | | } while (access(name, F_OK)!=-1); |
| | |
* A replacement of strdup(), since it's not defined at some | | * A replacement of strdup(), since it's not defined at some |
* unix variants. | | * unix variants. |
*/ | | */ |
char *strdup_local(char *str) { | | char *strdup_local(const char *str) { |
char *c=(char *)malloc(sizeof(char)*(strlen(str)+1)); | | char *c=(char *)malloc(sizeof(char)*(strlen(str)+1)); |
strcpy(c,str); | | strcpy(c,str); |
return c; | | return c; |