~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/line.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2007-2008 Sourcefire, Inc.
3
 
 *
4
 
 *  Authors: Nigel Horne
 
2
 *  Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk>
5
3
 *
6
4
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License version 2 as
8
 
 *  published by the Free Software Foundation.
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
9
8
 *
10
9
 *  This program is distributed in the hope that it will be useful,
11
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
59
58
#include "clamav-config.h"
60
59
#endif
61
60
 
 
61
#ifndef CL_DEBUG
 
62
#define NDEBUG  /* map CLAMAV debug onto standard */
 
63
#endif
 
64
 
62
65
#include <stdio.h>
63
66
#include <string.h>
64
67
#include <assert.h>
66
69
#include "line.h"
67
70
#include "others.h"
68
71
 
 
72
#ifdef  OLD
 
73
line_t *
 
74
lineCreate(const char *data)
 
75
{
 
76
        line_t *ret = (line_t *)cli_malloc(sizeof(struct line));
 
77
 
 
78
        if(ret == NULL)
 
79
                return NULL;
 
80
 
 
81
        ret->l_str = strdup(data);
 
82
        if(ret->l_str == NULL) {
 
83
                free(ret);
 
84
                return NULL;
 
85
        }
 
86
        ret->l_refs = 1;
 
87
 
 
88
        return ret;
 
89
}
 
90
 
 
91
line_t *
 
92
lineLink(line_t *line)
 
93
{
 
94
        line->l_refs++;
 
95
        return line;
 
96
}
 
97
 
 
98
line_t *
 
99
lineUnlink(line_t *line)
 
100
{
 
101
        /*printf("%d:\n\t'%s'\n", line->l_refs, line->l_str);*/
 
102
 
 
103
        if(--line->l_refs == 0) {
 
104
                free(line->l_str);
 
105
                free(line);
 
106
                return NULL;
 
107
        }
 
108
        return line;
 
109
}
 
110
 
 
111
const char *
 
112
lineGetData(const line_t *line)
 
113
{
 
114
        return line ? line->l_str : NULL;
 
115
}
 
116
 
 
117
#else
 
118
 
69
119
line_t *
70
120
lineCreate(const char *data)
71
121
{
113
163
{
114
164
        return line ? &line[1] : NULL;
115
165
}
 
166
 
 
167
unsigned char
 
168
lineGetRefCount(const line_t *line)
 
169
{
 
170
        return (unsigned char)line[0];
 
171
}
 
172
#endif