c++ code syntax help, : Passing by Reference or val ??
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
c++ code syntax help, : Passing by Reference or val ??
Hi,
I got stuck with code please help me understand what is it doing ..
Code:
int authcustomcommon(const char *user, const char *pass,
int (*callback)(struct authinfo *, void *),
void *arg)
{
struct authinfo auth;
int rc;
memset(&auth, 0, sizeof(auth));
rc=do_auth_custom(user, &auth);
....
}
static int do_auth_custom(const char *userid, struct authinfo *authinfo)
{
...
// I need to write code here to put values in auth struct variable pass to this function ....
...
}
In the above code, I have a structure called authinfo, variable name auth ...
this value is pass to below function, but I am not sure which value I need to set?
like in structure I have
Code:
struct authinfo{
<DATATYPE> sysusername
}
I need to set sysusername from called function as this value is used by calling function
I know this basic question but I did C++ 7 yrs ago on windows platform...
for your reference, this is code of Courier MTA's authentication module for Custom authentication Method ...
(file is : preauthcustom.c in courier-auth library)
It looks like you are receiving a pointer to the structure so when you change the value you want to dereference the field:
Code:
authinfo->sysusername = <your data goes here>
However it may not be that simple if sysusername is a character array, since you can't do direct assignment, rather you probably want to use a function that will copy the contents across.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.