ezmlmx 0.68
ezmlmx
Loading...
Searching...
No Matches
concat_hdr.c
Go to the documentation of this file.
1#include "stralloc.h"
2#include "case.h"
3#include "byte.h"
4#include "mime.h"
5#include "errtxt.h"
6#include "idx.h"
7#include "logmsg.h"
8#include "errtxt.h"
9
10#define WHO "concat_hdr"
11
22
23static void die_nomem() { logmsg(WHO,111,FATAL,ERR_NOMEM); }
24
25void concat_hdr(char *indata,unsigned int n,stralloc *outdata)
26{
27 char *cp;
28 char *cpout;
29 char *cplast;
30
31 if (!stralloc_copys(outdata,"")) die_nomem();
32 if (!stralloc_ready(outdata,n)) die_nomem();
33
34 cpout = outdata->s;
35 if (n == 0) return;
36
37 cplast = indata + n - 1;
38 cp = cplast;
39
40 while (*cplast == '\0' || *cplast == '\n')
41 --cplast;
42 if (cp == cplast) die_nomem(); /* just in case */
43 *(++cplast) = '\n'; /* have terminal '\n' */
44 cp = indata;
45
46 while (cp <= cplast) {
47 while (*cp == ' ' || *cp == '\t') ++cp; /* LWSP before */
48 while (*cp != '\n') *(cpout++) = *(cp++); /* text */
49 ++cp; /* skip \n */
50 --cpout; /* last char */
51 while (*cpout == ' ' || *cpout == '\t')
52 --cpout; /* LWSP after */
53 *(++cpout) = ' '; /* replace with single ' ' */
54 ++cpout; /* point to free byte */
55 }
56 outdata->len = cpout - outdata->s;
57}
Error messages. If you translate these, I would urge you to keep the English version as well....
#define ERR_NOMEM
Definition errtxt.h:14
void die_nomem()
Definition getconf.c:17
#define WHO
Definition author.c:1
#define outdata
Definition makehash.c:46
void concat_hdr(char *indata, unsigned int n, stralloc *outdata)
Definition concat_hdr.c:25
const char * cp
Definition ezmlm-cron.c:76
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)
Definition loginfo.c:32