$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...)
Revision 1.2 2001/02/07 22:41:51 brian
* Updated ChangeLog to conform to Citadel/UX standards (kinda) :)
+
} 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
** 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 *);
** 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 {
strcat(toret,buf);
}
} while(rc<0);
+ ****/
}
- DPF((DFA," toret = %s", toret));
-
return(toret);
}