OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_ut_sa.h versions 1.8 and 1.9
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/l2/l2_ut_sa.h 1.8 -> 1.9

--- l2_ut_sa.h   2001/10/02 14:11:51     1.8
+++ l2_ut_sa.h   2001/10/06 14:33:09     1.9
@@ -30,7 +30,9 @@
 #ifndef __SA_H__
 #define __SA_H__
 
-/* system definitions of "size_t", "socklen_t", "struct sockaddr" */
+#define SA_PREFIX l2_util_
+
+/* system definitions of "size_t", "socklen_t", "struct sockaddr *" */
 #include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -44,34 +46,37 @@
 #define __SA_CONCAT(x) x
 #define SA_CONCAT(x,y) __SA_CONCAT(x)y
 #endif
-#define sa_addr_st   SA_CONCAT(SA_PREFIX,sa_addr_st)
-#define sa_addr_t    SA_CONCAT(SA_PREFIX,sa_addr_t)
-#define sa_rc_t      SA_CONCAT(SA_PREFIX,sa_rc_t)
-#define sa_st        SA_CONCAT(SA_PREFIX,sa_st)
-#define sa_t         SA_CONCAT(SA_PREFIX,sa_t)
-#define sa_u2a       SA_CONCAT(SA_PREFIX,sa_u2a)
-#define sa_s2a       SA_CONCAT(SA_PREFIX,sa_s2a)
-#define sa_a2u       SA_CONCAT(SA_PREFIX,sa_a2u)
-#define sa_a2s       SA_CONCAT(SA_PREFIX,sa_a2s)
-#define sa_create    SA_CONCAT(SA_PREFIX,sa_create)
-#define sa_destroy   SA_CONCAT(SA_PREFIX,sa_destroy)
-#define sa_timeout   SA_CONCAT(SA_PREFIX,sa_timeout)
-#define sa_buffers   SA_CONCAT(SA_PREFIX,sa_buffers)
-#define sa_bind      SA_CONCAT(SA_PREFIX,sa_bind)
-#define sa_connect   SA_CONCAT(SA_PREFIX,sa_connect)
-#define sa_listen    SA_CONCAT(SA_PREFIX,sa_listen)
-#define sa_accept    SA_CONCAT(SA_PREFIX,sa_accept)
-#define sa_getremote SA_CONCAT(SA_PREFIX,sa_getremote)
-#define sa_getlocal  SA_CONCAT(SA_PREFIX,sa_getlocal)
-#define sa_getfd     SA_CONCAT(SA_PREFIX,sa_getfd)
-#define sa_shutdown  SA_CONCAT(SA_PREFIX,sa_shutdown)
-#define sa_read      SA_CONCAT(SA_PREFIX,sa_read)
-#define sa_readfrom  SA_CONCAT(SA_PREFIX,sa_readfrom)
-#define sa_readline  SA_CONCAT(SA_PREFIX,sa_readline)
-#define sa_write     SA_CONCAT(SA_PREFIX,sa_write)
-#define sa_writeto   SA_CONCAT(SA_PREFIX,sa_writeto)
-#define sa_printf    SA_CONCAT(SA_PREFIX,sa_printf)
-#define sa_flush     SA_CONCAT(SA_PREFIX,sa_flush)
+#define sa_addr_st      SA_CONCAT(SA_PREFIX,sa_addr_st)
+#define sa_addr_t       SA_CONCAT(SA_PREFIX,sa_addr_t)
+#define sa_rc_t         SA_CONCAT(SA_PREFIX,sa_rc_t)
+#define sa_st           SA_CONCAT(SA_PREFIX,sa_st)
+#define sa_t            SA_CONCAT(SA_PREFIX,sa_t)
+#define sa_addr_create  SA_CONCAT(SA_PREFIX,sa_addr_create)
+#define sa_addr_destroy SA_CONCAT(SA_PREFIX,sa_addr_destroy)
+#define sa_addr_u2a     SA_CONCAT(SA_PREFIX,sa_addr_u2a)
+#define sa_addr_s2a     SA_CONCAT(SA_PREFIX,sa_addr_s2a)
+#define sa_addr_a2u     SA_CONCAT(SA_PREFIX,sa_addr_a2u)
+#define sa_addr_a2s     SA_CONCAT(SA_PREFIX,sa_addr_a2s)
+#define sa_create       SA_CONCAT(SA_PREFIX,sa_create)
+#define sa_destroy      SA_CONCAT(SA_PREFIX,sa_destroy)
+#define sa_type         SA_CONCAT(SA_PREFIX,sa_type)
+#define sa_timeout      SA_CONCAT(SA_PREFIX,sa_timeout)
+#define sa_buffers      SA_CONCAT(SA_PREFIX,sa_buffers)
+#define sa_bind         SA_CONCAT(SA_PREFIX,sa_bind)
+#define sa_connect      SA_CONCAT(SA_PREFIX,sa_connect)
+#define sa_listen       SA_CONCAT(SA_PREFIX,sa_listen)
+#define sa_accept       SA_CONCAT(SA_PREFIX,sa_accept)
+#define sa_getremote    SA_CONCAT(SA_PREFIX,sa_getremote)
+#define sa_getlocal     SA_CONCAT(SA_PREFIX,sa_getlocal)
+#define sa_getfd        SA_CONCAT(SA_PREFIX,sa_getfd)
+#define sa_shutdown     SA_CONCAT(SA_PREFIX,sa_shutdown)
+#define sa_read         SA_CONCAT(SA_PREFIX,sa_read)
+#define sa_readln       SA_CONCAT(SA_PREFIX,sa_readln)
+#define sa_write        SA_CONCAT(SA_PREFIX,sa_write)
+#define sa_writef       SA_CONCAT(SA_PREFIX,sa_writef)
+#define sa_flush        SA_CONCAT(SA_PREFIX,sa_flush)
+#define sa_recv         SA_CONCAT(SA_PREFIX,sa_recv)
+#define sa_send         SA_CONCAT(SA_PREFIX,sa_send)
 #endif
 
 /* socket address abstraction object type */
@@ -82,48 +87,62 @@
 struct sa_st;
 typedef struct sa_st sa_t;
 
+/* socket connection types */
+typedef enum {
+    SA_TYPE_STREAM,
+    SA_TYPE_DATAGRAM
+} sa_type_t;
+
 /* return codes */
 typedef enum {
-    SA_OK,
-    SA_ERR_ARG,
-    SA_ERR_USE,
-    SA_ERR_MEM,
-    SA_ERR_SYS,
-    SA_ERR_INT
+    SA_OK,      /* everything ok */
+    SA_ERR_ARG, /* invalid argument (wrong parameter) */
+    SA_ERR_USE, /* invalid use (wrong context) */
+    SA_ERR_MEM, /* out of memory */
+    SA_ERR_SYS, /* system error (see errno) */
+    SA_ERR_EOF, /* end of file/socket communication */
+    SA_ERR_INT  /* internal error */
 } sa_rc_t;
 
+/* address object operations */
+sa_rc_t sa_addr_create  (sa_addr_t **saa);
+sa_rc_t sa_addr_destroy (sa_addr_t *saa);
+
 /* address operations */
-sa_rc_t sa_u2a      (sa_addr_t **saa, 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);
-
-/* object operations */
-sa_rc_t sa_create   (sa_t **sa);
-sa_rc_t sa_destroy  (sa_t *sa);
-
-/* parameter operations */
-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);
-
-/* connection operations */
-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, int backlog);
-sa_rc_t sa_accept   (sa_t *sa, sa_addr_t **caddr, sa_t **csa);
-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_getfd    (sa_t *sa, int *fd);
-sa_rc_t sa_shutdown (sa_t *sa, char *flags);
-
-/* input/output operations */
-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 **raddr);
-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 *raddr);
-sa_rc_t sa_printf   (sa_t *sa, const char *fmt, ...);
-sa_rc_t sa_flush    (sa_t *sa);
+sa_rc_t sa_addr_u2a     (sa_addr_t *saa, const char *uri, ...);
+sa_rc_t sa_addr_s2a     (sa_addr_t *saa, const struct sockaddr *sabuf, socklen_t salen);
+sa_rc_t sa_addr_a2u     (sa_addr_t *saa, char **uri);
+sa_rc_t sa_addr_a2s     (sa_addr_t *saa, struct sockaddr **sabuf, socklen_t *salen);
+
+/* socket object operations */
+sa_rc_t sa_create       (sa_t **sa);
+sa_rc_t sa_destroy      (sa_t *sa);
+
+/* socket parameter operations */
+sa_rc_t sa_type         (sa_t *sa, sa_type_t type);
+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);
+
+/* socket connection operations */
+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, int backlog);
+sa_rc_t sa_accept       (sa_t *sa, sa_addr_t **caddr, sa_t **csa);
+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_getfd        (sa_t *sa, int *fd);
+sa_rc_t sa_shutdown     (sa_t *sa, char *flags);
+
+/* socket input/output operations (stream communication) */
+sa_rc_t sa_read         (sa_t *sa, char *buf, size_t buflen, size_t *bufdone);
+sa_rc_t sa_readln       (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_writef       (sa_t *sa, const char *fmt, ...);
+sa_rc_t sa_flush        (sa_t *sa);
+
+/* socket input/output operations (datagram communication) */
+sa_rc_t sa_recv         (sa_t *sa, char *buf, size_t buflen, size_t *bufdone, sa_addr_t **raddr);
+sa_rc_t sa_send         (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone, sa_addr_t *raddr);
 
 #endif /* __SA_H__ */
 

CVSTrac 2.0.1