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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>KLone: null.c Source File</title>
<link href="kl.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">src</a> / <a class="el" href="dir_000006.html">libcodec</a></div>
<h1>null.c</h1><a href="null_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
00002 <span class="comment"> * Copyright (c) 2005, 2006 by KoanLogic s.r.l. <http://www.koanlogic.com></span>
00003 <span class="comment"> * All rights reserved.</span>
00004 <span class="comment"> *</span>
00005 <span class="comment"> * This file is part of KLone, and as such it is subject to the license stated</span>
00006 <span class="comment"> * in the LICENSE file which you have received as part of this distribution.</span>
00007 <span class="comment"> *</span>
00008 <span class="comment"> * $Id: null.c,v 1.14 2006/01/11 14:19:21 tat Exp $</span>
00009 <span class="comment"> */</span>
00010
00011 <span class="preprocessor">#include "klone_conf.h"</span>
00012 <span class="preprocessor">#include <u/libu.h></span>
00013 <span class="preprocessor">#include <<a class="code" href="codec_8h.html">klone/codec.h</a>></span>
00014 <span class="preprocessor">#include <<a class="code" href="cnull_8h.html">klone/cnull.h</a>></span>
00015 <span class="preprocessor">#include <<a class="code" href="utils_8h.html">klone/utils.h</a>></span>
00016
00022 <span class="keyword">struct </span>codec_null_s
00023 {
00024 <a class="code" href="structcodec__s.html">codec_t</a> codec;
00025 };
00026
<a name="l00027"></a><a class="code" href="group__codec__t.html#ga1">00027</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>codec_null_s <a class="code" href="group__codec__t.html#ga1">codec_null_t</a>;
00028
00029 <span class="keyword">static</span> ssize_t null_flush(<a class="code" href="structcodec__s.html">codec_t</a> *cn, <span class="keywordtype">char</span> *dst, size_t *dcount)
00030 {
00031 u_unused_args(cn, dst);
00032 *dcount = 0;
00033 <span class="keywordflow">return</span> CODEC_FLUSH_COMPLETE;
00034 }
00035
00036 <span class="keyword">static</span> ssize_t null_transform(<a class="code" href="structcodec__s.html">codec_t</a> *cn, <span class="keywordtype">char</span> *dst, size_t *dcount,
00037 <span class="keyword">const</span> <span class="keywordtype">char</span> *src, size_t src_sz)
00038 {
00039 ssize_t wr;
00040
00041 dbg_err_if (src == NULL);
00042 dbg_err_if (dst == NULL);
00043 dbg_err_if (dcount == NULL || *dcount == 0);
00044 dbg_err_if (src_sz == 0);
00045
00046 u_unused_args(cn);
00047
00048 wr = <a class="code" href="utils_8h.html#a0">MIN</a>(src_sz, *dcount);
00049 memcpy(dst, src, wr);
00050 *dcount = wr;
00051
00052 dbg_err_if(wr == 0);
00053 <span class="keywordflow">return</span> wr;
00054 err:
00055 <span class="keywordflow">return</span> -1;
00056 }
00057
00058 <span class="keyword">static</span> <span class="keywordtype">int</span> null_free(<a class="code" href="structcodec__s.html">codec_t</a> *cn)
00059 {
00060 U_FREE(cn);
00061
00062 <span class="keywordflow">return</span> 0;
00063 }
00064
<a name="l00074"></a><a class="code" href="group__codec__t.html#ga11">00074</a> <span class="keywordtype">int</span> <a class="code" href="group__codec__t.html#ga11">codec_null_create</a>(<a class="code" href="structcodec__s.html">codec_t</a> **pcn)
00075 {
00076 <a class="code" href="group__codec__t.html#ga1">codec_null_t</a> *cn = NULL;
00077
00078 dbg_return_if (pcn == NULL, ~0);
00079
00080 cn = u_zalloc(<span class="keyword">sizeof</span>(<a class="code" href="group__codec__t.html#ga1">codec_null_t</a>));
00081 dbg_err_if(cn == NULL);
00082
00083 cn->codec.transform = null_transform;
00084 cn->codec.flush = null_flush;
00085 cn->codec.free = null_free;
00086
00087 *pcn = (<a class="code" href="structcodec__s.html">codec_t</a>*)cn;
00088
00089 <span class="keywordflow">return</span> 0;
00090 err:
00091 U_FREE(cn);
00092 <span class="keywordflow">return</span> ~0;
00093 }
00094
</pre></div><hr>
<div>
<div style="text-align:left">
<a href="http://www.koanlogic.com/kl/cont/gb/html/products.html">←Products</a>
</div>
<div style="text-align:center;">
© 2005-2006 - <a href="http://www.koanlogic.com">KoanLogic S.r.l.</a> - All rights reserved
</div>
</div>
</body>
</html>
|