PennMUSH Community

Changeset 445

Show
Ignore:
Timestamp:
08/13/06 02:00:00 (2 years ago)
Author:
pennmush
Message:

PennMUSH 1.7.7p23 Archival

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.7.7/CHANGES.177

    r443 r445  
    1919========================================================================== 
    2020 
     21Version 1.7.7 patchlevel 23                     October 10, 2003 
     22 
     23Major Changes: 
     24  * Forking dumps now work with the chunk memory manager. [TAP] 
     25Minor Changes: 
     26  * Chunk allocator improvements in partial read/writes and for 
     27    Win32. [TAP] 
     28  * Use the SHA0 algorithm from OpenSSL instead of our own when possible. [SW] 
     29Functions: 
     30  * New digest() function for generating checksums via a variety of  
     31    algorithms. [SW] 
     32  * cowner() returns the dbref of a channel's owner. Suggested by 
     33    Sholevi@M*U*S*H. [SW] 
     34  * Added baseconv(), for converting numbers from one base to another. 
     35    Useful for tweaking things like Myrddin's bboard code. Suggested 
     36    by many people. [SW] 
     37Fixes: 
     38  * Remove warnings in set.c and pcre.c. Report by Nymeria@M*U*S*H 
     39  * @power messages now show the canonical name of the power. 
     40    Suggested by Cheetah@M*U*S*H. 
     41  * Adding DARK players to channels produced a duplicated message. 
     42    Reported by Mystery8@ST:AW. 
     43  * Players set WIZARD and ROYALTY would get double notification  
     44    of some GAME: messages. Fixed now. [SW] 
     45  * Chatdb corruption possible when admin add players to channels. 
     46    Reported by several folks, diagnosed by Mordie@M*U*S*H. 
     47 
     48 
    2149Version 1.7.7 patchlevel 22                     September 30, 2003 
    2250 
     
    3260  * Attempting to unset attribute flags actually set them. 
    3361    Report by Ambrosia@M*U*S*H. [SW] 
    34   * Remove a warning in set.c. Report by Nymeria@M*U*S*H 
    3562 
    3663 
  • 1.7.7/MANIFEST

    r441 r445  
    238238test/TestHarness.pm 
    239239test/testatree.pl 
     240test/testdigest.pl 
    240241test/testhastype.pl 
    241242test/testrand.pl 
  • 1.7.7/Patchlevel

    r443 r445  
    11Do not edit this file. It is maintained by the official PennMUSH patches. 
    2 This is PennMUSH 1.7.7p22 
     2This is PennMUSH 1.7.7p23 
  • 1.7.7/game/mushcnf.dst

    r441 r445  
    132132### file, and cache often-used attribute text in memory. This  
    133133### can result in substantial (typically 30-50%) savings 
    134 ### in process memory use, at the cost of a very small performance hit 
    135 ### and no longer being able to do forking dumps. 
     134### in process memory use, at the cost of a very small performance hit. 
    136135### You can control the size of memory cache (or set it so large 
    137136### that nothing is ever swapped to disk), as well as several less 
     
    148147# If you want to use an 'infinite' cache, try setting this 
    149148# to 2000000000; you'll lose the memory benefits, but you'll still 
    150 # gain some locality benefits and overhead savings and you'll 
    151 # be able to do forking dumps. 
     149# gain some locality benefits and overhead savings. 
    152150chunk_cache_memory 1000000 
    153151 
     
    388386# If I don't, the MUSH will pause while it dumps. 
    389387# If you're low on memory, don't do this. 
    390 # If you want to use the chunk-based memory allocator, you may not 
    391 # be able to do forking dumps, and it will ignore this. 
    392388# If you're on Win32, don't do this; fork() is not defined. 
    393 forking_dump no 
     389forking_dump yes 
    394390 
    395391# If you're not forking, you get a bunch of messages that you 
  • 1.7.7/game/txt/hlp/pennfunc.hlp

    r441 r445  
    8080  lists of toggle (Yes/No) options efficiently. 
    8181 
    82   band()        bnand()       bnot()        bor()         bxor() 
    83   shl()         shr() 
     82  baseconv()    band()        bnand()       bnot()        bor() 
     83  bxor()        shl()         shr() 
    8484 
    8585& Boolean functions 
     
    9999  Channel functions work with the channel system. 
    100100 
    101   cflags()      channels()    clock()      ctitle()       cwho() 
     101  cflags()      channels()    clock()      cowner()       ctitle() 
     102  cwho() 
    102103& Communication functions 
    103104  Communication functions are side-effect functions that send a message 
     
    197198  before()      brackets()    capstr()      case()        caseall() 
    198199  cat()         center()      comp()        chr()         decrypt() 
    199   delete()      edit()        encrypt()     escape()      if() 
    200   ifelse()      lcstr()       left()        lit()         ljust() 
    201   merge()       mid()         ord()         pos()         regedit() 
    202   lpos()        regmatch()    repeat()      reverse()     right() 
    203   rjust()       scramble()    secure()      sha0()        space() 
    204   spellnum()    squish()      strcat()      strinsert()   stripaccents() 
    205   stripansi()   strlen()      strmatch()    strreplace()  switch() 
    206   trim()        ucstr()       wrap() 
     200  delete()      digest()      edit()        encrypt()     escape() 
     201  if()          ifelse()      lcstr()       left()        lit() 
     202  ljust()       merge()       mid()         ord()         pos() 
     203  regedit()     lpos()        regmatch()    repeat()      reverse() 
     204  right()       rjust()       scramble()    secure()      sha0() 
     205  space()       spellnum()    squish()      strcat()      strinsert() 
     206  stripaccents()stripansi()   strlen()      strmatch()    strreplace() 
     207  switch()      trim()        ucstr()       wrap() 
    207208  
    208209  See also: STRINGS 
     
    457458  Does a bitwise AND of all its arguments, returning the result 
    458459  (A number with only the bits set in every argument set in it). 
     460& BASECONV() 
     461  baseconv(<integer>, <from base>, <to base>) 
     462 
     463  Converts a number from one base to another. The bases can be between 
     464  2 (Binary) and 36.  
    459465& BEEP() 
    460466  beep([<number>]) 
     
    740746 
    741747  See HELP CTU() for more on the angle type. 
     748& COWNER() 
     749  cowner(<channel>) 
     750 
     751  Returns the dbref of the owner of a channel. 
    742752& PCREATE() 
    743753  pcreate(<name>,<password>) 
     
    869879 
    870880  This is a side-effect function and may not be enabled on some MUSHes. 
     881& DIGEST() 
     882  digest(<algorithm>, <string>) 
     883 
     884  Returns a checksum (Hash, digest, etc.) of <string> using the given 
     885  <algorithm>. If the mush is compiled with SSL support (See @config 
     886  compile), <algorithm> can be one of: 
     887 
     888  md2 md4 md5 sha sha1 dss1 mdc2 ripemd160 
     889 
     890  Without SSL, only the sha algorithm is enabled. In both cases, sha returns 
     891  the same thing as the sha0() function. 
     892 
     893  See also: sha0() 
    871894& DIST2D() 
    872895  dist2d(x1, y1, x2, y2) 
  • 1.7.7/game/txt/hlp/pennv177.hlp

    r443 r445  
    1 & 1.7.7p22 
     1& 1.7.7p23 
    22& changes 
    33This is a list of changes in this patchlevel which are probably of 
     
    1212be read in 'help patchlevels'. 
    1313 
     14Version 1.7.7 patchlevel 23                     October 10, 2003 
     15 
     16Major Changes: 
     17  * Forking dumps now work with the chunk memory manager. [TAP] 
     18Minor Changes: 
     19  * Chunk allocator improvements in partial read/writes and for 
     20    Win32. [TAP] 
     21  * Use the SHA0 algorithm from OpenSSL instead of our own when possible. [SW] 
     22Functions: 
     23  * New digest() function for generating checksums via a variety of  
     24    algorithms. [SW] 
     25  * cowner() returns the dbref of a channel's owner. Suggested by 
     26    Sholevi@M*U*S*H. [SW] 
     27  * Added baseconv(), for converting numbers from one base to another. 
     28    Useful for tweaking things like Myrddin's bboard code. Suggested 
     29    by many people. [SW] 
     30Fixes: 
     31  * Remove warnings in set.c and pcre.c. Report by Nymeria@M*U*S*H 
     32  * @power messages now show the canonical name of the power. 
     33    Suggested by Cheetah@M*U*S*H. 
     34  * Adding DARK players to channels produced a duplicated message. 
     35    Reported by Mystery8@ST:AW. 
     36  * Players set WIZARD and ROYALTY would get double notification  
     37    of some GAME: messages. Fixed now. [SW] 
     38  * Chatdb corruption possible when admin add players to channels. 
     39    Reported by several folks, diagnosed by Mordie@M*U*S*H. 
     40 
     41 
     42& 1.7.7p22 
    1443Version 1.7.7 patchlevel 22                     September 30, 2003 
    1544 
     
    2554  * Attempting to unset attribute flags actually set them. 
    2655    Report by Ambrosia@M*U*S*H. [SW] 
    27   * Remove a warning in set.c. Report by Nymeria@M*U*S*H 
    2856 
    2957 
  • 1.7.7/game/txt/hlp/pennvOLD.hlp

    r443 r445  
    44194419 
    442044201.7.7: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 
    4421        19, 20, 21, 22 
     4421       19, 20, 21, 22, 23 
    442244221.7.6: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 
    442344231.7.5: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 
  • 1.7.7/hdrs/chunk.h

    r433 r445  
    2626void chunk_new_period(void); 
    2727 
     28int chunk_fork_file(void); 
     29void chunk_fork_parent(void); 
     30void chunk_fork_child(void); 
     31void chunk_fork_done(void); 
     32 
    2833#endif              /* _CHUNK_H_ */ 
  • 1.7.7/hdrs/flags.h

    r441 r445  
    124124extern void do_flag_add(dbref player, const char *name, char *args_right[]); 
    125125extern void do_flag_letter(dbref player, const char *name, const char *letter); 
     126extern const char *power_to_string(int pwr); 
    126127 
    127128#define twiddle_flag_bitmask(bm,b,neg) (neg ? clear_flag_bitmask(bm,b) : \ 
  • 1.7.7/hdrs/version.h

    r443 r445  
    1 #define VERSION "PennMUSH version 1.7.7 patchlevel 22 [09/30/2003]" 
    2 #define SHORTVN "PennMUSH 1.7.7p22
    3 #define NUMVERSION 001007007022 
     1#define VERSION "PennMUSH version 1.7.7 patchlevel 23 [10/10/2003]" 
     2#define SHORTVN "PennMUSH 1.7.7p23
     3#define NUMVERSION 001007007023 
  • 1.7.7/src/bsd.c

    r443 r445  
    33453345    do_rawlog(LT_ERR, T("ERROR! forking dump exited with signal %d"), 
    33463346          WTERMSIG(my_stat)); 
    3347     flag_broadcast("WIZARD", 0, 
    3348                T("GAME: ERROR! Forking database save failed!")); 
    3349     flag_broadcast("ROYALTY", 0, 
     3347    flag_broadcast("ROYALTY WIZARD", 0, 
    33503348               T("GAME: ERROR! Forking database save failed!")); 
    33513349      } else if (WIFEXITED(my_stat) && WEXITSTATUS(my_stat) == 0) { 
     
    36853683 
    36863684  if (Dark(player)) { 
    3687     flag_broadcast("WIZARD", "MONITOR", "%s %s", T("GAME:"), tbuf1); 
    3688     flag_broadcast("ROYALTY", "MONITOR", "%s %s", T("GAME:"), tbuf1); 
     3685    flag_broadcast("ROYALTY WIZARD", "MONITOR", "%s %s", T("GAME:"), tbuf1); 
    36893686  } else 
    36903687    flag_broadcast(0, "MONITOR", "%s %s", T("GAME:"), tbuf1); 
     
    38463843    flag_broadcast("WIZARD", 0, T("GAME: Suspect %s"), tbuf1); 
    38473844  if (Dark(player)) { 
    3848     flag_broadcast("WIZARD", "MONITOR", "%s %s", T("GAME:"), tbuf1); 
    3849     flag_broadcast("ROYALTY", "MONITOR", "%s %s", T("GAME:"), tbuf1); 
     3845    flag_broadcast("ROYALTY WIZARD", "MONITOR", "%s %s", T("GAME:"), tbuf1); 
    38503846  } else 
    38513847    flag_broadcast(0, "MONITOR", "%s %s", T("GAME:"), tbuf1); 
  • 1.7.7/src/chunk.c

    r439 r445  
    538538 
    539539/** Swap File */ 
     540#ifdef WIN32 
     541typedef HANDLE fd_type; 
     542static HANDLE swap_fd; 
     543static HANDLE swap_fd_child = INVALID_HANDLE_VALUE; 
     544#else 
     545typedef int fd_type; 
    540546static int swap_fd; 
     547static int swap_fd_child = -1; 
     548#endif 
     549static char child_filename[300]; 
    541550 
    542551/** Deref scale control. 
     
    11101119 */ 
    11111120 
     1121/** Read a region from a file. 
     1122 * \param fd file to read from 
     1123 * \param rhp region buffer to use 
     1124 * \param region region to read 
     1125 */ 
     1126static void 
     1127read_cache_region(fd_type fd, RegionHeader * rhp, u_int_16 region) 
     1128{ 
     1129  off_t file_offset = region * REGION_SIZE; 
     1130  int j; 
     1131  char *pos; 
     1132  size_t remaining; 
     1133  int done; 
     1134 
     1135  /* Try to seek up to 3 times... */ 
     1136  for (j = 0; j < 3; j++) 
     1137#ifdef WIN32 
     1138    if (SetFilePointer(fd, file_offset, NULL, FILE_BEGIN) == file_offset) 
     1139      break; 
     1140#else 
     1141    if (lseek(fd, file_offset, SEEK_SET) == file_offset) 
     1142      break; 
     1143#endif 
     1144  if (j >= 3) 
     1145#ifdef WIN32 
     1146    panic(tprintf("chunk swap file seek, GetLastError %d", GetLastError())); 
     1147#else 
     1148    panic(tprintf("chunk swap file seek, errno %d: %s", 
     1149          errno, strerror(errno))); 
     1150#endif 
     1151  pos = (char *) rhp; 
     1152  remaining = REGION_SIZE; 
     1153  for (j = 0; j < 10; j++) { 
     1154#ifdef WIN32 
     1155    if (!ReadFile(fd, pos, remaining, &done, NULL)) { 
     1156      /* nothing */ 
     1157    } 
     1158#else 
     1159    done = read(fd, pos, remaining); 
     1160#endif 
     1161    if (done >= 0) { 
     1162      remaining -= done; 
     1163      pos += done; 
     1164      if (!remaining) 
     1165    return; 
     1166    } 
     1167#ifndef WIN32 
     1168    if (done == -1 && errno == EAGAIN) 
     1169      sleep(0); 
     1170#endif 
     1171  } 
     1172#ifdef WIN32 
     1173  panic(tprintf("chunk swap file read, %d remaining, GetLastError %d", 
     1174        remaining, GetLastError())); 
     1175#else 
     1176  panic(tprintf("chunk swap file read, %d remaining, errno %d: %s", 
     1177        remaining, errno, strerror(errno))); 
     1178#endif 
     1179} 
     1180 
     1181/** Write a region from a file. 
     1182 * \param fd file to write to 
     1183 * \param rhp region buffer to use 
     1184 * \param region region to write 
     1185 */ 
     1186static void 
     1187write_cache_region(fd_type fd, RegionHeader * rhp, u_int_16 region) 
     1188{ 
     1189  off_t file_offset = region * REGION_SIZE; 
     1190  int j; 
     1191  char *pos; 
     1192  size_t remaining; 
     1193  int done; 
     1194 
     1195  /* Try to seek up to 3 times... */ 
     1196  for (j = 0; j < 3; j++) 
     1197#ifdef WIN32 
     1198    if (SetFilePointer(fd, file_offset, NULL, FILE_BEGIN) == file_offset) 
     1199      break; 
     1200#else 
     1201    if (lseek(fd, file_offset, SEEK_SET) == file_offset) 
     1202      break; 
     1203#endif 
     1204  if (j >= 3) 
     1205#ifdef WIN32 
     1206    panic(tprintf("chunk swap file seek, GetLastError %d", GetLastError())); 
     1207#else 
     1208    panic(tprintf("chunk swap file seek, errno %d: %s", 
     1209          errno, strerror(errno))); 
     1210#endif 
     1211  pos = (char *) rhp; 
     1212  remaining = REGION_SIZE; 
     1213  for (j = 0; j < 10; j++) { 
     1214#ifdef WIN32 
     1215    if (!WriteFile(fd, pos, remaining, &done, NULL)) { 
     1216      /* nothing */ 
     1217    } 
     1218#else 
     1219    done = write(fd, pos, remaining); 
     1220#endif 
     1221    if (done >= 0) { 
     1222      remaining -= done; 
     1223      pos += done; 
     1224      if (!remaining) 
     1225    return; 
     1226    } 
     1227#ifndef WIN32 
     1228    if (done == -1 && errno == EAGAIN) 
     1229      sleep(0); 
     1230#endif 
     1231  } 
     1232#ifdef WIN32 
     1233  panic(tprintf("chunk swap file write, %d remaining, GetLastError %d", 
     1234        remaining, GetLastError())); 
     1235#else 
     1236  panic(tprintf("chunk swap file write, %d remaining, errno %d: %s", 
     1237        remaining, errno, strerror(errno))); 
     1238#endif 
     1239} 
     1240 
    11121241/** Find space in the cache. 
    11131242 * This is likely to require paging out something. 
     
    11171246find_available_cache_region(void) 
    11181247{ 
    1119   off_t file_offset; 
    11201248  RegionHeader *rhp; 
    11211249 
     
    11401268 
    11411269  /* page the current occupant out */ 
    1142   file_offset = cache_tail->region_id * REGION_SIZE; 
    11431270#ifdef DEBUG_CHUNK_PAGING 
    11441271  do_rawlog(LT_TRACE, "CHUNK: Paging out region %04x (offset %08x)", 
    11451272        cache_tail->region_id, (unsigned) file_offset); 
    11461273#endif 
    1147   if (lseek(swap_fd, file_offset, SEEK_SET) != file_offset) { 
    1148     /* FIXME: what about EINTR? */ 
    1149     panic("chunk swap file seek"); 
    1150   } 
    1151   if (write(swap_fd, (char *) cache_tail, REGION_SIZE) != REGION_SIZE) { 
    1152     /* FIXME: what about EINTR? */ 
    1153     panic("chunk swap file write"); 
    1154   } 
     1274  write_cache_region(swap_fd, cache_tail, cache_tail->region_id); 
    11551275  /* keep statistics */ 
    11561276  stat_paging_histogram[RegionDerefs(cache_tail->region_id)]++; 
     
    11981318  Region *rp = regions + region; 
    11991319  RegionHeader *rhp, *prev, *next; 
    1200   off_t file_offset = region * REGION_SIZE; 
    12011320  u_int_32 offset; 
    12021321  unsigned int shift; 
     
    12161335        region, (unsigned) file_offset); 
    12171336#endif 
    1218   if (lseek(swap_fd, file_offset, SEEK_SET) != file_offset) { 
    1219     /* FIXME: what about EINTR? */ 
    1220     panic("chunk swap file seek"); 
    1221   } 
    1222   if (read(swap_fd, (char *) rhp, REGION_SIZE) != REGION_SIZE) { 
    1223     /* FIXME: what about EINTR? */ 
    1224     panic("chunk swap file read"); 
    1225   } 
     1337  read_cache_region(swap_fd, rhp, region); 
    12261338  /* link the region to its cache entry */ 
    12271339  rp->in_memory = rhp; 
     
    24052517  do { 
    24062518    worked = 0; 
    2407     for (rhp = cache_head; rhp; rhp = rhp->next) 
     2519    for (rhp = cache_head; rhp; rhp = rhp->next) { 
     2520      if (rhp->region_id == INVALID_REGION_ID) 
     2521    continue; 
    24082522      while (m_limit && migrate_hardpack(rhp->region_id)) { 
    24092523    worked = 1; 
    24102524      } 
     2525    } 
    24112526  } while (worked); 
    24122527 
     
    24282543  do { 
    24292544    worked = 0; 
    2430     for (rhp = cache_head; rhp; rhp = rhp->next) 
     2545    for (rhp = cache_head; rhp; rhp = rhp->next) { 
     2546      if (rhp->region_id == INVALID_REGION_ID) 
     2547    continue; 
    24312548      while (m_limit && migrate_softpack(rhp->region_id)) { 
    24322549    worked = 1; 
    24332550      } 
     2551    } 
    24342552  } while (worked); 
    24352553#ifdef DEBUG_CHUNK_MIGRATE_LOUD 
     
    24722590     (REGION_CAPACITY - MIN_REMNANT_LEN) / UNHAPPINESS_SPACE_DIVISOR); 
    24732591 
     2592#ifdef WIN32 
     2593  swap_fd = CreateFile(CHUNK_SWAP_FILE, GENERIC_READ | GENERIC_WRITE, 
     2594               0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL); 
     2595  if (swap_fd == INVALID_HANDLE_VALUE) 
     2596    panic(tprintf("Cannot open swap file: %d", GetLastError())); 
     2597#else 
    24742598  swap_fd = open(CHUNK_SWAP_FILE, O_RDWR | O_TRUNC | O_CREAT, 0600); 
    24752599  if (swap_fd < 0) 
    24762600    panic(tprintf("Cannot open swap file: %s", strerror(errno))); 
     2601#endif 
    24772602  curr_period = 0; 
    24782603 
     
    25882713  } 
    25892714} 
     2715 
     2716#ifndef WIN32 
     2717/** Clone the chunkswap file for forking dumps. 
     2718 * \retval 0 if unable to clone the swap file 
     2719 * \retval 1 if swap file clone succeeded 
     2720 */ 
     2721int 
     2722chunk_fork_file(void) 
     2723{ 
     2724  unsigned int j; 
     2725  RegionHeader *rhp, *prev, *next; 
     2726 
     2727  /* abort if already cloned */ 
     2728  if (swap_fd_child >= 0) 
     2729    return 0; 
     2730 
     2731  j = 0; 
     2732  for (;;) { 
     2733    sprintf(child_filename, "%s.%d", CHUNK_SWAP_FILE, j); 
     2734    swap_fd_child = open(child_filename, O_RDWR | O_EXCL | O_CREAT, 0600); 
     2735    if (swap_fd_child >= 0) 
     2736      break; 
     2737    if (j >= 10) 
     2738      return 0; 
     2739    j++; 
     2740  } 
     2741 
     2742  rhp = find_available_cache_region(); 
     2743  prev = rhp->prev; 
     2744  next = rhp->next; 
     2745  for (j = 0; j < region_count; j++) { 
     2746    if (regions[j].in_memory) 
     2747      continue; 
     2748 
     2749    read_cache_region(swap_fd, rhp, j); 
     2750    write_cache_region(swap_fd_child, rhp, j); 
     2751  } 
     2752  rhp->region_id = INVALID_REGION_ID; 
     2753  rhp->prev = prev; 
     2754  rhp->next = next; 
     2755 
     2756  return 1; 
     2757} 
     2758 
     2759/** Assert that we're the parent after fork. 
     2760 */ 
     2761void 
     2762chunk_fork_parent(void) 
     2763{ 
     2764  if (swap_fd_child < 0) 
     2765    return; 
     2766 
     2767  close(swap_fd_child); 
     2768  swap_fd_child = -1; 
     2769} 
     2770 
     2771/** Assert that we're the child after fork. 
     2772 */ 
     2773void 
     2774chunk_fork_child(void) 
     2775{ 
     2776  if (swap_fd_child < 0) 
     2777    return; 
     2778 
     2779  close(swap_fd); 
     2780  swap_fd = swap_fd_child; 
     2781  swap_fd_child = -1; 
     2782} 
     2783 
     2784/** Assert that we're done with the cloned chunkswap file. 
     2785 */ 
     2786void 
     2787chunk_fork_done(void) 
     2788{ 
     2789  if (swap_fd_child < 0) 
     2790    close(swap_fd); 
     2791  else 
     2792    close(swap_fd_child); 
     2793 
     2794  unlink(child_filename); 
     2795  swap_fd_child = -1; 
     2796} 
     2797#endif              /* !WIN32 */ 
  • 1.7.7/src/conf.c

    r439 r445  
    15481548#endif 
    15491549 
     1550#ifdef HAS_OPENSSL 
     1551  notify(player, T(" The MUSH was compiled with SSL support.")); 
     1552#endif 
     1553 
    15501554#ifdef SINGLE_LOGFILE 
    15511555  notify(player, T(" Logging is to a single log file.")); 
  • 1.7.7/src/extchat.c

    r441 r445  
    251251  u = (CHANUSER *) mush_malloc(sizeof(CHANUSER), "CHANUSER"); 
    252252  if (!u) 
    253     return NULL
     253    panic("Couldn't allocate memory in new_user in extchat.c")
    254254  CUdbref(u) = who; 
    255255  CUtype(u) = CU_DEFAULT_FLAGS; 
     
    294294load_channel(FILE * fp, CHAN *ch) 
    295295{ 
    296   int ret = 1; 
    297296  strcpy(ChanName(ch), getstring_noalloc(fp)); 
    298297  if (feof(fp)) 
     
    311310  ChanMaxUsers(ch) = ChanNumUsers(ch); 
    312311  ChanUsers(ch) = NULL; 
    313   if (ChanNumUsers(ch) > 0) { 
    314     ret = load_chanusers(fp, ch); 
    315     if (ret < 0) 
    316       return 0; 
    317     ChanNumUsers(ch) = ret; 
    318   } 
     312  if (ChanNumUsers(ch) > 0) 
     313    ChanNumUsers(ch) = load_chanusers(fp, ch); 
    319314  return 1; 
    320315} 
     
    332327    if (GoodObject(player) && Chan_Ok_Type(ch, player)) { 
    333328      user = new_user(player); 
    334       if (!user) 
    335     return -1; 
    336329      CUtype(user) = getref(fp); 
    337330      strcpy(CUtitle(user), getstring_noalloc(fp)); 
     
    990983    format_channel_broadcast(chan, u, victim, CB_CHECKQUIET | CB_PRESENCE, 
    991984                 T("<%s> %s has joined this channel."), NULL); 
    992     ChanNumUsers(chan)++; 
    993       } else { 
    994     notify_format(player, 
    995               T("%s is already on channel <%s>."), Name(victim), 
    996               ChanName(chan)); 
    997985      } 
    998       return; 
    999     } 
     986      ChanNumUsers(chan)++; 
     987    } else { 
     988      notify_format(player, 
     989            T("%s is already on channel <%s>."), Name(victim), 
     990            ChanName(chan)); 
     991    } 
     992    return; 
    1000993  } else if (!strcasecmp("off", com) || !strcasecmp("leave", com)) { 
    1001994    char title[CU_TITLE_LEN]; 
     
    19781971    break; 
    19791972  } 
     1973} 
     1974 
     1975FUNCTION(fun_cowner) 
     1976{ 
     1977  /* Return the dbref of the owner of a channel. */ 
     1978  CHAN *c; 
     1979 
     1980  if (!args[0] || !*args[0]) { 
     1981    safe_str(T("#-1 NO CHANNEL GIVEN"), buff, bp); 
     1982    return; 
     1983  } 
     1984  switch (find_channel(args[0], &c, executor)) { 
     1985  case CMATCH_NONE: 
     1986    safe_str(T("#-1 NO SUCH CHANNEL"), buff, bp); 
     1987    break; 
     1988  case CMATCH_AMBIG: 
     1989    safe_str(T("#-1 AMBIGUOUS CHANNEL NAME"), buff, bp); 
     1990    break; 
     1991  default: 
     1992    safe_dbref(ChanCreator(c), buff, bp); 
     1993  } 
     1994 
    19801995} 
    19811996 
  • 1.7.7/src/flags.c

    r441 r445  
    22862286  } 
    22872287} 
     2288 
     2289/* Not commented because this should go away in power rewrite */ 
     2290const char * 
     2291power_to_string(int pwr) 
     2292{ 
     2293  POWER *p; 
     2294  for (p = power_table; p->name; p++) { 
     2295    /* Special case for immortal, which we don't show any more */ 
     2296    if (!strcasecmp(p->name, "immortal")) 
     2297      continue; 
     2298    if (pwr & p->flag) 
     2299      return p->name; 
     2300  } 
     2301  return ""; 
     2302} 
  • 1.7.7/src/funcrypt.c

    r433 r445  
    2727#include "ansi.h" 
    2828#include "match.h" 
     29#ifdef HAS_OPENSSL 
     30#include <openssl/sha.h> 
     31#include <openssl/evp.h> 
     32#else 
    2933#include "shs.h" 
     34#endif 
    3035#include "confmagic.h" 
    3136 
     
    3338static char *crunch_code _((char *code)); 
    3439static char *crypt_code _((char *code, char *text, int type)); 
     40 
     41#ifdef HAS_OPENSSL 
     42static void safe_hexchar(unsigned char c, char *buff, char **bp); 
     43#endif 
    3544 
    3645/* Copy over only alphanumeric chars */ 
     
    120129FUNCTION(fun_sha0) 
    121130{ 
     131#ifdef HAS_OPENSSL 
     132  unsigned char hash[SHA_DIGEST_LENGTH]; 
     133  int n; 
     134 
     135  SHA(args[0], arglens[0], hash); 
     136 
     137  for (n = 0; n < SHA_DIGEST_LENGTH; n++) 
     138    safe_hexchar(hash[n], buff, bp); 
     139#else 
    122140  SHS_INFO shsInfo; 
    123141  shsInfo.reverse_wanted = (BYTE) options.reverse_shs; 
     
    128146          shsInfo.digest[1], shsInfo.digest[2], shsInfo.digest[3], 
    129147          shsInfo.digest[4]); 
    130 
     148#endif 
     149
     150 
     151FUNCTION(fun_digest) 
     152
     153#ifdef HAS_OPENSSL 
     154  EVP_MD_CTX ctx; 
     155  const EVP_MD *mp; 
     156  unsigned char md[EVP_MAX_MD_SIZE]; 
     157  size_t n, len = 0; 
     158 
     159  if ((mp = EVP_get_digestbyname(args[0])) == NULL) { 
     160    safe_str(T("#-1 UNSUPPORTED DIGEST TYPE"), buff, bp); 
     161    return; 
     162  } 
     163 
     164  EVP_DigestInit(&ctx, mp); 
     165  EVP_DigestUpdate(&ctx, args[1], arglens[1]); 
     166  EVP_DigestFinal(&ctx, md, &len); 
     167 
     168  for (n = 0; n < len; n++) { 
     169    safe_hexchar(md[n], buff, bp); 
     170  } 
     171 
     172#else 
     173  if (strcmp(args[0], "sha") == 0) { 
     174    SHS_INFO shsInfo; 
     175    shsInfo.reverse_wanted = (BYTE) options.reverse_shs; 
     176    shsInit(&shsInfo); 
     177    shsUpdate(&shsInfo, (const BYTE *) args[0], arglens[0]); 
     178    shsFinal(&shsInfo); 
     179    safe_format(buff, bp, "%0lx%0lx%0lx%0lx%0lx", shsInfo.digest[0], 
     180        shsInfo.digest[1], shsInfo.digest[2], shsInfo.digest[3], 
     181        shsInfo.digest[4]); 
     182  } else { 
     183    safe_str(T("#-1 UNSUPPORTED DIGEST TYPE"), buff, bp); 
     184  } 
     185#endif 
     186
     187 
     188#ifdef HAS_OPENSSL 
     189static void 
     190safe_hexchar(unsigned char c, char *buff, char **bp) 
     191
     192  const char *digits = "0123456789abcdef"; 
     193  if (*bp - buff < BUFFER_LEN - 1) { 
     194    **bp = digits[c >> 4]; 
     195    (*bp)++; 
     196  } 
     197  if (*bp - buff < BUFFER_LEN - 1) { 
     198    **bp = digits[c & 0x0F]; 
     199    (*bp)++; 
     200  } 
     201
     202#endif 
  • 1.7.7/src/function.c

    r441 r445  
    192192  {"ATRLOCK", fun_atrlock, 1, 2, FN_REG}, 
    193193  {"BAND", fun_band, 1, INT_MAX, FN_REG}, 
     194  {"BASECONV", fun_baseconv, 3, 3, FN_REG}, 
    194195  {"BEEP", fun_beep, 0, 1, FN_REG}, 
    195196  {"BEFORE", fun_before, 2, 2, FN_REG}, 
     
    207208#ifdef CHAT_SYSTEM 
    208209  {"CEMIT", fun_cemit, 2, 3, FN_REG}, 
     210  {"CFLAGS", fun_cflags, 1, 2, FN_REG}, 
     211  {"CHANNELS", fun_channels, 0, 2, FN_REG}, 
     212  {"CLOCK", fun_clock, 1, 2, FN_REG}, 
     213  {"COWNER", fun_cowner, 1, 1, FN_REG}, 
     214  {"CTITLE", fun_ctitle, 2, 2, FN_REG}, 
     215  {"CWHO", fun_cwho, 1, 1, FN_REG}, 
    209216#endif 
    210217  {"CENTER", fun_center, 2, 3, FN_REG}, 
    211218  {"CHILDREN", fun_lsearch, 1, 1, FN_REG}, 
    212219  {"CHR", fun_chr, 1, 1, FN_REG}, 
    213 #ifdef CHAT_SYSTEM 
    214   {"CFLAGS", fun_cflags, 1, 2, FN_REG}, 
    215   {"CHANNELS", fun_channels, 0, 2, FN_REG}, 
    216 #endif 
    217220  {"CHECKPASS", fun_checkpass, 2, 2, FN_REG | FN_WIZARD}, 
    218 #ifdef CHAT_SYSTEM 
    219   {"CLOCK", fun_clock, 1, 2, FN_REG}, 
    220 #endif 
    221221  {"CLONE", fun_clone, 1, 1, FN_REG}, 
    222222  {"COMP", fun_comp, 2, 3, FN_REG}, 
     
    231231  {"CREATE", fun_create, 1, 2, FN_REG}, 
    232232  {"CTIME", fun_ctime, 1, 1, FN_REG}, 
    233 #ifdef CHAT_SYSTEM 
    234   {"CTITLE", fun_ctitle, 2, 2, FN_REG}, 
    235   {"CWHO", fun_cwho, 1, 1, FN_REG}, 
    236 #endif 
    237233  {"DEC", fun_dec, 1, 1, FN_REG}, 
    238234  {"DECRYPT", fun_decrypt, 2, 2, FN_REG}, 
     
    241237  {"DIE", fun_die, 2, 3, FN_REG}, 
    242238  {"DIG", fun_dig, 1, 3, FN_REG}, 
     239  {"DIGEST", fun_digest, 2, -2, FN_REG}, 
    243240  {"DIST2D", fun_dist2d, 4, 4, FN_REG}, 
    244241  {"DIST3D", fun_dist3d, 6, 6, FN_REG}, 
  • 1.7.7/src/funmath.c

    r427 r445  
    5353static double frac(double v, int *RESTRICT n, int *RESTRICT d, double error); 
    5454void init_math_hashtab(void); 
     55 
     56extern int format_long(long n, char *buff, char **bp, int maxlen, int base); 
    5557 
    5658MATH_PROTO(math_add); 
     
    15771579 
    15781580  mush_free((Malloc_t) ptr, "string"); 
     1581} 
     1582 
     1583FUNCTION(fun_baseconv) 
     1584{ 
     1585  long n; 
     1586  int from, to; 
     1587  char *end; 
     1588 
     1589  if (!(is_integer(args[1]) && is_integer(args[2]))) { 
     1590    safe_str(T(e_ints), buff, bp); 
     1591    return; 
     1592  } 
     1593 
     1594  from = parse_integer(args[1]); 
     1595  to = parse_integer(args[2]); 
     1596 
     1597  if (from < 2 || from > 36) { 
     1598    safe_str(T("#-1 FROM BASE OUT OF RANGE"), buff, bp); 
     1599    return; 
     1600  } 
     1601 
     1602  if (to < 2 || to > 36) { 
     1603    safe_str(T("#-1 TO BASE OUT OF RANGE"), buff, bp); 
     1604    return; 
     1605  } 
     1606 
     1607  n = strtol(trim_space_sep(args[0], ' '), &end, from); 
     1608 
     1609  if (*end != '\0') { 
     1610    safe_str(T("#-1 MALFORMED NUMBER"), buff, bp); 
     1611    return; 
     1612  } 
     1613 
     1614  format_long(n, buff, bp, BUFFER_LEN, to); 
    15791615} 
    15801616 
  • 1.7.7/src/game.c

    r439 r445  
    537537fork_and_dump(int forking) 
    538538{ 
    539   int child, nofork, status
     539  int child, nofork, status, split
    540540  epoch++; 
    541541 
     
    549549  else 
    550550    nofork = !forking || (paranoid_dump == 2);  /* Don't fork for dump/debug */ 
    551   if (!nofork && chunk_num_swapped()) { 
    552     /* Ack, can't fork, 'cause we have stuff on disk... */ 
    553     do_log(LT_ERR, 0, 0, 
    554        "fork_and_dump: Data are swapped to disk, so nonforking dumps will be used."); 
    555     flag_broadcast("WIZARD", 0, 
    556            "DUMP: Data are swapped to disk, so nonforking dumps will be used."); 
    557     nofork = 1; 
    558   } 
    559551#ifdef WIN32 
    560552  nofork = 1; 
     
    563555  nofork = 1; 
    564556#endif 
     557  split = 0; 
     558  if (!nofork && chunk_num_swapped()) { 
     559#ifndef WIN32 
     560    /* Try to clone the chunk swapfile. */ 
     561    if (chunk_fork_file()) { 
     562      split = 1; 
     563    } else { 
     564      /* Ack, can't fork, 'cause we have stuff on disk... */ 
     565      do_log(LT_ERR, 0, 0, 
     566         "fork_and_dump: Data are swapped to disk, so nonforking dumps will be used."); 
     567      flag_broadcast("WIZARD", 0, 
     568             "DUMP: Data are swapped to disk, so nonforking dumps will be used."); 
     569      nofork = 1; 
     570    } 
     571#endif 
     572  } 
    565573  if (!nofork) { 
    566574#ifndef macintosh 
     
    575583      child = 0; 
    576584      nofork = 1; 
    577     } else if (child > 0) 
     585      if (split) { 
     586    split = 0; 
     587    chunk_fork_done(); 
     588      } 
     589    } else if (child > 0) { 
    578590      forked_dump_pid = child; 
    579  
     591      chunk_fork_parent(); 
     592    } else { 
     593      chunk_fork_child(); 
    580594#ifdef HAS_SETPRIORITY 
    581     else { 
    582595      /* Lower the priority of the child to make parent more responsive */ 
    583596#ifdef HAS_GETPRIORITY 
     
    586599      setpriority(PRIO_PROCESS, child, 8); 
    587600#endif              /* HAS_GETPRIORITY */ 
    588     } 
    589601#endif              /* HAS_SETPRIORITY */ 
     602    } 
    590603#endif              /* WIN32 */ 
    591604#endif              /* macintosh */ 
     
    599612    release_fd(); 
    600613    status = dump_database_internal(); 
     614#ifndef WIN32 
     615    if (split) 
     616      chunk_fork_done(); 
     617#endif 
    601618    if (!nofork) { 
    602619      _exit(status);        /* !!! */ 
  • 1.7.7/src/mycrypt.c

    r423 r445  
    1414#include "conf.h" 
    1515#if (CRYPT_SYSTEM > 0) 
     16#ifdef HAS_OPENSSL 
     17#include <openssl/sha.h> 
     18#else 
    1619#include "shs.h" 
     20#endif 
    1721#endif 
    1822#include "confmagic.h" 
     
    3034  return (char *) key; 
    3135#else 
     36  static char crypt_buff[70]; 
     37 
     38#ifdef HAS_OPENSSL 
     39  char hash[SHA_DIGEST_LENGTH]; 
     40  unsigned int a, b; 
     41 
     42  SHA(key, strlen(key), hash); 
     43 
     44  memcpy(&a, hash, sizeof a); 
     45  memcpy(&b, hash + sizeof a, sizeof b); 
     46 </