HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
posix_usoc.c
Go to the documentation of this file.
1 #include <stddef.h>
2 
3 #include <hipc.h>
4 #include <hipc/posix/ioutils.h>
5 #include <hipc/posix/usoc.h>
6 
14 void hipcPosixUsocInit(struct HIPC_usoc *so_p, const int fdr,
15  const int fdw)
16 {
17  so_p->fdr = fdr;
18  so_p->fdw = fdw;
19 
20  return;
21 }
22 
23 enum HIPC_errno
24 hipcUsocRead(struct HIPC_usoc *so_p, void *buf, const size_t size)
25 {
26  if (0 < size) {
27  if (0 >= hipcPosixReadExactly(so_p->fdr, buf, size)) {
28  return HIPC_ERR_S_IO_READ;
29  }
30  }
31 
32  return HIPC_SUCCESS;
33 }
34 
35 enum HIPC_errno
36 hipcUsocWrite(struct HIPC_usoc *so_p, const void *buf, const size_t size)
37 {
38  if (-1 == hipcPosixWriteExactly(so_p->fdw, buf, size)) {
39  return HIPC_ERR_S_IO_WRITE;
40  }
41 
42  return HIPC_SUCCESS;
43 }
void hipcPosixUsocInit(struct HIPC_usoc *so_p, const int fdr, const int fdw)
Initializes a universal socket.
Definition: posix_usoc.c:14
ssize_t hipcPosixReadExactly(const int fd, void *buf, const size_t count)
Read count bytes from fd by using read(2).
Definition: posix_ioutils.c:41
int fdw
Definition: usoc.h:6
enum HIPC_errno hipcUsocRead(struct HIPC_usoc *so_p, void *buf, const size_t size)
Reads exactly size bytes from so_p.
Definition: posix_usoc.c:24
HIPC_errno
Definition: hipc.h:4
enum HIPC_errno hipcUsocWrite(struct HIPC_usoc *so_p, const void *buf, const size_t size)
Writes exactly size bytes to so_p.
Definition: posix_usoc.c:36
ssize_t hipcPosixWriteExactly(const int fd, void const *buf, const size_t count)
Writes count bytes to fd by using write(2).
Definition: posix_ioutils.c:71
Definition: usoc.h:4
int fdr
Definition: usoc.h:5