~skinny.moey/drizzle/innodb-replication

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
1804.3.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
1 by brian
clean slate
15
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
16
#include "config.h"
17
18
#include "drizzled/internal/my_sys.h"
1689.2.10 by Brian Aker
Move thread_var out to its own include file.
19
#include "drizzled/internal/thread_var.h"
1271.5.3 by Tim Penhey
change the include files
20
#include "drizzled/error.h"
1271.5.7 by Monty Taylor
Merged up with trunk.
21
#include <cerrno>
1 by brian
clean slate
22
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
23
namespace drizzled
24
{
25
namespace internal
26
{
1 by brian
clean slate
27
28
	/* Write a chunk of bytes to a file */
29
481 by Brian Aker
Remove all of uchar.
30
size_t my_write(int Filedes, const unsigned char *Buffer, size_t Count, myf MyFlags)
1 by brian
clean slate
31
{
32
  size_t writenbytes, written;
482 by Brian Aker
Remove uint.
33
  uint32_t errors;
1 by brian
clean slate
34
  errors=0; written=0;
35
36
  /* The behavior of write(fd, buf, 0) is not portable */
37
  if (unlikely(!Count))
51.3.15 by Jay Pipes
Phase 3 removal of DBUG in mysys
38
    return(0);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
39
1 by brian
clean slate
40
  for (;;)
41
  {
42
    if ((writenbytes= write(Filedes, Buffer, Count)) == Count)
43
      break;
44
    if (writenbytes != (size_t) -1)
45
    {						/* Safeguard */
46
      written+=writenbytes;
47
      Buffer+=writenbytes;
48
      Count-=writenbytes;
49
    }
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
50
    errno=errno;
1 by brian
clean slate
51
    if (MyFlags & (MY_NABP | MY_FNABP))
52
    {
53
      if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
54
      {
55
	my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG),
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
56
		 "unknown", errno);
1 by brian
clean slate
57
      }
51.3.15 by Jay Pipes
Phase 3 removal of DBUG in mysys
58
      return(MY_FILE_ERROR);		/* Error on read */
1 by brian
clean slate
59
    }
60
    else
61
      break;					/* Return bytes written */
62
  }
63
  if (MyFlags & (MY_NABP | MY_FNABP))
51.3.15 by Jay Pipes
Phase 3 removal of DBUG in mysys
64
    return(0);			/* Want only errors */
65
  return(writenbytes+written);
1 by brian
clean slate
66
} /* my_write */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
67
68
} /* namespace internal */
69
} /* namespace drizzled */