1 /*
2  This file is part of SLRN.
3 
4  Copyright (c) 1994, 1999 John E. Davis <davis@space.mit.edu>
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by the Free
8  Software Foundation; either version 2 of the License, or (at your option)
9  any later version.
10 
11  This program is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc., 675
18  Mass Ave, Cambridge, MA 02139, USA.
19 */
20 #ifndef _SLRN_NNTPLIB_H
21 #define _SLRN_NNTPLIB_H
22 typedef struct
23 {
24 #define NNTP_RECONNECT_OK	0x1
25    unsigned int flags;
26    int init_state;
27    int can_post;
28 #define NNTP_MAX_GROUP_NAME_LEN 80
29 #define NNTP_MAX_CMD_LEN 512
30    char group_name [NNTP_MAX_GROUP_NAME_LEN + 1];
31 #define NNTP_MAX_HOST_LEN	80
32    char host [NNTP_MAX_HOST_LEN + 1];
33    int port;
34    int code;
35 #define NNTP_RSPBUF_SIZE	512
36    char rspbuf[NNTP_RSPBUF_SIZE];
37 
38    /* Capabilities-- if -1, probe server needs to be done */
39    int can_xover;
40    int can_xhdr;
41    int can_xpat;
42    int can_xgtitle;
43 
44    int (*auth_hook)(char *, char **, char **);
45 
46    SLTCP_Type *tcp;
47 }
48 NNTP_Type;
49 
50 extern void nntp_disconnect_server (NNTP_Type *);
51 extern int nntp_check_connection (NNTP_Type *);
52 extern int nntp_reconnect_server (NNTP_Type *);
53 
54 extern int nntp_server_cmd (NNTP_Type *, char *);
55 extern int nntp_server_vcmd (NNTP_Type *, char *, ...);
56 extern int nntp_write_server (NNTP_Type *, char *, unsigned int);
57 extern int nntp_fgets_server (NNTP_Type *, char *, unsigned int);
58 extern int nntp_fputs_server (NNTP_Type *, char *);
59 extern int nntp_gets_server (NNTP_Type *, char *, unsigned int);
60 extern int nntp_puts_server (NNTP_Type *, char *);
61 extern int nntp_get_server_response (NNTP_Type *);
62 extern int nntp_start_server_cmd (NNTP_Type *, char *);
63 extern int nntp_start_server_vcmd (NNTP_Type *, char *, ...);
64 extern int nntp_server_cmd (NNTP_Type *, char *);
65 extern int nntp_server_vcmd (NNTP_Type *, char *, ...);
66 
67 extern char *nntp_get_server_name (void);
68 
69 extern int nntp_close_server (NNTP_Type *);
70 extern NNTP_Type *nntp_open_server (char *, int);
71 
72 extern int nntp_read_line (NNTP_Type *s, char *, unsigned int);
73 extern int nntp_discard_output (NNTP_Type *s);
74 
75 
76 extern int nntp_has_cmd (NNTP_Type *, char *);
77 extern int nntp_list_newsgroups (NNTP_Type *);
78 extern int nntp_list_active (NNTP_Type *);
79 extern int nntp_end_post (NNTP_Type *);
80 extern int nntp_post_cmd (NNTP_Type *);
81 extern int nntp_list_active_cmd (NNTP_Type *);
82 
83 extern int nntp_select_group (NNTP_Type *, char *, int *, int *);
84 extern int nntp_xpat_cmd (NNTP_Type *, char *, int, int, char *);
85 extern int nntp_xgtitle_cmd (NNTP_Type *, char *);
86 extern int nntp_xhdr_cmd (NNTP_Type *, char *, int, char *, unsigned int);
87 
88 extern int nntp_listgroup (NNTP_Type *, char *);
89 extern int nntp_head_cmd (NNTP_Type *, int, char *, int *);
90 
91 extern int nntp_xover_cmd (NNTP_Type *, int, int);
92 extern int nntp_next_cmd (NNTP_Type *s, int *);
93 extern int nntp_body_cmd (NNTP_Type *s, int, char *);
94 extern int nntp_article_cmd (NNTP_Type *s, int, char *);
95 
96 extern char *nntp_read_and_malloc (NNTP_Type *);
97 
98 extern void (*NNTP_Connection_Lost_Hook) (NNTP_Type *);
99 extern int (*NNTP_Authorization_Hook) (char *, char **, char **);
100 extern FILE *NNTP_Debug_Fp;
101 extern char *nntp_map_code_to_string (int);
102 
103 #endif				       /* _SLRN_NNTPLIB_H */
104