Commit | Line | Data |
---|---|---|
236f657b MW |
1 | /* -*-c-*- |
2 | * | |
3 | * Null codec implementation | |
4 | * | |
5 | * (c) 2009 Straylight/Edgeware | |
6 | */ | |
7 | ||
8 | /*----- Licensing notice --------------------------------------------------* | |
9 | * | |
10 | * This file is part of the mLib utilities library. | |
11 | * | |
12 | * mLib is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU Library General Public License as | |
14 | * published by the Free Software Foundation; either version 2 of the | |
15 | * License, or (at your option) any later version. | |
16 | * | |
17 | * mLib is distributed in the hope that it will be useful, | |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | * GNU Library General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Library General Public | |
23 | * License along with mLib; if not, write to the Free | |
24 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, | |
25 | * MA 02111-1307, USA. | |
26 | */ | |
27 | ||
28 | /*----- Header files ------------------------------------------------------*/ | |
29 | ||
30 | #include <string.h> | |
31 | ||
32 | #include "codec.h" | |
33 | #include "sub.h" | |
34 | ||
35 | /*----- Data structures ---------------------------------------------------*/ | |
36 | ||
37 | typedef struct null_codec { | |
38 | codec c; | |
39 | } null_codec; | |
40 | ||
41 | /*----- Main code ---------------------------------------------------------*/ | |
42 | ||
43 | static int encdec(codec *c, const void *p, size_t sz, dstr *d) | |
44 | { DPUTM(d, p, sz); return (0); } | |
45 | ||
46 | static void destroy(codec *c) | |
47 | { null_codec *nc = (null_codec *)c; DESTROY(nc); } | |
48 | ||
49 | static const codec_ops ops = { &null_codec_class, encdec, destroy }; | |
50 | ||
51 | static codec *encoder(unsigned flags, const char *indent, unsigned maxlen) | |
52 | { | |
53 | null_codec *nc = CREATE(null_codec); | |
54 | nc->c.ops = &ops; | |
55 | return (&nc->c); | |
56 | } | |
57 | ||
58 | static codec *decoder(unsigned flags) | |
59 | { | |
60 | null_codec *nc = CREATE(null_codec); | |
61 | nc->c.ops = &ops; | |
62 | return (&nc->c); | |
63 | } | |
64 | ||
65 | const codec_class null_codec_class = { "null", encoder, decoder }; | |
66 | ||
67 | /*----- That's all, folks -------------------------------------------------*/ |