File: sendarticle.c

package info (click to toggle)
inn2 2.4.5-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,912 kB
  • ctags: 7,860
  • sloc: ansic: 85,104; perl: 11,427; sh: 9,863; makefile: 2,498; yacc: 1,563; python: 298; lex: 252; tcl: 7
file content (39 lines) | stat: -rw-r--r-- 790 bytes parent folder | download
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
/*  $Id: sendarticle.c 4076 2000-10-05 00:36:52Z rra $
**
*/

#include "config.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(char *p, FILE *F, bool Terminate)
{
    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;
}