Initial import
[samba] / examples / libsmbclient / get_auth_data_fn.h
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)
10     
11 {
12     char temp[128];
13     
14     fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
15     fgets(temp, sizeof(temp), stdin);
16     
17     if (temp[strlen(temp) - 1] == '\n') /* A new line? */
18     {
19         temp[strlen(temp) - 1] = '\0';
20     }
21     
22     if (temp[0] != '\0')
23     {
24         strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
25     }
26     
27     fprintf(stdout, "Username: [%s] ", pUsername);
28     fgets(temp, sizeof(temp), stdin);
29     
30     if (temp[strlen(temp) - 1] == '\n') /* A new line? */
31     {
32         temp[strlen(temp) - 1] = '\0';
33     }
34     
35     if (temp[0] != '\0')
36     {
37         strncpy(pUsername, temp, maxLenUsername - 1);
38     }
39     
40     fprintf(stdout, "Password: ");
41     fgets(temp, sizeof(temp), stdin);
42     
43     if (temp[strlen(temp) - 1] == '\n') /* A new line? */
44     {
45         temp[strlen(temp) - 1] = '\0';
46     }
47     
48     if (temp[0] != '\0')
49     {
50         strncpy(pPassword, temp, maxLenPassword - 1);
51     }
52 }