The Netsukuku Project
0.0.9
An Alternative routing method
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
buffer.h
Go to the documentation of this file.
1
/* This file is part of Netsukuku
2
* (c) Copyright 2005 Andrea Lo Pumo aka AlpT <alpt@freaknet.org>
3
*
4
* This source code is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as published
6
* by the Free Software Foundation; either version 2 of the License,
7
* or (at your option) any later version.
8
*
9
* This source code is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* Please refer to the GNU Public License for more details.
13
*
14
* You should have received a copy of the GNU Public License along with
15
* this source code; if not, write to:
16
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
*
18
* --
19
* buffer.c: various functions to manipulate buffers
20
*/
21
22
#ifndef BUFFER_H
23
#define BUFFER_H
24
25
/*
26
* In bzero(3):
27
* <<4.3BSD. This function [bzero] is deprecated -- use memset in new
28
* programs.>>
29
*/
30
#define setzero(_p, _sz) memset((_p), 0, (_sz))
31
32
/*
33
* memput
34
*
35
* It copies `__sz' bytes from `__src' to `__dst' and then increments the `__dst'
36
* pointer of `__sz' bytes.
37
*
38
* *WARNING*
39
* Do NOT put expression in `__dst', and `__sz', f.e.
40
* *WRONG CODE*
41
* memput(buf++, src, (size+=sizeof(src));
42
*
43
* *CORRECT CODE*
44
* buf++; size+=sizeof(src);
45
* memput(buf, src, size);
46
* *WARNING*
47
*/
48
#define memput(__dst, __src, __sz) \
49
({ \
50
void *_bufret=memcpy((__dst), (__src), (__sz)); \
51
(__dst)+=(__sz); \
52
_bufret; \
53
})
54
55
/*
56
* memget
57
*
58
* the same of memput(), but it increments `__src' instead.
59
*/
60
#define memget(__dst, __src, __sz) \
61
({ \
62
void *_bufret=memcpy((__dst), (__src), (__sz)); \
63
(__src)+=(__sz); \
64
_bufret; \
65
})
66
67
/* use of hardcoded `_src' and `_dst' variable names */
68
#define bufput(_src, _sz) (memput(buf, (_src), (_sz)))
69
#define bufget(_dst, _sz) (memget((_dst), buf, (_sz)))
70
71
/*\
72
* * * * Functions declaration * * *
73
\*/
74
int
is_bufzero
(
const
void
*a,
int
sz);
75
76
#endif
/*BUFFER_H*/
is_bufzero
int is_bufzero(const void *a, int sz)
Definition:
buffer.c:28
src
buffer.h
Generated on Wed Feb 19 2014 14:19:07 for The Netsukuku Project by
1.8.6