× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



As I understand it, a union is the RPG equivalent of a DS having two fields -
in this case an integer and a character in the same memory location. The idea
being you know which sort of value to expect, ths use the right variable.

the trouble with doing something else is that everything I do, except for
debug, says result is Null.
Now this might be OK, since I cant guarantee I'm actually asking for a real
value - but that's because you never really know what is going on with these
damn manuals... For instance the manual warns you to pass the text as ASCII,
then the example passes it as EBCDIC (or at least it's typed in in plain text
within SEU, I'm not sure what C then does to it).

On Wednesday 28 November 2001 20:39, Buck Calabro wrote:
> >struct _varBind{ struct _varBind * next;
> >char *oid; /* Null Terminated */
> >unsigned char asn_type;
> >int val_len;
> >union { int * int_val; char * str_val; } val; };
> >
> >0009.00 D pdu_ptr_s       S               *
> >0010.00 D pdu_ds          DS                   based(pdu_ptr_s)
> >0011.00 D  next                           *
> >0012.00 D  oid                            *
> >0013.00 D  asn_type                       *
> >0014.00 D  val_len                      10I 0
> >0015.00 D  result                         *
> >So if I do this and snmpget returns OK, the 'result' field
> >(from the DS) is
> >*NULL but in debug an 'eval pdu_ds' shows 'result' is a valid
> >pointer...
> >
> >So my 2 questions are:
> >1) Is the api translated to rpg ok
>
> I can't help because I don't understand union {}
>
> >2) can i access %str(result) or should I be doing something else.
>
> I would say you should be doing something else.  "result" is a pointer to
> something.  You need to create a space for that something, just as you have
> for pdu_ds.  The function returns a pointer and that pointer points to the
> pdu_ds memory space.  Since I don't know what union {} does, I can't tell
> you what sort of space to create; perhaps another data structure?  Then you
> could address the data being pointed to by "result."
>   --buck


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.