Skip to content

Commit

Permalink
Add a (very!) trivial cache to the example authentication callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
derrell committed Jan 16, 2008
1 parent 4ff2101 commit 01f6a4c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion examples/libsmbclient/get_auth_data_fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,23 @@ get_auth_data_fn(const char * pServer,
char * pPassword,
int maxLenPassword)
{
char temp[128];
char temp[128];
char server[256] = { '\0' };
char share[256] = { '\0' };
char workgroup[256] = { '\0' };
char username[256] = { '\0' };
char password[256] = { '\0' };

if (strcmp(server, pServer) == 0 &&
strcmp(share, pShare) == 0 &&
*workgroup != '\0' &&
*username != '\0')
{
strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1);
strncpy(pUsername, username, maxLenUsername - 1);
strncpy(pPassword, password, maxLenPassword - 1);
return;
}

fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
fgets(temp, sizeof(temp), stdin);
Expand Down Expand Up @@ -48,4 +64,8 @@ get_auth_data_fn(const char * pServer,
{
strncpy(pPassword, temp, maxLenPassword - 1);
}

strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
strncpy(username, pUsername, sizeof(username) - 1);
strncpy(password, pPassword, sizeof(password) - 1);
}

0 comments on commit 01f6a4c

Please sign in to comment.