gwenhywfar 5.11.1beta
misc.h
Go to the documentation of this file.
1/***************************************************************************
2 begin : Sat Jun 28 2003
3 copyright : (C) 2003-2010 by Martin Preuss
4 email : martin@libchipcard.de
5
6 ***************************************************************************
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 * *
23 ***************************************************************************/
24
67#ifndef GWENHYWFAR_MISC_H
68#define GWENHYWFAR_MISC_H
69
71#include <gwenhywfar/types.h>
72#include <stdio.h>
73#include <stdlib.h>
74#include <string.h>
75#include <assert.h>
76
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
82#define GWEN_LIST_ADD(typ, sr, head) {\
83 typ *curr; \
84 \
85 assert(sr); \
86 \
87 curr=*head; \
88 if (!curr) { \
89 *head=sr; \
90 } \
91 else { \
92 while(curr->next) { \
93 curr=curr->next; \
94 } \
95 curr->next=sr; \
96 }\
97 }
98
99
100#define GWEN_LIST_INSERT(typ, sr, head) {\
101 typ *curr; \
102 \
103 assert(sr); \
104 \
105 curr=*head; \
106 if (!curr) { \
107 *head=sr; \
108 } \
109 else { \
110 sr->next=curr;\
111 *head=sr;\
112 }\
113 }
114
115
116#define GWEN_LIST_DEL(typ, sr, head) {\
117 typ *curr; \
118 \
119 assert(sr); \
120 curr=*head; \
121 if (curr) { \
122 if (curr==sr) { \
123 *head=curr->next; \
124 } \
125 else { \
126 while(curr->next!=sr) { \
127 curr=curr->next; \
128 } \
129 if (curr) \
130 curr->next=sr->next; \
131 } \
132 } \
133 sr->next=0;\
134 }
135
136
137 /* defgroup */
139
140#ifdef __cplusplus
141}
142#endif
143
144
145#include <gwenhywfar/memory.h>
146#include <gwenhywfar/list1.h>
147
148
149
150
151#endif
152
153
154