Newsgroups: comp.parallel.pvm
From: Saghir Ahmed Shaikh <shaikh@ece.utexas.edu>
Subject: Help wanted in creating special packing/unpk routines
Organization: Univ. of Texas at Austin
Date: 30 Jan 1996 04:25:34 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <4ek6ju$rab@geraldo.cc.utexas.edu>

Dear pvm_users(all);

I have a question regarding creating a special packing and unpacking routine
for an object called event here is the code:

enum type {first, second};

class event {
	int	Value;
	String  Name;	// this is the String.h type for g++ 2.7
	type	Which;
};

I have made something like this:

// To pack an array of events
int pkevent(event *ep, int cnt, int std)
{
        int cc;
        while(cnt-- > 0) {
                cc = pvm_pkint(&ep->Value, 1, 1);
                cc *= pvm_pkstr((char *) (const char *) ep->Name);
                cc *= pvm_pkint((int *) &ep->Which, 1, 1);
                if (!cc) return cc;
                ep += std;
        }
        return PvmOk;
}
// To unpack the event

int upkevent(event *ep, int cnt, int std)
{
        int cc;  
        while(cnt-- > 0) {
                cc = pvm_upkint (&ep->Value, 1, 1);
                cc *= pvm_upkstr((char *) (const char *) ep->Name);
                cc *= pvm_upkint(&ep->Which, 1, 1);
                if (!cc) return cc;
                ep += std;
        }
        return PvmOk;
}


Problem: I know there is a problem in this routine, though gets compiled 
but i receive the wrong (garbage) value of the event on other end

I use it like this:

event	*eptr, TempEvent;

	upkevent(&Tempevent, 1, 1); // Does not work
	upkevent(eptr, 1, 1);	// Worng values or garbage values


Please help me in this regard. Send me the email too at saghir@mail.utexas.edu

Thanks a lot	


peace, saghir
-------------------------------------------------------------------+
Saghir A. Shaikh	       | Email: saghir@mail.utexas.edu	   |
Dept. of Elec. & Comp. Engr.   | The University of Texas at Austin | 
-------------------------------------------------------------------+


