4945ba06977a5e566c1ba3379c6055202cc5564a
[claws.git] / src / etpan / nntp-thread.c
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2005-2007 DINH Viet Hoa and the Claws Mail team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  * 
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #ifdef HAVE_LIBETPAN
25
26 #include "nntp-thread.h"
27 #include "news.h"
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #if (defined(__DragonFly__) || defined (__NetBSD__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__))
31 #include <sys/socket.h>
32 #endif
33 #include <fcntl.h>
34 #ifndef G_OS_WIN32
35 #include <sys/mman.h>
36 #include <sys/wait.h>
37 #endif
38 #include <gtk/gtk.h>
39 #include <log.h>
40 #include "etpan-thread-manager.h"
41 #include "utils.h"
42 #include "mainwindow.h"
43 #include "ssl_certificate.h"
44 #include "socket.h"
45 #include "remotefolder.h"
46
47 #define DISABLE_LOG_DURING_LOGIN
48
49 static struct etpan_thread_manager * thread_manager = NULL;
50 static chash * courier_workaround_hash = NULL;
51 static chash * nntp_hash = NULL;
52 static chash * session_hash = NULL;
53 static guint thread_manager_signal = 0;
54 static GIOChannel * io_channel = NULL;
55
56 static void (*previous_stream_logger)(int direction,
57     const char * str, size_t size);
58
59 static void nntp_logger(int direction, const char * str, size_t size) 
60 {
61         gchar *buf;
62         gchar **lines;
63         int i = 0;
64
65         if (size > 256) {
66                 log_print(LOG_PROTOCOL, "NNTP%c [data - %zd bytes]\n", direction?'>':'<', size);
67                 return;
68         }
69         buf = malloc(size+1);
70         memset(buf, 0, size+1);
71         strncpy(buf, str, size);
72         buf[size] = '\0';
73
74         if (!strncmp(buf, "<<<<<<<", 7) 
75         ||  !strncmp(buf, ">>>>>>>", 7)) {
76                 free(buf);
77                 return;
78         }
79         while (strstr(buf, "\r"))
80                 *strstr(buf, "\r") = ' ';
81         while (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
82                 buf[strlen(buf)-1] = '\0';
83
84         lines = g_strsplit(buf, "\n", -1);
85
86         while (lines[i] && *lines[i]) {
87                 log_print(LOG_PROTOCOL, "NNTP%c %s\n", direction?'>':'<', lines[i]);
88                 i++;
89         }
90         g_strfreev(lines);
91         free(buf);
92 }
93
94 static void delete_nntp(Folder *folder, newsnntp *nntp)
95 {
96         chashdatum key;
97         chashdatum value;
98
99         key.data = &folder;
100         key.len = sizeof(folder);
101         value.data = nntp;
102         value.len = 0;
103         chash_delete(session_hash, &key, NULL);
104         
105         key.data = &nntp;
106         key.len = sizeof(nntp);
107         if (nntp && nntp->nntp_stream) {
108                 /* we don't want libetpan to logout */
109                 mailstream_close(nntp->nntp_stream);
110                 nntp->nntp_stream = NULL;
111         }
112         debug_print("removing newsnntp %p\n", nntp);
113         newsnntp_free(nntp);    
114 }
115
116 static gboolean thread_manager_event(GIOChannel * source,
117     GIOCondition condition,
118     gpointer data)
119 {
120         etpan_thread_manager_loop(thread_manager);
121         
122         return TRUE;
123 }
124
125 #define ETPAN_DEFAULT_NETWORK_TIMEOUT 60
126 extern gboolean etpan_skip_ssl_cert_check;
127
128 void nntp_main_init(gboolean skip_ssl_cert_check)
129 {
130         int fd_thread_manager;
131         
132         etpan_skip_ssl_cert_check = skip_ssl_cert_check;
133         
134         nntp_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE);
135         session_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE);
136         courier_workaround_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE);
137         
138         thread_manager = etpan_thread_manager_new();
139         
140         fd_thread_manager = etpan_thread_manager_get_fd(thread_manager);
141         
142         io_channel = g_io_channel_unix_new(fd_thread_manager);
143         
144         thread_manager_signal = g_io_add_watch_full(io_channel, 0, G_IO_IN,
145                                                     thread_manager_event,
146                                                     (gpointer) NULL,
147                                                     NULL);
148 }
149
150 void nntp_main_done(void)
151 {
152         etpan_thread_manager_stop(thread_manager);
153 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
154         return;
155 #endif
156         etpan_thread_manager_join(thread_manager);
157         
158         g_source_remove(thread_manager_signal);
159         g_io_channel_unref(io_channel);
160         
161         etpan_thread_manager_free(thread_manager);
162         
163         chash_free(session_hash);
164         chash_free(nntp_hash);
165 }
166
167 void nntp_init(Folder * folder)
168 {
169         struct etpan_thread * thread;
170         chashdatum key;
171         chashdatum value;
172         
173         thread = etpan_thread_manager_get_thread(thread_manager);
174         
175         key.data = &folder;
176         key.len = sizeof(folder);
177         value.data = thread;
178         value.len = 0;
179         
180         chash_set(nntp_hash, &key, &value, NULL);
181 }
182
183 void nntp_done(Folder * folder)
184 {
185         struct etpan_thread * thread;
186         chashdatum key;
187         chashdatum value;
188         int r;
189         
190         key.data = &folder;
191         key.len = sizeof(folder);
192         
193         r = chash_get(nntp_hash, &key, &value);
194         if (r < 0)
195                 return;
196         
197         thread = value.data;
198         
199         etpan_thread_unbind(thread);
200         
201         chash_delete(nntp_hash, &key, NULL);
202         
203         debug_print("remove thread");
204 }
205
206 static struct etpan_thread * get_thread(Folder * folder)
207 {
208         struct etpan_thread * thread;
209         chashdatum key;
210         chashdatum value;
211         
212         key.data = &folder;
213         key.len = sizeof(folder);
214         
215         chash_get(nntp_hash, &key, &value);
216         thread = value.data;
217         
218         return thread;
219 }
220
221 static newsnntp * get_nntp(Folder * folder)
222 {
223         newsnntp * nntp;
224         chashdatum key;
225         chashdatum value;
226         int r;
227         
228         key.data = &folder;
229         key.len = sizeof(folder);
230         
231         r = chash_get(session_hash, &key, &value);
232         if (r < 0)
233                 return NULL;
234         
235         nntp = value.data;
236         debug_print("found nntp %p\n", nntp);
237         return nntp;
238 }
239
240
241 static void generic_cb(int cancelled, void * result, void * callback_data)
242 {
243         struct etpan_thread_op * op;
244         
245         op = (struct etpan_thread_op *) callback_data;
246
247         debug_print("generic_cb\n");
248         op->finished = 1;
249 }
250
251 static void threaded_run(Folder * folder, void * param, void * result,
252                          void (* func)(struct etpan_thread_op * ))
253 {
254         struct etpan_thread_op * op;
255         struct etpan_thread * thread;
256         
257         nntp_folder_ref(folder);
258
259         op = etpan_thread_op_new();
260         
261         op->nntp = get_nntp(folder);
262         op->param = param;
263         op->result = result;
264         
265         op->cancellable = 0;
266         op->run = func;
267         op->callback = generic_cb;
268         op->callback_data = op;
269         op->cleanup = NULL;
270         
271         op->finished = 0;
272         
273         previous_stream_logger = mailstream_logger;
274         mailstream_logger = nntp_logger;
275
276         thread = get_thread(folder);
277         etpan_thread_op_schedule(thread, op);
278         
279         while (!op->finished) {
280                 gtk_main_iteration();
281         }
282         
283         mailstream_logger = previous_stream_logger;
284
285         etpan_thread_op_free(op);
286
287         nntp_folder_unref(folder);
288 }
289
290
291 /* connect */
292
293 struct connect_param {
294         newsnntp * nntp;
295         const char * server;
296         int port;
297 };
298
299 struct connect_result {
300         int error;
301 };
302
303 #define CHECK_NNTP() {                                          \
304         if (!param->nntp) {                                     \
305                 result->error = NEWSNNTP_ERROR_BAD_STATE;       \
306                 return;                                         \
307         }                                                       \
308 }
309
310 static void connect_run(struct etpan_thread_op * op)
311 {
312         int r;
313         struct connect_param * param;
314         struct connect_result * result;
315         
316         param = op->param;
317         result = op->result;
318         
319         CHECK_NNTP();
320
321         r = newsnntp_socket_connect(param->nntp,
322                                     param->server, param->port);
323         
324         result->error = r;
325 }
326
327
328 int nntp_threaded_connect(Folder * folder, const char * server, int port)
329 {
330         struct connect_param param;
331         struct connect_result result;
332         chashdatum key;
333         chashdatum value;
334         newsnntp * nntp, * oldnntp;
335         
336         oldnntp = get_nntp(folder);
337
338         nntp = newsnntp_new(0, NULL);
339         
340         if (oldnntp) {
341                 debug_print("deleting old nntp %p\n", oldnntp);
342                 delete_nntp(folder, oldnntp);
343         }
344         
345         key.data = &folder;
346         key.len = sizeof(folder);
347         value.data = nntp;
348         value.len = 0;
349         chash_set(session_hash, &key, &value, NULL);
350         
351         param.nntp = nntp;
352         param.server = server;
353         param.port = port;
354         
355         refresh_resolvers();
356         threaded_run(folder, &param, &result, connect_run);
357         
358         debug_print("connect ok %i with nntp %p\n", result.error, nntp);
359         
360         return result.error;
361 }
362
363 static int etpan_certificate_check(const unsigned char *certificate, int len, void *data)
364 {
365 #ifdef USE_OPENSSL
366         struct connect_param *param = (struct connect_param *)data;
367         X509 *cert = NULL;
368         
369         if (certificate == NULL || len < 0) {
370                 g_warning("no cert presented.\n");
371                 return 0;
372         }
373         cert = d2i_X509(NULL, (const unsigned char **)&certificate, len);
374         if (cert == NULL) {
375                 g_warning("nntp: can't get cert\n");
376                 return 0;
377         } else if (ssl_certificate_check(cert, NULL,
378                 (gchar *)param->server, (gushort)param->port) == TRUE) {
379                 X509_free(cert);
380                 return 0;
381         } else {
382                 X509_free(cert);
383                 return -1;
384         }
385 #elif USE_GNUTLS
386         struct connect_param *param = (struct connect_param *)data;
387         gnutls_x509_crt cert = NULL;
388         gnutls_datum tmp;
389         
390         if (certificate == NULL || len < 0) {
391                 g_warning("no cert presented.\n");
392                 return 0;
393         }
394         
395         tmp.data = malloc(len);
396         memcpy(tmp.data, certificate, len);
397         tmp.size = len;
398         gnutls_x509_crt_init(&cert);
399         if (gnutls_x509_crt_import(cert, &tmp, GNUTLS_X509_FMT_DER) < 0) {
400                 g_warning("nntp: can't get cert\n");
401                 return 0;
402         } else if (ssl_certificate_check(cert, (guint)-1, NULL,
403                 (gchar *)param->server, (gushort)param->port) == TRUE) {
404                 gnutls_x509_crt_deinit(cert);
405                 return 0;
406         } else {
407                 gnutls_x509_crt_deinit(cert);
408                 return -1;
409         }
410 #endif
411         return 0;
412 }
413
414 static void connect_ssl_run(struct etpan_thread_op * op)
415 {
416         int r;
417         struct connect_param * param;
418         struct connect_result * result;
419         
420         param = op->param;
421         result = op->result;
422         
423         CHECK_NNTP();
424
425         r = newsnntp_ssl_connect(param->nntp,
426                                  param->server, param->port);
427         result->error = r;
428 }
429
430 int nntp_threaded_connect_ssl(Folder * folder, const char * server, int port)
431 {
432         struct connect_param param;
433         struct connect_result result;
434         chashdatum key;
435         chashdatum value;
436         newsnntp * nntp, * oldnntp;
437         unsigned char *certificate = NULL;
438         int cert_len;
439         
440         oldnntp = get_nntp(folder);
441
442         nntp = newsnntp_new(0, NULL);
443         
444         if (oldnntp) {
445                 debug_print("deleting old nntp %p\n", oldnntp);
446                 delete_nntp(folder, oldnntp);
447         }
448
449         key.data = &folder;
450         key.len = sizeof(folder);
451         value.data = nntp;
452         value.len = 0;
453         chash_set(session_hash, &key, &value, NULL);
454         
455         param.nntp = nntp;
456         param.server = server;
457         param.port = port;
458         
459         refresh_resolvers();
460         threaded_run(folder, &param, &result, connect_ssl_run);
461
462         if (result.error == NEWSNNTP_NO_ERROR && !etpan_skip_ssl_cert_check) {
463                 cert_len = (int)mailstream_ssl_get_certificate(nntp->nntp_stream, &certificate);
464                 if (etpan_certificate_check(certificate, cert_len, &param) < 0)
465                         return -1;
466                 if (certificate) 
467                         free(certificate); 
468         }
469         debug_print("connect %d with nntp %p\n", result.error, nntp);
470         
471         return result.error;
472 }
473
474 void nntp_threaded_disconnect(Folder * folder)
475 {
476         newsnntp * nntp;
477         
478         nntp = get_nntp(folder);
479         if (nntp == NULL) {
480                 debug_print("was disconnected\n");
481                 return;
482         }
483         
484         debug_print("deleting old nntp %p\n", nntp);
485         delete_nntp(folder, nntp);
486         
487         debug_print("disconnect ok\n");
488 }
489
490 void nntp_threaded_cancel(Folder * folder)
491 {
492         newsnntp * nntp;
493         
494         nntp = get_nntp(folder);
495         if (nntp->nntp_stream != NULL)
496                 mailstream_cancel(nntp->nntp_stream);
497 }
498
499
500 struct login_param {
501         newsnntp * nntp;
502         const char * login;
503         const char * password;
504 };
505
506 struct login_result {
507         int error;
508 };
509
510 static void login_run(struct etpan_thread_op * op)
511 {
512         struct login_param * param;
513         struct login_result * result;
514         int r;
515 #ifdef DISABLE_LOG_DURING_LOGIN
516         int old_debug;
517 #endif
518         
519         param = op->param;
520         result = op->result;
521
522         CHECK_NNTP();
523
524 #ifdef DISABLE_LOG_DURING_LOGIN
525         old_debug = mailstream_debug;
526         mailstream_debug = 0;
527 #endif
528
529         r = newsnntp_authinfo_username(param->nntp, param->login);
530         if (r == NEWSNNTP_NO_ERROR || 
531             r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD) {
532                 r = newsnntp_authinfo_password(param->nntp, param->password);
533         }
534         
535
536
537 #ifdef DISABLE_LOG_DURING_LOGIN
538         mailstream_debug = old_debug;
539 #endif
540         
541         result->error = r;
542         if (param->nntp->nntp_response)
543                 nntp_logger(0, param->nntp->nntp_response, strlen(param->nntp->nntp_response));
544
545         debug_print("nntp login run - end %i\n", r);
546 }
547
548 int nntp_threaded_login(Folder * folder, const char * login, const char * password)
549 {
550         struct login_param param;
551         struct login_result result;
552         
553         debug_print("nntp login - begin\n");
554         
555         param.nntp = get_nntp(folder);
556         param.login = login;
557         param.password = password;
558
559         threaded_run(folder, &param, &result, login_run);
560         
561         debug_print("nntp login - end\n");
562         
563         return result.error;
564 }
565
566 struct date_param {
567         newsnntp * nntp;
568         struct tm * lt;
569 };
570
571 struct date_result {
572         int error;
573 };
574
575 static void date_run(struct etpan_thread_op * op)
576 {
577         struct date_param * param;
578         struct date_result * result;
579         int r;
580         
581         param = op->param;
582         result = op->result;
583
584         CHECK_NNTP();
585
586         r = newsnntp_date(param->nntp, param->lt);
587         
588         result->error = r;
589         debug_print("nntp date run - end %i\n", r);
590 }
591
592 int nntp_threaded_date(Folder * folder, struct tm *lt)
593 {
594         struct date_param param;
595         struct date_result result;
596         
597         debug_print("nntp date - begin\n");
598         
599         param.nntp = get_nntp(folder);
600         param.lt = lt;
601
602         threaded_run(folder, &param, &result, date_run);
603         
604         debug_print("nntp date - end\n");
605         
606         return result.error;
607 }
608
609 struct list_param {
610         newsnntp * nntp;
611         clist **grouplist;
612 };
613
614 struct list_result {
615         int error;
616 };
617
618 static void list_run(struct etpan_thread_op * op)
619 {
620         struct list_param * param;
621         struct list_result * result;
622         int r;
623         
624         param = op->param;
625         result = op->result;
626
627         CHECK_NNTP();
628
629         r = newsnntp_list(param->nntp, param->grouplist);
630         
631         result->error = r;
632         debug_print("nntp list run - end %i\n", r);
633 }
634
635 int nntp_threaded_list(Folder * folder, clist **grouplist)
636 {
637         struct list_param param;
638         struct list_result result;
639         
640         debug_print("nntp list - begin\n");
641         
642         param.nntp = get_nntp(folder);
643         param.grouplist = grouplist;
644
645         threaded_run(folder, &param, &result, list_run);
646         
647         debug_print("nntp list - end\n");
648         
649         return result.error;
650 }
651
652 struct post_param {
653         newsnntp * nntp;
654         char *contents;
655         size_t len;
656 };
657
658 struct post_result {
659         int error;
660 };
661
662 static void post_run(struct etpan_thread_op * op)
663 {
664         struct post_param * param;
665         struct post_result * result;
666         int r;
667         
668         param = op->param;
669         result = op->result;
670
671         CHECK_NNTP();
672
673         r = newsnntp_post(param->nntp, param->contents, param->len);
674         
675         result->error = r;
676         debug_print("nntp post run - end %i\n", r);
677 }
678
679 int nntp_threaded_post(Folder * folder, char *contents, size_t len)
680 {
681         struct post_param param;
682         struct post_result result;
683         
684         debug_print("nntp post - begin\n");
685         
686         param.nntp = get_nntp(folder);
687         param.contents = contents;
688         param.len = len;
689
690         threaded_run(folder, &param, &result, post_run);
691         
692         debug_print("nntp post - end\n");
693         
694         return result.error;
695 }
696
697 struct article_param {
698         newsnntp * nntp;
699         guint32 num;
700         char **contents;
701         size_t *len;
702 };
703
704 struct article_result {
705         int error;
706 };
707
708 static void article_run(struct etpan_thread_op * op)
709 {
710         struct article_param * param;
711         struct article_result * result;
712         int r;
713         
714         param = op->param;
715         result = op->result;
716
717         CHECK_NNTP();
718
719         r = newsnntp_article(param->nntp, param->num, param->contents, param->len);
720         
721         result->error = r;
722         debug_print("nntp article run - end %i\n", r);
723 }
724
725 int nntp_threaded_article(Folder * folder, guint32 num, char **contents, size_t *len)
726 {
727         struct article_param param;
728         struct article_result result;
729         
730         debug_print("nntp article - begin\n");
731         
732         param.nntp = get_nntp(folder);
733         param.num = num;
734         param.contents = contents;
735         param.len = len;
736
737         threaded_run(folder, &param, &result, article_run);
738         
739         debug_print("nntp post - end\n");
740         
741         return result.error;
742 }
743
744 struct group_param {
745         newsnntp * nntp;
746         const char *group;
747         struct newsnntp_group_info **info;
748 };
749
750 struct group_result {
751         int error;
752 };
753
754 static void group_run(struct etpan_thread_op * op)
755 {
756         struct group_param * param;
757         struct group_result * result;
758         int r;
759         
760         param = op->param;
761         result = op->result;
762
763         CHECK_NNTP();
764
765         r = newsnntp_group(param->nntp, param->group, param->info);
766         
767         result->error = r;
768         debug_print("nntp group run - end %i\n", r);
769 }
770
771 int nntp_threaded_group(Folder * folder, const char *group, struct newsnntp_group_info **info)
772 {
773         struct group_param param;
774         struct group_result result;
775         
776         debug_print("nntp group - begin\n");
777         
778         param.nntp = get_nntp(folder);
779         param.group = group;
780         param.info = info;
781
782         threaded_run(folder, &param, &result, group_run);
783         
784         debug_print("nntp group - end\n");
785         
786         return result.error;
787 }
788
789 struct mode_reader_param {
790         newsnntp * nntp;
791 };
792
793 struct mode_reader_result {
794         int error;
795 };
796
797 static void mode_reader_run(struct etpan_thread_op * op)
798 {
799         struct mode_reader_param * param;
800         struct mode_reader_result * result;
801         int r;
802         
803         param = op->param;
804         result = op->result;
805
806         CHECK_NNTP();
807
808         r = newsnntp_mode_reader(param->nntp);
809         
810         result->error = r;
811         debug_print("nntp mode_reader run - end %i\n", r);
812 }
813
814 int nntp_threaded_mode_reader(Folder * folder)
815 {
816         struct mode_reader_param param;
817         struct mode_reader_result result;
818         
819         debug_print("nntp mode_reader - begin\n");
820         
821         param.nntp = get_nntp(folder);
822
823         threaded_run(folder, &param, &result, mode_reader_run);
824         
825         debug_print("nntp mode_reader - end\n");
826         
827         return result.error;
828 }
829
830 struct xover_param {
831         newsnntp * nntp;
832         guint32 beg;
833         guint32 end;
834         struct newsnntp_xover_resp_item **result;
835         clist **msglist;
836 };
837
838 struct xover_result {
839         int error;
840 };
841
842 static void xover_run(struct etpan_thread_op * op)
843 {
844         struct xover_param * param;
845         struct xover_result * result;
846         int r;
847         
848         param = op->param;
849         result = op->result;
850
851         CHECK_NNTP();
852         
853         if (param->result) {
854                 r = newsnntp_xover_single(param->nntp, param->beg, param->result);
855         } else {
856                 r = newsnntp_xover_range(param->nntp, param->beg, param->end, param->msglist);
857         }
858         
859         result->error = r;
860         debug_print("nntp xover run - end %i\n", r);
861 }
862
863 int nntp_threaded_xover(Folder * folder, guint32 beg, guint32 end, struct newsnntp_xover_resp_item **single_result, clist **multiple_result)
864 {
865         struct xover_param param;
866         struct xover_result result;
867         
868         debug_print("nntp xover - begin\n");
869         
870         param.nntp = get_nntp(folder);
871         param.beg = beg;
872         param.end = end;
873         param.result = single_result;
874         param.msglist = multiple_result;
875
876         threaded_run(folder, &param, &result, xover_run);
877         
878         debug_print("nntp xover - end\n");
879         
880         return result.error;
881 }
882
883 struct xhdr_param {
884         newsnntp * nntp;
885         const char *header;
886         guint32 beg;
887         guint32 end;
888         clist **hdrlist;
889 };
890
891 struct xhdr_result {
892         int error;
893 };
894
895 static void xhdr_run(struct etpan_thread_op * op)
896 {
897         struct xhdr_param * param;
898         struct xhdr_result * result;
899         int r;
900         
901         param = op->param;
902         result = op->result;
903
904         CHECK_NNTP();
905         
906         if (param->beg == param->end) {
907                 r = newsnntp_xhdr_single(param->nntp, param->header, param->beg, param->hdrlist);
908         } else {
909                 r = -1;
910                 g_warning("XHDR range not implemented\n");
911         }
912         
913         result->error = r;
914         debug_print("nntp xhdr run - end %i\n", r);
915 }
916
917 int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32 end, clist **hdrlist)
918 {
919         struct xhdr_param param;
920         struct xhdr_result result;
921         
922         debug_print("nntp xhdr - begin\n");
923         
924         param.nntp = get_nntp(folder);
925         param.header = header;
926         param.beg = beg;
927         param.end = end;
928         param.hdrlist = hdrlist;
929
930         threaded_run(folder, &param, &result, xhdr_run);
931         
932         debug_print("nntp xhdr - end\n");
933         
934         return result.error;
935 }
936
937
938 #else
939
940 void nntp_main_init(void)
941 {
942 }
943 void nntp_main_done(void)
944 {
945 }
946 void nntp_main_set_timeout(int sec)
947 {
948 }
949
950 void nntp_threaded_cancel(Folder * folder);
951 {
952 }
953
954 #endif