Fix build of pam_smbpass.
[Samba.git] / examples / libsmbclient / get_auth_data_fn.h
blobb1d36c8beacd4ecadc63075f2d8719cd5c7dd6c8
1 static void
2 get_auth_data_fn(const char * pServer,
3 const char * pShare,
4 char * pWorkgroup,
5 int maxLenWorkgroup,
6 char * pUsername,
7 int maxLenUsername,
8 char * pPassword,
9 int maxLenPassword)
11 char temp[128];
12 char server[256] = { '\0' };
13 char share[256] = { '\0' };
14 char workgroup[256] = { '\0' };
15 char username[256] = { '\0' };
16 char password[256] = { '\0' };
18 if (strcmp(server, pServer) == 0 &&
19 strcmp(share, pShare) == 0 &&
20 *workgroup != '\0' &&
21 *username != '\0')
23 strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1);
24 strncpy(pUsername, username, maxLenUsername - 1);
25 strncpy(pPassword, password, maxLenPassword - 1);
26 return;
29 fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
30 fgets(temp, sizeof(temp), stdin);
32 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
34 temp[strlen(temp) - 1] = '\0';
37 if (temp[0] != '\0')
39 strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
42 fprintf(stdout, "Username: [%s] ", pUsername);
43 fgets(temp, sizeof(temp), stdin);
45 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
47 temp[strlen(temp) - 1] = '\0';
50 if (temp[0] != '\0')
52 strncpy(pUsername, temp, maxLenUsername - 1);
55 fprintf(stdout, "Password: ");
56 fgets(temp, sizeof(temp), stdin);
58 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
60 temp[strlen(temp) - 1] = '\0';
63 if (temp[0] != '\0')
65 strncpy(pPassword, temp, maxLenPassword - 1);
68 strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
69 strncpy(username, pUsername, sizeof(username) - 1);
70 strncpy(password, pPassword, sizeof(password) - 1);