]> code.citadel.org Git - citadel.git/commitdiff
* Changed the return interface for CxMiExpRecv(). It now returns a more
authorBrian <brian@uncensored.citadel.org>
Tue, 13 Mar 2001 22:45:53 +0000 (22:45 +0000)
committerBrian <brian@uncensored.citadel.org>
Tue, 13 Mar 2001 22:45:53 +0000 (22:45 +0000)
intelligible struct representing an atomic Express Message.  UNfortunately,
this requires the user to free 2 things (object, object->message) as opposed
to one (object)...  C'est la vie...

libCxClient/ChangeLog
libCxClient/src/CxClient.h
libCxClient/src/misc.c

index cdfe6ab785d6b7ba1926900aee9c789545c059f8..75a20df3bac3d290f3109ec4b34d7c4161a002ef 100644 (file)
@@ -1,4 +1,10 @@
 $Log$
+Revision 1.9  2001/03/13 22:45:53  brian
+* Changed the return interface for CxMiExpRecv().  It now returns a more
+intelligible struct representing an atomic Express Message.  UNfortunately,
+this requires the user to free 2 things (object, object->message) as opposed
+to one (object)...  C'est la vie...
+
 Revision 1.8  2001/03/13 03:41:03  brian
 * Added SLRP support (but doesn't seem to work yet...)
 
@@ -23,3 +29,4 @@ 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 bf0cc9b29d8fcb8c721f5e2f990f652eb5d604f8..c05debae1faa5c029f547f1e210cbacf181fd06c 100644 (file)
@@ -152,6 +152,21 @@ struct             _user_info {
 
 } USERINFO;
 
+/**
+ ** struct _Exp_Mesg: This record contains a single Express Message, including any
+ ** text bound to the message.  It is an encapuslated GEXP message.
+ **/
+typedef struct _Exp_Mesg {
+
+ int           more_follows;
+ unsigned long int timestamp;
+ unsigned long int flags;
+ char          sender[255];
+ char          node[255];
+ char          *message;       /** This MUST be freed. **/
+
+} EXPRMESG;
+
 /**
  ** struct _Cmd_Callback: This record contains information regarding Server->Client
  ** message callbacks.  The general rule is such: IF the client wishes to handle
@@ -233,7 +248,7 @@ int         CxRmCreate(ROOMINFO);
  ** Miscellaneous Commands
  **/
 int            CxMiExpSend(const char *, const char *);
-char           *CxMiExpRecv();
+EXPRMESG       *CxMiExpRecv();
 int            CxMiExpCheck();
 void           CxMiExpHook(void (*)(const char *, const char*));
 char           *CxMiMessage(const char *);
index 4edee634f90202dd4776e091c69fb6b3e1112c90..88306ffaa697c24435dd012a7c9fea49030acd19 100644 (file)
@@ -94,22 +94,50 @@ int         rc;
  ** called after a NOOP loop returns RC_xxxx...
  **
  ** [Returns]
- **  Success: Ptr to malloc()ed message text.  [*]
+ **  Success: Ptr to malloc()ed EXPRMESG struct.  [*]
  **  Failure: NULL
  **/
-char           *CxMiExpRecv() {
-char           buf[255], *toret;
+EXPRMESG       *CxMiExpRecv() {
+char           buf[255], *Ser[20];
+EXPRMESG       *toret;
 int            rc;
 
+       /**
+        ** Ask the server for the latest Express Message [GEXP].
+        **/
        DPF((DFA,"Receive Express Message"));
        CxClSend("GEXP");
        rc = CxClRecv(buf);
        DPF((DFA,"buf=%s\n",buf));
-       toret = 0;
+       toret = 0L;
+
+       /**
+        ** If rc==RC_LISTING, then we have a valid Express Message.
+        **/
        DPF((DFA,"Checking result = ", rc));
        if( CHECKRC(rc, RC_LISTING)) {
+
                DPF((DFA,"Preparing to return"));
-               toret = (char *) CxMalloc(strlen(buf)+2);
+               toret = (EXPRMESG *) CxMalloc( sizeof(EXPRMESG) );
+               bzero( &toret, sizeof(EXPRMESG) );
+
+               CxSerialize( buf, &Ser );
+
+               toret->more_follows = atoi( Ser[0] );
+               toret->timestamp = (time_t) strtoul( Ser[1], 0, 10 );
+               toret->flags = atoi( Ser[2] );
+               strcpy( toret->sender, Ser[3] );
+               strcpy( toret->node, Ser[4] );
+               toret->message = 0L;
+               do {
+                       if((rc = CxClRecv(buf))) {
+                               DPF((DFA, "%s", buf));
+                               toret->message = (char *) realloc(toret, strlen(toret->message)+strlen(buf)+1);
+                               strcat(toret->message, buf);
+                       }
+               } while( rc < 0 );
+
+/****          toret = (char *) CxMalloc(strlen(buf)+2);
                strcpy(toret,buf);
                strcat(toret,"|");
                do {
@@ -119,10 +147,9 @@ int                rc;
                                strcat(toret,buf);
                        }
                } while(rc<0);
+ ****/
        }
 
-       DPF((DFA," toret = %s", toret));
-
        return(toret);
 }