ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] I: temporary file handling: C coding guideline
@ 2003-06-03  8:17 Dmitry V. Levin
  2003-06-03  9:15 ` Stanislav Ievlev
  2003-06-10 23:14 ` [devel] temporary file handling: questions Grigory Batalov
  0 siblings, 2 replies; 9+ messages in thread
From: Dmitry V. Levin @ 2003-06-03  8:17 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]

Greetings!

Я планирую добавить "C coding guideline" в дополнение к нынешнему shell
coding guideline из SPP:

#define _GNU_SOURCE

#include <stdio.h>
#include <error.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>

...
char *fname;
int fd;
FILE *fp;

if (asprintf (&fname, "%s/progname.XXXXXX", getenv ("TMPDIR") ?: P_tmpdir) < 0)
	error (EXIT_FAILURE, errno, "asprintf");

if ((fd = mkstemp (fname)) < 0)
	error (EXIT_FAILURE, errno, "mkstemp: %s", fname);

if (unlink (fname) < 0)
	error (EXIT_FAILURE, errno, "unlink: %s", fname);

if ((fp = fdopen (fd, "w+")) == NULL)
	error (EXIT_FAILURE, errno, "fdopen: %s", fname);

...

if (fclose (fp))
	error (EXIT_FAILURE, errno, "fclose: %s", fname);

free (fname);
fname = NULL;

Комментарии приветствуются.


--
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-06-13 10:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-03  8:17 [devel] I: temporary file handling: C coding guideline Dmitry V. Levin
2003-06-03  9:15 ` Stanislav Ievlev
2003-06-10 23:14 ` [devel] temporary file handling: questions Grigory Batalov
2003-06-10 23:32   ` Dmitry V. Levin
2003-06-11  7:31     ` Alexey I. Froloff
2003-06-11  8:19       ` Dmitry V. Levin
2003-06-13 10:30         ` Alexey I. Froloff
2003-06-11  8:31       ` Stanislav Ievlev
2003-06-11 14:14   ` [devel] " Alexey Tourbin

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git