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))); +