1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
static void
get_auth_data_fn(const char * pServer,
const char * pShare,
char * pWorkgroup,
int maxLenWorkgroup,
char * pUsername,
int maxLenUsername,
char * pPassword,
int maxLenPassword)
{
char temp[128];
fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
fgets(temp, sizeof(temp), stdin);
if (temp[strlen(temp) - 1] == '\n') /* A new line? */
{
temp[strlen(temp) - 1] = '\0';
}
if (temp[0] != '\0')
{
strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
}
fprintf(stdout, "Username: [%s] ", pUsername);
fgets(temp, sizeof(temp), stdin);
if (temp[strlen(temp) - 1] == '\n') /* A new line? */
{
temp[strlen(temp) - 1] = '\0';
}
if (temp[0] != '\0')
{
strncpy(pUsername, temp, maxLenUsername - 1);
}
fprintf(stdout, "Password: ");
fgets(temp, sizeof(temp), stdin);
if (temp[strlen(temp) - 1] == '\n') /* A new line? */
{
temp[strlen(temp) - 1] = '\0';
}
if (temp[0] != '\0')
{
strncpy(pPassword, temp, maxLenPassword - 1);
}
}
|