File: sendarticle.c

package info (click to toggle)
inn 1%3A1.7.2q-52
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,256 kB
  • sloc: ansic: 37,984; perl: 11,945; sh: 3,968; makefile: 2,009; awk: 1,567; yacc: 686; tcl: 85; csh: 70
file content (44 lines) | stat: -rw-r--r-- 858 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*  $Revision: 1.5 $
**
*/
#include <stdio.h>
#include <sys/types.h>
#include "configdata.h"
#include "clibrary.h"
#include "libinn.h"
#include "nntp.h"


/*
**  Send a string of one or more lines down a stdio FILE using RFC977
**  conventions.  Return -1 on error.
*/
int
NNTPsendarticle(p, F, Terminate)
    register char	*p;
    register FILE	*F;
    BOOL		Terminate;
{
    register char	*next;

    for (; p && *p; next[-1] = '\n', p = next) {
	/* Get pointer to next line.  Truncate long lines. */
	if ((next = strchr(p, '\n')) != NULL)
	    *next++ = '\0';

	/* Write line. */
	if (*p == '.' && putc('.', F) == EOF)
	    return -1;
	if (fprintf(F, "%s\r\n", p) == EOF)
	    return -1;

	/* Done? */
	if (next == NULL)
	    break;
    }

    if (Terminate && fprintf(F, ".\r\n") == EOF)
	return -1;

    return fflush(F) == EOF || ferror(F) ? -1 : 0;
}