+#define MAX_LINE_FEEDFILE (NNTP_MSGID_MAXLEN + sizeof(TOKEN)*2 + 10)
+
+#define VA va_list al; va_start(al,fmt)
+#define PRINTF(f,a) __attribute__((__format__(printf,f,a)))
+#define NORET_PRINTF(f,a) __attribute__((__noreturn__,__format__(printf,f,a)))
+
+/*----- doubly linked lists -----*/
+
+#define ISNODE(T) struct { T *succ, *pred; } node /* must be at start */
+#define DEFLIST(T) typedef struct { T *hd, *tl, *tp; int count; } T##List
+
+#define NODE(n) (assert((void*)&(n)->node == &(n)), \
+ (struct node*)&(n)->node)
+
+#define LIST_CHECKCANHAVENODE(l,n) \
+ ((void)((n) == ((l).hd))) /* just for the type check */
+
+#define LIST_ADDSOMEHOW(l,n,list_addsomehow) \
+ ( LIST_CHECKCANHAVENODE(l,n), \
+ list_addsomehow((struct list*)&(l), NODE((n))), \
+ (void)(l).count++ \
+ )
+
+#define LIST_REMSOMEHOW(l,list_remsomehow) \
+ ( (typeof((l).hd)) \
+ ( (l).count \
+ ? ( (l).count--, \
+ list_remsomehow((struct list*)&(l)) ) \
+ : 0 \
+ ) \
+ )
+
+
+#define LIST_ADDHEAD(l,n) LIST_ADDSOMEHOW((l),(n),list_addhead)
+#define LIST_ADDTAIL(l,n) LIST_ADDSOMEHOW((l),(n),list_addtail)
+#define LIST_REMHEAD(l) LIST_REMSOMEHOW((l),list_remhead)
+#define LIST_REMTAIL(l) LIST_REMSOMEHOW((l),list_remtail)
+
+#define LIST_INIT(l) ((l).hd, list_new((struct list*)&(l)))
+#define LIST_HEAD(l) ((typeof((l).hd))(list_head((struct list*)&(l))))
+#define LIST_NEXT(n) ((typeof(n))list_succ(NODE((n))))
+#define LIST_BACK(n) ((typeof(n))list_pred(NODE((n))))
+
+#define LIST_REMOVE(l,n) \
+ ( LIST_CHECKCANHAVENODE(l,n), \
+ list_remove(NODE((n))), \
+ (void)(l).count-- \
+ )
+
+#define LIST_INSERT(l,n,pred) \
+ ( LIST_CHECKCANHAVENODE(l,n), \
+ LIST_CHECKCANHAVENODE(l,pred), \
+ list_insert((struct list*)&(l), NODE((n)), NODE((pred))), \
+ (void)(l).count++ \
+ )
+
+/*----- type predeclarations -----*/
+
+typedef struct Conn Conn;
+typedef struct Article Article;
+typedef struct InputFile InputFile;
+typedef struct XmitDetails XmitDetails;
+typedef struct Filemon_Perfile Filemon_Perfile;
+typedef enum StateMachineState StateMachineState;
+
+DEFLIST(Conn);
+DEFLIST(Article);
+
+/*----- function predeclarations -----*/
+
+static void conn_maybe_write(Conn *conn);
+static void conn_make_some_xmits(Conn *conn);
+static void *conn_write_some_xmits(Conn *conn);
+
+static void xmit_free(XmitDetails *d);
+
+#define SMS(newstate, periods, why) \
+ (statemc_setstate(sm_##newstate,(periods),#newstate,(why)))
+static void statemc_setstate(StateMachineState newsms, int periods,
+ const char *forlog, const char *why);
+
+static void statemc_start_flush(const char *why); /* Normal => Flushing */
+static void spawn_inndcomm_flush(const char *why); /* Moved => Flushing */
+
+static void check_assign_articles(void);
+static void queue_check_input_done(void);
+
+static void statemc_check_flushing_done(void);
+static void statemc_check_backlog_done(void);
+
+static void postfork(void);
+
+static void open_defer(void);
+static void close_defer(void);
+static void search_backlog_file(void);
+
+static void inputfile_reading_start(InputFile *ipf);
+static void inputfile_reading_stop(InputFile *ipf);
+
+static void filemon_start(InputFile *ipf);
+static void filemon_stop(InputFile *ipf);
+static void filemon_callback(InputFile *ipf);
+
+static void vconnfail(Conn *conn, const char *fmt, va_list al) PRINTF(2,0);
+static void connfail(Conn *conn, const char *fmt, ...) PRINTF(2,3);