Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_con


Modified Files:
      Tag: SPLIT
        Ecore_Con.h ecore_con.c ecore_con_private.h 


Log Message:


protect data types... :)
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_con/Attic/Ecore_Con.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -3 -r1.1.2.3 -r1.1.2.4
--- Ecore_Con.h 17 Mar 2003 13:06:10 -0000      1.1.2.3
+++ Ecore_Con.h 17 Mar 2003 13:19:07 -0000      1.1.2.4
@@ -69,9 +69,11 @@
    int               ecore_con_shutdown(void);
    
    Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type, char *name, int port, 
const void *data);
+   
    Ecore_Con_Server *ecore_con_server_connect(Ecore_Con_Type type, char *name, int 
port, const void *data);
    void             *ecore_con_server_del(Ecore_Con_Server *svr);
    void             *ecore_con_server_data_get(Ecore_Con_Server *svr);
+   int               ecore_con_server_connected_get(Ecore_Con_Server *svr);
    int               ecore_con_server_send(Ecore_Con_Server *svr, void *data, int 
size);
    
    int               ecore_con_client_send(Ecore_Con_Client *cl, void *data, int 
size);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_con/Attic/ecore_con.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -3 -r1.1.2.6 -r1.1.2.7
--- ecore_con.c 17 Mar 2003 13:06:11 -0000      1.1.2.6
+++ ecore_con.c 17 Mar 2003 13:19:08 -0000      1.1.2.7
@@ -98,6 +98,7 @@
    struct linger       lin;
    char                buf[4096];
    
+   if (port < 0) return NULL;
    /* local  user   socket: FILE:   ~/.ecore/[name]/[port] */
    /* local  system socket: FILE:   /tmp/.ecore_service|[name]|[port] */
    /* remote system socket: TCP/IP: [name]:[port] */
@@ -110,6 +111,7 @@
        char *homedir;
        struct stat st;
        
+       if (!name) goto error;
        if (type == ECORE_CON_LOCAL_USER)
          {
             mode_t mask;
@@ -175,6 +177,7 @@
    svr->data = (void *)data;
    svr->created = 1;
    servers = _ecore_list_append(servers, svr);
+   ECORE_MAGIC_SET(svr, ECORE_MAGIC_CON_SERVER);   
    return svr;
    
    error:
@@ -204,7 +207,9 @@
    struct sockaddr_in  socket_addr;
    int                 curstate;
    char                buf[4096];
-   
+
+   if (!name) return NULL;
+   if (port < 0) return NULL;
    /* local  user   socket: FILE:   ~/.ecore/[name]/[port] */
    /* local  system socket: FILE:   /tmp/.ecore_service|[name]|[port] */
    /* remote system socket: TCP/IP: [name]:[port] */
@@ -293,6 +298,7 @@
    svr->data = (void *)data;
    svr->created = 0;
    servers = _ecore_list_append(servers, svr);
+   ECORE_MAGIC_SET(svr, ECORE_MAGIC_CON_SERVER);   
    return svr;
    
    error:
@@ -314,7 +320,13 @@
 ecore_con_server_del(Ecore_Con_Server *svr)
 {
    void *data;
-   
+
+   if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
+     {
+       ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
+                        "ecore_con_server_del");
+       return NULL;
+     }   
    data = svr->data;
    _ecore_con_server_free(svr);
    return data;
@@ -329,6 +341,12 @@
 void *
 ecore_con_server_data_get(Ecore_Con_Server *svr)
 {
+   if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
+     {
+       ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
+                        "ecore_con_server_data_get");
+       return NULL;
+     }   
    return svr->data;
 }
 
@@ -339,9 +357,36 @@
  * <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  */
 int
+ecore_con_server_connected_get(Ecore_Con_Server *svr)
+{
+   if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
+     {
+       ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
+                        "ecore_con_server_connected_get");
+       return 0;
+     }   
+   if (svr->connecting) return 0;
+   return 1;
+}
+
+/**
+ * To be documented.
+ *
+ * FIXME: To be fixed.
+ * <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
+ */
+int
 ecore_con_server_send(Ecore_Con_Server *svr, void *data, int size)
 {
+   if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
+     {
+       ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
+                        "ecore_con_server_send");
+       return 0;
+     }   
    if (svr->dead) return 1;
+   if (!data) return 0;
+   if (size < 1) return 0;
    ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
    if (svr->buf)
      {
@@ -373,7 +418,15 @@
 int
 ecore_con_client_send(Ecore_Con_Client *cl, void *data, int size)
 {
+   if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
+     {
+       ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
+                        "ecore_con_client_send");
+       return 0;
+     }   
    if (cl->dead) return 0;
+   if (!data) return 0;
+   if (size < 1) return 0;
    ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
    if (cl->buf)
      {
@@ -405,6 +458,12 @@
 Ecore_Con_Server *
 ecore_con_client_server_get(Ecore_Con_Client *cl)
 {
+   if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
+     {
+       ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
+                        "ecore_con_client_server_get");
+       return NULL;
+     }   
    return cl->server;
 }
 
@@ -417,12 +476,19 @@
 void
 ecore_con_client_del(Ecore_Con_Client *cl)
 {
+   if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
+     {
+       ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
+                        "ecore_con_client_del");
+       return;
+     }   
    _ecore_con_client_free(cl);
 }
 
 static void
 _ecore_con_server_free(Ecore_Con_Server *svr)
 {
+   ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE);   
    while ((svr->buf) && (!svr->dead)) _ecore_con_server_flush(svr);
    if (svr->buf) free(svr->buf);
    servers = _ecore_list_remove(servers, svr);
@@ -439,6 +505,7 @@
 static void
 _ecore_con_client_free(Ecore_Con_Client *cl)
 {
+   ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);   
    while ((cl->buf) && (!cl->dead)) _ecore_con_client_flush(cl);
    if (cl->buf) free(cl->buf);
    cl->server->clients = _ecore_list_remove(cl->server->clients, cl);
@@ -478,6 +545,7 @@
                                                   ECORE_FD_READ,
                                                   _ecore_con_svr_cl_handler, cl,
                                                   NULL, NULL);
+       ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT);
        svr->clients = _ecore_list_append(svr->clients, cl);
          {
             Ecore_Con_Event_Client_Add *e;
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_con/Attic/ecore_con_private.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -3 -r1.1.2.3 -r1.1.2.4
--- ecore_con_private.h 17 Mar 2003 07:33:57 -0000      1.1.2.3
+++ ecore_con_private.h 17 Mar 2003 13:19:08 -0000      1.1.2.4
@@ -1,7 +1,8 @@
 #ifndef _ECORE_CON_PRIVATE_H
 #define _ECORE_CON_PRIVATE_H
 
-#define ECORE_MAGIC_CON             0x77665544
+#define ECORE_MAGIC_CON_SERVER             0x77665544
+#define ECORE_MAGIC_CON_CLIENT             0x77556677
 
 typedef enum _Ecore_Con_Type
 {




-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to