1 /* ========================================================================
2 * Copyright 2006-2007 University of Washington
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * ========================================================================
16 #include "../../../c-client/c-client.h"
17 #include "../../../c-client/imap4r1.h"
19 #include "../../../pith/osdep/color.h" /* color support library */
20 #include "../../../pith/osdep/canaccess.h"
21 #include "../../../pith/osdep/temp_nam.h"
23 #include "../../../pith/stream.h"
24 #include "../../../pith/context.h"
25 #include "../../../pith/state.h"
26 #include "../../../pith/msgno.h"
27 #include "../../../pith/debug.h"
28 #include "../../../pith/init.h"
29 #include "../../../pith/conf.h"
30 #include "../../../pith/conftype.h"
31 #include "../../../pith/detoken.h"
32 #include "../../../pith/flag.h"
33 #include "../../../pith/help.h"
34 #include "../../../pith/remote.h"
35 #include "../../../pith/status.h"
36 #include "../../../pith/mailcmd.h"
37 #include "../../../pith/savetype.h"
38 #include "../../../pith/save.h"
39 #include "../../../pith/reply.h"
40 #include "../../../pith/sort.h"
41 #include "../../../pith/ldap.h"
42 #include "../../../pith/addrbook.h"
43 #include "../../../pith/takeaddr.h"
44 #include "../../../pith/bldaddr.h"
45 #include "../../../pith/copyaddr.h"
46 #include "../../../pith/thread.h"
47 #include "../../../pith/folder.h"
48 #include "../../../pith/mailview.h"
49 #include "../../../pith/indxtype.h"
50 #include "../../../pith/mailindx.h"
51 #include "../../../pith/mailpart.h"
52 #include "../../../pith/mimedesc.h"
53 #include "../../../pith/detach.h"
54 #include "../../../pith/newmail.h"
55 #include "../../../pith/charset.h"
56 #include "../../../pith/util.h"
57 #include "../../../pith/rfc2231.h"
58 #include "../../../pith/string.h"
59 #include "../../../pith/send.h"
64 struct pine
*wps_global
; /* THE global variable! */
65 //char wtmp_20k_buf[20480];
70 WPLDAP_S
*wpldap_global
;
73 int peNoPassword
, peCredentialError
;
74 int peCertQuery
, peCertFailure
;
75 char peCredentialRequestor
[CRED_REQ_SIZE
];
76 STRLIST_S
*peCertHosts
;
79 sml_addmsg(int priority
, char *text
)
84 peDestroyUserContext(struct pine
**pps
)
89 main(int argc
, char *argv
[])
92 struct pine
*pine_state
;
93 char *p
= NULL
, *userid
= NULL
, *domain
= NULL
, *pname
;
94 struct variable
*vars
;
95 int i
, usage
= 0, rv
= 0;
97 pine_state
= new_pine_struct();
98 wps_global
= pine_state
;
99 vars
= wps_global
->vars
;
104 for(i
= 1 ; i
< argc
; i
++){
106 switch (argv
[i
++][1]) {
123 if(usage
== 1) break;
125 if(argc
== 1) usage
= rv
= 1;
126 if (usage
== 1 || !p
|| !userid
){
130 wpldap_global
= (WPLDAP_S
*)fs_get(sizeof(WPLDAP_S
));
131 wpldap_global
->query_no
= 0;
132 wpldap_global
->ldap_search_list
= NULL
;
134 wps_global
->pconf
= new_pinerc_s(p
);
135 if(wps_global
->pconf
)
136 read_pinerc(wps_global
->pconf
, vars
, ParseGlobal
);
138 fprintf(stderr
, "Failed to read pineconf\n");
142 set_current_val(&wps_global
->vars
[V_LDAP_SERVERS
], FALSE
, FALSE
);
143 set_current_val(&wps_global
->vars
[V_USER_DOMAIN
], FALSE
, FALSE
);
144 if(!wps_global
->VAR_USER_DOMAIN
&& !domain
){
145 fprintf(stderr
, "No domain set in pineconf\n");
149 if((pname
= peLdapPname(userid
, domain
? domain
: wps_global
->VAR_USER_DOMAIN
)) != NULL
){
150 fprintf(stdout
, "%s\n", pname
);
151 fs_give((void **)&pname
);
154 fprintf(stdout
, "\n");
158 fprintf(stderr
, "usage: pineldap -u userid -p pineconf [-d domain]\n");
160 if(wpldap_global
->ldap_search_list
)
161 free_wpldapres(wpldap_global
->ldap_search_list
);
162 fs_give((void **)&wpldap_global
);
164 if(wps_global
->pconf
)
165 free_pinerc_s(&wps_global
->pconf
);
166 free_pine_struct(&pine_state
);
170 fprintf(stderr
, "%s: Not built with LDAP support\n", argv
[0]);