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
|
<!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: common.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_000007.html">libklog</a></div>
<h1>common.c</h1><a href="common_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: common.c,v 1.6 2006/01/09 12:38:38 tat Exp $</span>
00009 <span class="comment"> */</span>
00010
00011 <span class="preprocessor">#include "klone_conf.h"</span>
00012 <span class="preprocessor">#include <time.h></span>
00013 <span class="preprocessor">#include <u/libu.h></span>
00014 <span class="preprocessor">#include <<a class="code" href="klog_8h.html">klone/klog.h</a>></span>
00015 <span class="preprocessor">#include <<a class="code" href="klogprv_8h.html">klone/klogprv.h</a>></span>
00016
00017 <span class="comment">/* each klog_*_open() will push its private data afterwards */</span>
<a name="l00018"></a><a class="code" href="klogprv_8h.html#a1">00018</a> <span class="keywordtype">int</span> <a class="code" href="klogprv_8h.html#a1">klog_new</a> (<span class="keywordtype">int</span> type, <span class="keywordtype">int</span> threshold, <span class="keyword">const</span> <span class="keywordtype">char</span> *ident, <a class="code" href="structklog__s.html">klog_t</a> **pkl)
00019 {
00020 <a class="code" href="structklog__s.html">klog_t</a> *kl;
00021
00022 dbg_return_if (pkl == NULL, ~0);
00023
00024 kl = u_zalloc(<span class="keyword">sizeof</span>(<a class="code" href="structklog__s.html">klog_t</a>));
00025 dbg_err_if (kl == NULL);
00026
00027 kl-><a class="code" href="structklog__s.html#o1">threshold</a> = threshold;
00028 u_sstrncpy(kl-><a class="code" href="structklog__s.html#o2">ident</a>, ident ? ident : <span class="stringliteral">""</span>, <a class="code" href="klog_8h.html#a2">KLOG_ID_SZ</a>);
00029
00030 <span class="comment">/* check the supplied type */</span>
00031 <span class="keywordflow">switch</span> (type)
00032 {
00033 <span class="keywordflow">case</span> KLOG_TYPE_MEM:
00034 <span class="keywordflow">case</span> KLOG_TYPE_FILE:
00035 <span class="keywordflow">case</span> KLOG_TYPE_SYSLOG:
00036 kl-><a class="code" href="structklog__s.html#o0">type</a> = type;
00037 <span class="keywordflow">break</span>;
00038 <span class="keywordflow">default</span>:
00039 warn_err(<span class="stringliteral">"bad klog_t type !"</span>);
00040 }
00041
00042 <span class="comment">/* push out the klog_t object */</span>
00043 *pkl = kl;
00044
00045 <span class="keywordflow">return</span> 0;
00046 err:
00047 U_FREE(kl);
00048 <span class="keywordflow">return</span> ~0;
00049 }
00050
<a name="l00051"></a><a class="code" href="klogprv_8h.html#a5">00051</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="klogprv_8h.html#a5">klog_to_str</a> (<span class="keywordtype">int</span> lev)
00052 {
00053 <span class="keywordflow">return</span> (lev < KLOG_DEBUG || lev > KLOG_EMERG) ? <span class="stringliteral">"?"</span> : kloglev[lev];
00054 }
00055
</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>
|