File: bwrite.c

package info (click to toggle)
ifmail 2.14tx8.10-32
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: ansic: 30,328; perl: 4,955; yacc: 839; makefile: 716; sh: 424; cpp: 235; lex: 206; awk: 24
file content (74 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download | duplicates (15)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* ### Modified by P.Saratxaga on 29 Oct 1995 ###
 * - deleted transcodage (outtab & intab) code (now transcodage is done by
 *   strconv() function.
 */
#include <stdio.h>
#include <string.h>
#include "bwrite.h"
#include "config.h"

/* write short (16bit) integer in "standart" byte order */
int iwrite(i,fp)
int i;
FILE *fp;
{
	putc(i & 0xff,fp);
	putc((i >> 8) & 0xff,fp);
	return 0;
}

/* write long (32bit) integer in "standart" byte order */
int lwrite(i,fp)
long i;
FILE *fp;
{
	int c;

	for (c=0;c<32;c+=8) putc((i >> c) & 0xff,fp);
	return 0;
}

int awrite(s,fp)
char *s;
FILE *fp;
{
	if (s) while (*s) putc(*(s++), fp);
	putc(0,fp);
	return 0;
}

/* write an arbitrary line to message body: change \n to \r,
   if a line starts with three dashes, insert a dash and a blank */
int cwrite(s,fp)
char *s;
FILE *fp;
{
#ifdef PGP_LIKE_DASHES
	if ((strlen(s) >= 3) && (strncmp(s,"---",3) == 0) && (s[3] != '-')) {
		putc('-',fp);
		putc(' ',fp);
	}
#endif
	while (*s) 
	{
		if (*s == '\n') putc('\r',fp);
		else putc(*s, fp);
		s++;
	}
	return 0;
}

/* write (multiline) header to kluge: change \n to ' ' and end line with \r */
int kwrite(s,fp)
char *s;
FILE *fp;
{
	while (*s) 
	{
		if (*s != '\n') putc(*s, fp);
		else if (*(s+1)) putc(' ',fp);
		s++;
	}
	putc('\r',fp);
	return 0;
}