2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Guenther Deschner 2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include <sys/types.h>
30 void popt_common_callback(poptContext con
,
31 enum poptCallbackReason reason
,
32 const struct poptOption
*opt
,
33 const char *arg
, const void *data
)
35 struct libnetapi_ctx
*ctx
= NULL
;
37 libnetapi_getctx(&ctx
);
39 if (reason
== POPT_CALLBACK_REASON_PRE
) {
42 if (reason
== POPT_CALLBACK_REASON_POST
) {
50 char *puser
= strdup(arg
);
53 if ((p
= strchr(puser
,'%'))) {
56 libnetapi_set_username(ctx
, puser
);
57 libnetapi_set_password(ctx
, p
+1);
59 memset(strchr(arg
,'%')+1,'X',len
);
61 libnetapi_set_username(ctx
, puser
);
67 libnetapi_set_debuglevel(ctx
, arg
);
70 libnetapi_set_password(ctx
, arg
);
73 libnetapi_set_use_kerberos(ctx
);
78 struct poptOption popt_common_netapi_examples
[] = {
80 .argInfo
= POPT_ARG_CALLBACK
|POPT_CBFLAG_PRE
|POPT_CBFLAG_POST
,
81 .arg
= (void *)popt_common_callback
,
86 .argInfo
= POPT_ARG_STRING
,
88 .descrip
= "Username used for connection",
89 .argDescrip
= "USERNAME",
92 .longName
= "password",
94 .argInfo
= POPT_ARG_STRING
,
96 .descrip
= "Password used for connection",
97 .argDescrip
= "PASSWORD",
100 .longName
= "debuglevel",
102 .argInfo
= POPT_ARG_STRING
,
104 .descrip
= "Debuglevel",
105 .argDescrip
= "DEBUGLEVEL",
108 .longName
= "kerberos",
110 .argInfo
= POPT_ARG_NONE
,
112 .descrip
= "Use Kerberos",