11 void popt_common_callback(poptContext con
,
12 enum poptCallbackReason reason
,
13 const struct poptOption
*opt
,
14 const char *arg
, const void *data
)
16 struct libnetapi_ctx
*ctx
= NULL
;
18 libnetapi_getctx(&ctx
);
20 if (reason
== POPT_CALLBACK_REASON_PRE
) {
23 if (reason
== POPT_CALLBACK_REASON_POST
) {
31 char *puser
= strdup(arg
);
34 if ((p
= strchr(puser
,'%'))) {
37 libnetapi_set_username(ctx
, puser
);
38 libnetapi_set_password(ctx
, p
+1);
40 memset(strchr(arg
,'%')+1,'X',len
);
42 libnetapi_set_username(ctx
, puser
);
48 libnetapi_set_debuglevel(ctx
, arg
);
51 libnetapi_set_password(ctx
, arg
);
54 libnetapi_set_use_kerberos(ctx
);
59 struct poptOption popt_common_netapi_examples
[] = {
60 { NULL
, 0, POPT_ARG_CALLBACK
|POPT_CBFLAG_PRE
|POPT_CBFLAG_POST
, (void *)popt_common_callback
},
61 { "user", 'U', POPT_ARG_STRING
, NULL
, 'U', "Username used for connection", "USERNAME" },
62 { "password", 'p', POPT_ARG_STRING
, NULL
, 'p', "Password used for connection", "PASSWORD" },
63 { "debuglevel", 'd', POPT_ARG_STRING
, NULL
, 'd', "Debuglevel", "DEBUGLEVEL" },
64 { "kerberos", 'k', POPT_ARG_NONE
, NULL
, 'k', "Use Kerberos", NULL
},