Ok,
I now use this code to get the timeticks, but i only gets 4 bytes (char)
The 8 extra allocated bytes were a desperate attempt to get more digits
but alas, that does not work. I still only get 4 digits. Does anyone
have
a better way of doing this ? If i cast the 4th line as in
sprintf(data->sysUpTime,"%lu",(char *)*vars->val.integer) i still get
the
same value.
if(vars->type==ASN_TIMETICKS) {
if(i==1) {
/* sizeof(*vars->val.integer= long/int probably 4 bytes.
+8 for some digits in precision
+1 for the NULL terminated string
data->sysUpTime=malloc(sizeof(*vars->val.integer)+8+1);
sprintf(data->sysUpTime,"%lu",*vars->val.integer);
data->sysUpTime[sizeof(*vars->val.integer+8)]='\0';
}
}
Thanks Dave, and thanks Steve.
On Jan 17, 2007, at 12:27 AM, Dave Shield wrote:
On 16/01/07, Alef Veld <[EMAIL PROTECTED]> wrote:
I'm not sure what you mean exactly by number 2 though. Do you
mean that the long is defined 32bits on my machine ?
Not quite.
Rather that TimeTicks is defined as 32 bits, regardless of the
architecture of a particular system. Remember SNMP is all
about providing a *standard* mechanism for network management.
That means it must work the same way on all systems.
It's not possible to have different maximum sizes on different
systems - that way madness lies.
If so, are you implying i need an even bigger number to host the
long * ?
No - it doesn't work that way.
TimeTicks will inherently wrap after about 16 months.
There's nothing you can do to prevent this.
I just need a proper way to stuff the long * dereferenced value into
my char * pointer.
Don't think of the char* as a string of printable characters.
It's really just an alternative to void* - a generic pointer.
All you need to do is take the long* pointer, and cast it to char*
(or vice versa).
Dave
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders