2009-02-05 21:08:46 +00:00
|
|
|
#ifndef _INCLUDE_SOCKET_H_
|
|
|
|
#define _INCLUDE_SOCKET_H_
|
|
|
|
|
2009-07-24 13:38:53 +00:00
|
|
|
#include "r_types.h"
|
|
|
|
|
2009-10-12 15:41:52 +00:00
|
|
|
/* TODO: major refactoring of r_socket */
|
|
|
|
/* make it work like the rest of apis */
|
|
|
|
/* struct r_socket_t *sock = r_socket_new(R_SOCKET_TCP, "gogle.com", 80); */
|
|
|
|
/* struct r_socket_t *sock = r_socket_proc_new(R_SOCKET_PROCESS, "/bin/ls", 80); */
|
|
|
|
|
2010-01-26 00:28:33 +00:00
|
|
|
#ifdef R_API
|
2009-10-12 15:41:52 +00:00
|
|
|
#if __UNIX__
|
|
|
|
R_API int r_socket_unix_connect(const char *file);
|
|
|
|
R_API int r_socket_unix_listen(const char *file);
|
|
|
|
#endif
|
|
|
|
R_API int r_socket_flush(int fd);
|
|
|
|
R_API void r_socket_block(int fd, int block);
|
2009-07-24 13:38:53 +00:00
|
|
|
R_API int r_socket_ready(int fd, int secs, int usecs);
|
|
|
|
R_API int r_socket_read(int fd, unsigned char *read, int len);
|
2009-12-22 12:27:43 +00:00
|
|
|
R_API int r_socket_puts(int fd, char *buf);
|
|
|
|
R_API int r_socket_write(int fd, void *buf, int len);
|
2009-07-24 13:38:53 +00:00
|
|
|
R_API int r_socket_connect(char *host, int port);
|
|
|
|
R_API int r_socket_listen(int port);
|
|
|
|
R_API int r_socket_accept(int fd);
|
2009-12-22 12:27:43 +00:00
|
|
|
R_API int r_socket_gets(int fd, char *buf, int size);
|
2009-07-24 13:38:53 +00:00
|
|
|
R_API void r_socket_printf(int fd, const char *fmt, ...);
|
|
|
|
R_API char *r_socket_to_string(int fd);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2010-01-26 00:28:33 +00:00
|
|
|
/* process */
|
2010-03-30 15:37:15 +00:00
|
|
|
typedef struct r_socket_proc_t {
|
2010-01-26 00:28:33 +00:00
|
|
|
int fd0[2];
|
|
|
|
int fd1[2];
|
|
|
|
int pid;
|
2010-03-30 15:37:15 +00:00
|
|
|
} RSocketProc;
|
2010-01-26 00:28:33 +00:00
|
|
|
|
2010-03-30 15:37:15 +00:00
|
|
|
R_API RSocketProc *r_socket_proc_open(char *const argv[]);
|
|
|
|
R_API int r_socket_proc_close(RSocketProc *sp);
|
2010-01-26 00:28:33 +00:00
|
|
|
#define r_socket_proc_read(x,y,z) r_socket_read(x->fd1[0],y,z)
|
|
|
|
#define r_socket_proc_gets(x,y,z) r_socket_gets(x->fd1[0],y,z)
|
|
|
|
#define r_socket_proc_write(x,y,z) r_socket_write(x->fd0[1],y,z)
|
|
|
|
#define r_socket_proc_printf(x,y) r_socket_printf(x->fd0[1],y)
|
|
|
|
#define r_socket_proc_ready(x,y,z) r_socket_ready(x->fd1[0],y,z)
|
|
|
|
|
|
|
|
#endif
|
2009-02-05 21:08:46 +00:00
|
|
|
#endif
|