/usr/include/gwenhywfar4/gwenhywfar/misc.h is in libgwenhywfar60-dev 4.12.0beta-3+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | /***************************************************************************
begin : Sat Jun 28 2003
copyright : (C) 2003-2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
* *
***************************************************************************/
/** @file src/base/misc.h
*
* @short This file contains some macros concerning lists and inheritance.
*
* <p>
* FIRST: Yes, I DO know, macros are very, very bad.
* When writing these macros I spent much time debugging them, because the
* compiler is not much of a help here.
* The validity of a macro is only checked upon invocation,
* so if you never use a macro it will never be checked.
* </p>
* <p>
* However, these macros do work just fine and they make some tasks
* much easier to handle.
* </p>
* <p>
* The reason for using macros is the lack of templates in C.
* When writing Gwenhywfar I often faced the fact that some functions always
* appear with many structs defined. The only difference is the name of those
* functions and the type of the arguments.
* </p>
* <p>
* The best example is the handling of lists of structs.
* In most listable structs there was a variable called @b next which pointed
* to the next object in the list. There were also functions like TYPE_next(),
* TYPE_add(), TYPE_del() etc for list handling. Whenever I improved the list
* mechanism I had to change ALL code files in order to improve them all.
* </p>
* <p>
* These macros are now used to facilitate improvements in list or inheritance
* handling code in C.
* </p>
* <p>
* @b NOTE: Please do not change these macros unless you know exactly what you
* are doing!
* Bugs in the macros will most probably lead to nearly undebuggable results
* in code files using them.<br>
* You have been warned ;-)
* </p>
*
*/
#ifndef GWENHYWFAR_MISC_H
#define GWENHYWFAR_MISC_H
#include <gwenhywfar/gwenhywfarapi.h>
#include <gwenhywfar/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GWEN_LIST_ADD(typ, sr, head) {\
typ *curr; \
\
assert(sr); \
\
curr=*head; \
if (!curr) { \
*head=sr; \
} \
else { \
while(curr->next) { \
curr=curr->next; \
} \
curr->next=sr; \
}\
}
#define GWEN_LIST_INSERT(typ, sr, head) {\
typ *curr; \
\
assert(sr); \
\
curr=*head; \
if (!curr) { \
*head=sr; \
} \
else { \
sr->next=curr;\
*head=sr;\
}\
}
#define GWEN_LIST_DEL(typ, sr, head) {\
typ *curr; \
\
assert(sr); \
curr=*head; \
if (curr) { \
if (curr==sr) { \
*head=curr->next; \
} \
else { \
while(curr->next!=sr) { \
curr=curr->next; \
} \
if (curr) \
curr->next=sr->next; \
} \
} \
sr->next=0;\
}
/*@}*/ /* defgroup */
#ifdef __cplusplus
}
#endif
#include <gwenhywfar/memory.h>
#include <gwenhywfar/list1.h>
#endif
|