15 |
|
|
16 |
extern int sockpri; |
extern int sockpri; |
17 |
extern unsigned int capabilities; |
extern unsigned int capabilities; |
18 |
|
extern char authmech[AUTH_MECH_LEN]; |
19 |
extern jmp_buf acctloop; |
extern jmp_buf acctloop; |
20 |
|
|
21 |
static char *vbuf = NULL; /* Virtual buffer. */ |
static char *vbuf = NULL; /* Virtual buffer. */ |
30 |
socket_read(sock, buf); |
socket_read(sock, buf); |
31 |
|
|
32 |
#ifdef DEBUG |
#ifdef DEBUG |
33 |
printf("\n%s\n", buf); |
fprintf(stderr, "\n%s\n", buf); |
34 |
#endif |
#endif |
35 |
|
|
36 |
} |
} |
125 |
if (strcasestr(vbuf, "NAMESPACE")) |
if (strcasestr(vbuf, "NAMESPACE")) |
126 |
capabilities |= CAPABILITY_NAMESPACE; |
capabilities |= CAPABILITY_NAMESPACE; |
127 |
|
|
128 |
|
auth_mechanisms(); |
129 |
|
|
130 |
return analyze_response(buf); |
return analyze_response(buf); |
131 |
} |
} |
132 |
|
|
133 |
|
|
134 |
/* |
/* |
135 |
|
* Create the list of available authentication mechanisms. |
136 |
|
*/ |
137 |
|
void auth_mechanisms(void) |
138 |
|
{ |
139 |
|
int len; |
140 |
|
char *c, *cp, *tok; |
141 |
|
|
142 |
|
*authmech = 0; |
143 |
|
|
144 |
|
c = cp = xstrdup(vbuf); |
145 |
|
|
146 |
|
tok = strtok_r(c, " \r\n", &c); |
147 |
|
while(tok) { |
148 |
|
if (strcasestr(tok, "AUTH=")) { |
149 |
|
strncat(authmech, tok + 5, AUTH_MECH_LEN - strlen(authmech) - 2); |
150 |
|
len = strlen(authmech); |
151 |
|
*(authmech + len) = ' '; |
152 |
|
*(authmech + len + 1) = 0; |
153 |
|
} |
154 |
|
tok = strtok_r(NULL, " \r\n", &c); |
155 |
|
} |
156 |
|
if ((len = strlen(authmech))) |
157 |
|
*(authmech + strlen(authmech) - 1) = 0; |
158 |
|
|
159 |
|
xfree(cp); |
160 |
|
|
161 |
|
#ifdef DEBUG |
162 |
|
fprintf(stderr, "debug: authentication mechanisms: '%s'\n", authmech); |
163 |
|
#endif |
164 |
|
|
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
/* |
169 |
* Process the data that server sent due to IMAP NAMESPACE client request. |
* Process the data that server sent due to IMAP NAMESPACE client request. |
170 |
*/ |
*/ |
171 |
int namespace_response(int *sock, unsigned int tag, namesp_t * nsp) |
int namespace_response(int *sock, unsigned int tag, namesp_t * nsp) |
193 |
} |
} |
194 |
} |
} |
195 |
#ifdef DEBUG |
#ifdef DEBUG |
196 |
printf("debug: namespace: '%s' '%c'\n", nsp->prefix, nsp->delim); |
fprintf(stderr, "debug: namespace: '%s' '%c'\n", nsp->prefix, nsp->delim); |
197 |
#endif |
#endif |
198 |
return analyze_response(buf); |
return analyze_response(buf); |
199 |
} |
} |