]> code.citadel.org Git - citadel.git/commitdiff
* MAJOR BUG: Memory leaks and protocol misimplementations in misc.c (related
authorBrian <brian@uncensored.citadel.org>
Mon, 10 Sep 2001 22:40:39 +0000 (22:40 +0000)
committerBrian <brian@uncensored.citadel.org>
Mon, 10 Sep 2001 22:40:39 +0000 (22:40 +0000)
to Express Messaging).  UGH!
* GAMEPLAN: Fix the problems with the RC_901 handler.  Try not to weep.
Then, re-package sources and push to web.

libCxClient/ChangeLog
libCxClient/Makefile.cvs
libCxClient/configure.in
libCxClient/src/misc.c
libCxClient/src/testlib.cpp

index ac4b2f66c28133820491d074898db0b66d0dee6c..b579d28c0f36fa8c620e44c95932b0b818e5dc3f 100644 (file)
@@ -1,4 +1,10 @@
 $Log$
+Revision 1.16  2001/09/10 22:40:39  brian
+* MAJOR BUG: Memory leaks and protocol misimplementations in misc.c (related
+to Express Messaging).  UGH!
+* GAMEPLAN: Fix the problems with the RC_901 handler.  Try not to weep.
+Then, re-package sources and push to web.
+
 Revision 1.15  2001/08/23 13:14:53  brian
 * Changed type on CxMsLoad() from (const char *) to (long unsigned int) to
   make things more intuitive (and less apt for failure)
@@ -65,4 +71,3 @@ Revision 1.3  2001/02/07 22:42:24  brian
 
 Revision 1.2  2001/02/07 22:41:51  brian
 * Updated ChangeLog to conform to Citadel/UX standards (kinda)  :)
-
index 3a5af4c1cfab000d93aa9d1d985859e8a9730b54..e33433b5c0a95be5ee2e36d5ffe2e5f13746cc54 100644 (file)
@@ -7,8 +7,6 @@ all:
        @echo -n "."
        @automake
        @echo -n "."
-       @./am_edit
-       @echo -n "."
        @autoconf
        @echo -n "."
        @echo "Done!"
index 302607d803386546101e47cadc434b0b22474930..af3926d88c3d944bb30e3c51361c0e2ccb3677d5 100644 (file)
@@ -14,7 +14,7 @@ AM_CONFIG_HEADER(autoconf.h)
 dnl inits some variables needed by automake's Makefiles.
 dnl add here the package name and it's version number. It will
 dnl be defined in config.h and in the Makefiles
-AM_INIT_AUTOMAKE(libCxClient, 0.20)
+AM_INIT_AUTOMAKE(libCxClient, 0.21)
 
 dnl sets the prefix to $KDEDIR or /usr/local/kde (if no $KDEDIR
 dnl set) for the case, that there is no --prefix
index 7e920a8f00a90b43442eee92fb7eaeeda2f73417..0efd590843fdaff2149a83e82801e848171d5a3e 100644 (file)
@@ -74,17 +74,37 @@ int         CxMiExpSend(int id, const char *user, const char *msg) {
 char           *xmit, buf[255];
 int            rc;
 
-       DPF((DFA,"Send Express Message"));
-       xmit = (char *)CxMalloc(strlen(user)+strlen(msg) + 7);
+
+       /**
+        ** Need to check the server revision on this connection
+        ** handle.  If the server only supports short-style
+        ** express messages, we're gonna have to implement it
+        ** that way (and strip out everything after the newline
+        ** in msg?  or s/\n/ /g...?)
+
+        ** For reasons specified in session.txt, the following line
+        ** will never be guaranteed to work.. .
        sprintf(xmit,"SEXP %s|%s",user, msg);
+
+        **/
+       xmit = (char *)CxMalloc(strlen(user)+strlen(msg) + 7);
+       sprintf(xmit,"SEXP %s|-",user);
        CxClSend(id, xmit);
        CxFree(xmit);
 
-       rc = CxClRecv(id, buf);
-       if( CHECKRC(rc, RC_OK) ) {
+       rc = CxClRecv( id, buf );
+       if( CHECKRC( rc, RC_SENDLIST ) ) {
+               DPF((DFA, "Sending:\n%s\n", msg));
+               CxClSend( id, msg );
+               DPF((DFA, "END STREAM.", msg));
+               CxClSend( id, "000" );
+
+               DPF((DFA,"Express Message accepted by server.")); /** we hope... **/
                return(0);
 
        } else {
+               DPF((DFA,"Express Message _rejected_ by server."));
+               DPF((DFA,"(Operation not supported.)"));
                return(1);
        }
 }
@@ -117,7 +137,7 @@ int         rc;
        DPF((DFA,"Checking result = ", rc));
        if( CHECKRC(rc, RC_LISTING)) {
 
-               DPF((DFA,"Preparing to return"));
+               DPF((DFA,"This is an express message.  Working on receiving..."));
                toret = (EXPRMESG *) CxMalloc( sizeof(EXPRMESG) );
                bzero( &toret, sizeof(EXPRMESG) );
 
@@ -131,8 +151,13 @@ int                rc;
                toret->message = 0L;
                do {
                        if((rc = CxClRecv(id, buf))) {
-                               DPF((DFA, "%s", buf));
-                               toret->message = (char *) realloc(toret, strlen(toret->message)+strlen(buf)+1);
+                               DPF((DFA, "toret->message @0x%08x", toret->message));
+                               DPF((DFA, "+++ %s", buf));
+                               if(toret->message) {
+                                       toret->message = (char *) malloc(strlen(buf)+1);
+                               } else {
+                                       toret->message = (char *) realloc(toret->message, strlen(toret->message)+strlen(buf)+1);
+                               }
                                strcat(toret->message, buf);
                        }
                } while( rc < 0 );
@@ -197,24 +222,38 @@ char              buf[512], *user_buf, *data_buf;
 int            rc;
 
        DPF((DFA, "*ASYN* Received RC_901 message on CXID %d", id));
-       DPF((DFA, "Raw data: %s\n", (char *)data));
+       DPF((DFA, "Raw data: \"%s\"", (char *)data));
 
+       /**
+        ** Fetch the sending user's information from the data stream.
+        **/
        rc = CxClRecv(id, buf);
        user_buf = (char *)CxMalloc(strlen(buf)+1);
        strcpy(user_buf, buf);
 
+       DPF(( DFA, "user_buf @0x%08x", data_buf ));
+       DPF(( DFA, "user_buf: %s", user_buf ));
+
+       DPF(( DFA, "allocating data_buf" ));
        data_buf = (char *)CxMalloc(1);
        *(data_buf) = 0;
+       DPF(( DFA, "allocated data_buf @0x%08x", data_buf ));
 
        /**
-        ** If this is a multi-line message:
+        ** If this is a multi-line message, then fetch the message
+        ** from the datas stream.
         **/
        if(CHECKRC(rc, RC_LISTING)) {
                do {
+                       DPF(( DFA, "data_buf @0x%08x", data_buf ));
+                       DPF(( DFA, "data_buf: %s", data_buf ));
                        rc = CxClRecv( id, buf );
-                       if(rc<0) {
-                               realloc(data_buf, strlen(data_buf)+strlen(buf));
-                               strcat(data_buf, buf);
+                       if( rc<0 ) {
+                               DPF(( DFA, "data_buf szlen %d", strlen(data_buf) + strlen(buf) +1));
+                               if( strlen(buf) ) {
+                                       realloc(data_buf, strlen(data_buf)+strlen(buf)+1);
+                                       strcat(data_buf, buf);
+                               }
                        }
                } while(rc < 0);
        }
@@ -222,9 +261,19 @@ int                rc;
        /**
         ** Pass this information off to the user's function.
         **/
+       DPF(( DFA, "Completed.  Received the following data:\n: user_buf: %s\n: data_buf: %s\n",
+               user_buf, data_buf ));
+
+       DPF(( DFA, "->_MiExpFunc() -- USERLAND"));
        _MiExpFunc(user_buf, data_buf);
+       DPF(( DFA, "<-_MiExpFunc() -- /USERLAND"));
+
+       DPF(( DFA, "Freeing pointer user_buf"));
        CxFree(user_buf);
+       DPF(( DFA, "Freeing pointer data_buf"));
        CxFree(data_buf);
+
+       DPF(( DFA, "Done!"));
 }
 
 /**
@@ -331,6 +380,10 @@ int                rc;
  ** [Returns]
  **  Success: Ptr to malloc()ed image data.  [*]
  **  Failure; File not found: NULL
+ **
+ ** (Actually, we will probably want to store this in a temp
+ ** file, and return a pointer to the filename.  Unless you want
+ ** to store a 10-meg image in memory, of course... :)
  **/
 char           *CxMiImage(int id, const char *img) {
 
index ebb55d5b51089c24694fbf786b70102fadc954bd..ce1c111edb36b7783a998cfd255e7e51327d3dee 100644 (file)
@@ -12,7 +12,8 @@
  ** 901 express message callback...
  **/
 void           chathook(const char *user, const char *msg) {
-       printf("Chat Message Handler\n");
+
+       printf("------------------------------- Chat Message Handler\n");
 
        printf("[[[[[[ %s ]]]]]]\n", user);
        printf("%s\n", msg);
@@ -65,8 +66,8 @@ int           hndl;
 
                        fl = CxLlFlush(fl);
 
-                       CxMiExpSend(hndl, "detsaoT","Hello, World");
-                       CxMiExpSend(hndl, "detsaoT","How are you?");
+                       CxMiExpSend(hndl, "detsaoT","Hello, World.  This is a long diatribe\n on the evils of something\nof which the world may never know.");
+                       CxMiExpSend(hndl, "detsaoT","How are you?  I am fine.  If you see the optional potential of the explicit implicity of the file, you'll know what I mean.");
                        CxMiExpSend(hndl, "detsaoT","Blah blah blah.");
 
 
@@ -81,5 +82,4 @@ int           hndl;
        } else {
                printf("Unable to connect to '%s'!\n", argv[1]);
        }
-
 }