Updated Spanish translation
[anjuta-git-plugin.git] / plugins / valgrind / vgio.c
blobc4335b60aa061dca40dc393b80b3cb50c3d455b3
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * Authors: Jeffrey Stedfast <fejj@ximian.com>
5 * Copyright 2003 Ximian, Inc. (www.ximian.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
28 #include <sys/types.h>
29 #include <unistd.h>
30 #include <fcntl.h>
31 #include <errno.h>
33 #include "vgio.h"
35 ssize_t
36 vg_read (int fd, char *buf, size_t n)
38 ssize_t nread;
40 do {
41 nread = read (fd, buf, n);
42 } while (nread == -1 && errno == EINTR);
44 return nread;
48 ssize_t
49 vg_write (int fd, const char *buf, size_t n)
51 size_t nwritten = 0;
52 ssize_t w;
54 do {
55 do {
56 w = write (fd, buf + nwritten, n - nwritten);
57 } while (w == -1 && errno == EINTR);
59 if (w == -1)
60 return -1;
62 nwritten += w;
63 } while (nwritten < n);
65 return nwritten;