#include "copyright.h"#include "autoconf.h"#include "config.h"#include "externs.h"#include "attrs.h"#include "command.h"#include "interface.h"Include dependency graph for conf.cpp:

Go to the source code of this file.
Data Structures | |
| struct | confparm |
| struct | DECODEIPV4 |
Typedefs | |
| typedef confparm | CONF |
Functions | |
| void | cf_init (void) |
| void | cf_log_notfound (dbref player, char *cmd, const char *thingname, char *thing) |
| void DCL_CDECL | cf_log_syntax (dbref player, char *cmd, const char *fmt,...) |
| static int | cf_status_from_succfail (dbref player, char *cmd, int success, int failure) |
| static | CF_HAND (cf_int_array) |
| static | CF_HAND (cf_int) |
| static | CF_HAND (cf_dbref) |
| static | CF_HAND (cf_seconds) |
| static | CF_HAND (cf_bool) |
| static | CF_HAND (cf_option) |
| static | CF_HAND (cf_string) |
| static | CF_HAND (cf_string_dyn) |
| static | CF_HAND (cf_alias) |
| static | CF_HAND (cf_flagalias) |
| static | CF_HAND (cf_poweralias) |
| CF_HAND (cf_modify_bits) | |
| static | CF_HAND (cf_set_flags) |
| static | CF_HAND (cf_badname) |
| static bool | DecodeN (int nType, size_t len, const char *p, in_addr_t *pu32) |
| static bool | MakeCanonicalIPv4 (const char *str, in_addr_t *pnIP) |
| static bool | isValidSubnetMask (in_addr_t ulMask) |
| static | CF_HAND (cf_site) |
| static int | add_helpfile (dbref player, char *cmd, char *str, bool bRaw) |
| static | CF_HAND (cf_helpfile) |
| static | CF_HAND (cf_raw_helpfile) |
| static | CF_HAND (cf_hook) |
| static | CF_HAND (cf_include) |
| CF_HAND (cf_cf_access) | |
| int | cf_set (char *cp, char *ap, dbref player) |
| void | ValidateConfigurationDbrefs (void) |
| void | do_admin (dbref executor, dbref caller, dbref enactor, int extra, int nargs, char *kw, char *value) |
| int | cf_read (void) |
| void | list_cf_access (dbref player) |
| void | cf_display (dbref player, char *param_name, char *buff, char **bufc) |
| void | cf_list (dbref player, char *buff, char **bufc) |
Variables | |
| CONFDATA | mudconf |
| STATEDATA | mudstate |
| static NAMETAB | bool_names [] |
| static NAMETAB | hook_names [] |
| static CONF | conftable [] |
| struct { | |
| char ** pFilename | |
| char * pSuffix | |
| } | DefaultSuffixes [] |
| static int add_helpfile | ( | dbref | player, | |
| char * | cmd, | |||
| char * | str, | |||
| bool | bRaw | |||
| ) | [static] |
Definition at line 1435 of file conf.cpp.
References statedata::aHelpDesc, HELP_DESC::bEval, CA_PUBLIC, CMDENT_ONE_ARG::callseq, cf_log_syntax(), CMDENT_ONE_ARG::cmdname, statedata::command_htab, HELP_DESC::CommandName, CS_ONE_ARG, do_help(), CMDENT_ONE_ARG::extra, CMDENT_ONE_ARG::handler, hashaddLEN(), hashdeleteLEN(), CMDENT_ONE_ARG::hookmask, HELP_DESC::ht, ISOUTOFMEMORY, MEMALLOC, MEMFREE, statedata::mHelpDesc, mudstate, mux_strtok_ctl(), mux_strtok_parse(), mux_strtok_src(), statedata::nHelpDesc, HELP_DESC::pBaseFilename, CMDENT_ONE_ARG::perms, SBUF_SIZE, StringClone(), CMDENT_ONE_ARG::switches, and tprintf().
Referenced by CF_HAND().
01436 { 01437 // Parse the two arguments. 01438 // 01439 MUX_STRTOK_STATE tts; 01440 mux_strtok_src(&tts, str); 01441 mux_strtok_ctl(&tts, " \t\n\r"); 01442 01443 char *pCmdName = mux_strtok_parse(&tts); 01444 char *pBase = mux_strtok_parse(&tts); 01445 if (pBase == NULL) 01446 { 01447 cf_log_syntax(player, cmd, "Missing path for helpfile %s", pCmdName); 01448 return -1; 01449 } 01450 if ( pCmdName[0] == '_' 01451 && pCmdName[1] == '_') 01452 { 01453 cf_log_syntax(player, cmd, 01454 "Helpfile %s would conflict with the use of @addcommand.", 01455 pCmdName); 01456 return -1; 01457 } 01458 if (SBUF_SIZE <= strlen(pBase)) 01459 { 01460 cf_log_syntax(player, cmd, "Helpfile '%s' filename too long", pBase); 01461 return -1; 01462 } 01463 01464 // Allocate an empty place in the table of help file hashes. 01465 // 01466 if (mudstate.aHelpDesc == NULL) 01467 { 01468 mudstate.mHelpDesc = 4; 01469 mudstate.nHelpDesc = 0; 01470 mudstate.aHelpDesc = (HELP_DESC *)MEMALLOC(sizeof(HELP_DESC) 01471 *mudstate.mHelpDesc); 01472 ISOUTOFMEMORY(mudstate.aHelpDesc); 01473 } 01474 else if (mudstate.mHelpDesc <= mudstate.nHelpDesc) 01475 { 01476 int newsize = mudstate.mHelpDesc + 4; 01477 HELP_DESC *q = (HELP_DESC *)MEMALLOC(sizeof(HELP_DESC)*newsize); 01478 ISOUTOFMEMORY(q); 01479 memset(q, 0, sizeof(HELP_DESC)*newsize); 01480 memcpy(q, mudstate.aHelpDesc, sizeof(HELP_DESC)*mudstate.mHelpDesc); 01481 MEMFREE(mudstate.aHelpDesc); 01482 mudstate.aHelpDesc = q; 01483 mudstate.mHelpDesc = newsize; 01484 } 01485 01486 // Build HELP_DESC 01487 // 01488 HELP_DESC *pDesc = mudstate.aHelpDesc + mudstate.nHelpDesc; 01489 pDesc->CommandName = StringClone(pCmdName); 01490 pDesc->ht = NULL; 01491 pDesc->pBaseFilename = StringClone(pBase); 01492 pDesc->bEval = !bRaw; 01493 01494 // Build up Command Entry. 01495 // 01496 CMDENT_ONE_ARG *cmdp = (CMDENT_ONE_ARG *)MEMALLOC(sizeof(CMDENT_ONE_ARG)); 01497 ISOUTOFMEMORY(cmdp); 01498 01499 cmdp->callseq = CS_ONE_ARG; 01500 cmdp->cmdname = StringClone(pCmdName); 01501 cmdp->extra = mudstate.nHelpDesc; 01502 cmdp->handler = do_help; 01503 cmdp->hookmask = 0; 01504 cmdp->perms = CA_PUBLIC; 01505 cmdp->switches = NULL; 01506 01507 // TODO: If a command is deleted with one or both of the two 01508 // hashdeleteLEN() calls below, what guarantee do we have that parts of 01509 // the command weren't dynamically allocated. This might leak memory. 01510 // 01511 char *p = cmdp->cmdname; 01512 hashdeleteLEN(p, strlen(p), &mudstate.command_htab); 01513 hashaddLEN(p, strlen(p), cmdp, &mudstate.command_htab); 01514 01515 p = tprintf("__%s", cmdp->cmdname); 01516 hashdeleteLEN(p, strlen(p), &mudstate.command_htab); 01517 hashaddLEN(p, strlen(p), cmdp, &mudstate.command_htab); 01518 01519 mudstate.nHelpDesc++; 01520 01521 return 0; 01522 }
| void cf_display | ( | dbref | player, | |
| char * | param_name, | |||
| char * | buff, | |||
| char ** | bufc | |||
| ) |
Definition at line 2174 of file conf.cpp.
References check_access(), conftable, confparm::interpreter, confparm::loc, mux_stricmp(), confparm::pname, confparm::rperms, safe_chr, and safe_ltoa().
Referenced by FUNCTION().
02175 { 02176 CONF *tp; 02177 02178 for (tp = conftable; tp->pname; tp++) 02179 { 02180 if (!mux_stricmp(tp->pname, param_name)) 02181 { 02182 if (check_access(player, tp->rperms)) 02183 { 02184 if (tp->interpreter == cf_int) 02185 { 02186 safe_ltoa(*(tp->loc), buff, bufc); 02187 return; 02188 } 02189 else if (tp->interpreter == cf_dbref) 02190 { 02191 safe_chr('#', buff, bufc); 02192 safe_ltoa(*(tp->loc), buff, bufc); 02193 return; 02194 } 02195 else if (tp->interpreter == cf_bool) 02196 { 02197 bool *pb = (bool *)tp->loc; 02198 safe_bool(*pb, buff, bufc); 02199 return; 02200 } 02201 else if (tp->interpreter == cf_string) 02202 { 02203 safe_str((char *)tp->loc, buff, bufc); 02204 return; 02205 } 02206 else if (tp->interpreter == cf_string_dyn) 02207 { 02208 safe_str(*(char **)tp->loc, buff, bufc); 02209 return; 02210 } 02211 else if (tp->interpreter == cf_int_array) 02212 { 02213 IntArray *pia = (IntArray *)(tp->loc); 02214 ITL itl; 02215 ItemToList_Init(&itl, buff, bufc); 02216 for (int i = 0; i < pia->n; i++) 02217 { 02218 if (!ItemToList_AddInteger(&itl, pia->pi[i])) 02219 { 02220 break; 02221 } 02222 } 02223 ItemToList_Final(&itl); 02224 return; 02225 } 02226 else if (tp->interpreter == cf_seconds) 02227 { 02228 CLinearTimeDelta *pltd = (CLinearTimeDelta *)(tp->loc); 02229 safe_str(pltd->ReturnSecondsString(7), buff, bufc); 02230 return; 02231 } 02232 } 02233 safe_noperm(buff, bufc); 02234 return; 02235 } 02236 } 02237 safe_nomatch(buff, bufc); 02238 }
| CF_HAND | ( | cf_cf_access | ) |
Definition at line 1940 of file conf.cpp.
01941 { 01942 UNUSED_PARAMETER(vp); 01943 01944 CONF *tp; 01945 char *ap; 01946 01947 for (ap = str; *ap && !mux_isspace(*ap); ap++) 01948 { 01949 ; // Nothing 01950 } 01951 if (*ap) 01952 { 01953 *ap++ = '\0'; 01954 } 01955 01956 for (tp = conftable; tp->pname; tp++) 01957 { 01958 if (!strcmp(tp->pname, str)) 01959 { 01960 // Cannot modify parameters set CA_STATIC. 01961 // 01962 if ( tp->flags & CA_STATIC 01963 && !mudstate.bReadingConfiguration) 01964 { 01965 notify(player, NOPERM_MESSAGE); 01966 STARTLOG(LOG_CONFIGMODS, "CFG", "PERM"); 01967 log_name(player); 01968 log_text(" tried to change access to static param: "); 01969 log_text(tp->pname); 01970 ENDLOG; 01971 return -1; 01972 } 01973 return cf_modify_bits(&tp->flags, ap, pExtra, nExtra, player, cmd); 01974 } 01975 } 01976 cf_log_notfound(player, cmd, "Config directive", str); 01977 return -1; 01978 }
| static CF_HAND | ( | cf_include | ) | [static] |
Definition at line 1620 of file conf.cpp.
References alloc_lbuf, statedata::bReadingConfiguration, cf_log_notfound(), cf_set(), DebugTotalFiles, free_lbuf, LBUF_SIZE, mudstate, mux_isdigit, mux_isspace, and UNUSED_PARAMETER.
01621 { 01622 UNUSED_PARAMETER(vp); 01623 UNUSED_PARAMETER(pExtra); 01624 UNUSED_PARAMETER(nExtra); 01625 01626 if (!mudstate.bReadingConfiguration) 01627 { 01628 return -1; 01629 } 01630 01631 FILE *fp = fopen(str, "rb"); 01632 if (fp == NULL) 01633 { 01634 cf_log_notfound(player, cmd, "Config file", str); 01635 return -1; 01636 } 01637 DebugTotalFiles++; 01638 01639 char *buf = alloc_lbuf("cf_include"); 01640 fgets(buf, LBUF_SIZE, fp); 01641 while (!feof(fp)) 01642 { 01643 char *zp = buf; 01644 01645 // Remove comments. Anything after the '#' is a comment except if it 01646 // matches: whitespace + '#' + digit. 01647 // 01648 while (*zp != '\0') 01649 { 01650 if ( *zp == '#' 01651 && ( zp <= buf 01652 || !mux_isspace(zp[-1]) 01653 || !mux_isdigit(zp[1]))) 01654 { 01655 // Found a comment. 01656 // 01657 *zp = '\0'; 01658 } 01659 else 01660 { 01661 zp++; 01662 } 01663 } 01664 01665 // Trim trailing spaces. 01666 // 01667 while ( buf < zp 01668 && mux_isspace(zp[-1])) 01669 { 01670 *(--zp) = '\0'; 01671 } 01672 01673 // Process line. 01674 // 01675 char *cp = buf; 01676 01677 // Trim leading spaces. 01678 // 01679 while (mux_isspace(*cp)) 01680 { 01681 cp++; 01682 } 01683 01684 // Skip over command. 01685 // 01686 char *ap; 01687 for (ap = cp; *ap && !mux_isspace(*ap); ap++) 01688 { 01689 ; // Nothing. 01690 } 01691 01692 // Terminate command. 01693 // 01694 if (*ap) 01695 { 01696 *ap++ = '\0'; 01697 } 01698 01699 // Skip spaces between command and argument. 01700 // 01701 while (mux_isspace(*ap)) 01702 { 01703 ap++; 01704 } 01705 01706 if (*cp) 01707 { 01708 cf_set(cp, ap, player); 01709 } 01710 fgets(buf, LBUF_SIZE, fp); 01711 } 01712 free_lbuf(buf); 01713 if (fclose(fp) == 0) 01714 { 01715 DebugTotalFiles--; 01716 } 01717 return 0; 01718 }
| static CF_HAND | ( | cf_hook | ) | [static] |
Definition at line 1558 of file conf.cpp.
References statedata::command_htab, GOD, hashfindLEN(), hook_names, CMDENT::hookmask, mudstate, mux_strtok_ctl(), mux_strtok_parse(), mux_strtok_src(), search_nametab(), and UNUSED_PARAMETER.
01559 { 01560 UNUSED_PARAMETER(pExtra); 01561 UNUSED_PARAMETER(nExtra); 01562 UNUSED_PARAMETER(player); 01563 UNUSED_PARAMETER(cmd); 01564 01565 char *hookcmd, *hookptr, playbuff[201]; 01566 int hookflg; 01567 CMDENT *cmdp; 01568 01569 int retval = -1; 01570 memset(playbuff, '\0', sizeof(playbuff)); 01571 strncpy(playbuff, str, 200); 01572 MUX_STRTOK_STATE tts; 01573 mux_strtok_src(&tts, playbuff); 01574 mux_strtok_ctl(&tts, " \t"); 01575 hookcmd = mux_strtok_parse(&tts); 01576 if (hookcmd != NULL) 01577 { 01578 cmdp = (CMDENT *)hashfindLEN(hookcmd, strlen(hookcmd), &mudstate.command_htab); 01579 } 01580 else 01581 { 01582 return retval; 01583 } 01584 if (!cmdp) 01585 { 01586 return retval; 01587 } 01588 01589 *vp = cmdp->hookmask; 01590 strncpy(playbuff, str, 200); 01591 hookptr = mux_strtok_parse(&tts); 01592 while (hookptr != NULL) 01593 { 01594 if ( hookptr[0] == '!' 01595 && hookptr[1] != '\0') 01596 { 01597 if (search_nametab(GOD, hook_names, hookptr+1, &hookflg)) 01598 { 01599 retval = 0; 01600 *vp = *vp & ~hookflg; 01601 } 01602 } 01603 else 01604 { 01605 if (search_nametab(GOD, hook_names, hookptr, &hookflg)) 01606 { 01607 retval = 0; 01608 *vp = *vp | hookflg; 01609 } 01610 } 01611 hookptr = mux_strtok_parse(&tts); 01612 } 01613 cmdp->hookmask = *vp; 01614 return retval; 01615 }
| static CF_HAND | ( | cf_raw_helpfile | ) | [static] |
Definition at line 1533 of file conf.cpp.
References add_helpfile(), and UNUSED_PARAMETER.
01534 { 01535 UNUSED_PARAMETER(vp); 01536 UNUSED_PARAMETER(pExtra); 01537 UNUSED_PARAMETER(nExtra); 01538 01539 return add_helpfile(player, cmd, str, true); 01540 }
| static CF_HAND | ( | cf_helpfile | ) | [static] |
Definition at line 1524 of file conf.cpp.
References add_helpfile(), and UNUSED_PARAMETER.
01525 { 01526 UNUSED_PARAMETER(vp); 01527 UNUSED_PARAMETER(pExtra); 01528 UNUSED_PARAMETER(nExtra); 01529 01530 return add_helpfile(player, cmd, str, false); 01531 }
| static CF_HAND | ( | cf_site | ) | [static] |
Definition at line 1302 of file conf.cpp.
References site_data::address, statedata::bReadingConfiguration, cf_log_syntax(), site_data::flag, is_integer(), ISOUTOFMEMORY, isValidSubnetMask(), MakeCanonicalIPv4(), site_data::mask, MEMALLOC, mudstate, mux_atol(), mux_strtok_ctl(), mux_strtok_parse(), mux_strtok_src(), site_data::next, and UNUSED_PARAMETER.
01303 { 01304 UNUSED_PARAMETER(pExtra); 01305 01306 SITE **ppv = (SITE **)vp; 01307 struct in_addr addr_num, mask_num; 01308 in_addr_t ulMask, ulNetBits; 01309 01310 char *addr_txt; 01311 char *mask_txt = strchr(str, '/'); 01312 if (!mask_txt) 01313 { 01314 // Standard IP range and netmask notation. 01315 // 01316 MUX_STRTOK_STATE tts; 01317 mux_strtok_src(&tts, str); 01318 mux_strtok_ctl(&tts, " \t=,"); 01319 addr_txt = mux_strtok_parse(&tts); 01320 mask_txt = NULL; 01321 if (addr_txt) 01322 { 01323 mask_txt = mux_strtok_parse(&tts); 01324 } 01325 if (!addr_txt || !*addr_txt || !mask_txt || !*mask_txt) 01326 { 01327 cf_log_syntax(player, cmd, "Missing host address or mask.", ""); 01328 return -1; 01329 } 01330 if ( !MakeCanonicalIPv4(mask_txt, &ulNetBits) 01331 || !isValidSubnetMask(ulMask = ntohl(ulNetBits))) 01332 { 01333 cf_log_syntax(player, cmd, "Malformed mask address: %s", mask_txt); 01334 return -1; 01335 } 01336 mask_num.s_addr = ulNetBits; 01337 } 01338 else 01339 { 01340 // RFC 1517, 1518, 1519, 1520: CIDR IP prefix notation 01341 // 01342 addr_txt = str; 01343 *mask_txt++ = '\0'; 01344 if (!is_integer(mask_txt, NULL)) 01345 { 01346 cf_log_syntax(player, cmd, "Mask field (%s) in CIDR IP prefix is not numeric.", mask_txt); 01347 return -1; 01348 } 01349 int mask_bits = mux_atol(mask_txt); 01350 if ( mask_bits < 0 01351 || 32 < mask_bits) 01352 { 01353 cf_log_syntax(player, cmd, "Mask bits (%d) in CIDR IP prefix out of range.", mask_bits); 01354 return -1; 01355 } 01356 else 01357 { 01358 // << [0,31] works. << 32 is problematic on some systems. 01359 // 01360 ulMask = 0; 01361 if (mask_bits > 0) 01362 { 01363 ulMask = (0xFFFFFFFFUL << (32 - mask_bits)) & 0xFFFFFFFFUL; 01364 } 01365 mask_num.s_addr = htonl(ulMask); 01366 } 01367 } 01368 if (!MakeCanonicalIPv4(addr_txt, &ulNetBits)) 01369 { 01370 cf_log_syntax(player, cmd, "Malformed host address: %s", addr_txt); 01371 return -1; 01372 } 01373 addr_num.s_addr = ulNetBits; 01374 in_addr_t ulAddr = ntohl(addr_num.s_addr); 01375 01376 if (ulAddr & ~ulMask) 01377 { 01378 // The given subnet address contains 'one' bits which are outside 01379 // the given subnet mask. If we don't clear these bits, they will 01380 // interfere with the subnet tests in site_check. The subnet spec 01381 // would be defunct and useless. 01382 // 01383 cf_log_syntax(player, cmd, "Non-zero host address bits outside the subnet mask (fixed): %s %s", addr_txt, mask_txt); 01384 ulAddr &= ulMask; 01385 addr_num.s_addr = htonl(ulAddr); 01386 } 01387 01388 SITE *head = *ppv; 01389 01390 // Parse the access entry and allocate space for it. 01391 // 01392 SITE *site = (SITE *)MEMALLOC(sizeof(SITE)); 01393 ISOUTOFMEMORY(site); 01394 01395 // Initialize the site entry. 01396 // 01397 site->address.s_addr = addr_num.s_addr; 01398 site->mask.s_addr = mask_num.s_addr; 01399 site->flag = nExtra; 01400 site->next = NULL; 01401 01402 // Link in the entry. Link it at the start if not initializing, at the 01403 // end if initializing. This is so that entries in the config file are 01404 // processed as you would think they would be, while entries made while 01405 // running are processed first. 01406 // 01407 if (mudstate.bReadingConfiguration) 01408 { 01409 if (head == NULL) 01410 { 01411 *ppv = site; 01412 } 01413 else 01414 { 01415 SITE *last; 01416 for (last = head; last->next; last = last->next) 01417 { 01418 // Nothing 01419 } 01420 last->next = site; 01421 } 01422 } 01423 else 01424 { 01425 site->next = head; 01426 *ppv = site; 01427 } 01428 return 0; 01429 }
| static CF_HAND | ( | cf_badname | ) | [static] |
Definition at line 1033 of file conf.cpp.
References badname_add(), badname_remove(), and UNUSED_PARAMETER.
01034 { 01035 UNUSED_PARAMETER(vp); 01036 UNUSED_PARAMETER(pExtra); 01037 UNUSED_PARAMETER(player); 01038 UNUSED_PARAMETER(cmd); 01039 01040 if (nExtra) 01041 { 01042 badname_remove(str); 01043 } 01044 else 01045 { 01046 badname_add(str); 01047 } 01048 return 0; 01049 }
| static CF_HAND | ( | cf_set_flags | ) | [static] |
Definition at line 955 of file conf.cpp.
References flag_name_entry::bPositive, cf_log_notfound(), flag_name_entry::fbe, FLAG_WORD1, FLAG_WORD3, flag_bit_entry::flagflag, statedata::flags_htab, flag_bit_entry::flagvalue, hashfindLEN(), MakeCanonicalFlagName(), mudstate, mux_strtok_ctl(), mux_strtok_parse(), mux_strtok_src(), and UNUSED_PARAMETER.
00956 { 00957 UNUSED_PARAMETER(pExtra); 00958 UNUSED_PARAMETER(nExtra); 00959 00960 int success, failure; 00961 00962 // Walk through the tokens. 00963 // 00964 success = failure = 0; 00965 MUX_STRTOK_STATE tts; 00966 mux_strtok_src(&tts, str); 00967 mux_strtok_ctl(&tts, " \t"); 00968 char *sp = mux_strtok_parse(&tts); 00969 FLAGSET *fset = (FLAGSET *) vp; 00970 00971 while (sp != NULL) 00972 { 00973 // Canonical Flag Name. 00974 // 00975 int nName; 00976 bool bValid; 00977 char *pName = MakeCanonicalFlagName(sp, &nName, &bValid); 00978 FLAGNAMEENT *fp = NULL; 00979 if (bValid) 00980 { 00981 fp = (FLAGNAMEENT *)hashfindLEN(pName, nName, &mudstate.flags_htab); 00982 } 00983 if (fp != NULL) 00984 { 00985 // Set the appropriate bit. 00986 // 00987 if (success == 0) 00988 { 00989 for (int i = FLAG_WORD1; i <= FLAG_WORD3; i++) 00990 { 00991 (*fset).word[i] = 0; 00992 } 00993 } 00994 FLAGBITENT *fbe = fp->fbe; 00995 if (fp->bPositive) 00996 { 00997 (*fset).word[fbe->flagflag] |= fbe->flagvalue; 00998 } 00999 else 01000 { 01001 (*fset).word[fbe->flagflag] &= ~(fbe->flagvalue); 01002 } 01003 success++; 01004 } 01005 else 01006 { 01007 cf_log_notfound(player, cmd, "Entry", sp); 01008 failure++; 01009 } 01010 01011 // Get the next token 01012 // 01013 sp = mux_strtok_parse(&tts); 01014 } 01015 if ((success == 0) && (failure == 0)) 01016 { 01017 for (int i = FLAG_WORD1; i <= FLAG_WORD3; i++) 01018 { 01019 (*fset).word[i] = 0; 01020 } 01021 return 0; 01022 } 01023 if (success > 0) 01024 { 01025 return ((failure == 0) ? 0 : 1); 01026 } 01027 return -1; 01028 }
| CF_HAND | ( | cf_modify_bits | ) |
Definition at line 862 of file conf.cpp.
References cf_log_notfound(), cf_status_from_succfail(), GOD, mux_strtok_ctl(), mux_strtok_parse(), mux_strtok_src(), search_nametab(), and UNUSED_PARAMETER.
00863 { 00864 UNUSED_PARAMETER(nExtra); 00865 00866 int f, success, failure; 00867 bool negate; 00868 00869 // Walk through the tokens. 00870 // 00871 success = failure = 0; 00872 MUX_STRTOK_STATE tts; 00873 mux_strtok_src(&tts, str); 00874 mux_strtok_ctl(&tts, " \t"); 00875 char *sp = mux_strtok_parse(&tts); 00876 while (sp != NULL) 00877 { 00878 // Check for negation. 00879 // 00880 negate = false; 00881 if (*sp == '!') 00882 { 00883 negate = true; 00884 sp++; 00885 } 00886 00887 // Set or clear the appropriate bit. 00888 // 00889 if (search_nametab(GOD, (NAMETAB *)pExtra, sp, &f)) 00890 { 00891 if (negate) 00892 *vp &= ~f; 00893 else 00894 *vp |= f; 00895 success++; 00896 } 00897 else 00898 { 00899 cf_log_notfound(player, cmd, "Entry", sp); 00900 failure++; 00901 } 00902 00903 // Get the next token. 00904 // 00905 sp = mux_strtok_parse(&tts); 00906 } 00907 return cf_status_from_succfail(player, cmd, success, failure); 00908 }
| static CF_HAND | ( | cf_poweralias | ) | [static] |
Definition at line 782 of file conf.cpp.
References cf_log_notfound(), hashaddLEN(), hashfindLEN(), MakeCanonicalFlagName(), mudstate, mux_strtok_ctl(), mux_strtok_parse(), mux_strtok_src(), statedata::powers_htab, and UNUSED_PARAMETER.
00783 { 00784 UNUSED_PARAMETER(vp); 00785 UNUSED_PARAMETER(pExtra); 00786 UNUSED_PARAMETER(nExtra); 00787 00788 MUX_STRTOK_STATE tts; 00789 mux_strtok_src(&tts, str); 00790 mux_strtok_ctl(&tts, " \t=,"); 00791 char *alias = mux_strtok_parse(&tts); 00792 char *orig = mux_strtok_parse(&tts); 00793 00794 bool success = false; 00795 int nName; 00796 bool bValid; 00797 void *cp; 00798 char *pName = MakeCanonicalFlagName(orig, &nName, &bValid); 00799 if (bValid) 00800 { 00801 cp = hashfindLEN(pName, nName, &mudstate.powers_htab); 00802 if (cp) 00803 { 00804 pName = MakeCanonicalFlagName(alias, &nName, &bValid); 00805 if (bValid) 00806 { 00807 hashaddLEN(pName, nName, cp, &mudstate.powers_htab); 00808 success = true; 00809 } 00810 } 00811 } 00812 if (!success) 00813 { 00814 cf_log_notfound(player, cmd, "Power", orig); 00815 } 00816 return (success ? 0 : -1); 00817 }
| static CF_HAND | ( | cf_flagalias | ) | [static] |
Definition at line 739 of file conf.cpp.
References cf_log_notfound(), statedata::flags_htab, hashaddLEN(), hashfindLEN(), MakeCanonicalFlagName(), mudstate, mux_strtok_ctl(), mux_strtok_parse(), mux_strtok_src(), and UNUSED_PARAMETER.
00740 { 00741 UNUSED_PARAMETER(vp); 00742 UNUSED_PARAMETER(pExtra); 00743 UNUSED_PARAMETER(nExtra); 00744 00745 MUX_STRTOK_STATE tts; 00746 mux_strtok_src(&tts, str); 00747 mux_strtok_ctl(&tts, " \t=,"); 00748 char *alias = mux_strtok_parse(&tts); 00749 char *orig = mux_strtok_parse(&tts); 00750 00751 bool success = false; 00752 int nName; 00753 bool bValid; 00754 void *cp; 00755 char *pName = MakeCanonicalFlagName(orig, &nName, &bValid); 00756 if (bValid) 00757 { 00758 cp = hashfindLEN(pName, nName, &mudstate.flags_htab); 00759 if (cp) 00760 { 00761 pName = MakeCanonicalFlagName(alias, &nName, &bValid); 00762 if (bValid) 00763 { 00764 if (!hashfindLEN(pName, nName, &mudstate.flags_htab)) 00765 { 00766 hashaddLEN(pName, nName, cp, &mudstate.flags_htab); 00767 success = true; 00768 } 00769 } 00770 } 00771 } 00772 if (!success) 00773 { 00774 cf_log_notfound(player, cmd, "Flag", orig); 00775 } 00776 return (success ? 0 : -1); 00777 }
| static CF_HAND | ( | cf_alias | ) | [static] |
Definition at line 702 of file conf.cpp.
References cf_log_notfound(), hashaddLEN(), hashfindLEN(), mux_strlwr(), mux_strtok_ctl(), mux_strtok_parse(), mux_strtok_src(), mux_strupr(), and UNUSED_PARAMETER.
00703 { 00704 UNUSED_PARAMETER(pExtra); 00705 UNUSED_PARAMETER(nExtra); 00706 00707 MUX_STRTOK_STATE tts; 00708 mux_strtok_src(&tts, str); 00709 mux_strtok_ctl(&tts, " \t=,"); 00710 char *alias = mux_strtok_parse(&tts); 00711 char *orig = mux_strtok_parse(&tts); 00712 00713 if (orig) 00714 { 00715 mux_strlwr(orig); 00716 void *cp = hashfindLEN(orig, strlen(orig), (CHashTable *) vp); 00717 if (cp == NULL) 00718 { 00719 mux_strupr(orig); 00720 cp = hashfindLEN(orig, strlen(orig), (CHashTable *) vp); 00721 if (cp == NULL) 00722 { 00723 cf_log_notfound(player, cmd, "Entry", orig); 00724 return -1; 00725 } 00726 } 00727 if (!hashfindLEN(alias, strlen(alias), (CHashTable *) vp)) 00728 { 00729 hashaddLEN(alias, strlen(alias), cp, (CHashTable *) vp); 00730 } 00731 return 0; 00732 } 00733 return -1; 00734 }
| static CF_HAND | ( | cf_string_dyn | ) | [static] |
Definition at line 660 of file conf.cpp.
References statedata::bReadingConfiguration, ENDLOG, Log, LOG_STARTUP, MEMFREE, mudstate, notify, STARTLOG, StringCloneLen(), CLogFile::tinyprintf(), and UNUSED_PARAMETER.
00661 { 00662 UNUSED_PARAMETER(pExtra); 00663 00664 char **ppc = (char **)vp; 00665 00666 // Allocate memory for buffer and copy string to it. If nExtra is non-zero, 00667 // then there is a size limitation as well. 00668 // 00669 int retval = 0; 00670 unsigned int nStr = strlen(str); 00671 if (nExtra && nStr >= nExtra) 00672 { 00673 nStr = nExtra - 1; 00674 if (mudstate.bReadingConfiguration) 00675 { 00676 STARTLOG(LOG_STARTUP, "CNF", "NFND"); 00677 Log.tinyprintf("%s: String truncated", cmd); 00678 ENDLOG; 00679 } 00680 else 00681 { 00682 notify(player, "String truncated"); 00683 } 00684 retval = 1; 00685 } 00686 char *confbuff = StringCloneLen(str, nStr); 00687 00688 // Free previous memory for buffer. 00689 // 00690 if (*ppc != NULL) 00691 { 00692 MEMFREE(*ppc); 00693 } 00694 *ppc = confbuff; 00695 00696 return retval; 00697 }
| static CF_HAND | ( | cf_string | ) | [static] |
Definition at line 595 of file conf.cpp.
References alloc_sbuf, statedata::bReadingConfiguration, ENDLOG, free_sbuf, Log, LOG_STARTUP, confdata::mud_name, mudconf, mudstate, mux_isalnum, notify, SBUF_SIZE, CLogFile::SetPrefix(), STARTLOG, strip_ansi(), CLogFile::tinyprintf(), and UNUSED_PARAMETER.
00596 { 00597 UNUSED_PARAMETER(pExtra); 00598 00599 char *pc = (char *)vp; 00600 00601 // The following should never happen because extra is always a non-zero 00602 // constant in the config table. 00603 // 00604 if (nExtra <= 0) 00605 { 00606 return 1; 00607 } 00608 00609 // Copy the string to the buffer if it is not too big. 00610 // 00611 int retval = 0; 00612 unsigned int nStr = strlen(str); 00613 if (nStr >= nExtra) 00614 { 00615 nStr = nExtra - 1; 00616 if (mudstate.bReadingConfiguration) 00617 { 00618 STARTLOG(LOG_STARTUP, "CNF", "NFND"); 00619 Log.tinyprintf("%s: String truncated", cmd); 00620 ENDLOG; 00621 } 00622 else 00623 { 00624 notify(player, "String truncated"); 00625 } 00626 retval = 1; 00627 } 00628 memcpy(pc, str, nStr+1); 00629 pc[nStr] = '\0'; 00630 00631 if (pc == mudconf.mud_name) 00632 { 00633 // We are changing the name of the MUD. Form a prefix from the 00634 // mudname and let the logger know. 00635 // 00636 char *buff = alloc_sbuf("cf_string.prefix"); 00637 char *p = buff; 00638 char *q = strip_ansi(mudconf.mud_name); 00639 size_t nLen = 0; 00640 while ( *q 00641 && nLen < SBUF_SIZE) 00642 { 00643 if (mux_isalnum(*q)) 00644 { 00645 *p++ = *q; 00646 nLen++; 00647 } 00648 q++; 00649 } 00650 *p = '\0'; 00651 Log.SetPrefix(buff); 00652 free_sbuf(buff); 00653 } 00654 return retval; 00655 }
| static CF_HAND | ( | cf_option | ) | [static] |
Definition at line 578 of file conf.cpp.
References cf_log_notfound(), GOD, search_nametab(), and UNUSED_PARAMETER.
00579 { 00580 UNUSED_PARAMETER(nExtra); 00581 00582 int i; 00583 if (!search_nametab(GOD, (NAMETAB *)pExtra, str, &i)) 00584 { 00585 cf_log_notfound(player, cmd, "Value", str); 00586 return -1; 00587 } 00588 *vp = i; 00589 return 0; 00590 }
| static CF_HAND | ( | cf_bool | ) | [static] |
Definition at line 559 of file conf.cpp.
References bool_names, cf_log_notfound(), GOD, isTRUE, search_nametab(), and UNUSED_PARAMETER.
00560 { 00561 UNUSED_PARAMETER(pExtra); 00562 UNUSED_PARAMETER(nExtra); 00563 00564 int i; 00565 if (!search_nametab(GOD, bool_names, str, &i)) 00566 { 00567 cf_log_notfound(player, cmd, "Value", str); 00568 return -1; 00569 } 00570 bool *pb = (bool *)vp; 00571 *pb = isTRUE(i); 00572 return 0; 00573 }