1 /*****************************************************************************\
2 Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3 This file is licensed under the Snes9x License.
4 For further information, consult the LICENSE file in the root directory.
5 \*****************************************************************************/
6
7 /***********************************************************************************
8 SNES9X for Mac OS (c) Copyright John Stiles
9
10 Snes9x for Mac OS X
11
12 (c) Copyright 2001 - 2011 zones
13 (c) Copyright 2002 - 2005 107
14 (c) Copyright 2002 PB1400c
15 (c) Copyright 2004 Alexander and Sander
16 (c) Copyright 2004 - 2005 Steven Seeger
17 (c) Copyright 2005 Ryan Vogt
18 ***********************************************************************************/
19
20
21 #include "mac-prefix.h"
22 #include "mac-netplay.h"
23
24
socket_read(int fd,unsigned char * buf,int size)25 int socket_read (int fd, unsigned char *buf, int size)
26 {
27 int l, n = 0;
28
29 do
30 {
31 if ((l = read(fd, &buf[n], size - n)) <= 0)
32 return (-1);
33 else
34 n += l;
35 } while (n < size);
36
37 return (n);
38 }
39
socket_write(int fd,unsigned char * buf,int size)40 int socket_write (int fd, unsigned char *buf, int size)
41 {
42 int l, n = 0;
43
44 do
45 {
46 if ((l = write(fd, &buf[n], size - n)) <= 0)
47 return (-1);
48 else
49 n += l;
50 } while (n < size);
51
52 return (n);
53 }
54
NPError(const char * s,int err)55 void NPError (const char *s, int err)
56 {
57 printf("ERROR! %d: %s\n", err, s);
58 }
59
NPNotification(const char * s,int c)60 void NPNotification (const char *s, int c)
61 {
62 if (c != -1)
63 printf(s, c);
64 else
65 printf("%s", s);
66
67 printf("\n");
68 }
69