initial message templates support
[claws.git] / libkcc / buffer.c
blobcb846ed272561a9b1b9f70484fe83fa91b941612
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/types.h>
5 #include "kcc.h"
6 #include "libkcc.h"
8 /**********************************************************************
9 * *
10 * Hold Buffer Operations *
11 * *
12 **********************************************************************/
13 char *holdbuf, *bufend;
14 char *bufp;
16 /*---------------------------------------------------------------------
17 NAME
18 buffalloc
19 ---------------------------------------------------------------------*/
20 char *Kcc_buffalloc(len)
21 unsigned len;
23 if ((bufp = holdbuf = (char *) malloc(len)) == NULL)
24 return NULL;
25 bufend = holdbuf + len;
26 return bufend;
29 /*---------------------------------------------------------------------
30 NAME
31 append
32 ---------------------------------------------------------------------*/
33 bool Kcc_append(s, len)
34 register char *s;
35 register int len;
37 if (bufp + len > bufend)
38 return (0);
39 for (; len; --len)
40 *bufp++ = *(u_char *) s++;
41 return (1);
44 /*---------------------------------------------------------------------
45 NAME
46 flush
47 ---------------------------------------------------------------------*/
48 void Kcc_flush(code, ddd, outcode, inmode, insi, inso, innj, ingj)
49 unsigned code;
50 char **ddd;
51 enum mode *inmode;
52 unsigned long *insi, *inso, *innj, *ingj;
53 unsigned outcode;
55 unsigned out();
57 Kcc_out(ddd, holdbuf, bufp - holdbuf, code, outcode, inmode, insi, inso, innj, ingj);
58 bufp = holdbuf;
61 /*---------------------------------------------------------------------
62 NAME
63 bufffree
64 ---------------------------------------------------------------------*/
65 void Kcc_bufffree(void)
67 if (holdbuf) {
68 free(holdbuf);
69 holdbuf = NULL;