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