1 /*
2  * article creation and destruction
3  */
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <errno.h>
7 #include "fixerrno.h"
8 
9 #include <sys/types.h>
10 #include "libc.h"
11 #include "news.h"
12 #include "headers.h"
13 #include "relay.h"
14 #include "rerror.h"
15 #include "io.h"
16 
17 void
artinit(art)18 artinit(art)
19 register struct article *art;
20 {
21 	static long uniqno = 0;
22 	static struct article zart;
23 
24 	*art = zart;
25 	hdrinit(&art->h);
26 	art->a_status = ST_OKAY;
27 	art->a_id = uniqno++;
28 }
29 
30 void
artfree(art)31 artfree(art)
32 register struct article *art;
33 {
34 	freeheaders(&art->h);
35 	/* a_haccum is currently not malloced */
36 	art->a_hptrs = NULL;		/* don't free a_hptrs; see hdrsave() */
37 	nnfree(&art->a_files);
38 	if (art->a_artf != NULL) {
39 		errno = 0;
40 		canthappen(art, 'i', "a_artf still open in artfree()", "");
41 	}
42 	nnfclose(art, &art->a_artf, art->a_tmpf);
43 	nnfree(&art->a_tmpf);
44 }
45