2 * ircd-ratbox: A slightly useful ircd.
3 * tools.c: Various functions needed here and there.
5 * Copyright (C) 1996-2002 Hybrid Development Team
6 * Copyright (C) 2002-2005 ircd-ratbox development team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program 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
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * Here is the original header:
25 * Useful stuff, ripped from places ..
26 * adrian chadd <adrian@creative.net.au>
28 * When you update these functions make sure you update the ones in tools.h
40 * frob some memory. debugging time.
44 mem_frob(void *data
, int len
)
46 unsigned long x
= 0xdeadbeef;
47 unsigned char *b
= (unsigned char *)&x
;
50 for (i
= 0; i
< len
; i
++)
62 extern BlockHeap
*dnode_heap
;
64 init_dlink_nodes(void)
66 dnode_heap
= BlockHeapCreate(sizeof(dlink_node
), DNODE_HEAP_SIZE
);
67 if(dnode_heap
== NULL
)
75 * output - pointer to new dlink_node
81 return(BlockHeapAlloc(dnode_heap
));
87 * inputs - pointer to dlink_node
89 * side effects - free given dlink_node
92 free_dlink_node(dlink_node
* ptr
)
96 BlockHeapFree(dnode_heap
, ptr
);
103 * outputs - an available umode bitmask or
104 * 0 if no umodes are available
105 * side effects - NONE
108 find_umode_slot(void)
110 unsigned int all_umodes
= 0, my_umode
= 0, i
;
112 for (i
= 0; i
< 128; i
++)
113 all_umodes
|= user_modes
[i
];
115 for (my_umode
= 1; my_umode
&& (all_umodes
& my_umode
);