9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <russcox@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] mkstemp()
Date: Fri, 28 Jan 2005 10:05:21 -0500	[thread overview]
Message-ID: <ee9e417a0501280705a86733@mail.gmail.com> (raw)
In-Reply-To: <ACCF003CBA3D09458207DB0CB86AD17D0663DF@XMAIL.asuch.cas.cz>

Enjoy.

int
mkstemp(char *template)
{
    char *s;
    int i, fd;

    s = strdup(template);
    if(s == nil)
        return -1;
    for(i=0; i<20; i++){
        strcpy(s, template);
        mktemp(s);
        if((fd = create(s, ORDWR|OEXCL, 0666)) >= 0){
            strcpy(template, s);
            free(s);
            return fd;
        }
    }
    free(s);
    return -1;
}

On Fri, 28 Jan 2005 14:39:41 +0100, cej@gli.cas.cz <cej@gli.cas.cz> wrote:
> need mkstemp() [BSD unistd.h]
> any better idea than to copy the code from BSD | GNU ?
> (I understand that returns a fd of a temp file)
> 
> thanks,
> ++pac.
> 
>


  parent reply	other threads:[~2005-01-28 15:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-28 13:39 cej
2005-01-28 13:44 ` Gorka Guardiola Múzquiz
2005-01-29  3:02   ` Scott Schwartz
2005-01-29  3:07     ` boyd, rounin
2005-01-29  3:15       ` Russ Cox
2005-01-29  7:23         ` arisawa
2005-01-29  9:11           ` Russ Cox
2005-01-29 10:11             ` arisawa
2005-01-29 15:11               ` Russ Cox
2005-01-29  8:30       ` geoff
2005-01-28 15:05 ` Russ Cox [this message]
2005-01-28 15:38 ` Ronald G. Minnich
2005-01-28 16:08   ` Gorka Guardiola Múzquiz
2005-01-28 16:16     ` Russ Cox
2005-01-31  8:29 cej

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee9e417a0501280705a86733@mail.gmail.com \
    --to=russcox@gmail.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).