Git.pm: Use stream-like writing in cat_blob()
[git/dscho.git] / test-credential.c
blob3929efd9b0fa06bcd11306045afed7a131bf33fe
1 #include "cache.h"
2 #include "credential.h"
3 #include "string-list.h"
4 #include "parse-options.h"
6 int main(int argc, const char **argv)
8 int reject = 0;
9 struct credential c = { NULL };
10 struct string_list methods = STRING_LIST_INIT_NODUP;
11 const char *const usage[] = {
12 "test-credential [options] [method...]",
13 NULL
15 struct option options[] = {
16 OPT_BOOLEAN(0, "reject", &reject, "reject"),
17 OPT_STRING(0, "description", &c.description, "desc",
18 "description"),
19 OPT_STRING(0, "unique", &c.unique, "token",
20 "unique"),
21 OPT_STRING(0, "username", &c.username, "name", "username"),
22 OPT_STRING(0, "password", &c.password, "pass", "password"),
23 OPT_END()
25 int i;
27 argc = parse_options(argc, argv, NULL, options, usage, 0);
28 for (i = 0; i < argc; i++)
29 string_list_append(&methods, argv[i]);
30 /* credential_reject will try to free() */
31 if (c.username)
32 c.username = xstrdup(c.username);
33 if (c.password)
34 c.password = xstrdup(c.password);
36 if (reject)
37 credential_reject(&c, &methods);
38 else
39 credential_fill(&c, &methods);
41 if (c.username)
42 printf("username=%s\n", c.username);
43 if (c.password)
44 printf("password=%s\n", c.password);
46 return 0;