1
2 #include "outputFileHandle.h"
3
4 /**************************************************************************
5 **SA Network Connection Profiler [sancp] - A TCP/IP statistical/collection tool
6 * ************************************************************************
7 * * Copyright (C) 2003 John Curry <john.curry@metre.net>
8 * *
9 * * This program is distributed under the terms of version 1.0 of the
10 * * Q Public License. See LICENSE.QPL for further details.
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 * *
16 * ***********************************************************************/
17
outputFileHandle()18 outputFileHandle::outputFileHandle() : fmt(0),fmtlen(0),delimiter(0)
19 {
20
21 }
22
outputFileHandle(FILE * OFH,int mode=APPEND_MODE,char * ifmt=0,int len=0)23 outputFileHandle::outputFileHandle(FILE *OFH, int mode = APPEND_MODE,char *ifmt=0, int len=0) :fmt(0),fmtlen(0),delimiter('|'),eor('\n')
24 {
25 ::fileHandle(OFH,mode);
26 setFormat(ifmt,len);
27 }
28
outputFileHandle(const char * newfilename,char * ifmt=0,int len=0,int mode=APPEND_MODE)29 outputFileHandle::outputFileHandle(const char *newfilename,char *ifmt=0, int len=0, int mode=APPEND_MODE ) : fmt(0),fmtlen(0),delimiter('|'),eor('\n')
30 {
31 setMode(mode);
32 setFormat(ifmt,len);
33 setFileName(newfilename);
34 }
35
getFormat()36 char * outputFileHandle::getFormat()
37 {
38 return fmt;
39 }
40
setFormat(char * ifmt,int len)41 char * outputFileHandle::setFormat(char *ifmt, int len)
42 {
43 if(fmt) { free(fmt); fmt=0; }
44 fmtlen=len;
45 if((fmt=(char *) calloc(len,1))!=0)
46 memcpy(fmt,ifmt,len);
47 return fmt;
48 }
49
getFormatLen()50 int outputFileHandle::getFormatLen()
51 {
52 return fmtlen;
53 }
54
getEor()55 char outputFileHandle::getEor()
56 {
57 return eor;
58 }
59
setEor(char c)60 void outputFileHandle::setEor(char c)
61 {
62 eor=c;
63 }
64
getDelimiter()65 char outputFileHandle::getDelimiter()
66 {
67 return delimiter;
68 }
69
setDelimiter(char c)70 void outputFileHandle::setDelimiter(char c)
71 {
72 delimiter=c;
73 }
74
attach()75 outputFileHandle * outputFileHandle::attach()
76 {
77 fileHandle::attach();
78 return this;
79 }
80
~outputFileHandle()81 outputFileHandle::~outputFileHandle()
82 {
83 if(fmt) { free(fmt); fmt=0; }
84 }
85