There's no way to access the hidden struct elements without modifying the code one way or another. I've taken both approaches, for large scale hacks I move the structure definition into the header, and for one-offs I just write an accessor function and put its declaration in the header. Bill On 1/21/2015 2:18 PM, Brunner, Brian T. wrote: > Thanks, Bill! I was afraid I'd overlooked the obvious. > Copying the struct (and the enum) to my code file enabled reading > current_op. > (I had just done this before reading your reply) > > What would go wrong if there was a macro taking the header file, the > name (instance), the name (type), and member variable of a structure > and returning the named member of the named struct? > This wouldn't necessarily be a change to all of pjsip/pjsua/pjmedia, > rather it should create a file to be compiled with pjlibs. It would > be a different file for each app using pjlibs because different apps > need access to different elements of hidden structs. > > ------------------------------------------------------------------------ > *From:* pjsip [pjsip-bounces at lists.pjsip.org] on behalf of Bill > Gardner [billg at wavearts.com] > *Sent:* Wednesday, January 21, 2015 10:28 AM > *To:* pjsip at lists.pjsip.org > *Subject:* Re: [pjsip] (no subject) > > Hi Brian, > > The PJSIP code hides many of the structure definitions by defining > only the type in the header, > while the actual structure is defined in the C file that implements > the methods. This is akin > to having private members in a C++ class. > > In your example regc->current_op is not defined in the header. You can > modify the code by moving > the structure definition into the header (making the declaration > public), or define an accessor method > to get the value of current_op. > > Regards, > > Bill > > On 1/21/2015 9:42 AM, Brunner, Brian T. wrote: >> On /Wed May 15 22:41:44 EDT 2013 >> onmyway133 at gmail dot com said >> "/ >> @saltyfoam You can check for current_op in pjsip_regc >> They can be in IDLE, REGISTERING, UNREGISTERING >> " >> >> My attempts to access and test current_op fail. >> I have read online documentation and source code for a few days. >> Here is where I am stopped: >> #include <pjsip-ua/sip_regc.h> >> void cb_on_reg_state2 (pjsua_acc_id acc_id, pjsua_reg_info *info) >> { >> PJ_LOG(3,(__FILE__, "%s: Account %d Reason %.*s Status %d >> CurrentOp %d", >> __FUNCTION__, acc_id, info->cbparam->reason.slen, >> info->cbparam->reason.ptr, >> info->cbparam->status, info->cbparam->regc->current_op )); >> } >> error: invalid use of incomplete type 'pjsip_regc {aka struct >> pjsip_regc}' >> __FUNCTION__, acc_id, info->cbparam->reason.slen, >> info->cbparam->reason.ptr, info->cbparam->status, >> info->cbparam->regc->current_op )); >> >> The compiler declares struct pjsip_regc to be an incomplete type. >> >> /usr/include/pjsip-ua/sip_regc.h only gives a typedef struct >> pjsip_regc pjsip_regc; the structure definition is only in >> pjsip/src/pjsip-ua/sip_reg.c >> >> So, how do I inform the compiler where to get current_op? >> >> The brute-force method looks to be moving the pjsip_regc structure >> declaration into the header file ahead of the typedef, and removing >> it from the source file. >> >> Clues begged piteously. >> >> >> ------------------------------------------------------------------------ >> >> ---------------------------------------------------------------------------------------------------------------------------- >> >> >> Confidentiality Requirement: This communication, including any >> attachment(s), may contain confidential information and is for the >> sole use of the intended recipient(s). If you are not the intended >> recipient, you are hereby notified that you have received this >> communication in error and any unauthorized review, use, disclosure, >> dissemination, distribution or copying of it or its contents is >> strictly prohibited. If you have received this communication in >> error, please notify the sender immediately by telephone or e-mail >> and destroy all copies of this communication and any attachments. >> >> >> >> _______________________________________________ >> Visit our blog:http://blog.pjsip.org >> >> pjsip mailing list >> pjsip at lists.pjsip.org >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150121/b4d5c5af/attachment.html>