This is patch06 to PennMUSH 1.8.2. After applying this patch, you will have version 1.8.2p6 To apply this patch, save it to a file in your top-level 1.8.2p5 MUSH directory, and do the following: patch -p0 < 1.8.2-patch06 make update make install If you use GNU patch 2.2, you probably want the above to be 'patch -b -p0', not just 'patch -p0'. Unix (or cygwin) users need not worry about failed hunks in src/switchinc.c, hdrs/switches.h, hdrs/cmds.h, or hdrs/funs.h. These files are automatically rebuilt on compile. On the off chance they appear not to be, simply rm them and re-run make. Then @shutdown and restart your MUSH. - Shawn/Raevnos In this patch: Development team changes: * After many years of valuable work, Talek has retired from development. Minor changes: * Removed the gmalloc malloc option. (For real this time!) [SW] * KEEPALIVE flag makes the server send a telnet NOP after a short period of inactivity; helps prevent timeouts from NAT/router devices with a short timeout. [MUX] Fixes: * Fixed assorted small memory leaks. [SW] * Fixed handling of telnet NOPs sent by clients. [SW] * The OpenSSL random number pool wasn't getting adequately initialized on systems without /dev/urandom [SW] * Infinite loop in math code. Reported by Ashen-Sugar. [GM] * mkvershlp.pl skips over emacs backup files. Prereq: 1.8.2p5 =================================================================== --- Patchlevel (.../p5) (revision 1028) +++ Patchlevel (.../p6) (revision 1028) @@ -1,2 +1,2 @@ Do not edit this file. It is maintained by the official PennMUSH patches. -This is PennMUSH 1.8.2p5 +This is PennMUSH 1.8.2p6 Index: options.h.dist =================================================================== --- options.h.dist (.../p5) (revision 1028) +++ options.h.dist (.../p6) (revision 1028) @@ -34,18 +34,14 @@ * 0 -- Use my system's malloc. Required for Win32 systems. * Recommended for FreeBSD, Linux, Mac OS X/Darwin, and other OS's * where you think the malloc routines are efficient and debugged. - * Otherwise, use only as a last resort. - * 1 -- Use the CSRI malloc package in normal mode. - * Recommended for most operating systems where system malloc is - * suspect. Known to work well on SunOS 4.1.x. + * In other words, pretty much any fairly current OS releases. + * 1 -- Use the CSRI malloc package in normal mode. + * Recomended for ancient OS releases. On anything modern, you'll want + * the system malloc (Option 0). * 2 -- Use the CSRI malloc package in debug mode. * Only use this if you're tracking down memory leaks. Don't use * for a production MUSH - it's slow. - * 5 -- Use the GNU malloc (gmalloc) package. - * Doesn't work on Alpha processors or FreeBSD systems, and - * reportedly flaky on Linux. Requires an ANSI compiler. - * Otherwise, similar to CSRI malloc. - * 3, 4, 6 -- Same as 0, kept for compatibility. + * 3, 4, 5, 6 -- Same as 0, kept for compatibility. */ #define MALLOC_PACKAGE 0 Index: src/gmalloc.c =================================================================== --- src/gmalloc.c (.../p5) (revision 1028) +++ src/gmalloc.c (.../p6) (revision 1028) @@ -1,1295 +0,0 @@ -/* DO NOT EDIT THIS FILE -- it is automagically generated. -*- C -*- */ - -#define _MALLOC_INTERNAL - -/* The malloc headers and source files from the C library follow here. */ - -/* Declarations for `malloc' and friends. - Copyright 1990, 1991, 1992, 1993, 1995 Free Software Foundation, Inc. - Written May 1989 by Mike Haertel. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 675 Mass Ave, - Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef _MALLOC_H - -#define _MALLOC_H 1 - -#ifdef _MALLOC_INTERNAL - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#ifndef memset -#define memset(s, zero, n) bzero ((s), (n)) -#endif -#ifndef memcpy -#define memcpy(d, s, n) bcopy ((s), (d), (n)) -#endif - - -#if defined (__GNU_LIBRARY__) || (defined (__STDC__) && __STDC__) -#include -#else -#ifndef CHAR_BIT -#define CHAR_BIT 8 -#endif -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#endif /* _MALLOC_INTERNAL. */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) -#undef __P -#define __P(args) args -#undef __ptr_t -#define __ptr_t void * -#else /* Not C++ or ANSI C. */ -#undef __P -#define __P(args) () -#undef const -#define const -#undef __ptr_t -#define __ptr_t char * -#endif /* C++ or ANSI C. */ - -#if defined (__STDC__) && __STDC__ -#include -#define __malloc_size_t size_t -#define __malloc_ptrdiff_t ptrdiff_t -#else -#define __malloc_size_t unsigned int -#define __malloc_ptrdiff_t int -#endif - -#ifndef NULL -#define NULL 0 -#endif - - -/* Allocate SIZE bytes of memory. */ - extern __ptr_t malloc __P((__malloc_size_t __size)); -/* Re-allocate the previously allocated block - in __ptr_t, making the new block SIZE bytes long. */ - extern __ptr_t realloc __P((__ptr_t __ptr, __malloc_size_t __size)); -/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ - extern __ptr_t calloc __P((__malloc_size_t __nmemb, __malloc_size_t __size)); -/* Free a block allocated by `malloc', `realloc' or `calloc'. */ - extern void free __P((__ptr_t __ptr)); - -/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ - extern __ptr_t memalign __P((__malloc_size_t __alignment, - __malloc_size_t __size)); - -/* Allocate SIZE bytes on a page boundary. */ - extern __ptr_t valloc __P((__malloc_size_t __size)); - - -#ifdef _MALLOC_INTERNAL - -/* The allocator divides the heap into blocks of fixed size; large - requests receive one or more whole blocks, and small requests - receive a fragment of a block. Fragment sizes are powers of two, - and all fragments of a block are the same size. When all the - fragments in a block have been freed, the block itself is freed. */ -#define INT_BIT (CHAR_BIT * sizeof(int)) -#define BLOCKLOG (INT_BIT > 16 ? 12 : 9) -#define BLOCKSIZE (1 << BLOCKLOG) -#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) - -/* Determine the amount of memory spanned by the initial heap table - (not an absolute limit). */ -#define HEAP (INT_BIT > 16 ? 4194304 : 65536) - -/* Number of contiguous free blocks allowed to build up at the end of - memory before they will be returned to the system. */ -#define FINAL_FREE_BLOCKS 8 - -/* Data structure giving per-block information. */ - typedef union { - /* Heap information for a busy block. */ - struct { - /* Zero for a large (multiblock) object, or positive giving the - logarithm to the base two of the fragment size. */ - int type; - union { - struct { - __malloc_size_t nfree; /* Free frags in a fragmented block. */ - __malloc_size_t first; /* First free fragment of the block. */ - } frag; - /* For a large object, in its first block, this has the number - of blocks in the object. In the other blocks, this has a - negative number which says how far back the first block is. */ - __malloc_ptrdiff_t size; - } info; - } busy; - /* Heap information for a free block - (that may be the first of a free cluster). */ - struct { - __malloc_size_t size; /* Size (in blocks) of a free cluster. */ - __malloc_size_t next; /* Index of next free cluster. */ - __malloc_size_t prev; /* Index of previous free cluster. */ - } free; - } malloc_info; - -/* Pointer to first block of the heap. */ - extern char *_heapbase; - -/* Table indexed by block number giving per-block information. */ - extern malloc_info *_heapinfo; - -/* Address to block number and vice versa. */ -#define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) -#define ADDRESS(B) ((__ptr_t) (((B) - 1) * BLOCKSIZE + _heapbase)) - -/* Current search index for the heap table. */ - extern __malloc_size_t _heapindex; - -/* Limit of valid info table indices. */ - extern __malloc_size_t _heaplimit; - -/* Doubly linked lists of free fragments. */ - struct list { - struct list *next; - struct list *prev; - }; - -/* Free list headers for each fragment size. */ - extern struct list _fraghead[]; - -/* List of blocks allocated with `memalign' (or `valloc'). */ - struct alignlist { - struct alignlist *next; - __ptr_t aligned; /* The address that memaligned returned. */ - __ptr_t exact; /* The address that malloc returned. */ - }; - extern struct alignlist *_aligned_blocks; - -/* Instrumentation. */ - extern __malloc_size_t _chunks_used; - extern __malloc_size_t _bytes_used; - extern __malloc_size_t _chunks_free; - extern __malloc_size_t _bytes_free; - -/* Internal version of `free' used in `morecore' (malloc.c). */ - extern void _free_internal __P((__ptr_t __ptr)); - -#endif /* _MALLOC_INTERNAL. */ - -/* Given an address in the middle of a malloc'd object, - return the address of the beginning of the object. */ - extern __ptr_t malloc_find_object_address __P((__ptr_t __ptr)); - -/* Underlying allocation function; successive calls should - return contiguous pieces of memory. */ - extern __ptr_t (*__morecore) __P((__malloc_ptrdiff_t __size)); - -/* Default value of `__morecore'. */ - extern __ptr_t __default_morecore __P((__malloc_ptrdiff_t __size)); - -/* If not NULL, this function is called after each time - `__morecore' is called to increase the data size. */ - extern void (*__after_morecore_hook) __P((void)); - -/* Nonzero if `malloc' has been called and done its initialization. */ - extern int __malloc_initialized; - -/* Hooks for debugging versions. */ - extern void (*__malloc_initialize_hook) __P((void)); - extern void (*__free_hook) __P((__ptr_t __ptr)); - extern __ptr_t (*__malloc_hook) __P((__malloc_size_t __size)); - extern __ptr_t (*__realloc_hook) - __P((__ptr_t __ptr, __malloc_size_t __size)); - extern __ptr_t (*__memalign_hook) - __P((__malloc_size_t __size, __malloc_size_t __alignment)); - -/* Return values for `mprobe': these are the kinds of inconsistencies that - `mcheck' enables detection of. */ - enum mcheck_status { - MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */ - MCHECK_OK, /* Block is fine. */ - MCHECK_FREE, /* Block freed twice. */ - MCHECK_HEAD, /* Memory before the block was clobbered. */ - MCHECK_TAIL /* Memory after the block was clobbered. */ - }; - -/* Activate a standard collection of debugging hooks. This must be called - before `malloc' is ever called. ABORTFUNC is called with an error code - (see enum above) when an inconsistency is detected. If ABORTFUNC is - null, the standard function prints on stderr and then calls `abort'. */ - extern int mcheck __P((void (*__abortfunc) __P((enum mcheck_status)))); - -/* Check for aberrations in a particular malloc'd block. You must have - called `mcheck' already. These are the same checks that `mcheck' does - when you free or reallocate a block. */ - extern enum mcheck_status mprobe __P((__ptr_t __ptr)); - -/* Activate a standard collection of tracing hooks. */ - extern void mtrace __P((void)); - extern void muntrace __P((void)); - -/* Statistics available to the user. */ - struct mstats { - __malloc_size_t bytes_total; /* Total size of the heap. */ - __malloc_size_t chunks_used; /* Chunks allocated by the user. */ - __malloc_size_t bytes_used; /* Byte total of user-allocated chunks. */ - __malloc_size_t chunks_free; /* Chunks in the free list. */ - __malloc_size_t bytes_free; /* Byte total of chunks in the free list. */ - }; - -/* Pick up the current statistics. */ - extern struct mstats mstats __P((void)); - -/* Call WARNFUN with a warning message when memory usage is high. */ - extern void memory_warnings __P((__ptr_t __start, - void (*__warnfun) __P((const char *)))); - - -/* Relocating allocator. */ - -/* Allocate SIZE bytes, and store the address in *HANDLEPTR. */ - extern __ptr_t r_alloc __P((__ptr_t *__handleptr, __malloc_size_t __size)); - -/* Free the storage allocated in HANDLEPTR. */ - extern void r_alloc_free __P((__ptr_t *__handleptr)); - -/* Adjust the block at HANDLEPTR to be SIZE bytes long. */ - extern __ptr_t r_re_alloc __P((__ptr_t *__handleptr, __malloc_size_t __size)); - - -#ifdef __cplusplus -} -#endif -#endif /* malloc.h */ /* Allocate memory on a page boundary. - Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 675 Mass Ave, - Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ -#if defined (__GNU_LIBRARY__) || defined (_LIBC) -#include -#include -extern size_t __getpagesize __P((void)); -#else -#include "getpgsiz.h" -#define __getpagesize() getpagesize() -#endif -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif -static __malloc_size_t pagesize; - -__ptr_t -valloc(size) - __malloc_size_t size; -{ - if (pagesize == 0) - pagesize = __getpagesize(); - - return memalign(pagesize, size); -} - -/* Memory allocator `malloc'. - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - Written May 1989 by Mike Haertel. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 675 Mass Ave, - Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif - -/* How to really get more memory. */ -__ptr_t (*__morecore) __P((ptrdiff_t __size)) = __default_morecore; - -/* Debugging hook for `malloc'. */ -__ptr_t (*__malloc_hook) __P((__malloc_size_t __size)); - -/* Pointer to the base of the first block. */ -char *_heapbase; - -/* Block information table. Allocated with align/__free (not malloc/free). */ -malloc_info *_heapinfo; - -/* Number of info entries. */ -static -__malloc_size_t heapsize; - -/* Search index in the info table. */ -__malloc_size_t _heapindex; - -/* Limit of valid info table indices. */ -__malloc_size_t _heaplimit; - -/* Free lists for each fragment size. */ -struct list - _fraghead[BLOCKLOG]; - -/* Instrumentation. */ -__malloc_size_t _chunks_used; -__malloc_size_t _bytes_used; -__malloc_size_t _chunks_free; -__malloc_size_t _bytes_free; - -/* Are you experienced? */ -int - __malloc_initialized; - -void (*__malloc_initialize_hook) - __P((void)); -void (*__after_morecore_hook) - __P((void)); - -/* Aligned allocation. */ -static -__ptr_t align __P((__malloc_size_t)); -static - __ptr_t -align(size) - __malloc_size_t size; -{ - __ptr_t result; - unsigned long int adj; - - result = (*__morecore) (size); - adj = (unsigned long int) ((unsigned long int) ((char *) result - - (char *) NULL)) % BLOCKSIZE; - if (adj != 0) { - adj = BLOCKSIZE - adj; - (void) (*__morecore) (adj); - result = (char *) result + adj; - } - if (__after_morecore_hook) - (*__after_morecore_hook) (); - - return result; -} - -/* Set everything up and remember that we have. */ -static int initialize __P((void)); -static int -initialize() -{ - if (__malloc_initialize_hook) - (*__malloc_initialize_hook) (); - - heapsize = HEAP / BLOCKSIZE; - _heapinfo = (malloc_info *) align(heapsize * sizeof(malloc_info)); - if (_heapinfo == NULL) - return 0; - memset(_heapinfo, 0, heapsize * sizeof(malloc_info)); - _heapinfo[0].free.size = 0; - _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; - _heapindex = 0; - _heapbase = (char *) _heapinfo; - - /* Account for the _heapinfo block itself in the statistics. */ - _bytes_used = heapsize * sizeof(malloc_info); - _chunks_used = 1; - - __malloc_initialized = 1; - return 1; -} - -/* Get neatly aligned memory, initializing or - growing the heap info table as necessary. */ -static __ptr_t morecore __P((__malloc_size_t)); -static __ptr_t -morecore(size) - __malloc_size_t size; -{ - __ptr_t result; - malloc_info *newinfo, *oldinfo; - __malloc_size_t newsize; - - result = align(size); - if (result == NULL) - return NULL; - - /* Check if we need to grow the info table. */ - if ((__malloc_size_t) BLOCK((char *) result + size) > heapsize) { - newsize = heapsize; - while ((__malloc_size_t) BLOCK((char *) result + size) > newsize) - newsize *= 2; - newinfo = (malloc_info *) align(newsize * sizeof(malloc_info)); - if (newinfo == NULL) { - (*__morecore) (-size); - return NULL; - } - memcpy(newinfo, _heapinfo, heapsize * sizeof(malloc_info)); - memset(&newinfo[heapsize], 0, (newsize - heapsize) * sizeof(malloc_info)); - oldinfo = _heapinfo; - newinfo[BLOCK(oldinfo)].busy.type = 0; - newinfo[BLOCK(oldinfo)].busy.info.size - = BLOCKIFY(heapsize * sizeof(malloc_info)); - _heapinfo = newinfo; - /* Account for the _heapinfo block itself in the statistics. */ - _bytes_used += newsize * sizeof(malloc_info); - ++_chunks_used; - _free_internal(oldinfo); - heapsize = newsize; - } - _heaplimit = BLOCK((char *) result + size); - return result; -} - -/* Allocate memory from the heap. */ -__ptr_t -malloc(size) - __malloc_size_t size; -{ - __ptr_t result; - __malloc_size_t block, blocks, lastblocks, start; - register __malloc_size_t i; - struct list *next; - - /* ANSI C allows `malloc (0)' to either return NULL, or to return a - valid address you can realloc and free (though not dereference). - - It turns out that some extant code (sunrpc, at least Ultrix's version) - expects `malloc (0)' to return non-NULL and breaks otherwise. - Be compatible. */ - -#if 0 - if (size == 0) - return NULL; -#endif - - if (__malloc_hook != NULL) - return (*__malloc_hook) (size); - - if (!__malloc_initialized) - if (!initialize()) - return NULL; - - if (size < sizeof(struct list)) - size = sizeof(struct list); - -#ifdef SUNOS_LOCALTIME_BUG - if (size < 16) - size = 16; -#endif - - /* Determine the allocation policy based on the request size. */ - if (size <= BLOCKSIZE / 2) { - /* Small allocation to receive a fragment of a block. - Determine the logarithm to base two of the fragment size. */ - register __malloc_size_t log = 1; - --size; - while ((size /= 2) != 0) - ++log; - - /* Look in the fragment lists for a - free fragment of the desired size. */ - next = _fraghead[log].next; - if (next != NULL) { - /* There are free fragments of this size. - Pop a fragment out of the fragment list and return it. - Update the block's nfree and first counters. */ - result = (__ptr_t) next; - next->prev->next = next->next; - if (next->next != NULL) - next->next->prev = next->prev; - block = BLOCK(result); - if (--_heapinfo[block].busy.info.frag.nfree != 0) - _heapinfo[block].busy.info.frag.first = (unsigned long int) - ((unsigned long int) ((char *) next->next - (char *) NULL) - % BLOCKSIZE) >> log; - - /* Update the statistics. */ - ++_chunks_used; - _bytes_used += 1 << log; - --_chunks_free; - _bytes_free -= 1 << log; - } else { - /* No free fragments of the desired size, so get a new block - and break it into fragments, returning the first. */ - result = malloc(BLOCKSIZE); - if (result == NULL) - return NULL; - - /* Link all fragments but the first into the free list. */ - for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> log); ++i) { - next = (struct list *) ((char *) result + (i << log)); - next->next = _fraghead[log].next; - next->prev = &_fraghead[log]; - next->prev->next = next; - if (next->next != NULL) - next->next->prev = next; - } - - /* Initialize the nfree and first counters for this block. */ - block = BLOCK(result); - _heapinfo[block].busy.type = log; - _heapinfo[block].busy.info.frag.nfree = i - 1; - _heapinfo[block].busy.info.frag.first = i - 1; - - _chunks_free += (BLOCKSIZE >> log) - 1; - _bytes_free += BLOCKSIZE - (1 << log); - _bytes_used -= BLOCKSIZE - (1 << log); - } - } else { - /* Large allocation to receive one or more blocks. - Search the free list in a circle starting at the last place visited. - If we loop completely around without finding a large enough - space we will have to get more memory from the system. */ - blocks = BLOCKIFY(size); - start = block = _heapindex; - while (_heapinfo[block].free.size < blocks) { - block = _heapinfo[block].free.next; - if (block == start) { - /* Need to get more from the system. Check to see if - the new core will be contiguous with the final free - block; if so we don't need to get as much. */ - block = _heapinfo[0].free.prev; - lastblocks = _heapinfo[block].free.size; - if (_heaplimit != 0 && block + lastblocks == _heaplimit && - (*__morecore) (0) == ADDRESS(block + lastblocks) && - (morecore((blocks - lastblocks) * BLOCKSIZE)) != NULL) { - /* Which block we are extending (the `final free - block' referred to above) might have changed, if - it got combined with a freed info table. */ - block = _heapinfo[0].free.prev; - _heapinfo[block].free.size += (blocks - lastblocks); - _bytes_free += (blocks - lastblocks) * BLOCKSIZE; - continue; - } - result = morecore(blocks * BLOCKSIZE); - if (result == NULL) - return NULL; - block = BLOCK(result); - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = blocks; - ++_chunks_used; - _bytes_used += blocks * BLOCKSIZE; - return result; - } - } - - /* At this point we have found a suitable free list entry. - Figure out how to remove what we need from the list. */ - result = ADDRESS(block); - if (_heapinfo[block].free.size > blocks) { - /* The block we found has a bit left over, - so relink the tail end back into the free list. */ - _heapinfo[block + blocks].free.size = _heapinfo[block].free.size - blocks; - _heapinfo[block + blocks].free.next = _heapinfo[block].free.next; - _heapinfo[block + blocks].free.prev = _heapinfo[block].free.prev; - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapinfo[_heapinfo[block].free.next].free.prev - = _heapindex = block + blocks; - } else { - /* The block exactly matches our requirements, - so just remove it from the list. */ - _heapinfo[_heapinfo[block].free.next].free.prev - = _heapinfo[block].free.prev; - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapindex = _heapinfo[block].free.next; - --_chunks_free; - } - - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = blocks; - ++_chunks_used; - _bytes_used += blocks * BLOCKSIZE; - _bytes_free -= blocks * BLOCKSIZE; - - /* Mark all the blocks of the object just allocated except for the - first with a negative number so you can find the first block by - adding that adjustment. */ - while (--blocks > 0) - _heapinfo[block + blocks].busy.info.size = -blocks; - } - - return result; -} - -#ifndef _LIBC - -/* On some ANSI C systems, some libc functions call _malloc, _free - and _realloc. Make them use the GNU functions. */ - -__ptr_t _malloc _((__malloc_size_t size)); - -__ptr_t -_malloc(size) - __malloc_size_t size; -{ - return malloc(size); -} - -void _free _((__ptr_t ptr)); - -void -_free(ptr) - __ptr_t ptr; -{ - free(ptr); -} - -__ptr_t _realloc _((__ptr_t ptr, size_t size)); - -__ptr_t -_realloc(ptr, size) - __ptr_t ptr; - __malloc_size_t size; -{ - return realloc(ptr, size); -} - -#endif -/* Free a block of memory allocated by `malloc'. - Copyright 1990, 1991, 1992, 1994 Free Software Foundation, Inc. - Written May 1989 by Mike Haertel. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 675 Mass Ave, - Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif - -/* Debugging hook for free. */ -void (*__free_hook) __P((__ptr_t __ptr)); - -/* List of blocks allocated by memalign. */ -struct alignlist *_aligned_blocks = NULL; - -/* Return memory to the heap. - Like `free' but don't call a __free_hook if there is one. */ -void -_free_internal(ptr) - __ptr_t ptr; -{ - int type; - __malloc_size_t block, blocks; - register __malloc_size_t i; - struct list *prev, *next; - - block = BLOCK(ptr); - - type = _heapinfo[block].busy.type; - switch (type) { - case 0: - /* Get as many statistics as early as we can. */ - --_chunks_used; - _bytes_used -= _heapinfo[block].busy.info.size * BLOCKSIZE; - _bytes_free += _heapinfo[block].busy.info.size * BLOCKSIZE; - - /* Find the free cluster previous to this one in the free list. - Start searching at the last block referenced; this may benefit - programs with locality of allocation. */ - i = _heapindex; - if (i > block) - while (i > block) - i = _heapinfo[i].free.prev; - else { - do - i = _heapinfo[i].free.next; - while (i > 0 && i < block); - i = _heapinfo[i].free.prev; - } - - /* Determine how to link this block into the free list. */ - if (block == i + _heapinfo[i].free.size) { - /* Coalesce this block with its predecessor. */ - _heapinfo[i].free.size += _heapinfo[block].busy.info.size; - block = i; - } else { - /* Really link this block back into the free list. */ - _heapinfo[block].free.size = _heapinfo[block].busy.info.size; - _heapinfo[block].free.next = _heapinfo[i].free.next; - _heapinfo[block].free.prev = i; - _heapinfo[i].free.next = block; - _heapinfo[_heapinfo[block].free.next].free.prev = block; - ++_chunks_free; - } - - /* Now that the block is linked in, see if we can coalesce it - with its successor (by deleting its successor from the list - and adding in its size). */ - if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) { - _heapinfo[block].free.size - += _heapinfo[_heapinfo[block].free.next].free.size; - _heapinfo[block].free.next - = _heapinfo[_heapinfo[block].free.next].free.next; - _heapinfo[_heapinfo[block].free.next].free.prev = block; - --_chunks_free; - } - /* Now see if we can return stuff to the system. */ - blocks = _heapinfo[block].free.size; - if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit - && (*__morecore) (0) == ADDRESS(block + blocks)) { - register __malloc_size_t bytes = blocks * BLOCKSIZE; - _heaplimit -= blocks; - (*__morecore) (-bytes); - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapinfo[block].free.next; - _heapinfo[_heapinfo[block].free.next].free.prev - = _heapinfo[block].free.prev; - block = _heapinfo[block].free.prev; - --_chunks_free; - _bytes_free -= bytes; - } - /* Set the next search to begin at this block. */ - _heapindex = block; - break; - - default: - /* Do some of the statistics. */ - --_chunks_used; - _bytes_used -= 1 << type; - ++_chunks_free; - _bytes_free += 1 << type; - - /* Get the address of the first free fragment in this block. */ - prev = (struct list *) ((char *) ADDRESS(block) + - (_heapinfo[block].busy.info.frag.first << type)); - - if (_heapinfo[block].busy.info.frag.nfree == - (__malloc_size_t) (BLOCKSIZE >> type) - 1) { - /* If all fragments of this block are free, remove them - from the fragment list and free the whole block. */ - next = prev; - for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> type); ++i) - next = next->next; - prev->prev->next = next; - if (next != NULL) - next->prev = prev->prev; - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = 1; - - /* Keep the statistics accurate. */ - ++_chunks_used; - _bytes_used += BLOCKSIZE; - _chunks_free -= BLOCKSIZE >> type; - _bytes_free -= BLOCKSIZE; - - free(ADDRESS(block)); - } else if (_heapinfo[block].busy.info.frag.nfree != 0) { - /* If some fragments of this block are free, link this - fragment into the fragment list after the first free - fragment of this block. */ - next = (struct list *) ptr; - next->next = prev->next; - next->prev = prev; - prev->next = next; - if (next->next != NULL) - next->next->prev = next; - ++_heapinfo[block].busy.info.frag.nfree; - } else { - /* No fragments of this block are free, so link this - fragment into the fragment list and announce that - it is the first free fragment of this block. */ - prev = (struct list *) ptr; - _heapinfo[block].busy.info.frag.nfree = 1; - _heapinfo[block].busy.info.frag.first = (unsigned long int) - ((unsigned long int) ((char *) ptr - (char *) NULL) - % BLOCKSIZE >> type); - prev->next = _fraghead[type].next; - prev->prev = &_fraghead[type]; - prev->prev->next = prev; - if (prev->next != NULL) - prev->next->prev = prev; - } - break; - } -} - -/* Return memory to the heap. */ -void -free(ptr) - __ptr_t ptr; -{ - register struct alignlist *l; - - if (ptr == NULL) - return; - - for (l = _aligned_blocks; l != NULL; l = l->next) - if (l->aligned == ptr) { - l->aligned = NULL; /* Mark the slot in the list as free. */ - ptr = l->exact; - break; - } - if (__free_hook != NULL) - (*__free_hook) (ptr); - else - _free_internal(ptr); -} - -/* Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 675 Mass Ave, - Cambridge, MA 02139, USA. */ - -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif - -#ifdef _LIBC - -#include -#include - -#undef cfree - -function_alias(cfree, free, void, (ptr), DEFUN(cfree, (ptr), PTR ptr)) -#else - -void cfree _((__ptr_t ptr)); - -void -cfree(ptr) - __ptr_t ptr; -{ - free(ptr); -} - -#endif -/* Change the size of a block allocated by `malloc'. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. - Written May 1989 by Mike Haertel. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 675 Mass Ave, - Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif - -#if (defined (MEMMOVE_MISSING) || \ - !defined(_LIBC) && !defined(STDC_HEADERS) && !defined(USG)) - -/* Snarfed directly from Emacs src/dispnew.c: - XXX Should use system bcopy if it handles overlap. */ -#ifndef emacs - -/* Like bcopy except never gets confused by overlap. */ - -static void -safe_bcopy(from, to, size) - char *from, *to; - int size; -{ - if (size <= 0 || from == to) - return; - - /* If the source and destination don't overlap, then bcopy can - handle it. If they do overlap, but the destination is lower in - memory than the source, we'll assume bcopy can handle that. */ - if (to < from || from + size <= to) - bcopy(from, to, size); - - /* Otherwise, we'll copy from the end. */ - else { - register char *endf = from + size; - register char *endt = to + size; - - /* If TO - FROM is large, then we should break the copy into - nonoverlapping chunks of TO - FROM bytes each. However, if - TO - FROM is small, then the bcopy function call overhead - makes this not worth it. The crossover point could be about - anywhere. Since I don't think the obvious copy loop is too - bad, I'm trying to err in its favor. */ - if (to - from < 64) { - do - *--endt = *--endf; - while (endf != from); - } else { - for (;;) { - endt -= (to - from); - endf -= (to - from); - - if (endt < to) - break; - - bcopy(endf, endt, to - from); - } - - /* If SIZE wasn't a multiple of TO - FROM, there will be a - little left over. The amount left over is - (endt + (to - from)) - to, which is endt - from. */ - bcopy(from, to, endt - from); - } - } -} -#endif /* Not emacs. */ - -#define memmove(to, from, size) safe_bcopy ((from), (to), (size)) - -#endif - - -#define min(A, B) ((A) < (B) ? (A) : (B)) - -/* Debugging hook for realloc. */ -__ptr_t (*__realloc_hook) __P((__ptr_t __ptr, __malloc_size_t __size)); - -/* Resize the given region to the new size, returning a pointer - to the (possibly moved) region. This is optimized for speed; - some benchmarks seem to indicate that greater compactness is - achieved by unconditionally allocating and copying to a - new region. This module has incestuous knowledge of the - internals of both free and malloc. */ -__ptr_t -realloc(ptr, size) - __ptr_t ptr; - __malloc_size_t size; -{ - __ptr_t result; - int type; - __malloc_size_t block, blocks, oldlimit; - - if (size == 0) { - free(ptr); - return malloc(0); - } else if (ptr == NULL) - return malloc(size); - - if (__realloc_hook != NULL) - return (*__realloc_hook) (ptr, size); - - block = BLOCK(ptr); - - type = _heapinfo[block].busy.type; - switch (type) { - case 0: - /* Maybe reallocate a large block to a small fragment. */ - if (size <= BLOCKSIZE / 2) { - result = malloc(size); - if (result != NULL) { - memcpy(result, ptr, size); - _free_internal(ptr); - return result; - } - } - /* The new size is a large allocation as well; - see if we can hold it in place. */ - blocks = BLOCKIFY(size); - if ((__malloc_ptrdiff_t) blocks < _heapinfo[block].busy.info.size) { - /* The new size is smaller; return - excess memory to the free list. */ - _heapinfo[block + blocks].busy.type = 0; - _heapinfo[block + blocks].busy.info.size - = _heapinfo[block].busy.info.size - blocks; - _heapinfo[block].busy.info.size = blocks; - /* We have just created a new chunk by splitting a chunk in two. - Now we will free this chunk; increment the statistics counter - so it doesn't become wrong when _free_internal decrements it. */ - ++_chunks_used; - _free_internal(ADDRESS(block + blocks)); - result = ptr; - } else if ((__malloc_ptrdiff_t) blocks == _heapinfo[block].busy.info.size) - /* No size change necessary. */ - result = ptr; - else { - /* Won't fit, so allocate a new region that will. - Free the old region first in case there is sufficient - adjacent free space to grow without moving. */ - blocks = _heapinfo[block].busy.info.size; - /* Prevent free from actually returning memory to the system. */ - oldlimit = _heaplimit; - _heaplimit = 0; - _free_internal(ptr); - _heaplimit = oldlimit; - result = malloc(size); - if (result == NULL) { - /* Now we're really in trouble. We have to unfree - the thing we just freed. Unfortunately it might - have been coalesced with its neighbors. */ - if (_heapindex == block) - (void) malloc(blocks * BLOCKSIZE); - else { - __ptr_t previous = malloc((block - _heapindex) * BLOCKSIZE); - (void) malloc(blocks * BLOCKSIZE); - _free_internal(previous); - } - return NULL; - } - if (ptr != result) - memmove(result, ptr, blocks * BLOCKSIZE); - } - break; - - default: - /* Old size is a fragment; type is logarithm - to base two of the fragment size. */ - if (size > (__malloc_size_t) (1 << (type - 1)) && - size <= (__malloc_size_t) (1 << type)) - /* The new size is the same kind of fragment. */ - result = ptr; - else { - /* The new size is different; allocate a new space, - and copy the lesser of the new size and the old. */ - result = malloc(size); - if (result == NULL) - return NULL; - memcpy(result, ptr, min(size, (__malloc_size_t) 1 << type)); - free(ptr); - } - break; - } - - return result; -} - -/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 675 Mass Ave, - Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif - -/* Allocate an array of NMEMB elements each SIZE bytes long. - The entire array is initialized to zeros. */ -__ptr_t -calloc(nmemb, size) - register __malloc_size_t nmemb; - register __malloc_size_t size; -{ - register __ptr_t result = malloc(nmemb * size); - - if (result != NULL) - (void) memset(result, 0, nmemb * size); - - return result; -} - -/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The GNU C 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the GNU C Library; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif - -#ifndef __GNU_LIBRARY__ -#define __sbrk sbrk -#endif - -#ifdef __GNU_LIBRARY__ -/* It is best not to declare this and cast its result on foreign operating - systems with potentially hostile include files. */ -extern __ptr_t __sbrk __P((int increment)); -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* Allocate INCREMENT more bytes of data space, - and return the start of data space, or NULL on errors. - If INCREMENT is negative, shrink data space. */ -__ptr_t -__default_morecore(increment) -#ifdef __STDC__ - ptrdiff_t increment; -#else - int - increment; -#endif -{ - __ptr_t result = (__ptr_t) __sbrk((int) increment); - if (result == (__ptr_t) -1) - return NULL; - return result; -} - -/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 675 Mass Ave, - Cambridge, MA 02139, USA. */ - -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif - -__ptr_t (*__memalign_hook) __P((size_t __size, size_t __alignment)); - -__ptr_t -memalign(alignment, size) - __malloc_size_t alignment; - __malloc_size_t size; -{ - __ptr_t result; - unsigned long int adj; - - if (__memalign_hook) - return (*__memalign_hook) (alignment, size); - - size = ((size + alignment - 1) / alignment) * alignment; - - result = malloc(size); - if (result == NULL) - return NULL; - adj = (unsigned long int) ((unsigned long int) ((char *) result - - (char *) NULL)) % alignment; - if (adj != 0) { - struct alignlist *l; - for (l = _aligned_blocks; l != NULL; l = l->next) - if (l->aligned == NULL) - /* This slot is free. Use it. */ - break; - if (l == NULL) { - l = (struct alignlist *) malloc(sizeof(struct alignlist)); - if (l == NULL) { - free(result); - return NULL; - } - l->next = _aligned_blocks; - _aligned_blocks = l; - } - l->exact = result; - result = l->aligned = (char *) result + alignment - adj; - } - return result; -} Index: src/mysocket.c =================================================================== --- src/mysocket.c (.../p5) (revision 1028) +++ src/mysocket.c (.../p6) (revision 1028) @@ -119,7 +119,7 @@ static char port[NI_MAXSERV]; if (getnameinfo(host, len, hostname, sizeof hostname, port, sizeof port, - (USE_DNS ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV) != 0) { + (USE_DNS ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV) != 0) { return NULL; } hi.hostname = hostname; @@ -140,14 +140,14 @@ static char port[NI_MAXSERV]; if (getnameinfo(host, len, hostname, sizeof hostname, port, sizeof port, - NI_NUMERICHOST | NI_NUMERICSERV) != 0) { + NI_NUMERICHOST | NI_NUMERICSERV) != 0) { return NULL; } hi.hostname = hostname; hi.port = port; return &hi; } -#endif /* INFOSLAVE */ +#endif /* INFOSLAVE */ /** Open a tcp connection to a given host and port. Basically * tcp_connect from UNPv1 @@ -160,7 +160,7 @@ */ int make_socket_conn(const char *host, struct sockaddr *myiterface, - socklen_t myilen, Port_t port, int *timeout) + socklen_t myilen, Port_t port, int *timeout) { struct addrinfo hints, *server, *save; char cport[NI_MAXSERV]; @@ -170,7 +170,7 @@ memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; - hints.ai_family = AF_UNSPEC; /* Try to use IPv6 if available */ + hints.ai_family = AF_UNSPEC; /* Try to use IPv6 if available */ hints.ai_socktype = SOCK_STREAM; sprintf(cport, "%hu", port); @@ -198,11 +198,11 @@ if (myiterface && myilen > 0) { /* Bind to a specific interface. Needed for ident lookups */ if (bind(s, myiterface, myilen) < 0) - perror("bind failed (Possibly harmless)"); + perror("bind failed (Possibly harmless)"); } if ((err = connect_nonb(s, server->ai_addr, server->ai_addrlen, timeout)) == - 0) + 0) break; #ifdef DEBUG @@ -243,7 +243,7 @@ */ int make_socket(Port_t port, union sockaddr_u *addr, socklen_t *len, - const char *host) + const char *host) { int s, opt, ipv = 4; /* Use getaddrinfo() to fill in the sockaddr fields. This @@ -258,10 +258,10 @@ memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; #ifdef FORCE_IPV4 - hints.ai_family = AF_INET; /* OpenBSD apparently doesn't properly - map IPv4 connections to IPv6 servers. */ + hints.ai_family = AF_INET; /* OpenBSD apparently doesn't properly + map IPv4 connections to IPv6 servers. */ #else - hints.ai_family = AF_UNSPEC; /* Try to use IPv6 if available */ + hints.ai_family = AF_UNSPEC; /* Try to use IPv6 if available */ #endif hints.ai_socktype = SOCK_STREAM; @@ -295,7 +295,7 @@ } if (bind(s, server->ai_addr, server->ai_addrlen) == 0) - break; /* Success */ + break; /* Success */ perror("binding stream socket (Possibly ignorable)"); closesocket(s); @@ -343,7 +343,7 @@ } if (fcntl(s, F_SETFL, flags | O_NDELAY) == -1) { -#endif /* WIN32 */ +#endif /* WIN32 */ perror("make_nonblocking: fcntl"); #ifndef INFOSLAVE mush_panic("O_NDELAY fcntl failed"); @@ -370,7 +370,7 @@ /* enable TCP keepalive */ if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, - (void *) &keepalive, sizeof(keepalive)) == -1) + (void *) &keepalive, sizeof(keepalive)) == -1) fprintf(stderr, "[%d] could not set SO_KEEPALIVE: errno %d", s, errno); /* And set the ping time to something reasonable instead of the @@ -378,11 +378,11 @@ this. OS X and possibly others use TCP_KEEPALIVE. */ #if defined(TCP_KEEPIDLE) if (setsockopt(s, IPPROTO_TCP, TCP_KEEPIDLE, - (void *) &keepidle, sizeof(keepidle)) == -1) + (void *) &keepidle, sizeof(keepidle)) == -1) fprintf(stderr, "[%d] could not set TCP_KEEPIDLE: errno %d", s, errno); #elif defined(TCP_KEEPALIVE) if (setsockopt(s, IPPROTO_TCP, TCP_KEEPALIVE, - (void *) &keepidle, sizeof(keepidle)) == -1) + (void *) &keepidle, sizeof(keepidle)) == -1) fprintf(stderr, "[%d] could not set TCP_KEEPALIVE: errno %d", s, errno); #endif #endif @@ -405,7 +405,7 @@ */ int connect_nonb(int sockfd, const struct sockaddr *saptr, socklen_t salen, - int *timeout) + int *timeout) { int n, error; time_t start, end; @@ -437,7 +437,7 @@ time(&start); if ((n = select(sockfd + 1, &rset, &wset, NULL, &tval)) == 0) { - closesocket(sockfd); /* timeout */ + closesocket(sockfd); /* timeout */ errno = ETIMEDOUT; return -1; } @@ -449,14 +449,14 @@ if (FD_ISSET(sockfd, &rset) || FD_ISSET(sockfd, &wset)) { len = sizeof(error); if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (__ptr_t) &error, &len) < 0) - return -1; /* Solaris pending error */ + return -1; /* Solaris pending error */ } else return -1; done: if (error) { - closesocket(sockfd); /* just in case */ + closesocket(sockfd); /* just in case */ errno = error; return -1; } @@ -501,7 +501,7 @@ #define INT16SZ 2 #ifndef AF_INET6 -#define AF_INET6 AF_MAX+1 /* just to let this compile */ +#define AF_INET6 AF_MAX+1 /* just to let this compile */ #endif /* @@ -597,14 +597,14 @@ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { if (words[i] == 0) { if (cur.base == -1) - cur.base = i, cur.len = 1; + cur.base = i, cur.len = 1; else - cur.len++; + cur.len++; } else { if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; + if (best.base == -1 || cur.len > best.len) + best = cur; + cur.base = -1; } } } @@ -623,7 +623,7 @@ /* Are we inside the best run of 0x00's? */ if (best.base != -1 && i >= best.base && i < (best.base + best.len)) { if (i == best.base) - *tp++ = ':'; + *tp++ = ':'; continue; } /* Are we following an initial run of 0x00s or any real hex? */ @@ -631,9 +631,9 @@ *tp++ = ':'; /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { + (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp))) - return (NULL); + return (NULL); tp += strlen(tp); break; } @@ -737,16 +737,16 @@ unsigned int new = *tp * 10 + (pch - digits); if (new > 255) - return (0); + return (0); *tp = new; if (!saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; + if (++octets > 4) + return (0); + saw_digit = 1; } } else if (ch == '.' && saw_digit) { if (octets == 4) - return (0); + return (0); *++tp = 0; saw_digit = 0; } else @@ -801,20 +801,20 @@ val <<= 4; val |= (pch - xdigits); if (val > 0xffff) - return (0); + return (0); saw_xdigit = 1; continue; } if (ch == ':') { curtok = src; if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; + if (colonp) + return (0); + colonp = tp; + continue; } if (tp + INT16SZ > endp) - return (0); + return (0); *tp++ = (unsigned char) (val >> 8) & 0xff; *tp++ = (unsigned char) val & 0xff; saw_xdigit = 0; @@ -824,7 +824,7 @@ if (ch == '.' && ((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) { tp += INADDRSZ; saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ + break; /* '\0' was seen by inet_pton4(). */ } return (0); } @@ -858,7 +858,7 @@ #ifndef HAS_GETNAMEINFO static int gn_ipv46(char *, size_t, char *, size_t, void *, size_t, - int, int, int); + int, int, int); /* * Handle either an IPv4 or an IPv6 address and port. @@ -867,7 +867,7 @@ /* include gn_ipv46 */ static int gn_ipv46(char *host, size_t hostlen, char *serv, size_t servlen, - void *aptr, size_t alen, int family, int port, int flags) + void *aptr, size_t alen, int family, int port, int flags) { char *ptr; struct hostent *hptr; @@ -875,25 +875,25 @@ if (hostlen > 0) { if (flags & NI_NUMERICHOST) { if (inet_ntop(family, aptr, host, hostlen) == NULL) - return (1); + return (1); } else { hptr = gethostbyaddr(aptr, alen, family); if (hptr != NULL && hptr->h_name != NULL) { - if (flags & NI_NOFQDN) { - if ((ptr = strchr(hptr->h_name, '.')) != NULL) - *ptr = 0; /* overwrite first dot */ - } + if (flags & NI_NOFQDN) { + if ((ptr = strchr(hptr->h_name, '.')) != NULL) + *ptr = 0; /* overwrite first dot */ + } #ifdef HAS_SNPRINTF - snprintf(host, hostlen, "%s", hptr->h_name); + snprintf(host, hostlen, "%s", hptr->h_name); #else - strncpy(host, hptr->h_name, hostlen); - host[hostlen - 1] = '\0'; + strncpy(host, hptr->h_name, hostlen); + host[hostlen - 1] = '\0'; #endif } else { - if (flags & NI_NAMEREQD) - return (1); - if (inet_ntop(family, aptr, host, hostlen) == NULL) - return (1); + if (flags & NI_NAMEREQD) + return (1); + if (inet_ntop(family, aptr, host, hostlen) == NULL) + return (1); } } } @@ -924,7 +924,7 @@ /* include getnameinfo */ int getnameinfo(const struct sockaddr *sa, socklen_t salen, - char *host, size_t hostlen, char *serv, size_t servlen, int flags) + char *host, size_t hostlen, char *serv, size_t servlen, int flags) { switch (sa->sa_family) { @@ -933,8 +933,8 @@ struct sockaddr_in *sain = (struct sockaddr_in *) sa; return (gn_ipv46(host, hostlen, serv, servlen, - &sain->sin_addr, sizeof(struct in_addr), - AF_INET, sain->sin_port, flags)); + &sain->sin_addr, sizeof(struct in_addr), + AF_INET, sain->sin_port, flags)); } #endif @@ -943,8 +943,8 @@ struct sockaddr_in6 *sain = (struct sockaddr_in6 *) sa; return (gn_ipv46(host, hostlen, serv, servlen, - &sain->sin6_addr, sizeof(struct in6_addr), - AF_INET6, sain->sin6_port, flags)); + &sain->sin6_addr, sizeof(struct in6_addr), + AF_INET6, sain->sin6_port, flags)); } #endif @@ -961,12 +961,12 @@ /* include ga1 */ struct search { - const char *host; /* hostname or address string */ - int family; /* AF_xxx */ + const char *host; /* hostname or address string */ + int family; /* AF_xxx */ }; static int ga_aistruct(struct addrinfo ***, const struct addrinfo *, - const void *, int); + const void *, int); static struct addrinfo *ga_clone(struct addrinfo *); static int ga_echeck(const char *, const char *, int, int, int, int); static int ga_nsearch(const char *, const struct addrinfo *, struct search *); @@ -976,7 +976,7 @@ int getaddrinfo(const char *hostname, const char *servname, - const struct addrinfo *hintsp, struct addrinfo **result) + const struct addrinfo *hintsp, struct addrinfo **result) { int rc, error, nsearch; char **ap, *canon; @@ -990,7 +990,7 @@ */ #define error(e) { error = (e); goto bad; } - aihead = NULL; /* initialize automatic variables */ + aihead = NULL; /* initialize automatic variables */ aipnext = &aihead; canon = NULL; @@ -998,11 +998,11 @@ memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; } else - hints = *hintsp; /* struct copy */ + hints = *hintsp; /* struct copy */ /* 4first some basic error checking */ if ((rc = ga_echeck(hostname, servname, hints.ai_flags, hints.ai_family, - hints.ai_socktype, hints.ai_protocol)) != 0) + hints.ai_socktype, hints.ai_protocol)) != 0) error(rc); /* end ga1 */ @@ -1017,14 +1017,14 @@ struct in_addr inaddr; if (inet_pton(AF_INET, sptr->host, &inaddr) == 1) { - if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET) - error(EAI_ADDRFAMILY); - if (sptr->family != AF_INET) - continue; /* ignore */ - rc = ga_aistruct(&aipnext, &hints, &inaddr, AF_INET); - if (rc != 0) - error(rc); - continue; + if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET) + error(EAI_ADDRFAMILY); + if (sptr->family != AF_INET) + continue; /* ignore */ + rc = ga_aistruct(&aipnext, &hints, &inaddr, AF_INET); + if (rc != 0) + error(rc); + continue; } } #endif @@ -1032,18 +1032,18 @@ #ifdef HAS_IPV6 /* 4check for an IPv6 hex string */ if ((isxdigit((unsigned char) sptr->host[0]) || sptr->host[0] == ':') && - (strchr(sptr->host, ':') != NULL)) { + (strchr(sptr->host, ':') != NULL)) { struct in6_addr in6addr; if (inet_pton(AF_INET6, sptr->host, &in6addr) == 1) { - if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET6) - error(EAI_ADDRFAMILY); - if (sptr->family != AF_INET6) - continue; /* ignore */ - rc = ga_aistruct(&aipnext, &hints, &in6addr, AF_INET6); - if (rc != 0) - error(rc); - continue; + if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET6) + error(EAI_ADDRFAMILY); + if (sptr->family != AF_INET6) + continue; /* ignore */ + rc = ga_aistruct(&aipnext, &hints, &in6addr, AF_INET6); + if (rc != 0) + error(rc); + continue; } } #endif @@ -1052,7 +1052,7 @@ /* 4remainder of for() to look up hostname */ #ifdef HAS_IPV6 if ((_res.options & RES_INIT) == 0) - res_init(); /* need this to set _res.options */ + res_init(); /* need this to set _res.options */ #endif if (nsearch == 2) { @@ -1063,27 +1063,27 @@ } else { #ifdef HAS_IPV6 if (sptr->family == AF_INET6) - _res.options |= RES_USE_INET6; + _res.options |= RES_USE_INET6; else - _res.options &= ~RES_USE_INET6; + _res.options &= ~RES_USE_INET6; #endif hptr = gethostbyname(sptr->host); } if (hptr == NULL) { if (nsearch == 2) - continue; /* failure OK if multiple searches */ + continue; /* failure OK if multiple searches */ switch (h_errno) { case HOST_NOT_FOUND: - error(EAI_NONAME); + error(EAI_NONAME); case TRY_AGAIN: - error(EAI_AGAIN); + error(EAI_AGAIN); case NO_RECOVERY: - error(EAI_FAIL); + error(EAI_FAIL); case NO_DATA: - error(EAI_NODATA); + error(EAI_NODATA); default: - error(EAI_NONAME); + error(EAI_NONAME); } } @@ -1093,30 +1093,30 @@ /* 4save canonical name first time */ if (hostname != NULL && hostname[0] != '\0' && - (hints.ai_flags & AI_CANONNAME) && canon == NULL) { + (hints.ai_flags & AI_CANONNAME) && canon == NULL) { if ((canon = strdup(hptr->h_name)) == NULL) - error(EAI_MEMORY); + error(EAI_MEMORY); } /* 4create one addrinfo{} for each returned address */ for (ap = hptr->h_addr_list; *ap != NULL; ap++) { rc = ga_aistruct(&aipnext, &hints, *ap, hptr->h_addrtype); if (rc != 0) - error(rc); + error(rc); } } if (aihead == NULL) - error(EAI_NONAME); /* nothing found */ + error(EAI_NONAME); /* nothing found */ /* end ga4 */ /* include ga5 */ /* 4return canonical name */ if (hostname != NULL && hostname[0] != '\0' && hints.ai_flags & AI_CANONNAME) { if (canon != NULL) - aihead->ai_canonname = canon; /* strdup'ed earlier */ + aihead->ai_canonname = canon; /* strdup'ed earlier */ else { if ((aihead->ai_canonname = strdup(search[0].host)) == NULL) - error(EAI_MEMORY); + error(EAI_MEMORY); } } @@ -1126,11 +1126,11 @@ error(rc); } - *result = aihead; /* pointer to first structure in linked list */ + *result = aihead; /* pointer to first structure in linked list */ return (0); bad: - freeaddrinfo(aihead); /* free any alloc'ed memory */ + freeaddrinfo(aihead); /* free any alloc'ed memory */ return (error); } @@ -1143,14 +1143,14 @@ /* include ga_echeck */ static int ga_echeck(const char *hostname, const char *servname, - int flags, int family, int socktype, int protocol) + int flags, int family, int socktype, int protocol) { if (flags & ~(AI_PASSIVE | AI_CANONNAME)) - return (EAI_BADFLAGS); /* unknown flag bits */ + return (EAI_BADFLAGS); /* unknown flag bits */ if (hostname == NULL || hostname[0] == '\0') { if (servname == NULL || servname[0] == '\0') - return (EAI_NONAME); /* host or service must be specified */ + return (EAI_NONAME); /* host or service must be specified */ } switch (family) { @@ -1159,21 +1159,21 @@ #ifdef IPv4 case AF_INET: if (socktype != 0 && - (socktype != SOCK_STREAM && - socktype != SOCK_DGRAM && socktype != SOCK_RAW)) - return (EAI_SOCKTYPE); /* invalid socket type */ + (socktype != SOCK_STREAM && + socktype != SOCK_DGRAM && socktype != SOCK_RAW)) + return (EAI_SOCKTYPE); /* invalid socket type */ break; #endif #ifdef HAS_IPV6 case AF_INET6: if (socktype != 0 && - (socktype != SOCK_STREAM && - socktype != SOCK_DGRAM && socktype != SOCK_RAW)) - return (EAI_SOCKTYPE); /* invalid socket type */ + (socktype != SOCK_STREAM && + socktype != SOCK_DGRAM && socktype != SOCK_RAW)) + return (EAI_SOCKTYPE); /* invalid socket type */ break; #endif default: - return (EAI_FAMILY); /* unknown protocol family */ + return (EAI_FAMILY); /* unknown protocol family */ } return (0); } @@ -1189,7 +1189,7 @@ /* include ga_nsearch1 */ static int ga_nsearch(const char *hostname, const struct addrinfo *hintsp, - struct search *search) + struct search *search) { int nsearch = 0; @@ -1199,30 +1199,30 @@ switch (hintsp->ai_family) { #ifdef IPv4 case AF_INET: - search[nsearch].host = "0.0.0.0"; - search[nsearch].family = AF_INET; - nsearch++; - break; + search[nsearch].host = "0.0.0.0"; + search[nsearch].family = AF_INET; + nsearch++; + break; #endif #ifdef HAS_IPV6 case AF_INET6: - search[nsearch].host = "0::0"; - search[nsearch].family = AF_INET6; - nsearch++; - break; + search[nsearch].host = "0::0"; + search[nsearch].family = AF_INET6; + nsearch++; + break; #endif case AF_UNSPEC: #ifdef HAS_IPV6 - search[nsearch].host = "0::0"; /* IPv6 first, then IPv4 */ - search[nsearch].family = AF_INET6; - nsearch++; + search[nsearch].host = "0::0"; /* IPv6 first, then IPv4 */ + search[nsearch].family = AF_INET6; + nsearch++; #endif #ifdef IPv4 - search[nsearch].host = "0.0.0.0"; - search[nsearch].family = AF_INET; - nsearch++; + search[nsearch].host = "0.0.0.0"; + search[nsearch].family = AF_INET; + nsearch++; #endif - break; + break; } /* end ga_nsearch1 */ /* include ga_nsearch2 */ @@ -1231,35 +1231,35 @@ switch (hintsp->ai_family) { #ifdef IPv4 case AF_INET: - search[nsearch].host = "localhost"; /* 127.0.0.1 */ - search[nsearch].family = AF_INET; - nsearch++; - break; + search[nsearch].host = "localhost"; /* 127.0.0.1 */ + search[nsearch].family = AF_INET; + nsearch++; + break; #endif #ifdef HAS_IPV6 case AF_INET6: - search[nsearch].host = "0::1"; - search[nsearch].family = AF_INET6; - nsearch++; - break; + search[nsearch].host = "0::1"; + search[nsearch].family = AF_INET6; + nsearch++; + break; #endif case AF_UNSPEC: #ifdef HAS_IPV6 - search[nsearch].host = "0::1"; /* IPv6 first, then IPv4 */ - search[nsearch].family = AF_INET6; - nsearch++; + search[nsearch].host = "0::1"; /* IPv6 first, then IPv4 */ + search[nsearch].family = AF_INET6; + nsearch++; #endif #ifdef IPv4 - search[nsearch].host = "localhost"; - search[nsearch].family = AF_INET; - nsearch++; + search[nsearch].host = "localhost"; + search[nsearch].family = AF_INET; + nsearch++; #endif - break; + break; } } /* end ga_nsearch2 */ /* include ga_nsearch3 */ - } else { /* host is specified */ + } else { /* host is specified */ switch (hintsp->ai_family) { #ifdef IPv4 case AF_INET: @@ -1278,12 +1278,12 @@ case AF_UNSPEC: #ifdef HAS_IPV6 search[nsearch].host = hostname; - search[nsearch].family = AF_INET6; /* IPv6 first */ + search[nsearch].family = AF_INET6; /* IPv6 first */ nsearch++; #endif #ifdef IPv4 search[nsearch].host = hostname; - search[nsearch].family = AF_INET; /* then IPv4 */ + search[nsearch].family = AF_INET; /* then IPv4 */ nsearch++; #endif break; @@ -1306,7 +1306,7 @@ /* include ga_aistruct1 */ int ga_aistruct(struct addrinfo ***paipnext, const struct addrinfo *hintsp, - const void *addr, int family) + const void *addr, int family) { struct addrinfo *ai; @@ -1331,7 +1331,7 @@ /* 4allocate sockaddr_in{} and fill in all but port */ if ((sinptr = calloc(1, sizeof(struct sockaddr_in))) == NULL) - return (EAI_MEMORY); + return (EAI_MEMORY); #ifdef HAVE_SOCKADDR_SA_LEN sinptr->sin_len = sizeof(struct sockaddr_in); #endif @@ -1341,14 +1341,14 @@ ai->ai_addrlen = sizeof(struct sockaddr_in); break; } -#endif /* IPV4 */ +#endif /* IPV4 */ #ifdef HAS_IPV6 case AF_INET6:{ struct sockaddr_in6 *sin6ptr; /* 4allocate sockaddr_in6{} and fill in all but port */ if ((sin6ptr = calloc(1, sizeof(struct sockaddr_in6))) == NULL) - return (EAI_MEMORY); + return (EAI_MEMORY); #ifdef HAVE_SOCKADDR_SA_LEN sin6ptr->sin6_len = sizeof(struct sockaddr_in6); #endif @@ -1358,7 +1358,7 @@ ai->ai_addrlen = sizeof(struct sockaddr_in6); break; } -#endif /* IPV6 */ +#endif /* IPV6 */ } return (0); @@ -1373,34 +1373,34 @@ /* include ga_serv */ int ga_serv(struct addrinfo *aihead, const struct addrinfo *hintsp, - const char *serv) + const char *serv) { int port, rc, nfound; nfound = 0; - if (isdigit((unsigned char) serv[0])) { /* check for port number string first */ + if (isdigit((unsigned char) serv[0])) { /* check for port number string first */ port = (int) htons((unsigned short) atoi(serv)); if (hintsp->ai_socktype) { /* 4caller specifies socket type */ if ((rc = ga_port(aihead, port, hintsp->ai_socktype)) < 0) - return (EAI_MEMORY); + return (EAI_MEMORY); nfound += rc; } else { /* 4caller does not specify socket type */ if ((rc = ga_port(aihead, port, SOCK_STREAM)) < 0) - return (EAI_MEMORY); + return (EAI_MEMORY); nfound += rc; if ((rc = ga_port(aihead, port, SOCK_DGRAM)) < 0) - return (EAI_MEMORY); + return (EAI_MEMORY); nfound += rc; } } if (nfound == 0) { if (hintsp->ai_socktype == 0) - return (EAI_NONAME); /* all calls to getservbyname() failed */ + return (EAI_NONAME); /* all calls to getservbyname() failed */ else - return (EAI_SERVICE); /* service not supported for socket type */ + return (EAI_SERVICE); /* service not supported for socket type */ } return (0); } @@ -1437,7 +1437,7 @@ /* include ga_port */ int ga_port(struct addrinfo *aihead, int port, int socktype) - /* port must be in network byte order */ + /* port must be in network byte order */ { int nfound = 0; struct addrinfo *ai; @@ -1445,12 +1445,12 @@ for (ai = aihead; ai != NULL; ai = ai->ai_next) { if (ai->ai_flags & AI_CLONE) { if (ai->ai_socktype != 0) { - if ((ai = ga_clone(ai)) == NULL) - return (-1); /* memory allocation error */ - /* ai points to newly cloned entry, which is what we want */ + if ((ai = ga_clone(ai)) == NULL) + return (-1); /* memory allocation error */ + /* ai points to newly cloned entry, which is what we want */ } } else if (ai->ai_socktype != socktype) - continue; /* ignore if mismatch on socket type */ + continue; /* ignore if mismatch on socket type */ ai->ai_socktype = socktype; @@ -1490,7 +1490,7 @@ new->ai_next = ai->ai_next; ai->ai_next = new; - new->ai_flags = 0; /* make sure AI_CLONE is off */ + new->ai_flags = 0; /* make sure AI_CLONE is off */ new->ai_family = ai->ai_family; new->ai_socktype = ai->ai_socktype; new->ai_protocol = ai->ai_protocol; @@ -1504,7 +1504,7 @@ } /* end ga_clone */ -#endif /* HAS_GETADDRINFO */ +#endif /* HAS_GETADDRINFO */ /* * Return a string containing some additional information after an @@ -1542,7 +1542,7 @@ return ("unknown getaddrinfo() error"); } } -#endif /* HAS_GAI_STRERROR */ +#endif /* HAS_GAI_STRERROR */ #ifndef HAS_GETADDRINFO @@ -1554,16 +1554,16 @@ for (ai = aihead; ai != NULL; ai = ainext) { if (ai->ai_addr != NULL) - free(ai->ai_addr); /* socket address structure */ + free(ai->ai_addr); /* socket address structure */ if (ai->ai_canonname != NULL) free(ai->ai_canonname); - ainext = ai->ai_next; /* can't fetch ai_next after free() */ - free(ai); /* the addrinfo{} itself */ + ainext = ai->ai_next; /* can't fetch ai_next after free() */ + free(ai); /* the addrinfo{} itself */ } } /* end freeaddrinfo */ -#endif /* HAS_GETADDRINFO */ +#endif /* HAS_GETADDRINFO */ Index: src/fundb.c =================================================================== --- src/fundb.c (.../p5) (revision 1028) +++ src/fundb.c (.../p6) (revision 1028) @@ -28,18 +28,18 @@ #include "confmagic.h" #ifdef WIN32 -#pragma warning( disable : 4761) /* NJG: disable warning re conversion */ +#pragma warning( disable : 4761) /* NJG: disable warning re conversion */ #endif extern PRIV attr_privs_view[]; static lock_type get_locktype(char *str); extern struct db_stat_info *get_stats(dbref owner); static int lattr_helper(dbref player, dbref thing, dbref parent, - char const *pattern, ATTR *atr, void *args); + char const *pattern, ATTR *atr, void *args); static dbref dbwalk(char *buff, char **bp, dbref executor, dbref enactor, - int type, dbref loc, dbref after, int skipdark, - int start, int count, int *retcount); + int type, dbref loc, dbref after, int skipdark, + int start, int count, int *retcount); const char * @@ -52,9 +52,9 @@ if (a) { if (Can_Read_Attr(executor, thing, a)) { if (strlen(value = atr_value(a)) < BUFFER_LEN) - return value; + return value; else - return T("#-1 ATTRIBUTE LENGTH TOO LONG"); + return T("#-1 ATTRIBUTE LENGTH TOO LONG"); } return T(e_atrperm); } @@ -71,12 +71,12 @@ /** Structure containing arguments for lattr_helper */ struct lh_args { - int first; /**< Is this is the first attribute, or later? */ + int first; /**< Is this is the first attribute, or later? */ int nattr; - int start; /**< Where do we start counting? */ - int count; /**< How many do we count? */ - char *buff; /**< Buffer to store output */ - char **bp; /**< Pointer to address of insertion point in buff */ + int start; /**< Where do we start counting? */ + int count; /**< How many do we count? */ + char *buff; /**< Buffer to store output */ + char **bp; /**< Pointer to address of insertion point in buff */ }; /* this function produces a space-separated list of attributes that are @@ -85,10 +85,10 @@ /* ARGSUSED */ static int lattr_helper(dbref player __attribute__ ((__unused__)), - dbref thing __attribute__ ((__unused__)), - dbref parent __attribute__ ((__unused__)), - char const *pattern __attribute__ ((__unused__)), - ATTR *atr, void *args) + dbref thing __attribute__ ((__unused__)), + dbref parent __attribute__ ((__unused__)), + char const *pattern __attribute__ ((__unused__)), + ATTR *atr, void *args) { struct lh_args *lh = args; lh->nattr++; @@ -109,14 +109,14 @@ { dbref thing; int doparent; - static const char *matchall = "**"; /* count atrees by default too */ + static const char *matchall = "**"; /* count atrees by default too */ char *pattern; pattern = strchr(args[0], '/'); if (pattern) *pattern++ = '\0'; else - pattern = (char *) matchall; /* match anything */ + pattern = (char *) matchall; /* match anything */ thing = match_thing(executor, args[0]); if (!GoodObject(thing)) { @@ -130,7 +130,7 @@ safe_integer(AttrCount(thing), buff, bp); } else { safe_integer(atr_pattern_count(executor, thing, pattern, doparent, - !Can_Examine(executor, thing)), buff, bp); + !Can_Examine(executor, thing)), buff, bp); } } @@ -162,7 +162,7 @@ if (pattern) *pattern++ = '\0'; else - pattern = (char *) "*"; /* match anything */ + pattern = (char *) "*"; /* match anything */ thing = match_thing(executor, args[0]); if (!GoodObject(thing)) { @@ -174,11 +174,11 @@ lh.bp = bp; if (strchr(called_as, 'P')) { (void) atr_iter_get_parent(executor, thing, pattern, - !Can_Examine(executor, thing), lattr_helper, - &lh); + !Can_Examine(executor, thing), lattr_helper, + &lh); } else { (void) atr_iter_get(executor, thing, pattern, - !Can_Examine(executor, thing), lattr_helper, &lh); + !Can_Examine(executor, thing), lattr_helper, &lh); } } @@ -264,7 +264,7 @@ dp = mstr; sp = args[i - 1]; process_expression(mstr, &dp, &sp, executor, caller, enactor, PE_DEFAULT, - PT_DEFAULT, pe_info); + PT_DEFAULT, pe_info); *dp = '\0'; parse_attrib(executor, mstr, &thing, &attrib); if (GoodObject(thing) && attrib && Can_Read_Attr(executor, thing, attrib)) { @@ -278,7 +278,7 @@ /* We couldn't get it. Evaluate the last arg and return it */ sp = args[nargs - 1]; process_expression(buff, bp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); return; } @@ -306,7 +306,7 @@ tp = tbuf = safe_atr_value(a); add_check("fun_eval.attr_value"); process_expression(buff, bp, &tp, thing, executor, executor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); mush_free((Malloc_t) tbuf, "fun_eval.attr_value"); return; } else if (a || !Can_Examine(executor, thing)) { @@ -346,7 +346,7 @@ tp = tbuf = safe_atr_value(a); add_check("fun_eval.attr_value"); process_expression(buff, bp, &tp, thing, executor, executor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); mush_free((Malloc_t) tbuf, "fun_eval.attr_value"); return; } else if (a || !Can_Examine(executor, thing)) { @@ -371,7 +371,7 @@ dp = mstr; sp = args[0]; process_expression(mstr, &dp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); *dp = '\0'; parse_attrib(executor, mstr, &thing, &attrib); if (GoodObject(thing) && attrib && Can_Read_Attr(executor, thing, attrib)) { @@ -383,14 +383,14 @@ sp = sbuf = safe_atr_value(attrib); add_check("fun_edefault.attr_value"); process_expression(buff, bp, &sp, thing, executor, executor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); mush_free((Malloc_t) sbuf, "fun_edefault.attr_value"); return; } /* We couldn't get it. Evaluate args[1] and return it */ sp = args[1]; process_expression(buff, bp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); return; } @@ -414,7 +414,7 @@ case '8': case '9': if (global_eval_context.wenv[c - '0']) - safe_str(global_eval_context.wenv[c - '0'], buff, bp); + safe_str(global_eval_context.wenv[c - '0'], buff, bp); return; case '#': /* enactor dbref */ @@ -513,7 +513,7 @@ } #ifdef WIN32 -#pragma warning( disable : 4761) /* Disable bogus conversion warning */ +#pragma warning( disable : 4761) /* Disable bogus conversion warning */ #endif /* ARGSUSED */ FUNCTION(fun_haspower) @@ -553,7 +553,7 @@ } #ifdef WIN32 -#pragma warning( default : 4761) /* Re-enable conversion warning */ +#pragma warning( default : 4761) /* Re-enable conversion warning */ #endif /* ARGSUSED */ @@ -658,28 +658,28 @@ * use type == TYPE_PLAYER for this check. :-/. */ if (!(Typeof(thing) & type) || - !can_interact(thing, executor, INTERACT_SEE) || - (skipdark && Dark(thing) && !Light(thing) && !Light(loc)) || - ((type == TYPE_PLAYER) && skipdark && !Connected(thing))) - continue; + !can_interact(thing, executor, INTERACT_SEE) || + (skipdark && Dark(thing) && !Light(thing) && !Light(loc)) || + ((type == TYPE_PLAYER) && skipdark && !Connected(thing))) + continue; nthing += 1; if (count < 1 || (nthing >= start && nthing < start + count)) { - if (buff) { - if (first) - first = 0; - else - safe_chr(' ', buff, bp); - safe_dbref(thing, buff, bp); - } + if (buff) { + if (first) + first = 0; + else + safe_chr(' ', buff, bp); + safe_dbref(thing, buff, bp); + } } if (result == NOTHING) { - if (after == NOTHING) - result = thing; - if (after == thing) - after = NOTHING; + if (after == NOTHING) + result = thing; + if (after == thing) + after = NOTHING; } if (retcount) - *retcount = nthing; + *retcount = nthing; } } else if (buff) safe_str("#-1", buff, bp); @@ -727,16 +727,16 @@ } switch (*ptr) { - case 'C': /* con */ + case 'C': /* con */ type = TYPE_THING | TYPE_PLAYER; break; - case 'T': /* things */ + case 'T': /* things */ type = TYPE_THING; break; - case 'P': /* players */ + case 'P': /* players */ type = TYPE_PLAYER; break; - case 'E': /* exits */ + case 'E': /* exits */ type = TYPE_EXIT; break; default: @@ -745,7 +745,7 @@ } dbwalk(buffptr, bptr, executor, enactor, type, loc, NOTHING, - vis, start, count, &result); + vis, start, count, &result); if (!buffptr) { safe_integer(result, buff, bp); @@ -757,8 +757,8 @@ { dbref loc = match_thing(executor, args[0]); safe_dbref(dbwalk - (NULL, NULL, executor, enactor, TYPE_THING | TYPE_PLAYER, loc, - NOTHING, 0, 0, 0, NULL), buff, bp); + (NULL, NULL, executor, enactor, TYPE_THING | TYPE_PLAYER, loc, + NOTHING, 0, 0, 0, NULL), buff, bp); } /* ARGSUSED */ @@ -766,8 +766,8 @@ { dbref loc = match_thing(executor, args[0]); safe_dbref(dbwalk - (NULL, NULL, executor, enactor, TYPE_EXIT, loc, NOTHING, 0, 0, 0, - NULL), buff, bp); + (NULL, NULL, executor, enactor, TYPE_EXIT, loc, NOTHING, 0, 0, 0, + NULL), buff, bp); } /* ARGSUSED */ @@ -779,14 +779,14 @@ switch (Typeof(it)) { case TYPE_EXIT: safe_dbref(dbwalk - (NULL, NULL, executor, enactor, TYPE_EXIT, Source(it), it, 0, - 0, 0, NULL), buff, bp); + (NULL, NULL, executor, enactor, TYPE_EXIT, Source(it), it, 0, + 0, 0, NULL), buff, bp); break; case TYPE_THING: case TYPE_PLAYER: safe_dbref(dbwalk - (NULL, NULL, executor, enactor, TYPE_THING | TYPE_PLAYER, - Location(it), it, 0, 0, 0, NULL), buff, bp); + (NULL, NULL, executor, enactor, TYPE_THING | TYPE_PLAYER, + Location(it), it, 0, 0, 0, NULL), buff, bp); break; default: safe_str("#-1", buff, bp); @@ -812,7 +812,7 @@ dbref counter; dbref entrance; int found; - int exd, td, pd, rd; /* what we're looking for */ + int exd, td, pd, rd; /* what we're looking for */ char *p; if (!command_check_byname(executor, "@entrances")) { @@ -837,27 +837,27 @@ switch (*p) { case 'a': case 'A': - exd = td = pd = rd = 1; - break; + exd = td = pd = rd = 1; + break; case 'e': case 'E': - exd = 1; - break; + exd = 1; + break; case 't': case 'T': - td = 1; - break; + td = 1; + break; case 'p': case 'P': - pd = 1; - break; + pd = 1; + break; case 'r': case 'R': - rd = 1; - break; + rd = 1; + break; default: - safe_str(T("#-1 INVALID SECOND ARGUMENT"), buff, bp); - return; + safe_str(T("#-1 INVALID SECOND ARGUMENT"), buff, bp); + return; } p++; } @@ -896,7 +896,7 @@ } if (!payfor(executor, FIND_COST)) { notify_format(executor, T("You don't have %d %s to do that."), - FIND_COST, ((FIND_COST == 1) ? MONEY : MONIES)); + FIND_COST, ((FIND_COST == 1) ? MONEY : MONIES)); safe_str("#-1", buff, bp); return; } @@ -905,19 +905,19 @@ for (counter = low; counter <= high; counter++) { if (controls(executor, where) || controls(executor, counter)) { if ((exd && IsExit(counter)) || - (td && IsThing(counter)) || - (pd && IsPlayer(counter)) || (rd && IsRoom(counter))) { - if (Mobile(counter)) - entrance = Home(counter); - else - entrance = Location(counter); - if (entrance == where) { - if (!found) - found = 1; - else - safe_chr(' ', buff, bp); - safe_dbref(counter, buff, bp); - } + (td && IsThing(counter)) || + (pd && IsPlayer(counter)) || (rd && IsRoom(counter))) { + if (Mobile(counter)) + entrance = Home(counter); + else + entrance = Location(counter); + if (entrance == where) { + if (!found) + found = 1; + else + safe_chr(' ', buff, bp); + safe_dbref(counter, buff, bp); + } } } } @@ -954,7 +954,7 @@ else if (!GoodObject(thing)) safe_str(T("#-1 ARG2 NOT FOUND"), buff, bp); else if (!(controls(executor, it) || controls(executor, thing) - || See_All(executor))) + || See_All(executor))) safe_str(T(e_perm), buff, bp); else safe_chr(controls(it, thing) ? '1' : '0', buff, bp); @@ -1022,7 +1022,7 @@ default: safe_str("WEIRD OBJECT", buff, bp); do_rawlog(LT_ERR, T("WARNING: Weird object #%d (type %d)\n"), it, - Typeof(it)); + Typeof(it)); } } @@ -1067,27 +1067,27 @@ case 'r': case 'R': if (IsRoom(it)) - found = 1; + found = 1; break; case 'e': case 'E': if (IsExit(it)) - found = 1; + found = 1; break; case 'p': case 'P': if (IsPlayer(it)) - found = 1; + found = 1; break; case 't': case 'T': if (IsThing(it)) - found = 1; + found = 1; break; case 'g': case 'G': if (IsGarbage(it)) - found = 1; + found = 1; break; default: safe_str(T("#-1 NO SUCH TYPE"), buff, bp); @@ -1127,10 +1127,10 @@ dbref it = match_thing(executor, args[0]); if (!strcmp(called_as, "ORLPOWERS")) safe_boolean(flaglist_check_long("POWER", executor, it, args[1], 0), buff, - bp); + bp); else safe_boolean(flaglist_check_long("FLAG", executor, it, args[1], 0), buff, - bp); + bp); } /* ARGSUSED */ @@ -1139,10 +1139,10 @@ dbref it = match_thing(executor, args[0]); if (!strcmp(called_as, "ANDLPOWERS")) safe_boolean(flaglist_check_long("POWER", executor, it, args[1], 1), buff, - bp); + bp); else safe_boolean(flaglist_check_long("FLAG", executor, it, args[1], 1), buff, - bp); + bp); } static lock_type @@ -1191,7 +1191,7 @@ lock_list *ll; lock_type ltype; - if (called_as[1] == 'L') /* LLOCKFLAGS */ + if (called_as[1] == 'L') /* LLOCKFLAGS */ fullname = 1; if (nargs == 0) { @@ -1217,9 +1217,9 @@ ll = getlockstruct(it, ltype); if (ll) { if (fullname) - safe_str(lock_flags_long(ll), buff, bp); + safe_str(lock_flags_long(ll), buff, bp); else - safe_str(lock_flags(ll), buff, bp); + safe_str(lock_flags(ll), buff, bp); return; } else { safe_str("#-1 NO SUCH LOCK", buff, bp); @@ -1274,7 +1274,7 @@ if (GoodObject(it) && (real_ltype != NULL) && Can_Read_Lock(executor, it, real_ltype)) { safe_str(unparse_boolexp(executor, getlock(it, real_ltype), UB_DBREF), - buff, bp); + buff, bp); return; } safe_str("#-1", buff, bp); @@ -1317,7 +1317,7 @@ else if (!GoodObject(victim)) safe_str(T("#-1 ARG2 NOT FOUND"), buff, bp); else if (!See_All(executor) && !controls(executor, obj) && - !controls(executor, victim)) + !controls(executor, victim)) safe_str(T(e_perm), buff, bp); else safe_boolean(Can_Locate(obj, victim), buff, bp); @@ -1419,7 +1419,7 @@ else { for (i = 0; i < deep; i++) { if (!GoodObject(it) || IsRoom(it)) - break; + break; it = Location(it); } safe_dbref(it, buff, bp); @@ -1528,9 +1528,9 @@ if (is_integer(args[0])) { int a = parse_integer(args[0]); if (abs(a) == 1) - safe_str(MONEY, buff, bp); + safe_str(MONEY, buff, bp); else - safe_str(MONIES, buff, bp); + safe_str(MONIES, buff, bp); } else { /* Guess we're just making a typo or something. */ safe_str("#-1", buff, bp); @@ -1562,7 +1562,7 @@ if (strchr(args[0], '/')) { parse_attrib(executor, args[0], &thing, &attrib); if (!GoodObject(thing) || !attrib - || !Can_Read_Attr(executor, thing, attrib)) + || !Can_Read_Attr(executor, thing, attrib)) safe_str("#-1", buff, bp); else safe_dbref(attrib->creator, buff, bp); @@ -1587,7 +1587,7 @@ /* Support changing alias via function if side-effects are enabled */ if (nargs == 2) { if (!command_check_byname(executor, "ATTRIB_SET") - || fun->flags & FN_NOSIDEFX) { + || fun->flags & FN_NOSIDEFX) { safe_str(T(e_perm), buff, bp); return; } @@ -1666,12 +1666,12 @@ if (GoodObject(it)) { /* You must either be see_all, control it, or be inside it */ if (!(controls(executor, it) || See_All(executor) || - (Location(executor) == it))) { + (Location(executor) == it))) { safe_str(T(e_perm), buff, bp); return; } if (nameformat(executor, it, tbuf1, - IsExit(it) ? shortname(it) : (char *) accented_name(it))) + IsExit(it) ? shortname(it) : (char *) accented_name(it))) safe_str(tbuf1, buff, bp); else if (IsExit(it)) safe_str(shortname(it), buff, bp); @@ -1835,7 +1835,7 @@ match_flags |= MAT_ENGLISH; break; case 'X': - ambig_ok = 1; /* okay to pick last match */ + ambig_ok = 1; /* okay to pick last match */ break; default: notify_format(executor, T("I don't understand switch '%c'."), *p); @@ -1872,13 +1872,13 @@ if (Can_Examine(executor, loc)) safe_dbref(item, buff, bp); else if (can_interact(item, executor, INTERACT_SEE) - && (!DarkLegal(item) || Light(loc) || Light(item))) + && (!DarkLegal(item) || Light(loc) || Light(item))) safe_dbref(item, buff, bp); else safe_dbref(NOTHING, buff, bp); } else { if (can_interact(item, executor, INTERACT_SEE) - && (See_All(executor) || !DarkLegal(item) || Light(item))) + && (See_All(executor) || !DarkLegal(item) || Light(item))) safe_dbref(item, buff, bp); else safe_dbref(NOTHING, buff, bp); @@ -2142,10 +2142,10 @@ si = get_stats(who); if (who != ANY_OWNER) { safe_format(buff, bp, "%d %d %d %d %d", si->total - si->garbage, si->rooms, - si->exits, si->things, si->players); + si->exits, si->things, si->players); } else { safe_format(buff, bp, "%d %d %d %d %d %d", si->total, si->rooms, si->exits, - si->things, si->players, si->garbage); + si->things, si->players, si->garbage); } } @@ -2166,9 +2166,9 @@ if (status == 1) { if (FUNCTION_SIDE_EFFECTS) { if (!command_check_byname(executor, "@atrlock") - || fun->flags & FN_NOSIDEFX) { - safe_str(T(e_perm), buff, bp); - return; + || fun->flags & FN_NOSIDEFX) { + safe_str(T(e_perm), buff, bp); + return; } do_atrlock(executor, args[0], args[1]); return; @@ -2189,7 +2189,7 @@ if ((thing = noisy_match_result(executor, args[0], NOTYPE, - MAT_EVERYTHING)) == NOTHING) { + MAT_EVERYTHING)) == NOTHING) { safe_str(T(e_notvis), buff, bp); return; } Index: src/sql.c =================================================================== --- src/sql.c (.../p5) (revision 1028) +++ src/sql.c (.../p6) (revision 1028) @@ -76,11 +76,11 @@ mysql_struct = mysql_init(NULL); if (!mysql_real_connect - (mysql_struct, SQL_HOST, SQL_USER, SQL_PASS, SQL_DB, 3306, 0, 0)) { - do_rawlog(LT_ERR, "Failed mysql connection: %s\n", - mysql_error(mysql_struct)); - sql_shutdown(); - sleep(1); + (mysql_struct, SQL_HOST, SQL_USER, SQL_PASS, SQL_DB, 3306, 0, 0)) { + do_rawlog(LT_ERR, "Failed mysql connection: %s\n", + mysql_error(mysql_struct)); + sql_shutdown(); + sleep(1); } retries--; } @@ -230,7 +230,7 @@ for (i = 0; (i < numfields) && (i < 9); i++) { wenv[i + 1] = row_p[i]; if (!wenv[i + 1]) - wenv[i + 1] = (char *) ""; + wenv[i + 1] = (char *) ""; } /* Now call the ufun. */ if (call_ufun(&ufun, wenv, i + 1, rbuff, executor, enactor, pe_info)) @@ -293,12 +293,12 @@ } for (i = 0; i < numfields; i++) { if (i > 0) { - if (safe_str(fieldsep, buff, bp)) - goto finished; + if (safe_str(fieldsep, buff, bp)) + goto finished; } if (row_p[i] && *row_p[i]) - if (safe_str(row_p[i], buff, bp)) - goto finished; /* We filled the buffer, best stop */ + if (safe_str(row_p[i], buff, bp)) + goto finished; /* We filled the buffer, best stop */ } } finished: @@ -366,9 +366,9 @@ rownum++; if (numfields > 0) { for (i = 0; i < numfields; i++) { - cell = row_p[i]; - notify_format(player, "Row %d, Field %s: %s", - rownum, fields[i].name, (cell && *cell) ? cell : "NULL"); + cell = row_p[i]; + notify_format(player, "Row %d, Field %s: %s", + rownum, fields[i].name, (cell && *cell) ? cell : "NULL"); } } else notify_format(player, "Row %d: NULL", rownum); Index: src/extchat.c =================================================================== --- src/extchat.c (.../p5) (revision 1028) +++ src/extchat.c (.../p6) (revision 1028) @@ -63,9 +63,9 @@ static int yesno(const char *str); static int canstilladd(dbref player); static enum cmatch_type find_channel_partial_on(const char *name, CHAN **chan, - dbref player); + dbref player); static enum cmatch_type find_channel_partial_off(const char *name, CHAN **chan, - dbref player); + dbref player); static char *list_cuflags(CHANUSER *u, int verbose); static void channel_join_self(dbref player, const char *name); static void channel_leave_self(dbref player, const char *name); @@ -73,20 +73,20 @@ void chat_player_announce(dbref player, char *msg, int ungag); static int ok_channel_name(const char *n); static void format_channel_broadcast(CHAN *chan, CHANUSER *u, dbref victim, - int flags, const char *msg, - const char *extra); + int flags, const char *msg, + const char *extra); static void list_partial_matches(dbref player, const char *name, - enum chan_match_type type); + enum chan_match_type type); -const char *chan_speak_lock = "ChanSpeakLock"; /**< Name of speak lock */ -const char *chan_join_lock = "ChanJoinLock"; /**< Name of join lock */ -const char *chan_mod_lock = "ChanModLock"; /**< Name of modify lock */ -const char *chan_see_lock = "ChanSeeLock"; /**< Name of see lock */ -const char *chan_hide_lock = "ChanHideLock"; /**< Name of hide lock */ +const char *chan_speak_lock = "ChanSpeakLock"; /**< Name of speak lock */ +const char *chan_join_lock = "ChanJoinLock"; /**< Name of join lock */ +const char *chan_mod_lock = "ChanModLock"; /**< Name of modify lock */ +const char *chan_see_lock = "ChanSeeLock"; /**< Name of see lock */ +const char *chan_hide_lock = "ChanHideLock"; /**< Name of hide lock */ -#define YES 1 /**< An affirmative. */ -#define NO 0 /**< A negative. */ -#define ERR -1 /**< An error. Clever, eh? */ +#define YES 1 /**< An affirmative. */ +#define NO 0 /**< A negative. */ +#define ERR -1 /**< An error. Clever, eh? */ /** Wrapper for insert_user() that generates a new CHANUSER and inserts it */ #define insert_user_by_dbref(who,chan) \ @@ -97,7 +97,7 @@ int num_channels; /**< Number of channels defined */ -CHAN *channels; /**< Pointer to channel list */ +CHAN *channels; /**< Pointer to channel list */ static PRIV priv_table[] = { {"Disabled", 'D', CHANNEL_DISABLED, CHANNEL_DISABLED}, @@ -256,8 +256,8 @@ if (strcmp(chat_timestamp, db_timestamp)) do_rawlog(LT_ERR, - T - ("CHAT: warning: chatdb and game db were saved at different times!")); + T + ("CHAT: warning: chatdb and game db were saved at different times!")); /* How many channels? */ db_read_this_labeled_number(fp, "channels", &num_channels); @@ -453,11 +453,11 @@ strcpy(CUtitle(user), getstring_noalloc(fp)); CUnext(user) = NULL; if (insert_user(user, ch)) - num++; + num++; } else { /* But be sure to read (and discard) the player's info */ do_log(LT_ERR, 0, 0, T("Bad object #%d removed from channel %s"), - player, ChanName(ch)); + player, ChanName(ch)); (void) getref(fp); (void) getstring_noalloc(fp); } @@ -484,11 +484,11 @@ strcpy(CUtitle(user), tmp); CUnext(user) = NULL; if (insert_user(user, ch)) - num++; + num++; } else { /* But be sure to read (and discard) the player's info */ do_log(LT_ERR, 0, 0, T("Bad object #%d removed from channel %s"), - player, ChanName(ch)); + player, ChanName(ch)); db_read_this_labeled_number(fp, "type", &n); db_read_this_labeled_string(fp, "title", &tmp); } @@ -597,9 +597,9 @@ } else { /* Otherwise, find which channel this channel should be inserted after */ for (; - p->next - && (strcasecoll(ChanName(p->next->chan), ChanName(*ch)) < 0); - p = p->next) ; + p->next + && (strcasecoll(ChanName(p->next->chan), ChanName(*ch)) < 0); + p = p->next) ; if (p->next && !strcasecmp(ChanName(p->next->chan), ChanName(*ch))) { /* Don't add the same channel twice! */ free_chanlist(tmp); @@ -691,9 +691,9 @@ } else { /* Otherwise, find which user this user should be inserted after */ for (; - p->next - && (strcasecoll(Name(CUdbref(p->next)), Name(CUdbref(user))) <= 0); - p = p->next) ; + p->next + && (strcasecoll(Name(CUdbref(p->next)), Name(CUdbref(user))) <= 0); + p = p->next) ; if (CUdbref(p) == CUdbref(user)) { /* Don't add the same user twice! */ mush_free((Malloc_t) user, "CHANUSER"); @@ -871,16 +871,16 @@ if (!strcasecmp(cleanname, cleanp)) { *chan = p; if (Chan_Can_See(*chan, player) || onchannel(player, *chan)) - return CMATCH_EXACT; + return CMATCH_EXACT; else - return CMATCH_NONE; + return CMATCH_NONE; } if (string_prefix(cleanp, name)) { /* Keep the alphabetically first channel if we've got one */ if (Chan_Can_See(p, player) || onchannel(player, p)) { - if (!*chan) - *chan = p; - count++; + if (!*chan) + *chan = p; + count++; } } } @@ -932,7 +932,7 @@ * our best candidate so far. */ if (!*chan || (!onchannel(player, *chan) && onchannel(player, p))) - *chan = p; + *chan = p; count++; } } @@ -963,12 +963,12 @@ if (!Chan_Can_See(p, player)) continue; if ((type == PMATCH_ALL) || ((type == PMATCH_ON) - ? !!onchannel(player, p) - : !onchannel(player, p))) { + ? !!onchannel(player, p) + : !onchannel(player, p))) { strcpy(cleanp, remove_markup(ChanName(p), NULL)); if (string_prefix(cleanp, cleanname)) { - safe_chr(' ', buff, &bp); - safe_str(ChanName(p), buff, &bp); + safe_chr(' ', buff, &bp); + safe_str(ChanName(p), buff, &bp); } } } @@ -1011,13 +1011,13 @@ if (onchannel(player, p)) { strcpy(cleanp, remove_markup(ChanName(p), NULL)); if (!strcasecmp(cleanname, cleanp)) { - *chan = p; - return CMATCH_EXACT; + *chan = p; + return CMATCH_EXACT; } if (string_prefix(cleanp, cleanname) && onchannel(player, p)) { - if (!*chan) - *chan = p; - count++; + if (!*chan) + *chan = p; + count++; } } } @@ -1060,13 +1060,13 @@ if (!onchannel(player, p)) { strcpy(cleanp, remove_markup(ChanName(p), NULL)); if (!strcasecmp(cleanname, cleanp)) { - *chan = p; - return CMATCH_EXACT; + *chan = p; + return CMATCH_EXACT; } if (string_prefix(cleanp, cleanname)) { - if (!*chan) - *chan = p; - count++; + if (!*chan) + *chan = p; + count++; } } } @@ -1133,8 +1133,8 @@ if (!Chan_Can_See(chan, player)) { if (onchannel(player, chan)) notify_format(player, - T("CHAT: You can't do that with channel <%s>."), - ChanName(chan)); + T("CHAT: You can't do that with channel <%s>."), + ChanName(chan)); else notify(player, T("CHAT: I don't recognize that channel.")); return; @@ -1166,8 +1166,8 @@ if (!strcasecmp("on", com) || !strcasecmp("join", com)) { if (!Chan_Ok_Type(chan, victim)) { notify_format(player, - T("Sorry, wrong type of thing for channel <%s>."), - ChanName(chan)); + T("Sorry, wrong type of thing for channel <%s>."), + ChanName(chan)); return; } if (Guest(player)) { @@ -1181,39 +1181,39 @@ /* Is victim already on the channel? */ if (onchannel(victim, chan)) { notify_format(player, - T("%s is already on channel <%s>."), Name(victim), - ChanName(chan)); + T("%s is already on channel <%s>."), Name(victim), + ChanName(chan)); return; } /* Does victim pass the joinlock? */ if (!Chan_Can_Join(chan, victim)) { if (Wizard(player)) { - /* Wizards can override join locks */ - notify(player, - T - ("CHAT: Warning: Target does not meet channel join permissions (joining anyway)")); + /* Wizards can override join locks */ + notify(player, + T + ("CHAT: Warning: Target does not meet channel join permissions (joining anyway)")); } else { - notify(player, T("Permission to join denied.")); - return; + notify(player, T("Permission to join denied.")); + return; } } if (insert_user_by_dbref(victim, chan)) { notify_format(victim, - T("CHAT: %s joins you to channel <%s>."), Name(player), - ChanName(chan)); + T("CHAT: %s joins you to channel <%s>."), Name(player), + ChanName(chan)); notify_format(player, - T("CHAT: You join %s to channel <%s>."), Name(victim), - ChanName(chan)); + T("CHAT: You join %s to channel <%s>."), Name(victim), + ChanName(chan)); u = onchannel(victim, chan); if (!Channel_Quiet(chan) && !DarkLegal(victim)) { - format_channel_broadcast(chan, u, victim, CB_CHECKQUIET | CB_PRESENCE, - T("<%s> %s has joined this channel."), NULL); + format_channel_broadcast(chan, u, victim, CB_CHECKQUIET | CB_PRESENCE, + T("<%s> %s has joined this channel."), NULL); } ChanNumUsers(chan)++; } else { notify_format(player, - T("%s is already on channel <%s>."), Name(victim), - ChanName(chan)); + T("%s is already on channel <%s>."), Name(victim), + ChanName(chan)); } return; } else if (!strcasecmp("off", com) || !strcasecmp("leave", com)) { @@ -1231,19 +1231,19 @@ strcpy(title, (u &&CUtitle(u)) ? CUtitle(u) : ""); if (remove_user(u, chan)) { if (!Channel_Quiet(chan) && !DarkLegal(victim)) { - format_channel_broadcast(chan, NULL, victim, - CB_CHECKQUIET | CB_PRESENCE, - T("<%s> %s has left this channel."), title); + format_channel_broadcast(chan, NULL, victim, + CB_CHECKQUIET | CB_PRESENCE, + T("<%s> %s has left this channel."), title); } notify_format(victim, - T("CHAT: %s removes you from channel <%s>."), - Name(player), ChanName(chan)); + T("CHAT: %s removes you from channel <%s>."), + Name(player), ChanName(chan)); notify_format(player, - T("CHAT: You remove %s from channel <%s>."), - Name(victim), ChanName(chan)); + T("CHAT: You remove %s from channel <%s>."), + Name(victim), ChanName(chan)); } else { notify_format(player, T("%s is not on channel <%s>."), Name(victim), - ChanName(chan)); + ChanName(chan)); } return; } else { @@ -1267,7 +1267,7 @@ case CMATCH_NONE: if (find_channel_partial_on(name, &chan, player)) notify_format(player, T("CHAT: You are already on channel <%s>"), - ChanName(chan)); + ChanName(chan)); else notify(player, T("CHAT: I don't recognize that channel.")); return; @@ -1284,8 +1284,8 @@ } if (!Chan_Ok_Type(chan, player)) { notify_format(player, - T("Sorry, wrong type of thing for channel <%s>."), - ChanName(chan)); + T("Sorry, wrong type of thing for channel <%s>."), + ChanName(chan)); return; } /* Does victim pass the joinlock? */ @@ -1293,8 +1293,8 @@ if (Wizard(player)) { /* Wizards can override join locks */ notify(player, - T - ("CHAT: Warning: You don't meet channel join permissions (joining anyway)")); + T + ("CHAT: Warning: You don't meet channel join permissions (joining anyway)")); } else { notify(player, T("Permission to join denied.")); return; @@ -1305,13 +1305,13 @@ u = onchannel(player, chan); if (!Channel_Quiet(chan) && !DarkLegal(player)) format_channel_broadcast(chan, u, player, CB_CHECKQUIET | CB_PRESENCE, - T("<%s> %s has joined this channel."), NULL); + T("<%s> %s has joined this channel."), NULL); ChanNumUsers(chan)++; } else { /* Should never happen */ notify_format(player, - T("%s is already on channel <%s>."), Name(player), - ChanName(chan)); + T("%s is already on channel <%s>."), Name(player), + ChanName(chan)); } } @@ -1329,9 +1329,9 @@ switch (find_channel_partial_on(name, &chan, player)) { case CMATCH_NONE: if (find_channel_partial_off(name, &chan, player) - && Chan_Can_See(chan, player)) + && Chan_Can_See(chan, player)) notify_format(player, T("CHAT: You are not on channel <%s>"), - ChanName(chan)); + ChanName(chan)); else notify(player, T("CHAT: I don't recognize that channel.")); return; @@ -1347,12 +1347,12 @@ if (remove_user(u, chan)) { if (!Channel_Quiet(chan) && !DarkLegal(player)) format_channel_broadcast(chan, NULL, player, CB_CHECKQUIET | CB_PRESENCE, - T("<%s> %s has left this channel."), title); + T("<%s> %s has left this channel."), title); notify_format(player, T("CHAT: You leave channel <%s>."), ChanName(chan)); } else { /* Should never happen */ notify_format(player, T("%s is not on channel <%s>."), Name(player), - ChanName(chan)); + ChanName(chan)); } } @@ -1437,8 +1437,8 @@ notify(player, T("CHAT: I don't know which channel you mean.")); list_partial_matches(player, name, PMATCH_ON); notify(player, - T - ("CHAT: You may wish to set the CHAN_USEFIRSTMATCH flag on yourself.")); + T + ("CHAT: You may wish to set the CHAN_USEFIRSTMATCH flag on yourself.")); return 1; } case CMATCH_EXACT: @@ -1448,7 +1448,7 @@ case CMATCH_NONE: if (find_channel(name, &c, player) == CMATCH_NONE) { if (source) - notify(player, T("CHAT: No such channel.")); + notify(player, T("CHAT: No such channel.")); return 0; } } @@ -1474,16 +1474,16 @@ if (!Chan_Ok_Type(chan, player)) { notify_format(player, - T - ("Sorry, you're not the right type to be on channel <%s>."), - ChanName(chan)); + T + ("Sorry, you're not the right type to be on channel <%s>."), + ChanName(chan)); return; } if (!Loud(player) && !Chan_Can_Speak(chan, player)) { if (Chan_Can_See(chan, player)) notify_format(player, - T("Sorry, you're not allowed to speak on channel <%s>."), - ChanName(chan)); + T("Sorry, you're not allowed to speak on channel <%s>."), + ChanName(chan)); else notify(player, T("No such channel.")); return; @@ -1526,26 +1526,26 @@ case POSE_TOKEN: arg1 = arg1 + 1; channel_broadcast(chan, player, 0, "<%s> %s%s%s%s%s%s", ChanName(chan), - title ? title : "", title ? ANSI_NORMAL : "", - (title && name) ? " " : "", name ? name : "", gap, arg1); + title ? title : "", title ? ANSI_NORMAL : "", + (title && name) ? " " : "", name ? name : "", gap, arg1); if (!canhear) notify_format(player, T("To channel %s: %s%s%s%s%s%s"), ChanName(chan), - title ? title : "", title ? ANSI_NORMAL : "", - (title && name) ? " " : "", name ? name : "", gap, arg1); + title ? title : "", title ? ANSI_NORMAL : "", + (title && name) ? " " : "", name ? name : "", gap, arg1); break; default: if (CHAT_STRIP_QUOTE && (*arg1 == SAY_TOKEN)) arg1 = arg1 + 1; channel_broadcast(chan, player, 0, T("<%s> %s%s%s%s says, \"%s\""), - ChanName(chan), title ? title : "", - title ? ANSI_NORMAL : "", (title && name) ? " " : "", - name ? name : "", arg1); + ChanName(chan), title ? title : "", + title ? ANSI_NORMAL : "", (title && name) ? " " : "", + name ? name : "", arg1); if (!canhear) notify_format(player, - T("To channel %s: %s%s%s%s says, \"%s\""), - ChanName(chan), title ? title : "", - title ? ANSI_NORMAL : "", (title && name) ? " " : "", - name ? name : "", arg1); + T("To channel %s: %s%s%s%s says, \"%s\""), + ChanName(chan), title ? title : "", + title ? ANSI_NORMAL : "", (title && name) ? " " : "", + name ? name : "", arg1); break; } @@ -1596,15 +1596,15 @@ override_checks = 1; if (!override_checks && !Chan_Ok_Type(chan, player)) { notify_format(player, - T - ("Sorry, you're not the right type to be on channel <%s>."), - ChanName(chan)); + T + ("Sorry, you're not the right type to be on channel <%s>."), + ChanName(chan)); return; } if (!override_checks && !Chan_Can_Cemit(chan, player)) { notify_format(player, - T("Sorry, you're not allowed to @cemit on channel <%s>."), - ChanName(chan)); + T("Sorry, you're not allowed to @cemit on channel <%s>."), + ChanName(chan)); return; } u = onchannel(player, chan); @@ -1626,10 +1626,10 @@ } if (!(flags & PEMIT_SILENT)) channel_broadcast(chan, player, (flags & PEMIT_SPOOF) ? 0 : CB_NOSPOOF, - "<%s> %s", ChanName(chan), msg); + "<%s> %s", ChanName(chan), msg); else channel_broadcast(chan, player, (flags & PEMIT_SPOOF) ? 0 : CB_NOSPOOF, - "%s", msg); + "%s", msg); if (!canhear) notify_format(player, T("Cemit to channel %s: %s"), ChanName(chan), msg); ChanNumMsgs(chan)++; @@ -1709,7 +1709,7 @@ /* Can the player afford it? There's a cost */ if (!payfor(Owner(player), CHANNEL_COST)) { notify_format(player, T("You can't afford the %d %s."), CHANNEL_COST, - MONIES); + MONIES); return; } /* Ok, let's do it */ @@ -1765,8 +1765,8 @@ * itself */ if (temp != chan) { - notify(player, T("The channel needs a more unique new name.")); - return; + notify(player, T("The channel needs a more unique new name.")); + return; } } if (strlen(perms) > CHAN_NAME_LEN - 1) { @@ -1779,8 +1779,8 @@ strcpy(ChanName(chan), perms); insert_channel(&chan); channel_broadcast(chan, player, 0, - "<%s> %s has renamed channel %s to %s.", - ChanName(chan), Name(player), old, ChanName(chan)); + "<%s> %s has renamed channel %s to %s.", + ChanName(chan), Name(player), old, ChanName(chan)); notify(player, T("Channel renamed.")); break; case 3: @@ -1799,13 +1799,13 @@ notify(player, T("Warning: channel will be disabled.")); if (type == ChanType(chan)) { notify_format(player, - T - ("Invalid or same permissions on channel <%s>. No changes made."), - ChanName(chan)); + T + ("Invalid or same permissions on channel <%s>. No changes made."), + ChanName(chan)); } else { ChanType(chan) = type; notify_format(player, - T("Permissions on channel <%s> changed."), ChanName(chan)); + T("Permissions on channel <%s> changed."), ChanName(chan)); } break; } @@ -1856,7 +1856,7 @@ */ void do_chan_user_flags(dbref player, char *name, const char *isyn, int flag, - int silent) + int silent) { CHAN *c = NULL; CHANUSER *u; @@ -1874,15 +1874,15 @@ switch (flag) { case 0: notify(player, setting ? T("All channels have been muted.") - : T("All channels have been unmuted.")); + : T("All channels have been unmuted.")); break; case 1: notify(player, setting ? T("You hide on all the channels you can.") - : T("You unhide on all channels.")); + : T("You unhide on all channels.")); break; case 2: notify(player, setting ? T("All channels have been gagged.") - : T("All channels have been ungagged.")); + : T("All channels have been ungagged.")); break; } } else { @@ -1903,7 +1903,7 @@ if (!u) { /* This should only happen if they gave us a bad name */ if (!silent) - notify_format(player, T("You are not on channel <%s>."), ChanName(c)); + notify_format(player, T("You are not on channel <%s>."), ChanName(c)); return; } @@ -1911,61 +1911,61 @@ case 0: /* Mute */ if (setting) { - CUtype(u) |= CU_QUIET; - if (!silent) - notify_format(player, - T - ("You will no longer hear connection messages on channel <%s>."), - ChanName(c)); + CUtype(u) |= CU_QUIET; + if (!silent) + notify_format(player, + T + ("You will no longer hear connection messages on channel <%s>."), + ChanName(c)); } else { - CUtype(u) &= ~CU_QUIET; - if (!silent) - notify_format(player, - T - ("You will now hear connection messages on channel <%s>."), - ChanName(c)); + CUtype(u) &= ~CU_QUIET; + if (!silent) + notify_format(player, + T + ("You will now hear connection messages on channel <%s>."), + ChanName(c)); } break; case 1: /* Hide */ if (setting) { - if (!Chan_Can_Hide(c, player) && !Wizard(player)) { - if (!silent) - notify_format(player, - T("You are not permitted to hide on channel <%s>."), - ChanName(c)); - } else { - CUtype(u) |= CU_HIDE; - if (!silent) - notify_format(player, - T - ("You no longer appear on channel <%s>'s who list."), - ChanName(c)); - } + if (!Chan_Can_Hide(c, player) && !Wizard(player)) { + if (!silent) + notify_format(player, + T("You are not permitted to hide on channel <%s>."), + ChanName(c)); + } else { + CUtype(u) |= CU_HIDE; + if (!silent) + notify_format(player, + T + ("You no longer appear on channel <%s>'s who list."), + ChanName(c)); + } } else { - CUtype(u) &= ~CU_HIDE; - if (!silent) - notify_format(player, - T("You now appear on channel <%s>'s who list."), - ChanName(c)); + CUtype(u) &= ~CU_HIDE; + if (!silent) + notify_format(player, + T("You now appear on channel <%s>'s who list."), + ChanName(c)); } break; case 2: /* Gag */ if (setting) { - CUtype(u) |= CU_GAG; - if (!silent) - notify_format(player, - T - ("You will no longer hear messages on channel <%s>."), - ChanName(c)); + CUtype(u) |= CU_GAG; + if (!silent) + notify_format(player, + T + ("You will no longer hear messages on channel <%s>."), + ChanName(c)); } else { - CUtype(u) &= ~CU_GAG; - if (!silent) - notify_format(player, - T("You will now hear messages on channel <%s>."), - ChanName(c)); + CUtype(u) &= ~CU_GAG; + if (!silent) + notify_format(player, + T("You will now hear messages on channel <%s>."), + ChanName(c)); } break; } @@ -2003,7 +2003,7 @@ /* Stomp newlines and other weird whitespace */ for (scan = title; *scan; scan++) { if ((isspace((unsigned char) *scan) && (*scan != ' ')) - || (*scan == BEEP_CHAR)) { + || (*scan == BEEP_CHAR)) { notify(player, T("Invalid character in title.")); return; } @@ -2017,8 +2017,8 @@ strcpy(CUtitle(u), title); if (!Quiet(player)) notify_format(player, T("Title %s for %schannel <%s>."), - *title ? T("set") : T("cleared"), - Channel_NoTitles(c) ? "(NoTitles) " : "", ChanName(c)); + *title ? T("set") : T("cleared"), + Channel_NoTitles(c) ? "(NoTitles) " : "", ChanName(c)); return; } @@ -2044,18 +2044,18 @@ if (SUPPORT_PUEBLO) notify_noenter(player, tprintf("%cSAMP%c", TAG_START, TAG_END)); notify_format(player, "%-30s %-5s %8s %-16s %-8s %-3s", - "Name", "Users", "Msgs", T("Chan Type"), "Status", "Buf"); + "Name", "Users", "Msgs", T("Chan Type"), "Status", "Buf"); for (c = channels; c; c = c->next) { strcpy(cleanname, remove_markup(ChanName(c), NULL)); if (Chan_Can_See(c, player) && string_prefix(cleanname, partname)) { u = onchannel(player, c); if (SUPPORT_PUEBLO) - sprintf(numusers, - "%cA XCH_CMD=\"@channel/who %s\" XCH_HINT=\"See who's on this channel now\"%c%5ld%c/A%c", - TAG_START, cleanname, TAG_END, ChanNumUsers(c), - TAG_START, TAG_END); + sprintf(numusers, + "%cA XCH_CMD=\"@channel/who %s\" XCH_HINT=\"See who's on this channel now\"%c%5ld%c/A%c", + TAG_START, cleanname, TAG_END, ChanNumUsers(c), + TAG_START, TAG_END); else - sprintf(numusers, "%5ld", ChanNumUsers(c)); + sprintf(numusers, "%5ld", ChanNumUsers(c)); /* Display length is strlen(cleanname), but actual length is * strlen(ChanName(c)). There are two different cases: * 1. actual length <= 30. No problems. @@ -2066,37 +2066,37 @@ len = strlen(ChanName(c)); numblanks = len - strlen(cleanname); if (numblanks > 0 && numblanks < CHAN_NAME_LEN) { - memset(blanks, ' ', CHAN_NAME_LEN - 1); - if (len > 30) - numblanks -= (len - 30); - if (numblanks < 0) - numblanks = 0; - blanks[numblanks] = '\0'; + memset(blanks, ' ', CHAN_NAME_LEN - 1); + if (len > 30) + numblanks -= (len - 30); + if (numblanks < 0) + numblanks = 0; + blanks[numblanks] = '\0'; } else { - blanks[0] = '\0'; + blanks[0] = '\0'; } notify_format(player, - "%-30s%s %s %8ld [%c%c%c%c%c%c%c %c%c%c%c%c%c] [%-3s %c%c] %3d", - ChanName(c), blanks, numusers, ChanNumMsgs(c), - Channel_Disabled(c) ? 'D' : '-', - Channel_Player(c) ? 'P' : '-', - Channel_Object(c) ? 'O' : '-', - Channel_Admin(c) ? 'A' : (Channel_Wizard(c) ? 'W' : '-'), - Channel_Quiet(c) ? 'Q' : '-', - Channel_CanHide(c) ? 'H' : '-', Channel_Open(c) ? 'o' : '-', - /* Locks */ - ChanJoinLock(c) != TRUE_BOOLEXP ? 'j' : '-', - ChanSpeakLock(c) != TRUE_BOOLEXP ? 's' : '-', - ChanModLock(c) != TRUE_BOOLEXP ? 'm' : '-', - ChanSeeLock(c) != TRUE_BOOLEXP ? 'v' : '-', - ChanHideLock(c) != TRUE_BOOLEXP ? 'h' : '-', - /* Does the player own it? */ - ChanCreator(c) == player ? '*' : '-', - /* User status */ - u ? (Chanuser_Gag(u) ? "Gag" : "On") : "Off", - (u &&Chanuser_Quiet(u)) ? 'Q' : ' ', - (u &&Chanuser_Hide(u)) ? 'H' : ' ', - bufferq_lines(ChanBufferQ(c))); + "%-30s%s %s %8ld [%c%c%c%c%c%c%c %c%c%c%c%c%c] [%-3s %c%c] %3d", + ChanName(c), blanks, numusers, ChanNumMsgs(c), + Channel_Disabled(c) ? 'D' : '-', + Channel_Player(c) ? 'P' : '-', + Channel_Object(c) ? 'O' : '-', + Channel_Admin(c) ? 'A' : (Channel_Wizard(c) ? 'W' : '-'), + Channel_Quiet(c) ? 'Q' : '-', + Channel_CanHide(c) ? 'H' : '-', Channel_Open(c) ? 'o' : '-', + /* Locks */ + ChanJoinLock(c) != TRUE_BOOLEXP ? 'j' : '-', + ChanSpeakLock(c) != TRUE_BOOLEXP ? 's' : '-', + ChanModLock(c) != TRUE_BOOLEXP ? 'm' : '-', + ChanSeeLock(c) != TRUE_BOOLEXP ? 'v' : '-', + ChanHideLock(c) != TRUE_BOOLEXP ? 'h' : '-', + /* Does the player own it? */ + ChanCreator(c) == player ? '*' : '-', + /* User status */ + u ? (Chanuser_Gag(u) ? "Gag" : "On") : "Off", + (u &&Chanuser_Quiet(u)) ? 'Q' : ' ', + (u &&Chanuser_Hide(u)) ? 'H' : ' ', + bufferq_lines(ChanBufferQ(c))); } } if (SUPPORT_PUEBLO) @@ -2158,9 +2158,9 @@ } if (nargs == 1) { if (string_prefix(called_as, "CL")) - safe_str(privs_to_string(priv_table, ChanType(c)), buff, bp); + safe_str(privs_to_string(priv_table, ChanType(c)), buff, bp); else - safe_str(privs_to_letters(priv_table, ChanType(c)), buff, bp); + safe_str(privs_to_letters(priv_table, ChanType(c)), buff, bp); return; } thing = match_thing(executor, args[1]); @@ -2207,9 +2207,9 @@ safe_str(ChanTitle(c), buff, bp); } else if (string_prefix(called_as, "CB")) { if (ChanBufferQ(c) != NULL) { - safe_integer(BufferQSize(ChanBufferQ(c)), buff, bp); + safe_integer(BufferQSize(ChanBufferQ(c)), buff, bp); } else { - safe_integer(0, buff, bp); + safe_integer(0, buff, bp); } } else if (string_prefix(called_as, "CU")) { safe_integer(ChanNumUsers(c), buff, bp); @@ -2262,9 +2262,9 @@ u = onchannel(thing, c); if (!u) { if (can_ex || ok) - safe_str(T("#-1 NOT ON CHANNEL"), buff, bp); + safe_str(T("#-1 NOT ON CHANNEL"), buff, bp); else - safe_str(T("#-1 PERMISSION DENIED"), buff, bp); + safe_str(T("#-1 PERMISSION DENIED"), buff, bp); return; } ok &= !Chanuser_Hide(u); @@ -2319,7 +2319,7 @@ } /* They're on the channel, but maybe we can't see them? */ if (Chanuser_Hide(u) && - !(Priv_Who(executor) || Can_Examine(executor, thing))) { + !(Priv_Who(executor) || Can_Examine(executor, thing))) { safe_str("Off", buff, bp); return; } @@ -2368,7 +2368,7 @@ victim = CUdbref(u); if (remove_user(u, chan)) notify_format(victim, T("CHAT: %s has removed all users from <%s>."), - Name(player), ChanName(chan)); + Name(player), ChanName(chan)); } ChanNumUsers(chan) = 0; return; @@ -2430,8 +2430,8 @@ */ chan_chown(c, victim); notify_format(player, - T("CHAT: Channel <%s> now owned by %s."), ChanName(c), - Name(ChanCreator(c))); + T("CHAT: Channel <%s> now owned by %s."), ChanName(c), + Name(ChanCreator(c))); return; } @@ -2523,36 +2523,36 @@ free_boolexp(ChanJoinLock(c)); ChanJoinLock(c) = key; notify_format(player, (key == TRUE_BOOLEXP) ? - T("CHAT: Joinlock on <%s> reset.") : - T("CHAT: Joinlock on <%s> set."), ChanName(c)); + T("CHAT: Joinlock on <%s> reset.") : + T("CHAT: Joinlock on <%s> set."), ChanName(c)); break; case CL_SPEAK: free_boolexp(ChanSpeakLock(c)); ChanSpeakLock(c) = key; notify_format(player, (key == TRUE_BOOLEXP) ? - T("CHAT: Speaklock on <%s> reset.") : - T("CHAT: Speaklock on <%s> set."), ChanName(c)); + T("CHAT: Speaklock on <%s> reset.") : + T("CHAT: Speaklock on <%s> set."), ChanName(c)); break; case CL_SEE: free_boolexp(ChanSeeLock(c)); ChanSeeLock(c) = key; notify_format(player, (key == TRUE_BOOLEXP) ? - T("CHAT: Seelock on <%s> reset.") : - T("CHAT: Seelock on <%s> set."), ChanName(c)); + T("CHAT: Seelock on <%s> reset.") : + T("CHAT: Seelock on <%s> set."), ChanName(c)); break; case CL_HIDE: free_boolexp(ChanHideLock(c)); ChanHideLock(c) = key; notify_format(player, (key == TRUE_BOOLEXP) ? - T("CHAT: Hidelock on <%s> reset.") : - T("CHAT: Hidelock on <%s> set."), ChanName(c)); + T("CHAT: Hidelock on <%s> reset.") : + T("CHAT: Hidelock on <%s> set."), ChanName(c)); break; case CL_MOD: free_boolexp(ChanModLock(c)); ChanModLock(c) = key; notify_format(player, (key == TRUE_BOOLEXP) ? - T("CHAT: Modlock on <%s> reset.") : - T("CHAT: Modlock on <%s> set."), ChanName(c)); + T("CHAT: Modlock on <%s> reset.") : + T("CHAT: Modlock on <%s> set."), ChanName(c)); break; } return; @@ -2582,12 +2582,12 @@ notify_format(player, T("Description: %s"), ChanTitle(c)); notify_format(player, T("Owner: %s"), Name(ChanCreator(c))); notify_format(player, T("Flags: %s"), - privs_to_string(priv_table, ChanType(c))); + privs_to_string(priv_table, ChanType(c))); if (ChanBufferQ(c)) - notify_format(player, - T("Recall buffer: %dk, with %d lines stored."), - BufferQSize(ChanBufferQ(c)), - bufferq_lines(ChanBufferQ(c))); + notify_format(player, + T("Recall buffer: %dk, with %d lines stored."), + BufferQSize(ChanBufferQ(c)), + bufferq_lines(ChanBufferQ(c))); found++; } } @@ -2621,44 +2621,44 @@ if (string_prefix(cleanp, cleanname)) { found++; if (!(See_All(player) || Chan_Can_Modify(c, player) - || (ChanCreator(c) == player))) { - if (Chan_Can_See(c, player)) - notify_format(player, T("CHAT: No permission to decompile <%s>"), - ChanName(c)); - continue; + || (ChanCreator(c) == player))) { + if (Chan_Can_See(c, player)) + notify_format(player, T("CHAT: No permission to decompile <%s>"), + ChanName(c)); + continue; } notify_format(player, "@channel/add %s = %s", ChanName(c), - privs_to_string(priv_table, ChanType(c))); + privs_to_string(priv_table, ChanType(c))); notify_format(player, "@channel/chown %s = %s", ChanName(c), - Name(ChanCreator(c))); + Name(ChanCreator(c))); if (ChanModLock(c) != TRUE_BOOLEXP) - notify_format(player, "@clock/mod %s = %s", ChanName(c), - unparse_boolexp(player, ChanModLock(c), UB_MEREF)); + notify_format(player, "@clock/mod %s = %s", ChanName(c), + unparse_boolexp(player, ChanModLock(c), UB_MEREF)); if (ChanHideLock(c) != TRUE_BOOLEXP) - notify_format(player, "@clock/hide %s = %s", ChanName(c), - unparse_boolexp(player, ChanHideLock(c), UB_MEREF)); + notify_format(player, "@clock/hide %s = %s", ChanName(c), + unparse_boolexp(player, ChanHideLock(c), UB_MEREF)); if (ChanJoinLock(c) != TRUE_BOOLEXP) - notify_format(player, "@clock/join %s = %s", ChanName(c), - unparse_boolexp(player, ChanJoinLock(c), UB_MEREF)); + notify_format(player, "@clock/join %s = %s", ChanName(c), + unparse_boolexp(player, ChanJoinLock(c), UB_MEREF)); if (ChanSpeakLock(c) != TRUE_BOOLEXP) - notify_format(player, "@clock/speak %s = %s", ChanName(c), - unparse_boolexp(player, ChanSpeakLock(c), UB_MEREF)); + notify_format(player, "@clock/speak %s = %s", ChanName(c), + unparse_boolexp(player, ChanSpeakLock(c), UB_MEREF)); if (ChanSeeLock(c) != TRUE_BOOLEXP) - notify_format(player, "@clock/see %s = %s", ChanName(c), - unparse_boolexp(player, ChanSeeLock(c), UB_MEREF)); + notify_format(player, "@clock/see %s = %s", ChanName(c), + unparse_boolexp(player, ChanSeeLock(c), UB_MEREF)); if (ChanTitle(c)) - notify_format(player, "@channel/desc %s = %s", ChanName(c), - ChanTitle(c)); + notify_format(player, "@channel/desc %s = %s", ChanName(c), + ChanTitle(c)); if (ChanBufferQ(c)) - notify_format(player, "@channel/buffer %s = %d", ChanName(c), - bufferq_lines(ChanBufferQ(c))); + notify_format(player, "@channel/buffer %s = %d", ChanName(c), + bufferq_lines(ChanBufferQ(c))); if (!brief) { - for (u = ChanUsers(c); u; u = u->next) { - if (!Chanuser_Hide(u) || Priv_Who(player)) + for (u = ChanUsers(c); u; u = u->next) { + if (!Chanuser_Hide(u) || Priv_Who(player)) - notify_format(player, "@channel/on %s = %s", ChanName(c), - Name(CUdbref(u))); - } + notify_format(player, "@channel/on %s = %s", ChanName(c), + Name(CUdbref(u))); + } } } } @@ -2678,18 +2678,18 @@ for (u = ChanUsers(chan); u; u = u->next) { who = CUdbref(u); if ((IsThing(who) || Connected(who)) && - (!Chanuser_Hide(u) || Priv_Who(player))) { + (!Chanuser_Hide(u) || Priv_Who(player))) { i++; safe_itemizer(i, !(u->next), ",", T("and"), " ", tbuf1, &bp); safe_str(Name(who), tbuf1, &bp); if (IsThing(who)) - safe_format(tbuf1, &bp, "(#%d)", who); + safe_format(tbuf1, &bp, "(#%d)", who); if (Chanuser_Hide(u) && Chanuser_Gag(u)) - safe_str(" (hidden,gagging)", tbuf1, &bp); + safe_str(" (hidden,gagging)", tbuf1, &bp); else if (Chanuser_Hide(u)) - safe_str(" (hidden)", tbuf1, &bp); + safe_str(" (hidden)", tbuf1, &bp); else if (Chanuser_Gag(u)) - safe_str(" (gagging)", tbuf1, &bp); + safe_str(" (gagging)", tbuf1, &bp); } } *bp = '\0'; @@ -2740,11 +2740,11 @@ for (u = ChanUsers(chan); u; u = u->next) { who = CUdbref(u); if ((IsThing(who) || Connected(who)) && - (!Chanuser_Hide(u) || Priv_Who(executor))) { + (!Chanuser_Hide(u) || Priv_Who(executor))) { if (first) - first = 0; + first = 0; else - safe_chr(' ', buff, bp); + safe_chr(' ', buff, bp); safe_dbref(who, buff, bp); } } @@ -2780,11 +2780,11 @@ if (!title || !*title) { ChanTitle(c)[0] = '\0'; notify_format(player, T("CHAT: Channel <%s> description cleared."), - ChanName(c)); + ChanName(c)); } else { strcpy(ChanTitle(c), title); notify_format(player, T("CHAT: Channel <%s> description set."), - ChanName(c)); + ChanName(c)); } } @@ -2852,16 +2852,16 @@ u = onchannel(player, c); if (u) { if (!Channel_Quiet(c) && (Channel_Admin(c) || Channel_Wizard(c) - || (!Chanuser_Hide(u) && !Dark(player)))) { - bp = buff; + || (!Chanuser_Hide(u) && !Dark(player)))) { + bp = buff; - safe_format(buff, &bp, "<%s> %s", "%s", msg); - *bp = '\0'; - format_channel_broadcast(c, u, player, CB_CHECKQUIET | CB_PRESENCE, - buff, NULL); + safe_format(buff, &bp, "<%s> %s", "%s", msg); + *bp = '\0'; + format_channel_broadcast(c, u, player, CB_CHECKQUIET | CB_PRESENCE, + buff, NULL); } if (ungag) - CUtype(u) &= ~CU_GAG; + CUtype(u) &= ~CU_GAG; } } } @@ -2912,35 +2912,35 @@ if (GoodObject(it)) { int first = 1; if (!delim_check(buff, bp, nargs, args, 2, &sep)) - return; + return; can_ex = Can_Examine(executor, it); for (cl = Chanlist(it); cl; cl = cl->next) { - if (can_ex || ((u = onchannel(it, cl->chan)) &&!Chanuser_Hide(u) - && onchannel(executor, cl->chan))) { - if (!first) - safe_chr(sep, buff, bp); - safe_str(ChanName(cl->chan), buff, bp); - first = 0; - } + if (can_ex || ((u = onchannel(it, cl->chan)) &&!Chanuser_Hide(u) + && onchannel(executor, cl->chan))) { + if (!first) + safe_chr(sep, buff, bp); + safe_str(ChanName(cl->chan), buff, bp); + first = 0; + } } return; } else { /* args[0] didn't match. Maybe it's a delimiter? */ if (arglens[0] > 1) { - if (it == NOTHING) - notify(executor, T("I can't see that here.")); - else if (it == AMBIGUOUS) - notify(executor, T("I don't know which thing you mean.")); - return; + if (it == NOTHING) + notify(executor, T("I can't see that here.")); + else if (it == AMBIGUOUS) + notify(executor, T("I don't know which thing you mean.")); + return; } else if (!delim_check(buff, bp, nargs, args, 1, &sep)) - return; + return; } } /* No arguments (except maybe delimiter) - return list of all channels */ for (c = channels; c; c = c->next) { if (Chan_Can_See(c, executor)) { if (c != channels) - safe_chr(sep, buff, bp); + safe_chr(sep, buff, bp); safe_str(ChanName(c), buff, bp); } } @@ -2994,8 +2994,8 @@ if (nargs == 2) { if (FUNCTION_SIDE_EFFECTS) { if (!command_check_byname(executor, "@clock") || fun->flags & FN_NOSIDEFX) { - safe_str(T(e_perm), buff, bp); - return; + safe_str(T(e_perm), buff, bp); + return; } do_chan_lock(executor, args[0], args[1], which_lock); return; @@ -3114,27 +3114,27 @@ start--; } while ((buf = iter_bufferq(ChanBufferQ(chan), &p, &speaker, &type, - ×tamp)) && num_lines > 0) { + ×tamp)) && num_lines > 0) { if (first) first = 0; else safe_chr(sep, buff, bp); if (Nospoof(executor) && GoodObject(speaker)) { char *nsmsg = ns_esnotify(speaker, na_one, &executor, - Paranoid(executor) ? 1 : 0); + Paranoid(executor) ? 1 : 0); if (!showstamp) - safe_format(buff, bp, T("%s %s"), nsmsg, buf); + safe_format(buff, bp, T("%s %s"), nsmsg, buf); else { - stamp = show_time(timestamp, 0); - safe_format(buff, bp, T("[%s] %s %s"), stamp, nsmsg, buf); + stamp = show_time(timestamp, 0); + safe_format(buff, bp, T("[%s] %s %s"), stamp, nsmsg, buf); } mush_free(nsmsg, "string"); } else { if (!showstamp) - safe_str(buf, buff, bp); + safe_str(buf, buff, bp); else { - stamp = show_time(timestamp, 0); - safe_format(buff, bp, T("[%s] %s"), stamp, buf); + stamp = show_time(timestamp, 0); + safe_format(buff, bp, T("[%s] %s"), stamp, buf); } } num_lines--; @@ -3239,8 +3239,8 @@ current = CUdbref(u); nu = u->next; cont = (!GoodObject(current) || - (nac->checkquiet && Chanuser_Quiet(u)) || - Chanuser_Gag(u) || (IsPlayer(current) && !Connected(current))); + (nac->checkquiet && Chanuser_Quiet(u)) || + Chanuser_Gag(u) || (IsPlayer(current) && !Connected(current))); } while (cont); nac->u = nu; return current; @@ -3260,7 +3260,7 @@ #ifdef HAS_VSNPRINTF char tbuf1[BUFFER_LEN]; #else - char tbuf1[BUFFER_LEN * 2]; /* Safety margin as per tprintf */ + char tbuf1[BUFFER_LEN * 2]; /* Safety margin as per tprintf */ #endif struct na_cpass nac; int na_flags = NA_INTER_LOCK; @@ -3284,10 +3284,10 @@ if (Channel_Interact(channel)) na_flags |= (flags & CB_PRESENCE) ? NA_INTER_PRESENCE : NA_INTER_HEAR; notify_anything(player, na_channel, &nac, ns_esnotify, - na_flags | ((flags & CB_NOSPOOF) ? 0 : NA_SPOOF), tbuf1); + na_flags | ((flags & CB_NOSPOOF) ? 0 : NA_SPOOF), tbuf1); if (ChanBufferQ(channel)) add_to_bufferq(ChanBufferQ(channel), 0, - (flags & CB_NOSPOOF) ? player : NOTHING, tbuf1); + (flags & CB_NOSPOOF) ? player : NOTHING, tbuf1); } @@ -3309,7 +3309,7 @@ CHANUSER *u; const char *lines; const char *startpos; - int num_lines = 10; /* Default if none is given */ + int num_lines = 10; /* Default if none is given */ int start = -1; int all; char *p = NULL, *buf; @@ -3334,7 +3334,7 @@ if (is_integer(lines)) { num_lines = parse_integer(lines); if (num_lines == 0) - num_lines = INT_MAX; + num_lines = INT_MAX; } else { notify(player, T("How many lines did you want to recall?")); return; @@ -3349,8 +3349,8 @@ if (!Chan_Can_See(chan, player)) { if (onchannel(player, chan)) notify_format(player, - T("CHAT: You can't do that with channel <%s>."), - ChanName(chan)); + T("CHAT: You can't do that with channel <%s>."), + ChanName(chan)); else notify(player, T("CHAT: I don't recognize that channel.")); return; @@ -3379,23 +3379,23 @@ start--; } while ((buf = iter_bufferq(ChanBufferQ(chan), &p, &speaker, &type, - ×tamp)) && num_lines > 0) { + ×tamp)) && num_lines > 0) { if (Nospoof(player) && GoodObject(speaker)) { char *nsmsg = ns_esnotify(speaker, na_one, &player, - Paranoid(player) ? 1 : 0); + Paranoid(player) ? 1 : 0); if (quiet) - notify_format(player, T("%s %s"), nsmsg, buf); + notify_format(player, T("%s %s"), nsmsg, buf); else { - stamp = show_time(timestamp, 0); - notify_format(player, T("[%s] %s %s"), stamp, nsmsg, buf); + stamp = show_time(timestamp, 0); + notify_format(player, T("[%s] %s %s"), stamp, nsmsg, buf); } mush_free(nsmsg, "string"); } else { if (quiet) - notify(player, buf); + notify(player, buf); else { - stamp = show_time(timestamp, 0); - notify_format(player, T("[%s] %s"), stamp, buf); + stamp = show_time(timestamp, 0); + notify_format(player, T("[%s] %s"), stamp, buf); } } num_lines--; @@ -3403,9 +3403,9 @@ notify(player, T("CHAT: End recall")); if (!all) notify_format(player, - T - ("CHAT: To recall the entire buffer, use @chan/recall %s=0"), - ChanName(chan)); + T + ("CHAT: To recall the entire buffer, use @chan/recall %s=0"), + ChanName(chan)); } /** Set the size of a channel's buffer in maximum lines. @@ -3445,27 +3445,27 @@ free_bufferq(ChanBufferQ(chan)); ChanBufferQ(chan) = NULL; notify_format(player, - T - ("CHAT: Channel buffering disabled for channel <%s>."), - ChanName(chan)); + T + ("CHAT: Channel buffering disabled for channel <%s>."), + ChanName(chan)); } else { notify_format(player, - T - ("CHAT: Channel buffering already disabled for channel <%s>."), - ChanName(chan)); + T + ("CHAT: Channel buffering already disabled for channel <%s>."), + ChanName(chan)); } } else { if (ChanBufferQ(chan)) { /* Resize a buffer */ ChanBufferQ(chan) = reallocate_bufferq(ChanBufferQ(chan), size); notify_format(player, - T("CHAT: Resizing buffer of channel <%s>"), ChanName(chan)); + T("CHAT: Resizing buffer of channel <%s>"), ChanName(chan)); } else { /* Start a new buffer */ ChanBufferQ(chan) = allocate_bufferq(size); notify_format(player, - T("CHAT: Buffering enabled on channel <%s>."), - ChanName(chan)); + T("CHAT: Buffering enabled on channel <%s>."), + ChanName(chan)); } } } @@ -3474,8 +3474,8 @@ in it. */ static void format_channel_broadcast(CHAN *chan, CHANUSER *u, - dbref victim, int flags, - const char *msg, const char *extra) + dbref victim, int flags, + const char *msg, const char *extra) { const char *title = NULL; if (extra && *extra) Index: src/utils.c =================================================================== --- src/utils.c (.../p5) (revision 1028) +++ src/utils.c (.../p6) (revision 1028) @@ -30,7 +30,7 @@ #endif #ifdef WIN32 #include -#include /* For GetCurrentProcessId() */ +#include /* For GetCurrentProcessId() */ #endif #include "conf.h" @@ -48,7 +48,7 @@ dbref find_entrance(dbref door); void initialize_mt(void); -static unsigned long genrand_int32(void); +unsigned int genrand_int32(void); static void init_genrand(unsigned long); static void init_by_array(unsigned long *, int); @@ -67,7 +67,7 @@ ptr = malloc(size); if (ptr == NULL) do_log(LT_ERR, 0, 0, "mush_malloc failed to malloc %lu bytes for %s", - (unsigned long) size, check); + (unsigned long) size, check); return ptr; } @@ -79,7 +79,7 @@ */ void mush_free(Malloc_t RESTRICT ptr, const char *RESTRICT check - __attribute__ ((__unused__))) + __attribute__ ((__unused__))) { del_check(check); free(ptr); @@ -140,9 +140,10 @@ } else { *attrib = mush_malloc(sizeof(ATTR), "anon_attr"); AL_CREATOR(*attrib) = player; - AL_NAME(*attrib) = strdup("#lambda"); + AL_NAME(*attrib) = mush_strdup("#lambda", "anon_attr.lambda"); t = compress(str); (*attrib)->data = chunk_create(t, (u_int_16) u_strlen(t), 0); + free(t); AL_FLAGS(*attrib) = AF_ANON; AL_NEXT(*attrib) = NULL; *thing = player; @@ -159,7 +160,7 @@ free_anon_attrib(ATTR *attrib) { if (attrib && (AL_FLAGS(attrib) & AF_ANON)) { - free((char *) AL_NAME(attrib)); + mush_free((void *) AL_NAME(attrib), "anon_attr.lambda"); chunk_delete(attrib->data); mush_free(attrib, "anon_attr"); } @@ -171,14 +172,14 @@ */ int fetch_ufun_attrib(char *attrname, dbref executor, ufun_attrib * ufun, - int accept_lambda) + int accept_lambda) { ATTR *attrib; dbref thing; int pe_flags = PE_UDEFAULT; if (!ufun) - return 0; /* We should never NOT receive a ufun. */ + return 0; /* We should never NOT receive a ufun. */ ufun->errmess = (char *) ""; /* find our object and attribute */ @@ -245,7 +246,7 @@ */ int call_ufun(ufun_attrib * ufun, char **wenv_args, int wenv_argc, char *ret, - dbref executor, dbref enactor, PE_Info * pe_info) + dbref executor, dbref enactor, PE_Info * pe_info) { char rbuff[BUFFER_LEN]; char *rp; @@ -298,7 +299,7 @@ ap = ufun->contents; pe_ret = process_expression(ret, &rp, &ap, ufun->thing, executor, - enactor, ufun->pe_flags, PT_DEFAULT, pe_info); + enactor, ufun->pe_flags, PT_DEFAULT, pe_info); *rp = '\0'; /* Restore the old wenv */ @@ -332,9 +333,9 @@ if (IsRoom(room)) { thing = Exits(room); while (thing != NOTHING) { - if (thing == door) - return room; - thing = Next(thing); + if (thing == door) + return room; + thing = Next(thing); } } return NOTHING; @@ -357,8 +358,8 @@ /* have to find it */ DOLIST(prev, first) { if (Next(prev) == what) { - Next(prev) = Next(what); - return first; + Next(prev) = Next(what); + return first; } } return first; @@ -484,7 +485,7 @@ close(fd); if (r <= 0) { do_rawlog(LT_ERR, - "Couldn't read from /dev/urandom! Resorting to normal seeding method."); + "Couldn't read from /dev/urandom! Resorting to normal seeding method."); } else { do_rawlog(LT_ERR, "Seeded RNG from /dev/urandom"); init_by_array(buf, r / sizeof(unsigned long)); @@ -492,7 +493,7 @@ } } else do_rawlog(LT_ERR, - "Couldn't open /dev/urandom to seed random number generator. Resorting to normal seeding method."); + "Couldn't open /dev/urandom to seed random number generator. Resorting to normal seeding method."); #endif /* Default seeder. Pick a seed that's fairly random */ @@ -522,12 +523,12 @@ /* Period parameters */ #define M 397 /**< PRNG constant */ -#define MATRIX_A 0x9908b0dfUL /**< PRNG constant vector a */ -#define UPPER_MASK 0x80000000UL /**< PRNG most significant w-r bits */ -#define LOWER_MASK 0x7fffffffUL /**< PRNG least significant r bits */ +#define MATRIX_A 0x9908b0dfUL /**< PRNG constant vector a */ +#define UPPER_MASK 0x80000000UL /**< PRNG most significant w-r bits */ +#define LOWER_MASK 0x7fffffffUL /**< PRNG least significant r bits */ -static unsigned long mt[N]; /* the array for the state vector */ -static int mti = N + 1; /* mti==N+1 means mt[N] is not initialized */ +static unsigned long mt[N]; /* the array for the state vector */ +static int mti = N + 1; /* mti==N+1 means mt[N] is not initialized */ /** initializes mt[N] with a seed. * \param a seed value. @@ -561,8 +562,8 @@ k = (N > key_length ? N : key_length); for (; k; k--) { mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1664525UL)) - + init_key[j] + j; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + + init_key[j] + j; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; j++; if (i >= N) { @@ -574,8 +575,8 @@ } for (k = N - 1; k; k--) { mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1566083941UL)) - - i; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + - i; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; if (i >= N) { mt[0] = mt[N - 1]; @@ -583,22 +584,22 @@ } } - mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ + mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ } /* generates a random number on [0,0xffffffff]-interval */ -static unsigned long +unsigned int genrand_int32(void) { unsigned long y; static unsigned long mag01[2] = { 0x0UL, MATRIX_A }; /* mag01[x] = x * MATRIX_A for x=0,1 */ - if (mti >= N) { /* generate N words at one time */ + if (mti >= N) { /* generate N words at one time */ int kk; - if (mti == N + 1) /* if init_genrand() has not been called, */ - init_genrand(5489UL); /* a default initial seed is used */ + if (mti == N + 1) /* if init_genrand() has not been called, */ + init_genrand(5489UL); /* a default initial seed is used */ for (kk = 0; kk < N - M; kk++) { y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); @@ -683,11 +684,13 @@ char * fullalias(dbref it) { - static char n[BUFFER_LEN]; /* STATIC */ + static char n[BUFFER_LEN]; /* STATIC */ ATTR *a = atr_get_noparent(it, "ALIAS"); - if (!a) - return '\0'; + if (!a) { + n[0] = '\0'; + return n; + } strncpy(n, atr_value(a), BUFFER_LEN - 1); n[BUFFER_LEN - 1] = '\0'; @@ -703,12 +706,14 @@ char * shortalias(dbref it) { - static char n[BUFFER_LEN]; /* STATIC */ + static char n[BUFFER_LEN]; /* STATIC */ char *s; s = fullalias(it); - if (!(s && *s)) - return '\0'; + if (!(s && *s)) { + n[0] = '\0'; + return n; + } strncpy(n, s, BUFFER_LEN - 1); n[BUFFER_LEN - 1] = '\0'; @@ -726,7 +731,7 @@ char * shortname(dbref it) { - static char n[BUFFER_LEN]; /* STATIC */ + static char n[BUFFER_LEN]; /* STATIC */ char *s; strncpy(n, Name(it), BUFFER_LEN - 1); Index: src/malias.c =================================================================== --- src/malias.c (.../p5) (revision 1028) +++ src/malias.c (.../p6) (revision 1028) @@ -33,7 +33,7 @@ * \endverbatim */ -#define MA_INC 3 /**< How many maliases we malloc at a time */ +#define MA_INC 3 /**< How many maliases we malloc at a time */ #include "config.h" #include "copyrite.h" @@ -66,7 +66,7 @@ int ma_size = 0; /**< Number of maliases */ -int ma_top = 0; /**< Top of alias array */ +int ma_top = 0; /**< Top of alias array */ struct mail_alias *malias; /**< Pointer to linked list of aliases */ /** Privilege table for maliases. */ @@ -144,8 +144,8 @@ } if (*alias != MALIAS_TOKEN) { notify_format(player, - T("MAIL: All Mail aliases must begin with '%c'."), - MALIAS_TOKEN); + T("MAIL: All Mail aliases must begin with '%c'."), + MALIAS_TOKEN); return; } good = "`$_-.'"; @@ -158,8 +158,8 @@ return; } } - m = get_malias(GOD, alias); /* GOD can see all aliases */ - if (m) { /* Ensures no duplicates! */ + m = get_malias(GOD, alias); /* GOD can see all aliases */ + if (m) { /* Ensures no duplicates! */ notify_format(player, T("MAIL: Mail Alias '%s' already exists."), alias); return; } @@ -167,12 +167,12 @@ ma_size = MA_INC; malias = (struct mail_alias *) mush_malloc(sizeof(struct mail_alias) * - ma_size, "malias_list"); + ma_size, "malias_list"); } else if (ma_top >= ma_size) { ma_size += MA_INC; m = (struct mail_alias *) mush_malloc(sizeof(struct mail_alias) * - (ma_size), "malias_list"); + (ma_size), "malias_list"); memcpy(m, malias, sizeof(struct mail_alias) * ma_top); mush_free((Malloc_t) malias, "malias_list"); malias = m; @@ -189,13 +189,13 @@ tail = head; while (*tail && (*tail != ' ')) { if (*tail == '"') { - head++; - tail++; - while (*tail && (*tail != '"')) - tail++; + head++; + tail++; + while (*tail && (*tail != '"')) + tail++; } if (*tail) - tail++; + tail++; } tail--; if (*tail != '"') @@ -272,18 +272,18 @@ for (i = 0; i < ma_top; i++) { m = &malias[i]; if ((m->owner == player) || (m->nflags == 0) || - ((m->nflags & ALIAS_ADMIN) && Hasprivs(player)) || - ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))) { + ((m->nflags & ALIAS_ADMIN) && Hasprivs(player)) || + ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))) { if (!notified) { - notify_format(player, "%-13s %-35s %s %-15s", - T("Name"), T("Alias Description"), T("Use See"), - T("Owner")); - notified++; + notify_format(player, "%-13s %-35s %s %-15s", + T("Name"), T("Alias Description"), T("Use See"), + T("Owner")); + notified++; } notify_format(player, - "%c%-12.12s %-35.35s %s %-15.15s", MALIAS_TOKEN, m->name, - uncompress((unsigned char *) (m->desc)), get_shortprivs(m), - Name(m->owner)); + "%c%-12.12s %-35.35s %s %-15.15s", MALIAS_TOKEN, m->name, + uncompress((unsigned char *) (m->desc)), get_shortprivs(m), + Name(m->owner)); } } @@ -346,28 +346,28 @@ m = get_malias(executor, args[0]); if (m) { if (!delim_check(buff, bp, nargs, args, 2, &sep)) - return; + return; if ((m->owner == executor) || (m->mflags == 0) || - (Hasprivs(executor)) || - ((m->mflags & ALIAS_MEMBERS) && ismember(m, executor))) { - for (i = 0; i < m->size; i++) { - if (count++) - safe_chr(sep, buff, bp); - safe_dbref(m->members[i], buff, bp); - } + (Hasprivs(executor)) || + ((m->mflags & ALIAS_MEMBERS) && ismember(m, executor))) { + for (i = 0; i < m->size; i++) { + if (count++) + safe_chr(sep, buff, bp); + safe_dbref(m->members[i], buff, bp); + } } else { - safe_str(T(e_perm), buff, bp); + safe_str(T(e_perm), buff, bp); } return; } else { /* Perhaps it's a delimiter? */ if (arglens[0] > 1) { - /* Oops, not if it's longer than one character */ - safe_str(T(e_match), buff, bp); - return; + /* Oops, not if it's longer than one character */ + safe_str(T(e_match), buff, bp); + return; } if (!delim_check(buff, bp, nargs, args, 1, &sep)) - return; + return; } @@ -376,10 +376,10 @@ for (i = 0; i < ma_top; i++) { m = &malias[i]; if ((m->owner == executor) || (m->nflags == 0) || - ((m->nflags & ALIAS_ADMIN) && Hasprivs(executor)) || - ((m->nflags & ALIAS_MEMBERS) && ismember(m, executor))) { + ((m->nflags & ALIAS_ADMIN) && Hasprivs(executor)) || + ((m->nflags & ALIAS_MEMBERS) && ismember(m, executor))) { if (count++) - safe_chr(sep, buff, bp); + safe_chr(sep, buff, bp); safe_chr(MALIAS_TOKEN, buff, bp); safe_str(m->name, buff, bp); } @@ -405,7 +405,7 @@ return; } else if (Wizard(player) || (player == m->owner)) { if (m->desc) - free(m->desc); /* No need to update MEM_CHECK records here */ + free(m->desc); /* No need to update MEM_CHECK records here */ m->desc = compress(desc); notify(player, T("MAIL: Description changed.")); } else @@ -437,8 +437,8 @@ return; } else { if ((no = lookup_player(owner)) == NOTHING) { - notify(player, T("MAIL: I cannot find that player.")); - return; + notify(player, T("MAIL: I cannot find that player.")); + return; } m->owner = no; notify(player, T("MAIL: Owner changed for alias.")); @@ -467,8 +467,8 @@ } if (*newname != MALIAS_TOKEN) { notify_format(player, - T("MAIL: Bad alias. Aliases must start with '%c'."), - MALIAS_TOKEN); + T("MAIL: Bad alias. Aliases must start with '%c'."), + MALIAS_TOKEN); return; } if (get_malias(GOD, newname) != NULL) { @@ -480,7 +480,7 @@ return; } - free(m->name); /* No need to update MEM_CHECK records here. */ + free(m->name); /* No need to update MEM_CHECK records here. */ m->name = strdup(newname + 1); notify(player, T("MAIL: Mail Alias renamed.")); @@ -502,8 +502,8 @@ m = get_malias(player, alias); if (!m) { notify(player, - T - ("MAIL: Not a valid alias. Remember to prefix the alias name with *.")); + T + ("MAIL: Not a valid alias. Remember to prefix the alias name with *.")); return; } if (Wizard(player) || (m->owner == player)) { @@ -542,9 +542,9 @@ m = get_malias(player, alias); if (!m) { notify_format(player, - T - ("MAIL: Not a valid alias. Remember to prefix the alias name with %c."), - MALIAS_TOKEN); + T + ("MAIL: Not a valid alias. Remember to prefix the alias name with %c."), + MALIAS_TOKEN); return; } if (!tolist || !*tolist) { @@ -566,13 +566,13 @@ tail = head; while (*tail && (*tail != ' ')) { if (*tail == '"') { - head++; - tail++; - while (*tail && (*tail != '"')) - tail++; + head++; + tail++; + while (*tail && (*tail != '"')) + tail++; } if (*tail) - tail++; + tail++; } tail--; if (*tail != '"') @@ -641,14 +641,14 @@ return; } notify(player, - "Num Name Description Owner Count"); + "Num Name Description Owner Count"); for (i = 0; i < ma_top; i++) { m = &malias[i]; notify_format(player, "#%-4d %c%-10.10s %-40.40s %-11.11s (%3d)", - i, MALIAS_TOKEN, m->name, - uncompress((unsigned char *) m->desc), - Name(m->owner), m->size); + i, MALIAS_TOKEN, m->name, + uncompress((unsigned char *) m->desc), + Name(m->owner), m->size); } notify(player, T("***** End of Mail Aliases *****")); @@ -670,7 +670,7 @@ notify(player, T("MAIL: Permission denied.")); else { notify_format(player, - T("MAIL: Number of mail aliases defined: %d"), ma_top); + T("MAIL: Number of mail aliases defined: %d"), ma_top); notify_format(player, T("MAIL: Allocated slots %d"), ma_size); } } @@ -691,15 +691,15 @@ notify(player, T("MAIL: Only god can do that!")); return; } - if (ma_size) { /* aliases defined ? */ + if (ma_size) { /* aliases defined ? */ for (i = 0; i < ma_top; i++) { m = &malias[i]; if (m->name) - mush_free(m->name, "malias_name"); + mush_free(m->name, "malias_name"); if (m->desc) - mush_free(m->desc, "malias_desc"); + mush_free(m->desc, "malias_desc"); if (m->members) - mush_free((Malloc_t) m->members, "malias_members"); + mush_free((Malloc_t) m->members, "malias_members"); } mush_free((Malloc_t) malias, "malias_list"); } @@ -734,8 +734,8 @@ p = type ? &m->mflags : &m->nflags; *p = string_to_privs(malias_priv_table, privs, 0); notify_format(player, - T("MAIL: Permission to see/use alias '%s' changed to %s"), - alias, privs_to_string(malias_priv_table, *p)); + T("MAIL: Permission to see/use alias '%s' changed to %s"), + alias, privs_to_string(malias_priv_table, *p)); } @@ -776,13 +776,13 @@ tail = head; while (*tail && (*tail != ' ')) { if (*tail == '"') { - head++; - tail++; - while (*tail && (*tail != '"')) - tail++; + head++; + tail++; + while (*tail && (*tail != '"')) + tail++; } if (*tail) - tail++; + tail++; } tail--; if (*tail != '"') @@ -802,14 +802,14 @@ notify_format(player, T("MAIL: No such player '%s'."), head); } else { if (ismember(m, target)) { - notify_format(player, - T("MAIL: player '%s' exists already in alias %s."), - head, alias); + notify_format(player, + T("MAIL: player '%s' exists already in alias %s."), + head, alias); } else { - buff = unparse_object(player, target); - notify_format(player, T("MAIL: %s added to alias %s"), buff, alias); - alist[i] = target; - i++; + buff = unparse_object(player, target); + notify_format(player, T("MAIL: %s added to alias %s"), buff, alias); + alist[i] = target; + i++; } } /* @@ -882,13 +882,13 @@ tail = head; while (*tail && (*tail != ' ')) { if (*tail == '"') { - head++; - tail++; - while (*tail && (*tail != '"')) - tail++; + head++; + tail++; + while (*tail && (*tail != '"')) + tail++; } if (*tail) - tail++; + tail++; } tail--; if (*tail != '"') @@ -908,12 +908,12 @@ notify_format(player, T("MAIL: No such player '%s'."), head); } else { if (!(i = ismember(m, target))) { - notify_format(player, T("MAIL: player '%s' is not in alias %s."), - head, alias); + notify_format(player, T("MAIL: player '%s' is not in alias %s."), + head, alias); } else { - buff = unparse_object(player, target); - m->members[i - 1] = m->members[--m->size]; - notify_format(player, T("MAIL: %s removed from alias %s"), buff, alias); + buff = unparse_object(player, target); + m->members[i - 1] = m->members[--m->size]; + notify_format(player, T("MAIL: %s removed from alias %s"), buff, alias); } } /* @@ -981,7 +981,7 @@ int i; for (i = 0; i < m->size; i++) { if (player == m->members[i]) - return (i + 1); /* To avoid entry "0" */ + return (i + 1); /* To avoid entry "0" */ } return 0; } @@ -1024,12 +1024,12 @@ for (i = 0; i < ma_top; i++) { m = &malias[i]; if ((m->owner == player) || (m->nflags == 0) || - /* ((m->nflags & ALIAS_ADMIN) && Hasprivs(player)) || */ - Hasprivs(player) || - ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))) { + /* ((m->nflags & ALIAS_ADMIN) && Hasprivs(player)) || */ + Hasprivs(player) || + ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))) { if (!strcasecmp(mal, m->name)) - return m; + return m; } } return NULL; @@ -1061,7 +1061,7 @@ if (ma_top > 0) malias = (struct mail_alias *) mush_malloc(sizeof(struct mail_alias) * - ma_size, "malias_list"); + ma_size, "malias_list"); else malias = NULL; @@ -1079,9 +1079,9 @@ if (m->size > 0) { m->members = - (dbref *) mush_malloc(m->size * sizeof(dbref), "malias_members"); + (dbref *) mush_malloc(m->size * sizeof(dbref), "malias_members"); for (j = 0; j < m->size; j++) { - m->members[j] = getref(fp); + m->members[j] = getref(fp); } } else { m->members = NULL; Index: src/myssl.c =================================================================== --- src/myssl.c (.../p5) (revision 1028) +++ src/myssl.c (.../p6) (revision 1028) @@ -28,7 +28,7 @@ #define MAXHOSTNAMELEN 32 #define LC_MESSAGES 6 void shutdown_checkpoint(void); -#else /* !WIN32 */ +#else /* !WIN32 */ #ifdef I_SYS_FILE #include #endif @@ -52,7 +52,7 @@ #ifdef I_SYS_STAT #include #endif -#endif /* !WIN32 */ +#endif /* !WIN32 */ #include #ifdef I_SYS_WAIT #include @@ -73,6 +73,7 @@ #include #include #include +#include #include "conf.h" #include "mysocket.h" @@ -82,13 +83,13 @@ #include "parse.h" #include "confmagic.h" -#define MYSSL_RB 0x1 /**< Read blocked (on read) */ -#define MYSSL_WB 0x2 /**< Write blocked (on write) */ -#define MYSSL_RBOW 0x4 /**< Read blocked (on write) */ -#define MYSSL_WBOR 0x8 /**< Write blocked (on read) */ -#define MYSSL_ACCEPT 0x10 /**< We need to call SSL_accept (again) */ -#define MYSSL_VERIFIED 0x20 /**< This is an authenticated connection */ -#define MYSSL_HANDSHAKE 0x40 /**< We need to call SSL_do_handshake */ +#define MYSSL_RB 0x1 /**< Read blocked (on read) */ +#define MYSSL_WB 0x2 /**< Write blocked (on write) */ +#define MYSSL_RBOW 0x4 /**< Read blocked (on write) */ +#define MYSSL_WBOR 0x8 /**< Write blocked (on read) */ +#define MYSSL_ACCEPT 0x10 /**< We need to call SSL_accept (again) */ +#define MYSSL_VERIFIED 0x20 /**< This is an authenticated connection */ +#define MYSSL_HANDSHAKE 0x40 /**< We need to call SSL_do_handshake */ #undef MYSSL_DEBUG #ifdef MYSSL_DEBUG @@ -105,6 +106,8 @@ static BIO *bio_err = NULL; static SSL_CTX *ctx = NULL; +unsigned int genrand_int32(void); + /** Initialize the SSL context. * \return pointer to SSL context object. */ @@ -113,6 +116,8 @@ { SSL_METHOD *meth; unsigned char context[128]; + DH *dh; + unsigned int reps = 1; if (!bio_err) { if (!SSL_library_init()) @@ -121,11 +126,23 @@ /* Error write context */ bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); } -#ifndef HAS_DEV_URANDOM - /* We need to seed the RNG with RAND_seed() or RAND_egd() here. - * Where are we going to get an unpredictable seed? - */ -#endif + + do_rawlog(LT_ERR, "Seeding OpenSSL random number pool."); + while (!RAND_status()) { + /* At this point, a system with /dev/urandom or a EGD file in the usual + places will have enough entropy. Otherwise, be lazy and use random numbers + until it's satisfied. */ + unsigned int gibberish[4]; + int n; + + for (n = 0; n < 4; n++) + gibberish[n] = genrand_int32(); + + RAND_seed(gibberish, sizeof gibberish); + + reps += 1; + } + do_rawlog(LT_ERR, "Seeded after %u %s.", reps, reps > 1 ? "cycles" : "cycle"); /* Set up SIGPIPE handler here? */ @@ -137,11 +154,11 @@ if (private_key_file && *private_key_file) { if (!SSL_CTX_use_certificate_chain_file(ctx, private_key_file)) { ssl_errordump - ("Unable to load server certificate - only anonymous ciphers supported."); + ("Unable to load server certificate - only anonymous ciphers supported."); } if (!SSL_CTX_use_PrivateKey_file(ctx, private_key_file, SSL_FILETYPE_PEM)) { ssl_errordump - ("Unable to load private key - only anonymous ciphers supported."); + ("Unable to load private key - only anonymous ciphers supported."); } } @@ -151,11 +168,11 @@ ssl_errordump("Unable to load CA certificates"); } else { if (req_client_cert) - SSL_CTX_set_verify(ctx, - SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, - client_verify_callback); + SSL_CTX_set_verify(ctx, + SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, + client_verify_callback); else - SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, client_verify_callback); + SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, client_verify_callback); #if (OPENSSL_VERSION_NUMBER < 0x0090600fL) SSL_CTX_set_verify_depth(ctx, 1); #endif @@ -164,11 +181,14 @@ SSL_CTX_set_options(ctx, SSL_OP_SINGLE_DH_USE | SSL_OP_ALL); SSL_CTX_set_mode(ctx, - SSL_MODE_ENABLE_PARTIAL_WRITE | - SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); + SSL_MODE_ENABLE_PARTIAL_WRITE | + SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); /* Set up DH callback */ + dh = get_dh1024(); SSL_CTX_set_tmp_dh(ctx, get_dh1024()); + /* The above function makes a private copy of this */ + DH_free(dh); /* Set the cipher list to the usual default list, except that * we'll allow anonymous diffie-hellman, too. @@ -199,7 +219,7 @@ X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256); if (!preverify_ok) { do_log(LT_ERR, 0, 0, "verify error:num=%d:%s:depth=%d:%s\n", err, - X509_verify_cert_error_string(err), depth, buf); + X509_verify_cert_error_string(err), depth, buf); if (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT) { X509_NAME_oneline(X509_get_issuer_name(x509_ctx->current_cert), buf, 256); do_log(LT_ERR, 0, 0, "issuer= %s\n", buf); @@ -422,10 +442,10 @@ /* Successful accept - report it */ if ((peer = SSL_get_peer_certificate(ssl))) { if (SSL_get_verify_result(ssl) == X509_V_OK) { - /* The client sent a certificate which verified OK */ - X509_NAME_oneline(X509_get_subject_name(peer), buf, 256); - do_log(LT_CONN, 0, 0, "SSL client certificate accepted: %s", buf); - state |= MYSSL_VERIFIED; + /* The client sent a certificate which verified OK */ + X509_NAME_oneline(X509_get_subject_name(peer), buf, 256); + do_log(LT_CONN, 0, 0, "SSL client certificate accepted: %s", buf); + state |= MYSSL_VERIFIED; } } } @@ -446,7 +466,7 @@ */ int ssl_read(SSL * ssl, int state, int net_read_ready, int net_write_ready, - char *buf, int bufsize, int *bytes_read) + char *buf, int bufsize, int *bytes_read) { if ((net_read_ready && !(state & MYSSL_WBOR)) || (net_write_ready && (state & MYSSL_RBOW))) { @@ -455,27 +475,27 @@ *bytes_read = SSL_read(ssl, buf, bufsize); switch (SSL_get_error(ssl, *bytes_read)) { case SSL_ERROR_NONE: - /* Yay */ - return state; + /* Yay */ + return state; case SSL_ERROR_ZERO_RETURN: - /* End of data on this socket */ - return -1; + /* End of data on this socket */ + return -1; case SSL_ERROR_WANT_READ: - /* More needs to be read from the underlying socket */ - ssl_debugdump("SSL_read wants read"); - state |= MYSSL_RB; - break; + /* More needs to be read from the underlying socket */ + ssl_debugdump("SSL_read wants read"); + state |= MYSSL_RB; + break; case SSL_ERROR_WANT_WRITE: - /* More needs to be written to the underlying socket. - * This can happen during a rehandshake. - */ - ssl_debugdump("SSL_read wants write"); - state |= MYSSL_RBOW; - break; + /* More needs to be written to the underlying socket. + * This can happen during a rehandshake. + */ + ssl_debugdump("SSL_read wants write"); + state |= MYSSL_RBOW; + break; default: - /* Should never happen */ - ssl_errordump("Unknown ssl_read failure!"); - return -1; + /* Should never happen */ + ssl_errordump("Unknown ssl_read failure!"); + return -1; } } while (SSL_pending(ssl) && !(state & MYSSL_RB)); } @@ -494,7 +514,7 @@ */ int ssl_write(SSL * ssl, int state, int net_read_ready, int net_write_ready, - unsigned char *buf, int bufsize, int *offset) + unsigned char *buf, int bufsize, int *offset) { int r; if ((net_write_ready && bufsize) || (net_read_ready && !(state & MYSSL_WBOR))) { @@ -586,7 +606,7 @@ SSL_set_bio(ssl, bio, bio); return ssl; } -#endif /* BROKEN */ +#endif /* BROKEN */ -#endif /* HAS_OPENSSL */ +#endif /* HAS_OPENSSL */ Index: src/wiz.c =================================================================== --- src/wiz.c (.../p5) (revision 1028) +++ src/wiz.c (.../p6) (revision 1028) @@ -60,17 +60,17 @@ #endif struct search_spec { - dbref owner; /**< Limit to this owner, if specified */ - int type; /**< Limit to this type */ - dbref parent; /**< Limit to children of this parent */ - dbref zone; /**< Limit to those in this zone */ + dbref owner; /**< Limit to this owner, if specified */ + int type; /**< Limit to this type */ + dbref parent; /**< Limit to children of this parent */ + dbref zone; /**< Limit to those in this zone */ char flags[BUFFER_LEN]; /**< Limit to those with these flags */ char lflags[BUFFER_LEN]; /**< Limit to those with these flags */ char powers[BUFFER_LEN]; /**< Limit to those with these powers */ char eval[BUFFER_LEN]; /**< Limit to those where this evals true */ char name[BUFFER_LEN]; /**< Limit to those prefix-matching this name */ - dbref low; /**< Limit to dbrefs here or higher */ - dbref high; /**< Limit to dbrefs here or lower */ + dbref low; /**< Limit to dbrefs here or higher */ + dbref high; /**< Limit to dbrefs here or lower */ int start; /**< Limited results: start at this one. */ int count; /**< Limited results: return this many */ int end; /**< Limited results: return until this one.*/ @@ -80,9 +80,9 @@ static int tport_control_ok(dbref player, dbref victim, dbref loc); static int mem_usage(dbref thing); static int raw_search(dbref player, const char *owner, int nargs, - const char **args, dbref **result, PE_Info * pe_info); + const char **args, dbref **result, PE_Info * pe_info); static int fill_search_spec(dbref player, const char *owner, int nargs, - const char **args, struct search_spec *spec); + const char **args, struct search_spec *spec); #ifdef INFO_SLAVE void kill_info_slave(void); @@ -118,11 +118,11 @@ } if (player == AMBIGUOUS) { notify_format(creator, T("Failure creating '%s' (bad password)"), - player_name); + player_name); return NOTHING; } notify_format(creator, T("New player '%s' (#%d) created with password '%s'"), - player_name, player, player_password); + player_name, player, player_password); do_log(LT_WIZ, creator, player, T("Player creation")); return player; } @@ -163,12 +163,12 @@ return; } /* count up all owned objects */ - owned = -1; /* a player is never included in his own - * quota */ + owned = -1; /* a player is never included in his own + * quota */ for (thing = 0; thing < db_top; thing++) { if (Owner(thing) == who) if (!IsGarbage(thing)) - ++owned; + ++owned; } /* the quotas of priv'ed players are unlimited and cannot be set. */ @@ -197,7 +197,7 @@ limit = owned + get_current_quota(who) + atoi(arg2); else limit = parse_integer(arg2); - if (limit < owned) /* always have enough quota for your objects */ + if (limit < owned) /* always have enough quota for your objects */ limit = owned; (void) atr_add(Owner(who), "RQUOTA", tprintf("%d", limit - owned), GOD, 0); @@ -242,30 +242,30 @@ continue; /* count up all owned objects */ - owned = -1; /* a player is never included in his own - * quota */ + owned = -1; /* a player is never included in his own + * quota */ for (thing = 0; thing < db_top; thing++) { if (Owner(thing) == who) - if (!IsGarbage(thing)) - ++owned; + if (!IsGarbage(thing)) + ++owned; } if (NoQuota(who)) { if (!quiet) - notify_format(player, "%s: Objects: %d Limit: UNLIMITED", - Name(who), owned); + notify_format(player, "%s: Objects: %d Limit: UNLIMITED", + Name(who), owned); continue; } if (!quiet) { oldlimit = get_current_quota(who); notify_format(player, "%s: Objects: %d Limit: %d", - Name(who), owned, oldlimit); + Name(who), owned, oldlimit); } if (limit != -1) { if (limit <= owned) - (void) atr_add(who, "RQUOTA", "0", GOD, 0); + (void) atr_add(who, "RQUOTA", "0", GOD, 0); else - (void) atr_add(who, "RQUOTA", tprintf("%d", limit - owned), GOD, 0); + (void) atr_add(who, "RQUOTA", tprintf("%d", limit - owned), GOD, 0); } } if (limit == -1) @@ -336,13 +336,13 @@ */ void do_teleport(dbref player, const char *arg1, const char *arg2, int silent, - int inside) + int inside) { dbref victim; dbref destination; dbref loc; const char *to; - dbref absroom; /* "absolute room", for NO_TEL check */ + dbref absroom; /* "absolute room", for NO_TEL check */ /* get victim, destination */ if (*arg2 == '\0') { @@ -350,8 +350,8 @@ to = arg1; } else { if ((victim = - noisy_match_result(player, arg1, NOTYPE, - MAT_OBJECTS | MAT_ENGLISH)) == NOTHING) { + noisy_match_result(player, arg1, NOTYPE, + MAT_OBJECTS | MAT_ENGLISH)) == NOTHING) { return; } to = arg2; @@ -373,7 +373,7 @@ */ if (player == victim) { if (command_check_byname(victim, "HOME")) - safe_tel(victim, HOME, silent); + safe_tel(victim, HOME, silent); return; } else destination = Home(victim); @@ -398,7 +398,7 @@ return; } if (recursive_member(destination, victim, 0) - || (victim == destination)) { + || (victim == destination)) { notify(player, T("Bad destination.")); return; } @@ -409,25 +409,25 @@ if (IsExit(victim)) { /* Teleporting an exit means moving its source */ if (!IsRoom(destination)) { - notify(player, T("Exits can only be teleported to other rooms.")); - return; + notify(player, T("Exits can only be teleported to other rooms.")); + return; } if (Going(destination)) { - notify(player, - T("You can't move an exit to someplace that's crumbling.")); - return; + notify(player, + T("You can't move an exit to someplace that's crumbling.")); + return; } if (!GoodObject(Home(victim))) - loc = find_entrance(victim); + loc = find_entrance(victim); else - loc = Home(victim); + loc = Home(victim); /* Unlike normal teleport, you must control the destination * or have the open_anywhere power */ if (!(tport_control_ok(player, victim, loc) && - (controls(player, destination) || Open_Anywhere(player)))) { - notify(player, T("Permission denied.")); - return; + (controls(player, destination) || Open_Anywhere(player)))) { + notify(player, T("Permission denied.")); + return; } /* Remove it from its old room */ Exits(loc) = remove_first(Exits(loc), victim); @@ -435,7 +435,7 @@ Source(victim) = destination; PUSH(victim, Exits(destination)); if (!Quiet(player) && !(Quiet(victim) && (Owner(victim) == player))) - notify(player, T("Teleported.")); + notify(player, T("Teleported.")); return; } loc = Location(victim); @@ -444,13 +444,13 @@ * using @tel/inside */ if (IsPlayer(destination) && Tel_Anywhere(player) && IsPlayer(victim) - && !inside) { + && !inside) { if (!silent && loc != Location(destination)) - did_it(victim, victim, NULL, NULL, "OXTPORT", NULL, NULL, loc); + did_it(victim, victim, NULL, NULL, "OXTPORT", NULL, NULL, loc); safe_tel(victim, Location(destination), silent); if (!silent && loc != Location(destination)) - did_it(victim, victim, "TPORT", NULL, "OTPORT", NULL, "ATPORT", - Location(destination)); + did_it(victim, victim, "TPORT", NULL, "OTPORT", NULL, "ATPORT", + Location(destination)); return; } /* check needed for NOTHING. Especially important for unlinked exits */ @@ -459,7 +459,7 @@ /* At this point, they're in a bad location, so let's check * if home is valid before sending them there. */ if (!GoodObject(Home(victim))) - Home(victim) = PLAYER_START; + Home(victim) = PLAYER_START; do_move(victim, "home", MOVE_NORMAL); return; } else { @@ -467,29 +467,29 @@ /* if player is inside himself, send him home */ if (absroom == victim) { - notify(player, T("What are you doing inside of yourself?")); - if (Home(victim) == absroom) - Home(victim) = PLAYER_START; - do_move(victim, "home", MOVE_NORMAL); - return; + notify(player, T("What are you doing inside of yourself?")); + if (Home(victim) == absroom) + Home(victim) = PLAYER_START; + do_move(victim, "home", MOVE_NORMAL); + return; } /* find the "absolute" room */ absroom = absolute_room(victim); if (absroom == NOTHING) { - notify(victim, T("You're in the void - sending you home.")); - if (Home(victim) == Location(victim)) - Home(victim) = PLAYER_START; - do_move(victim, "home", MOVE_NORMAL); - return; + notify(victim, T("You're in the void - sending you home.")); + if (Home(victim) == Location(victim)) + Home(victim) = PLAYER_START; + do_move(victim, "home", MOVE_NORMAL); + return; } /* if there are a lot of containers, send him home */ if (absroom == AMBIGUOUS) { - notify(victim, T("You're in too many containers.")); - if (Home(victim) == Location(victim)) - Home(victim) = PLAYER_START; - do_move(victim, "home", MOVE_NORMAL); - return; + notify(victim, T("You're in too many containers.")); + if (Home(victim) == Location(victim)) + Home(victim) = PLAYER_START; + do_move(victim, "home", MOVE_NORMAL); + return; } /* note that we check the NO_TEL status of the victim rather * than the player that issued the command. This prevents someone @@ -499,17 +499,17 @@ /* now check to see if the absolute room is set NO_TEL */ if (NoTel(absroom) && !controls(player, absroom) - && !Tel_Anywhere(player)) { - notify(player, T("Teleports are not allowed in this room.")); - return; + && !Tel_Anywhere(player)) { + notify(player, T("Teleports are not allowed in this room.")); + return; } /* Check leave lock on room, if necessary */ if (!controls(player, absroom) && !Tel_Anywhere(player) && - !eval_lock(player, absroom, Leave_Lock)) { - fail_lock(player, absroom, Leave_Lock, - T("Teleports are not allowed in this room."), NOTHING); - return; + !eval_lock(player, absroom, Leave_Lock)) { + fail_lock(player, absroom, Leave_Lock, + T("Teleports are not allowed in this room."), NOTHING); + return; } /* Now check the Z_TEL status of the victim's room. @@ -518,51 +518,51 @@ * the destination must also be a room in the same zone */ if (GoodObject(Zone(absroom)) && (ZTel(absroom) || ZTel(Zone(absroom))) - && !controls(player, absroom) && !Tel_Anywhere(player) - && (Zone(absroom) != Zone(destination))) { - notify(player, - T("You may not teleport out of the zone from this room.")); - return; + && !controls(player, absroom) && !Tel_Anywhere(player) + && (Zone(absroom) != Zone(destination))) { + notify(player, + T("You may not teleport out of the zone from this room.")); + return; } } if (!IsExit(destination)) { if (tport_control_ok(player, victim, Location(victim)) && - tport_dest_ok(player, victim, destination) - && (Tel_Anything(player) || - (Tel_Anywhere(player) && (player == victim)) || - (destination == Owner(victim)) || - (!Fixed(Owner(victim)) && !Fixed(player)))) { - if (!silent && loc != destination) - did_it(victim, victim, NULL, NULL, "OXTPORT", NULL, NULL, loc); - safe_tel(victim, destination, silent); - if (!silent && loc != destination) - did_it(victim, victim, "TPORT", NULL, "OTPORT", NULL, "ATPORT", - destination); - if ((victim != player) && !(Puppet(victim) && - (Owner(victim) == Owner(player)))) { - if (!Quiet(player) && !(Quiet(victim) && (Owner(victim) == player))) - notify(player, T("Teleported.")); - } - return; + tport_dest_ok(player, victim, destination) + && (Tel_Anything(player) || + (Tel_Anywhere(player) && (player == victim)) || + (destination == Owner(victim)) || + (!Fixed(Owner(victim)) && !Fixed(player)))) { + if (!silent && loc != destination) + did_it(victim, victim, NULL, NULL, "OXTPORT", NULL, NULL, loc); + safe_tel(victim, destination, silent); + if (!silent && loc != destination) + did_it(victim, victim, "TPORT", NULL, "OTPORT", NULL, "ATPORT", + destination); + if ((victim != player) && !(Puppet(victim) && + (Owner(victim) == Owner(player)))) { + if (!Quiet(player) && !(Quiet(victim) && (Owner(victim) == player))) + notify(player, T("Teleported.")); + } + return; } /* we can't do it */ fail_lock(player, destination, Enter_Lock, T("Permission denied."), - Location(player)); + Location(player)); return; } else { /* attempted teleport to an exit */ if (tport_control_ok(player, victim, Location(victim)) - && (Tel_Anything(player) || - (Tel_Anywhere(player) && (player == victim)) || - (!Fixed(Owner(victim)) && !Fixed(player)))) { - do_move(victim, to, MOVE_NORMAL); + && (Tel_Anything(player) || + (Tel_Anywhere(player) && (player == victim)) || + (!Fixed(Owner(victim)) && !Fixed(player)))) { + do_move(victim, to, MOVE_NORMAL); } else { - notify(player, T("Permission denied.")); - if (victim != player) - notify_format(victim, - T("%s tries to impose his will on you and fails."), - Name(player)); + notify(player, T("Permission denied.")); + if (victim != player) + notify_format(victim, + T("%s tries to impose his will on you and fails."), + Name(player)); } } } @@ -590,9 +590,9 @@ if (Wizard(player)) { /* Log forces by wizards */ if (Owner(victim) != Owner(player)) - do_log(LT_WIZ, player, victim, "** FORCE: %s", command); + do_log(LT_WIZ, player, victim, "** FORCE: %s", command); else - do_log(LT_WIZ, player, victim, "FORCE: %s", command); + do_log(LT_WIZ, player, victim, "FORCE: %s", command); } else if (Wizard(Owner(victim))) { /* Log forces of wizards */ do_log(LT_WIZ, player, victim, "** FORCE WIZ-OWNED: %s", command); @@ -628,12 +628,12 @@ s = command + 1; while (*s && !isspace((unsigned char) *s)) { if (!isdigit((unsigned char) *s)) - return 0; /* #1a is no good */ + return 0; /* #1a is no good */ s++; } if (!*s) - return 0; /* dbref with no action is no good */ - *s = '='; /* Replace the first space with = so we have #3= */ + return 0; /* dbref with no action is no good */ + *s = '='; /* Replace the first space with = so we have #3= */ return 1; } @@ -658,24 +658,24 @@ if (owner == ANY_OWNER || owner == Owner(i)) { si.total++; if (IsGarbage(i)) { - si.garbage++; + si.garbage++; } else { - switch (Typeof(i)) { - case TYPE_ROOM: - si.rooms++; - break; - case TYPE_EXIT: - si.exits++; - break; - case TYPE_THING: - si.things++; - break; - case TYPE_PLAYER: - si.players++; - break; - default: - break; - } + switch (Typeof(i)) { + case TYPE_ROOM: + si.rooms++; + break; + case TYPE_EXIT: + si.exits++; + break; + case TYPE_THING: + si.things++; + break; + case TYPE_PLAYER: + si.players++; + break; + default: + break; + } } } } @@ -720,18 +720,18 @@ si = get_stats(owner); if (owner == ANY_OWNER) { notify_format(player, - T - ("%d objects = %d rooms, %d exits, %d things, %d players, %d garbage."), - si->total, si->rooms, si->exits, si->things, si->players, - si->garbage); + T + ("%d objects = %d rooms, %d exits, %d things, %d players, %d garbage."), + si->total, si->rooms, si->exits, si->things, si->players, + si->garbage); if (first_free != NOTHING) notify_format(player, T("The next object to be created will be #%d."), - first_free); + first_free); } else { notify_format(player, - T("%d objects = %d rooms, %d exits, %d things, %d players."), - si->total - si->garbage, si->rooms, si->exits, si->things, - si->players); + T("%d objects = %d rooms, %d exits, %d things, %d players."), + si->total - si->garbage, si->rooms, si->exits, si->things, + si->players); } } @@ -746,7 +746,7 @@ */ void do_newpassword(dbref player, dbref cause, - const char *name, const char *password) + const char *name, const char *password) { dbref victim; @@ -758,7 +758,7 @@ sp = password; bp = pass_eval; process_expression(pass_eval, &bp, &sp, player, player, cause, - PE_DEFAULT, PT_DEFAULT, NULL); + PE_DEFAULT, PT_DEFAULT, NULL); *bp = '\0'; password = pass_eval; } @@ -775,7 +775,7 @@ (void) atr_add(victim, "XYXXY", mush_crypt(password), GOD, 0); notify_format(player, T("Password for %s changed."), Name(victim)); notify_format(victim, T("Your password has been changed by %s."), - Name(player)); + Name(player)); do_log(LT_WIZ, player, victim, "*** NEWPASSWORD ***"); } } @@ -806,18 +806,18 @@ if (victim == NOTHING) { d = port_desc(atoi(name)); if (!d && Can_Boot(player)) { - notify(player, "There is no one connected on that descriptor."); - return; + notify(player, "There is no one connected on that descriptor."); + return; } else - victim = AMBIGUOUS; + victim = AMBIGUOUS; } break; case BOOT_SILENT: case BOOT_NAME: /* boot by name */ if ((victim = - noisy_match_result(player, name, TYPE_PLAYER, - MAT_LIMITED | MAT_ME)) == NOTHING) { + noisy_match_result(player, name, TYPE_PLAYER, + MAT_LIMITED | MAT_ME)) == NOTHING) { notify(player, T("No such connected player.")); return; } @@ -871,7 +871,7 @@ else { notify_format(player, T("You booted %s off!"), Name(victim)); if (flag != BOOT_SILENT) - notify(victim, T("You are politely shown to the door.")); + notify(victim, T("You are politely shown to the door.")); } boot_desc(d); } @@ -906,8 +906,8 @@ n_target = player; } else { if ((n_target = - noisy_match_result(player, target, TYPE_PLAYER, - MAT_LIMITED)) == NOTHING) + noisy_match_result(player, target, TYPE_PLAYER, + MAT_LIMITED)) == NOTHING) return; } @@ -1038,9 +1038,9 @@ notify(player, object_header(player, thing)); notify_format(player, T("Flags value: %s"), - bits_to_string("FLAG", Flags(thing), GOD, NOTHING)); + bits_to_string("FLAG", Flags(thing), GOD, NOTHING)); notify_format(player, T("Powers value: %s"), - bits_to_string("POWER", Powers(thing), GOD, NOTHING)); + bits_to_string("POWER", Powers(thing), GOD, NOTHING)); notify_format(player, "Next: %d", Next(thing)); notify_format(player, "Contents: %d", Contents(thing)); @@ -1153,16 +1153,16 @@ /* First argument is a player, so we could have a quoted name */ if (PLAYER_NAME_SPACES && *arg1 == '\"') { for (; *arg1 && ((*arg1 == '\"') || isspace((unsigned char) *arg1)); - arg1++) ; + arg1++) ; strcpy(tbuf, arg1); while (*arg2 && (*arg2 != '\"')) { while (*arg2 && (*arg2 != '\"')) - arg2++; + arg2++; if (*arg2 == '\"') { - *arg2++ = '\0'; - while (*arg2 && isspace((unsigned char) *arg2)) - arg2++; - break; + *arg2++ = '\0'; + while (*arg2 && isspace((unsigned char) *arg2)) + arg2++; + break; } } } else { @@ -1177,9 +1177,9 @@ if (!*arg2) { if (!arg3[1] || !*arg3[1]) - arg2 = (char *) ""; /* arg1 */ + arg2 = (char *) ""; /* arg1 */ else { - arg2 = (char *) arg1; /* arg2=arg3 */ + arg2 = (char *) arg1; /* arg2=arg3 */ tbuf[0] = '\0'; } } @@ -1208,32 +1208,32 @@ for (n = 0; n < nresults; n++) { switch (Typeof(results[n])) { case TYPE_THING: - things[nthings++] = results[n]; - break; + things[nthings++] = results[n]; + break; case TYPE_EXIT: - exits[nexits++] = results[n]; - break; + exits[nexits++] = results[n]; + break; case TYPE_ROOM: - rooms[nrooms++] = results[n]; - break; + rooms[nrooms++] = results[n]; + break; case TYPE_PLAYER: - players[nplayers++] = results[n]; - break; + players[nplayers++] = results[n]; + break; default: - /* Unknown type. Ignore. */ - do_rawlog(LT_ERR, T("Weird type for dbref #%d"), results[n]); + /* Unknown type. Ignore. */ + do_rawlog(LT_ERR, T("Weird type for dbref #%d"), results[n]); } } if (nrooms) { notify(player, "\nROOMS:"); for (n = 0; n < nrooms; n++) { - tbp = tbuf; - safe_format(tbuf, &tbp, "%s [owner: ", object_header(player, rooms[n])); - safe_str(object_header(player, Owner(rooms[n])), tbuf, &tbp); - safe_chr(']', tbuf, &tbp); - *tbp = '\0'; - notify(player, tbuf); + tbp = tbuf; + safe_format(tbuf, &tbp, "%s [owner: ", object_header(player, rooms[n])); + safe_str(object_header(player, Owner(rooms[n])), tbuf, &tbp); + safe_chr(']', tbuf, &tbp); + *tbp = '\0'; + notify(player, tbuf); } } @@ -1242,34 +1242,34 @@ notify(player, "\nEXITS:"); for (n = 0; n < nexits; n++) { - tbp = tbuf; - if (Source(exits[n]) == NOTHING) - from = NOTHING; - else - from = Source(exits[n]); - to = Destination(exits[n]); - safe_format(tbuf, &tbp, "%s [from ", object_header(player, exits[n])); - safe_str((from == NOTHING) ? "NOWHERE" : object_header(player, from), - tbuf, &tbp); - safe_str(" to ", tbuf, &tbp); - safe_str((to == NOTHING) ? "NOWHERE" : object_header(player, to), - tbuf, &tbp); - safe_chr(']', tbuf, &tbp); - *tbp = '\0'; - notify(player, tbuf); + tbp = tbuf; + if (Source(exits[n]) == NOTHING) + from = NOTHING; + else + from = Source(exits[n]); + to = Destination(exits[n]); + safe_format(tbuf, &tbp, "%s [from ", object_header(player, exits[n])); + safe_str((from == NOTHING) ? "NOWHERE" : object_header(player, from), + tbuf, &tbp); + safe_str(" to ", tbuf, &tbp); + safe_str((to == NOTHING) ? "NOWHERE" : object_header(player, to), + tbuf, &tbp); + safe_chr(']', tbuf, &tbp); + *tbp = '\0'; + notify(player, tbuf); } } if (nthings) { notify(player, "\nTHINGS:"); for (n = 0; n < nthings; n++) { - tbp = tbuf; - safe_format(tbuf, &tbp, "%s [owner: ", - object_header(player, things[n])); - safe_str(object_header(player, Owner(things[n])), tbuf, &tbp); - safe_chr(']', tbuf, &tbp); - *tbp = '\0'; - notify(player, tbuf); + tbp = tbuf; + safe_format(tbuf, &tbp, "%s [owner: ", + object_header(player, things[n])); + safe_str(object_header(player, Owner(things[n])), tbuf, &tbp); + safe_chr(']', tbuf, &tbp); + *tbp = '\0'; + notify(player, tbuf); } } @@ -1277,22 +1277,22 @@ int is_wizard = Search_All(player) || See_All(player); notify(player, "\nPLAYERS:"); for (n = 0; n < nplayers; n++) { - tbp = tbuf; - safe_str(object_header(player, players[n]), tbuf, &tbp); - if (is_wizard) - safe_format(tbuf, &tbp, - T(" [location: %s]"), - object_header(player, Location(players[n]))); - *tbp = '\0'; - notify(player, tbuf); + tbp = tbuf; + safe_str(object_header(player, players[n]), tbuf, &tbp); + if (is_wizard) + safe_format(tbuf, &tbp, + T(" [location: %s]"), + object_header(player, Location(players[n]))); + *tbp = '\0'; + notify(player, tbuf); } } notify(player, T("---------- Search Done ----------")); notify_format(player, - T - ("Totals: Rooms...%d Exits...%d Things...%d Players...%d"), - nrooms, nexits, nthings, nplayers); + T + ("Totals: Rooms...%d Exits...%d Things...%d Players...%d"), + nrooms, nexits, nthings, nplayers); mush_free((Malloc_t) rooms, "dbref_list"); mush_free((Malloc_t) exits, "dbref_list"); mush_free((Malloc_t) things, "dbref_list"); @@ -1327,7 +1327,7 @@ } else { nresults = raw_search(executor, args[0], nargs - 1, (const char **) (args + 1), - &results, pe_info); + &results, pe_info); } if (nresults < 0) { @@ -1340,21 +1340,21 @@ int first = 1, n; if (!rev) { for (n = 0; n < nresults; n++) { - if (first) - first = 0; - else if (safe_chr(' ', buff, bp)) - break; - if (safe_dbref(results[n], buff, bp)) - break; + if (first) + first = 0; + else if (safe_chr(' ', buff, bp)) + break; + if (safe_dbref(results[n], buff, bp)) + break; } } else { for (n = nresults - 1; n >= 0; n--) { - if (first) - first = 0; - else if (safe_chr(' ', buff, bp)) - break; - if (safe_dbref(results[n], buff, bp)) - break; + if (first) + first = 0; + else if (safe_chr(' ', buff, bp)) + break; + if (safe_dbref(results[n], buff, bp)) + break; } } } @@ -1364,7 +1364,7 @@ #ifdef WIN32 -#pragma warning( disable : 4761) /* Disable bogus conversion warning */ +#pragma warning( disable : 4761) /* Disable bogus conversion warning */ #endif /* ARGSUSED */ FUNCTION(fun_hidden) @@ -1385,7 +1385,7 @@ } #ifdef WIN32 -#pragma warning( default : 4761) /* Re-enable conversion warning */ +#pragma warning( default : 4761) /* Re-enable conversion warning */ #endif /* ARGSUSED */ @@ -1401,7 +1401,7 @@ return; } if (!(Do_Quotas(executor) || See_All(executor) - || controls(executor, who))) { + || controls(executor, who))) { notify(executor, T("You can't see someone else's quota!")); safe_str("#-1", buff, bp); return; @@ -1412,12 +1412,12 @@ return; } /* count up all owned objects */ - owned = -1; /* a player is never included in his own - * quota */ + owned = -1; /* a player is never included in his own + * quota */ for (thing = 0; thing < db_top; thing++) { if (Owner(thing) == who) if (!IsGarbage(thing)) - ++owned; + ++owned; } safe_integer(owned + get_current_quota(who), buff, bp); @@ -1436,7 +1436,7 @@ */ void do_sitelock(dbref player, const char *site, const char *opts, const char *who, - enum sitelock_type type) + enum sitelock_type type) { if (!Wizard(player)) { notify(player, T("Your delusions of grandeur have been noted.")); @@ -1455,11 +1455,11 @@ notify(player, T("No valid options found.")); return; } - if (who && *who) { /* Specify a character */ + if (who && *who) { /* Specify a character */ whod = lookup_player(who); if (!GoodObject(whod)) { - notify(player, T("Who do you want to lock?")); - return; + notify(player, T("Who do you want to lock?")); + return; } } @@ -1467,11 +1467,11 @@ write_access_file(); if (whod != AMBIGUOUS) { notify_format(player, - T("Site %s access options for %s(%s) set to %s"), - site, Name(whod), unparse_dbref(whod), opts); + T("Site %s access options for %s(%s) set to %s"), + site, Name(whod), unparse_dbref(whod), opts); do_log(LT_WIZ, player, NOTHING, - T("*** SITELOCK *** %s for %s(%s) --> %s"), site, - Name(whod), unparse_dbref(whod), opts); + T("*** SITELOCK *** %s for %s(%s) --> %s"), site, + Name(whod), unparse_dbref(whod), opts); } else { notify_format(player, T("Site %s access options set to %s"), site, opts); do_log(LT_WIZ, player, NOTHING, "*** SITELOCK *** %s --> %s", site, opts); @@ -1499,27 +1499,27 @@ do_log(LT_WIZ, player, NOTHING, "*** SITELOCK *** %s", site); break; case SITELOCK_CHECK:{ - struct access *ap; - char tbuf[BUFFER_LEN], *bp; - int rulenum; - if (!site || !*site) { - do_list_access(player); - return; - } - ap = site_check_access(site, AMBIGUOUS, &rulenum); - bp = tbuf; - format_access(ap, rulenum, AMBIGUOUS, tbuf, &bp); - *bp = '\0'; - notify(player, tbuf); - break; + struct access *ap; + char tbuf[BUFFER_LEN], *bp; + int rulenum; + if (!site || !*site) { + do_list_access(player); + return; + } + ap = site_check_access(site, AMBIGUOUS, &rulenum); + bp = tbuf; + format_access(ap, rulenum, AMBIGUOUS, tbuf, &bp); + *bp = '\0'; + notify(player, tbuf); + break; } case SITELOCK_REMOVE:{ - int n; - n = remove_access_sitelock(site); - if (n > 0) - write_access_file(); - notify_format(player, T("%d sitelocks removed."), n); - break; + int n; + n = remove_access_sitelock(site); + if (n > 0) + write_access_file(); + notify_format(player, T("%d sitelocks removed."), n); + break; } } } @@ -1553,79 +1553,79 @@ } else { notify(player, T("Any name matching these wildcard patterns is banned:")); while (fgets(buffer, sizeof buffer, fp)) { - if ((p = strchr(buffer, '\r')) != NULL) - *p = '\0'; - else if ((p = strchr(buffer, '\n')) != NULL) - *p = '\0'; - notify(player, buffer); + if ((p = strchr(buffer, '\r')) != NULL) + *p = '\0'; + else if ((p = strchr(buffer, '\n')) != NULL) + *p = '\0'; + notify(player, buffer); } fclose(fp); } - } else if (name[0] == '!') { /* Delete a name */ + } else if (name[0] == '!') { /* Delete a name */ if ((fp = fopen(NAMES_FILE, FOPEN_READ)) != NULL) { if ((fptmp = fopen("tmp.tmp", FOPEN_WRITE)) == NULL) { - notify(player, T("Unable to delete name.")); - fclose(fp); + notify(player, T("Unable to delete name.")); + fclose(fp); } else { - while (fgets(buffer, sizeof buffer, fp)) { - if ((p = strchr(buffer, '\r')) != NULL) - *p = '\0'; - else if ((p = strchr(buffer, '\n')) != NULL) - *p = '\0'; - if (strcasecmp(buffer, name + 1) == 0) - /* Replace the name with #NAME, to allow things like - keeping track of unlocked feature names. */ - fprintf(fptmp, "#%s\n", buffer); - else - fprintf(fptmp, "%s\n", buffer); - } - fclose(fp); - fclose(fptmp); - if (rename_file("tmp.tmp", NAMES_FILE) == 0) { - notify(player, T("Name removed.")); - do_log(LT_WIZ, player, NOTHING, "*** UNLOCKED NAME *** %s", name + 1); - } else { - notify(player, T("Unable to delete name.")); - } + while (fgets(buffer, sizeof buffer, fp)) { + if ((p = strchr(buffer, '\r')) != NULL) + *p = '\0'; + else if ((p = strchr(buffer, '\n')) != NULL) + *p = '\0'; + if (strcasecmp(buffer, name + 1) == 0) + /* Replace the name with #NAME, to allow things like + keeping track of unlocked feature names. */ + fprintf(fptmp, "#%s\n", buffer); + else + fprintf(fptmp, "%s\n", buffer); + } + fclose(fp); + fclose(fptmp); + if (rename_file("tmp.tmp", NAMES_FILE) == 0) { + notify(player, T("Name removed.")); + do_log(LT_WIZ, player, NOTHING, "*** UNLOCKED NAME *** %s", name + 1); + } else { + notify(player, T("Unable to delete name.")); + } } } else notify(player, T("Unable to delete name.")); - } else { /* Add a name */ + } else { /* Add a name */ if ((fp = fopen(NAMES_FILE, FOPEN_READ)) != NULL) { if ((fptmp = fopen("tmp.tmp", FOPEN_WRITE)) == NULL) { - notify(player, T("Unable to lock name.")); + notify(player, T("Unable to lock name.")); } else { - /* Read the names file, looking for #NAME and writing it - without the commenting #. Otherwise, add the new name - to the end of the file unless it's already present */ - char commented[BUFFER_LEN + 1]; - int found = 0; - commented[0] = '#'; - strcpy(commented + 1, name); - while (fgets(buffer, sizeof buffer, fp) != NULL) { - if ((p = strchr(buffer, '\r')) != NULL) - *p = '\0'; - else if ((p = strchr(buffer, '\n')) != NULL) - *p = '\0'; - if (strcasecmp(commented, buffer) == 0) { - fprintf(fptmp, "%s\n", buffer + 1); - found = 1; - } else { - fprintf(fptmp, "%s\n", buffer); - if (strcasecmp(name, buffer) == 0) - found = 1; - } - } - if (!found) - fprintf(fptmp, "%s\n", name); - fclose(fp); - fclose(fptmp); + /* Read the names file, looking for #NAME and writing it + without the commenting #. Otherwise, add the new name + to the end of the file unless it's already present */ + char commented[BUFFER_LEN + 1]; + int found = 0; + commented[0] = '#'; + strcpy(commented + 1, name); + while (fgets(buffer, sizeof buffer, fp) != NULL) { + if ((p = strchr(buffer, '\r')) != NULL) + *p = '\0'; + else if ((p = strchr(buffer, '\n')) != NULL) + *p = '\0'; + if (strcasecmp(commented, buffer) == 0) { + fprintf(fptmp, "%s\n", buffer + 1); + found = 1; + } else { + fprintf(fptmp, "%s\n", buffer); + if (strcasecmp(name, buffer) == 0) + found = 1; + } + } + if (!found) + fprintf(fptmp, "%s\n", name); + fclose(fp); + fclose(fptmp); - if (rename_file("tmp.tmp", NAMES_FILE) == 0) { - notify_format(player, T("Name %s locked."), name); - do_log(LT_WIZ, player, NOTHING, "*** NAMELOCK *** %s", name); - } else - notify(player, T("Unable to lock name.")); + if (rename_file("tmp.tmp", NAMES_FILE) == 0) { + notify_format(player, T("Name %s locked."), name); + do_log(LT_WIZ, player, NOTHING, "*** NAMELOCK *** %s", name); + } else + notify(player, T("Unable to lock name.")); } } } @@ -1643,8 +1643,8 @@ int k; ATTR *m; lock_list *l; - k = sizeof(struct object); /* overhead */ - k += strlen(Name(thing)) + 1; /* The name */ + k = sizeof(struct object); /* overhead */ + k += strlen(Name(thing)) + 1; /* The name */ for (m = List(thing); m; m = AL_NEXT(m)) { k += sizeof(ATTR); if (AL_STR(m) && *AL_STR(m)) @@ -1740,13 +1740,13 @@ { if (player == NOTHING) { flag_broadcast(0, 0, - T - ("GAME: Reboot w/o disconnect from game account, please wait.")); + T + ("GAME: Reboot w/o disconnect from game account, please wait.")); } else { flag_broadcast(0, 0, - T - ("GAME: Reboot w/o disconnect by %s, please wait."), - Name(Owner(player))); + T + ("GAME: Reboot w/o disconnect by %s, please wait."), + Name(Owner(player))); } if (flag) { globals.paranoid_dump = 1; @@ -1779,14 +1779,14 @@ execl("netmush", "netmush", confname, NULL); #else execl("pennmush.exe", "pennmush.exe", "/run", NULL); -#endif /* WIN32 */ - exit(1); /* Shouldn't ever get here, but just in case... */ +#endif /* WIN32 */ + exit(1); /* Shouldn't ever get here, but just in case... */ } static int fill_search_spec(dbref player, const char *owner, int nargs, const char **args, - struct search_spec *spec) + struct search_spec *spec) { int n; int is_wiz; @@ -1801,7 +1801,7 @@ strcpy(spec->name, ""); spec->low = 0; spec->high = db_top - 1; - spec->start = 1; /* 1-indexed */ + spec->start = 1; /* 1-indexed */ spec->count = 0; is_wiz = Search_All(player) || See_All(player); @@ -1823,37 +1823,37 @@ /* A special old-timey kludge */ if (class && !*class && restriction && *restriction) { if (isdigit((unsigned char) *restriction) - || ((*restriction == '#') && *(restriction + 1) - && isdigit((unsigned char) *(restriction + 1)))) { - size_t offset = 0; - if (*restriction == '#') - offset = 1; - spec->high = parse_integer(restriction + offset); - if (!GoodObject(spec->high)) - spec->high = db_top - 1; - continue; + || ((*restriction == '#') && *(restriction + 1) + && isdigit((unsigned char) *(restriction + 1)))) { + size_t offset = 0; + if (*restriction == '#') + offset = 1; + spec->high = parse_integer(restriction + offset); + if (!GoodObject(spec->high)) + spec->high = db_top - 1; + continue; } } if (!class || !*class || !restriction) continue; if (isdigit((unsigned char) *class) || ((*class == '#') && *(class + 1) - && isdigit((unsigned char) - *(class + 1)))) { + && isdigit((unsigned char) + *(class + 1)))) { size_t offset = 0; if (*class == '#') - offset = 1; + offset = 1; spec->low = parse_integer(class + offset); if (!GoodObject(spec->low)) - spec->low = 0; + spec->low = 0; if (isdigit((unsigned char) *restriction) - || ((*restriction == '#') && *(restriction + 1) - && isdigit((unsigned char) *(restriction + 1)))) { - offset = 0; - if (*restriction == '#') - offset = 1; - spec->high = parse_integer(restriction + offset); - if (!GoodObject(spec->high)) - spec->high = db_top - 1; + || ((*restriction == '#') && *(restriction + 1) + && isdigit((unsigned char) *(restriction + 1)))) { + offset = 0; + if (*restriction == '#') + offset = 1; + spec->high = parse_integer(restriction + offset); + if (!GoodObject(spec->high)) + spec->high = db_top - 1; } continue; @@ -1865,41 +1865,41 @@ if (string_prefix("mindb", class)) { size_t offset = 0; if (*restriction == '#') - offset = 1; + offset = 1; spec->low = parse_integer(restriction + offset); if (!GoodObject(spec->low)) - spec->low = 0; + spec->low = 0; continue; } else if (string_prefix("maxdb", class)) { size_t offset = 0; if (*restriction == '#') - offset = 1; + offset = 1; spec->high = parse_integer(restriction + offset); if (!GoodObject(spec->high)) - spec->low = db_top - 1; + spec->low = db_top - 1; continue; } if (string_prefix("type", class)) { if (string_prefix("things", restriction) - || string_prefix("objects", restriction)) { - spec->type = TYPE_THING; + || string_prefix("objects", restriction)) { + spec->type = TYPE_THING; } else if (string_prefix("rooms", restriction)) { - spec->type = TYPE_ROOM; + spec->type = TYPE_ROOM; } else if (string_prefix("exits", restriction)) { - spec->type = TYPE_EXIT; + spec->type = TYPE_EXIT; } else if (string_prefix("rooms", restriction)) { - spec->type = TYPE_ROOM; + spec->type = TYPE_ROOM; } else if (string_prefix("players", restriction)) { - spec->type = TYPE_PLAYER; + spec->type = TYPE_PLAYER; } else if (string_prefix("garbage", restriction)) { - spec->type = TYPE_GARBAGE; + spec->type = TYPE_GARBAGE; } else { - notify(player, T("Unknown type.")); - return -1; + notify(player, T("Unknown type.")); + return -1; } } else if (string_prefix("things", class) - || string_prefix("objects", class)) { + || string_prefix("objects", class)) { strcpy(spec->name, restriction); spec->type = TYPE_THING; } else if (string_prefix("exits", class)) { @@ -1916,47 +1916,47 @@ } else if (string_prefix("start", class)) { spec->start = parse_integer(restriction); if (spec->start < 1) { - notify(player, T("Invalid start index")); - return -1; + notify(player, T("Invalid start index")); + return -1; } } else if (string_prefix("count", class)) { spec->count = parse_integer(restriction); if (spec->count < 1) { - notify(player, T("Invalid count index")); - return -1; + notify(player, T("Invalid count index")); + return -1; } } else if (string_prefix("parent", class)) { if (!*restriction) { - spec->parent = NOTHING; - continue; + spec->parent = NOTHING; + continue; } if (!is_objid(restriction)) { - notify(player, T("Unknown parent.")); - return -1; + notify(player, T("Unknown parent.")); + return -1; } spec->parent = parse_objid(restriction); if (!GoodObject(spec->parent)) { - notify(player, T("Unknown parent.")); - return -1; + notify(player, T("Unknown parent.")); + return -1; } } else if (string_prefix("zone", class)) { if (!*restriction) { - spec->zone = NOTHING; - continue; + spec->zone = NOTHING; + continue; } if (!is_objid(restriction)) { - notify(player, T("Unknown zone.")); - return -1; + notify(player, T("Unknown zone.")); + return -1; } spec->zone = parse_objid(restriction); if (!GoodObject(spec->zone)) { - notify(player, T("Unknown zone.")); - return -1; + notify(player, T("Unknown zone.")); + return -1; } } else if (string_prefix("eval", class)) { strcpy(spec->eval, restriction); } else if (string_prefix("ethings", class) || - string_prefix("eobjects", class)) { + string_prefix("eobjects", class)) { strcpy(spec->eval, restriction); spec->type = TYPE_THING; } else if (string_prefix("eexits", class)) { @@ -1971,22 +1971,22 @@ } else if (string_prefix("powers", class)) { /* Handle the checking later. */ if (!restriction || !*restriction) { - notify(player, T("You must give a list of power names.")); - return -1; + notify(player, T("You must give a list of power names.")); + return -1; } strcpy(spec->powers, restriction); } else if (string_prefix("flags", class)) { /* Handle the checking later. */ if (!restriction || !*restriction) { - notify(player, T("You must give a string of flag characters.")); - return -1; + notify(player, T("You must give a string of flag characters.")); + return -1; } strcpy(spec->flags, restriction); } else if (string_prefix("lflags", class)) { /* Handle the checking later. */ if (!restriction || !*restriction) { - notify(player, T("You must give a list of flag names.")); - return -1; + notify(player, T("You must give a list of flag names.")); + return -1; } strcpy(spec->lflags, restriction); } else { @@ -2002,7 +2002,7 @@ /* Does the actual searching */ static int raw_search(dbref player, const char *owner, int nargs, const char **args, - dbref **result, PE_Info * pe_info) + dbref **result, PE_Info * pe_info) { size_t result_size; size_t nresults = 0; @@ -2014,7 +2014,7 @@ /* make sure player has money to do the search */ if (!payfor(player, FIND_COST)) { notify_format(player, T("Searches cost %d %s."), FIND_COST, - ((FIND_COST == 1) ? MONEY : MONIES)); + ((FIND_COST == 1) ? MONEY : MONIES)); return -1; } @@ -2027,7 +2027,7 @@ if ((spec.owner != ANY_OWNER && spec.owner != Owner(player)) && !(is_wiz || (spec.type == TYPE_PLAYER) || - (ZMaster(spec.owner) && eval_lock(player, spec.owner, Zone_Lock)))) { + (ZMaster(spec.owner) && eval_lock(player, spec.owner, Zone_Lock)))) { giveto(player, FIND_COST); notify(player, T("You need a search warrant to do that.")); return -1; @@ -2057,7 +2057,7 @@ if (*spec.lflags && !flaglist_check_long("FLAG", player, n, spec.lflags, 1)) continue; if (*spec.powers - && !flaglist_check_long("POWER", player, n, spec.powers, 1)) + && !flaglist_check_long("POWER", player, n, spec.powers, 1)) continue; if (*spec.eval) { char *ebuf1; @@ -2069,11 +2069,11 @@ ebuf2 = ebuf1; bp = tbuf1; process_expression(tbuf1, &bp, &ebuf2, player, player, player, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); mush_free((Malloc_t) ebuf1, "replace_string.buff"); *bp = '\0'; if (!parse_boolean(tbuf1)) - continue; + continue; } /* Only include the matching dbrefs from start to start+count */ @@ -2089,9 +2089,9 @@ dbref *newresults; result_size *= 2; newresults = - (dbref *) realloc((Malloc_t) *result, sizeof(dbref) * result_size); + (dbref *) realloc((Malloc_t) *result, sizeof(dbref) * result_size); if (!newresults) - mush_panic(T("Couldn't reallocate memory in search!")); + mush_panic(T("Couldn't reallocate memory in search!")); *result = newresults; } Index: src/comp_w8.c =================================================================== --- src/comp_w8.c (.../p5) (revision 1028) +++ src/comp_w8.c (.../p6) (revision 1028) @@ -128,15 +128,15 @@ #include "mymalloc.h" #include "confmagic.h" -#define MAXTABLE 32768 /**< Maximum words in the table */ -#define MAXWORDS 100 /**< Maximum length of a word */ -#define COLLISION_LIMIT 20 /**< Maximum allowed collisions */ +#define MAXTABLE 32768 /**< Maximum words in the table */ +#define MAXWORDS 100 /**< Maximum length of a word */ +#define COLLISION_LIMIT 20 /**< Maximum allowed collisions */ -#define COMPRESS_HASH_MASK 0x7FFF /**< 32767 in hex */ +#define COMPRESS_HASH_MASK 0x7FFF /**< 32767 in hex */ -#define MARKER_CHAR 0x06 /**< Separates words. This char is the only one that can't be represented */ -#define TABLE_FLAG 0x80 /**< Distinguishes a table */ -#define TABLE_MASK 0x7F /**< Mask out words within a table */ +#define MARKER_CHAR 0x06 /**< Separates words. This char is the only one that can't be represented */ +#define TABLE_FLAG 0x80 /**< Distinguishes a table */ +#define TABLE_MASK 0x7F /**< Mask out words within a table */ /* Table of words */ @@ -164,7 +164,7 @@ int init_compress(FILE * f); #ifdef COMP_STATS void compress_stats(long *entries, long *mem_used, - long *total_uncompressed, long *total_compressed); + long *total_uncompressed, long *total_compressed); #endif static unsigned int hash_fn(const char *s, int hashtab_mask); @@ -174,7 +174,7 @@ char *p; int i, j; - word[wordpos++] = 0; /* word's trailing null */ + word[wordpos++] = 0; /* word's trailing null */ /* Don't bother putting few-letter words in the table */ @@ -191,15 +191,15 @@ (words[i] || (i & 0xFF) == 0) && j < COLLISION_LIMIT; i++, j++) if (words[i]) if (strcmp(word, words[i]) == 0) { - *b++ = MARKER_CHAR; - *b++ = (i >> 8) | TABLE_FLAG; - *b++ = i & 0xFF; - return; + *b++ = MARKER_CHAR; + *b++ = (i >> 8) | TABLE_FLAG; + *b++ = i & 0xFF; + return; } /* not in table, add to it */ if ((i & 0xFF) == 0) { - i++; /* make sure we don't have a null in the message */ + i++; /* make sure we don't have a null in the message */ j++; } /* Can't add to table if full */ @@ -227,7 +227,7 @@ *b++ = (i >> 8) | TABLE_FLAG; *b++ = i & 0xFF; -} /* end of output_previous_word */ +} /* end of output_previous_word */ /** Word-compress a string. * @@ -255,11 +255,11 @@ while (*p) { if (!(isdigit(*p) || isalpha(*p)) || wordpos >= MAXWORDS) { if (wordpos) { - word[wordpos++] = *p; /* add trailing punctuation */ - output_previous_word(); - wordpos = 0; + word[wordpos++] = *p; /* add trailing punctuation */ + output_previous_word(); + wordpos = 0; } else - *b++ = *p; + *b++ = *p; } else word[wordpos++] = *p; p++; @@ -268,15 +268,15 @@ if (wordpos) output_previous_word(); - *b = 0; /* trailing null */ + *b = 0; /* trailing null */ #ifdef COMP_STATS - total_comp += u_strlen(buf); /* calculate size of compressed text */ - total_uncomp += strlen(s); /* calculate size of uncompressed text */ + total_comp += u_strlen(buf); /* calculate size of compressed text */ + total_uncomp += strlen(s); /* calculate size of uncompressed text */ #endif return u_strdup(buf); -} /* end of compress; */ +} /* end of compress; */ /** Word-uncompress a string. @@ -314,16 +314,16 @@ c = *p; i = ((c & TABLE_MASK) << 8) | *(++p); if (i >= MAXTABLE || words[i] == NULL) { - static int panicking = 0; - if (panicking) { - fprintf(stderr, - "Error in string decompression occurred during panic dump.\n"); - exit(1); - } else { - panicking = 1; /* don't panic from within panic */ - fprintf(stderr, "Error in string decompression, i = %i\n", i); - mush_panic("Fatal error in decompression"); - } + static int panicking = 0; + if (panicking) { + fprintf(stderr, + "Error in string decompression occurred during panic dump.\n"); + exit(1); + } else { + panicking = 1; /* don't panic from within panic */ + fprintf(stderr, "Error in string decompression, i = %i\n", i); + mush_panic("Fatal error in decompression"); + } } strncpy((char *) b, words[i], words_len[i]); b += words_len[i] - 1; @@ -332,11 +332,11 @@ p++; } - *b++ = 0; /* trailing null */ + *b++ = 0; /* trailing null */ return buf; -} /* end of uncompress; */ +} /* end of uncompress; */ /** Word-uncompress a string, allocating memory. * this function should be used when you're doing something like @@ -377,7 +377,7 @@ */ void compress_stats(long *entries, long *mem_used, long *total_uncompressed, - long *total_compressed) + long *total_compressed) { *entries = total_entries; Index: src/unparse.c =================================================================== --- src/unparse.c (.../p5) (revision 1028) +++ src/unparse.c (.../p6) (revision 1028) @@ -114,7 +114,7 @@ */ const char * real_unparse(dbref player, dbref loc, int obey_myopic, int use_nameformat, - int use_nameaccent) + int use_nameaccent) { static char buf[BUFFER_LEN], *bp; static char tbuf1[BUFFER_LEN]; @@ -122,7 +122,7 @@ couldunparse = 0; if (!(GoodObject(loc) || (loc == NOTHING) || (loc == AMBIGUOUS) || - (loc == HOME))) + (loc == HOME))) return T("*NOTHING*"); switch (loc) { case NOTHING: @@ -138,30 +138,30 @@ strcpy(tbuf1, Name(loc)); if (IsExit(loc) && obey_myopic) { if ((p = strchr(tbuf1, ';'))) - *p = '\0'; + *p = '\0'; } if ((Can_Examine(player, loc) || can_link_to(player, loc) || - JumpOk(loc) || ChownOk(loc) || DestOk(loc)) && - (!Myopic(player) || !obey_myopic)) { + JumpOk(loc) || ChownOk(loc) || DestOk(loc)) && + (!Myopic(player) || !obey_myopic)) { /* show everything */ if (SUPPORT_PUEBLO) - couldunparse = 1; + couldunparse = 1; bp = buf; if (ANSI_NAMES && ShowAnsi(player)) - safe_format(buf, &bp, "%s%s%s(#%d%s)", ANSI_HILITE, tbuf1, - ANSI_NORMAL, loc, unparse_flags(loc, player)); + safe_format(buf, &bp, "%s%s%s(#%d%s)", ANSI_HILITE, tbuf1, + ANSI_NORMAL, loc, unparse_flags(loc, player)); else - safe_format(buf, &bp, "%s(#%d%s)", tbuf1, loc, - unparse_flags(loc, player)); + safe_format(buf, &bp, "%s(#%d%s)", tbuf1, loc, + unparse_flags(loc, player)); *bp = '\0'; } else { /* show only the name */ if (ANSI_NAMES && ShowAnsi(player)) { - bp = buf; - safe_format(buf, &bp, "%s%s%s", ANSI_HILITE, tbuf1, ANSI_NORMAL); - *bp = '\0'; + bp = buf; + safe_format(buf, &bp, "%s%s%s", ANSI_HILITE, tbuf1, ANSI_NORMAL); + *bp = '\0'; } else - strcpy(buf, tbuf1); + strcpy(buf, tbuf1); } } /* buf now contains the default formatting of the name. If we @@ -213,7 +213,7 @@ sp = save = safe_atr_value(a); bp = tbuf1; process_expression(tbuf1, &bp, &sp, loc, player, player, - PE_DEFAULT, PT_DEFAULT, NULL); + PE_DEFAULT, PT_DEFAULT, NULL); *bp = '\0'; free((Malloc_t) save); for (j = 0; j < 10; j++) { @@ -283,7 +283,7 @@ char * unparse_number(NVAL num) { - static char str[100]; /* Should be large enough for even the HUGE floats */ + static char str[100]; /* Should be large enough for even the HUGE floats */ char *p; sprintf(str, "%.*f", FLOAT_PRECISION, num); Index: src/services.c =================================================================== --- src/services.c (.../p5) (revision 1028) +++ src/services.c (.../p6) (revision 1028) @@ -1,13 +1,16 @@ -/* Win32 services routines */ - -/* Author: Nick Gammon */ +/** \file services.c + * \brief Win32 services routines + * + * Original author: Nick Gammon + */ -#ifdef WIN32 #include "copyrite.h" #include "config.h" -#include /* for service and thread routines */ +#ifdef WIN32 + +#include /* for service and thread routines */ #include #include @@ -30,7 +33,7 @@ void mainthread(int argc, char **argv); -SERVICE_STATUS ssStatus; /* current status of the service */ +SERVICE_STATUS ssStatus; /* current status of the service */ SERVICE_STATUS_HANDLE sshStatusHandle; DWORD dwGlobalErr; @@ -44,8 +47,8 @@ VOID service_main(DWORD dwArgc, LPTSTR * lpszArgv); VOID WINAPI service_ctrl(DWORD dwCtrlCode); BOOL ReportStatusToSCMgr(DWORD dwCurrentState, - DWORD dwWin32ExitCode, - DWORD dwCheckPoint, DWORD dwWaitHint); + DWORD dwWin32ExitCode, + DWORD dwCheckPoint, DWORD dwWaitHint); VOID worker_thread(VOID * notused); VOID StopService(LPTSTR lpszMsg); @@ -100,8 +103,8 @@ status = get_service_status(&svcstatus, TRUE); if (status == 0 && svcstatus.dwCurrentState == SERVICE_RUNNING) { - fprintf(stderr, T("The MUSH is already running as a service.\n")); - return 1; + fprintf(stderr, T("The MUSH is already running as a service.\n")); + return 1; } worker_thread(NULL); } else @@ -133,17 +136,17 @@ fprintf(stderr, T("Attempting to start PennMUSH as a service ...\n")); if (!StartServiceCtrlDispatcher(dispatchTable)) { fprintf(stderr, - T - ("Unable to start service, assuming running console-mode application.\n")); + T + ("Unable to start service, assuming running console-mode application.\n")); fprintf(stderr, - T - ("You can save time on the next invocation by specifying: pennmush /run\n")); + T + ("You can save time on the next invocation by specifying: pennmush /run\n")); worker_thread(NULL); } - } /* end of argc == 1 */ + } /* end of argc == 1 */ return 0; -} /* end of main */ +} /* end of main */ /* service_main() -- */ @@ -168,35 +171,35 @@ /* report the status to Service Control Manager. */ - if (!ReportStatusToSCMgr(SERVICE_START_PENDING, /* service state */ - NO_ERROR, /* exit code */ - 1, /* checkpoint */ - 3000)) /* wait hint */ + if (!ReportStatusToSCMgr(SERVICE_START_PENDING, /* service state */ + NO_ERROR, /* exit code */ + 1, /* checkpoint */ + 3000)) /* wait hint */ goto cleanup; /* start the thread that performs the work of the service. */ - threadHandle = (HANDLE) _beginthreadex(NULL, /* security attributes */ - 0, /* stack size (0 means inherit parent's stack size) */ - (LPTHREAD_START_ROUTINE) worker_thread, NULL, /* argument to thread */ - 0, /* thread creation flags */ - &TID); /* pointer to thread ID */ + threadHandle = (HANDLE) _beginthreadex(NULL, /* security attributes */ + 0, /* stack size (0 means inherit parent's stack size) */ + (LPTHREAD_START_ROUTINE) worker_thread, NULL, /* argument to thread */ + 0, /* thread creation flags */ + &TID); /* pointer to thread ID */ if (!threadHandle) goto cleanup; /* report the status to the service control manager. */ - if (!ReportStatusToSCMgr(SERVICE_RUNNING, /* service state */ - NO_ERROR, /* exit code */ - 0, /* checkpoint */ - 0)) /* wait hint */ + if (!ReportStatusToSCMgr(SERVICE_RUNNING, /* service state */ + NO_ERROR, /* exit code */ + 0, /* checkpoint */ + 0)) /* wait hint */ goto cleanup; /* wait indefinitely until threadHandle is signaled. */ /* The thread handle is signalled when the thread terminates */ - dwWait = WaitForSingleObject(threadHandle, /* event object */ - INFINITE); /* wait indefinitely */ + dwWait = WaitForSingleObject(threadHandle, /* event object */ + INFINITE); /* wait indefinitely */ cleanup: @@ -208,7 +211,7 @@ /* process, the StartServiceCtrlDispatcher function in */ /* the main thread returns, terminating the process. */ return; -} /* end of service_main */ +} /* end of service_main */ @@ -248,10 +251,10 @@ /* Report the status, specifying the checkpoint and waithint, */ /* before setting the termination event. */ - ReportStatusToSCMgr(SERVICE_STOP_PENDING, /* current state */ - NO_ERROR, /* exit code */ - 1, /* checkpoint */ - 10000); /* waithint (10 secs) */ + ReportStatusToSCMgr(SERVICE_STOP_PENDING, /* current state */ + NO_ERROR, /* exit code */ + 1, /* checkpoint */ + 10000); /* waithint (10 secs) */ shutdown_flag = 1; @@ -267,11 +270,11 @@ default: break; - } /* end of switch */ + } /* end of switch */ /* send a status response. */ ReportStatusToSCMgr(dwState, NO_ERROR, 0, 0); -} /* end of service_ctrl */ +} /* end of service_ctrl */ /* utility functions... */ @@ -284,7 +287,7 @@ /* to the service control manager. */ static BOOL ReportStatusToSCMgr(DWORD dwCurrentState, - DWORD dwWin32ExitCode, DWORD dwCheckPoint, DWORD dwWaitHint) + DWORD dwWin32ExitCode, DWORD dwCheckPoint, DWORD dwWaitHint) { BOOL fResult; @@ -303,14 +306,14 @@ ssStatus.dwWaitHint = dwWaitHint; /* Report the status of the service to the service control manager. */ - if (!(fResult = SetServiceStatus(sshStatusHandle, /* service reference handle */ - &ssStatus))) { /* SERVICE_STATUS structure */ + if (!(fResult = SetServiceStatus(sshStatusHandle, /* service reference handle */ + &ssStatus))) { /* SERVICE_STATUS structure */ /* If an error occurs, stop the service. */ StopService("SetServiceStatus"); } return fResult; -} /* end of ReportStatusToSCMgr */ +} /* end of ReportStatusToSCMgr */ @@ -333,21 +336,21 @@ lpszStrings[1] = lpszMsg; if (hEventSource) { - ReportEvent(hEventSource, /* handle of event source */ - EVENTLOG_ERROR_TYPE, /* event type */ - 0, /* event category */ - 0, /* event ID */ - NULL, /* current user's SID */ - 2, /* strings in lpszStrings */ - 0, /* no bytes of raw data */ - lpszStrings, /* array of error strings */ - NULL); /* no raw data */ + ReportEvent(hEventSource, /* handle of event source */ + EVENTLOG_ERROR_TYPE, /* event type */ + 0, /* event category */ + 0, /* event ID */ + NULL, /* current user's SID */ + 2, /* strings in lpszStrings */ + 0, /* no bytes of raw data */ + lpszStrings, /* array of error strings */ + NULL); /* no raw data */ (VOID) DeregisterEventSource(hEventSource); } if (threadHandle) TerminateThread(threadHandle, 1); -} /* end of StopService */ +} /* end of StopService */ /* called at shutdown, ctrl-c etc. */ @@ -369,7 +372,7 @@ } return FALSE; -} /* end of shut_down_handler */ +} /* end of shut_down_handler */ /* @@ -432,7 +435,7 @@ mainthread(argc, argv); -} /* end of worker_thread */ +} /* end of worker_thread */ void WIN32_CDECL Win32_Exit(int exit_code) @@ -446,7 +449,7 @@ else _exit(exit_code); -} /* end of Win32_Exit */ +} /* end of Win32_Exit */ /* this is called from db_write (every 256 objects) */ /* to keep the service manager happy (it needs a checkpoint every 3 seconds) */ @@ -457,12 +460,12 @@ static DWORD checkpoint = 1; if (threadHandle && shutdown_flag) - ReportStatusToSCMgr(SERVICE_STOP_PENDING, /* current state */ - NO_ERROR, /* exit code */ - ++checkpoint, /* checkpoint */ - 3000); /* waithint (3 seconds) */ + ReportStatusToSCMgr(SERVICE_STOP_PENDING, /* current state */ + NO_ERROR, /* exit code */ + ++checkpoint, /* checkpoint */ + 3000); /* waithint (3 seconds) */ -} /* end of shutdown_checkpoint */ +} /* end of shutdown_checkpoint */ /* We need to close these handles so often I'll do it in a separate routine */ @@ -476,7 +479,7 @@ if (SCmanager) CloseServiceHandle(SCmanager); SCmanager = NULL; -} /* end of close_service_handles */ +} /* end of close_service_handles */ /* We put out *so* many error messages, let's centralise the whole thing */ @@ -498,12 +501,12 @@ if (error_code) fprintf(stderr, " ** Error %ld\n ** %s\n", - error_code, convert_error(error_code)); + error_code, convert_error(error_code)); close_service_handles(); return TRUE; -} /* end of service_error */ +} /* end of service_error */ /* Open a handle to the Service Control Manager. @@ -517,11 +520,11 @@ if (!SCmanager) return service_error(GetLastError(), - T("Unable to talk to the Service Control Manager")); + T("Unable to talk to the Service Control Manager")); return FALSE; -} /* end of openServiceManager */ +} /* end of openServiceManager */ /* @@ -536,7 +539,7 @@ return service_error(GetLastError(), T("Cannot access service definition")); return FALSE; -} /* end of get_service */ +} /* end of get_service */ /* Opens the service manager and gets the status, optionally leaving @@ -582,7 +585,7 @@ return 0; -} /* end of get_service_status */ +} /* end of get_service_status */ /* Install this service. @@ -611,11 +614,11 @@ Now create the service definition. */ - service = CreateService(SCmanager, THIS_SERVICE, THIS_SERVICE_DISPLAY, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, fullfilename, NULL, /* no load ordering group */ - NULL, /* no tag identifier */ - NULL, /* no dependencies */ - NULL, /* LocalSystem account */ - NULL); /* no password */ + service = CreateService(SCmanager, THIS_SERVICE, THIS_SERVICE_DISPLAY, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, fullfilename, NULL, /* no load ordering group */ + NULL, /* no tag identifier */ + NULL, /* no dependencies */ + NULL, /* LocalSystem account */ + NULL); /* no password */ if (!service) return service_error(GetLastError(), T("Unable to create service")); @@ -625,7 +628,7 @@ fprintf(stderr, T("Service successfully installed\n")); return FALSE; -} /* end of CmdInstallService */ +} /* end of CmdInstallService */ /* Remove this service. @@ -650,8 +653,8 @@ if (svcstatus.dwCurrentState != SERVICE_STOPPED) return service_error(0, - T - ("You must stop the service before you can remove it.")); + T + ("You must stop the service before you can remove it.")); /* Everything is fine, so delete the service definition. @@ -665,7 +668,7 @@ fprintf(stderr, T("Service successfully removed\n")); return FALSE; -} /* end of CmdRemoveService */ +} /* end of CmdRemoveService */ /* @@ -700,7 +703,7 @@ fprintf(stderr, T("Start request sent to service\n")); return FALSE; -} /* end of CmdStartService */ +} /* end of CmdStartService */ /* Stop this service. @@ -734,7 +737,7 @@ fprintf(stderr, T("Stop request sent to service\n")); return FALSE; -} /* end of CmdStopService */ +} /* end of CmdStopService */ /* @@ -780,12 +783,12 @@ default: p = T("Unrecognised status."); break; - } /* end of switch */ + } /* end of switch */ fprintf(stderr, "%s\n", p); return FALSE; -} /* end of CmdStatusService */ +} /* end of CmdStatusService */ @@ -798,18 +801,18 @@ { fprintf(stderr, T("Usage is :-\n")); fprintf(stderr, T(" %s - runs as a service, or stand-alone\n"), - THIS_SERVICE); + THIS_SERVICE); fprintf(stderr, T(" %s /run - runs stand-alone\n"), THIS_SERVICE); fprintf(stderr, T(" %s /start - starts this service\n"), THIS_SERVICE); fprintf(stderr, T(" %s /stop - stops this service\n"), THIS_SERVICE); fprintf(stderr, T(" %s /install - installs this service\n"), THIS_SERVICE); fprintf(stderr, T(" %s /remove - removes (un-installs) this service\n"), - THIS_SERVICE); + THIS_SERVICE); fprintf(stderr, T(" %s /status - displays the status of this service\n"), - THIS_SERVICE); + THIS_SERVICE); fprintf(stderr, T(" %s /help - displays this information\n"), - THIS_SERVICE); -} /* end of CmdDisplayFormat */ + THIS_SERVICE); +} /* end of CmdDisplayFormat */ static char * convert_error(DWORD error) @@ -819,16 +822,16 @@ static char buff[100]; if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - error, LANG_NEUTRAL, (LPTSTR) & formattedmsg, 0, NULL)) { + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + error, LANG_NEUTRAL, (LPTSTR) & formattedmsg, 0, NULL)) { sprintf(buff, "", error); return buff; } else return formattedmsg; -} /* end of convert_error */ +} /* end of convert_error */ -#endif /* WIN32SERVICES */ -#endif /* WIN32 */ +#endif /* WIN32SERVICES */ +#endif /* WIN32 */ Index: src/attrib.c =================================================================== --- src/attrib.c (.../p5) (revision 1028) +++ src/attrib.c (.../p6) (revision 1028) @@ -28,7 +28,7 @@ #include "confmagic.h" #ifdef WIN32 -#pragma warning( disable : 4761) /* disable warning re conversion */ +#pragma warning( disable : 4761) /* disable warning re conversion */ #endif /** A string tree of attribute names in use, to save us memory since @@ -40,7 +40,7 @@ extern PRIV attr_privs_view[]; static int real_atr_clr(dbref thinking, char const *atr, dbref player, - int we_are_wiping); + int we_are_wiping); /** A string to hold the name of a missing prefix branch, set by @@ -59,7 +59,7 @@ * and build a linked free list from the allocated page. */ typedef struct atrpage { - ATTR atrs[ATTRS_PER_PAGE]; /**< Array of attribute structures */ + ATTR atrs[ATTRS_PER_PAGE]; /**< Array of attribute structures */ } ATTRPAGE; static ATTR *atr_free_list = NULL; @@ -69,7 +69,7 @@ static void atr_free_one(ATTR *); static ATTR *find_atr_pos_in_list(ATTR ***pos, char const *name); static atr_err can_create_attr(dbref player, dbref obj, char const *atr_name, - unsigned int flags); + unsigned int flags); static ATTR *find_atr_in_list(ATTR *atr, char const *name); static ATTR *atr_get_with_parent(dbref obj, char const *atrname, dbref *parent); @@ -139,9 +139,9 @@ return NULL; if (n2[len] == '`') { if (!strncmp(n2, name, len)) - return branch; + return branch; else - return NULL; + return NULL; } } return NULL; @@ -280,8 +280,8 @@ visible = (player == NOTHING); if (visible) { cansee = (Visual(obj) && - eval_lock(PLAYER_START, obj, Examine_Lock) && - eval_lock(MASTER_ROOM, obj, Examine_Lock)); + eval_lock(PLAYER_START, obj, Examine_Lock) && + eval_lock(MASTER_ROOM, obj, Examine_Lock)); canlook = 0; } else { cansee = controls(player, obj) || @@ -293,9 +293,9 @@ /* If we can't see the attribute itself, then that's easy. */ if (AF_Internal(atr) || AF_Mdark(atr) || !(cansee || - (AF_Visual(atr) && (!AF_Nearby(atr) || canlook)) || - (!visible && !Mistrust(player) && - (Owner(AL_CREATOR(atr)) == Owner(player))))) + (AF_Visual(atr) && (!AF_Nearby(atr) || canlook)) || + (!visible && !Mistrust(player) && + (Owner(AL_CREATOR(atr)) == Owner(player))))) return 0; /* If the attribute isn't on a branch, then that's also easy. */ if (!strchr(AL_NAME(atr), '`')) @@ -317,15 +317,15 @@ *p = '\0'; atr = find_atr_in_list(atr, name); if (!atr || (target != obj && AF_Private(atr))) { - *p = '`'; - goto continue_target; + *p = '`'; + goto continue_target; } if (AF_Internal(atr) || AF_Mdark(atr) || - !(cansee || - (AF_Visual(atr) && (!AF_Nearby(atr) || canlook)) || - (!visible && !Mistrust(player) && - (Owner(AL_CREATOR(atr)) == Owner(player))))) - return 0; + !(cansee || + (AF_Visual(atr) && (!AF_Nearby(atr) || canlook)) || + (!visible && !Mistrust(player) && + (Owner(AL_CREATOR(atr)) == Owner(player))))) + return 0; *p = '`'; } @@ -422,7 +422,7 @@ */ static int can_create_attr(dbref player, dbref obj, char const *atr_name, - unsigned int flags) + unsigned int flags) { char *p; ATTR tmpatr, *atr; @@ -468,8 +468,8 @@ if ((AttrCount(obj) + num_new) > (Many_Attribs(obj) ? HARD_MAX_ATTRCOUNT : MAX_ATTRCOUNT)) { do_log(LT_ERR, player, obj, - T("Attempt by %s(%d) to create too many attributes on %s(%d)"), - Name(player), player, Name(obj), obj); + T("Attempt by %s(%d) to create too many attributes on %s(%d)"), + Name(player), player, Name(obj), obj); return AE_TOOMANY; } @@ -530,7 +530,7 @@ */ void atr_new_add(dbref thing, const char *RESTRICT atr, const char *RESTRICT s, - dbref player, unsigned int flags, unsigned char derefs) + dbref player, unsigned int flags, unsigned char derefs) { ATTR *ptr; char *p, root_name[ATTRIBUTE_NAME_LIMIT + 1]; @@ -541,7 +541,7 @@ /* Don't fail on a bad name, but do log it */ if (!good_atr_name(atr)) do_rawlog(LT_ERR, T("Bad attribute name %s on object %s"), atr, - unparse_dbref(thing)); + unparse_dbref(thing)); ptr = create_atr(thing, atr); if (!ptr) @@ -554,22 +554,22 @@ root = find_atr_in_list(List(thing), root_name); if (!root) { do_rawlog(LT_ERR, T("Missing root attribute '%s' on object #%d!\n"), - root_name, thing); + root_name, thing); root = create_atr(thing, root_name); set_default_flags(root, 0); AL_FLAGS(root) |= AF_ROOT; AL_CREATOR(root) = player; if (!EMPTY_ATTRS) { - unsigned char *t = compress(" "); - if (!t) { - mush_panic(T("Unable to allocate memory in atr_new_add()!")); - } - root->data = chunk_create(t, u_strlen(t), 0); - free(t); + unsigned char *t = compress(" "); + if (!t) { + mush_panic(T("Unable to allocate memory in atr_new_add()!")); + } + root->data = chunk_create(t, u_strlen(t), 0); + free(t); } } else { - if (!AL_FLAGS(root) & AF_ROOT) /* Upgrading old database */ - AL_FLAGS(root) |= AF_ROOT; + if (!AL_FLAGS(root) & AF_ROOT) /* Upgrading old database */ + AL_FLAGS(root) |= AF_ROOT; } } @@ -611,7 +611,7 @@ */ atr_err atr_add(dbref thing, const char *RESTRICT atr, const char *RESTRICT s, - dbref player, unsigned int flags) + dbref player, unsigned int flags) { ATTR *ptr, *root = NULL; char *p; @@ -645,28 +645,28 @@ root = find_atr_in_list(ptr, missing_name); if (!root) { - root = create_atr(thing, missing_name); - if (!root) - return AE_TREE; + root = create_atr(thing, missing_name); + if (!root) + return AE_TREE; - /* update modification time here, because from now on, - * we modify even if we fail */ - if (!IsPlayer(thing) && !AF_Nodump(root)) - ModTime(thing) = mudtime; + /* update modification time here, because from now on, + * we modify even if we fail */ + if (!IsPlayer(thing) && !AF_Nodump(root)) + ModTime(thing) = mudtime; - set_default_flags(root, flags); - AL_FLAGS(root) &= ~AF_COMMAND & ~AF_LISTEN; - AL_FLAGS(root) |= AF_ROOT; - AL_CREATOR(root) = Owner(player); - if (!EMPTY_ATTRS) { - unsigned char *t = compress(" "); - if (!t) - mush_panic(T("Unable to allocate memory in atr_add()!")); - root->data = chunk_create(t, u_strlen(t), 0); - free(t); - } + set_default_flags(root, flags); + AL_FLAGS(root) &= ~AF_COMMAND & ~AF_LISTEN; + AL_FLAGS(root) |= AF_ROOT; + AL_CREATOR(root) = Owner(player); + if (!EMPTY_ATTRS) { + unsigned char *t = compress(" "); + if (!t) + mush_panic(T("Unable to allocate memory in atr_add()!")); + root->data = chunk_create(t, u_strlen(t), 0); + free(t); + } } else - AL_FLAGS(root) |= AF_ROOT; + AL_FLAGS(root) |= AF_ROOT; *p = '`'; } @@ -729,10 +729,10 @@ sub && string_prefix(AL_NAME(sub), AL_NAME(root)); sub = next) { if (AL_FLAGS(sub) & AF_ROOT) { if (!atr_clear_children(player, thing, sub)) { - skipped++; - next = AL_NEXT(sub); - prev = sub; - continue; + skipped++; + next = AL_NEXT(sub); + prev = sub; + continue; } } @@ -810,11 +810,11 @@ *p = '`'; if (!root) { - do_rawlog(LT_ERR, T("Attribute %s on object #%d lacks a parent!"), - root_name, thing); + do_rawlog(LT_ERR, T("Attribute %s on object #%d lacks a parent!"), + root_name, thing); } else { - if (!atr_sub_branch(root)) - AL_FLAGS(root) &= ~AF_ROOT; + if (!atr_sub_branch(root)) + AL_FLAGS(root) &= ~AF_ROOT; } } @@ -892,29 +892,29 @@ * we use it there, and don't check the ancestor later. */ if (target == ancestor) - ancestor = NOTHING; + ancestor = NOTHING; atr = List(target); /* If we're looking at a parent/ancestor, then we * need to check the branch path for privacy... */ if (target != obj) { - for (p = strchr(name, '`'); p; p = strchr(p + 1, '`')) { - *p = '\0'; - atr = find_atr_in_list(atr, name); - if (!atr || AF_Private(atr)) { - *p = '`'; - goto continue_target; - } - *p = '`'; - } + for (p = strchr(name, '`'); p; p = strchr(p + 1, '`')) { + *p = '\0'; + atr = find_atr_in_list(atr, name); + if (!atr || AF_Private(atr)) { + *p = '`'; + goto continue_target; + } + *p = '`'; + } } /* Now actually find the attribute. */ atr = find_atr_in_list(atr, name); if (atr && (target == obj || !AF_Private(atr))) { - if (parent) - *parent = target; - return atr; + if (parent) + *parent = target; + return atr; } continue_target: @@ -922,8 +922,8 @@ parent_depth++; target = Parent(target); if (!GoodObject(target)) { - parent_depth = 0; - target = ancestor; + parent_depth = 0; + target = ancestor; } } @@ -989,7 +989,7 @@ */ int atr_iter_get(dbref player, dbref thing, const char *name, int mortal, - aig_func func, void *args) + aig_func func, void *args) { ATTR *ptr, **indirect; int result; @@ -1003,17 +1003,17 @@ if (!wildcard(name) && name[len - 1] != '`') { ptr = atr_get_noparent(thing, strupper(name)); if (ptr && (mortal ? Is_Visible_Attr(thing, ptr) - : Can_Read_Attr(player, thing, ptr))) + : Can_Read_Attr(player, thing, ptr))) result = func(player, thing, NOTHING, name, ptr, args); } else { indirect = &List(thing); while (*indirect) { ptr = *indirect; if ((mortal ? Is_Visible_Attr(thing, ptr) - : Can_Read_Attr(player, thing, ptr)) && atr_wild(name, AL_NAME(ptr))) - result += func(player, thing, NOTHING, name, ptr, args); + : Can_Read_Attr(player, thing, ptr)) && atr_wild(name, AL_NAME(ptr))) + result += func(player, thing, NOTHING, name, ptr, args); if (ptr == *indirect) - indirect = &AL_NEXT(ptr); + indirect = &AL_NEXT(ptr); } } @@ -1032,7 +1032,7 @@ */ int atr_pattern_count(dbref player, dbref thing, const char *name, - int doparent, int mortal) + int doparent, int mortal) { ATTR *ptr, **indirect; int result; @@ -1051,29 +1051,29 @@ else ptr = atr_get_noparent(thing, strupper(name)); if (ptr && (mortal ? Is_Visible_Attr(parent, ptr) - : Can_Read_Attr(player, parent, ptr))) + : Can_Read_Attr(player, parent, ptr))) result += 1; } else { StrTree seen; int parent_depth; st_init(&seen); for (parent_depth = MAX_PARENTS + 1, parent = thing; - (parent_depth-- && parent != NOTHING) && - (doparent || (parent == thing)); parent = Parent(parent)) { + (parent_depth-- && parent != NOTHING) && + (doparent || (parent == thing)); parent = Parent(parent)) { indirect = &List(parent); while (*indirect) { - ptr = *indirect; - if (!st_find(AL_NAME(ptr), &seen)) { - st_insert(AL_NAME(ptr), &seen); - if ((parent == thing) || !AF_Private(ptr)) { - if ((mortal ? Is_Visible_Attr(parent, ptr) - : Can_Read_Attr(player, parent, ptr)) - && atr_wild(name, AL_NAME(ptr))) - result += 1; - } - } - if (ptr == *indirect) - indirect = &AL_NEXT(ptr); + ptr = *indirect; + if (!st_find(AL_NAME(ptr), &seen)) { + st_insert(AL_NAME(ptr), &seen); + if ((parent == thing) || !AF_Private(ptr)) { + if ((mortal ? Is_Visible_Attr(parent, ptr) + : Can_Read_Attr(player, parent, ptr)) + && atr_wild(name, AL_NAME(ptr))) + result += 1; + } + } + if (ptr == *indirect) + indirect = &AL_NEXT(ptr); } } st_flush(&seen); @@ -1097,7 +1097,7 @@ */ int atr_iter_get_parent(dbref player, dbref thing, const char *name, int mortal, - aig_func func, void *args) + aig_func func, void *args) { ATTR *ptr, **indirect; int result; @@ -1112,28 +1112,28 @@ if (!wildcard(name) && name[len - 1] != '`') { ptr = atr_get_with_parent(thing, strupper(name), &parent); if (ptr && (mortal ? Is_Visible_Attr(parent, ptr) - : Can_Read_Attr(player, parent, ptr))) + : Can_Read_Attr(player, parent, ptr))) result = func(player, thing, parent, name, ptr, args); } else { StrTree seen; int parent_depth; st_init(&seen); for (parent_depth = MAX_PARENTS + 1, parent = thing; - parent_depth-- && parent != NOTHING; parent = Parent(parent)) { + parent_depth-- && parent != NOTHING; parent = Parent(parent)) { indirect = &List(parent); while (*indirect) { - ptr = *indirect; - if (!st_find(AL_NAME(ptr), &seen)) { - st_insert(AL_NAME(ptr), &seen); - if ((parent == thing) || !AF_Private(ptr)) { - if ((mortal ? Is_Visible_Attr(parent, ptr) - : Can_Read_Attr(player, parent, ptr)) - && atr_wild(name, AL_NAME(ptr))) - result += func(player, thing, parent, name, ptr, args); - } - } - if (ptr == *indirect) - indirect = &AL_NEXT(ptr); + ptr = *indirect; + if (!st_find(AL_NAME(ptr), &seen)) { + st_insert(AL_NAME(ptr), &seen); + if ((parent == thing) || !AF_Private(ptr)) { + if ((mortal ? Is_Visible_Attr(parent, ptr) + : Can_Read_Attr(player, parent, ptr)) + && atr_wild(name, AL_NAME(ptr))) + result += func(player, thing, parent, name, ptr, args); + } + } + if (ptr == *indirect) + indirect = &AL_NEXT(ptr); } } st_flush(&seen); @@ -1184,9 +1184,9 @@ List(dest) = NULL; for (ptr = List(source); ptr; ptr = AL_NEXT(ptr)) if (!AF_Nocopy(ptr) - && (AttrCount(dest) < max_attrs)) { + && (AttrCount(dest) < max_attrs)) { atr_new_add(dest, AL_NAME(ptr), atr_value(ptr), - AL_CREATOR(ptr), AL_FLAGS(ptr), AL_DEREFS(ptr)); + AL_CREATOR(ptr), AL_FLAGS(ptr), AL_DEREFS(ptr)); AttrCount(dest)++; } } @@ -1194,9 +1194,9 @@ /** Structure for keeping track of which attributes have appeared * on children when doing command matching. */ typedef struct used_attr { - struct used_attr *next; /**< Next attribute in list */ - char const *name; /**< The name of the attribute */ - int no_prog; /**< Was it AF_NOPROG */ + struct used_attr *next; /**< Next attribute in list */ + char const *name; /**< The name of the attribute */ + int no_prog; /**< Was it AF_NOPROG */ } UsedAttr; /** Find an attribute in the list of seen attributes. @@ -1281,7 +1281,7 @@ */ int atr_comm_match(dbref thing, dbref player, int type, int end, char const *str, - int just_match, char *atrname, char **abp, dbref *errobj) + int just_match, char *atrname, char **abp, dbref *errobj) { int flag_mask; ATTR *ptr; @@ -1325,9 +1325,9 @@ if (skipcount && ptr == skip[skipcount - 1]) { size_t len = strrchr(AL_NAME(ptr), '`') - AL_NAME(ptr); while (AL_NEXT(ptr) && strlen(AL_NAME(AL_NEXT(ptr))) > len && - AL_NAME(AL_NEXT(ptr))[len] == '`') { - ptr = AL_NEXT(ptr); - /* do_rawlog(LT_TRACE, " Skipping %s", AL_NAME(ptr)); */ + AL_NAME(AL_NEXT(ptr))[len] == '`') { + ptr = AL_NEXT(ptr); + /* do_rawlog(LT_TRACE, " Skipping %s", AL_NAME(ptr)); */ } skipcount--; continue; @@ -1337,7 +1337,7 @@ if (AF_Noprog(ptr)) { skip[skipcount] = atr_sub_branch(ptr); if (skip[skipcount]) - skipcount++; + skipcount++; continue; } if (!(AL_FLAGS(ptr) & flag_mask)) @@ -1352,17 +1352,17 @@ *s++ = '\0'; if (type == '^' && !AF_Ahear(ptr)) { if ((thing == player && !AF_Mhear(ptr)) - || (thing != player && AF_Mhear(ptr))) - continue; + || (thing != player && AF_Mhear(ptr))) + continue; } if (AF_Regexp(ptr)) { /* Turn \: into : */ char *from, *to; for (from = tbuf1, to = tbuf2; *from; from++, to++) { - if (*from == '\\' && *(from + 1) == ':') - from++; - *to = *from; + if (*from == '\\' && *(from + 1) == ':') + from++; + *to = *from; } *to = '\0'; } else @@ -1371,19 +1371,19 @@ match_found = 0; if (AF_Regexp(ptr)) { if (regexp_match_case_r(tbuf2 + 1, str, AF_Case(ptr), - global_eval_context.wnxt, 10, - match_space, match_space_len)) { - match_found = 1; - match++; + global_eval_context.wnxt, 10, + match_space, match_space_len)) { + match_found = 1; + match++; } } else { if (quick_wild_new(tbuf2 + 1, str, AF_Case(ptr))) { - match_found = 1; - match++; - if (!just_match) - wild_match_case_r(tbuf2 + 1, str, AF_Case(ptr), - global_eval_context.wnxt, 10, - match_space, match_space_len); + match_found = 1; + match++; + if (!just_match) + wild_match_case_r(tbuf2 + 1, str, AF_Case(ptr), + global_eval_context.wnxt, 10, + match_space, match_space_len); } } if (match_found) { @@ -1393,25 +1393,25 @@ * run the lock once for 'foo bar'. */ if (!lock_checked) { - lock_checked = 1; - if ((type == '$' && !eval_lock(player, thing, Command_Lock)) - || (type == '^' && !eval_lock(player, thing, Listen_Lock)) - || !eval_lock(player, thing, Use_Lock)) { - match--; - if (errobj) - *errobj = thing; - /* If we failed the lock, there's no point in continuing at all. */ - goto exit_sequence; - } + lock_checked = 1; + if ((type == '$' && !eval_lock(player, thing, Command_Lock)) + || (type == '^' && !eval_lock(player, thing, Listen_Lock)) + || !eval_lock(player, thing, Use_Lock)) { + match--; + if (errobj) + *errobj = thing; + /* If we failed the lock, there's no point in continuing at all. */ + goto exit_sequence; + } } if (atrname && abp) { - safe_chr(' ', atrname, abp); - safe_dbref(thing, atrname, abp); - safe_chr('/', atrname, abp); - safe_str(AL_NAME(ptr), atrname, abp); + safe_chr(' ', atrname, abp); + safe_dbref(thing, atrname, abp); + safe_chr('/', atrname, abp); + safe_str(AL_NAME(ptr), atrname, abp); } if (!just_match) - parse_que(thing, s, player); + parse_que(thing, s, player); } } @@ -1427,118 +1427,118 @@ prev = &used_list; for (ptr = List(parent); ptr; ptr = AL_NEXT(ptr)) { if (skipcount && ptr == skip[skipcount - 1]) { - size_t len = strrchr(AL_NAME(ptr), '`') - AL_NAME(ptr); - while (AL_NEXT(ptr) && strlen(AL_NAME(AL_NEXT(ptr))) > len && - AL_NAME(AL_NEXT(ptr))[len] == '`') { - ptr = AL_NEXT(ptr); - /* do_rawlog(LT_TRACE, " Skipping %s", AL_NAME(ptr)); */ - } - skipcount--; - continue; + size_t len = strrchr(AL_NAME(ptr), '`') - AL_NAME(ptr); + while (AL_NEXT(ptr) && strlen(AL_NAME(AL_NEXT(ptr))) > len && + AL_NAME(AL_NEXT(ptr))[len] == '`') { + ptr = AL_NEXT(ptr); + /* do_rawlog(LT_TRACE, " Skipping %s", AL_NAME(ptr)); */ + } + skipcount--; + continue; } if (AF_Private(ptr)) { - /* do_rawlog(LT_TRACE, "Private %s:", AL_NAME(ptr)); */ - skip[skipcount] = atr_sub_branch(ptr); - if (skip[skipcount]) - skipcount++; - continue; + /* do_rawlog(LT_TRACE, "Private %s:", AL_NAME(ptr)); */ + skip[skipcount] = atr_sub_branch(ptr); + if (skip[skipcount]) + skipcount++; + continue; } if (find_attr(&prev, AL_NAME(ptr))) { - /* do_rawlog(LT_TRACE, "Found %s:", AL_NAME(ptr)); */ - if (prev[0]->no_prog || AF_Noprog(ptr)) { - skip[skipcount] = atr_sub_branch(ptr); - if (skip[skipcount]) - skipcount++; - prev[0]->no_prog = AF_NOPROG; - } - continue; + /* do_rawlog(LT_TRACE, "Found %s:", AL_NAME(ptr)); */ + if (prev[0]->no_prog || AF_Noprog(ptr)) { + skip[skipcount] = atr_sub_branch(ptr); + if (skip[skipcount]) + skipcount++; + prev[0]->no_prog = AF_NOPROG; + } + continue; } if (GoodObject(Parent(parent))) - prev = use_attr(prev, AL_NAME(ptr), AF_Noprog(ptr)); + prev = use_attr(prev, AL_NAME(ptr), AF_Noprog(ptr)); if (AF_Noprog(ptr)) { - /* do_rawlog(LT_TRACE, "NoProg %s:", AL_NAME(ptr)); */ - skip[skipcount] = atr_sub_branch(ptr); - if (skip[skipcount]) - skipcount++; - continue; + /* do_rawlog(LT_TRACE, "NoProg %s:", AL_NAME(ptr)); */ + skip[skipcount] = atr_sub_branch(ptr); + if (skip[skipcount]) + skipcount++; + continue; } if (!(AL_FLAGS(ptr) & flag_mask)) - continue; + continue; strcpy(tbuf1, atr_value(ptr)); s = tbuf1; do { - s = strchr(s + 1, end); + s = strchr(s + 1, end); } while (s && s[-1] == '\\'); if (!s) - continue; + continue; *s++ = '\0'; if (type == '^' && !AF_Ahear(ptr)) { - if ((thing == player && !AF_Mhear(ptr)) - || (thing != player && AF_Mhear(ptr))) - continue; + if ((thing == player && !AF_Mhear(ptr)) + || (thing != player && AF_Mhear(ptr))) + continue; } if (AF_Regexp(ptr)) { - /* Turn \: into : */ - char *from, *to; - for (from = tbuf1, to = tbuf2; *from; from++, to++) { - if (*from == '\\' && *(from + 1) == ':') - from++; - *to = *from; - } - *to = '\0'; + /* Turn \: into : */ + char *from, *to; + for (from = tbuf1, to = tbuf2; *from; from++, to++) { + if (*from == '\\' && *(from + 1) == ':') + from++; + *to = *from; + } + *to = '\0'; } else - strcpy(tbuf2, tbuf1); + strcpy(tbuf2, tbuf1); match_found = 0; if (AF_Regexp(ptr)) { - if (regexp_match_case_r(tbuf2 + 1, str, AF_Case(ptr), - global_eval_context.wnxt, 10, - match_space, match_space_len)) { - match_found = 1; - match++; - } + if (regexp_match_case_r(tbuf2 + 1, str, AF_Case(ptr), + global_eval_context.wnxt, 10, + match_space, match_space_len)) { + match_found = 1; + match++; + } } else { - if (quick_wild_new(tbuf2 + 1, str, AF_Case(ptr))) { - match_found = 1; - match++; - if (!just_match) - wild_match_case_r(tbuf2 + 1, str, AF_Case(ptr), - global_eval_context.wnxt, 10, - match_space, match_space_len); - } + if (quick_wild_new(tbuf2 + 1, str, AF_Case(ptr))) { + match_found = 1; + match++; + if (!just_match) + wild_match_case_r(tbuf2 + 1, str, AF_Case(ptr), + global_eval_context.wnxt, 10, + match_space, match_space_len); + } } if (match_found) { - /* Since we're still checking the lock on the child, not the - * parent, we don't actually want to reset lock_checked with - * each parent checked. Sorry for the misdirection, Alan. - * - Alex */ - if (!lock_checked) { - lock_checked = 1; - if ((type == '$' && !eval_lock(player, thing, Command_Lock)) - || (type == '^' && !eval_lock(player, thing, Listen_Lock)) - || !eval_lock(player, thing, Use_Lock)) { - match--; - if (errobj) - *errobj = thing; - /* If we failed the lock, there's no point in continuing at all. */ - goto exit_sequence; - } - } - if (atrname && abp) { - safe_chr(' ', atrname, abp); - if (Can_Examine(player, parent)) - safe_dbref(parent, atrname, abp); - else - safe_dbref(thing, atrname, abp); + /* Since we're still checking the lock on the child, not the + * parent, we don't actually want to reset lock_checked with + * each parent checked. Sorry for the misdirection, Alan. + * - Alex */ + if (!lock_checked) { + lock_checked = 1; + if ((type == '$' && !eval_lock(player, thing, Command_Lock)) + || (type == '^' && !eval_lock(player, thing, Listen_Lock)) + || !eval_lock(player, thing, Use_Lock)) { + match--; + if (errobj) + *errobj = thing; + /* If we failed the lock, there's no point in continuing at all. */ + goto exit_sequence; + } + } + if (atrname && abp) { + safe_chr(' ', atrname, abp); + if (Can_Examine(player, parent)) + safe_dbref(parent, atrname, abp); + else + safe_dbref(thing, atrname, abp); - safe_chr('/', atrname, abp); - safe_str(AL_NAME(ptr), atrname, abp); - } - if (!just_match) { - /* do_rawlog(LT_TRACE, "MATCHED %s:", AL_NAME(ptr)); */ - parse_que(thing, s, player); - } + safe_chr('/', atrname, abp); + safe_str(AL_NAME(ptr), atrname, abp); + } + if (!just_match) { + /* do_rawlog(LT_TRACE, "MATCHED %s:", AL_NAME(ptr)); */ + parse_que(thing, s, player); + } } } } @@ -1597,7 +1597,7 @@ char *from, *to; for (from = tbuf1, to = tbuf2; *from; from++, to++) { if (*from == '\\' && *(from + 1) == ':') - from++; + from++; *to = *from; } *to = '\0'; @@ -1606,16 +1606,16 @@ if (AF_Regexp(ptr) ? regexp_match_case_r(tbuf2 + 1, str, AF_Case(ptr), - global_eval_context.wnxt, 10, match_space, - match_space_len) : wild_match_case_r(tbuf2 + 1, str, - AF_Case(ptr), - global_eval_context. - wnxt, 10, - match_space, - match_space_len)) + global_eval_context.wnxt, 10, match_space, + match_space_len) : wild_match_case_r(tbuf2 + 1, str, + AF_Case(ptr), + global_eval_context. + wnxt, 10, + match_space, + match_space_len)) { if (!eval_lock(player, thing, Command_Lock) - || !eval_lock(player, thing, Use_Lock)) + || !eval_lock(player, thing, Use_Lock)) return 0; parse_que(thing, s, player); return 1; @@ -1643,7 +1643,7 @@ */ int do_set_atr(dbref thing, const char *RESTRICT atr, const char *RESTRICT s, - dbref player, unsigned int flags) + dbref player, unsigned int flags) { ATTR *old; char name[BUFFER_LEN]; @@ -1669,47 +1669,47 @@ /* Old alias - we're allowed to change to a different case */ strcpy(tbuf1, atr_value(old)); if (s && !*s) { - notify_format(player, T("'%s' is not a valid alias."), s); - return -1; + notify_format(player, T("'%s' is not a valid alias."), s); + return -1; } if (s && strcasecmp(s, tbuf1)) { - int opae_res = ok_player_alias(s, player, thing); - switch (opae_res) { - case OPAE_INVALID: - notify_format(player, T("'%s' is not a valid alias."), s); - break; - case OPAE_TOOMANY: - notify_format(player, T("'%s' contains too many aliases."), s); - break; - case OPAE_NULL: - notify_format(player, T("Null aliases are not valid.")); - break; - } - if (opae_res != OPAE_SUCCESS) - return -1; + int opae_res = ok_player_alias(s, player, thing); + switch (opae_res) { + case OPAE_INVALID: + notify_format(player, T("'%s' is not a valid alias."), s); + break; + case OPAE_TOOMANY: + notify_format(player, T("'%s' contains too many aliases."), s); + break; + case OPAE_NULL: + notify_format(player, T("Null aliases are not valid.")); + break; + } + if (opae_res != OPAE_SUCCESS) + return -1; } } else { /* No old alias */ if (s && *s) { - int opae_res = ok_player_alias(s, player, thing); - switch (opae_res) { - case OPAE_INVALID: - notify_format(player, T("'%s' is not a valid alias."), s); - break; - case OPAE_TOOMANY: - notify_format(player, T("'%s' contains too many aliases."), s); - break; - case OPAE_NULL: - notify_format(player, T("Null aliases are not valid.")); - break; - } - if (opae_res != OPAE_SUCCESS) - return -1; + int opae_res = ok_player_alias(s, player, thing); + switch (opae_res) { + case OPAE_INVALID: + notify_format(player, T("'%s' is not a valid alias."), s); + break; + case OPAE_TOOMANY: + notify_format(player, T("'%s' contains too many aliases."), s); + break; + case OPAE_NULL: + notify_format(player, T("Null aliases are not valid.")); + break; + } + if (opae_res != OPAE_SUCCESS) + return -1; } } } else if (s && *s && (!strcmp(name, "FORWARDLIST") - || !strcmp(name, "MAILFORWARDLIST") - || !strcmp(name, "DEBUGFORWARDLIST"))) { + || !strcmp(name, "MAILFORWARDLIST") + || !strcmp(name, "DEBUGFORWARDLIST"))) { /* You can only set this to dbrefs of things you're allowed to * forward to. If you get one wrong, we puke. */ @@ -1719,24 +1719,24 @@ fwdstr = trim_space_sep(tbuf1, ' '); while ((curr = split_token(&fwdstr, ' ')) != NULL) { if (!is_objid(curr)) { - notify_format(player, T("%s should contain only dbrefs."), name); - return -1; + notify_format(player, T("%s should contain only dbrefs."), name); + return -1; } fwd = parse_objid(curr); if (!GoodObject(fwd) || IsGarbage(fwd)) { - notify_format(player, T("Invalid dbref #%d in %s."), fwd, name); - return -1; + notify_format(player, T("Invalid dbref #%d in %s."), fwd, name); + return -1; } if ((!strcmp(name, "FORWARDLIST") || !strcmp(name, "DEBUGFORWARDLIST")) - && !Can_Forward(thing, fwd)) { - notify_format(player, T("I don't think #%d wants to hear from %s."), - fwd, Name(thing)); - return -1; + && !Can_Forward(thing, fwd)) { + notify_format(player, T("I don't think #%d wants to hear from %s."), + fwd, Name(thing)); + return -1; } if (!strcmp(name, "MAILFORWARDLIST") && !Can_MailForward(thing, fwd)) { - notify_format(player, T("I don't think #%d wants %s's mail."), fwd, - Name(thing)); - return -1; + notify_format(player, T("I don't think #%d wants %s's mail."), fwd, + Name(thing)); + return -1; } } /* If you made it here, all your dbrefs were ok */ @@ -1746,25 +1746,25 @@ was_listener = Listener(thing); res = s ? atr_add(thing, name, s, player, - (flags & 0x02) ? AF_NOPROG : AF_EMPTY_FLAGS) + (flags & 0x02) ? AF_NOPROG : AF_EMPTY_FLAGS) : atr_clr(thing, name, player); switch (res) { case AE_SAFE: notify_format(player, T("Attribute %s is SAFE. Set it !SAFE to modify it."), - name); + name); return 0; case AE_TREE: if (!s) { notify_format(player, - T - ("Unable to remove '%s' because of a protected tree attribute."), - name); + T + ("Unable to remove '%s' because of a protected tree attribute."), + name); return 0; } else { notify_format(player, - T - ("Unable to set '%s' because of a failure to create a needed parent attribute."), - name); + T + ("Unable to set '%s' because of a failure to create a needed parent attribute."), + name); return 0; } case AE_BADNAME: @@ -1773,11 +1773,11 @@ case AE_ERROR: if (*missing_name) { if (s && (EMPTY_ATTRS || *s)) - notify_format(player, T("You must set %s first."), missing_name); + notify_format(player, T("You must set %s first."), missing_name); else - notify_format(player, - T("%s is a branch attribute; remove its children first."), - missing_name); + notify_format(player, + T("%s is a branch attribute; remove its children first."), + missing_name); } else notify(player, T("That attribute cannot be changed by you.")); return 0; @@ -1804,24 +1804,24 @@ else { contents = Location(thing); if (GoodObject(contents)) - contents = Contents(contents); + contents = Contents(contents); } if (GoodObject(contents)) { if (!s && !was_listener && !Hearer(thing)) { - notify_except(contents, thing, - tprintf(T("%s loses its ears and becomes deaf."), - Name(thing)), NA_INTER_PRESENCE); + notify_except(contents, thing, + tprintf(T("%s loses its ears and becomes deaf."), + Name(thing)), NA_INTER_PRESENCE); } else if (s && !was_hearer && !was_listener) { - notify_except(contents, thing, - tprintf(T("%s grows ears and can now hear."), - Name(thing)), NA_INTER_PRESENCE); + notify_except(contents, thing, + tprintf(T("%s grows ears and can now hear."), + Name(thing)), NA_INTER_PRESENCE); } } } if ((flags & 0x01) && !AreQuiet(player, thing)) notify_format(player, - "%s/%s - %s.", Name(thing), name, - s ? T("Set") : T("Cleared")); + "%s/%s - %s.", Name(thing), name, + s ? T("Set") : T("Cleared")); return 1; } @@ -1871,25 +1871,25 @@ if (ptr && Can_Read_Attr(player, thing, ptr)) { if (!status) { notify_format(player, T("That attribute is %slocked."), - AF_Locked(ptr) ? "" : "un"); + AF_Locked(ptr) ? "" : "un"); return; } else if (!Can_Write_Attr(player, thing, ptr)) { notify(player, - T("You need to be able to set the attribute to change its lock.")); + T("You need to be able to set the attribute to change its lock.")); return; } else { if (status == 1) { - AL_FLAGS(ptr) |= AF_LOCKED; - AL_CREATOR(ptr) = Owner(player); - notify(player, T("Attribute locked.")); - return; + AL_FLAGS(ptr) |= AF_LOCKED; + AL_CREATOR(ptr) = Owner(player); + notify(player, T("Attribute locked.")); + return; } else if (status == 2) { - AL_FLAGS(ptr) &= ~AF_LOCKED; - notify(player, T("Attribute unlocked.")); - return; + AL_FLAGS(ptr) &= ~AF_LOCKED; + notify(player, T("Attribute unlocked.")); + return; } else { - notify(player, T("Invalid status on atrlock.. Notify god.")); - return; + notify(player, T("Invalid status on atrlock.. Notify god.")); + return; } } } else @@ -1941,8 +1941,8 @@ if (ptr && Can_Read_Attr(player, thing, ptr)) { if (Can_Write_Attr(player, thing, ptr)) { if (new_owner != Owner(player) && !Wizard(player)) { - notify(player, T("You can only chown an attribute to yourself.")); - return; + notify(player, T("You can only chown an attribute to yourself.")); + return; } AL_CREATOR(ptr) = Owner(new_owner); notify(player, T("Attribute owner changed.")); Index: src/conf.c =================================================================== --- src/conf.c (.../p5) (revision 1028) +++ src/conf.c (.../p6) (revision 1028) @@ -36,14 +36,14 @@ #include "function.h" #include "confmagic.h" -time_t mudtime; /**< game time, in seconds */ +time_t mudtime; /**< game time, in seconds */ static void show_compile_options(dbref player); static char *config_list_helper(dbref player, PENNCONF * cp, int lc); static char *config_list_helper2(dbref player, PENNCONF * cp, int lc); -OPTTAB options; /**< The table of configuration options */ -HASHTAB local_options; /**< Hash table for local config options */ +OPTTAB options; /**< The table of configuration options */ +HASHTAB local_options; /**< Hash table for local config options */ int config_set(const char *opt, char *val, int source, int restrictions); void conf_default_set(void); @@ -509,9 +509,9 @@ * the display of configuration options. */ typedef struct confgroupparm { - const char *name; /**< name of group */ - const char *desc; /**< description of group */ - int viewperms; /**< who can view this group */ + const char *name; /**< name of group */ + const char *desc; /**< description of group */ + int viewperms; /**< who can view this group */ } PENNCONFGROUP; /** The table of all configuration groups. */ @@ -556,7 +556,7 @@ */ PENNCONF * add_config(const char *name, config_func handler, void *loc, int max, - const char *group) + const char *group) { PENNCONF *cnf; if ((cnf = get_config(name))) @@ -597,7 +597,7 @@ */ int cf_bool(const char *opt, const char *val, void *loc, - int maxval __attribute__ ((__unused__)), int source) + int maxval __attribute__ ((__unused__)), int source) { /* enter boolean parameter */ @@ -605,7 +605,7 @@ !strcasecmp(val, "1")) *((int *) loc) = 1; else if (!strcasecmp(val, "no") || !strcasecmp(val, "false") || - !strcasecmp(val, "0")) + !strcasecmp(val, "0")) *((int *) loc) = 0; else { if (source == 0) { @@ -671,13 +671,13 @@ n = maxval; if (source == 0) { do_rawlog(LT_ERR, T("CONFIG: option %s value limited to #%d\n"), opt, - maxval); + maxval); } } if (source && (!GoodObject(n) || IsGarbage(n))) { do_rawlog(LT_ERR, - T("CONFIG: attempt to set option %s to a bad dbref (#%d)"), - opt, n); + T("CONFIG: attempt to set option %s to a bad dbref (#%d)"), + opt, n); return 0; } *((dbref *) loc) = n; @@ -710,7 +710,7 @@ n = maxval; if (source == 0) { do_rawlog(LT_ERR, T("CONFIG: option %s value limited to %d\n"), opt, - maxval); + maxval); } } *((int *) loc) = n; @@ -745,10 +745,10 @@ switch (*end) { case '\0': if (in_minutes) - secs += n * 60; + secs += n * 60; else - secs += n; - goto done; /* Sigh. What I wouldn't give for named loops in C */ + secs += n; + goto done; /* Sigh. What I wouldn't give for named loops in C */ case 's': case 'S': secs += n; @@ -763,7 +763,7 @@ break; default: if (source == 0) - do_rawlog(LT_ERR, T("CONFIG: Unknown time interval in option %s"), opt); + do_rawlog(LT_ERR, T("CONFIG: Unknown time interval in option %s"), opt); return 0; } val = end + 1; @@ -774,7 +774,7 @@ secs = maxval; if (source == 0) { do_rawlog(LT_ERR, T("CONFIG: option %s value limited to %d\n"), opt, - maxval); + maxval); } } *((int *) loc) = secs; @@ -803,7 +803,7 @@ len = maxval - total - 1; if (len <= 0) { if (source == 0) - do_rawlog(LT_ERR, T("CONFIG: option %s value overflow\n"), opt); + do_rawlog(LT_ERR, T("CONFIG: option %s value overflow\n"), opt); return 0; } if (source == 0) @@ -832,7 +832,7 @@ char *p; if (!val) - return 0; /* NULL val is no good, but "" is ok */ + return 0; /* NULL val is no good, but "" is ok */ /* Was this "restrict_command "? If so, do it */ if (!strcasecmp(opt, "restrict_command")) { @@ -842,18 +842,18 @@ if (*p) { *p++ = '\0'; if (!restrict_command(val, p)) { - if (source == 0) { - do_rawlog(LT_ERR, - T("CONFIG: Invalid command or restriction for %s.\n"), val); - } - return 0; + if (source == 0) { + do_rawlog(LT_ERR, + T("CONFIG: Invalid command or restriction for %s.\n"), val); + } + return 0; } } else { if (source == 0) { - do_rawlog(LT_ERR, - T - ("CONFIG: restrict_command %s requires a restriction value.\n"), - val); + do_rawlog(LT_ERR, + T + ("CONFIG: restrict_command %s requires a restriction value.\n"), + val); } return 0; } @@ -865,19 +865,19 @@ if (*p) { *p++ = '\0'; if (!restrict_function(val, p)) { - if (source == 0) { - do_rawlog(LT_ERR, - T("CONFIG: Invalid function or restriction for %s.\n"), - val); - } - return 0; + if (source == 0) { + do_rawlog(LT_ERR, + T("CONFIG: Invalid function or restriction for %s.\n"), + val); + } + return 0; } } else { if (source == 0) { - do_rawlog(LT_ERR, - T - ("CONFIG: restrict_function %s requires a restriction value.\n"), - val); + do_rawlog(LT_ERR, + T + ("CONFIG: restrict_function %s requires a restriction value.\n"), + val); } return 0; } @@ -894,15 +894,15 @@ if (*p) { *p++ = '\0'; if (!alias_command(val, p)) { - if (source == 0) { - do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val); - } - return 0; + if (source == 0) { + do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val); + } + return 0; } } else { if (source == 0) { - do_rawlog(LT_ERR, - T("CONFIG: command_alias %s requires an alias.\n"), val); + do_rawlog(LT_ERR, + T("CONFIG: command_alias %s requires an alias.\n"), val); } return 0; } @@ -914,15 +914,15 @@ if (*p) { *p++ = '\0'; if (!alias_attribute(val, p)) { - if (source == 0) { - do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val); - } - return 0; + if (source == 0) { + do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val); + } + return 0; } } else { if (source == 0) { - do_rawlog(LT_ERR, - T("CONFIG: attribute_alias %s requires an alias.\n"), val); + do_rawlog(LT_ERR, + T("CONFIG: attribute_alias %s requires an alias.\n"), val); } return 0; } @@ -934,21 +934,21 @@ if (*p) { *p++ = '\0'; if (!alias_function(val, p)) { - if (source == 0) { - do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val); - } - return 0; + if (source == 0) { + do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val); + } + return 0; } } else { if (source == 0) { - do_rawlog(LT_ERR, - T("CONFIG: function_alias %s requires an alias.\n"), val); + do_rawlog(LT_ERR, + T("CONFIG: function_alias %s requires an alias.\n"), val); } return 0; } return 1; } else if (!strcasecmp(opt, "help_command") - || !strcasecmp(opt, "ahelp_command")) { + || !strcasecmp(opt, "ahelp_command")) { char *comm, *file; int admin = !strcasecmp(opt, "ahelp_command"); if (!restrictions) @@ -958,8 +958,8 @@ return 0; if (!val || !*val) { do_rawlog(LT_ERR, - T - ("CONFIG: help_command requires a command name and file name.\n")); + T + ("CONFIG: help_command requires a command name and file name.\n")); return 0; } comm = val; @@ -970,8 +970,8 @@ return 1; } else { do_rawlog(LT_ERR, - T - ("CONFIG: help_command requires a command name and file name.\n")); + T + ("CONFIG: help_command requires a command name and file name.\n")); return 0; } } else if (restrictions) { @@ -984,11 +984,11 @@ for (cp = conftable; cp->name; cp++) { int i = 0; if ((!source || (cp->group && strcmp(cp->group, "files") != 0 - && strcmp(cp->group, "messages") != 0)) - && !strcasecmp(cp->name, opt)) { + && strcmp(cp->group, "messages") != 0)) + && !strcasecmp(cp->name, opt)) { i = cp->handler(opt, val, cp->loc, cp->max, source); if (i) - cp->overridden = 1; + cp->overridden = 1; return i; } } @@ -996,11 +996,11 @@ cp = (PENNCONF *) hash_nextentry(&local_options)) { int i = 0; if ((!source || (cp->group && strcmp(cp->group, "files") != 0 - && strcmp(cp->group, "messages") != 0)) - && !strcasecmp(cp->name, opt)) { + && strcmp(cp->group, "messages") != 0)) + && !strcasecmp(cp->name, opt)) { i = cp->handler(opt, val, cp->loc, cp->max, source); if (i) - cp->overridden = 1; + cp->overridden = 1; return i; } } @@ -1040,7 +1040,7 @@ options.keepalive_timeout = 300; options.dump_interval = 3601; strcpy(options.dump_message, - T("GAME: Dumping database. Game may freeze for a minute")); + T("GAME: Dumping database. Game may freeze for a minute")); strcpy(options.dump_complete, T("GAME: Dump complete. Time in.")); options.ident_timeout = 5; options.max_logins = 128; @@ -1072,7 +1072,7 @@ strcpy(options.compressprog, "compress"); strcpy(options.uncompressprog, "uncompress"); strcpy(options.compresssuff, ".Z"); -#endif /* WIN32 */ +#endif /* WIN32 */ strcpy(options.connect_file[0], "txt/connect.txt"); strcpy(options.motd_file[0], "txt/motd.txt"); strcpy(options.wizmotd_file[0], "txt/wizmotd.txt"); @@ -1103,9 +1103,9 @@ options.use_dns = 1; options.safer_ufun = 1; strcpy(options.dump_warning_1min, - T("GAME: Database will be dumped in 1 minute.")); + T("GAME: Database will be dumped in 1 minute.")); strcpy(options.dump_warning_5min, - T("GAME: Database will be dumped in 5 minutes.")); + T("GAME: Database will be dumped in 5 minutes.")); options.noisy_whisper = 0; options.possessive_get = 1; options.possessive_get_d = 1; @@ -1185,7 +1185,7 @@ strcpy(options.ssl_ca_file, ""); options.ssl_require_client_cert = 0; #endif - options.mem_check = 0; + options.mem_check = 1; #ifdef HAS_MYSQL strcpy(options.sql_platform, "disabled"); strcpy(options.sql_database, ""); @@ -1221,7 +1221,7 @@ char tbuf1[BUFFER_LEN]; char *p, *q, *s; - static char cfile[BUFFER_LEN]; /* Remember the last one */ + static char cfile[BUFFER_LEN]; /* Remember the last one */ if (conf_recursion == 0) { if (conf && *conf) strcpy(cfile, conf); @@ -1236,7 +1236,7 @@ fp = fopen(conf, FOPEN_READ); if (fp == NULL) { do_rawlog(LT_ERR, T("ERROR: Cannot open configuration file %s."), - (conf && *conf) ? conf : "Unknown"); + (conf && *conf) ? conf : "Unknown"); return 0; } do_rawlog(LT_ERR, "Reading %s", conf); @@ -1260,43 +1260,43 @@ */ for (p = tbuf1; *p && (*p != '\n') && (*p != '\r'); p++) ; - *p = '\0'; /* strip the end of line char(s) */ - for (p = tbuf1; *p && isspace((unsigned char) *p); p++) /* strip spaces */ + *p = '\0'; /* strip the end of line char(s) */ + for (p = tbuf1; *p && isspace((unsigned char) *p); p++) /* strip spaces */ ; - for (q = p; *q && !isspace((unsigned char) *q); q++) /* move over command */ + for (q = p; *q && !isspace((unsigned char) *q); q++) /* move over command */ ; if (*q) - *q++ = '\0'; /* split off command */ - for (; *q && isspace((unsigned char) *q); q++) /* skip spaces */ + *q++ = '\0'; /* split off command */ + for (; *q && isspace((unsigned char) *q); q++) /* skip spaces */ ; /* If the first character of the value is a #, and that is followed by a number, treat it as a dbref instead of a comment. */ if (*q == '#' && isdigit((unsigned char) *(q + 1))) { - for (s = q + 1; *s && (*s != '#'); s++) /* look for a real comment */ - ; + for (s = q + 1; *s && (*s != '#'); s++) /* look for a real comment */ + ; } else { - for (s = q; *s && (*s != '#'); s++) /* look for comment */ - ; + for (s = q; *s && (*s != '#'); s++) /* look for comment */ + ; } - if (*s) /* if found nuke it */ + if (*s) /* if found nuke it */ *s = '\0'; - for (s = s - 1; (s >= q) && isspace((unsigned char) *s); s--) /* smash trailing stuff */ + for (s = s - 1; (s >= q) && isspace((unsigned char) *s); s--) /* smash trailing stuff */ *s = '\0'; - if (strlen(p) != 0) { /* skip blank lines */ + if (strlen(p) != 0) { /* skip blank lines */ /* Handle include filename directives separetly */ if (strcasecmp(p, "include") == 0) { - conf_recursion++; - if (conf_recursion > 10) { - do_rawlog(LT_ERR, T("CONFIG: include depth too deep in file %s"), - conf); - } else { - config_file_startup(q, restrictions); - } - conf_recursion--; + conf_recursion++; + if (conf_recursion > 10) { + do_rawlog(LT_ERR, T("CONFIG: include depth too deep in file %s"), + conf); + } else { + config_file_startup(q, restrictions); + } + conf_recursion--; } else - config_set(p, q, 0, restrictions); + config_set(p, q, 0, restrictions); } fgets(tbuf1, BUFFER_LEN, fp); } @@ -1307,19 +1307,19 @@ if (conf_recursion == 0) { for (cp = conftable; cp->name; cp++) { if (!cp->overridden) { - do_rawlog(LT_ERR, - T - ("CONFIG: directive '%s' missing from cnf file, using default value."), - cp->name); + do_rawlog(LT_ERR, + T + ("CONFIG: directive '%s' missing from cnf file, using default value."), + cp->name); } } for (cp = (PENNCONF *) hash_firstentry(&local_options); cp; - cp = (PENNCONF *) hash_nextentry(&local_options)) { + cp = (PENNCONF *) hash_nextentry(&local_options)) { if (!cp->overridden) { - do_rawlog(LT_ERR, - T - ("CONFIG: local directive '%s' missing from cnf file. Using default value."), - cp->name); + do_rawlog(LT_ERR, + T + ("CONFIG: local directive '%s' missing from cnf file. Using default value."), + cp->name); } } @@ -1334,16 +1334,16 @@ /* if we're on Win32, complain about compression */ if ((options.compressprog && *options.compressprog)) { do_rawlog(LT_ERR, - T - ("CONFIG: compression program is specified but not used in Win32, ignoring"), - options.compressprog); + T + ("CONFIG: compression program is specified but not used in Win32, ignoring"), + options.compressprog); } if (((options.compresssuff && *options.compresssuff))) { do_rawlog(LT_ERR, - T - ("CONFIG: compression suffix is specified but not used in Win32, ignoring"), - options.compresssuff); + T + ("CONFIG: compression suffix is specified but not used in Win32, ignoring"), + options.compresssuff); } /* Also remove the compression options */ @@ -1376,63 +1376,63 @@ int found = 0; for (cgp = confgroups; cgp->name; cgp++) { if (string_prefix(T(cgp->name), type) - && Can_View_Config_Group(player, cgp)) { - found = 1; - break; + && Can_View_Config_Group(player, cgp)) { + found = 1; + break; } } if (!found) { /* It wasn't a group. Is is one or more specific options? */ for (cp = conftable; cp->name; cp++) { - if (cp->group && string_prefix(cp->name, type)) { - notify(player, config_list_helper(player, cp, lc)); - found = 1; - } + if (cp->group && string_prefix(cp->name, type)) { + notify(player, config_list_helper(player, cp, lc)); + found = 1; + } } if (!found) { - /* Ok, maybe a local option? */ - for (cp = (PENNCONF *) hash_firstentry(&local_options); cp; - cp = (PENNCONF *) hash_nextentry(&local_options)) { - if (cp->group && !strcasecmp(cp->name, type)) { - notify(player, config_list_helper(player, cp, lc)); - found = 1; - } - } + /* Ok, maybe a local option? */ + for (cp = (PENNCONF *) hash_firstentry(&local_options); cp; + cp = (PENNCONF *) hash_nextentry(&local_options)) { + if (cp->group && !strcasecmp(cp->name, type)) { + notify(player, config_list_helper(player, cp, lc)); + found = 1; + } + } } if (!found) { - /* Wasn't found at all. Ok. */ - notify(player, T("I only know the following types of options:")); - for (cgp = confgroups; cgp->name; cgp++) { - if (Can_View_Config_Group(player, cgp)) - notify_format(player, " %-15s %s", T(cgp->name), cgp->desc); - } + /* Wasn't found at all. Ok. */ + notify(player, T("I only know the following types of options:")); + for (cgp = confgroups; cgp->name; cgp++) { + if (Can_View_Config_Group(player, cgp)) + notify_format(player, " %-15s %s", T(cgp->name), cgp->desc); + } } } else { /* Show all entries of that type */ notify(player, cgp->desc); if (string_prefix("compile", type)) - show_compile_options(player); + show_compile_options(player); else { - for (cp = conftable; cp->name; cp++) { - if (cp->group && !strcmp(cp->group, cgp->name)) { - notify(player, config_list_helper(player, cp, lc)); - } - } - for (cp = (PENNCONF *) hash_firstentry(&local_options); cp; - cp = (PENNCONF *) hash_nextentry(&local_options)) { - if (cp->group && !strcasecmp(cp->group, cgp->name)) { - notify(player, config_list_helper(player, cp, lc)); - } - } + for (cp = conftable; cp->name; cp++) { + if (cp->group && !strcmp(cp->group, cgp->name)) { + notify(player, config_list_helper(player, cp, lc)); + } + } + for (cp = (PENNCONF *) hash_firstentry(&local_options); cp; + cp = (PENNCONF *) hash_nextentry(&local_options)) { + if (cp->group && !strcasecmp(cp->group, cgp->name)) { + notify(player, config_list_helper(player, cp, lc)); + } + } } } } else { /* If we're here, we ran @config without a type. */ notify(player, - T("Use: @config/list where type is one of:")); + T("Use: @config/list where type is one of:")); for (cgp = confgroups; cgp->name; cgp++) { if (Can_View_Config_Group(player, cgp)) - notify_format(player, " %-15s %s", T(cgp->name), cgp->desc); + notify_format(player, " %-15s %s", T(cgp->name), cgp->desc); } } if (SUPPORT_PUEBLO) @@ -1443,7 +1443,7 @@ #define MAYBE_LC(x) (lc ? strlower(x) : x) static char * config_list_helper(dbref player - __attribute__ ((__unused__)), PENNCONF * cp, int lc) + __attribute__ ((__unused__)), PENNCONF * cp, int lc) { static char result[BUFFER_LEN]; char *bp = result; @@ -1452,7 +1452,7 @@ safe_format(result, &bp, " %-40s %s", MAYBE_LC(cp->name), (char *) cp->loc); else if (cp->handler == cf_int) safe_format(result, &bp, " %-40s %d", MAYBE_LC(cp->name), - *((int *) cp->loc)); + *((int *) cp->loc)); else if (cp->handler == cf_time) { div_t n; int secs = *(int *) cp->loc; @@ -1473,10 +1473,10 @@ safe_format(result, &bp, "%ds", secs); } else if (cp->handler == cf_bool) safe_format(result, &bp, " %-40s %s", MAYBE_LC(cp->name), - (*((int *) cp->loc) ? "Yes" : "No")); + (*((int *) cp->loc) ? "Yes" : "No")); else if (cp->handler == cf_dbref) safe_format(result, &bp, " %-40s #%d", MAYBE_LC(cp->name), - *((dbref *) cp->loc)); + *((dbref *) cp->loc)); *bp = '\0'; return result; } @@ -1484,8 +1484,8 @@ /* This one doesn't return the names */ static char * config_list_helper2(dbref player - __attribute__ ((__unused__)), PENNCONF * cp, int lc - __attribute__ ((__unused__))) + __attribute__ ((__unused__)), PENNCONF * cp, int lc + __attribute__ ((__unused__))) { static char result[BUFFER_LEN]; char *bp = result; @@ -1529,15 +1529,15 @@ if (args[0] && *args[0]) { for (cp = conftable; cp->name; cp++) { if (cp->group && !strcasecmp(cp->name, args[0])) { - safe_str(config_list_helper2(executor, cp, 0), buff, bp); - return; + safe_str(config_list_helper2(executor, cp, 0), buff, bp); + return; } } for (cp = (PENNCONF *) hash_firstentry(&local_options); cp; - cp = (PENNCONF *) hash_nextentry(&local_options)) { + cp = (PENNCONF *) hash_nextentry(&local_options)) { if (cp->group && !strcasecmp(cp->name, args[0])) { - safe_str(config_list_helper2(executor, cp, 0), buff, bp); - return; + safe_str(config_list_helper2(executor, cp, 0), buff, bp); + return; } } safe_str(T("#-1 NO SUCH CONFIG OPTION"), buff, bp); @@ -1546,21 +1546,21 @@ int first = 1; for (cp = conftable; cp->name; cp++) { if (cp->group) { - if (first) - first = 0; - else - safe_chr(' ', buff, bp); - safe_str(cp->name, buff, bp); + if (first) + first = 0; + else + safe_chr(' ', buff, bp); + safe_str(cp->name, buff, bp); } } for (cp = (PENNCONF *) hash_firstentry(&local_options); cp; - cp = (PENNCONF *) hash_nextentry(&local_options)) { + cp = (PENNCONF *) hash_nextentry(&local_options)) { if (cp->group) { - if (first) - first = 0; - else - safe_chr(' ', buff, bp); - safe_str(cp->name, buff, bp); + if (first) + first = 0; + else + safe_chr(' ', buff, bp); + safe_str(cp->name, buff, bp); } } } @@ -1579,15 +1579,15 @@ for (cp = conftable; cp->name; cp++) { if (cp->group && !strcasecmp(cp->name, param)) { if (cp->handler == cf_bool) { - cf_bool(param, (state ? "yes" : "no"), cp->loc, cp->max, 1); - if (state == 0) - notify(player, T("Disabled.")); - else - notify(player, T("Enabled.")); - do_log(LT_WIZ, player, NOTHING, "%s %s", - cp->name, (state) ? "ENABLED" : "DISABLED"); + cf_bool(param, (state ? "yes" : "no"), cp->loc, cp->max, 1); + if (state == 0) + notify(player, T("Disabled.")); + else + notify(player, T("Enabled.")); + do_log(LT_WIZ, player, NOTHING, "%s %s", + cp->name, (state) ? "ENABLED" : "DISABLED"); } else - notify(player, T("That isn't a on/off option.")); + notify(player, T("That isn't a on/off option.")); return; } } Index: src/db.c =================================================================== --- src/db.c (.../p5) (revision 1028) +++ src/db.c (.../p6) (revision 1028) @@ -37,7 +37,7 @@ #include "confmagic.h" #ifdef WIN32 -#pragma warning( disable : 4761) /* disable warning re conversion */ +#pragma warning( disable : 4761) /* disable warning re conversion */ #endif #ifdef WIN32SERVICES @@ -51,25 +51,25 @@ int loading_db = 0; /**< Are we loading the database? */ -char db_timestamp[100]; /**< Time the read database was saved. */ +char db_timestamp[100]; /**< Time the read database was saved. */ struct object *db = NULL; /**< The object db array */ -dbref db_top = 0; /**< The number of objects in the db array */ +dbref db_top = 0; /**< The number of objects in the db array */ -dbref errobj; /**< Dbref of object on which an error has occurred */ +dbref errobj; /**< Dbref of object on which an error has occurred */ -int dbline = 0; /**< Line of the database file being read */ +int dbline = 0; /**< Line of the database file being read */ /** String that markes the end of dumps */ const char *EOD = "***END OF DUMP***\n"; #ifndef DB_INITIAL_SIZE #define DB_INITIAL_SIZE 5000 /**< Initial size for db array */ -#endif /* DB_INITIAL_SIZE */ +#endif /* DB_INITIAL_SIZE */ dbref db_size = DB_INITIAL_SIZE; /**< Current size of db array */ -HASHTAB htab_objdata; /**< Object data hash table */ +HASHTAB htab_objdata; /**< Object data hash table */ HASHTAB htab_objdata_keys; /**< Object data keys hash table */ static void db_grow(dbref newtop); @@ -87,7 +87,7 @@ static void db_write_flags(FILE * f); static dbref db_read_oldstyle(FILE * f); -StrTree object_names; /**< String tree of object names */ +StrTree object_names; /**< String tree of object names */ extern StrTree atr_names; void init_names(void); @@ -144,22 +144,22 @@ /* make the initial one */ db_size = (db_init) ? db_init : DB_INITIAL_SIZE; while (db_top > db_size) - db_size *= 2; + db_size *= 2; if ((db = (struct object *) - malloc(db_size * sizeof(struct object))) == NULL) { - do_rawlog(LT_ERR, "ERROR: out of memory while creating database!"); - abort(); + malloc(db_size * sizeof(struct object))) == NULL) { + do_rawlog(LT_ERR, "ERROR: out of memory while creating database!"); + abort(); } } /* maybe grow it */ if (db_top > db_size) { /* make sure it's big enough */ while (db_top > db_size) - db_size *= 2; + db_size *= 2; if ((newdb = (struct object *) - realloc(db, db_size * sizeof(struct object))) == NULL) { - do_rawlog(LT_ERR, "ERROR: out of memory while extending database!"); - abort(); + realloc(db, db_size * sizeof(struct object))) == NULL) { + do_rawlog(LT_ERR, "ERROR: out of memory while extending database!"); + abort(); } db = newdb; } @@ -218,7 +218,7 @@ o->zone = NOTHING; o->penn = 0; o->type = TYPE_GARBAGE; - o->flags = new_flag_bitmask("FLAG"); + /* Flags are set by the functions that call this */ o->powers = new_flag_bitmask("POWER"); o->warnings = 0; o->modification_time = o->creation_time = mudtime; @@ -291,15 +291,15 @@ c = getc(f); while (isspace(c)) { if (c == '\n') - dbline++; + dbline++; c = getc(f); } if (c == '#') { while ((c = getc(f)) != '\n' && c != EOF) { - /* nothing */ + /* nothing */ } if (c == '\n') - dbline++; + dbline++; } } while (c != EOF && isspace(c)); @@ -312,10 +312,10 @@ p = lbuf; do { - if (c != '_' && c != '-' && c != '!' && c != '.' && c != '>' && c != '<' && c != '#' && /* these really should only be first time */ - !isalnum(c)) { + if (c != '_' && c != '-' && c != '!' && c != '.' && c != '>' && c != '<' && c != '#' && /* these really should only be first time */ + !isalnum(c)) { do_rawlog(LT_ERR, "DB: Illegal character '%c'(%d) in label, line %d", - c, c, dbline); + c, c, dbline); longjmp(db_err, 1); } safe_chr(c, lbuf, &p); @@ -335,7 +335,7 @@ do_rawlog(LT_ERR, T("DB: Unexpected EOF at line %d"), dbline); else do_rawlog(LT_ERR, T("DB: Missing value for '%s' at line %d"), lbuf, - dbline); + dbline); longjmp(db_err, 1); } @@ -349,37 +349,37 @@ for (;;) { c = getc(f); if (c == '"') - break; + break; if (c == '\\') - c = getc(f); + c = getc(f); if (c == EOF) { - do_rawlog(LT_ERR, "DB: Unclosed quoted string starting on line %d", - sline); - longjmp(db_err, 1); + do_rawlog(LT_ERR, "DB: Unclosed quoted string starting on line %d", + sline); + longjmp(db_err, 1); } if (c == '\0') - do_rawlog(LT_ERR, - "DB: warning: null in quoted string, remainder lost, line %d", - dbline); + do_rawlog(LT_ERR, + "DB: warning: null in quoted string, remainder lost, line %d", + dbline); if (c == '\n') - dbline++; + dbline++; safe_chr(c, vbuf, &p); } do { c = getc(f); if (c != EOF && !isspace(c)) { - do_rawlog(LT_ERR, "DB: Garbage after quoted string, line %d", dbline); - longjmp(db_err, 1); + do_rawlog(LT_ERR, "DB: Garbage after quoted string, line %d", dbline); + longjmp(db_err, 1); } } while (c != '\n' && c != EOF); } else { /* non-quoted value */ do { if (c != '_' && c != '-' && c != '!' && c != '.' && - c != '#' && !isalnum(c) && !isspace(c)) { - do_rawlog(LT_ERR, "DB: Illegal character '%c'(%d) in value, line %d", - c, c, dbline); - longjmp(db_err, 1); + c != '#' && !isalnum(c) && !isspace(c)) { + do_rawlog(LT_ERR, "DB: Illegal character '%c'(%d) in value, line %d", + c, c, dbline); + longjmp(db_err, 1); } safe_chr(c, vbuf, &p); c = getc(f); @@ -414,8 +414,8 @@ if (strcmp(readlabel, label)) { do_rawlog(LT_ERR, - T("DB: error: Got label '%s', expected label '%s' at line %d"), - readlabel, label, dbline); + T("DB: error: Got label '%s', expected label '%s' at line %d"), + readlabel, label, dbline); longjmp(db_err, 1); } } @@ -437,8 +437,8 @@ if (strcmp(readlabel, label)) { do_rawlog(LT_ERR, - T("DB: error: Got label '%s', expected label '%s' at line %d"), - readlabel, label, dbline); + T("DB: error: Got label '%s', expected label '%s' at line %d"), + readlabel, label, dbline); longjmp(db_err, 1); } @@ -476,8 +476,8 @@ if (strcmp(readlabel, label)) { do_rawlog(LT_ERR, - T("DB: error: Got label '%s', expected label '%s' at line %d"), - readlabel, label, dbline); + T("DB: error: Got label '%s', expected label '%s' at line %d"), + readlabel, label, dbline); longjmp(db_err, 1); } *val = qparse_dbref(readvalue); @@ -578,9 +578,9 @@ db_write_labeled_number(f, "pennies", Pennies(i)); db_write_labeled_number(f, "type", Typeof(i)); db_write_labeled_string(f, "flags", - bits_to_string("FLAG", o->flags, GOD, NOTHING)); + bits_to_string("FLAG", o->flags, GOD, NOTHING)); db_write_labeled_string(f, "powers", - bits_to_string("POWER", o->powers, GOD, NOTHING)); + bits_to_string("POWER", o->powers, GOD, NOTHING)); db_write_labeled_string(f, "warnings", unparse_warnings(o->warnings)); db_write_labeled_number(f, "created", (int) o->creation_time); db_write_labeled_number(f, "modified", (int) o->modification_time); @@ -750,8 +750,8 @@ strcpy(name, AL_NAME(list)); for (p = name; *p; p++) { if (!isprint((unsigned char) *p) || isspace((unsigned char) *p)) { - *p = '!'; - fixmemdb = err = 1; + *p = '!'; + fixmemdb = err = 1; } } if (err) { @@ -759,17 +759,17 @@ * number to the end. Give up if we can't find one < 10000 */ if (atr_get_noparent(i, name)) { - count = 0; - do { - name[BUFFER_LEN - 6] = '\0'; - sprintf(tbuf1, "%s%d", name, count); - count++; - } while (count < 10000 && atr_get_noparent(i, tbuf1)); - strcpy(name, tbuf1); + count = 0; + do { + name[BUFFER_LEN - 6] = '\0'; + sprintf(tbuf1, "%s%d", name, count); + count++; + } while (count < 10000 && atr_get_noparent(i, tbuf1)); + strcpy(name, tbuf1); } do_rawlog(LT_CHECK, - T(" * Bad attribute name on #%d. Changing name to %s.\n"), - i, name); + T(" * Bad attribute name on #%d. Changing name to %s.\n"), + i, name); err = 0; } /* check the owner */ @@ -794,18 +794,18 @@ lastp = '\0'; for (p = tbuf1; *p; p++) { if (!isprint((unsigned char) *p)) { - if (!isspace((unsigned char) *p)) { - *p = '!'; - err = 1; - } + if (!isspace((unsigned char) *p)) { + *p = '!'; + err = 1; + } } lastp = *p; } if (err) { fixmemdb = 1; do_rawlog(LT_CHECK, - T(" * Bad text in attribute %s on #%d. Changed to:\n"), name, - i); + T(" * Bad text in attribute %s on #%d. Changed to:\n"), name, + i); do_rawlog(LT_CHECK, "%s\n", tbuf1); } db_write_labeled_string(f, " value", tbuf1); @@ -936,11 +936,11 @@ } else if (c != '"') { for (;;) { if ((c == '\0') || (c == EOF) || - ((c == '\n') && ((p == buf) || (p[-1] != '\r')))) { - *p = '\0'; - if (c == '\n') - dbline++; - return buf; + ((c == '\n') && ((p == buf) || (p[-1] != '\r')))) { + *p = '\0'; + if (c == '\n') + dbline++; + return buf; } safe_chr(c, buf, &p); c = fgetc(f); @@ -949,24 +949,24 @@ for (;;) { c = fgetc(f); if (c == '"') { - /* It's a closing quote if it's followed by \r or \n */ - c = fgetc(f); - if (c == '\r') { - /* Get a possible \n, too */ - if ((c = fgetc(f)) != '\n') - ungetc(c, f); - else - dbline++; - } else if (c != '\n') - ungetc(c, f); - *p = '\0'; - return buf; + /* It's a closing quote if it's followed by \r or \n */ + c = fgetc(f); + if (c == '\r') { + /* Get a possible \n, too */ + if ((c = fgetc(f)) != '\n') + ungetc(c, f); + else + dbline++; + } else if (c != '\n') + ungetc(c, f); + *p = '\0'; + return buf; } else if (c == '\\') { - c = fgetc(f); + c = fgetc(f); } if ((c == '\0') || (c == EOF)) { - *p = '\0'; - return buf; + *p = '\0'; + return buf; } safe_chr(c, buf, &p); } @@ -1043,9 +1043,9 @@ if (found != count) do_rawlog(LT_ERR, - T - ("WARNING: Actual lock count (%d) different from expected count (%d)."), - found, count); + T + ("WARNING: Actual lock count (%d) different from expected count (%d)."), + found, count); } @@ -1075,7 +1075,7 @@ do_rawlog(LT_ERR, T("ERROR: Invalid lock format on object #%d"), i); return; } - b = getboolexp(f, buf); /* Which will clobber a '\n' */ + b = getboolexp(f, buf); /* Which will clobber a '\n' */ if (b == TRUE_BOOLEXP) { /* getboolexp() would already have complained. */ return; @@ -1129,22 +1129,22 @@ tbuf1[0] = '\0'; while (1) switch (c = getc(f)) { - case ']': /* new style attribs, read name then value */ + case ']': /* new style attribs, read name then value */ /* Using getstring_noalloc here will cause problems with attribute names starting with ". This is probably a better fix than just disallowing " in attribute names. */ fgets(tbuf1, BUFFER_LEN + 150, f); if (!(p = strchr(tbuf1, '^'))) { - do_rawlog(LT_ERR, T("ERROR: Bad format on new attributes. object #%d"), - i); - return -1; + do_rawlog(LT_ERR, T("ERROR: Bad format on new attributes. object #%d"), + i); + return -1; } *p++ = '\0'; if (!(q = strchr(p, '^'))) { - do_rawlog(LT_ERR, - T("ERROR: Bad format on new attribute %s. object #%d"), - tbuf1, i); - return -1; + do_rawlog(LT_ERR, + T("ERROR: Bad format on new attribute %s. object #%d"), + tbuf1, i); + return -1; } *q++ = '\0'; flags = atoi(q); @@ -1152,18 +1152,18 @@ flags &= ~AF_NUKED; flags &= ~AF_STATIC; if (!(globals.indb_flags & DBF_AF_VISUAL)) { - /* Remove AF_ODARK flag. If it wasn't there, set AF_VISUAL */ - if (!(flags & AF_ODARK)) - flags |= AF_VISUAL; - flags &= ~AF_ODARK; + /* Remove AF_ODARK flag. If it wasn't there, set AF_VISUAL */ + if (!(flags & AF_ODARK)) + flags |= AF_VISUAL; + flags &= ~AF_ODARK; } /* Read in the deref count for the attribute, or set it to 0 if not present. */ q = strchr(q, '^'); if (q++) - derefs = atoi(q); + derefs = atoi(q); else - derefs = 0; + derefs = 0; /* We add the attribute assuming that atoi(p) is an ok dbref * since we haven't loaded the whole db and can't really tell * if it is or not. We'll fix this up at the end of the load @@ -1175,31 +1175,31 @@ * attributes (which, if not built-in attrs, have a flag val of 0.) */ break; - case '>': /* old style attribs, die noisily */ + case '>': /* old style attribs, die noisily */ do_rawlog(LT_ERR, T("ERROR: old-style attribute format in object %d"), i); return -1; break; - case '<': /* end of list */ + case '<': /* end of list */ if ('\n' != getc(f)) { - do_rawlog(LT_ERR, T("ERROR: no line feed after < on object %d"), i); - return -1; + do_rawlog(LT_ERR, T("ERROR: no line feed after < on object %d"), i); + return -1; } return count; default: if (c == EOF) { - do_rawlog(LT_ERR, T("ERROR: Unexpected EOF on file.")); - return -1; + do_rawlog(LT_ERR, T("ERROR: Unexpected EOF on file.")); + return -1; } do_rawlog(LT_ERR, - T - ("ERROR: Bad character %c (%d) in attribute list on object %d"), - c, c, i); + T + ("ERROR: Bad character %c (%d) in attribute list on object %d"), + c, c, i); do_rawlog(LT_ERR, - T(" (expecting ], >, or < as first character of the line.)")); + T(" (expecting ], >, or < as first character of the line.)")); if (*tbuf1) - do_rawlog(LT_ERR, T(" Last attribute read was: %s"), tbuf1); + do_rawlog(LT_ERR, T(" Last attribute read was: %s"), tbuf1); else - do_rawlog(LT_ERR, T(" No attributes had been read yet.")); + do_rawlog(LT_ERR, T(" No attributes had been read yet.")); return -1; } } @@ -1248,9 +1248,9 @@ if (found != count) do_rawlog(LT_ERR, - T - ("WARNING: Actual attribute count (%d) different than expected count (%d)."), - found, count); + T + ("WARNING: Actual attribute count (%d) different than expected count (%d)."), + found, count); } @@ -1275,30 +1275,30 @@ /* make sure database is at least this big *1.5 */ case '~': db_init = (getref(f) * 3) / 2; - init_objdata_htab(db_init, NULL); + init_objdata_htab(db_init / 8, NULL); break; /* Use the MUSH 2.0 header stuff to see what's in this db */ case '+': - c = getc(f); /* Skip the V */ + c = getc(f); /* Skip the V */ if (c == 'F') { - (void) getstring_noalloc(f); - flag_read_all(f, "FLAG"); + (void) getstring_noalloc(f); + flag_read_all(f, "FLAG"); } else if (c == 'P') { - (void) getstring_noalloc(f); - flag_read_all(f, "POWER"); + (void) getstring_noalloc(f); + flag_read_all(f, "POWER"); } else { - do_rawlog(LT_ERR, T("Unrecognized database format!")); - return -1; + do_rawlog(LT_ERR, T("Unrecognized database format!")); + return -1; } break; /* old fashioned database */ case '#': - case '&': /* zone oriented database */ + case '&': /* zone oriented database */ do_rawlog(LT_ERR, T("ERROR: old style database.")); return -1; break; /* new database */ - case '!': /* non-zone oriented database */ + case '!': /* non-zone oriented database */ /* make space */ i = getref(f); db_grow(i + 1); @@ -1316,18 +1316,18 @@ o->zone = getref(f); s_Pennies(i, getref(f)); if (globals.indb_flags & DBF_NEW_FLAGS) { - o->type = getref(f); - o->flags = string_to_bits("FLAG", getstring_noalloc(f)); + o->type = getref(f); + o->flags = string_to_bits("FLAG", getstring_noalloc(f)); } else { - int old_flags, old_toggles; - old_flags = getref(f); - old_toggles = getref(f); - if ((o->type = type_from_old_flags(old_flags)) < 0) { - do_rawlog(LT_ERR, T("Unable to determine type of #%d\n"), i); - return -1; - } - o->flags = - flags_from_old_flags("FLAG", old_flags, old_toggles, o->type); + int old_flags, old_toggles; + old_flags = getref(f); + old_toggles = getref(f); + if ((o->type = type_from_old_flags(old_flags)) < 0) { + do_rawlog(LT_ERR, T("Unable to determine type of #%d\n"), i); + return -1; + } + o->flags = + flags_from_old_flags("FLAG", old_flags, old_toggles, o->type); } /* We need to have flags in order to do this right, which is why @@ -1335,64 +1335,64 @@ */ switch (Typeof(i)) { case TYPE_PLAYER: - current_state.players++; - current_state.garbage--; - break; + current_state.players++; + current_state.garbage--; + break; case TYPE_THING: - current_state.things++; - current_state.garbage--; - break; + current_state.things++; + current_state.garbage--; + break; case TYPE_EXIT: - current_state.exits++; - current_state.garbage--; - break; + current_state.exits++; + current_state.garbage--; + break; case TYPE_ROOM: - current_state.rooms++; - current_state.garbage--; - break; + current_state.rooms++; + current_state.garbage--; + break; } if (IsPlayer(i) && (strlen(o->name) > (Size_t) PLAYER_NAME_LIMIT)) { - char buff[BUFFER_LEN + 1]; /* The name plus a NUL */ - strncpy(buff, o->name, PLAYER_NAME_LIMIT); - buff[PLAYER_NAME_LIMIT] = '\0'; - set_name(i, buff); - do_rawlog(LT_CHECK, - T(" * Name of #%d is longer than the maximum, truncating.\n"), - i); + char buff[BUFFER_LEN + 1]; /* The name plus a NUL */ + strncpy(buff, o->name, PLAYER_NAME_LIMIT); + buff[PLAYER_NAME_LIMIT] = '\0'; + set_name(i, buff); + do_rawlog(LT_CHECK, + T(" * Name of #%d is longer than the maximum, truncating.\n"), + i); } else if (!IsPlayer(i) && (strlen(o->name) > OBJECT_NAME_LIMIT)) { - char buff[OBJECT_NAME_LIMIT + 1]; /* The name plus a NUL */ - strncpy(buff, o->name, OBJECT_NAME_LIMIT); - buff[OBJECT_NAME_LIMIT] = '\0'; - set_name(i, buff); - do_rawlog(LT_CHECK, - T(" * Name of #%d is longer than the maximum, truncating.\n"), - i); + char buff[OBJECT_NAME_LIMIT + 1]; /* The name plus a NUL */ + strncpy(buff, o->name, OBJECT_NAME_LIMIT); + buff[OBJECT_NAME_LIMIT] = '\0'; + set_name(i, buff); + do_rawlog(LT_CHECK, + T(" * Name of #%d is longer than the maximum, truncating.\n"), + i); } if (!(globals.indb_flags & DBF_VALUE_IS_COST) && IsThing(i)) - s_Pennies(i, (Pennies(i) + 1) * 5); + s_Pennies(i, (Pennies(i) + 1) * 5); if (globals.indb_flags & DBF_NEW_POWERS) { - o->powers = string_to_bits("POWER", getstring_noalloc(f)); + o->powers = string_to_bits("POWER", getstring_noalloc(f)); } else { - int old_powers; - old_powers = getref(f); - o->powers = flags_from_old_flags("POWER", old_powers, 0, o->type); + int old_powers; + old_powers = getref(f); + o->powers = flags_from_old_flags("POWER", old_powers, 0, o->type); } /* If we've got a variable exit predating the link_anywhere power, * give it the link_anywhere power now. */ if (!(globals.indb_flags & DBF_LINK_ANYWHERE)) { - if (IsExit(i) && (Destination(i) == AMBIGUOUS)) - set_power_internal(i, "LINK_ANYWHERE"); + if (IsExit(i) && (Destination(i) == AMBIGUOUS)) + set_power_internal(i, "LINK_ANYWHERE"); } /* Remove the STARTUP and ACCESSED flags */ if (!(globals.indb_flags & DBF_NO_STARTUP_FLAG)) { - clear_flag_internal(i, "STARTUP"); - clear_flag_internal(i, "ACCESSED"); + clear_flag_internal(i, "STARTUP"); + clear_flag_internal(i, "ACCESSED"); } /* Clear the GOING flags. If it was scheduled for destruction @@ -1404,9 +1404,9 @@ /* If there are channels in the db, read 'em in */ /* We don't support this anymore, so we just discard them */ if (!(globals.indb_flags & DBF_NO_CHAT_SYSTEM)) - temp = getref(f); + temp = getref(f); else - temp = 0; + temp = 0; /* If there are warnings in the db, read 'em in */ temp = MAYBE_GET(f, DBF_WARNINGS); @@ -1414,48 +1414,48 @@ /* If there are creation times in the db, read 'em in */ temp_time = MAYBE_GET(f, DBF_CREATION_TIMES); if (temp_time) - o->creation_time = (time_t) temp_time; + o->creation_time = (time_t) temp_time; else - o->creation_time = mudtime; + o->creation_time = mudtime; temp_time = MAYBE_GET(f, DBF_CREATION_TIMES); if (temp_time || IsPlayer(i)) - o->modification_time = (time_t) temp_time; + o->modification_time = (time_t) temp_time; else - o->modification_time = o->creation_time; + o->modification_time = o->creation_time; /* read attribute list for item */ if ((o->attrcount = get_list(f, i)) < 0) { - do_rawlog(LT_ERR, T("ERROR: bad attribute list object %d"), i); - return -1; + do_rawlog(LT_ERR, T("ERROR: bad attribute list object %d"), i); + return -1; } if (!(globals.indb_flags & DBF_AF_NODUMP)) { - /* Clear QUEUE and SEMAPHORE attributes */ - atr_clr(i, "QUEUE", GOD); - atr_clr(i, "SEMAPHORE", GOD); + /* Clear QUEUE and SEMAPHORE attributes */ + atr_clr(i, "QUEUE", GOD); + atr_clr(i, "SEMAPHORE", GOD); } /* check to see if it's a player */ if (IsPlayer(i)) { - add_player(i); - clear_flag_internal(i, "CONNECTED"); + add_player(i); + clear_flag_internal(i, "CONNECTED"); } break; case '*': { - char buff[80]; - ungetc('*', f); - fgets(buff, sizeof buff, f); - if (strcmp(buff, EOD) != 0) { - do_rawlog(LT_ERR, T("ERROR: No end of dump after object #%d"), i - 1); - return -1; - } else { - do_rawlog(LT_ERR, "READING: done"); - loading_db = 0; - fix_free_list(); - dbck(); - log_mem_check(); - return db_top; - } + char buff[80]; + ungetc('*', f); + fgets(buff, sizeof buff, f); + if (strcmp(buff, EOD) != 0) { + do_rawlog(LT_ERR, T("ERROR: No end of dump after object #%d"), i - 1); + return -1; + } else { + do_rawlog(LT_ERR, "READING: done"); + loading_db = 0; + fix_free_list(); + dbck(); + log_mem_check(); + return db_top; + } } default: do_rawlog(LT_ERR, T("ERROR: failed object %d"), i); @@ -1522,206 +1522,206 @@ case '+': c = fgetc(f); if (c == 'F') { - (void) getstring_noalloc(f); - flag_read_all(f, "FLAG"); + (void) getstring_noalloc(f); + flag_read_all(f, "FLAG"); } else if (c == 'P') { - (void) getstring_noalloc(f); - flag_read_all(f, "POWER"); + (void) getstring_noalloc(f); + flag_read_all(f, "POWER"); } else { - do_rawlog(LT_ERR, T("Unrecognized database format!")); - return -1; + do_rawlog(LT_ERR, T("Unrecognized database format!")); + return -1; } break; case '~': db_init = (getref(f) * 3) / 2; - init_objdata_htab(db_init, NULL); + init_objdata_htab(db_init / 8, NULL); break; case '!': /* Read an object */ { - char *label, *value; - /* Thre should be an entry in the enum and following table and - switch for each top-level label associated with an - object. Not finding a label is not an error; the default - set in new_object() is used. Finding a label not listed - below is an error. */ - enum known_labels { - LBL_NAME, LBL_LOCATION, LBL_CONTENTS, LBL_EXITS, - LBL_NEXT, LBL_PARENT, LBL_LOCKS, LBL_OWNER, LBL_ZONE, - LBL_PENNIES, LBL_TYPE, LBL_FLAGS, LBL_POWERS, LBL_WARNINGS, - LBL_CREATED, LBL_MODIFIED, LBL_ATTRS, LBL_ERROR - }; - struct label_table { - const char *label; - enum known_labels tag; - }; - struct label_table fields[] = { - {"name", LBL_NAME}, - {"location", LBL_LOCATION}, - {"contents", LBL_CONTENTS}, - {"exits", LBL_EXITS}, - {"next", LBL_NEXT}, - {"parent", LBL_PARENT}, - {"lockcount", LBL_LOCKS}, - {"owner", LBL_OWNER}, - {"zone", LBL_ZONE}, - {"pennies", LBL_PENNIES}, - {"type", LBL_TYPE}, - {"flags", LBL_FLAGS}, - {"powers", LBL_POWERS}, - {"warnings", LBL_WARNINGS}, - {"created", LBL_CREATED}, - {"modified", LBL_MODIFIED}, - {"attrcount", LBL_ATTRS}, - /* Add new label types here. */ - {NULL, LBL_ERROR} - }, *entry; - enum known_labels the_label; + char *label, *value; + /* Thre should be an entry in the enum and following table and + switch for each top-level label associated with an + object. Not finding a label is not an error; the default + set in new_object() is used. Finding a label not listed + below is an error. */ + enum known_labels { + LBL_NAME, LBL_LOCATION, LBL_CONTENTS, LBL_EXITS, + LBL_NEXT, LBL_PARENT, LBL_LOCKS, LBL_OWNER, LBL_ZONE, + LBL_PENNIES, LBL_TYPE, LBL_FLAGS, LBL_POWERS, LBL_WARNINGS, + LBL_CREATED, LBL_MODIFIED, LBL_ATTRS, LBL_ERROR + }; + struct label_table { + const char *label; + enum known_labels tag; + }; + struct label_table fields[] = { + {"name", LBL_NAME}, + {"location", LBL_LOCATION}, + {"contents", LBL_CONTENTS}, + {"exits", LBL_EXITS}, + {"next", LBL_NEXT}, + {"parent", LBL_PARENT}, + {"lockcount", LBL_LOCKS}, + {"owner", LBL_OWNER}, + {"zone", LBL_ZONE}, + {"pennies", LBL_PENNIES}, + {"type", LBL_TYPE}, + {"flags", LBL_FLAGS}, + {"powers", LBL_POWERS}, + {"warnings", LBL_WARNINGS}, + {"created", LBL_CREATED}, + {"modified", LBL_MODIFIED}, + {"attrcount", LBL_ATTRS}, + /* Add new label types here. */ + {NULL, LBL_ERROR} + }, *entry; + enum known_labels the_label; - i = getref(f); - db_grow(i + 1); - o = db + i; - while (1) { - c = fgetc(f); - ungetc(c, f); - /* At the start of another object or the EOD marker */ - if (c == '!' || c == '*') - break; - db_read_labeled_string(f, &label, &value); - the_label = LBL_ERROR; - /* Look up the right enum value in the label table */ - for (entry = fields; entry->label; entry++) { - if (strcmp(entry->label, label) == 0) { - the_label = entry->tag; - break; - } - } - switch (the_label) { - case LBL_NAME: - set_name(i, value); - break; - case LBL_LOCATION: - o->location = qparse_dbref(value); - break; - case LBL_CONTENTS: - o->contents = qparse_dbref(value); - break; - case LBL_EXITS: - o->exits = qparse_dbref(value); - break; - case LBL_NEXT: - o->next = qparse_dbref(value); - break; - case LBL_PARENT: - o->parent = qparse_dbref(value); - break; - case LBL_LOCKS: - get_new_locks(i, f, parse_integer(value)); - break; - case LBL_OWNER: - o->owner = qparse_dbref(value); - break; - case LBL_ZONE: - o->zone = qparse_dbref(value); - break; - case LBL_PENNIES: - s_Pennies(i, parse_integer(value)); - break; - case LBL_TYPE: - o->type = parse_integer(value); - switch (Typeof(i)) { - case TYPE_PLAYER: - current_state.players++; - current_state.garbage--; - break; - case TYPE_THING: - current_state.things++; - current_state.garbage--; - break; - case TYPE_EXIT: - current_state.exits++; - current_state.garbage--; - break; - case TYPE_ROOM: - current_state.rooms++; - current_state.garbage--; - break; - } - break; - case LBL_FLAGS: - o->flags = string_to_bits("FLAG", value); - /* Clear the GOING flags. If it was scheduled for destruction - * when the db was saved, it gets a reprieve. - */ - clear_flag_internal(i, "GOING"); - clear_flag_internal(i, "GOING_TWICE"); - break; - case LBL_POWERS: - o->powers = string_to_bits("POWER", value); - break; - case LBL_WARNINGS: - o->warnings = parse_warnings(NOTHING, value); - break; - case LBL_CREATED: - o->creation_time = (time_t) parse_integer(value); - break; - case LBL_MODIFIED: - o->modification_time = (time_t) parse_integer(value); - break; - case LBL_ATTRS: - { - int attrcount = parse_integer(value); - db_read_attrs(f, i, attrcount); - } - break; - case LBL_ERROR: - default: - do_rawlog(LT_ERR, T("Unrecognized field '%s' in object #%d"), - label, i); - return -1; - } - } - if (IsPlayer(i) && (strlen(o->name) > (size_t) PLAYER_NAME_LIMIT)) { - char buff[BUFFER_LEN + 1]; /* The name plus a NUL */ - strncpy(buff, o->name, PLAYER_NAME_LIMIT); - buff[PLAYER_NAME_LIMIT] = '\0'; - set_name(i, buff); - do_rawlog(LT_CHECK, - T - (" * Name of #%d is longer than the maximum, truncating.\n"), - i); - } else if (!IsPlayer(i) && (strlen(o->name) > OBJECT_NAME_LIMIT)) { - char buff[OBJECT_NAME_LIMIT + 1]; /* The name plus a NUL */ - strncpy(buff, o->name, OBJECT_NAME_LIMIT); - buff[OBJECT_NAME_LIMIT] = '\0'; - set_name(i, buff); - do_rawlog(LT_CHECK, - T - (" * Name of #%d is longer than the maximum, truncating.\n"), - i); - } - if (IsPlayer(i)) { - add_player(i); - clear_flag_internal(i, "CONNECTED"); - } + i = getref(f); + db_grow(i + 1); + o = db + i; + while (1) { + c = fgetc(f); + ungetc(c, f); + /* At the start of another object or the EOD marker */ + if (c == '!' || c == '*') + break; + db_read_labeled_string(f, &label, &value); + the_label = LBL_ERROR; + /* Look up the right enum value in the label table */ + for (entry = fields; entry->label; entry++) { + if (strcmp(entry->label, label) == 0) { + the_label = entry->tag; + break; + } + } + switch (the_label) { + case LBL_NAME: + set_name(i, value); + break; + case LBL_LOCATION: + o->location = qparse_dbref(value); + break; + case LBL_CONTENTS: + o->contents = qparse_dbref(value); + break; + case LBL_EXITS: + o->exits = qparse_dbref(value); + break; + case LBL_NEXT: + o->next = qparse_dbref(value); + break; + case LBL_PARENT: + o->parent = qparse_dbref(value); + break; + case LBL_LOCKS: + get_new_locks(i, f, parse_integer(value)); + break; + case LBL_OWNER: + o->owner = qparse_dbref(value); + break; + case LBL_ZONE: + o->zone = qparse_dbref(value); + break; + case LBL_PENNIES: + s_Pennies(i, parse_integer(value)); + break; + case LBL_TYPE: + o->type = parse_integer(value); + switch (Typeof(i)) { + case TYPE_PLAYER: + current_state.players++; + current_state.garbage--; + break; + case TYPE_THING: + current_state.things++; + current_state.garbage--; + break; + case TYPE_EXIT: + current_state.exits++; + current_state.garbage--; + break; + case TYPE_ROOM: + current_state.rooms++; + current_state.garbage--; + break; + } + break; + case LBL_FLAGS: + o->flags = string_to_bits("FLAG", value); + /* Clear the GOING flags. If it was scheduled for destruction + * when the db was saved, it gets a reprieve. + */ + clear_flag_internal(i, "GOING"); + clear_flag_internal(i, "GOING_TWICE"); + break; + case LBL_POWERS: + o->powers = string_to_bits("POWER", value); + break; + case LBL_WARNINGS: + o->warnings = parse_warnings(NOTHING, value); + break; + case LBL_CREATED: + o->creation_time = (time_t) parse_integer(value); + break; + case LBL_MODIFIED: + o->modification_time = (time_t) parse_integer(value); + break; + case LBL_ATTRS: + { + int attrcount = parse_integer(value); + db_read_attrs(f, i, attrcount); + } + break; + case LBL_ERROR: + default: + do_rawlog(LT_ERR, T("Unrecognized field '%s' in object #%d"), + label, i); + return -1; + } + } + if (IsPlayer(i) && (strlen(o->name) > (size_t) PLAYER_NAME_LIMIT)) { + char buff[BUFFER_LEN + 1]; /* The name plus a NUL */ + strncpy(buff, o->name, PLAYER_NAME_LIMIT); + buff[PLAYER_NAME_LIMIT] = '\0'; + set_name(i, buff); + do_rawlog(LT_CHECK, + T + (" * Name of #%d is longer than the maximum, truncating.\n"), + i); + } else if (!IsPlayer(i) && (strlen(o->name) > OBJECT_NAME_LIMIT)) { + char buff[OBJECT_NAME_LIMIT + 1]; /* The name plus a NUL */ + strncpy(buff, o->name, OBJECT_NAME_LIMIT); + buff[OBJECT_NAME_LIMIT] = '\0'; + set_name(i, buff); + do_rawlog(LT_CHECK, + T + (" * Name of #%d is longer than the maximum, truncating.\n"), + i); + } + if (IsPlayer(i)) { + add_player(i); + clear_flag_internal(i, "CONNECTED"); + } } break; case '*': { - char buff[80]; - ungetc('*', f); - fgets(buff, sizeof buff, f); - if (strcmp(buff, EOD) != 0) { - do_rawlog(LT_ERR, T("ERROR: No end of dump after object #%d"), i - 1); - return -1; - } else { - do_rawlog(LT_ERR, "READING: done"); - loading_db = 0; - fix_free_list(); - dbck(); - log_mem_check(); - return db_top; - } + char buff[80]; + ungetc('*', f); + fgets(buff, sizeof buff, f); + if (strcmp(buff, EOD) != 0) { + do_rawlog(LT_ERR, T("ERROR: No end of dump after object #%d"), i - 1); + return -1; + } else { + do_rawlog(LT_ERR, "READING: done"); + loading_db = 0; + fix_free_list(); + dbck(); + log_mem_check(); + return db_top; + } } default: do_rawlog(LT_ERR, T("ERROR: failed object %d"), i); @@ -1734,6 +1734,8 @@ static void init_objdata_htab(int size, void (*free_data) (void *)) { + if (size < 128) + size = 128; hash_init(&htab_objdata, size, 4, free_data); hashinit(&htab_objdata_keys, 8, 32); } @@ -1799,9 +1801,9 @@ int desc_flags = AF_VISUAL | AF_NOPROG | AF_PREFIXMATCH; - start_room = new_object(); /* #0 */ - god = new_object(); /* #1 */ - master_room = new_object(); /* #2 */ + start_room = new_object(); /* #0 */ + god = new_object(); /* #1 */ + master_room = new_object(); /* #2 */ init_objdata_htab(DB_INITIAL_SIZE, NULL); @@ -1809,7 +1811,7 @@ Type(start_room) = TYPE_ROOM; Flags(start_room) = string_to_bits("FLAG", "LINK_OK"); atr_new_add(start_room, "DESCRIBE", "You are in Room Zero.", GOD, desc_flags, - 1); + 1); CreTime(start_room) = ModTime(start_room) = mudtime; current_state.rooms++; @@ -1839,7 +1841,7 @@ Owner(master_room) = god; CreTime(master_room) = ModTime(master_room) = mudtime; atr_new_add(master_room, "DESCRIBE", - "This is the master room. Any exit in here is considered global. The same is true for objects with $-commands placed here.", - god, desc_flags, 1); + "This is the master room. Any exit in here is considered global. The same is true for objects with $-commands placed here.", + god, desc_flags, 1); current_state.rooms++; } Index: src/function.c =================================================================== --- src/function.c (.../p5) (revision 1028) +++ src/function.c (.../p6) (revision 1028) @@ -33,7 +33,7 @@ static int apply_restrictions(unsigned int result, const char *restriction); USERFN_ENTRY *userfn_tab; /**< Table of user-defined functions */ -HASHTAB htab_function; /**< Function hash table */ +HASHTAB htab_function; /**< Function hash table */ HASHTAB htab_user_function; /**< User-defined function hash table */ /* -------------------------------------------------------------------------* @@ -125,7 +125,7 @@ */ void save_global_env(const char *funcname __attribute__ ((__unused__)), - char *preserve[]) + char *preserve[]) { int i; for (i = 0; i < 10; i++) @@ -138,7 +138,7 @@ */ void restore_global_env(const char *funcname __attribute__ ((__unused__)), - char *preserve[]) + char *preserve[]) { int i; for (i = 0; i < 10; i++) @@ -157,7 +157,7 @@ */ void save_global_nxt(const char *funcname, char *preservew[], char *preserver[], - char *valw[], char *valr[]) + char *valw[], char *valr[]) { int i; for (i = 0; i < NUMQ; i++) { @@ -189,7 +189,7 @@ */ void restore_global_nxt(const char *funcname, char *preservew[], char *preserver[], - char *valw[], char *valr[]) + char *valw[], char *valr[]) { int i; for (i = 0; i < NUMQ; i++) { @@ -228,7 +228,7 @@ */ int delim_check(char *buff, char **bp, int nfargs, char *fargs[], int sep_arg, - char *sep) + char *sep) { /* Find a delimiter. */ @@ -254,11 +254,11 @@ * This structure represents a function's entry in the function table. */ typedef struct fun_tab { - const char *name; /**< Name of the function, uppercase. */ - function_func fun; /**< Pointer to code to call for this function. */ - int minargs; /**< Minimum args required. */ - int maxargs; /**< Maximum args, or INT_MAX. If <0, last arg may have commas */ - int flags; /**< Flags to control how the function is parsed. */ + const char *name; /**< Name of the function, uppercase. */ + function_func fun; /**< Pointer to code to call for this function. */ + int minargs; /**< Minimum args required. */ + int maxargs; /**< Maximum args, or INT_MAX. If <0, last arg may have commas */ + int flags; /**< Flags to control how the function is parsed. */ } FUNTAB; @@ -830,7 +830,7 @@ { userfn_tab = (USERFN_ENTRY *) mush_malloc(MAX_GLOBAL_FNS * sizeof(USERFN_ENTRY), - "userfn_tab"); + "userfn_tab"); } /** Check permissions to run a function. @@ -889,7 +889,7 @@ return 0; function_add(strdup(strupper(alias)), fp->where.fun, - fp->minargs, fp->maxargs, fp->flags); + fp->minargs, fp->maxargs, fp->flags); return 1; } @@ -902,7 +902,7 @@ */ void function_add(const char *name, function_func fun, int minargs, int maxargs, - int ftype) + int ftype) { FUN *fp; fp = (FUN *) mush_malloc(sizeof(FUN), "function"); @@ -935,7 +935,7 @@ buff = (char *) mush_malloc(BUFFER_LEN, "strip_braces.buff"); bufc = buff; - while (isspace((unsigned char) *str)) /* eat spaces at the beginning */ + while (isspace((unsigned char) *str)) /* eat spaces at the beginning */ str++; switch (*str) { @@ -944,7 +944,7 @@ process_expression(buff, &bufc, &str, 0, 0, 0, PE_NOTHING, PT_BRACE, NULL); *bufc = '\0'; return buff; - break; /* NOT REACHED */ + break; /* NOT REACHED */ default: strcpy(buff, str); return buff; @@ -1117,19 +1117,19 @@ */ notify(player, T("Function Name Dbref # Attrib")); for (fp = (FUN *) hash_firstentry(&htab_user_function); - fp; fp = (FUN *) hash_nextentry(&htab_user_function)) { - notify_format(player, - "%-32s %6d %s", fp->name, - userfn_tab[fp->where.offset].thing, - userfn_tab[fp->where.offset].name); + fp; fp = (FUN *) hash_nextentry(&htab_user_function)) { + notify_format(player, + "%-32s %6d %s", fp->name, + userfn_tab[fp->where.offset].thing, + userfn_tab[fp->where.offset].name); } } else { /* just print out the list of available functions */ safe_str(T("User functions:"), tbuf1, &bp); for (fp = (FUN *) hash_firstentry(&htab_user_function); - fp; fp = (FUN *) hash_nextentry(&htab_user_function)) { - safe_chr(' ', tbuf1, &bp); - safe_str(fp->name, tbuf1, &bp); + fp; fp = (FUN *) hash_nextentry(&htab_user_function)) { + safe_chr(' ', tbuf1, &bp); + safe_str(fp->name, tbuf1, &bp); } *bp = '\0'; notify(player, tbuf1); @@ -1195,18 +1195,18 @@ if (argv[3] && *argv[3]) { fp->minargs = parse_integer(argv[3]); if (fp->minargs < 0) - fp->minargs = 0; + fp->minargs = 0; else if (fp->minargs > 10) - fp->minargs = 10; + fp->minargs = 10; } else fp->minargs = 0; if (argv[4] && *argv[4]) { fp->maxargs = parse_integer(argv[4]); if (fp->maxargs < -10) - fp->maxargs = -10; + fp->maxargs = -10; else if (fp->maxargs > 10) - fp->maxargs = 10; + fp->maxargs = 10; } else fp->maxargs = 10; if (argv[5] && *argv[5]) @@ -1233,10 +1233,10 @@ notify(player, T("You cannot change that built-in function.")); return; } - if (fp->flags & FN_BUILTIN) { /* Overriding a built in function */ + if (fp->flags & FN_BUILTIN) { /* Overriding a built in function */ if (userfn_count >= (Size_t) MAX_GLOBAL_FNS) { - notify(player, T("Function table full.")); - return; + notify(player, T("Function table full.")); + return; } fp = (FUN *) mush_malloc(sizeof(FUN), "func_hash.FUN"); fp->name = mush_strdup(name, "func_hash.name"); @@ -1248,24 +1248,24 @@ userfn_tab[fp->where.offset].thing = thing; if (userfn_tab[fp->where.offset].name) mush_free((Malloc_t) userfn_tab[fp->where.offset].name, - "userfn_tab.name"); + "userfn_tab.name"); userfn_tab[fp->where.offset].name = mush_strdup(upcasestr(argv[2]), "userfn_tab.name"); if (argv[3] && *argv[3]) { fp->minargs = parse_integer(argv[3]); if (fp->minargs < 0) - fp->minargs = 0; + fp->minargs = 0; else if (fp->minargs > 10) - fp->minargs = 10; + fp->minargs = 10; } else fp->minargs = 0; if (argv[4] && *argv[4]) { fp->maxargs = parse_integer(argv[4]); if (fp->maxargs < -10) - fp->maxargs = -10; + fp->maxargs = -10; else if (fp->maxargs > 10) - fp->maxargs = 10; + fp->maxargs = 10; } else fp->maxargs = 10; @@ -1554,8 +1554,8 @@ if (!(fp->flags & FN_BUILTIN) && Global_Funcs(player)) { notify_format(player, T("Location : #%d/%s"), - userfn_tab[fp->where.offset].thing, - userfn_tab[fp->where.offset].name); + userfn_tab[fp->where.offset].thing, + userfn_tab[fp->where.offset].name); } maxargs = abs(fp->maxargs); @@ -1574,5 +1574,5 @@ notify_format(player, T("Arguments : At least %d %s"), fp->minargs, tbuf); else notify_format(player, - T("Arguments : %d to %d %s"), fp->minargs, maxargs, tbuf); + T("Arguments : %d to %d %s"), fp->minargs, maxargs, tbuf); } Index: src/cmds.c =================================================================== --- src/cmds.c (.../p5) (revision 1028) +++ src/cmds.c (.../p6) (revision 1028) @@ -37,12 +37,12 @@ void do_poor(dbref player, char *arg1); void do_list_memstats(dbref player); -#define DOL_MAP 1 /**< dolist/map bitflag */ -#define DOL_NOTIFY 2 /**< dolist/notify bitflag */ -#define DOL_DELIM 4 /**< dolist/delim bitflag */ +#define DOL_MAP 1 /**< dolist/map bitflag */ +#define DOL_NOTIFY 2 /**< dolist/notify bitflag */ +#define DOL_DELIM 4 /**< dolist/delim bitflag */ void do_dolist(dbref player, char *list, char *command, - dbref cause, unsigned int flags); + dbref cause, unsigned int flags); void do_list(dbref player, char *arg, int lc); void do_writelog(dbref player, char *str, int ltype); void do_readcache(dbref player); @@ -68,7 +68,7 @@ COMMAND (cmd_attribute) { if (SW_ISSET(sw, SWITCH_ACCESS)) do_attribute_access(player, arg_left, arg_right, - SW_ISSET(sw, SWITCH_RETROACTIVE)); + SW_ISSET(sw, SWITCH_RETROACTIVE)); else if (SW_ISSET(sw, SWITCH_DELETE)) do_attribute_delete(player, arg_left); else if (SW_ISSET(sw, SWITCH_RENAME)) @@ -99,8 +99,8 @@ char const *sp = arg_right; char *bp = global_eval_context.break_replace; process_expression(global_eval_context.break_replace, &bp, &sp, - player, player, cause, - PE_COMMAND_BRACES, PT_DEFAULT, NULL); + player, player, cause, + PE_COMMAND_BRACES, PT_DEFAULT, NULL); *bp++ = '\0'; } } @@ -113,8 +113,8 @@ char const *sp = arg_right; char *bp = global_eval_context.break_replace; process_expression(global_eval_context.break_replace, &bp, &sp, - player, player, cause, - PE_COMMAND_BRACES, PT_DEFAULT, NULL); + player, player, cause, + PE_COMMAND_BRACES, PT_DEFAULT, NULL); *bp++ = '\0'; } } @@ -167,7 +167,7 @@ return; } if (!config_set(arg_left, arg_right, 1, 0) - && !config_set(arg_left, arg_right, 1, 1)) + && !config_set(arg_left, arg_right, 1, 1)) notify(player, T("Couldn't set that option")); else notify(player, T("Option set.")); @@ -202,7 +202,7 @@ /* @dec/tf overrides @dec/prefix */ ATTR *a; if (((a = atr_get_noparent(player, "TFPREFIX")) != NULL) && - AL_STR(a) && *AL_STR(a)) { + AL_STR(a) && *AL_STR(a)) { strcpy(prefix, atr_value(a)); } else { strcpy(prefix, "FugueEdit > "); @@ -263,8 +263,8 @@ COMMAND (cmd_edit) { do_gedit(player, arg_left, args_right, - SW_ISSET(sw, SWITCH_FIRST) ? EDIT_FIRST : EDIT_ALL, - SW_ISSET(sw, SWITCH_CHECK) ? 0 : 1); + SW_ISSET(sw, SWITCH_FIRST) ? EDIT_FIRST : EDIT_ALL, + SW_ISSET(sw, SWITCH_CHECK) ? 0 : 1); } COMMAND (cmd_elock) { @@ -277,7 +277,7 @@ if (SW_ISSET(sw, SWITCH_ROOM)) do_lemit(player, arg_left, - (SW_ISSET(sw, SWITCH_SILENT) * PEMIT_SILENT) | spflags); + (SW_ISSET(sw, SWITCH_SILENT) * PEMIT_SILENT) | spflags); else do_emit(player, arg_left, spflags); } @@ -358,8 +358,8 @@ split = 1; saved = args_right[2]; if ((args_right[2] = strchr(args_right[1], '/')) == NULL) { - notify(player, T("#-1 INVALID SECOND ARGUMENT")); - return; + notify(player, T("#-1 INVALID SECOND ARGUMENT")); + return; } *args_right[2]++ = '\0'; } @@ -371,7 +371,7 @@ do_function(player, NULL, NULL, 0); if (split) { if (args_right[2]) - *--args_right[2] = '/'; + *--args_right[2] = '/'; args_right[2] = saved; } } @@ -380,9 +380,9 @@ COMMAND (cmd_grep) { do_grep(player, arg_left, arg_right, ((SW_ISSET(sw, SWITCH_IPRINT)) - || (SW_ISSET(sw, SWITCH_PRINT))), - ((SW_ISSET(sw, SWITCH_IPRINT)) - || (SW_ISSET(sw, SWITCH_ILIST)))); + || (SW_ISSET(sw, SWITCH_PRINT))), + ((SW_ISSET(sw, SWITCH_IPRINT)) + || (SW_ISSET(sw, SWITCH_ILIST)))); } COMMAND (cmd_halt) { @@ -440,7 +440,7 @@ int spflags = !strcmp(cmd->name, "@NSLEMIT") ? PEMIT_SPOOF : 0; SPOOF(player, cause, sw); do_lemit(player, arg_left, - (SW_ISSET(sw, SWITCH_SILENT) * PEMIT_SILENT) | spflags); + (SW_ISSET(sw, SWITCH_SILENT) * PEMIT_SILENT) | spflags); } COMMAND (cmd_link) { @@ -551,7 +551,7 @@ else if (SW_ISSET(sw, SWITCH_UNTAG)) do_mail_untag(player, arg_left); else if (SW_ISSET(sw, SWITCH_FWD) || SW_ISSET(sw, SWITCH_FORWARD) - || SW_ISSET(sw, SWITCH_SEND) || silent || urgent || nosig) { + || SW_ISSET(sw, SWITCH_SEND) || silent || urgent || nosig) { /* These commands are not allowed to gagged players */ if (Gagged(player)) { notify(player, T("You cannot do that while gagged.")); @@ -563,9 +563,9 @@ do_mail_fwd(player, arg_left, arg_right); else if (SW_ISSET(sw, SWITCH_SEND) || silent || urgent || nosig) do_mail_send(player, arg_left, arg_right, - urgent ? M_URGENT : 0, silent, nosig); + urgent ? M_URGENT : 0, silent, nosig); } else - do_mail(player, arg_left, arg_right); /* Does its own gagged check */ + do_mail(player, arg_left, arg_right); /* Does its own gagged check */ } @@ -801,7 +801,7 @@ do_scan(player, arg_left, CHECK_GLOBAL); else do_scan(player, arg_left, CHECK_INVENTORY | CHECK_NEIGHBORS | - CHECK_SELF | CHECK_HERE | CHECK_ZONE | CHECK_GLOBAL); + CHECK_SELF | CHECK_HERE | CHECK_ZONE | CHECK_GLOBAL); } COMMAND (cmd_search) { @@ -810,7 +810,7 @@ COMMAND (cmd_select) { do_switch(player, arg_left, args_right, cause, 1, - SW_ISSET(sw, SWITCH_NOTIFY), SW_ISSET(sw, SWITCH_REGEXP)); + SW_ISSET(sw, SWITCH_NOTIFY), SW_ISSET(sw, SWITCH_REGEXP)); } COMMAND (cmd_set) { @@ -882,7 +882,7 @@ COMMAND (cmd_switch) { do_switch(player, arg_left, args_right, cause, SW_ISSET(sw, SWITCH_FIRST), - SW_ISSET(sw, SWITCH_NOTIFY), SW_ISSET(sw, SWITCH_REGEXP)); + SW_ISSET(sw, SWITCH_NOTIFY), SW_ISSET(sw, SWITCH_REGEXP)); } COMMAND (cmd_squota) { @@ -895,7 +895,7 @@ notify(player, T("You can't teleport to nothing!")); else do_teleport(player, arg_left, arg_right, (SW_ISSET(sw, SWITCH_SILENT)), - (SW_ISSET(sw, SWITCH_INSIDE))); + (SW_ISSET(sw, SWITCH_INSIDE))); } COMMAND (cmd_trigger) { @@ -1090,9 +1090,9 @@ do_page_port(player, arg_left, arg_right); else do_page(player, arg_left, arg_right, cause, SW_ISSET(sw, SWITCH_NOEVAL), - !(SW_ISSET(sw, SWITCH_BLIND) || - (!(SW_ISSET(sw, SWITCH_LIST)) && (BLIND_PAGE))), - SW_ISSET(sw, SWITCH_OVERRIDE), rhs_present); + !(SW_ISSET(sw, SWITCH_BLIND) || + (!(SW_ISSET(sw, SWITCH_LIST)) && (BLIND_PAGE))), + SW_ISSET(sw, SWITCH_OVERRIDE), rhs_present); } COMMAND (cmd_pose) { @@ -1125,8 +1125,8 @@ COMMAND (cmd_whisper) { do_whisper(player, arg_left, arg_right, - (SW_ISSET(sw, SWITCH_NOISY) || - (!SW_ISSET(sw, SWITCH_SILENT) && NOISY_WHISPER))); + (SW_ISSET(sw, SWITCH_NOISY) || + (!SW_ISSET(sw, SWITCH_SILENT) && NOISY_WHISPER))); } COMMAND (cmd_use) { @@ -1142,7 +1142,7 @@ /* If it's &attr obj, we must pass a NULL. If &attr obj=, pass "" */ if (rhs_present) { do_set_atr(thing, switches, arg_right, player, - 0x1 | (SW_ISSET(sw, SWITCH_NOEVAL) ? 0 : 0x02)); + 0x1 | (SW_ISSET(sw, SWITCH_NOEVAL) ? 0 : 0x02)); } else { do_set_atr(thing, switches, NULL, player, 1); } @@ -1154,8 +1154,8 @@ COMMAND (cmd_warn_on_missing) { notify_format(Owner(player), - T - ("No command found in code by %s - don't start code with functions."), - unparse_dbref(player)); + T + ("No command found in code by %s - don't start code with functions."), + unparse_dbref(player)); return; } Index: src/csrimalloc.c =================================================================== --- src/csrimalloc.c (.../p5) (revision 1028) +++ src/csrimalloc.c (.../p6) (revision 1028) @@ -22,7 +22,7 @@ #include "conf.h" #include "externs.h" #include "mymalloc.h" -#include "csrimalloc.h" /* Must be after mymalloc.h! */ +#include "csrimalloc.h" /* Must be after mymalloc.h! */ #ifdef CSRI_TRACE #undef malloc(x) @@ -37,7 +37,7 @@ #undef strsave(p) #undef cfree(p) #undef free(p) -extern char *strdup _((const char *)); +extern char *strdup(const char *); #endif @@ -98,7 +98,7 @@ * sprintf(). */ -#if 0 /* can't win with this one */ +#if 0 /* can't win with this one */ extern int sprintf proto((char *, const char *, ...)); #endif @@ -111,6 +111,9 @@ /* Character Handling: */ +#if 0 +/* We'd better not have to do this - Javelin */ + #ifndef HAS_MEMSET extern univptr_t memset proto((univptr_t, int, memsize_t)); #endif @@ -119,8 +122,6 @@ extern univptr_t memcpy proto((univptr_t, const univptr_t, memsize_t)); #endif -#if 0 -/* We'd better not have to do this - Javelin */ extern char *strcpy proto((char *, const char *)); extern memsize_t strlen proto((const char *)); #endif @@ -133,19 +134,19 @@ #define caddr_t char * extern caddr_t sbrk proto((int)); -#ifdef _SC_PAGESIZE /* Solaris 2.x, SVR4? */ +#ifdef _SC_PAGESIZE /* Solaris 2.x, SVR4? */ #define getpagesize() sysconf(_SC_PAGESIZE) -#else /* ! _SC_PAGESIZE */ -#ifdef _SC_PAGE_SIZE /* HP, IBM */ +#else /* ! _SC_PAGESIZE */ +#ifdef _SC_PAGE_SIZE /* HP, IBM */ #define getpagesize() sysconf(_SC_PAGE_SIZE) -#else /* ! _SC_PAGE_SIZE */ +#else /* ! _SC_PAGE_SIZE */ #ifndef getpagesize extern int getpagesize proto((void)); -#endif /* getpagesize */ -#endif /* _SC_PAGE_SIZE */ -#endif /* _SC_PAGESIZE */ +#endif /* getpagesize */ +#endif /* _SC_PAGE_SIZE */ +#endif /* _SC_PAGESIZE */ -#ifdef _AIX /* IBM AIX doesn't declare sbrk, but is STDHEADERS. */ +#ifdef _AIX /* IBM AIX doesn't declare sbrk, but is STDHEADERS. */ extern caddr_t sbrk proto((int)); #endif @@ -184,7 +185,7 @@ extern caddr_t mmap proto((caddr_t, size_t, int, int, int, off_t)); #endif -#endif /* EXTERNS_H__ */ /* Do not add anything after this line */ +#endif /* EXTERNS_H__ */ /* Do not add anything after this line */ /* $Id: csrimalloc.c 1.23.1.8 Wed, 26 May 2004 09:52:42 -0500 dunemush $ */ #ifndef __ASSERT_H__ @@ -204,7 +205,7 @@ #define ASSERT_SP(p, s, s2, sp) #define ASSERT_EP(p, s, s2, ep) #endif -#endif /* __ASSERT_H__ */ /* Do not add anything after this line */ +#endif /* __ASSERT_H__ */ /* Do not add anything after this line */ #ifndef EXIT_FAILURE #define EXIT_FAILURE 1 #endif @@ -299,19 +300,19 @@ /* a number used normally for size of a shift */ #if gcos #define BITSPERBYTE 9 -#else /* ! gcos */ +#else /* ! gcos */ #define BITSPERBYTE 8 -#endif /* gcos */ -#endif /* BITSPERBYTE */ +#endif /* gcos */ +#endif /* BITSPERBYTE */ #ifndef BITS #define BITS(type) (BITSPERBYTE * (int) sizeof(type)) -#endif /* BITS */ +#endif /* BITS */ /* size_t with only the high-order bit turned on */ #define HIBITSZ (((size_t) 1) << (BITS(size_t) - 1)) -#endif /* __ALIGN_H__ */ /* Do not add anything after this line */ +#endif /* __ALIGN_H__ */ /* Do not add anything after this line */ /* * We assume that FREE is a 0 bit, and the tag for a free block, Or'ing the @@ -327,18 +328,18 @@ #define DEF_SBRKUNITS 1024 -union word { /* basic unit of storage */ - size_t size; /* size of this block + 1 bit status */ - union word *next; /* next free block */ - union word *prev; /* prev free block */ - univptr_t ptr; /* stops lint complaining, keeps alignment */ +union word { /* basic unit of storage */ + size_t size; /* size of this block + 1 bit status */ + union word *next; /* next free block */ + union word *prev; /* prev free block */ + univptr_t ptr; /* stops lint complaining, keeps alignment */ char c; int i; char *cp; char **cpp; int *ip; int **ipp; - ALIGN; /* alignment stuff - wild fun */ + ALIGN; /* alignment stuff - wild fun */ }; typedef union word Word; @@ -405,7 +406,7 @@ #ifdef CSRI_DEBUG #define REALSIZE(sp) (((sp)+1)->size) -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ #define NEXT(ep) (((ep)-1)->next) #define PREV(ep) (((ep)-2)->prev) @@ -415,16 +416,16 @@ * free block header uses extra words in the block itself */ #ifdef CSRI_DEBUG -#define HEADERWORDS 2 /* Start boundary tag + real size in bytes */ -#else /* ! CSRI_DEBUG */ -#define HEADERWORDS 1 /* Start boundary tag */ -#endif /* CSRI_DEBUG */ +#define HEADERWORDS 2 /* Start boundary tag + real size in bytes */ +#else /* ! CSRI_DEBUG */ +#define HEADERWORDS 1 /* Start boundary tag */ +#endif /* CSRI_DEBUG */ #define TRAILERWORDS 1 -#define FREEHEADERWORDS 1 /* Start boundary tag */ +#define FREEHEADERWORDS 1 /* Start boundary tag */ -#define FREETRAILERWORDS 3 /* next and prev, end boundary tag */ +#define FREETRAILERWORDS 3 /* next and prev, end boundary tag */ #define ALLOC_OVERHEAD (HEADERWORDS + TRAILERWORDS) #define FREE_OVERHEAD (FREEHEADERWORDS + FREETRAILERWORDS) @@ -442,7 +443,7 @@ * tags that are permanantly marked allocated, so that no attempt is * made to coalesce past them. See the code in dumpheap for more info. */ -#define ARENASTART 2 /* next ptr + fake start tag */ +#define ARENASTART 2 /* next ptr + fake start tag */ #ifdef CSRI_DEBUG /* @@ -450,10 +451,10 @@ * REALSIZE word */ #define FIXEDOVERHEAD (1 + ALLOC_OVERHEAD) -#else /* ! CSRI_DEBUG */ +#else /* ! CSRI_DEBUG */ /* 1 for prev link, 1 for next link, + header and trailer */ #define FIXEDOVERHEAD (2 + ALLOC_OVERHEAD) -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ /* * Check that pointer is safe to dereference i.e. actually points @@ -485,7 +486,7 @@ */ #ifndef u_char #define u_char unsigned char -#endif /* u_char */ +#endif /* u_char */ #define MAGIC_BYTE ((u_char) '\252') @@ -532,11 +533,11 @@ */ #define TOO_SMALL(sp) (SIZE(sp) < ALLOC_OVERHEAD) -#else /* ! CSRI_DEBUG */ +#else /* ! CSRI_DEBUG */ #define SET_REALSIZE(sp, n) #define VALID_MAGIC(sp) (1) #define TOO_SMALL(sp) (0) -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ /* * Check that a free list ptr points to a block with something pointing @@ -571,7 +572,7 @@ #define fputs(s, f) write(fileno(f), (s), strlen(s)) #define setvbuf(f, s, n, l) __nothing() #define fflush(f) __nothing() -#endif /* USESTDIO */ +#endif /* USESTDIO */ #ifdef CSRI_TRACE /* @@ -616,11 +617,11 @@ } else \ _malloc_debugging += 0 -#else /* !CSRI_DEBUG */ +#else /* !CSRI_DEBUG */ #define CHECKHEAP() #define CHECKFREEPTR(ep, msg) #define CHECKALLOCPTR(sp, msg) -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ #define FREEMAGIC '\125' @@ -649,7 +650,7 @@ * variable accessed in a way not obvious to the compiler", so should * be called volatile. Amazing - a use for const volatile... */ -#ifndef RCSID /* define RCSID(x) to nothing if don't want the rcs headers */ +#ifndef RCSID /* define RCSID(x) to nothing if don't want the rcs headers */ #if defined(lint) || defined(__STRICT_ANSI__) #define RCSID(x) #else @@ -657,7 +658,7 @@ #endif #endif -#endif /* __DEFS_H__ */ /* Do not add anything after this line */ +#endif /* __DEFS_H__ */ /* Do not add anything after this line */ /* Author: Mark Moraes */ @@ -699,7 +700,7 @@ #ifdef CSRI_PROFILESIZES #define _malloc_scount __MALC_scount -#endif /* CSRI_PROFILESIZES */ +#endif /* CSRI_PROFILESIZES */ #ifdef CSRI_DEBUG /* @@ -708,13 +709,13 @@ * malloc/free/realloc/memalign. (the rest call these) */ #define _malloc_debugging __MALD_debugging -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ #define _malloc_version __MALE_version #define _malloc_memfunc __MALF_memfunc -#endif /* SHORTNAMES */ /* Do not add anything after this line */ -#endif /* __GLOBALRENAME_H__ */ /* Do not add anything after this line */ +#endif /* SHORTNAMES */ /* Do not add anything after this line */ +#endif /* __GLOBALRENAME_H__ */ /* Do not add anything after this line */ const char *_malloc_version = "CSRI, University of Toronto Malloc Version 1.18alpha"; @@ -766,14 +767,14 @@ * you want to format something before printing. We don't want stdio * calling malloc() if we can help it */ -int _malloc_tracing = 0; /* No tracing */ +int _malloc_tracing = 0; /* No tracing */ char _malloc_statsbuf[128]; int _malloc_leaktrace = 0; #ifdef CSRI_PROFILESIZES int _malloc_scount[MAXPROFILESIZE]; -#endif /* CSRI_PROFILESIZES */ +#endif /* CSRI_PROFILESIZES */ #ifdef CSRI_DEBUG /* @@ -782,7 +783,7 @@ * malloc/free/realloc/memalign. (the rest call these) */ int _malloc_debugging = 0; -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ univptr_t (*_malloc_memfunc) proto((size_t)) = _mal_sbrk; @@ -812,7 +813,7 @@ extern Word *_malloc_mem; extern int - _malloc_tracing; /* No tracing */ + _malloc_tracing; /* No tracing */ extern char _malloc_statsbuf[]; @@ -822,7 +823,7 @@ #ifdef CSRI_PROFILESIZES extern int _malloc_scount[]; -#endif /* CSRI_PROFILESIZES */ +#endif /* CSRI_PROFILESIZES */ #ifdef CSRI_DEBUG /* @@ -832,15 +833,16 @@ */ extern int _malloc_debugging; -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ extern -univptr_t (*_malloc_memfunc) proto((size_t)); +univptr_t (*_malloc_memfunc) + proto((size_t)); extern int __m_prblock proto((univptr_t, int, FILE *)); -#endif /* __GLOBALS_H__ */ /* Do not add anything after this line */ +#endif /* __GLOBALS_H__ */ /* Do not add anything after this line */ /* ** sptree.h: The following type declarations provide the binary tree @@ -862,27 +864,27 @@ struct _spblk *uplink; univptr_t - key; /* formerly time/timetyp */ + key; /* formerly time/timetyp */ univptr_t - data; /* formerly aux/auxtype */ + data; /* formerly aux/auxtype */ univptr_t datb; } SPBLK; typedef struct { - SPBLK *root; /* root node */ + SPBLK *root; /* root node */ /* Statistics, not strictly necessary, but handy for tuning */ int - lookups; /* number of splookup()s */ + lookups; /* number of splookup()s */ int - lkpcmps; /* number of lookup comparisons */ + lkpcmps; /* number of lookup comparisons */ int - enqs; /* number of spenq()s */ + enqs; /* number of spenq()s */ int - enqcmps; /* compares in spenq */ + enqcmps; /* compares in spenq */ int splays; @@ -915,7 +917,7 @@ #undef __proto -#endif /* SPTREE_H */ +#endif /* SPTREE_H */ #ifndef __CSRI_TRACE_H__ #define __CSRI_TRACE_H__ @@ -937,87 +939,89 @@ else \ _malloc_leaktrace += 0 -#endif /* __CSRI_TRACE_H__ */ /* Do not add anything after this line */ +#endif /* __CSRI_TRACE_H__ */ /* Do not add anything after this line */ #include "confmagic.h" #ifdef CSRI_TRACE /* Tracing malloc definitions - helps find leaks */ univptr_t -trace__malloc _((size_t nbytes, const char *fname, int linenum)); + trace__malloc(size_t nbytes, const char *fname, int linenum); univptr_t -trace__calloc _((size_t nelem, size_t elsize, const char *fname, int linenum)); + trace__calloc(size_t nelem, size_t elsize, const char *fname, int linenum); univptr_t -trace__realloc _((univptr_t cp, size_t nbytes, const char *fname, int linenum)); -univptr_t trace__valloc _((size_t size, const char *fname, int linenum)); + trace__realloc(univptr_t cp, size_t nbytes, const char *fname, int linenum); univptr_t - trace__memalign -_((size_t alignment, size_t size, const char *fname, int linenum)); -univptr_t trace__emalloc _((size_t nbytes, const char *fname, int linenum)); + trace__valloc(size_t size, const char *fname, int linenum); univptr_t -trace__ecalloc _((size_t nelem, size_t sz, const char *fname, int linenum)); + trace__memalign(size_t alignment, size_t size, const char *fname, int linenum); univptr_t - trace__erealloc -_((univptr_t ptr, size_t nbytes, const char *fname, int linenum)); -char *trace__strdup _((const char *s, const char *fname, int linenum)); -char *trace__strsave _((const char *s, const char *fname, int linenum)); + trace__emalloc(size_t nbytes, const char *fname, int linenum); +univptr_t + trace__ecalloc(size_t nelem, size_t sz, const char *fname, int linenum); +univptr_t + trace__erealloc(univptr_t ptr, size_t nbytes, const char *fname, int linenum); +char *trace__strdup(const char *s, const char *fname, int linenum); +char *trace__strsave(const char *s, const char *fname, int linenum); void -trace__free _((univptr_t cp, const char *fname, int linenum)); + trace__free(univptr_t cp, const char *fname, int linenum); void -trace__cfree _((univptr_t cp, const char *fname, int linenum)); -#else /* CSRI_TRACE */ + trace__cfree(univptr_t cp, const char *fname, int linenum); +#else /* CSRI_TRACE */ univptr_t -malloc _((size_t nbytes)); + malloc(size_t nbytes); univptr_t -calloc _((size_t nelem, size_t elsize)); + calloc(size_t nelem, size_t elsize); univptr_t -realloc _((univptr_t cp, size_t nbytes)); + realloc(univptr_t cp, size_t nbytes); univptr_t -valloc _((size_t size)); + valloc(size_t size); univptr_t -memalign _((size_t alignment, size_t size)); + memalign(size_t alignment, size_t size); univptr_t -emalloc _((size_t nbytes)); + emalloc(size_t nbytes); univptr_t -ecalloc _((size_t nelem, size_t sz)); + ecalloc(size_t nelem, size_t sz); univptr_t -erealloc _((univptr_t ptr, size_t nbytes)); -Free_t free _((univptr_t cp)); -Free_t cfree _((univptr_t cp)); -#endif /* CSRI_TRACE */ + erealloc(univptr_t ptr, size_t nbytes); +Free_t + free(univptr_t cp); +Free_t + cfree(univptr_t cp); +#endif /* CSRI_TRACE */ int __m_botch -_((const char *s1, const char *s2, univptr_t p, - int is_end_ptr, const char *filename, int linenumber)); + (const char *s1, const char *s2, univptr_t p, + int is_end_ptr, const char *filename, int linenumber); void -__m_prnode _((SPBLK * spblk)); + __m_prnode(SPBLK * spblk); void -mal_contents _((FILE * fp)); + mal_contents(FILE * fp); #ifdef CSRI_DEBUG void -mal_debug _((int level)); + mal_debug(int level); int -mal_verify _((int fullcheck)); + mal_verify(int fullcheck); #endif void -mal_dumpleaktrace _((FILE * fp)); + mal_dumpleaktrace(FILE * fp); void -mal_heapdump _((FILE * fp)); + mal_heapdump(FILE * fp); void -mal_leaktrace _((int value)); + mal_leaktrace(int value); void -mal_sbrkset _((int n)); + mal_sbrkset(int n); void -mal_slopset _((int n)); + mal_slopset(int n); #ifdef CSRI_PROFILESIZES void -mal_statsdump _((FILE * fp)); + mal_statsdump(FILE * fp); #endif void -mal_trace _((int value)); + mal_trace(int value); void -mal_mmap _((char *fname)); + mal_mmap(char *fname); #ifdef CSRI_TRACE @@ -1039,8 +1043,7 @@ univptr_t trace__erealloc(ptr, nbytes, fname, linenum) - univptr_t - ptr; + univptr_t ptr; size_t nbytes; const char *fname; int @@ -1110,8 +1113,7 @@ univptr_t trace__realloc(cp, nbytes, fname, linenum) - univptr_t - cp; + univptr_t cp; size_t nbytes; const char *fname; int @@ -1224,7 +1226,7 @@ RECORD_FILE_AND_LINE((univptr_t) cp, fname, linenum); return (cp); } -#endif /* CSRI_TRACE */ +#endif /* CSRI_TRACE */ int __nothing() { @@ -1243,7 +1245,7 @@ const char *filename; int linenumber, is_end_ptr; { - static char linebuf[32]; /* Enough for a BIG linenumber! */ + static char linebuf[32]; /* Enough for a BIG linenumber! */ static int notagain = 0; if (notagain == 0) { @@ -1265,10 +1267,10 @@ * tried to unbuffer it */ (void) fflush(stderr); - notagain++; /* just in case abort() tries to cleanup */ + notagain++; /* just in case abort() tries to cleanup */ abort(); } - return 0; /* SHOULDNTHAPPEN */ + return 0; /* SHOULDNTHAPPEN */ } /* Author: Mark Moraes */ @@ -1287,7 +1289,7 @@ Word *blkend; ulong tag; ulong blksize; - char buf[512]; /* long enough for the sprintfs below */ + char buf[512]; /* long enough for the sprintfs below */ if (blk == NULL) return 0; @@ -1306,8 +1308,8 @@ blkend = blk + blksize - 1; } (void) sprintf(buf, " %s blk: 0x%lx to 0x%lx, %lu (0x%lx) words", - tag == FREE ? "Free" : "Allocated", (ulong) blk, - (ulong) blkend, blksize, blksize); + tag == FREE ? "Free" : "Allocated", (ulong) blk, + (ulong) blkend, blksize, blksize); (void) fputs(buf, fp); if (is_end_ptr && !PTR_IN_HEAP(blk)) { sprintf(buf, " ** start pointer 0x%lx not in heap\n", (ulong) blk); @@ -1327,7 +1329,7 @@ char *cp; (void) sprintf(buf, " next=0x%lx, prev=0x%lx\n", - (ulong) NEXT(blkend), (ulong) PREV(blkend)); + (ulong) NEXT(blkend), (ulong) PREV(blkend)); (void) fputs(buf, fp); /* Make sure free block is filled with FREEMAGIC */ n = (blksize - FREE_OVERHEAD) * sizeof(Word); @@ -1335,8 +1337,8 @@ #ifdef CSRI_DEBUG for (i = 0; i < n; i++, cp++) { if (*cp != FREEMAGIC) { - (void) fputs(" ** modified after free().\n", fp); - break; + (void) fputs(" ** modified after free().\n", fp); + break; } } #endif @@ -1363,7 +1365,7 @@ } if (!VALID_START_SIZE_FIELD(blk)) { sprintf(buf, " ** bad size field: tags = 0x%x, 0x%x\n", - SIZEFIELD(blk), SIZEFIELD(blkend)); + SIZEFIELD(blk), SIZEFIELD(blkend)); (void) fputs(buf, fp); return 0; } @@ -1384,9 +1386,9 @@ REGISTER Word *blk; REGISTER Word *blkend; int i; - char buf[512]; /* long enough for the sprintfs below */ + char buf[512]; /* long enough for the sprintfs below */ - if (_malloc_loword == NULL) { /* Nothing malloc'ed yet */ + if (_malloc_loword == NULL) { /* Nothing malloc'ed yet */ (void) fputs("Null heap - nothing malloc'ed yet\n", fp); return; } @@ -1410,26 +1412,26 @@ } if (_malloc_rovers[MAXBINS] != NULL) { (void) sprintf(buf, " ** rover terminator is 0x%lx, fixing\n", - (ulong) _malloc_rovers[MAXBINS]); + (ulong) _malloc_rovers[MAXBINS]); (void) fputs(buf, fp); _malloc_rovers[MAXBINS] = NULL; } for (ptr = _malloc_mem; ptr != NULL; ptr = ptr->next) { /* print the arena */ (void) sprintf(buf, "Arena from 0x%lx to 0x%lx, %lu (0x%lx) words\n", - (ulong) ptr, (ulong) (ptr + SIZE(ptr + 1)), - (ulong) SIZE(ptr + 1) + 1, (ulong) SIZE(ptr + 1) + 1); + (ulong) ptr, (ulong) (ptr + SIZE(ptr + 1)), + (ulong) SIZE(ptr + 1) + 1, (ulong) SIZE(ptr + 1) + 1); (void) fputs(buf, fp); (void) sprintf(buf, "Next arena is 0x%lx\n", (ulong) ptr->next); (void) fputs(buf, fp); (void) fflush(fp); ASSERT(SIZEFIELD(ptr + 1) == SIZEFIELD(ptr + SIZE(ptr + 1)), - "mal_dumpheap: corrupt malloc arena"); + "mal_dumpheap: corrupt malloc arena"); blkend = ptr + SIZE(ptr + 1); for (blk = ptr + ARENASTART; blk < blkend; blk += SIZE(blk)) { if (!__m_prblock((univptr_t) blk, 0, fp)) { - __m_botch("mal_dumpheap: corrupt block", "", - (univptr_t) 0, 0, __FILE__, __LINE__); + __m_botch("mal_dumpheap: corrupt block", "", + (univptr_t) 0, 0, __FILE__, __LINE__); } } } @@ -1469,8 +1471,7 @@ */ univptr_t erealloc(ptr, nbytes) - univptr_t - ptr; + univptr_t ptr; size_t nbytes; { univptr_t cp = realloc(ptr, nbytes); @@ -1523,7 +1524,7 @@ */ if (nbytes > 0) { ASSERT(p > lastsbrk, - "system call error? sbrk returned value lower than previous calls"); + "system call error? sbrk returned value lower than previous calls"); lastsbrk = p; } return p; @@ -1589,7 +1590,7 @@ } mmf.i_size = stbuf.st_size; mmf.i_data = mmap((caddr_t) 0, mmf.i_size, PROT_READ | PROT_WRITE, - MAP_SHARED, mmf.i_fd, (off_t) 0); + MAP_SHARED, mmf.i_fd, (off_t) 0); if (mmf.i_data == (caddr_t) - 1) return (univptr_t) -1; mmf.i_end = mmf.i_data + mmf.i_size; @@ -1598,7 +1599,7 @@ (void) madvise(mmf.i_data, mmf.i_size, MADV_RANDOM); return mmf.i_data; } -#else /* !HAVE_MMAP */ +#else /* !HAVE_MMAP */ univptr_t _mal_mmap(nbytes) size_t nbytes __attribute__ ((__unused__)); @@ -1606,7 +1607,7 @@ return (univptr_t) -1; } -#endif /* HAVE_MMAP */ +#endif /* HAVE_MMAP */ void mal_mmap(fname) @@ -1689,8 +1690,8 @@ if ((unsigned long) spblk->datb < min_num) return; (void) sprintf(_malloc_statsbuf, "%s%8lu %8lu(0x%08lx)\n", - (char *) spblk->data, (unsigned long) spblk->datb, - (unsigned long) spblk->key, (unsigned long) spblk->key); + (char *) spblk->data, (unsigned long) spblk->datb, + (unsigned long) spblk->key, (unsigned long) spblk->key); (void) fputs(_malloc_statsbuf, dumpfp); } @@ -1736,7 +1737,7 @@ } } -static void __m_count _((SPBLK * spblk)); +static void __m_count(SPBLK * spblk); static void __m_count(spblk) @@ -1761,8 +1762,8 @@ global_nbytes = 0; __spscan(__m_count, (SPBLK *) NULL, sp); (void) sprintf(_malloc_statsbuf, - "%% %lu bytes %lu mallocs %p vm\n", - global_nbytes, nmallocs, sbrk(0)); + "%% %lu bytes %lu mallocs %p vm\n", + global_nbytes, nmallocs, sbrk(0)); (void) fputs(_malloc_statsbuf, fp); (void) fflush(fp); } @@ -1858,7 +1859,7 @@ } \ } -static int grabhunk _((size_t)); +static int grabhunk(size_t); static int grabhunk(nwords) @@ -1878,7 +1879,7 @@ */ #define EXCESS 3 sbrkwords = (size_t) (((nwords + EXCESS) / _malloc_sbrkunits + 1) * - _malloc_sbrkunits); + _malloc_sbrkunits); morecore = sbrkwords * sizeof(Word) + SBRKEXTRA; if ((cp = (*_malloc_memfunc) (morecore)) == (univptr_t) -1) return (0); @@ -1905,7 +1906,7 @@ spare = (char *) (ptr + sbrkwords); nspare = (morecore - sbrkwords * sizeof(Word)); PRCSRI_TRACE(sprintf(_malloc_statsbuf, "sbrk %lu\n", - (ulong) sbrkwords * sizeof(Word))); + (ulong) sbrkwords * sizeof(Word))); /* * If the new chunk adjoins _malloc_hiword, then _malloc_hiword @@ -1946,7 +1947,7 @@ SIZEFIELD(ptr) = ALLOCED | sbrkwords; _malloc_hiword += sbrkwords - 1; PRCSRI_TRACE(sprintf(_malloc_statsbuf, "heapend 0x%lx\n", - (ulong) _malloc_hiword)); + (ulong) _malloc_hiword)); SIZEFIELD(_malloc_hiword) = ALLOCED | sbrkwords; /* * Subtract 2 for the special arena end tags. */ @@ -1958,7 +1959,7 @@ LINK(ptr, sbrkwords, _malloc_lastbin) _malloc_rovers[_malloc_lastbin] = ptr; while (_malloc_rovers[_malloc_firstbin] == NULL && - _malloc_firstbin < MAXBINS - 1) + _malloc_firstbin < MAXBINS - 1) _malloc_firstbin++; return (1); } @@ -1996,7 +1997,7 @@ errno = EINVAL; return (NULL); } -#endif /* SVID_MALLOC_0 */ +#endif /* SVID_MALLOC_0 */ required = ALLOC_OVERHEAD + (nbytes + sizeof(Word) - 1) / sizeof(Word); if (required < (size_t) _malloc_minchunk) @@ -2021,9 +2022,9 @@ CHECKFREEPTR(search, "while searching in malloc()"); searchsize = FREESIZE(search); if (searchsize >= required) { - break; + break; } else { - search = NEXT(search); + search = NEXT(search); } } while (search != start); } @@ -2048,9 +2049,9 @@ p = search - searchsize + 1; SIZEFIELD(p) = SIZEFIELD(p + required - 1) = ALLOCMASK(required); PRCSRI_TRACE(sprintf - (_malloc_statsbuf, "+ %lu %lu 0x%lx\n", (ulong) nbytes, - (ulong) (required - ALLOC_OVERHEAD) * sizeof(Word), - (ulong) (p + HEADERWORDS))); + (_malloc_statsbuf, "+ %lu %lu 0x%lx\n", (ulong) nbytes, + (ulong) (required - ALLOC_OVERHEAD) * sizeof(Word), + (ulong) (p + HEADERWORDS))); COUNTSIZE(required); SET_REALSIZE(p, nbytes); return ((univptr_t) (p + HEADERWORDS)); @@ -2060,8 +2061,7 @@ Free_t free(cp) - univptr_t - cp; + univptr_t cp; { /* * This is where the boundary tags come into their own. The @@ -2107,8 +2107,8 @@ sizep0 = SIZE(p0); DMEMSET(p0 + FREEHEADERWORDS, sizep0 - FREE_OVERHEAD); PRCSRI_TRACE(sprintf(_malloc_statsbuf, "- %lu 0x%lx\n", - (ulong) (sizep0 - ALLOC_OVERHEAD) * sizeof(Word), - (ulong) (p0 + HEADERWORDS))); + (ulong) (sizep0 - ALLOC_OVERHEAD) * sizeof(Word), + (ulong) (p0 + HEADERWORDS))); p1 = p0 - 1; /* @@ -2141,7 +2141,7 @@ SIZEFIELD(p2 - sizep0 + 1) = SIZEFIELD(p2) = FREEMASK(sizep0); /* Smash p0's old end tag and p2's old start tag. */ DMEMSET(p0 - FREETRAILERWORDS + 1, FREETRAILERWORDS + FREEHEADERWORDS); - p0 = p2; /* p0 just vanished - became part of p2 */ + p0 = p2; /* p0 just vanished - became part of p2 */ } if (TAG(p1) == FREE) { /* @@ -2197,8 +2197,7 @@ */ univptr_t realloc(cp, nbytes) - univptr_t - cp; + univptr_t cp; size_t nbytes; { REGISTER Word *p0 = (Word *) cp; @@ -2281,9 +2280,9 @@ SIZEFIELD(p0) = SIZEFIELD(p0 + sizep0 - 1) = ALLOCMASK(sizep0); SET_REALSIZE(p0, nbytes); PRCSRI_TRACE(sprintf(_malloc_statsbuf, "++ %lu %lu 0x%lx\n", - (ulong) nbytes, - (ulong) (sizep0 - ALLOC_OVERHEAD) * sizeof(Word), - (ulong) cp)); + (ulong) nbytes, + (ulong) (sizep0 - ALLOC_OVERHEAD) * sizeof(Word), + (ulong) cp)); CHECKHEAP(); return (cp); } @@ -2312,8 +2311,7 @@ */ Free_t cfree(cp) - univptr_t - cp; + univptr_t cp; { #ifdef INT_FREE return free(cp); @@ -2356,14 +2354,14 @@ size_t blksize; #ifdef CSRI_DEBUG int tmp_debugging = _malloc_debugging; -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ if (alignment < sizeof(int) || !is_power_of_2(alignment) || size == 0) { errno = EINVAL; return (NULL); } if (alignment < sizeof(Word)) - return (malloc(size)); /* We guarantee this alignment anyway */ + return (malloc(size)); /* We guarantee this alignment anyway */ /* * Life starts to get complicated - need to get a block large * enough to hold a block 'size' long, starting on an 'alignment' @@ -2423,7 +2421,7 @@ SET_REALSIZE(p1, size); if (after > 0) { /* We can now free the block after the memaligned block. */ - p1 += blksize + ALLOC_OVERHEAD; /* SIZE(p1) */ + p1 += blksize + ALLOC_OVERHEAD; /* SIZE(p1) */ /* * p1 now points to the space after the memaligned block. we * fix the size, mark it alloced, and call free - the block @@ -2440,7 +2438,7 @@ * call free(). */ _malloc_debugging = 0; -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ free((univptr_t) (p1 + HEADERWORDS)); } if (addr != cp) { @@ -2473,7 +2471,7 @@ } #ifdef CSRI_DEBUG _malloc_debugging = tmp_debugging; -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ return (addr); } @@ -2514,7 +2512,7 @@ } _malloc_debugging = level; } -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ /* * Allows you to control the number of system calls made, which might @@ -2575,7 +2573,7 @@ * sure we print the heap start for xmem analysis. */ PRCSRI_TRACE(sprintf(_malloc_statsbuf, "heapstart 0x%lx\n", - (ulong) _malloc_loword)); + (ulong) _malloc_loword)); } } else { /* For symmetry */ @@ -2603,21 +2601,21 @@ for (i = 1; i < MAXPROFILESIZE; i++) { if (_malloc_scount[i] > 0) { (void) sprintf(buf, "%lu: %lu\n", (ulong) i * sizeof(Word), - (ulong) _malloc_scount[i]); + (ulong) _malloc_scount[i]); (void) fputs(buf, fp); _malloc_scount[i] = 0; } } if (_malloc_scount[0] > 0) { (void) sprintf(buf, ">= %lu: %lu\n", - (ulong) MAXPROFILESIZE * sizeof(Word), - (ulong) _malloc_scount[0]); + (ulong) MAXPROFILESIZE * sizeof(Word), + (ulong) _malloc_scount[0]); (void) fputs(buf, fp); _malloc_scount[0] = 0; } (void) fflush(fp); } -#endif /* CSRI_PROFILESIZES */ +#endif /* CSRI_PROFILESIZES */ /* Author: Mark Moraes */ @@ -2666,7 +2664,7 @@ REGISTER Word *ptr, *p, *blk, *blkend; int i; - if (_malloc_loword == NULL) /* Nothing malloc'ed yet */ + if (_malloc_loword == NULL) /* Nothing malloc'ed yet */ return (0); for (i = 0; i < MAXBINS; i++) { @@ -2683,35 +2681,35 @@ * despite similar appearance of the test */ ASSERT(SIZEFIELD(ptr + 1) == SIZEFIELD(ptr + SIZE(ptr + 1)), - "corrupt malloc arena"); + "corrupt malloc arena"); blkend = ptr + SIZE(ptr + 1); for (blk = ptr + ARENASTART; blk < blkend; blk += SIZE(blk)) { ASSERT_SP(PTR_IN_HEAP(blk), "corrupt pointer", "", blk); ASSERT_SP(VALID_START_SIZE_FIELD(blk), "corrupt SIZE field", "", blk); if (TAG(blk) == FREE) { - p = blk + FREESIZE(blk) - 1; - ASSERT_EP(VALID_NEXT_PTR(p), "corrupt NEXT pointer", "", p); - ASSERT_EP(VALID_PREV_PTR(p), "corrupt PREV pointer", "", p); - if (fullcheck) { - /* Make sure all free blocks are filled with FREEMAGIC */ - int n; - char *cp; + p = blk + FREESIZE(blk) - 1; + ASSERT_EP(VALID_NEXT_PTR(p), "corrupt NEXT pointer", "", p); + ASSERT_EP(VALID_PREV_PTR(p), "corrupt PREV pointer", "", p); + if (fullcheck) { + /* Make sure all free blocks are filled with FREEMAGIC */ + int n; + char *cp; - n = (SIZE(blk) - FREE_OVERHEAD) * sizeof(Word); - cp = (char *) (blk + FREEHEADERWORDS); - for (i = 0; i < n; i++, cp++) { - ASSERT_SP(*cp == FREEMAGIC, - "free block modified after free()", "", blk); - } - } + n = (SIZE(blk) - FREE_OVERHEAD) * sizeof(Word); + cp = (char *) (blk + FREEHEADERWORDS); + for (i = 0; i < n; i++, cp++) { + ASSERT_SP(*cp == FREEMAGIC, + "free block modified after free()", "", blk); + } + } } else { - ASSERT_SP(VALID_MAGIC(blk), "overwritten end of block", "", blk); + ASSERT_SP(VALID_MAGIC(blk), "overwritten end of block", "", blk); } } } return (0); } -#endif /* CSRI_DEBUG */ +#endif /* CSRI_DEBUG */ /* * This file contains a few splay tree routines snarfed from David @@ -2894,7 +2892,7 @@ return (x); -} /* spfhead */ +} /* spfhead */ @@ -2946,23 +2944,23 @@ while (x->leftlink != NULL) x = x->leftlink; next = x; - } else { /* x == NULL */ + } else { /* x == NULL */ x = n->uplink; next = NULL; while (x != NULL) { if (x->leftlink == n) { - next = x; - x = NULL; + next = x; + x = NULL; } else { - n = x; - x = n->uplink; + n = x; + x = n->uplink; } } } return (next); -} /* spfnext */ +} /* spfnext */ char * @@ -2982,7 +2980,7 @@ sloops = q->splays ? (float) q->splayloops / q->splays : 0; (void) sprintf(buf, "f(%d %4.2f) i(%d %4.2f) s(%d %4.2f)", - q->lookups, llen, q->enqs, elen, q->splays, sloops); + q->lookups, llen, q->enqs, elen, q->splays, sloops); return buf; } @@ -3073,11 +3071,11 @@ splay(n, q); x = spdeq(&q->root->rightlink); - if (x == NULL) { /* empty right subtree */ + if (x == NULL) { /* empty right subtree */ q->root = q->root->leftlink; if (q->root) q->root->uplink = NULL; - } else { /* non-empty right subtree */ + } else { /* non-empty right subtree */ x->uplink = NULL; x->leftlink = q->root->leftlink; x->rightlink = q->root->rightlink; @@ -3088,7 +3086,7 @@ q->root = x; } spfree(n, q); -} /* spdelete */ +} /* spdelete */ /* @@ -3173,9 +3171,9 @@ REGISTER SPBLK *n; REGISTER SPTREE *q; { - REGISTER SPBLK *left; /* the rightmost node in the left tree */ - REGISTER SPBLK *right; /* the leftmost node in the right tree */ - REGISTER SPBLK *next; /* the root of the unsplit part */ + REGISTER SPBLK *left; /* the rightmost node in the left tree */ + REGISTER SPBLK *right; /* the leftmost node in the right tree */ + REGISTER SPBLK *next; /* the root of the unsplit part */ REGISTER SPBLK *temp; REGISTER univptr_t key; @@ -3184,10 +3182,10 @@ n->uplink = NULL; next = q->root; q->root = n; - if (next == NULL) { /* trivial enq */ + if (next == NULL) { /* trivial enq */ n->leftlink = NULL; n->rightlink = NULL; - } else { /* difficult enq */ + } else { /* difficult enq */ key = n->key; left = n; right = n; @@ -3200,27 +3198,27 @@ if (COMPARE(next->key, key) > 0) goto two; - one: /* assert next->key <= key */ + one: /* assert next->key <= key */ - do { /* walk to the right in the left tree */ + do { /* walk to the right in the left tree */ temp = next->rightlink; if (temp == NULL) { - left->rightlink = next; - next->uplink = left; - right->leftlink = NULL; - goto done; /* job done, entire tree split */ + left->rightlink = next; + next->uplink = left; + right->leftlink = NULL; + goto done; /* job done, entire tree split */ } q->enqcmps++; if (COMPARE(temp->key, key) > 0) { - left->rightlink = next; - next->uplink = left; - left = next; - next = temp; - goto two; /* change sides */ + left->rightlink = next; + next->uplink = left; + left = next; + next = temp; + goto two; /* change sides */ } next->rightlink = temp->leftlink; if (temp->leftlink != NULL) - temp->leftlink->uplink = next; + temp->leftlink->uplink = next; left->rightlink = temp; temp->uplink = left; temp->leftlink = next; @@ -3228,34 +3226,34 @@ left = temp; next = temp->rightlink; if (next == NULL) { - right->leftlink = NULL; - goto done; /* job done, entire tree split */ + right->leftlink = NULL; + goto done; /* job done, entire tree split */ } q->enqcmps++; - } while (COMPARE(next->key, key) <= 0); /* change sides */ + } while (COMPARE(next->key, key) <= 0); /* change sides */ - two: /* assert next->key > key */ + two: /* assert next->key > key */ - do { /* walk to the left in the right tree */ + do { /* walk to the left in the right tree */ temp = next->leftlink; if (temp == NULL) { - right->leftlink = next; - next->uplink = right; - left->rightlink = NULL; - goto done; /* job done, entire tree split */ + right->leftlink = next; + next->uplink = right; + left->rightlink = NULL; + goto done; /* job done, entire tree split */ } q->enqcmps++; if (COMPARE(temp->key, key) <= 0) { - right->leftlink = next; - next->uplink = right; - right = next; - next = temp; - goto one; /* change sides */ + right->leftlink = next; + next->uplink = right; + right = next; + next = temp; + goto one; /* change sides */ } next->leftlink = temp->rightlink; if (temp->rightlink != NULL) - temp->rightlink->uplink = next; + temp->rightlink->uplink = next; right->leftlink = temp; temp->uplink = right; temp->rightlink = next; @@ -3263,16 +3261,16 @@ right = temp; next = temp->leftlink; if (next == NULL) { - left->rightlink = NULL; - goto done; /* job done, entire tree split */ + left->rightlink = NULL; + goto done; /* job done, entire tree split */ } q->enqcmps++; - } while (COMPARE(next->key, key) > 0); /* change sides */ + } while (COMPARE(next->key, key) > 0); /* change sides */ goto one; - done: /* split is done, branches of n need reversal */ + done: /* split is done, branches of n need reversal */ temp = n->leftlink; n->leftlink = n->rightlink; @@ -3281,7 +3279,7 @@ return (n); -} /* spenq */ +} /* spenq */ /*---------------- @@ -3295,14 +3293,14 @@ */ static SPBLK * spdeq(np) - SPBLK **np; /* pointer to a node pointer */ + SPBLK **np; /* pointer to a node pointer */ { - REGISTER SPBLK *deq; /* one to return */ - REGISTER SPBLK *next; /* the next thing to deal with */ - REGISTER SPBLK *left; /* the left child of next */ - REGISTER SPBLK *farleft; /* the left child of left */ - REGISTER SPBLK *farfarleft; /* the left child of farleft */ + REGISTER SPBLK *deq; /* one to return */ + REGISTER SPBLK *next; /* the next thing to deal with */ + REGISTER SPBLK *left; /* the left child of next */ + REGISTER SPBLK *farleft; /* the left child of left */ + REGISTER SPBLK *farfarleft; /* the left child of farleft */ if (np == NULL || *np == NULL) { deq = NULL; @@ -3314,44 +3312,44 @@ *np = next->rightlink; if (*np != NULL) - (*np)->uplink = NULL; + (*np)->uplink = NULL; } else - for (;;) { /* left is not null */ - /* next is not it, left is not NULL, might be it */ - farleft = left->leftlink; - if (farleft == NULL) { - deq = left; - next->leftlink = left->rightlink; - if (left->rightlink != NULL) - left->rightlink->uplink = next; - break; - } - /* next, left are not it, farleft is not NULL, might be it */ - farfarleft = farleft->leftlink; - if (farfarleft == NULL) { - deq = farleft; - left->leftlink = farleft->rightlink; - if (farleft->rightlink != NULL) - farleft->rightlink->uplink = left; - break; - } - /* next, left, farleft are not it, rotate */ - next->leftlink = farleft; - farleft->uplink = next; - left->leftlink = farleft->rightlink; - if (farleft->rightlink != NULL) - farleft->rightlink->uplink = left; - farleft->rightlink = left; - left->uplink = farleft; - next = farleft; - left = farfarleft; + for (;;) { /* left is not null */ + /* next is not it, left is not NULL, might be it */ + farleft = left->leftlink; + if (farleft == NULL) { + deq = left; + next->leftlink = left->rightlink; + if (left->rightlink != NULL) + left->rightlink->uplink = next; + break; + } + /* next, left are not it, farleft is not NULL, might be it */ + farfarleft = farleft->leftlink; + if (farfarleft == NULL) { + deq = farleft; + left->leftlink = farleft->rightlink; + if (farleft->rightlink != NULL) + farleft->rightlink->uplink = left; + break; + } + /* next, left, farleft are not it, rotate */ + next->leftlink = farleft; + farleft->uplink = next; + left->leftlink = farleft->rightlink; + if (farleft->rightlink != NULL) + farleft->rightlink->uplink = left; + farleft->rightlink = left; + left->uplink = farleft; + next = farleft; + left = farfarleft; } } return (deq); -} /* spdeq */ +} /* spdeq */ /*---------------- @@ -3376,12 +3374,12 @@ SPTREE *q; { - REGISTER SPBLK *up; /* points to the node being dealt with */ - REGISTER SPBLK *prev; /* a descendent of up, already dealt with */ - REGISTER SPBLK *upup; /* the parent of up */ - REGISTER SPBLK *upupup; /* the grandparent of up */ - REGISTER SPBLK *left; /* the top of left subtree being built */ - REGISTER SPBLK *right; /* the top of right subtree being built */ + REGISTER SPBLK *up; /* points to the node being dealt with */ + REGISTER SPBLK *prev; /* a descendent of up, already dealt with */ + REGISTER SPBLK *upup; /* the parent of up */ + REGISTER SPBLK *upupup; /* the grandparent of up */ + REGISTER SPBLK *left; /* the top of left subtree being built */ + REGISTER SPBLK *right; /* the top of right subtree being built */ left = n->leftlink; right = n->rightlink; @@ -3397,48 +3395,48 @@ n into the left subtree, all to right into the right subtree */ upup = up->uplink; - if (up->leftlink == prev) { /* up is to the right of n */ - if (upup != NULL && upup->leftlink == up) { /* rotate */ - upupup = upup->uplink; - upup->leftlink = up->rightlink; - if (upup->leftlink != NULL) - upup->leftlink->uplink = upup; - up->rightlink = upup; - upup->uplink = up; - if (upupup == NULL) - q->root = up; - else if (upupup->leftlink == upup) - upupup->leftlink = up; - else - upupup->rightlink = up; - up->uplink = upupup; - upup = upupup; + if (up->leftlink == prev) { /* up is to the right of n */ + if (upup != NULL && upup->leftlink == up) { /* rotate */ + upupup = upup->uplink; + upup->leftlink = up->rightlink; + if (upup->leftlink != NULL) + upup->leftlink->uplink = upup; + up->rightlink = upup; + upup->uplink = up; + if (upupup == NULL) + q->root = up; + else if (upupup->leftlink == upup) + upupup->leftlink = up; + else + upupup->rightlink = up; + up->uplink = upupup; + upup = upupup; } up->leftlink = right; if (right != NULL) - right->uplink = up; + right->uplink = up; right = up; - } else { /* up is to the left of n */ - if (upup != NULL && upup->rightlink == up) { /* rotate */ - upupup = upup->uplink; - upup->rightlink = up->leftlink; - if (upup->rightlink != NULL) - upup->rightlink->uplink = upup; - up->leftlink = upup; - upup->uplink = up; - if (upupup == NULL) - q->root = up; - else if (upupup->rightlink == upup) - upupup->rightlink = up; - else - upupup->leftlink = up; - up->uplink = upupup; - upup = upupup; + } else { /* up is to the left of n */ + if (upup != NULL && upup->rightlink == up) { /* rotate */ + upupup = upup->uplink; + upup->rightlink = up->leftlink; + if (upup->rightlink != NULL) + upup->rightlink->uplink = upup; + up->leftlink = upup; + upup->uplink = up; + if (upupup == NULL) + q->root = up; + else if (upupup->rightlink == upup) + upupup->rightlink = up; + else + upupup->leftlink = up; + up->uplink = upupup; + upup = upupup; } up->rightlink = left; if (left != NULL) - left->uplink = up; + left->uplink = up; left = up; } prev = up; @@ -3461,4 +3459,4 @@ q->root = n; n->uplink = NULL; -} /* splay */ +} /* splay */ Index: src/compress.c =================================================================== --- src/compress.c (.../p5) (revision 1028) +++ src/compress.c (.../p6) (revision 1028) @@ -17,7 +17,7 @@ #if defined(COMPRESSION_TYPE) && (COMPRESSION_TYPE == 0) /* No compression */ -char ucbuff[BUFFER_LEN]; /**< Dummy buffer for no compression */ +char ucbuff[BUFFER_LEN]; /**< Dummy buffer for no compression */ #elif (COMPRESSION_TYPE == 1) || (COMPRESSION_TYPE == 2) /* Huffman compression */ @@ -38,4 +38,4 @@ */ char ucbuff[BUFFER_LEN]; -#endif /* Compression type checks */ +#endif /* Compression type checks */ Index: src/access.c =================================================================== --- src/access.c (.../p5) (revision 1028) +++ src/access.c (.../p6) (revision 1028) @@ -91,9 +91,9 @@ * This structure is used to build a table of access control flags. */ struct a_acsflag { - const char *name; /**< Name of the access flag */ - int toggle; /**< Is this a negatable flag? */ - int flag; /**< Bitmask of the flag */ + const char *name; /**< Name of the access flag */ + int toggle; /**< Is this a negatable flag? */ + int flag; /**< Bitmask of the flag */ }; static acsflag acslist[] = { {"connect", 1, ACS_CONNECT}, @@ -118,7 +118,7 @@ static int add_access_node(const char *host, const dbref who, const int can, - const int cant, const char *comment) + const int cant, const char *comment) { struct access *end; struct access *tmp; @@ -183,37 +183,37 @@ while (fgets(buf, BUFFER_LEN, fp)) { /* Strip end of line if it's \r\n or \n */ if ((p = strchr(buf, '\r'))) - *p = '\0'; + *p = '\0'; else if ((p = strchr(buf, '\n'))) - *p = '\0'; + *p = '\0'; /* Find beginning of line; ignore blank lines */ p = buf; if (*p && isspace((unsigned char) *p)) - p++; + p++; if (*p && *p != '#') { - can = cant = 0; - comment = NULL; - /* Is this the @sitelock entry? */ - if (!strncasecmp(p, "@sitelock", 9)) { - if (!add_access_node("@sitelock", AMBIGUOUS, ACS_SITELOCK, 0, "")) - do_log(LT_ERR, GOD, GOD, T("Failed to add sitelock node!")); - } else { - if ((comment = strchr(p, '#'))) { - *comment++ = '\0'; - while (*comment && isspace((unsigned char) *comment)) - comment++; - } - /* Move past the host name */ - while (*p && !isspace((unsigned char) *p)) - p++; - if (*p) - *p++ = '\0'; - if (!parse_access_options(p, &who, &can, &cant, NOTHING)) - /* Nothing listed, so assume we can't do anything! */ - cant = ACS_DEFAULT; - if (!add_access_node(buf, who, can, cant, comment)) - do_log(LT_ERR, GOD, GOD, T("Failed to add access node!")); - } + can = cant = 0; + comment = NULL; + /* Is this the @sitelock entry? */ + if (!strncasecmp(p, "@sitelock", 9)) { + if (!add_access_node("@sitelock", AMBIGUOUS, ACS_SITELOCK, 0, "")) + do_log(LT_ERR, GOD, GOD, T("Failed to add sitelock node!")); + } else { + if ((comment = strchr(p, '#'))) { + *comment++ = '\0'; + while (*comment && isspace((unsigned char) *comment)) + comment++; + } + /* Move past the host name */ + while (*p && !isspace((unsigned char) *p)) + p++; + if (*p) + *p++ = '\0'; + if (!parse_access_options(p, &who, &can, &cant, NOTHING)) + /* Nothing listed, so assume we can't do anything! */ + cant = ACS_DEFAULT; + if (!add_access_node(buf, who, can, cant, comment)) + do_log(LT_ERR, GOD, GOD, T("Failed to add access node!")); + } } } retval = 1; @@ -243,36 +243,36 @@ } else { for (ap = access_top; ap; ap = ap->next) { if (strcmp(ap->host, "@sitelock") == 0) { - fprintf(fp, "@sitelock\n"); - continue; + fprintf(fp, "@sitelock\n"); + continue; } fprintf(fp, "%s %d ", ap->host, ap->who); switch (ap->can) { case ACS_SITELOCK: - break; + break; case ACS_DEFAULT: - fprintf(fp, "DEFAULT "); - break; + fprintf(fp, "DEFAULT "); + break; default: - for (c = acslist; c->name; c++) - if (ap->can & c->flag) - fprintf(fp, "%s ", c->name); - break; + for (c = acslist; c->name; c++) + if (ap->can & c->flag) + fprintf(fp, "%s ", c->name); + break; } switch (ap->cant) { case ACS_DEFAULT: - fprintf(fp, "NONE "); - break; + fprintf(fp, "NONE "); + break; default: - for (c = acslist; c->name; c++) - if (c->toggle && (ap->cant & c->flag)) - fprintf(fp, "!%s ", c->name); - break; + for (c = acslist; c->name; c++) + if (c->toggle && (ap->cant & c->flag)) + fprintf(fp, "!%s ", c->name); + break; } if (ap->comment && *ap->comment) - fprintf(fp, "# %s\n", ap->comment); + fprintf(fp, "# %s\n", ap->comment); else - fprintf(fp, "\n"); + fprintf(fp, "\n"); } fclose(fp); rename_file(tmpf, ACCESS_FILE); @@ -329,37 +329,37 @@ for (ap = access_top; ap; ap = ap->next) { if (!(ap->can & ACS_SITELOCK) - && ((ap->can & ACS_REGEXP) - ? (quick_regexp_match(ap->host, hname, 0) - || (p && quick_regexp_match(ap->host, p, 0)) + && ((ap->can & ACS_REGEXP) + ? (quick_regexp_match(ap->host, hname, 0) + || (p && quick_regexp_match(ap->host, p, 0)) #ifdef FORCE_IPV4 - || quick_regexp_match(ip4_to_ip6(ap->host), hname, 0) - || (p && quick_regexp_match(ip4_to_ip6(ap->host), p, 0)) + || quick_regexp_match(ip4_to_ip6(ap->host), hname, 0) + || (p && quick_regexp_match(ip4_to_ip6(ap->host), p, 0)) #endif - ) - : (quick_wild(ap->host, hname) - || (p && quick_wild(ap->host, p)) + ) + : (quick_wild(ap->host, hname) + || (p && quick_wild(ap->host, p)) #ifdef FORCE_IPV4 - || quick_wild(ip4_to_ip6(ap->host), hname) - || (p && quick_wild(ip4_to_ip6(ap->host), p)) + || quick_wild(ip4_to_ip6(ap->host), hname) + || (p && quick_wild(ip4_to_ip6(ap->host), p)) #endif - )) - && (ap->who == AMBIGUOUS || ap->who == who)) { + )) + && (ap->who == AMBIGUOUS || ap->who == who)) { /* Got one */ if (flag & ACS_CONNECT) { - if ((ap->cant & ACS_GOD) && God(who)) /* God can't connect from here */ - return 0; - else if ((ap->cant & ACS_WIZARD) && Wizard(who)) - /* Wiz can't connect from here */ - return 0; - else if ((ap->cant & ACS_ADMIN) && Hasprivs(who)) - /* Wiz and roy can't connect from here */ - return 0; + if ((ap->cant & ACS_GOD) && God(who)) /* God can't connect from here */ + return 0; + else if ((ap->cant & ACS_WIZARD) && Wizard(who)) + /* Wiz can't connect from here */ + return 0; + else if ((ap->cant & ACS_ADMIN) && Hasprivs(who)) + /* Wiz and roy can't connect from here */ + return 0; } if (ap->cant && ((ap->cant & flag) == flag)) - return 0; + return 0; if (ap->can && (ap->can & flag)) - return 1; + return 1; /* Hmm. We don't know if we can or not, so continue */ break; @@ -399,22 +399,22 @@ for (ap = access_top; ap; ap = ap->next) { (*rulenum)++; if (!(ap->can & ACS_SITELOCK) - && ((ap->can & ACS_REGEXP) - ? (quick_regexp_match(ap->host, hname, 0) - || (p && quick_regexp_match(ap->host, p, 0)) + && ((ap->can & ACS_REGEXP) + ? (quick_regexp_match(ap->host, hname, 0) + || (p && quick_regexp_match(ap->host, p, 0)) #ifdef FORCE_IPV4 - || quick_regexp_match(ip4_to_ip6(ap->host), hname, 0) - || (p && quick_regexp_match(ip4_to_ip6(ap->host), p, 0)) + || quick_regexp_match(ip4_to_ip6(ap->host), hname, 0) + || (p && quick_regexp_match(ip4_to_ip6(ap->host), p, 0)) #endif - ) - : (quick_wild(ap->host, hname) - || (p && quick_wild(ap->host, p)) + ) + : (quick_wild(ap->host, hname) + || (p && quick_wild(ap->host, p)) #ifdef FORCE_IPV4 - || quick_wild(ip4_to_ip6(ap->host), hname) - || (p && quick_wild(ip4_to_ip6(ap->host), p)) + || quick_wild(ip4_to_ip6(ap->host), hname) + || (p && quick_wild(ip4_to_ip6(ap->host), p)) #endif - )) - && (ap->who == AMBIGUOUS || ap->who == who)) { + )) + && (ap->who == AMBIGUOUS || ap->who == who)) { /* Got one */ return ap; } @@ -433,11 +433,11 @@ */ int format_access(struct access *ap, int rulenum, - dbref who __attribute__ ((__unused__)), char *buff, char **bp) + dbref who __attribute__ ((__unused__)), char *buff, char **bp) { if (ap) { safe_format(buff, bp, T("Matched line %d: %s %s"), rulenum, ap->host, - (ap->can & ACS_REGEXP) ? "(regexp)" : ""); + (ap->can & ACS_REGEXP) ? "(regexp)" : ""); safe_chr('\n', buff, bp); safe_format(buff, bp, T("Comment: %s"), ap->comment); safe_chr('\n', buff, bp); @@ -493,7 +493,7 @@ */ int add_access_sitelock(dbref player, const char *host, dbref who, int can, - int cant) + int cant) { struct access *end; struct access *tmp; @@ -507,7 +507,7 @@ tmp->cant = cant; strcpy(tmp->host, host); sprintf(tmp->comment, "By %s(#%d) on %s", Name(player), player, - show_time(mudtime, 0)); + show_time(mudtime, 0)); tmp->next = NULL; if (!access_top) { @@ -523,7 +523,7 @@ if (end->can != ACS_SITELOCK) { /* We're at the end and there's no sitelock marker. Add one */ if (!add_access_node("@sitelock", AMBIGUOUS, ACS_SITELOCK, 0, "")) - return 0; + return 0; end = end->next; } else { /* We're in the middle, so be sure we keep the list linked */ @@ -563,9 +563,9 @@ n++; mush_free(ap, "struct_access"); if (prev) - prev->next = next; + prev->next = next; else - access_top = next; + access_top = next; } else { prev = ap; } @@ -608,27 +608,27 @@ if (ap->can != ACS_SITELOCK) { bp = flaglist; for (c = acslist; c->name; c++) { - if (c->flag == ACS_DEFAULT) - continue; - if (ap->can & c->flag) { - safe_chr(' ', flaglist, &bp); - safe_str(c->name, flaglist, &bp); - } - if (c->toggle && (ap->cant & c->flag)) { - safe_chr(' ', flaglist, &bp); - safe_chr('!', flaglist, &bp); - safe_str(c->name, flaglist, &bp); - } + if (c->flag == ACS_DEFAULT) + continue; + if (ap->can & c->flag) { + safe_chr(' ', flaglist, &bp); + safe_str(c->name, flaglist, &bp); + } + if (c->toggle && (ap->cant & c->flag)) { + safe_chr(' ', flaglist, &bp); + safe_chr('!', flaglist, &bp); + safe_str(c->name, flaglist, &bp); + } } *bp = '\0'; notify_format(player, - "%3d SITE: %-20s DBREF: %-6s FLAGS:%s", rulenum, - ap->host, unparse_dbref(ap->who), flaglist); + "%3d SITE: %-20s DBREF: %-6s FLAGS:%s", rulenum, + ap->host, unparse_dbref(ap->who), flaglist); notify_format(player, " COMMENT: %s", ap->comment); } else { notify(player, - T - ("---- @sitelock will add sites immediately below this line ----")); + T + ("---- @sitelock will add sites immediately below this line ----")); } } @@ -647,7 +647,7 @@ */ int parse_access_options(const char *opts, dbref *who, int *can, int *cant, - dbref player) + dbref player) { char myopts[BUFFER_LEN]; char *p; @@ -666,13 +666,13 @@ while ((w = split_token(&p, ' '))) { found = 0; - if (first && who) { /* Check for a character */ + if (first && who) { /* Check for a character */ first = 0; - if (is_integer(w)) { /* We have a dbref */ - *who = parse_integer(w); - if (*who != AMBIGUOUS && !GoodObject(*who)) - *who = AMBIGUOUS; - continue; + if (is_integer(w)) { /* We have a dbref */ + *who = parse_integer(w); + if (*who != AMBIGUOUS && !GoodObject(*who)) + *who = AMBIGUOUS; + continue; } } @@ -680,31 +680,31 @@ /* Found a negated warning */ w++; for (c = acslist; c->name; c++) { - if (c->toggle && !strncasecmp(w, c->name, strlen(c->name))) { - *cant |= c->flag; - found++; - } + if (c->toggle && !strncasecmp(w, c->name, strlen(c->name))) { + *cant |= c->flag; + found++; + } } } else { /* None is special */ if (!strncasecmp(w, "NONE", 4)) { - *cant = ACS_DEFAULT; - found++; + *cant = ACS_DEFAULT; + found++; } else { - for (c = acslist; c->name; c++) { - if (!strncasecmp(w, c->name, strlen(c->name))) { - *can |= c->flag; - found++; - } - } + for (c = acslist; c->name; c++) { + if (!strncasecmp(w, c->name, strlen(c->name))) { + *can |= c->flag; + found++; + } + } } } /* At this point, we haven't matched any warnings. */ if (!found) { if (GoodObject(player)) - notify_format(player, T("Unknown access option: %s"), w); + notify_format(player, T("Unknown access option: %s"), w); else - do_log(LT_ERR, GOD, GOD, T("Unknown access flag: %s"), w); + do_log(LT_ERR, GOD, GOD, T("Unknown access flag: %s"), w); } else { totalfound += found; } Index: src/local.dst =================================================================== --- src/local.dst (.../p5) (revision 1028) +++ src/local.dst (.../p6) (revision 1028) @@ -53,9 +53,9 @@ * but just config_string for strings. */ add_config("use_example", cf_bool, &config_example, sizeof config_example, - "cosmetic"); + "cosmetic"); add_config("some_string", cf_str, config_string, sizeof config_string, - "cosmetic"); + "cosmetic"); #endif } @@ -114,8 +114,8 @@ */ void local_connect(dbref player __attribute__ ((__unused__)), - int isnew __attribute__ ((__unused__)), - int num __attribute__ ((__unused__))) + int isnew __attribute__ ((__unused__)), + int num __attribute__ ((__unused__))) { } @@ -124,7 +124,7 @@ */ void local_disconnect(dbref player __attribute__ ((__unused__)), - int num __attribute__ ((__unused__))) + int num __attribute__ ((__unused__))) { } @@ -166,7 +166,7 @@ void local_data_clone(dbref clone __attribute__ ((__unused__)), - dbref source __attribute__ ((__unused__))) + dbref source __attribute__ ((__unused__))) { } @@ -191,8 +191,8 @@ */ int local_can_interact_first(dbref from __attribute__ ((__unused__)), - dbref to __attribute__ ((__unused__)), int type - __attribute__ ((__unused__))) + dbref to __attribute__ ((__unused__)), int type + __attribute__ ((__unused__))) { return NOTHING; @@ -201,8 +201,8 @@ /* This one is called *after* most standard interaction checks. */ int local_can_interact_last(dbref from __attribute__ ((__unused__)), - dbref to __attribute__ ((__unused__)), int type - __attribute__ ((__unused__))) + dbref to __attribute__ ((__unused__)), int type + __attribute__ ((__unused__))) { /* from is where the message is coming from, in theory. It makes sense * for sound, but think of it as light rays for visiblity or matching. @@ -256,10 +256,10 @@ /* Splits the universe in half, half FOO and half not. */ return (has_flag_by_name(to, "FOO", NOTYPE) == - has_flag_by_name(from, "FOO", NOTYPE)); + has_flag_by_name(from, "FOO", NOTYPE)); -#endif /* NEVER */ +#endif /* NEVER */ /* You want to return NOTHING if you haven't made up your mind */ return NOTHING; Index: src/funmisc.c =================================================================== --- src/funmisc.c (.../p5) (revision 1028) +++ src/funmisc.c (.../p6) (revision 1028) @@ -29,7 +29,7 @@ #include "confmagic.h" #ifdef WIN32 -#pragma warning( disable : 4761) /* NJG: disable warning re conversion */ +#pragma warning( disable : 4761) /* NJG: disable warning re conversion */ #endif extern FUN flist[]; @@ -179,18 +179,18 @@ if ((nargs % 2) != 0) { safe_format(buff, bp, - T("#-1 FUNCTION (%s) EXPECTS AN EVEN NUMBER OF ARGUMENTS"), - called_as); + T("#-1 FUNCTION (%s) EXPECTS AN EVEN NUMBER OF ARGUMENTS"), + called_as); return; } for (n = 0; n < nargs; n += 2) { if (*args[n] && (*(args[n] + 1) == '\0') && - ((qindex = qreg_indexes[(unsigned char) args[n][0]]) != -1) - && global_eval_context.renv[qindex]) { + ((qindex = qreg_indexes[(unsigned char) args[n][0]]) != -1) + && global_eval_context.renv[qindex]) { strcpy(global_eval_context.renv[qindex], args[n + 1]); if (n == 0 && !strcmp(called_as, "SETR")) - safe_strl(args[n + 1], arglens[n + 1], buff, bp); + safe_strl(args[n + 1], arglens[n + 1], buff, bp); } else safe_str(T("#-1 REGISTER OUT OF RANGE"), buff, bp); } @@ -272,9 +272,9 @@ if (show_all) { for (count = 0; count < n; count++) { if (first) - first = 0; + first = 0; else - safe_chr(' ', buff, bp); + safe_chr(' ', buff, bp); safe_uinteger(get_random_long(1, die), buff, bp); } } else { @@ -310,7 +310,7 @@ dp = mstr; sp = args[0]; process_expression(mstr, &dp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); *dp = '\0'; /* try matching, return match immediately when found */ @@ -319,30 +319,30 @@ dp = pstr; sp = args[j]; process_expression(pstr, &dp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); *dp = '\0'; if ((!exact) - ? local_wild_match(pstr, mstr) - : (strcmp(pstr, mstr) == 0)) { + ? local_wild_match(pstr, mstr) + : (strcmp(pstr, mstr) == 0)) { /* If there's a #$ in a switch's action-part, replace it with * the value of the conditional (mstr) before evaluating it. */ if (!exact) - tbuf1 = replace_string("#$", mstr, args[j + 1]); + tbuf1 = replace_string("#$", mstr, args[j + 1]); else - tbuf1 = args[j + 1]; + tbuf1 = args[j + 1]; sp = tbuf1; per = process_expression(buff, bp, &sp, - executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); if (!exact) - mush_free((Malloc_t) tbuf1, "replace_string.buff"); + mush_free((Malloc_t) tbuf1, "replace_string.buff"); found = 1; if (per || first) - return; + return; } } @@ -354,7 +354,7 @@ } else sp = args[nargs - 1]; process_expression(buff, bp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); if (!exact) mush_free((Malloc_t) tbuf1, "replace_string.buff"); } @@ -380,7 +380,7 @@ dp = mstr; sp = args[0]; process_expression(mstr, &dp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); *dp = '\0'; /* try matching, return match immediately when found */ @@ -389,7 +389,7 @@ dp = pstr; sp = args[j]; process_expression(pstr, &dp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); *dp = '\0'; if (quick_regexp_match(pstr, mstr, cs)) { @@ -401,12 +401,12 @@ sp = tbuf1; per = process_expression(buff, bp, &sp, - executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); mush_free((Malloc_t) tbuf1, "replace_string.buff"); found = 1; if (per || first) - return; + return; } } @@ -415,7 +415,7 @@ tbuf1 = replace_string("#$", mstr, args[nargs - 1]); sp = tbuf1; process_expression(buff, bp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); mush_free((Malloc_t) tbuf1, "replace_string.buff"); } } @@ -429,16 +429,16 @@ tp = tbuf; sp = args[0]; process_expression(tbuf, &tp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); *tp = '\0'; if (parse_boolean(tbuf)) { sp = args[1]; process_expression(buff, bp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); } else if (nargs > 2) { sp = args[2]; process_expression(buff, bp, &sp, executor, caller, enactor, - PE_DEFAULT, PT_DEFAULT, pe_info); + PE_DEFAULT, PT_DEFAULT, pe_info); } } @@ -452,7 +452,7 @@ FUNCTION(fun_version) { safe_format(buff, bp, "PennMUSH version %s patchlevel %s %s", - VERSION, PATCHLEVEL, PATCHDATE); + VERSION, PATCHLEVEL, PATCHDATE); } /* ARGSUSED */ @@ -552,7 +552,7 @@ if (!args[0] || !*args[0] || !isalpha((unsigned char) *args[0]) || strchr(args[0], ' ')) { safe_str(T("#-1 FUNCTION (SOUNDEX) REQUIRES A SINGLE WORD ARGUMENT"), buff, - bp); + bp); return; } safe_str(soundex(args[0]), buff, bp); @@ -571,7 +571,7 @@ || !isalpha((unsigned char) *args[1]) || strchr(args[0], ' ') || strchr(args[1], ' ')) { safe_str(T("#-1 FUNCTION (SOUNDLIKE) REQUIRES TWO ONE-WORD ARGUMENTS"), - buff, bp); + buff, bp); return; } /* soundex uses a static buffer, so we need to save it */ @@ -660,8 +660,8 @@ enum whichof_t { DO_FIRSTOF, DO_ALLOF }; static void do_whichof(char *args[], int nargs, enum whichof_t flag, - char *buff, char **bp, dbref executor, - dbref caller, dbref enactor, PE_Info * pe_info) + char *buff, char **bp, dbref executor, + dbref caller, dbref enactor, PE_Info * pe_info) { int j; char tbuf[BUFFER_LEN], *tp; @@ -675,7 +675,7 @@ char *isep = insep; const char *arglast = args[nargs - 1]; process_expression(insep, &isep, &arglast, executor, - caller, enactor, PE_DEFAULT, PT_DEFAULT, pe_info); + caller, enactor, PE_DEFAULT, PT_DEFAULT, pe_info); *isep = '\0'; strcpy(args[nargs - 1], insep); if (!delim_check(buff, bp, nargs, args, nargs, &sep)) @@ -687,16 +687,16 @@ tp = tbuf; sp = args[j]; process_expression(tbuf, &tp, &sp, executor, caller, - enactor, PE_DEFAULT, PT_DEFAULT, pe_info); + enactor, PE_DEFAULT, PT_DEFAULT, pe_info); *tp = '\0'; if (parse_boolean(tbuf)) { if (!first) { - safe_chr(sep, buff, bp); + safe_chr(sep, buff, bp); } else - first = 0; + first = 0; safe_str(tbuf, buff, bp); if (flag == DO_FIRSTOF) - return; + return; } } if (flag == DO_FIRSTOF) @@ -707,7 +707,7 @@ FUNCTION(fun_firstof) { do_whichof(args, nargs, DO_FIRSTOF, buff, bp, executor, - caller, enactor, pe_info); + caller, enactor, pe_info); } @@ -715,5 +715,5 @@ FUNCTION(fun_allof) { do_whichof(args, nargs, DO_ALLOF, buff, bp, executor, - caller, enactor, pe_info); + caller, enactor, pe_info); } Index: src/myrlimit.c =================================================================== --- src/myrlimit.c (.../p5) (revision 1028) +++ src/myrlimit.c (.../p6) (revision 1028) @@ -75,7 +75,7 @@ #endif return; } -#endif /* HAS_GETRLIMIT */ +#endif /* HAS_GETRLIMIT */ int how_many_fds(void) @@ -122,7 +122,7 @@ #ifdef HAS_SYSCONF errno = 0; if ((open_max = sysconf(_SC_OPEN_MAX)) < 0) { - if (errno == 0) /* Value was indeterminate */ + if (errno == 0) /* Value was indeterminate */ open_max = 0; } if (open_max) @@ -137,5 +137,5 @@ */ open_max = 0; return getdtablesize(); -#endif /* WIN 32 */ +#endif /* WIN 32 */ } Index: src/move.c =================================================================== --- src/move.c (.../p5) (revision 1028) +++ src/move.c (.../p6) (revision 1028) @@ -77,9 +77,9 @@ switch (where) { case NOTHING: Location(what) = NOTHING; - return; /* NOTHING doesn't have contents */ + return; /* NOTHING doesn't have contents */ case HOME: - where = Home(what); /* home */ + where = Home(what); /* home */ safe_tel(what, where, nomovemsgs); return; /*NOTREACHED */ @@ -95,43 +95,43 @@ if ((where != NOTHING) && (old != where)) { did_it(what, what, NULL, NULL, "OXMOVE", NULL, NULL, old); if (Hearer(what)) { - did_it_interact(what, old, "LEAVE", NULL, "OLEAVE", T("has left."), - "ALEAVE", old, NA_INTER_PRESENCE); - /* If the player is leaving a zone, do zone messages */ - /* The tricky bit here is that we only care about the zone of - * the outermost contents */ - if (GoodObject(absold) && GoodObject(Zone(absold)) - && (Zone(absloc) != Zone(absold))) - did_it_interact(what, Zone(absold), "ZLEAVE", NULL, "OZLEAVE", NULL, - "AZLEAVE", old, NA_INTER_SEE); - if (GoodObject(old) && !IsRoom(old)) - did_it_interact(what, old, NULL, NULL, "OXLEAVE", NULL, NULL, where, - NA_INTER_SEE); - if (!IsRoom(where)) - did_it_interact(what, where, NULL, NULL, "OXENTER", NULL, NULL, old, - NA_INTER_SEE); - /* If the player is entering a new zone, do zone messages */ - if (!GoodObject(absold) - || (GoodObject(Zone(absloc)) && (Zone(absloc) != Zone(absold)))) - did_it_interact(what, Zone(absloc), "ZENTER", NULL, "OZENTER", NULL, - "AZENTER", where, NA_INTER_SEE); - did_it_interact(what, where, "ENTER", NULL, "OENTER", T("has arrived."), - "AENTER", where, NA_INTER_PRESENCE); + did_it_interact(what, old, "LEAVE", NULL, "OLEAVE", T("has left."), + "ALEAVE", old, NA_INTER_PRESENCE); + /* If the player is leaving a zone, do zone messages */ + /* The tricky bit here is that we only care about the zone of + * the outermost contents */ + if (GoodObject(absold) && GoodObject(Zone(absold)) + && (Zone(absloc) != Zone(absold))) + did_it_interact(what, Zone(absold), "ZLEAVE", NULL, "OZLEAVE", NULL, + "AZLEAVE", old, NA_INTER_SEE); + if (GoodObject(old) && !IsRoom(old)) + did_it_interact(what, old, NULL, NULL, "OXLEAVE", NULL, NULL, where, + NA_INTER_SEE); + if (!IsRoom(where)) + did_it_interact(what, where, NULL, NULL, "OXENTER", NULL, NULL, old, + NA_INTER_SEE); + /* If the player is entering a new zone, do zone messages */ + if (!GoodObject(absold) + || (GoodObject(Zone(absloc)) && (Zone(absloc) != Zone(absold)))) + did_it_interact(what, Zone(absloc), "ZENTER", NULL, "OZENTER", NULL, + "AZENTER", where, NA_INTER_SEE); + did_it_interact(what, where, "ENTER", NULL, "OENTER", T("has arrived."), + "AENTER", where, NA_INTER_PRESENCE); } else { - /* non-listeners only trigger the actions not the messages */ - did_it(what, old, NULL, NULL, NULL, NULL, "ALEAVE", old); - if (GoodObject(absold) && GoodObject(Zone(absold)) - && (Zone(absloc) != Zone(absold))) - did_it(what, Zone(absold), NULL, NULL, NULL, NULL, "AZLEAVE", old); - if (!GoodObject(absold) - || (GoodObject(Zone(absloc)) && (Zone(absloc) != Zone(absold)))) - did_it(what, Zone(absloc), NULL, NULL, NULL, NULL, "AZENTER", where); - did_it(what, where, NULL, NULL, NULL, NULL, "AENTER", where); + /* non-listeners only trigger the actions not the messages */ + did_it(what, old, NULL, NULL, NULL, NULL, "ALEAVE", old); + if (GoodObject(absold) && GoodObject(Zone(absold)) + && (Zone(absloc) != Zone(absold))) + did_it(what, Zone(absold), NULL, NULL, NULL, NULL, "AZLEAVE", old); + if (!GoodObject(absold) + || (GoodObject(Zone(absloc)) && (Zone(absloc) != Zone(absold)))) + did_it(what, Zone(absloc), NULL, NULL, NULL, NULL, "AZENTER", where); + did_it(what, where, NULL, NULL, NULL, NULL, "AENTER", where); } } if (!nomovemsgs) did_it_interact(what, what, "MOVE", NULL, "OMOVE", NULL, "AMOVE", where, - NA_INTER_SEE); + NA_INTER_SEE); } /** A dropper is an object that can hear and has a connected owner */ @@ -168,7 +168,7 @@ { dbref thing; if (loc == dropto) - return; /* bizarre special case */ + return; /* bizarre special case */ if (!IsRoom(loc)) return; /* check for players */ @@ -216,14 +216,14 @@ } if (loc == player) { do_rawlog(LT_ERR, T("ERROR: Attempt to move player %d into itself\n"), - player); + player); deep--; return; } if (recursive_member(loc, player, 0)) { do_rawlog(LT_ERR, - T("ERROR: Attempt to move player %d into carried object %d\n"), - player, loc); + T("ERROR: Attempt to move player %d into carried object %d\n"), + player, loc); deep--; return; } @@ -278,8 +278,8 @@ * the player. */ if (!controls(player, first) - && (Sticky(first) - && (Home(first) != player))) + && (Sticky(first) + && (Home(first) != player))) enter_room(first, HOME, nomovemsgs); else { PUSH(first, Contents(player)); @@ -307,9 +307,9 @@ } else { /* otherwise match on exits - don't use GoodObject here! */ ok = (match_result(player, direction, TYPE_EXIT, MAT_ENGLISH | MAT_EXIT) != - NOTHING); + NOTHING); } - return ok; /* Written like this due to overeager compiler */ + return ok; /* Written like this due to overeager compiler */ } static dbref @@ -341,7 +341,7 @@ ap = abuf; bp = buff; process_expression(buff, &bp, &ap, exit_obj, player, player, - PE_DEFAULT, PT_DEFAULT, NULL); + PE_DEFAULT, PT_DEFAULT, NULL); *bp = '\0'; dest_room = parse_objid(buff); free((Malloc_t) abuf); @@ -362,15 +362,15 @@ /* send him home */ /* but steal all his possessions */ if (!Mobile(player) || !GoodObject(Home(player)) || - recursive_member(Home(player), player, 0) - || (player == Home(player))) { + recursive_member(Home(player), player, 0) + || (player == Home(player))) { notify(player, T("Bad destination.")); return; } if ((loc = Location(player)) != NOTHING && !Dark(player) && !Dark(loc)) { /* tell everybody else */ notify_except(Contents(loc), player, - tprintf(T("%s goes home."), Name(player)), NA_INTER_SEE); + tprintf(T("%s goes home."), Name(player)), NA_INTER_SEE); } /* give the player the messages */ notify(player, T("There's no place like home...")); @@ -381,16 +381,16 @@ /* find the exit */ if (type == MOVE_GLOBAL) exit_m = - match_result(player, direction, TYPE_EXIT, - MAT_ENGLISH | MAT_EXIT | MAT_GLOBAL | MAT_CHECK_KEYS); + match_result(player, direction, TYPE_EXIT, + MAT_ENGLISH | MAT_EXIT | MAT_GLOBAL | MAT_CHECK_KEYS); else if (type == MOVE_ZONE) exit_m = - match_result(player, direction, TYPE_EXIT, - MAT_ENGLISH | MAT_EXIT | MAT_REMOTES | MAT_CHECK_KEYS); + match_result(player, direction, TYPE_EXIT, + MAT_ENGLISH | MAT_EXIT | MAT_REMOTES | MAT_CHECK_KEYS); else exit_m = - match_result(player, direction, TYPE_EXIT, - MAT_ENGLISH | MAT_EXIT | MAT_CHECK_KEYS); + match_result(player, direction, TYPE_EXIT, + MAT_ENGLISH | MAT_EXIT | MAT_CHECK_KEYS); switch (exit_m) { case NOTHING: /* try to force the object */ @@ -403,79 +403,79 @@ /* we got one */ /* check to see if we're allowed to pass */ if (!eval_lock(player, Location(player), Leave_Lock)) { - fail_lock(player, Location(player), Leave_Lock, - T("You can't go that way."), NOTHING); - return; + fail_lock(player, Location(player), Leave_Lock, + T("You can't go that way."), NOTHING); + return; } if (could_doit(player, exit_m)) { - switch (Location(exit_m)) { - case HOME: - var_dest = Home(player); - break; - case AMBIGUOUS: - var_dest = find_var_dest(player, exit_m); - /* Only allowed if the owner of the exit could link to var_dest */ - if (!GoodObject(var_dest) || !can_link_to(exit_m, var_dest)) { - notify_format(player, - T - ("Variable exit destination #%d is invalid or not permitted."), - var_dest); - return; - } - break; - default: - var_dest = Location(exit_m); - } + switch (Location(exit_m)) { + case HOME: + var_dest = Home(player); + break; + case AMBIGUOUS: + var_dest = find_var_dest(player, exit_m); + /* Only allowed if the owner of the exit could link to var_dest */ + if (!GoodObject(var_dest) || !can_link_to(exit_m, var_dest)) { + notify_format(player, + T + ("Variable exit destination #%d is invalid or not permitted."), + var_dest); + return; + } + break; + default: + var_dest = Location(exit_m); + } - if (!GoodObject(var_dest)) { - do_rawlog(LT_ERR, - T("Exit #%d destination became %d during move.\n"), - exit_m, var_dest); - notify(player, T("Exit destination is invalid.")); - return; - } - if (recursive_member(var_dest, player, 0)) { - notify(player, T("Exit destination is invalid.")); - return; - } - did_it(player, exit_m, "SUCCESS", NULL, "OSUCCESS", NULL, - "ASUCCESS", NOTHING); - did_it(player, exit_m, "DROP", NULL, "ODROP", NULL, "ADROP", var_dest); - switch (Typeof(var_dest)) { + if (!GoodObject(var_dest)) { + do_rawlog(LT_ERR, + T("Exit #%d destination became %d during move.\n"), + exit_m, var_dest); + notify(player, T("Exit destination is invalid.")); + return; + } + if (recursive_member(var_dest, player, 0)) { + notify(player, T("Exit destination is invalid.")); + return; + } + did_it(player, exit_m, "SUCCESS", NULL, "OSUCCESS", NULL, + "ASUCCESS", NOTHING); + did_it(player, exit_m, "DROP", NULL, "ODROP", NULL, "ADROP", var_dest); + switch (Typeof(var_dest)) { - case TYPE_ROOM: - /* Remember the current room */ - loc = Location(player); - /* Move the leader */ - enter_room(player, var_dest, 0); - /* Move the followers if the leader is elsewhere */ - if (Location(player) != loc) - follower_command(player, loc, tprintf("%s #%d", "goto", exit_m)); - break; - case TYPE_PLAYER: - case TYPE_THING: - if (IsGarbage(var_dest)) { - notify(player, T("You can't go that way.")); - return; - } - if (Location(var_dest) == NOTHING) - return; - /* Remember the current room */ - loc = Location(player); - /* Move the leader */ - safe_tel(player, var_dest, 0); - /* Move the followers if the leader is elsewhere */ - if (Location(player) != loc) - follower_command(player, loc, tprintf("%s #%d", "goto", exit_m)); - break; - case TYPE_EXIT: - notify(player, T("This feature coming soon.")); - break; - } + case TYPE_ROOM: + /* Remember the current room */ + loc = Location(player); + /* Move the leader */ + enter_room(player, var_dest, 0); + /* Move the followers if the leader is elsewhere */ + if (Location(player) != loc) + follower_command(player, loc, tprintf("%s #%d", "goto", exit_m)); + break; + case TYPE_PLAYER: + case TYPE_THING: + if (IsGarbage(var_dest)) { + notify(player, T("You can't go that way.")); + return; + } + if (Location(var_dest) == NOTHING) + return; + /* Remember the current room */ + loc = Location(player); + /* Move the leader */ + safe_tel(player, var_dest, 0); + /* Move the followers if the leader is elsewhere */ + if (Location(player) != loc) + follower_command(player, loc, tprintf("%s #%d", "goto", exit_m)); + break; + case TYPE_EXIT: + notify(player, T("This feature coming soon.")); + break; + } } else - fail_lock(player, exit_m, Basic_Lock, T("You can't go that way."), - NOTHING); + fail_lock(player, exit_m, Basic_Lock, T("You can't go that way."), + NOTHING); break; } } @@ -495,7 +495,7 @@ dbref loc; if ((thing = noisy_match_result(player, what, TYPE_EXIT, - MAT_ENGLISH | MAT_EXIT)) == NOTHING) + MAT_ENGLISH | MAT_EXIT)) == NOTHING) return; loc = Home(thing); if (!controls(player, loc)) { @@ -535,103 +535,103 @@ /* take care of possessive get (stealing) */ box = parse_match_possessor(player, &what); if (box == NOTHING) { - notify(player, T("I don't see that here.")); - return; + notify(player, T("I don't see that here.")); + return; } else if (box == AMBIGUOUS) { - notify_format(player, T("I can't tell which %s."), boxname); - return; + notify_format(player, T("I can't tell which %s."), boxname); + return; } thing = match_result(box, what, NOTYPE, MAT_POSSESSION); if (thing == NOTHING) { - notify(player, T("I don't see that here.")); - return; + notify(player, T("I don't see that here.")); + return; } else if (thing == AMBIGUOUS) { - notify_format(player, T("I can't tell which %s."), what); - return; + notify_format(player, T("I can't tell which %s."), what); + return; } /* to steal something, you have to be able to get it, and the * object must be ENTER_OK and not take-locked against you. */ if (could_doit(player, thing) && - (POSSGET_ON_DISCONNECTED || - (!IsPlayer(Location(thing)) || - Connected(Location(thing)))) && - (controls(player, thing) || - (EnterOk(Location(thing)) && - eval_lock(player, Location(thing), Take_Lock)))) { - notify_format(Location(thing), - T("%s was taken from you."), Name(thing)); - notify_format(thing, T("%s took you."), Name(player)); - tp = tbuf1; - safe_format(tbuf1, &tp, T("You take %s from %s."), Name(thing), - Name(Location(thing))); - *tp = '\0'; - tp = tbuf2; - safe_format(tbuf2, &tp, T("takes %s from %s."), Name(thing), - Name(Location(thing))); - *tp = '\0'; - moveto(thing, player); - did_it(player, thing, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, "ASUCCESS", - NOTHING); - did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL, - "ARECEIVE", NOTHING, thing, NOTHING, NA_INTER_HEAR); + (POSSGET_ON_DISCONNECTED || + (!IsPlayer(Location(thing)) || + Connected(Location(thing)))) && + (controls(player, thing) || + (EnterOk(Location(thing)) && + eval_lock(player, Location(thing), Take_Lock)))) { + notify_format(Location(thing), + T("%s was taken from you."), Name(thing)); + notify_format(thing, T("%s took you."), Name(player)); + tp = tbuf1; + safe_format(tbuf1, &tp, T("You take %s from %s."), Name(thing), + Name(Location(thing))); + *tp = '\0'; + tp = tbuf2; + safe_format(tbuf2, &tp, T("takes %s from %s."), Name(thing), + Name(Location(thing))); + *tp = '\0'; + moveto(thing, player); + did_it(player, thing, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, "ASUCCESS", + NOTHING); + did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL, + "ARECEIVE", NOTHING, thing, NOTHING, NA_INTER_HEAR); } else - fail_lock(player, thing, Basic_Lock, - T("You can't take that from there."), NOTHING); + fail_lock(player, thing, Basic_Lock, + T("You can't take that from there."), NOTHING); } else { notify(player, T("I don't see that here.")); } return; } else { if ((thing = noisy_match_result(player, what, TYPE_THING, match_flags)) - != NOTHING) { + != NOTHING) { if (Location(thing) == player) { - notify(player, T("You already have that!")); - return; + notify(player, T("You already have that!")); + return; } if (Location(player) == thing) { - notify(player, T("It's all around you!")); - return; + notify(player, T("It's all around you!")); + return; } if (recursive_member(player, thing, 0)) { - notify(player, T("Bad destination.")); - return; + notify(player, T("Bad destination.")); + return; } switch (Typeof(thing)) { case TYPE_PLAYER: case TYPE_THING: - if (thing == player) { - notify(player, T("You cannot get yourself!")); - return; - } - if (!eval_lock(player, Location(thing), Take_Lock)) { - fail_lock(player, Location(thing), Take_Lock, - T("You can't take that from there."), NOTHING); - return; - } - if (could_doit(player, thing)) { - moveto(thing, player); - notify_format(thing, T("%s took you."), Name(player)); - tp = tbuf1; - safe_format(tbuf1, &tp, T("You take %s."), Name(thing)); - *tp = '\0'; - tp = tbuf2; - safe_format(tbuf2, &tp, T("takes %s."), Name(thing)); - *tp = '\0'; - did_it(player, thing, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, - "ASUCCESS", NOTHING); - did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL, - "ARECEIVE", NOTHING, thing, NOTHING, NA_INTER_HEAR); - } else - fail_lock(player, thing, Basic_Lock, T("You can't pick that up."), - NOTHING); - break; + if (thing == player) { + notify(player, T("You cannot get yourself!")); + return; + } + if (!eval_lock(player, Location(thing), Take_Lock)) { + fail_lock(player, Location(thing), Take_Lock, + T("You can't take that from there."), NOTHING); + return; + } + if (could_doit(player, thing)) { + moveto(thing, player); + notify_format(thing, T("%s took you."), Name(player)); + tp = tbuf1; + safe_format(tbuf1, &tp, T("You take %s."), Name(thing)); + *tp = '\0'; + tp = tbuf2; + safe_format(tbuf2, &tp, T("takes %s."), Name(thing)); + *tp = '\0'; + did_it(player, thing, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, + "ASUCCESS", NOTHING); + did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL, + "ARECEIVE", NOTHING, thing, NOTHING, NA_INTER_HEAR); + } else + fail_lock(player, thing, Basic_Lock, T("You can't pick that up."), + NOTHING); + break; case TYPE_EXIT: - notify(player, T("You can't pick up exits.")); - return; + notify(player, T("You can't pick up exits.")); + return; default: - notify(player, T("You can't take that!")); - break; + notify(player, T("You can't take that!")); + break; } } } @@ -651,9 +651,9 @@ if ((loc = Location(player)) == NOTHING) return; switch (thing = - match_result(player, name, TYPE_THING, - MAT_POSSESSION | MAT_ABSOLUTE | MAT_CONTROL | - MAT_ENGLISH)) { + match_result(player, name, TYPE_THING, + MAT_POSSESSION | MAT_ABSOLUTE | MAT_CONTROL | + MAT_ENGLISH)) { case NOTHING: notify(player, T("You don't have that!")); return; @@ -678,7 +678,7 @@ notify(thing, T("Dropped.")); safe_tel(thing, HOME, 0); } else if ((Location(loc) != NOTHING) && IsRoom(loc) && !Sticky(loc) - && eval_lock(thing, loc, Dropto_Lock)) { + && eval_lock(thing, loc, Dropto_Lock)) { /* location has immediate dropto */ notify_format(thing, T("%s drops you."), Name(player)); moveto(thing, Location(loc)); @@ -733,7 +733,7 @@ return; thing = noisy_match_result(player, what, TYPE_THING | TYPE_PLAYER, - MAT_NEAR_THINGS | MAT_ENGLISH); + MAT_NEAR_THINGS | MAT_ENGLISH); if (!GoodObject(thing)) return; thing_loc = Location(thing); @@ -747,31 +747,31 @@ item = first_visible(player, next)) { next = Next(item); if (IsExit(item)) - continue; /* No dropping exits */ + continue; /* No dropping exits */ empty_ok = 0; if (player == thing) { /* empty me: You don't need to get what's in your inventory already */ if (eval_lock(player, item, Drop_Lock) && - (!IsRoom(thing_loc) || eval_lock(player, thing_loc, Drop_Lock))) - empty_ok = 1; + (!IsRoom(thing_loc) || eval_lock(player, thing_loc, Drop_Lock))) + empty_ok = 1; } /* Check that player can get stuff from thing */ else if (controls(player, thing) || - (EnterOk(thing) && eval_lock(player, thing, Enter_Lock))) { + (EnterOk(thing) && eval_lock(player, thing, Enter_Lock))) { /* Check that player can get item */ if (!could_doit(player, item)) { - /* Send failure message if set, otherwise be quiet */ - fail_lock(player, thing, Basic_Lock, NULL, NOTHING); - continue; + /* Send failure message if set, otherwise be quiet */ + fail_lock(player, thing, Basic_Lock, NULL, NOTHING); + continue; } /* Now check for dropping in the destination */ /* Thing is in player's inventory - sufficient */ if (thing_loc == player) - empty_ok = 1; + empty_ok = 1; /* Thing is in player's location - player must also be able to drop */ else if (eval_lock(player, item, Drop_Lock) && - (!IsRoom(thing_loc) || eval_lock(player, thing_loc, Drop_Lock))) - empty_ok = 1; + (!IsRoom(thing_loc) || eval_lock(player, thing_loc, Drop_Lock))) + empty_ok = 1; } /* Now do the work, if we should. That includes triggering messages */ if (empty_ok) { @@ -780,48 +780,48 @@ count++; /* Get messages */ if (thing != player) { - notify_format(thing, T("%s was taken from you."), Name(item)); - notify_format(item, T("%s took you."), Name(player)); - tp = tbuf1; - safe_format(tbuf1, &tp, T("You take %s from %s."), Name(item), - Name(thing)); - *tp = '\0'; - tp = tbuf2; - safe_format(tbuf2, &tp, T("takes %s from %s."), Name(item), - Name(thing)); - *tp = '\0'; - moveto(item, player); - did_it(player, item, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, "ASUCCESS", - NOTHING); - did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL, - "ARECEIVE", NOTHING, item, NOTHING, NA_INTER_HEAR); + notify_format(thing, T("%s was taken from you."), Name(item)); + notify_format(item, T("%s took you."), Name(player)); + tp = tbuf1; + safe_format(tbuf1, &tp, T("You take %s from %s."), Name(item), + Name(thing)); + *tp = '\0'; + tp = tbuf2; + safe_format(tbuf2, &tp, T("takes %s from %s."), Name(item), + Name(thing)); + *tp = '\0'; + moveto(item, player); + did_it(player, item, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, "ASUCCESS", + NOTHING); + did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL, + "ARECEIVE", NOTHING, item, NOTHING, NA_INTER_HEAR); } /* Drop messages */ if (thing_loc != player) { - if (Sticky(item) && !Fixed(item)) { - safe_tel(thing, HOME, 0); - } else if ((Location(thing_loc) != NOTHING) && IsRoom(thing_loc) - && !Sticky(thing_loc) - && eval_lock(item, thing_loc, Dropto_Lock)) { - /* location has immediate dropto */ - notify_format(item, T("%s drops you."), Name(player)); - moveto(item, Location(thing_loc)); - } else { - notify_format(item, T("%s drops you."), Name(player)); - moveto(item, thing_loc); - } - tp = tbuf1; - safe_format(tbuf1, &tp, T("You drop %s."), Name(item)); - *tp = '\0'; - tp = tbuf2; - safe_format(tbuf2, &tp, T("drops %s."), Name(item)); - *tp = '\0'; - did_it(player, item, "DROP", tbuf1, "ODROP", tbuf2, "ADROP", NOTHING); + if (Sticky(item) && !Fixed(item)) { + safe_tel(thing, HOME, 0); + } else if ((Location(thing_loc) != NOTHING) && IsRoom(thing_loc) + && !Sticky(thing_loc) + && eval_lock(item, thing_loc, Dropto_Lock)) { + /* location has immediate dropto */ + notify_format(item, T("%s drops you."), Name(player)); + moveto(item, Location(thing_loc)); + } else { + notify_format(item, T("%s drops you."), Name(player)); + moveto(item, thing_loc); + } + tp = tbuf1; + safe_format(tbuf1, &tp, T("You drop %s."), Name(item)); + *tp = '\0'; + tp = tbuf2; + safe_format(tbuf2, &tp, T("drops %s."), Name(item)); + *tp = '\0'; + did_it(player, item, "DROP", tbuf1, "ODROP", tbuf2, "ADROP", NOTHING); } } } notify_format(player, T("You remove %d object%s from %s."), - count, (count == 1) ? "" : "s", Name(thing)); + count, (count == 1) ? "" : "s", Name(thing)); return; } @@ -855,8 +855,8 @@ /* the object must pass the lock. Also, the thing being entered */ /* has to be controlled, or must be enter_ok */ if (!((EnterOk(thing) || controls(player, thing)) && - (eval_lock(player, thing, Enter_Lock)) - )) { + (eval_lock(player, thing, Enter_Lock)) + )) { fail_lock(player, thing, Enter_Lock, T("Permission denied."), NOTHING); return; } @@ -903,7 +903,7 @@ global_exit(dbref player, const char *direction) { return (GoodObject - (match_result(player, direction, TYPE_EXIT, MAT_GLOBAL | MAT_EXIT))); + (match_result(player, direction, TYPE_EXIT, MAT_GLOBAL | MAT_EXIT))); } /** Is direction a remote exit? @@ -916,7 +916,7 @@ remote_exit(dbref player, const char *direction) { return (GoodObject - (match_result(player, direction, TYPE_EXIT, MAT_REMOTES | MAT_EXIT))); + (match_result(player, direction, TYPE_EXIT, MAT_REMOTES | MAT_EXIT))); } /** Wrapper for exit movement. @@ -935,7 +935,7 @@ else if ((Zone(Location(player)) != NOTHING) && remote_exit(player, command)) do_move(player, command, MOVE_ZONE); else if ((Location(player) != MASTER_ROOM) - && global_exit(player, command)) + && global_exit(player, command)) do_move(player, command, MOVE_GLOBAL); else do_move(player, command, MOVE_NORMAL); @@ -963,10 +963,10 @@ return; } if (!GoodObject(leader) || !GoodObject(Location(player)) - || (IsPlayer(leader) && !Connected(leader)) - || ((DarkLegal(leader) - || (Dark(Location(player)) && !Light(leader))) - && !See_All(player))) { + || (IsPlayer(leader) && !Connected(leader)) + || ((DarkLegal(leader) + || (Dark(Location(player)) && !Light(leader))) + && !See_All(player))) { notify(player, T("You don't see that here.")); return; } @@ -986,7 +986,7 @@ /* Ok, are we allowed to follow them? */ if (!eval_lock(player, leader, Follow_Lock)) { fail_lock(player, leader, Follow_Lock, - T("You're not alllowed to follow."), Location(player)); + T("You're not alllowed to follow."), Location(player)); return; } /* Ok, looks good */ @@ -1090,9 +1090,9 @@ } /* Are we following or leading them? */ if (!is_following(who, player) - && !is_following(player, who)) { + && !is_following(player, who)) { notify_format(player, - T("%s isn't following you, nor vice versa."), Name(who)); + T("%s isn't following you, nor vice versa."), Name(who)); return; } /* Ok, looks good */ @@ -1156,7 +1156,7 @@ strcpy(msg, tprintf(T("You begin following %s."), Name(leader))); notify_format(leader, T("%s begins following you."), Name(follower)); did_it(follower, leader, "FOLLOW", msg, "OFOLLOW", NULL, - "AFOLLOW", NOTHING); + "AFOLLOW", NOTHING); } } @@ -1170,7 +1170,7 @@ char flwr[BUFFER_LEN]; a = atr_get_noparent(leader, "FOLLOWERS"); if (!a) - return; /* No followers, so no deletion */ + return; /* No followers, so no deletion */ /* Let's take it apart and put it back together w/o follower */ strcpy(flwr, unparse_dbref(follower)); strcpy(tbuf1, atr_value(a)); @@ -1186,7 +1186,7 @@ char ldr[BUFFER_LEN]; a = atr_get_noparent(follower, "FOLLOWING"); if (!a) - return; /* Not following, so no deletion */ + return; /* Not following, so no deletion */ /* Let's take it apart and put it back together w/o leader */ strcpy(ldr, unparse_dbref(leader)); strcpy(tbuf1, atr_value(a)); @@ -1203,7 +1203,7 @@ strcpy(msg, tprintf(T("You stop following %s."), Name(leader))); notify_format(leader, T("%s stops following you."), Name(follower)); did_it(follower, leader, "UNFOLLOW", msg, "OUNFOLLOW", - NULL, "AUNFOLLOW", NOTHING); + NULL, "AUNFOLLOW", NOTHING); } } @@ -1229,7 +1229,7 @@ who = parse_dbref(sp); if (GoodObject(who)) { if (!first) - safe_str(", ", buff, &bp); + safe_str(", ", buff, &bp); safe_str(Name(who), buff, &bp); first = 0; } @@ -1260,7 +1260,7 @@ who = parse_dbref(sp); if (GoodObject(who)) { if (!first) - safe_str(", ", buff, &bp); + safe_str(", ", buff, &bp); safe_str(Name(who), buff, &bp); first = 0; } @@ -1281,7 +1281,7 @@ */ a = atr_get_noparent(follower, "FOLLOWING"); if (!a) - return 0; /* Following no one */ + return 0; /* Following no one */ strcpy(tbuf1, atr_value(a)); s = trim_space_sep(tbuf1, ' '); while (s) { @@ -1305,7 +1305,7 @@ dbref flwr; a = atr_get_noparent(leader, "FOLLOWERS"); if (!a) - return; /* No one's following me */ + return; /* No one's following me */ strcpy(tbuf1, atr_value(a)); s = trim_space_sep(tbuf1, ' '); while (s) { @@ -1314,7 +1314,7 @@ if (GoodObject(flwr)) { del_following(flwr, leader); if (noisy) - notify_format(flwr, T("You stop following %s."), Name(leader)); + notify_format(flwr, T("You stop following %s."), Name(leader)); } } (void) atr_clr(leader, "FOLLOWERS", GOD); @@ -1333,7 +1333,7 @@ dbref ldr; a = atr_get_noparent(follower, "FOLLOWING"); if (!a) - return; /* I'm not following anyone */ + return; /* I'm not following anyone */ strcpy(tbuf1, atr_value(a)); s = trim_space_sep(tbuf1, ' '); while (s) { @@ -1342,7 +1342,7 @@ if (GoodObject(ldr)) { del_follower(ldr, follower); if (noisy) - notify_format(ldr, T("%s stops following you."), Name(follower)); + notify_format(ldr, T("%s stops following you."), Name(follower)); } } (void) atr_clr(follower, "FOLLOWING", GOD); @@ -1364,17 +1364,17 @@ strcpy(combuf, com); a = atr_get_noparent(leader, "FOLLOWERS"); if (!a) - return; /* No followers */ + return; /* No followers */ strcpy(tbuf1, atr_value(a)); s = tbuf1; while (s) { sp = split_token(&s, ' '); follower = parse_dbref(sp); if (GoodObject(follower) && (Location(follower) == loc) - && (Connected(follower) || IsThing(follower)) - && (!(DarkLegal(leader) - || (Dark(Location(follower)) && !Light(leader))) - || See_All(follower))) { + && (Connected(follower) || IsThing(follower)) + && (!(DarkLegal(leader) + || (Dark(Location(follower)) && !Light(leader))) + || See_All(follower))) { /* This is a follower who was in the room with the leader. Follow. */ notify_format(follower, T("You follow %s."), Name(leader)); process_command(follower, combuf, follower, 0); Index: src/speech.c =================================================================== --- src/speech.c (.../p5) (revision 1028) +++ src/speech.c (.../p6) (revision 1028) @@ -31,9 +31,9 @@ static dbref speech_loc(dbref thing); void propagate_sound(dbref thing, const char *msg); static void do_audible_stuff(dbref loc, dbref *excs, int numexcs, - const char *msg); + const char *msg); static void do_one_remit(dbref player, const char *target, const char *msg, - int flags); + int flags); dbref na_zemit(dbref current, void *data); const char * @@ -127,14 +127,14 @@ return; } - recurse = 1; /* Protect use from recursive teach */ + recurse = 1; /* Protect use from recursive teach */ notify_except(Contents(loc), NOTHING, - tprintf(T("%s types --> %s%s%s"), spname(player), - ANSI_HILITE, tbuf1, ANSI_NORMAL), NA_INTER_HEAR); - command = mush_strdup(tbuf1, "string"); /* process_command is destructive */ + tprintf(T("%s types --> %s%s%s"), spname(player), + ANSI_HILITE, tbuf1, ANSI_NORMAL), NA_INTER_HEAR); + command = mush_strdup(tbuf1, "string"); /* process_command is destructive */ process_command(player, command, cause, 1); mush_free(command, "string"); - recurse = 0; /* Ok, we can be called again safely */ + recurse = 0; /* Ok, we can be called again safely */ } /** The say command. @@ -161,8 +161,8 @@ /* notify everybody */ notify_format(player, T("You say, \"%s\""), tbuf1); notify_except(Contents(loc), player, - tprintf(T("%s says, \"%s\""), spname(player), tbuf1), - NA_INTER_HEAR); + tprintf(T("%s says, \"%s\""), spname(player), tbuf1), + NA_INTER_HEAR); } /** A comparator for raw dbrefs. @@ -228,11 +228,11 @@ if (!Loud(player) && !eval_lock(player, pass[1], Speech_Lock)) { fail_lock(player, pass[1], Speech_Lock, T("You may not speak there!"), - NOTHING); + NOTHING); return; } - oneloc = 1; /* we are only oemitting to one location */ + oneloc = 1; /* we are only oemitting to one location */ } else { temp = list; } @@ -251,15 +251,15 @@ * locs[0..10] are corresponding dbrefs of locations */ if (GoodObject(who) && GoodObject(Location(who)) - && (Loud(player) || eval_lock(player, Location(who), Speech_Lock)) + && (Loud(player) || eval_lock(player, Location(who), Speech_Lock)) ) { if (pass[0] < 10) { - locs[pass[0]] = Location(who); - pass[pass[0] + 2] = who; - pass[0]++; + locs[pass[0]] = Location(who); + pass[pass[0] + 2] = who; + pass[0]++; } else { - notify(player, T("Too many people to oemit to.")); - break; + notify(player, T("Too many people to oemit to.")); + break; } } } @@ -275,7 +275,7 @@ continue; pass[1] = locs[i]; notify_anything_loc(orator, na_exceptN, pass, ns_esnotify, na_flags, - message, locs[i]); + message, locs[i]); do_audible_stuff(pass[1], &pass[2], pass[0], message); } } @@ -336,18 +336,18 @@ while (head && *head) { current = next_in_list(start); who = match_result(player, current, TYPE_PLAYER, MAT_NEAR_THINGS | - MAT_CONTAINER); + MAT_CONTAINER); if (!GoodObject(who) || !can_interact(player, who, INTERACT_HEAR)) { safe_chr(' ', tbuf, &tp); safe_str_space(current, tbuf, &tp); if (GoodObject(who)) - notify_format(player, T("%s can't hear you."), Name(who)); + notify_format(player, T("%s can't hear you."), Name(who)); } else { /* A good whisper */ good[gcount++] = who; if (gcount >= 100) { - notify(player, T("Too many people to whisper to.")); - break; + notify(player, T("Too many people to whisper to.")); + break; } } } @@ -378,12 +378,12 @@ if (key == 1) { notify_format(player, (gcount > 1) ? T("%s sense: %s%s%s") : - T("%s senses: %s%s%s"), tbuf + 4, Name(player), gap, arg2); + T("%s senses: %s%s%s"), tbuf + 4, Name(player), gap, arg2); p = tprintf("You sense: %s%s%s", Name(player), gap, arg2); } else { notify_format(player, T("You whisper, \"%s\"%s."), arg2, tbuf); p = tprintf("%s whispers%s: %s", Name(player), - gcount > 1 ? tbuf : "", arg2); + gcount > 1 ? tbuf : "", arg2); } for (who = 0; who < gcount; who++) { @@ -399,13 +399,13 @@ DOLIST(first, first) { overheard = 1; for (who = 0; who < gcount; who++) { - if ((first == player) || (first == good[who])) { - overheard = 0; - break; - } + if ((first == player) || (first == good[who])) { + overheard = 0; + break; + } } if (overheard) - notify_noecho(first, p); + notify_noecho(first, p); } } mush_free((Malloc_t) tbuf, "string"); @@ -442,38 +442,38 @@ who = noisy_match_result(player, p, NOTYPE, MAT_EVERYTHING); if (GoodObject(who) && okay_pemit(player, who)) { if (nospoof && Nospoof(who)) { - if (Paranoid(who)) { - if (!nspbuf) { - bp = nspbuf = mush_malloc(BUFFER_LEN, "string"); - if (player == Owner(player)) - safe_format(nspbuf, &bp, "[%s(#%d)->] %s", Name(player), - player, message); - else - safe_format(nspbuf, &bp, "[%s(#%d)'s %s(#%d)->] %s", - Name(Owner(player)), Owner(player), - Name(player), player, message); - *bp = '\0'; - } - if (flags & PEMIT_PROMPT) - notify_prompt(who, nspbuf); - else - notify(who, nspbuf); - } else { - if (!nsbuf) { - bp = nsbuf = mush_malloc(BUFFER_LEN, "string"); - safe_format(nsbuf, &bp, "[%s->] %s", Name(player), message); - *bp = '\0'; - } - if (flags & PEMIT_PROMPT) - notify_prompt(who, nsbuf); - else - notify(who, nsbuf); - } + if (Paranoid(who)) { + if (!nspbuf) { + bp = nspbuf = mush_malloc(BUFFER_LEN, "string"); + if (player == Owner(player)) + safe_format(nspbuf, &bp, "[%s(#%d)->] %s", Name(player), + player, message); + else + safe_format(nspbuf, &bp, "[%s(#%d)'s %s(#%d)->] %s", + Name(Owner(player)), Owner(player), + Name(player), player, message); + *bp = '\0'; + } + if (flags & PEMIT_PROMPT) + notify_prompt(who, nspbuf); + else + notify(who, nspbuf); + } else { + if (!nsbuf) { + bp = nsbuf = mush_malloc(BUFFER_LEN, "string"); + safe_format(nsbuf, &bp, "[%s->] %s", Name(player), message); + *bp = '\0'; + } + if (flags & PEMIT_PROMPT) + notify_prompt(who, nsbuf); + else + notify(who, nsbuf); + } } else { - if (flags & PEMIT_PROMPT) - notify_prompt_must_puppet(who, message); - else - notify_must_puppet(who, message); + if (flags & PEMIT_PROMPT) + notify_prompt_must_puppet(who, message); + else + notify_must_puppet(who, message); } } } @@ -500,7 +500,7 @@ nospoof = (flags & PEMIT_SPOOF) ? 0 : 1; switch (who = match_result(player, arg1, NOTYPE, - MAT_OBJECTS | MAT_HERE | MAT_CONTAINER)) { + MAT_OBJECTS | MAT_HERE | MAT_CONTAINER)) { case NOTHING: notify(player, T("I don't see that here.")); break; @@ -510,23 +510,23 @@ default: if (!okay_pemit(player, who)) { notify_format(player, - T("I'm sorry, but %s wishes to be left alone now."), - Name(who)); + T("I'm sorry, but %s wishes to be left alone now."), + Name(who)); return; } if (!silent) notify_format(player, T("You pemit \"%s\" to %s."), arg2, Name(who)); if (nospoof && Nospoof(who)) { if (Paranoid(who)) { - if (player == Owner(player)) - notify_format(who, "[%s(#%d)->%s] %s", Name(player), player, - Name(who), arg2); - else - notify_format(who, "[%s(#%d)'s %s(#%d)->%s] %s", - Name(Owner(player)), Owner(player), - Name(player), player, Name(who), arg2); + if (player == Owner(player)) + notify_format(who, "[%s(#%d)->%s] %s", Name(player), player, + Name(who), arg2); + else + notify_format(who, "[%s(#%d)'s %s(#%d)->%s] %s", + Name(Owner(player)), Owner(player), + Name(player), player, Name(who), arg2); } else - notify_format(who, "[%s->%s] %s", Name(player), Name(who), arg2); + notify_format(who, "[%s->%s] %s", Name(player), Name(who), arg2); } else { notify_must_puppet(who, arg2); } @@ -556,10 +556,10 @@ /* notify everybody */ if (!space) notify_except(Contents(loc), NOTHING, - tprintf("%s %s", spname(player), tbuf1), NA_INTER_HEAR); + tprintf("%s %s", spname(player), tbuf1), NA_INTER_HEAR); else notify_except(Contents(loc), NOTHING, - tprintf("%s%s", spname(player), tbuf1), NA_INTER_HEAR); + tprintf("%s%s", spname(player), tbuf1), NA_INTER_HEAR); } /** The *wall commands. @@ -579,8 +579,8 @@ * Only @rwall is available to royalty. */ if (!(Wizard(player) || - ((target == WALL_ALL) && Can_Announce(player)) || - ((target == WALL_RW) && Royalty(player)))) { + ((target == WALL_ALL) && Can_Announce(player)) || + ((target == WALL_RW) && Royalty(player)))) { notify(player, T("Posing as a wizard could be hazardous to your health.")); return; } @@ -590,7 +590,7 @@ switch (*message) { case SAY_TOKEN: if (CHAT_STRIP_QUOTE) - message++; + message++; break; case SEMI_POSE_TOKEN: gap = ""; @@ -626,8 +626,8 @@ flag_broadcast(mask, 0, "%s [%s]: %s", prefix, Name(player), message); else flag_broadcast(mask, 0, - "%s %s %s, \"%s\"", prefix, Name(player), - target == WALL_ALL ? "shouts" : "says", message); + "%s %s %s, \"%s\"", prefix, Name(player), + target == WALL_ALL ? "shouts" : "says", message); } /** The page command. @@ -642,7 +642,7 @@ */ void do_page(dbref player, const char *arg1, const char *arg2, dbref cause, - int noeval, int multipage, int override, int has_eq) + int noeval, int multipage, int override, int has_eq) { dbref target; const char *message; @@ -671,7 +671,7 @@ if (*arg1 && has_eq) { /* page to=[msg]. Always evaluate to, maybe evaluate msg */ process_expression(tbuf2, &tp2, &arg1, player, cause, cause, - PE_DEFAULT, PT_DEFAULT, NULL); + PE_DEFAULT, PT_DEFAULT, NULL); *tp2 = '\0'; head = tbuf2; message = arg2; @@ -695,7 +695,7 @@ notify_format(player, T("You last paged %s."), head); mush_free((Malloc_t) tbuf2, "string"); if (hp) - free((Malloc_t) hp); + free((Malloc_t) hp); return; } } @@ -717,43 +717,43 @@ target = short_page(current); if (target == NOTHING) { notify_format(player, - T("I can't find who you're trying to page with: %s"), - current); + T("I can't find who you're trying to page with: %s"), + current); safe_chr(' ', tbuf, &tp); safe_str_space(current, tbuf, &tp); } else if (target == AMBIGUOUS) { notify_format(player, - T("I'm not sure who you want to page with: %s"), current); + T("I'm not sure who you want to page with: %s"), current); safe_chr(' ', tbuf, &tp); safe_str_space(current, tbuf, &tp); } else { fails_lock = !(override || eval_lock(player, target, Page_Lock)); is_haven = !override && Haven(target); if (!Connected(target) || (Dark(target) && (is_haven || fails_lock))) { - /* A player isn't connected if they aren't connected, or if - * they're DARK and HAVEN, or DARK and the pagelock fails. */ - page_return(player, target, "Away", "AWAY", - tprintf(T("%s is not connected."), Name(target))); - if (fails_lock) - fail_lock(player, target, Page_Lock, NULL, NOTHING); - safe_chr(' ', tbuf, &tp); - safe_str_space(current, tbuf, &tp); + /* A player isn't connected if they aren't connected, or if + * they're DARK and HAVEN, or DARK and the pagelock fails. */ + page_return(player, target, "Away", "AWAY", + tprintf(T("%s is not connected."), Name(target))); + if (fails_lock) + fail_lock(player, target, Page_Lock, NULL, NOTHING); + safe_chr(' ', tbuf, &tp); + safe_str_space(current, tbuf, &tp); } else if (is_haven) { - page_return(player, target, "Haven", "HAVEN", - tprintf(T("%s is not accepting any pages."), Name(target))); - safe_chr(' ', tbuf, &tp); - safe_str_space(Name(target), tbuf, &tp); + page_return(player, target, "Haven", "HAVEN", + tprintf(T("%s is not accepting any pages."), Name(target))); + safe_chr(' ', tbuf, &tp); + safe_str_space(Name(target), tbuf, &tp); } else if (fails_lock) { - page_return(player, target, "Haven", "HAVEN", - tprintf(T("%s is not accepting your pages."), - Name(target))); - fail_lock(player, target, Page_Lock, NULL, NOTHING); - safe_chr(' ', tbuf, &tp); - safe_str_space(Name(target), tbuf, &tp); + page_return(player, target, "Haven", "HAVEN", + tprintf(T("%s is not accepting your pages."), + Name(target))); + fail_lock(player, target, Page_Lock, NULL, NOTHING); + safe_chr(' ', tbuf, &tp); + safe_str_space(Name(target), tbuf, &tp); } else { - /* This is a good page */ - good[gcount] = target; - gcount++; + /* This is a good page */ + good[gcount] = target; + gcount++; } } } @@ -815,7 +815,7 @@ mush_panic("Unable to allocate memory in do_page"); process_expression(msgbuf, &mb, &message, player, cause, cause, - PE_DEFAULT, PT_DEFAULT, NULL); + PE_DEFAULT, PT_DEFAULT, NULL); *mb = '\0'; message = msgbuf; } @@ -864,12 +864,12 @@ /* Figure out the one success message, and send it */ if (key == 1) notify_format(player, T("Long distance to %s%s: %s%s%s"), - ((gcount > 1) && (!multipage)) ? "(blind) " : "", tbuf2, - Name(player), gap, message); + ((gcount > 1) && (!multipage)) ? "(blind) " : "", tbuf2, + Name(player), gap, message); else notify_format(player, T("You paged %s%s with '%s'"), - ((gcount > 1) && (!multipage)) ? "(blind) " : "", tbuf2, - message); + ((gcount > 1) && (!multipage)) ? "(blind) " : "", tbuf2, + message); /* Figure out the 'name' of the player */ if (PAGE_ALIASES && (alias = shortalias(player)) && *alias) @@ -936,10 +936,10 @@ char *filter; ATTR *a; char *p, *bp; - char *temp; /* need this so we don't leak memory - * by failing to free the storage - * allocated by safe_uncompress - */ + char *temp; /* need this so we don't leak memory + * by failing to free the storage + * allocated by safe_uncompress + */ int i; int matched = 0; @@ -956,12 +956,12 @@ for (i = 0; (i < MAX_ARG) && !matched; i++) { p = bp = filter; process_expression(p, &bp, (char const **) &filter, 0, 0, 0, - PE_NOTHING, PT_COMMA, NULL); + PE_NOTHING, PT_COMMA, NULL); if (*filter == ',') *filter++ = '\0'; - if (*p == '\0' && *filter == '\0') /* No more filters */ + if (*p == '\0' && *filter == '\0') /* No more filters */ break; - if (*p == '\0') /* Empty filter */ + if (*p == '\0') /* Empty filter */ continue; if (AF_Regexp(a)) matched = quick_regexp_match(p, msg, AF_Case(a)); @@ -1005,7 +1005,7 @@ asave = safe_atr_value(a); ap = asave; process_expression(tbuf1, &bp, &ap, thing, orator, orator, - PE_DEFAULT, PT_DEFAULT, NULL); + PE_DEFAULT, PT_DEFAULT, NULL); free((Malloc_t) asave); restore_global_regs("prefix_save", preserve); for (j = 0; j < 10; j++) @@ -1047,7 +1047,7 @@ if (IsExit(thing)) { notify_anything(orator, na_next, &Contents(loc), NULL, NA_INTER_HEAR, - tbuf1); + tbuf1); } else { pass[0] = Contents(loc); pass[1] = thing; @@ -1068,12 +1068,12 @@ if (IsRoom(loc)) { DOLIST(e, Exits(loc)) { if (Audible(e)) - propagate_sound(e, msg); + propagate_sound(e, msg); } } else { for (i = 0; i < numexcs; i++) if (*(excs + i) == loc) - exclude = 1; + exclude = 1; if (!exclude) propagate_sound(loc, msg); } @@ -1204,21 +1204,21 @@ notify(player, T("There can't be anything in that!")); } else if (!okay_pemit(player, room)) { notify_format(player, - T("I'm sorry, but %s wishes to be left alone now."), - Name(room)); + T("I'm sorry, but %s wishes to be left alone now."), + Name(room)); } else if (!Loud(player) && !eval_lock(player, room, Speech_Lock)) { fail_lock(player, room, Speech_Lock, T("You may not speak there!"), - NOTHING); + NOTHING); } else { if (!(flags & PEMIT_SILENT) && (Location(player) != room)) { - const char *rmno; - rmno = unparse_object(player, room); - notify_format(player, T("You remit, \"%s\" in %s"), msg, rmno); + const char *rmno; + rmno = unparse_object(player, room); + notify_format(player, T("You remit, \"%s\" in %s"), msg, rmno); } if (flags & PEMIT_SPOOF) - na_flags |= NA_SPOOF; + na_flags |= NA_SPOOF; notify_anything_loc(player, na_loc, &room, ns_esnotify, na_flags, - msg, room); + msg, room); do_audible_stuff(room, NULL, 0, msg); } } @@ -1269,7 +1269,7 @@ if (((room = Location(player)) == player) || !GoodObject(room)) { notify(player, T("Invalid container object.")); do_rawlog(LT_ERR, T("** BAD CONTAINER ** #%d is inside #%d."), player, - room); + room); return; } while (!IsRoom(room) && (rec < 15)) { @@ -1281,7 +1281,7 @@ return; } else if (!Loud(player) && !eval_lock(player, room, Speech_Lock)) { fail_lock(player, room, Speech_Lock, T("You may not speak there!"), - NOTHING); + NOTHING); return; } else { if (!silent && (Location(player) != room)) @@ -1307,13 +1307,13 @@ do { if (this == NOTHING) { for (room = dbrefs[1]; room < db_top; room++) { - if (IsRoom(room) && (Zone(room) == dbrefs[2]) - && (Loud(dbrefs[3]) || eval_lock(dbrefs[3], room, Speech_Lock)) - ) - break; + if (IsRoom(room) && (Zone(room) == dbrefs[2]) + && (Loud(dbrefs[3]) || eval_lock(dbrefs[3], room, Speech_Lock)) + ) + break; } if (!(room < db_top)) - return NOTHING; + return NOTHING; this = room; dbrefs[1] = room + 1; } else if (IsRoom(this)) { Index: src/chunk.c =================================================================== --- src/chunk.c (.../p5) (revision 1028) +++ src/chunk.c (.../p6) (revision 1028) @@ -236,7 +236,7 @@ #include "confmagic.h" #ifdef WIN32 -#pragma warning( disable : 4761) /* disable warning re conversion */ +#pragma warning( disable : 4761) /* disable warning re conversion */ #endif /* A whole bunch of debugging #defines. */ @@ -263,10 +263,10 @@ /* debug... */ #ifdef CHUNK_DEBUG #define ASSERT(x) assert(x) -#else /* CHUNK_DEBUG */ -static int ignore; /**< Used to shut up compiler warnings when not asserting */ +#else /* CHUNK_DEBUG */ +static int ignore; /**< Used to shut up compiler warnings when not asserting */ #define ASSERT(x) ignore++ -#endif /* CHUNK_DEBUG */ +#endif /* CHUNK_DEBUG */ /* * Sizes, limits, etc. @@ -529,26 +529,26 @@ * the rest of the 64K bytes of the region contain chunks. */ typedef struct region_header { - u_int_16 region_id; /**< will be INVALID_REGION_ID if not in use */ - u_int_16 first_free; /**< offset of 1st free chunk */ - struct region_header *prev; /**< linked list prev for LRU cache */ - struct region_header *next; /**< linked list next for LRU cache */ + u_int_16 region_id; /**< will be INVALID_REGION_ID if not in use */ + u_int_16 first_free; /**< offset of 1st free chunk */ + struct region_header *prev; /**< linked list prev for LRU cache */ + struct region_header *next; /**< linked list next for LRU cache */ } RegionHeader; #define FIRST_CHUNK_OFFSET_IN_REGION sizeof(RegionHeader) /** In-memory (never paged) region info. */ typedef struct region { - u_int_16 used_count; /**< number of used chunks */ - u_int_16 free_count; /**< number of free chunks */ - u_int_16 free_bytes; /**< number of free bytes (with headers) */ - u_int_16 largest_free_chunk; /**< largest single free chunk */ - unsigned int total_derefs; /**< total of all used chunk derefs */ - unsigned int period_last_touched; /**< "this" period, for deref counts; + u_int_16 used_count; /**< number of used chunks */ + u_int_16 free_count; /**< number of free chunks */ + u_int_16 free_bytes; /**< number of free bytes (with headers) */ + u_int_16 largest_free_chunk; /**< largest single free chunk */ + unsigned int total_derefs; /**< total of all used chunk derefs */ + unsigned int period_last_touched; /**< "this" period, for deref counts; we don't page in regions to update counts on period change! */ - RegionHeader *in_memory; /**< cache entry; NULL if paged out */ - u_int_16 oddballs[NUM_ODDBALLS]; /**< chunk offsets with odd derefs */ + RegionHeader *in_memory; /**< cache entry; NULL if paged out */ + u_int_16 oddballs[NUM_ODDBALLS]; /**< chunk offsets with odd derefs */ } Region; #define RegionDerefs(region) \ @@ -586,44 +586,44 @@ /* * Info about all regions */ -static u_int_32 region_count; /**< regions in use */ -static u_int_32 region_array_len; /**< length of regions array */ -static Region *regions; /**< regions array, realloced as (rarely) needed */ +static u_int_32 region_count; /**< regions in use */ +static u_int_32 region_array_len; /**< length of regions array */ +static Region *regions; /**< regions array, realloced as (rarely) needed */ /* * regions presently in memory */ -static u_int_32 cached_region_count; /**< number of regions in cache */ -static RegionHeader *cache_head; /**< most recently used region */ -static RegionHeader *cache_tail; /**< least recently used region */ +static u_int_32 cached_region_count; /**< number of regions in cache */ +static RegionHeader *cache_head; /**< most recently used region */ +static RegionHeader *cache_tail; /**< least recently used region */ /* * statistics */ -static int stat_used_short_count; /**< How many short chunks? */ -static int stat_used_short_bytes; /**< How much space in short chunks? */ -static int stat_used_medium_count; /**< How many medium chunks? */ -static int stat_used_medium_bytes; /**< How much space in medium chunks? */ -static int stat_used_long_count; /**< How many long chunks? */ -static int stat_used_long_bytes; /**< How much space in long chunks? */ -static int stat_deref_count; /**< Dereferences this period */ -static int stat_deref_maxxed; /**< Number of chunks with max derefs */ +static int stat_used_short_count; /**< How many short chunks? */ +static int stat_used_short_bytes; /**< How much space in short chunks? */ +static int stat_used_medium_count; /**< How many medium chunks? */ +static int stat_used_medium_bytes; /**< How much space in medium chunks? */ +static int stat_used_long_count; /**< How many long chunks? */ +static int stat_used_long_bytes; /**< How much space in long chunks? */ +static int stat_deref_count; /**< Dereferences this period */ +static int stat_deref_maxxed; /**< Number of chunks with max derefs */ /** histogram for average derefs of regions being paged in/out */ static int stat_paging_histogram[CHUNK_DEREF_MAX + 1]; -static int stat_page_out; /**< Number of page-outs */ -static int stat_page_in; /**< Number of page-ins */ -static int stat_migrate_slide; /**< Number of slide migrations */ -static int stat_migrate_move; /**< Number of move migrations */ -static int stat_migrate_away; /**< Number of chunk evictions */ -static int stat_create; /**< Number of chunk creations */ -static int stat_delete; /**< Number of chunk deletions */ +static int stat_page_out; /**< Number of page-outs */ +static int stat_page_in; /**< Number of page-ins */ +static int stat_migrate_slide; /**< Number of slide migrations */ +static int stat_migrate_move; /**< Number of move migrations */ +static int stat_migrate_away; /**< Number of chunk evictions */ +static int stat_create; /**< Number of chunk creations */ +static int stat_delete; /**< Number of chunk deletions */ /* * migration globals that are used for holding relevant data... */ -static int m_count; /**< The used length for the arrays. */ +static int m_count; /**< The used length for the arrays. */ static chunk_reference_t **m_references; /**< The passed-in references array. */ #ifdef CHUNK_PARANOID @@ -660,7 +660,7 @@ rolling_pos = (rolling_pos + 1) % ROLLING_LOG_SIZE; #else if (format) - return; /* shut up the compiler warning */ + return; /* shut up the compiler warning */ #endif } @@ -715,11 +715,11 @@ rhp = rp->in_memory; fprintf(fp, "region: id:%04x period:%-8x deref:%-8x (%-2x per chunk)\n", - region, rp->period_last_touched, rp->total_derefs, - RegionDerefs(region)); + region, rp->period_last_touched, rp->total_derefs, + RegionDerefs(region)); fprintf(fp, " #used:%-4x #free:%-4x fbytes:%-4x hole:%-4x ", - rp->used_count, rp->free_count, rp->free_bytes, - rp->largest_free_chunk); + rp->used_count, rp->free_count, rp->free_bytes, + rp->largest_free_chunk); if (rhp) fprintf(fp, "first:%-4x h_id:%-4x\n", rhp->first_free, rhp->region_id); else @@ -728,25 +728,25 @@ if (rhp) { for (offset = FIRST_CHUNK_OFFSET_IN_REGION; - offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { + offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { fprintf(fp, "chunk:%c%4s %-6s off:%04x full:%04x ", - migratable(region, offset) ? '*' : ' ', - ChunkIsFree(region, offset) ? "FREE" : "", - ChunkIsShort(region, offset) ? "SHORT" : - (ChunkIsMedium(region, offset) ? "MEDIUM" : "LONG"), - offset, ChunkFullLen(region, offset)); + migratable(region, offset) ? '*' : ' ', + ChunkIsFree(region, offset) ? "FREE" : "", + ChunkIsShort(region, offset) ? "SHORT" : + (ChunkIsMedium(region, offset) ? "MEDIUM" : "LONG"), + offset, ChunkFullLen(region, offset)); if (ChunkIsFree(region, offset)) { - fprintf(fp, "next:%04x\n", ChunkNextFree(region, offset)); + fprintf(fp, "next:%04x\n", ChunkNextFree(region, offset)); } else { - fprintf(fp, "doff:%04x len:%04x ", - ChunkDataPtr(region, offset) - (unsigned char *) rhp, - ChunkLen(region, offset)); - count = ChunkDerefs(region, offset); - if (count == 0xFF) { - fprintf(fp, "deref:many\n"); - } else { - fprintf(fp, "deref:%04x\n", count); - } + fprintf(fp, "doff:%04x len:%04x ", + ChunkDataPtr(region, offset) - (unsigned char *) rhp, + ChunkLen(region, offset)); + count = ChunkDerefs(region, offset); + if (count == 0xFF) { + fprintf(fp, "deref:many\n"); + } else { + fprintf(fp, "deref:%04x\n", count); + } } } } @@ -768,7 +768,7 @@ pos < REGION_SIZE; pos += ChunkFullLen(region, pos)) { if (pos == offset) { if (ChunkIsFree(region, pos)) - mush_panic("Invalid reference to free chunk as used"); + mush_panic("Invalid reference to free chunk as used"); return; } } @@ -801,7 +801,7 @@ if (region >= region_count) { do_rawlog(LT_ERR, "region 0x%04x is not valid: region_count is 0x%04x", - region, region_count); + region, region_count); return 0; } result = 1; @@ -809,21 +809,21 @@ rp = regions + region; if (rp->used_count > REGION_SIZE / MIN_REMNANT_LEN) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: chunk count is ludicrous: 0x%04x", - region, rp->used_count); + "region 0x%04x is not valid: chunk count is ludicrous: 0x%04x", + region, rp->used_count); result = 0; } if (rp->free_count > REGION_SIZE / MIN_REMNANT_LEN) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: free count is ludicrous: 0x%04x", - region, rp->free_count); + "region 0x%04x is not valid: free count is ludicrous: 0x%04x", + region, rp->free_count); result = 0; } if (rp->largest_free_chunk > rp->free_bytes) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: largest free chunk > free bytes:" - " 0x%04x > 0x%04x", - region, rp->largest_free_chunk, rp->free_bytes); + "region 0x%04x is not valid: largest free chunk > free bytes:" + " 0x%04x > 0x%04x", + region, rp->largest_free_chunk, rp->free_bytes); result = 0; } if (!rp->in_memory) @@ -833,7 +833,7 @@ if (rhp->region_id != region) { do_rawlog(LT_ERR, "region 0x%04x is not valid: region in cache is 0x%04x", - region, rhp->region_id); + region, rhp->region_id); result = 0; } dump = 0; @@ -848,8 +848,8 @@ offset < REGION_SIZE; offset += len) { if (was_free && ChunkIsFree(region, offset)) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: uncoalesced free chunk:" - " 0x%04x (see map)", region, offset); + "region 0x%04x is not valid: uncoalesced free chunk:" + " 0x%04x (see map)", region, offset); result = 0; dump = 1; } @@ -859,80 +859,80 @@ free_count++; free_bytes += len; if (largest_free < len) - largest_free = len; + largest_free = len; if (next_free != offset) { - do_rawlog(LT_ERR, - "region 0x%04x is not valid: free chain broken:" - " 0x%04x, expecting 0x%04x (see map)", - region, offset, next_free); - result = 0; - dump = 1; + do_rawlog(LT_ERR, + "region 0x%04x is not valid: free chain broken:" + " 0x%04x, expecting 0x%04x (see map)", + region, offset, next_free); + result = 0; + dump = 1; } next_free = ChunkNextFree(region, offset); } else { used_count++; total_derefs += ChunkDerefs(region, offset); if (ChunkIsMedium(region, offset) && - ChunkLen(region, offset) <= MAX_SHORT_CHUNK_LEN) { - do_rawlog(LT_ERR, - "region 0x%04x is not valid: medium chunk too small:" - " 0x%04x (see map)", region, offset); - result = 0; - dump = 1; + ChunkLen(region, offset) <= MAX_SHORT_CHUNK_LEN) { + do_rawlog(LT_ERR, + "region 0x%04x is not valid: medium chunk too small:" + " 0x%04x (see map)", region, offset); + result = 0; + dump = 1; } if (ChunkIsLong(region, offset) && - ChunkLen(region, offset) <= MAX_MEDIUM_CHUNK_LEN) { - do_rawlog(LT_ERR, - "region 0x%04x is not valid: long chunk too small:" - " 0x%04x (see map)", region, offset); - result = 0; - dump = 1; + ChunkLen(region, offset) <= MAX_MEDIUM_CHUNK_LEN) { + do_rawlog(LT_ERR, + "region 0x%04x is not valid: long chunk too small:" + " 0x%04x (see map)", region, offset); + result = 0; + dump = 1; } } } if (offset != REGION_SIZE) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: last chunk past bounds (see map)", - region); + "region 0x%04x is not valid: last chunk past bounds (see map)", + region); result = 0; } if (next_free != 0) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: free chain unterminated:" - " expecting 0x%04x (see map)", region, next_free); + "region 0x%04x is not valid: free chain unterminated:" + " expecting 0x%04x (see map)", region, next_free); result = 0; dump = 1; } if (rp->used_count != used_count) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: used count is wrong:" - " 0x%04x should be 0x%04x", region, rp->used_count, used_count); + "region 0x%04x is not valid: used count is wrong:" + " 0x%04x should be 0x%04x", region, rp->used_count, used_count); result = 0; } if (rp->total_derefs != total_derefs) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: total derefs is wrong:" - " 0x%04x should be 0x%04x", - region, rp->total_derefs, total_derefs); + "region 0x%04x is not valid: total derefs is wrong:" + " 0x%04x should be 0x%04x", + region, rp->total_derefs, total_derefs); result = 0; } if (rp->free_count != free_count) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: free count is wrong:" - " 0x%04x should be 0x%04x", region, rp->free_count, free_count); + "region 0x%04x is not valid: free count is wrong:" + " 0x%04x should be 0x%04x", region, rp->free_count, free_count); result = 0; } if (rp->free_bytes != free_bytes) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: free bytes is wrong:" - " 0x%04x should be 0x%04x", region, rp->free_bytes, free_bytes); + "region 0x%04x is not valid: free bytes is wrong:" + " 0x%04x should be 0x%04x", region, rp->free_bytes, free_bytes); result = 0; } if (rp->largest_free_chunk != largest_free) { do_rawlog(LT_ERR, - "region 0x%04x is not valid: largest free is wrong:" - " 0x%04x should be 0x%04x", - region, rp->largest_free_chunk, largest_free); + "region 0x%04x is not valid: largest free is wrong:" + " 0x%04x should be 0x%04x", + region, rp->largest_free_chunk, largest_free); result = 0; } if (dump) { @@ -956,8 +956,8 @@ */ static void write_used_chunk(u_int_16 region, u_int_16 offset, u_int_16 full_len, - unsigned char const *data, u_int_16 data_len, - unsigned char derefs) + unsigned char const *data, u_int_16 data_len, + unsigned char derefs) { unsigned char *cptr = ChunkPointer(region, offset); if (full_len <= MAX_SHORT_CHUNK_LEN + CHUNK_SHORT_DATA_OFFSET) { @@ -992,7 +992,7 @@ */ static void write_free_chunk(u_int_16 region, u_int_16 offset, u_int_16 full_len, - u_int_16 next) + u_int_16 next) { unsigned char *cptr = ChunkPointer(region, offset); if (full_len <= MAX_SHORT_CHUNK_LEN + CHUNK_SHORT_DATA_OFFSET) { @@ -1177,9 +1177,9 @@ else { u_int_16 hole; for (hole = rp->in_memory->first_free; - hole; hole = ChunkNextFree(region, hole)) - if (ChunkNextFree(region, hole) == offset) - break; + hole; hole = ChunkNextFree(region, hole)) + if (ChunkNextFree(region, hole) == offset) + break; ASSERT(hole); write_next_free(region, hole, ChunkNextFree(region, offset)); } @@ -1198,15 +1198,15 @@ if (align == 1) { rp->free_bytes -= full_len; write_free_chunk(region, offset + full_len, - hole_len - full_len, ChunkNextFree(region, offset)); + hole_len - full_len, ChunkNextFree(region, offset)); if (rp->in_memory->first_free == offset) rp->in_memory->first_free += full_len; else { u_int_16 hole; for (hole = rp->in_memory->first_free; - hole; hole = ChunkNextFree(region, hole)) - if (ChunkNextFree(region, hole) == offset) - break; + hole; hole = ChunkNextFree(region, hole)) + if (ChunkNextFree(region, hole) == offset) + break; ASSERT(hole); write_next_free(region, hole, offset + full_len); } @@ -1216,7 +1216,7 @@ } else { rp->free_bytes -= full_len; write_free_chunk(region, offset, - hole_len - full_len, ChunkNextFree(region, offset)); + hole_len - full_len, ChunkNextFree(region, offset)); if (rp->largest_free_chunk == hole_len) rp->largest_free_chunk = largest_hole(region); return offset + hole_len - full_len; @@ -1274,7 +1274,7 @@ remaining -= done; pos += done; if (!remaining) - return; + return; } #ifndef WIN32 if (done == -1 && errno == EAGAIN) @@ -1283,10 +1283,10 @@ } #ifdef WIN32 mush_panicf("chunk swap file read, %lu remaining, GetLastError %d", - (unsigned long) remaining, GetLastError()); + (unsigned long) remaining, GetLastError()); #else mush_panicf("chunk swap file read, %lu remaining, errno %d: %s", - (unsigned long) remaining, errno, strerror(errno)); + (unsigned long) remaining, errno, strerror(errno)); #endif } @@ -1339,7 +1339,7 @@ remaining -= done; pos += done; if (!remaining) - return; + return; } #ifndef WIN32 if (done == -1 && errno == EAGAIN) @@ -1348,10 +1348,10 @@ } #ifdef WIN32 mush_panicf("chunk swap file write, %lu remaining, GetLastError %d", - (unsigned long) remaining, GetLastError()); + (unsigned long) remaining, GetLastError()); #else mush_panicf("chunk swap file write, %lu remaining, errno %d: %s", - (unsigned long) remaining, errno, strerror(errno)); + (unsigned long) remaining, errno, strerror(errno)); #endif } @@ -1416,7 +1416,7 @@ find_oddballs(rhp->region_id); #ifdef DEBUG_CHUNK_PAGING do_rawlog(LT_TRACE, "CHUNK: Paging out region %04x (offset %08x)", - rhp->region_id, (unsigned) file_offset); + rhp->region_id, (unsigned) file_offset); #endif write_cache_region(swap_fd, rhp, rhp->region_id); /* keep statistics */ @@ -1458,7 +1458,7 @@ /* page it in */ #ifdef DEBUG_CHUNK_PAGING do_rawlog(LT_TRACE, "CHUNK: Paging in region %04x (offset %08x)", - region, (unsigned) file_offset); + region, (unsigned) file_offset); #endif read_cache_region(swap_fd, rhp, region); /* link the region to its cache entry */ @@ -1475,17 +1475,17 @@ if (shift > 8) { rp->total_derefs = 0; for (offset = FIRST_CHUNK_OFFSET_IN_REGION; - offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { - ChunkDerefs(region, offset) = 0; + offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { + ChunkDerefs(region, offset) = 0; } } else { rp->total_derefs = 0; for (offset = FIRST_CHUNK_OFFSET_IN_REGION; - offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { - if (ChunkIsFree(region, offset)) - continue; - ChunkDerefs(region, offset) >>= shift; - rp->total_derefs += ChunkDerefs(region, offset); + offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { + if (ChunkIsFree(region, offset)) + continue; + ChunkDerefs(region, offset) >>= shift; + rp->total_derefs += ChunkDerefs(region, offset); } } rp->period_last_touched = curr_period; @@ -1520,7 +1520,7 @@ #endif regions = (Region *) realloc(regions, region_array_len * sizeof(Region)); if (!regions) - mush_panic("chunk: region array realloc failure"); + mush_panic("chunk: region array realloc failure"); } region = region_count; region_count++; @@ -1538,7 +1538,7 @@ regions[region].in_memory->region_id = region; regions[region].in_memory->first_free = FIRST_CHUNK_OFFSET_IN_REGION; write_free_chunk(region, FIRST_CHUNK_OFFSET_IN_REGION, - regions[region].free_bytes, 0); + regions[region].free_bytes, 0); touch_cache_region(regions[region].in_memory); return region; @@ -1571,12 +1571,12 @@ j = NUM_ODDBALLS; while (j--) { if (!rp->oddballs[j]) - continue; + continue; d2 = abs(mean - ChunkDerefs(region, rp->oddballs[j])); if (d1 < d2) - break; + break; if (j < NUM_ODDBALLS - 1) - rp->oddballs[j + 1] = rp->oddballs[j]; + rp->oddballs[j + 1] = rp->oddballs[j]; } j++; if (j >= NUM_ODDBALLS) @@ -1611,8 +1611,8 @@ rp = regions + region; free_bytes += rp->free_bytes; if (!FitsInSpace(full_len, rp->largest_free_chunk) && - !(rp->free_count == 2 && - rp->free_bytes - rp->largest_free_chunk == full_len)) + !(rp->free_count == 2 && + rp->free_bytes - rp->largest_free_chunk == full_len)) continue; if (region == old_region) @@ -1638,8 +1638,8 @@ #endif best_region = create_region(); } else if (best_score > (1 << LONLINESS_LIMIT) + IN_MEMORY_BIAS && - (free_bytes * 100 / (REGION_CAPACITY * region_count)) < - FREE_PERCENT_LIMIT) { + (free_bytes * 100 / (REGION_CAPACITY * region_count)) < + FREE_PERCENT_LIMIT) { #ifdef DEBUG_CHUNK_REGION_CREATE do_rawlog(LT_TRACE, "find_best_region chose to create region %04x", region); #endif @@ -1656,7 +1656,7 @@ */ static u_int_16 find_best_offset(u_int_16 full_len, u_int_16 region, - u_int_16 old_region, u_int_16 old_offset) + u_int_16 old_region, u_int_16 old_offset) { u_int_16 fits, offset; @@ -1667,9 +1667,9 @@ offset = ChunkNextFree(region, offset)) { if (region == old_region) { if (offset > old_offset) - break; + break; if (offset + ChunkFullLen(region, offset) == old_offset) - return fits ? fits : offset; + return fits ? fits : offset; } if (ChunkFullLen(region, offset) == full_len) return offset; @@ -1758,49 +1758,49 @@ stat_used_medium_count * CHUNK_MEDIUM_DATA_OFFSET + stat_used_long_count * CHUNK_LONG_DATA_OFFSET; STAT_OUT(tprintf - ("Chunks: %10d allocated (%10d bytes, %10d (%2d%%) overhead)", - used_count, used_bytes, overhead, - used_bytes ? overhead * 100 / used_bytes : 0)); + ("Chunks: %10d allocated (%10d bytes, %10d (%2d%%) overhead)", + used_count, used_bytes, overhead, + used_bytes ? overhead * 100 / used_bytes : 0)); overhead = stat_used_short_count * CHUNK_SHORT_DATA_OFFSET; STAT_OUT(tprintf - (" %10d short (%10d bytes, %10d (%2d%%) overhead)", - stat_used_short_count, stat_used_short_bytes, overhead, - stat_used_short_bytes ? overhead * 100 / - stat_used_short_bytes : 0)); + (" %10d short (%10d bytes, %10d (%2d%%) overhead)", + stat_used_short_count, stat_used_short_bytes, overhead, + stat_used_short_bytes ? overhead * 100 / + stat_used_short_bytes : 0)); overhead = stat_used_medium_count * CHUNK_MEDIUM_DATA_OFFSET; STAT_OUT(tprintf - (" %10d medium (%10d bytes, %10d (%2d%%) overhead)", - stat_used_medium_count, stat_used_medium_bytes, overhead, - stat_used_medium_bytes ? overhead * 100 / - stat_used_medium_bytes : 0)); + (" %10d medium (%10d bytes, %10d (%2d%%) overhead)", + stat_used_medium_count, stat_used_medium_bytes, overhead, + stat_used_medium_bytes ? overhead * 100 / + stat_used_medium_bytes : 0)); overhead = stat_used_long_count * CHUNK_LONG_DATA_OFFSET; STAT_OUT(tprintf - (" %10d long (%10d bytes, %10d (%2d%%) overhead)", - stat_used_long_count, stat_used_long_bytes, overhead, - stat_used_long_bytes ? overhead * 100 / stat_used_long_bytes : 0)); + (" %10d long (%10d bytes, %10d (%2d%%) overhead)", + stat_used_long_count, stat_used_long_bytes, overhead, + stat_used_long_bytes ? overhead * 100 / stat_used_long_bytes : 0)); STAT_OUT(tprintf - (" %10d free (%10d bytes, %10d (%2d%%) fragmented)", - free_count, free_bytes, free_bytes - free_large, - free_bytes ? (free_bytes - free_large) * 100 / free_bytes : 0)); + (" %10d free (%10d bytes, %10d (%2d%%) fragmented)", + free_count, free_bytes, free_bytes - free_large, + free_bytes ? (free_bytes - free_large) * 100 / free_bytes : 0)); overhead = region_count * REGION_SIZE + region_array_len * sizeof(Region); STAT_OUT(tprintf("Storage: %10d total (%2d%% saturation)", - overhead, used_bytes * 100 / overhead)); + overhead, used_bytes * 100 / overhead)); STAT_OUT(tprintf("Regions: %10d total, %8d cached", - region_count, cached_region_count)); + region_count, cached_region_count)); STAT_OUT(tprintf("Paging: %10d out, %10d in", - stat_page_out, stat_page_in)); + stat_page_out, stat_page_in)); STAT_OUT(" "); STAT_OUT(tprintf("Period: %10d (%10d accesses so far, %10d chunks at max)", - curr_period, stat_deref_count, stat_deref_maxxed)); + curr_period, stat_deref_count, stat_deref_maxxed)); STAT_OUT(tprintf("Activity: %10d creates, %10d deletes this period", - stat_create, stat_delete)); + stat_create, stat_delete)); STAT_OUT(tprintf("Migration: %10d moves this period", - stat_migrate_slide + stat_migrate_move)); + stat_migrate_slide + stat_migrate_move)); STAT_OUT(tprintf(" %10d slide %10d move", - stat_migrate_slide, stat_migrate_move)); + stat_migrate_slide, stat_migrate_move)); STAT_OUT(tprintf(" %10d in region%10d out of region", - stat_migrate_slide + stat_migrate_move - stat_migrate_away, - stat_migrate_away)); + stat_migrate_slide + stat_migrate_move - stat_migrate_away, + stat_migrate_away)); } /** Show just the page counts. @@ -1811,7 +1811,7 @@ { const char *s; STAT_OUT(tprintf("Paging: %10d out, %10d in", - stat_page_out, stat_page_in)); + stat_page_out, stat_page_in)); } /** Display the per-region stats. @@ -1828,11 +1828,11 @@ } for (rid = 0; rid < region_count; rid++) { STAT_OUT(tprintf - ("region:%4d #used:%5d #free:%5d " - "fbytes:%04x largest:%04x deref:%3d", - rid, regions[rid].used_count, regions[rid].free_count, - regions[rid].free_bytes, regions[rid].largest_free_chunk, - RegionDerefs(rid))); + ("region:%4d #used:%5d #free:%5d " + "fbytes:%04x largest:%04x deref:%3d", + rid, regions[rid].used_count, regions[rid].free_count, + regions[rid].free_bytes, regions[rid].largest_free_chunk, + RegionDerefs(rid))); } } @@ -1893,19 +1893,19 @@ if (k > max) { sprintf(num, "(%d)", k); if (j < 32) { - if (j < pen) - ante = 18; - else - ante = 19; - memcpy(buffer[ante] + j + 1, num, strlen(num)); - pen = j + strlen(num) + 1; + if (j < pen) + ante = 18; + else + ante = 19; + memcpy(buffer[ante] + j + 1, num, strlen(num)); + pen = j + strlen(num) + 1; } else { - if (j - (int) strlen(num) < pen) - ante = 18; - else - ante = 19; - memcpy(buffer[ante] + j - strlen(num), num, strlen(num)); - pen = j; + if (j - (int) strlen(num) < pen) + ante = 18; + else + ante = 19; + memcpy(buffer[ante] + j - strlen(num), num, strlen(num)); + pen = j; } } } @@ -1939,7 +1939,7 @@ t = m_references[j]; for (k = j; k--;) { if (m_references[k][0] < t[0]) - break; + break; m_references[k + 1] = m_references[k]; } m_references[k + 1] = t; @@ -1958,7 +1958,7 @@ u_int_16 o_len, len, next, other, prev, o_off, o_oth; debug_log("migrate_slide %d (%08x) to %04x%04x", - which, m_references[which][0], region, offset); + which, m_references[which][0], region, offset); bring_in_region(region); @@ -1973,7 +1973,7 @@ memmove(ChunkPointer(region, offset), ChunkPointer(region, other), o_len); #ifdef DEBUG_CHUNK_MIGRATE do_rawlog(LT_TRACE, "CHUNK: Sliding chunk %08x to %04x%04x", - m_references[which][0], region, offset); + m_references[which][0], region, offset); #endif m_references[which][0] = ChunkReference(region, offset); other = offset + o_len; @@ -1982,7 +1982,7 @@ memmove(ChunkPointer(region, prev), ChunkPointer(region, other), o_len); #ifdef DEBUG_CHUNK_MIGRATE do_rawlog(LT_TRACE, "CHUNK: Sliding chunk %08x to %04x%04x", - m_references[which][0], region, prev); + m_references[which][0], region, prev); #endif m_references[which][0] = ChunkReference(region, prev); } @@ -2004,7 +2004,7 @@ if (!region_is_valid(region)) { do_rawlog(LT_TRACE, "Invalid region after migrate_slide!"); do_rawlog(LT_TRACE, "Was moving %04x%04x to %04x%04x (became %08x)...", - region, o_oth, region, o_off, m_references[which][0]); + region, o_oth, region, o_off, m_references[which][0]); do_rawlog(LT_TRACE, "Chunk length %04x into hole length %04x", o_len, len); debug_dump_region(region, tracelog_fp); dump_debug_log(tracelog_fp); @@ -2027,7 +2027,7 @@ Region *srp; debug_log("migrate_move %d (%08x) to %04x%04x, alignment %d", - which, m_references[which][0], region, offset, align); + which, m_references[which][0], region, offset, align); s_reg = ChunkReferenceToRegion(m_references[which][0]); s_off = ChunkReferenceToOffset(m_references[which][0]); @@ -2051,7 +2051,7 @@ if (!FitsInSpace(s_len, ChunkFullLen(region, offset))) { dump_debug_log(tracelog_fp); mush_panicf("Trying to migrate into too small a hole: %04x into %04x!", - s_len, length); + s_len, length); } #endif @@ -2060,7 +2060,7 @@ memcpy(ChunkPointer(region, offset), ChunkPointer(s_reg, s_off), s_len); #ifdef DEBUG_CHUNK_MIGRATE do_rawlog(LT_TRACE, "CHUNK: moving chunk %08x to %04x%04x", - m_references[which][0], region, offset); + m_references[which][0], region, offset); #endif m_references[which][0] = ChunkReference(region, offset); rp->total_derefs += ChunkDerefs(region, offset); @@ -2072,9 +2072,9 @@ if (!region_is_valid(region)) { do_rawlog(LT_TRACE, "Invalid region after migrate_move!"); do_rawlog(LT_TRACE, "Was moving %04x%04x to %04x%04x (became %04x%04x)...", - s_reg, s_off, region, o_off, region, offset); + s_reg, s_off, region, o_off, region, offset); do_rawlog(LT_TRACE, "Chunk length %04x into hole length %04x, alignment %d", - s_len, length, align); + s_len, length, align); debug_dump_region(region, tracelog_fp); mush_panic("Invalid region after migrate_move!"); } @@ -2101,9 +2101,9 @@ best_region = find_best_region(length, derefs, region); best_offset = find_best_offset(length, best_region, region, offset); if (best_offset) - migrate_move(best_region, best_offset, j, 1); + migrate_move(best_region, best_offset, j, 1); if (best_region != region) - stat_migrate_away++; + stat_migrate_away++; } } migrate_sort(); @@ -2185,7 +2185,7 @@ */ u_int_16 chunk_fetch(chunk_reference_t reference, - unsigned char *buffer, u_int_16 buffer_len) + unsigned char *buffer, u_int_16 buffer_len) { u_int_16 region, offset, len; region = ChunkReferenceToRegion(reference); @@ -2275,24 +2275,24 @@ /* Make sure we have something to migrate, in the region. */ for (k = 0; k < m_count; k++) if (ChunkReferenceToRegion(m_references[k][0]) == region) - break; + break; if (k >= m_count) continue; if (!regions[region].in_memory) { /* If not in memory, see if we've got an oddball. */ while (k < m_count) { - if (ChunkReferenceToRegion(m_references[k][0]) != region) - break; - offset = ChunkReferenceToOffset(m_references[k][0]); - for (l = 0; l < NUM_ODDBALLS; l++) { - if (regions[region].oddballs[l] == offset) { - /* Yup, have an oddball... that's worth bringing it in. */ - bring_in_region(region); - goto do_migrate; - } - } - k++; + if (ChunkReferenceToRegion(m_references[k][0]) != region) + break; + offset = ChunkReferenceToOffset(m_references[k][0]); + for (l = 0; l < NUM_ODDBALLS; l++) { + if (regions[region].oddballs[l] == offset) { + /* Yup, have an oddball... that's worth bringing it in. */ + bring_in_region(region); + goto do_migrate; + } + } + k++; } } else { do_migrate: @@ -2337,7 +2337,7 @@ #ifdef WIN32 swap_fd = CreateFile(CHUNK_SWAP_FILE, GENERIC_READ | GENERIC_WRITE, - 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL); + 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL); if (swap_fd == INVALID_HANDLE_VALUE) mush_panicf("Cannot open swap file: %d", GetLastError()); #else @@ -2381,15 +2381,15 @@ break; case CSTATS_REGIONG: chunk_histogram(player, chunk_regionhist(), - "Chart number of regions (y) vs. references (x)"); + "Chart number of regions (y) vs. references (x)"); break; case CSTATS_PAGINGG: chunk_histogram(player, stat_paging_histogram, - "Chart pages in/out (y) vs. references (x)"); + "Chart pages in/out (y) vs. references (x)"); break; case CSTATS_FREESPACEG: chunk_histogram(player, chunk_freehist(), - "Chart region free space (y) vs. references (x)"); + "Chart region free space (y) vs. references (x)"); break; case CSTATS_REGION: chunk_region_statistics(player); @@ -2439,17 +2439,17 @@ if (shift > 8) { rp->total_derefs = 0; for (offset = FIRST_CHUNK_OFFSET_IN_REGION; - offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { - ChunkDerefs(region, offset) = 0; + offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { + ChunkDerefs(region, offset) = 0; } } else { rp->total_derefs = 0; for (offset = FIRST_CHUNK_OFFSET_IN_REGION; - offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { - if (ChunkIsFree(region, offset)) - continue; - ChunkDerefs(region, offset) >>= shift; - rp->total_derefs += ChunkDerefs(region, offset); + offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) { + if (ChunkIsFree(region, offset)) + continue; + ChunkDerefs(region, offset) >>= shift; + rp->total_derefs += ChunkDerefs(region, offset); } } rp->period_last_touched = curr_period; @@ -2537,4 +2537,4 @@ unlink(child_filename); swap_fd_child = -1; } -#endif /* !WIN32 */ +#endif /* !WIN32 */ Index: src/bsd.c =================================================================== --- src/bsd.c (.../p5) (revision 1028) +++ src/bsd.c (.../p6) (revision 1028) @@ -27,8 +27,8 @@ #define EINTR WSAEINTR #define EWOULDBLOCK WSAEWOULDBLOCK #define MAXHOSTNAMELEN 32 -#pragma warning( disable : 4761) /* disable warning re conversion */ -#else /* !WIN32 */ +#pragma warning( disable : 4761) /* disable warning re conversion */ +#else /* !WIN32 */ #ifdef I_SYS_FILE #include #endif @@ -52,7 +52,7 @@ #ifdef I_SYS_STAT #include #endif -#endif /* !WIN32 */ +#endif /* !WIN32 */ #include #ifdef I_SYS_WAIT #include @@ -141,32 +141,32 @@ #define FD_CLR(n,p) (*p &= ~(1<<(n))) /** Check a bit in an fd_set */ #define FD_ISSET(n,p) (*p & (1<<(n))) -#endif /* defines for BSD 4.2 */ +#endif /* defines for BSD 4.2 */ #ifdef HAS_GETRUSAGE void rusage_stats(void); #endif -int que_next(void); /* from cque.c */ +int que_next(void); /* from cque.c */ -void dispatch(void); /* from timer.c */ -dbref email_register_player(const char *name, const char *email, const char *host, const char *ip); /* from player.c */ +void dispatch(void); /* from timer.c */ +dbref email_register_player(const char *name, const char *email, const char *host, const char *ip); /* from player.c */ #ifdef SUN_OS static int extrafd; #endif -int shutdown_flag = 0; /**< Is it time to shut down? */ +int shutdown_flag = 0; /**< Is it time to shut down? */ void chat_player_announce(dbref player, char *msg, int ungag); static int login_number = 0; static int under_limit = 1; -char cf_motd_msg[BUFFER_LEN]; /**< The message of the day */ -char cf_wizmotd_msg[BUFFER_LEN]; /**< The wizard motd */ -char cf_downmotd_msg[BUFFER_LEN]; /**< The down message */ -char cf_fullmotd_msg[BUFFER_LEN]; /**< The 'mush full' message */ +char cf_motd_msg[BUFFER_LEN]; /**< The message of the day */ +char cf_wizmotd_msg[BUFFER_LEN]; /**< The wizard motd */ +char cf_downmotd_msg[BUFFER_LEN]; /**< The down message */ +char cf_fullmotd_msg[BUFFER_LEN]; /**< The 'mush full' message */ static char poll_msg[DOING_LEN]; -char confname[BUFFER_LEN]; /**< Name of the config file */ -char errlog[BUFFER_LEN]; /**< Name of the error log file */ +char confname[BUFFER_LEN]; /**< Name of the config file */ +char errlog[BUFFER_LEN]; /**< Name of the error log file */ /** Is this descriptor connected to a telnet-compatible terminal? */ #define TELNET_ABLE(d) ((d)->conn_flags & (CONN_TELNET | CONN_TELNET_QUERY)) @@ -193,19 +193,19 @@ */ /* Telnet codes */ -#define IAC 255 /**< interpret as command: */ -#define NOP 241 /**< no operation */ -#define AYT 246 /**< are you there? */ -#define DONT 254 /**< you are not to use option */ -#define DO 253 /**< please, you use option */ -#define WONT 252 /**< I won't use option */ -#define WILL 251 /**< I will use option */ -#define SB 250 /**< interpret as subnegotiation */ -#define SE 240 /**< end sub negotiation */ -#define TN_SGA 3 /**< Suppress go-ahead */ -#define TN_LINEMODE 34 /**< Line mode */ -#define TN_NAWS 31 /**< Negotiate About Window Size */ -#define TN_TTYPE 24 /**< Ask for termial type information */ +#define IAC 255 /**< interpret as command: */ +#define NOP 241 /**< no operation */ +#define AYT 246 /**< are you there? */ +#define DONT 254 /**< you are not to use option */ +#define DO 253 /**< please, you use option */ +#define WONT 252 /**< I won't use option */ +#define WILL 251 /**< I will use option */ +#define SB 250 /**< interpret as subnegotiation */ +#define SE 240 /**< end sub negotiation */ +#define TN_SGA 3 /**< Suppress go-ahead */ +#define TN_LINEMODE 34 /**< Line mode */ +#define TN_NAWS 31 /**< Negotiate About Window Size */ +#define TN_TTYPE 24 /**< Ask for termial type information */ static void test_telnet(DESC *d); static void setup_telnet(DESC *d); static int handle_telnet(DESC *d, unsigned char **q, unsigned char *qend); @@ -257,18 +257,18 @@ #endif -DESC *descriptor_list = NULL; /**< The linked list of descriptors */ +DESC *descriptor_list = NULL; /**< The linked list of descriptors */ static int sock; #ifdef HAS_OPENSSL static int sslsock = 0; -SSL *ssl_master_socket = NULL; /**< Master SSL socket for ssl port */ +SSL *ssl_master_socket = NULL; /**< Master SSL socket for ssl port */ #endif static int ndescriptors = 0; #ifdef WIN32 static WSADATA wsadata; #endif -int restarting = 0; /**< Are we restarting the server after a reboot? */ +int restarting = 0; /**< Are we restarting the server after a reboot? */ static int maxd = 0; extern const unsigned char *tables; @@ -276,14 +276,14 @@ #ifdef INFO_SLAVE static fd_set info_pending; static int info_slave; -Pid_t info_slave_pid = -1; /**< Process id of the info_slave process */ -int info_slave_state = 0; /**< State of the info_slave process */ +Pid_t info_slave_pid = -1; /**< Process id of the info_slave process */ +int info_slave_state = 0; /**< State of the info_slave process */ static int info_query_spill, info_reap_spill; static time_t info_queue_time = 0; #endif -sig_atomic_t signal_shutdown_flag = 0; /**< Have we caught a shutdown signal? */ -sig_atomic_t signal_dump_flag = 0; /**< Have we caught a dump signal? */ +sig_atomic_t signal_shutdown_flag = 0; /**< Have we caught a shutdown signal? */ +sig_atomic_t signal_dump_flag = 0; /**< Have we caught a dump signal? */ #ifndef BOOLEXP_DEBUGGING #ifdef WIN32SERVICES @@ -318,21 +318,21 @@ /** A block of cached text. */ typedef struct fblock { - unsigned char *buff; /**< Pointer to the block as a string */ - size_t len; /**< Length of buff */ + unsigned char *buff; /**< Pointer to the block as a string */ + size_t len; /**< Length of buff */ } FBLOCK; /** The complete collection of cached text files. */ struct fcache_entries { - FBLOCK connect_fcache[2]; /**< connect.txt and connect.html */ - FBLOCK motd_fcache[2]; /**< motd.txt and motd.html */ - FBLOCK wizmotd_fcache[2]; /**< wizmotd.txt and wizmotd.html */ - FBLOCK newuser_fcache[2]; /**< newuser.txt and newuser.html */ - FBLOCK register_fcache[2]; /**< register.txt and register.html */ - FBLOCK quit_fcache[2]; /**< quit.txt and quit.html */ - FBLOCK down_fcache[2]; /**< down.txt and down.html */ - FBLOCK full_fcache[2]; /**< full.txt and full.html */ - FBLOCK guest_fcache[2]; /**< guest.txt and guest.html */ + FBLOCK connect_fcache[2]; /**< connect.txt and connect.html */ + FBLOCK motd_fcache[2]; /**< motd.txt and motd.html */ + FBLOCK wizmotd_fcache[2]; /**< wizmotd.txt and wizmotd.html */ + FBLOCK newuser_fcache[2]; /**< newuser.txt and newuser.html */ + FBLOCK register_fcache[2]; /**< register.txt and register.html */ + FBLOCK quit_fcache[2]; /**< quit.txt and quit.html */ + FBLOCK down_fcache[2]; /**< down.txt and down.html */ + FBLOCK full_fcache[2]; /**< full.txt and full.html */ + FBLOCK guest_fcache[2]; /**< guest.txt and guest.html */ }; static struct fcache_entries fcache; @@ -363,7 +363,7 @@ static int dump_messages(DESC *d, dbref player, int new); static int check_connect(DESC *d, const char *msg); static void parse_connect(const char *msg, char *command, char *user, - char *pass); + char *pass); static void close_sockets(void); dbref find_player_by_desc(int port); static DESC *lookup_desc(dbref executor, const char *name); @@ -375,7 +375,7 @@ sig_atomic_t dump_error = 0; WAIT_TYPE dump_status = 0; #endif -extern Pid_t forked_dump_pid; /**< Process id of forking dump process */ +extern Pid_t forked_dump_pid; /**< Process id of forking dump process */ static void dump_users(DESC *call_by, char *match, int doing); static const char *time_format_1(time_t dt); static const char *time_format_2(time_t dt); @@ -408,7 +408,7 @@ */ int main(int argc, char **argv) -#endif /* WIN32SERVICES */ +#endif /* WIN32SERVICES */ { #ifdef AUTORESTART FILE *id; @@ -418,7 +418,7 @@ /* read the configuration file */ if (argc < 2) { fprintf(stderr, - "WARNING: Called without a config file argument. Assuming mush.cnf\n"); + "WARNING: Called without a config file argument. Assuming mush.cnf\n"); strncpy(confname, "mush.cnf", BUFFER_LEN - 1); } else strncpy(confname, argv[1], BUFFER_LEN - 1); @@ -437,10 +437,10 @@ exit(1); } } -#endif /* WIN32 */ +#endif /* WIN32 */ #ifdef HAS_GETRLIMIT - init_rlimit(); /* unlimit file descriptors */ + init_rlimit(); /* unlimit file descriptors */ #endif /* These are FreeBSDisms to fix floating point exceptions */ @@ -451,6 +451,8 @@ fpsetmask(0L); #endif + options.mem_check = 1; + time(&mudtime); /* If we have setlocale, call it to set locale info @@ -595,7 +597,7 @@ #ifdef HAS_GETRUSAGE rusage_stats(); -#endif /* HAS_RUSAGE */ +#endif /* HAS_RUSAGE */ do_rawlog(LT_ERR, T("MUSH shutdown completed.")); @@ -604,12 +606,12 @@ #ifdef WIN32SERVICES shutdown_checkpoint(); #endif - WSACleanup(); /* clean up */ + WSACleanup(); /* clean up */ #else exit(0); #endif } -#endif /* BOOLEXP_DEBUGGING */ +#endif /* BOOLEXP_DEBUGGING */ /** Close and reopen the logfiles - called on SIGHUP */ void @@ -621,8 +623,8 @@ newerr = fopen(errlog, "a"); if (!newerr) { fprintf(stderr, - T("Unable to open %s. Error output continues to stderr.\n"), - errlog); + T("Unable to open %s. Error output continues to stderr.\n"), + errlog); } else { if (!freopen(errlog, "a", stderr)) { printf(T("Ack! Failed reopening stderr!")); @@ -771,7 +773,7 @@ for (d = descriptor_list; d; d = d->next) { d->quota += COMMANDS_PER_TIME * nslices; if (d->quota > COMMAND_BURST_SIZE) - d->quota = COMMAND_BURST_SIZE; + d->quota = COMMAND_BURST_SIZE; } } } @@ -810,7 +812,7 @@ sslsock = make_socket(s