utils.h
rogue25b3/src/utils.h · 2.1 KB
From the archive rogue25b3.tar.gz
Download the archive « Back to the archive contents
/***************************************************************************\
[*] ___ ____ ____ __ __ ____ [*] ROGUE: ROM With Attitude [*]
[*] /#/ ) /#/ ) /#/ ) /#/ /#/ /#/ [*] All rights reserved [*]
[*] /#/ < /#/ / /#/ _ /#/ /#/ /#/-- [*] Copyright(C) 2000-2003 [*]
[*] /#/ \(#(__/ (#(__/ (#(__/#/ (#(___ [*] Kenneth Conley (Mendanbar) [*]
[*] Expression of Digital Creativity.. [*] roguemud@yahoogroups.com [*]
[-]---------------------------------------+-+-----------------------------[-]
[*] File: utils.h [*]
[*] Usage: various internal functions of a utility nature [*]
\***************************************************************************/
#ifndef __UTILS_H__
#define __UTILS_H__
#include "types.h"
// Public Functions
int get_line(FILE *fl, char *buf);
// defines
#define plus(num) ((num) > 0 ? "+" : "")
#define plusminus(num) ((num) > 0 ? "+" : "-")
#define repstr(pstr, nstr) { free_string(pstr); pstr = str_dup(nstr); }
#if !defined(__STRING)
#define __STRING(x) #x
#endif
#define BUFFER_MEMORY 0
#if BUFFER_MEMORY
#define CREATE(result, type, number) do {\
if (!((result) = (type *) debug_calloc ((number), sizeof(type), __STRING(result), __FUNCTION__, __LINE__)))\
{ perror("malloc failure"); abort(); } } while(0)
#define RECREATE(result,type,number) do {\
if (!((result) = (type *) debug_realloc ((result), sizeof(type) * (number), __STRING(result), __FUNCTION__, __LINE__)))\
{ perror("realloc failure"); abort(); } } while(0)
#else
#define CREATE(result, type, number) do {\
if ((number * sizeof(type)) <= 0) {\
mudlogf(BRF, 102, TRUE, "CODEERR: Attempt to alloc 0 at %s:%d", __FUNCTION__, __LINE__);\
}\
if (!((result) = (type *) ALLOC ((number ? number : 1), sizeof(type))))\
{ perror("malloc failure"); abort(); } } while(0)
#define RECREATE(result,type,number) do {\
if (!((result) = (type *) realloc ((result), sizeof(type) * (number))))\
{ perror("realloc failure"); abort(); } } while(0)
#endif
#endif