~ubuntu-branches/ubuntu/gutsy/tcpreen/gutsy

« back to all changes in this revision

Viewing changes to src/basiclog.h

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Kurth
  • Date: 2003-03-04 23:19:35 UTC
  • Revision ID: james.westby@ubuntu.com-20030304231935-rlvnd0mv4be1n8rn
Tags: upstream-1.2.2
Import upstream version 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * basiclog.h - basic DataLog classes
 
3
 * $Id: basiclog.h,v 1.8 2003/01/26 09:09:07 rdenisc Exp $
 
4
 */
 
5
 
 
6
/***********************************************************************
 
7
 *  Copyright (C) 2002-2003 R�mi Denis-Courmont.                       *
 
8
 *  This program is free software; you can redistribute and/or modify  *
 
9
 *  it under the terms of the GNU General Public License as published  *
 
10
 *  by the Free Software Foundation; version 2 of the license.         *
 
11
 *                                                                     *
 
12
 *  This program is distributed in the hope that it will be useful,    *
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of     *
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               *
 
15
 *  See the GNU General Public License for more details.               *
 
16
 *                                                                     *
 
17
 *  You should have received a copy of the GNU General Pulic License   *
 
18
 *  along with this program; if not, you can get it from:              *
 
19
 *  http://www.gnu.org/copyleft/gpl.html                               *
 
20
 ***********************************************************************/
 
21
 
 
22
#ifndef __TCPREEN_BASICLOG_H
 
23
 
 
24
# define __TCPREEN_BASICLOG_H
 
25
# include "log.h"
 
26
 
 
27
/*
 
28
 * Base class for all basic log formats
 
29
 */
 
30
class BasicDataLog : public DataLog
 
31
{
 
32
        private:
 
33
                int (*logwrite) (const void *, int, FILE *);
 
34
                long incount, outcount;
 
35
        
 
36
        public:
 
37
                BasicDataLog (int (*logfunc) (const void *, int, FILE *)) :
 
38
                        DataLog (), logwrite (logfunc),
 
39
                        incount (0), outcount (0)
 
40
                {
 
41
                }
 
42
                virtual ~BasicDataLog (void);
 
43
 
 
44
                void Connect (const char *server, const char *client);
 
45
                int WriteServerData (const void *data, int length, int oob);
 
46
                int WriteClientData (const void *data, int length, int oob);
 
47
                void ShutdownServer (void);
 
48
                void ShutdownClient (void);
 
49
};
 
50
 
 
51
template <int (*fwrite_func) (const void *, int, FILE *)>
 
52
class TemplateBasicDataLog : public BasicDataLog
 
53
{
 
54
        public:
 
55
                TemplateBasicDataLog <fwrite_func> (void) :
 
56
                        BasicDataLog (fwrite_func)
 
57
                {
 
58
                }
 
59
};
 
60
                
 
61
 
 
62
# include "output.h"
 
63
 
 
64
typedef TemplateBasicDataLog<fwrite_count> CountDataLog;
 
65
typedef TemplateBasicDataLog<fwrite_C> CDataLog;
 
66
typedef TemplateBasicDataLog<fwrite_hex> HexDataLog;
 
67
typedef TemplateBasicDataLog<fwrite_raw> RawDataLog;
 
68
typedef TemplateBasicDataLog<fwrite_strip> StrippedDataLog;
 
69
 
 
70
/*
 
71
 * Makers for the above classes
 
72
 */
 
73
extern DataLog *CountDataLogMaker (void);
 
74
extern DataLog *CDataLogMaker (void);
 
75
extern DataLog *HexDataLogMaker (void);
 
76
extern DataLog *RawDataLogMaker (void);
 
77
extern DataLog *StrippedDataLogMaker (void);
 
78
 
 
79
#endif /* ifndef __TCPREEN_BASICLOG_H */
 
80