9 void popt_common_callback(poptContext con
,
10 enum poptCallbackReason reason
,
11 const struct poptOption
*opt
,
12 const char *arg
, const void *data
)
14 struct libnetapi_ctx
*ctx
= NULL
;
16 libnetapi_getctx(&ctx
);
18 if (reason
== POPT_CALLBACK_REASON_PRE
) {
21 if (reason
== POPT_CALLBACK_REASON_POST
) {
29 char *puser
= strdup(arg
);
32 if ((p
= strchr(puser
,'%'))) {
35 libnetapi_set_username(ctx
, puser
);
36 libnetapi_set_password(ctx
, p
+1);
38 memset(strchr(arg
,'%')+1,'X',len
);
40 libnetapi_set_username(ctx
, puser
);
46 libnetapi_set_debuglevel(ctx
, arg
);
49 libnetapi_set_password(ctx
, arg
);
52 libnetapi_set_use_kerberos(ctx
);
57 struct poptOption popt_common_netapi_examples
[] = {
58 { NULL
, 0, POPT_ARG_CALLBACK
|POPT_CBFLAG_PRE
|POPT_CBFLAG_POST
, (void *)popt_common_callback
},
59 { "user", 'U', POPT_ARG_STRING
, NULL
, 'U', "Username used for connection", "USERNAME" },
60 { "password", 'p', POPT_ARG_STRING
, NULL
, 'p', "Password used for connection", "PASSWORD" },
61 { "debuglevel", 'd', POPT_ARG_STRING
, NULL
, 'd', "Debuglevel", "DEBUGLEVEL" },
62 { "kerberos", 'k', POPT_ARG_NONE
, NULL
, 'k', "Use Kerberos", NULL
},