--- l2_ut_sa.h 2001/09/06 17:17:41 1.2
+++ l2_ut_sa.h 2001/09/09 15:54:31 1.3
@@ -24,31 +24,58 @@
** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
-** l2_ut_sa.h: utility library for socket address handling
+** l2_ut_sa.h: socket abstraction library
*/
#ifndef __L2_UT_SA_H__
#define __L2_UT_SA_H__
-#include <netdb.h>
+#include <string.h>
#include <sys/types.h>
-#include <netinet/in.h>
#include <sys/socket.h>
-#include <arpa/inet.h>
-typedef struct {
- struct sockaddr *sa_buf;
- socklen_t sa_len;
- int sa_proto;
-} l2_util_sa_t;
-
-enum {
- L2_UTIL_SA_UNIX,
- L2_UTIL_SA_IP
-};
+struct sa_st;
+typedef struct sa_st sa_t;
-l2_util_sa_t *l2_util_sa_create(int, ...);
-void l2_util_sa_destroy(l2_util_sa_t *);
+struct sa_addr_st;
+typedef struct sa_addr_st sa_addr_t;
+
+typedef enum {
+ SA_OK,
+ SA_ERR_ARG,
+ SA_ERR_USE,
+ SA_ERR_MEM,
+ SA_ERR_SYS,
+ SA_ERR_INT
+} sa_rc_t;
+
+sa_rc_t sa_u2a (sa_addr_t **asaa, const char *uri, ...);
+sa_rc_t sa_s2a (sa_addr_t **saa, const struct sockaddr *sabuf, socklen_t salen);
+sa_rc_t sa_a2u (const sa_addr_t *saa, char **uri);
+sa_rc_t sa_a2s (const sa_addr_t *saa, struct sockaddr **sabuf, socklen_t *salen);
+
+sa_rc_t sa_create (sa_t **sa);
+sa_rc_t sa_destroy (sa_t *sa);
+
+sa_rc_t sa_timeout (sa_t *sa, long sec, long usec);
+sa_rc_t sa_buffers (sa_t *sa, size_t rsize, size_t wsize);
+
+sa_rc_t sa_bind (sa_t *sa, sa_addr_t *laddr);
+sa_rc_t sa_connect (sa_t *sa, sa_addr_t *raddr);
+sa_rc_t sa_listen (sa_t *sa);
+sa_rc_t sa_accept (sa_t *sa, sa_t **sa_new);
+
+sa_rc_t sa_getremote(sa_t *sa, sa_addr_t *raddr);
+sa_rc_t sa_getlocal (sa_t *sa, sa_addr_t *laddr);
+
+sa_rc_t sa_read (sa_t *sa, char *buf, size_t buflen, size_t *bufdone);
+sa_rc_t sa_readfrom (sa_t *sa, char *buf, size_t buflen, size_t *bufdone, sa_addr_t *addr);
+sa_rc_t sa_readline (sa_t *sa, char *buf, size_t buflen, size_t *bufdone);
+sa_rc_t sa_write (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone);
+sa_rc_t sa_writeto (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone, sa_addr_t *addr);
+sa_rc_t sa_printf (sa_t *sa, const char *fmt, ...);
+sa_rc_t sa_flush (sa_t *sa);
+sa_rc_t sa_shutdown (sa_t *sa, char *flags);
#endif /* __L2_UT_SA_H__ */
|