util_tdb: mark tdb_pack() and friends as deprecated
[Samba.git] / examples / libsmbclient / get_auth_data_fn.h
blob6b91c973375a08d5b50e88c1f306c7240daf49ef
1 #include <stdlib.h>
3 static void
4 get_auth_data_fn(const char * pServer,
5 const char * pShare,
6 char * pWorkgroup,
7 int maxLenWorkgroup,
8 char * pUsername,
9 int maxLenUsername,
10 char * pPassword,
11 int maxLenPassword)
13 char temp[128];
14 char server[256] = { '\0' };
15 char share[256] = { '\0' };
16 char workgroup[256] = { '\0' };
17 char username[256] = { '\0' };
18 char password[256] = { '\0' };
20 static int krb5_set = 1;
22 if (strcmp(server, pServer) == 0 &&
23 strcmp(share, pShare) == 0 &&
24 *workgroup != '\0' &&
25 *username != '\0')
27 strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1);
28 strncpy(pUsername, username, maxLenUsername - 1);
29 strncpy(pPassword, password, maxLenPassword - 1);
30 return;
33 if (krb5_set && getenv("KRB5CCNAME")) {
34 krb5_set = 0;
35 return;
38 fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
39 fgets(temp, sizeof(temp), stdin);
41 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
43 temp[strlen(temp) - 1] = '\0';
46 if (temp[0] != '\0')
48 strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
51 fprintf(stdout, "Username: [%s] ", pUsername);
52 fgets(temp, sizeof(temp), stdin);
54 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
56 temp[strlen(temp) - 1] = '\0';
59 if (temp[0] != '\0')
61 strncpy(pUsername, temp, maxLenUsername - 1);
64 fprintf(stdout, "Password: ");
65 fgets(temp, sizeof(temp), stdin);
67 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
69 temp[strlen(temp) - 1] = '\0';
72 if (temp[0] != '\0')
74 strncpy(pPassword, temp, maxLenPassword - 1);
77 strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
78 strncpy(username, pUsername, sizeof(username) - 1);
79 strncpy(password, pPassword, sizeof(password) - 1);
81 krb5_set = 1;