Changeset 1302
- Timestamp:
- 10/01/08 01:21:51 (2 months ago)
- Files:
-
- 1.8.3/branches/devel/CHANGES.183 (modified) (1 diff)
- 1.8.3/branches/devel/config.h.in (modified) (1 diff)
- 1.8.3/branches/devel/configure (modified) (4 diffs)
- 1.8.3/branches/devel/configure.in (modified) (2 diffs)
- 1.8.3/branches/devel/game/txt/hlp/penncmd.hlp (modified) (2 diffs)
- 1.8.3/branches/devel/hdrs/switches.h (modified) (1 diff)
- 1.8.3/branches/devel/src/SWITCHES (modified) (1 diff)
- 1.8.3/branches/devel/src/cmds.c (modified) (2 diffs)
- 1.8.3/branches/devel/src/command.c (modified) (1 diff)
- 1.8.3/branches/devel/src/conf.c (modified) (22 diffs)
- 1.8.3/branches/devel/src/switchinc.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/devel/CHANGES.183
r1301 r1302 17 17 18 18 Version 1.8.3 patchlevel 8 ??? ??, 200? 19 20 Minor changes: 21 * @config/save foo=bar acts like @config/set but also attempts to 22 alter the original configuration file to reflect the new value. 19 23 20 24 Version 1.8.3 patchlevel 7 Oct 01, 2008 21 25 22 Minor changes:23 26 Minor changes: 24 27 * If compiling with a recent enough version of gcc to support the 1.8.3/branches/devel/config.h.in
r1272 r1302 351 351 #undef SENDMAIL 352 352 353 #undef HAVE_ED 354 #undef ED_PATH 355 353 356 #undef HAVE_SAFE_TOUPPER 354 357 1.8.3/branches/devel/configure
r1285 r1302 658 658 GREP 659 659 CPP 660 ED 660 661 SENDMAIL 661 662 UPTIME … … 749 750 PERL 750 751 SENDMAIL 752 ED 751 753 CPP 752 754 CXX … … 1405 1407 PERL Absolute path to perl executable 1406 1408 SENDMAIL Path to sendmail 1409 ED Path to ed 1407 1410 CPP C preprocessor 1408 1411 CXX C++ compiler command … … 4071 4074 fi 4072 4075 4076 4077 # Extract the first word of "ed", so it can be a program name with args. 4078 set dummy ed; ac_word=$2 4079 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 4080 $as_echo_n "checking for $ac_word... " >&6; } 4081 if test "${ac_cv_path_ED+set}" = set; then 4082 $as_echo_n "(cached) " >&6 4083 else 4084 case $ED in 4085 [\\/]* | ?:[\\/]*) 4086 ac_cv_path_ED="$ED" # Let the user override the test with a path. 4087 ;; 4088 *) 4089 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 4090 for as_dir in $PATH 4091 do 4092 IFS=$as_save_IFS 4093 test -z "$as_dir" && as_dir=. 4094 for ac_exec_ext in '' $ac_executable_extensions; do 4095 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then 4096 ac_cv_path_ED="$as_dir/$ac_word$ac_exec_ext" 4097 $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 4098 break 2 4099 fi 4100 done 4101 done 4102 IFS=$as_save_IFS 4103 4104 ;; 4105 esac 4106 fi 4107 ED=$ac_cv_path_ED 4108 if test -n "$ED"; then 4109 { $as_echo "$as_me:$LINENO: result: $ED" >&5 4110 $as_echo "$ED" >&6; } 4111 else 4112 { $as_echo "$as_me:$LINENO: result: no" >&5 4113 $as_echo "no" >&6; } 4114 fi 4115 4116 4117 if test "${ED+set}" = "set"; then 4118 cat >>confdefs.h <<\_ACEOF 4119 #define HAVE_ED 1 4120 _ACEOF 4121 4122 cat >>confdefs.h <<_ACEOF 4123 #define ED_PATH "$ED -s" 4124 _ACEOF 4125 4126 fi 4073 4127 4074 4128 ### Headers 1.8.3/branches/devel/configure.in
r1285 r1302 86 86 fi 87 87 88 AC_ARG_VAR(SENDMAIL, Path to sendmail)88 AC_ARG_VAR(SENDMAIL, [Path to sendmail]) 89 89 AC_PATH_PROG(SENDMAIL, sendmail) 90 90 if test "${SENDMAIL+set}" = "set"; then … … 93 93 fi 94 94 95 AC_ARG_VAR(ED, [Path to ed]) 96 AC_PATH_PROG(ED, ed) 97 if test "${ED+set}" = "set"; then 98 AC_DEFINE([HAVE_ED]) 99 AC_DEFINE_UNQUOTED([ED_PATH], "$ED -s") 100 fi 95 101 96 102 ### Headers 1.8.3/branches/devel/game/txt/hlp/penncmd.hlp
r1298 r1302 672 672 @config/flags 673 673 @config/list[/lowercase] [<option|option-type>] 674 @config/set option=value674 @config/set|save option=value 675 675 676 676 This command lists the MUSH configuration parameters, indicating what … … 686 686 /set -- Wizard only, changes parameters from the mush. See 687 687 help @config parameters for available ones. 688 /save -- Like /set, but also modifies the config file so the 689 change persists over reboots. 688 690 & @conformat 689 691 @conformat <object> [=<format>] 1.8.3/branches/devel/hdrs/switches.h
r1070 r1302 119 119 #define SWITCH_ROOMS 116 120 120 #define SWITCH_RSARGS 117 121 #define SWITCH_SEE 118 122 #define SWITCH_SEEFLAG 119 123 #define SWITCH_SELF 120 124 #define SWITCH_SEND 121 125 #define SWITCH_SET 122 126 #define SWITCH_SILENT 123 127 #define SWITCH_SKIPDEFAULTS 124 128 #define SWITCH_SPEAK 125 129 #define SWITCH_SPOOF 126 130 #define SWITCH_STATS 127 131 #define SWITCH_SUMMARY 128 132 #define SWITCH_TABLES 129 133 #define SWITCH_TAG 130 134 #define SWITCH_TELEPORT 131 135 #define SWITCH_TF 132 136 #define SWITCH_THINGS 133 137 #define SWITCH_TITLE 134 138 #define SWITCH_TRACE 135 139 #define SWITCH_TYPE 136 140 #define SWITCH_UNCLEAR 137 141 #define SWITCH_UNFOLDER 138 142 #define SWITCH_UNGAG 139 143 #define SWITCH_UNHIDE 140 144 #define SWITCH_UNMUTE 141 145 #define SWITCH_UNTAG 142 146 #define SWITCH_UNTIL 143 147 #define SWITCH_URGENT 144 148 #define SWITCH_USEFLAG 145 149 #define SWITCH_WHAT 146 150 #define SWITCH_WHO 147 151 #define SWITCH_WIPE 148 152 #define SWITCH_WIZ 149 153 #define SWITCH_WIZARD 150 154 #define SWITCH_YES 151 155 #define SWITCH_ZONE 152 121 #define SWITCH_SAVE 118 122 #define SWITCH_SEE 119 123 #define SWITCH_SEEFLAG 120 124 #define SWITCH_SELF 121 125 #define SWITCH_SEND 122 126 #define SWITCH_SET 123 127 #define SWITCH_SILENT 124 128 #define SWITCH_SKIPDEFAULTS 125 129 #define SWITCH_SPEAK 126 130 #define SWITCH_SPOOF 127 131 #define SWITCH_STATS 128 132 #define SWITCH_SUMMARY 129 133 #define SWITCH_TABLES 130 134 #define SWITCH_TAG 131 135 #define SWITCH_TELEPORT 132 136 #define SWITCH_TF 133 137 #define SWITCH_THINGS 134 138 #define SWITCH_TITLE 135 139 #define SWITCH_TRACE 136 140 #define SWITCH_TYPE 137 141 #define SWITCH_UNCLEAR 138 142 #define SWITCH_UNFOLDER 139 143 #define SWITCH_UNGAG 140 144 #define SWITCH_UNHIDE 141 145 #define SWITCH_UNMUTE 142 146 #define SWITCH_UNTAG 143 147 #define SWITCH_UNTIL 144 148 #define SWITCH_URGENT 145 149 #define SWITCH_USEFLAG 146 150 #define SWITCH_WHAT 147 151 #define SWITCH_WHO 148 152 #define SWITCH_WIPE 149 153 #define SWITCH_WIZ 150 154 #define SWITCH_WIZARD 151 155 #define SWITCH_YES 152 156 #define SWITCH_ZONE 153 156 157 #endif /* SWITCHES_H */ 1.8.3/branches/devel/src/SWITCHES
r892 r1302 116 116 ROOMS 117 117 RSARGS 118 SAVE 118 119 SEE 119 120 SEEFLAG 1.8.3/branches/devel/src/cmds.c
r1213 r1302 170 170 else if (SW_ISSET(sw, SWITCH_POWERS)) 171 171 do_list_flags("POWER", player, arg_left, lc, T("Powers")); 172 else if (SW_ISSET(sw, SWITCH_SET) ) {172 else if (SW_ISSET(sw, SWITCH_SET) || SW_ISSET(sw, SWITCH_SAVE)) { 173 173 if (!Wizard(player)) { 174 174 notify(player, T("You can't remake the world in your image.")); … … 179 179 return; 180 180 } 181 if (!config_set(arg_left, arg_right, 1, 0) 182 && !config_set(arg_left, arg_right, 1, 1)) 183 notify(player, T("Couldn't set that option")); 184 else 185 notify(player, T("Option set.")); 181 { 182 int source = SW_ISSET(sw, SWITCH_SAVE) ? 2 : 1; 183 if (!config_set(arg_left, arg_right, source, 0) 184 && !config_set(arg_left, arg_right, source, 1)) 185 notify(player, T("Couldn't set that option")); 186 else { 187 if (source == 2) { 188 #ifdef HAVE_ED 189 notify(player, T("Option set and saved.")); 190 #else 191 notify(player, T("Option set but not saved.")); 192 #endif 193 } else 194 notify(player, T("Option set.")); 195 } 196 } 186 197 } else 187 198 do_config_list(player, arg_left, lc); 1.8.3/branches/devel/src/command.c
r1237 r1302 112 112 CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_NOGAGGED, 0, 0}, 113 113 {"@CONFIG", 114 "SET LOWERCASE LIST GLOBALS DEFAULTS COSTS FLAGS FUNCTIONS COMMANDS ATTRIBS",114 "SET SAVE LOWERCASE LIST GLOBALS DEFAULTS COSTS FLAGS FUNCTIONS COMMANDS ATTRIBS", 115 115 cmd_config, CMD_T_ANY | CMD_T_EQSPLIT, 0, 0}, 116 116 {"@CPATTR", "CONVERT NOFLAGCOPY", cmd_cpattr, 1.8.3/branches/devel/src/conf.c
r1213 r1302 24 24 #include <stdlib.h> 25 25 #include <ctype.h> 26 #include <errno.h> 26 27 27 28 #include "conf.h" … … 44 45 45 46 static void show_compile_options(dbref player); 46 static char *config_list_helper(dbref player, PENNCONF *cp, int lc); 47 static char *config_list_helper2(dbref player, PENNCONF *cp, int lc); 47 static char *config_to_string(dbref player, PENNCONF *cp, int lc); 48 48 49 49 OPTTAB options; /**< The table of configuration options */ … … 880 880 } 881 881 882 static char *toplevel_cfile = NULL; 883 884 static void 885 append_restriction(const char *r, const char *what, const char *opts) 886 { 887 FILE *out; 888 889 out = fopen(toplevel_cfile, "a"); 890 if (out) { 891 fprintf(out, "# Added by @config/save\n%s %s %s\n\n", 892 r, what, opts); 893 fclose(out); 894 } 895 } 896 897 /* Not perfect -- things defined in included config files won't 898 get changed -- but it'll catch most cases. 899 */ 900 static void 901 save_config_option(PENNCONF *cp) 902 { 903 #if defined(HAVE_ED) 904 FILE *ed; 905 906 /* ed is the standard! Why reinvent it? */ 907 908 ed = popen(ED_PATH, "w"); 909 if (!ed) { 910 do_rawlog(LT_ERR, "Unable to open ed: %s", strerror(errno)); 911 return; 912 } 913 914 fprintf(ed, "e %s\n", toplevel_cfile); 915 fprintf(ed, ",s/^[[:space:]]*%s[[:space:]].*$/%s/\n", cp->name, 916 trim_space_sep(config_to_string(GOD, cp, 1), ' ')); 917 fputs("wq\n", ed); 918 pclose(ed); 919 #endif 920 921 } 922 882 923 /** Set a configuration option. 883 924 * This function sets a runtime configuration option. During the load … … 887 928 * \param opt name of the option. 888 929 * \param val value to set the option to. 889 * \param source 0 if being set from mush.cnf, 1 from softcode .930 * \param source 0 if being set from mush.cnf, 1 from softcode, 2 from softcode and saving. 890 931 * \param restrictions 1 if we're setting restriction options, 0 for others. 891 932 * \retval 1 success. … … 924 965 return 0; 925 966 } 967 if (source == 2) 968 append_restriction("restrict_command", val, p); 926 969 return 1; 927 970 } else if (!strcasecmp(opt, "restrict_function")) { … … 947 990 return 0; 948 991 } 992 if (source == 2) 993 append_restriction("restrict_function", val, p); 949 994 return 1; 950 995 } else if (!strcasecmp(opt, "reserve_alias")) { … … 972 1017 return 0; 973 1018 } 1019 if (source == 2) 1020 append_restriction("reserve_alias", val, p); 974 1021 return 1; 975 1022 } else if (!strcasecmp(opt, "attribute_alias")) { … … 992 1039 return 0; 993 1040 } 1041 if (source == 2) 1042 append_restriction("attribute_alias", val, p); 994 1043 return 1; 995 1044 } else if (!strcasecmp(opt, "function_alias")) { … … 1012 1061 return 0; 1013 1062 } 1063 if (source == 2) 1064 append_restriction("function_alias", val, p); 1014 1065 return 1; 1015 1066 } else if (!strcasecmp(opt, "help_command") … … 1020 1071 return 0; 1021 1072 /* Add a new help-like command */ 1022 if (source == 1)1073 if (source >= 1) /* Can't do this from @config/set */ 1023 1074 return 0; 1024 1075 if (!val || !*val) { … … 1053 1104 && !strcasecmp(cp->name, opt)) { 1054 1105 i = cp->handler(opt, val, cp->loc, cp->max, source); 1055 if (i) 1106 if (i) { 1056 1107 cp->overridden = 1; 1108 if (source == 2) 1109 save_config_option(cp); 1110 } 1057 1111 return i; 1058 1112 } 1059 1113 } 1060 for (cp = (PENNCONF *)hash_firstentry(&local_options); cp;1061 cp = (PENNCONF *)hash_nextentry(&local_options)) {1114 for (cp = hash_firstentry(&local_options); cp; 1115 cp = hash_nextentry(&local_options)) { 1062 1116 int i = 0; 1063 1117 if ((!source || (cp->group && strcmp(cp->group, "files") != 0 … … 1065 1119 && !strcasecmp(cp->name, opt)) { 1066 1120 i = cp->handler(opt, val, cp->loc, cp->max, source); 1067 if (i) 1121 if (i) { 1068 1122 cp->overridden = 1; 1123 if (source == 2) 1124 save_config_option(cp); 1125 } 1069 1126 return i; 1070 1127 } … … 1287 1344 char tbuf1[BUFFER_LEN]; 1288 1345 char *p, *q, *s; 1289 1290 1346 static char cfile[BUFFER_LEN]; /* Remember the last one */ 1347 1291 1348 if (conf_recursion == 0) { 1292 1349 if (conf && *conf) … … 1298 1355 } 1299 1356 do_rawlog(LT_ERR, "Reading %s", cfile); 1357 if (toplevel_cfile == NULL) 1358 toplevel_cfile = mush_strdup(cfile, "config.file"); 1300 1359 } else { 1301 1360 if (conf && *conf) … … 1452 1511 for (cp = conftable; cp->name; cp++) { 1453 1512 if (cp->group && string_prefix(cp->name, type)) { 1454 notify(player, config_ list_helper(player, cp, lc));1513 notify(player, config_to_string(player, cp, lc)); 1455 1514 found = 1; 1456 1515 } … … 1461 1520 cp = (PENNCONF *) hash_nextentry(&local_options)) { 1462 1521 if (cp->group && !strcasecmp(cp->name, type)) { 1463 notify(player, config_ list_helper(player, cp, lc));1522 notify(player, config_to_string(player, cp, lc)); 1464 1523 found = 1; 1465 1524 } … … 1482 1541 for (cp = conftable; cp->name; cp++) { 1483 1542 if (cp->group && !strcmp(cp->group, cgp->name)) { 1484 notify(player, config_ list_helper(player, cp, lc));1543 notify(player, config_to_string(player, cp, lc)); 1485 1544 } 1486 1545 } … … 1488 1547 cp = (PENNCONF *) hash_nextentry(&local_options)) { 1489 1548 if (cp->group && !strcasecmp(cp->group, cgp->name)) { 1490 notify(player, config_ list_helper(player, cp, lc));1549 notify(player, config_to_string(player, cp, lc)); 1491 1550 } 1492 1551 } … … 1509 1568 #define MAYBE_LC(x) (lc ? strlower(x) : x) 1510 1569 static char * 1511 config_ list_helper(dbref player1570 config_to_string(dbref player 1512 1571 __attribute__ ((__unused__)), PENNCONF *cp, int lc) 1513 1572 { … … 1550 1609 /* This one doesn't return the names */ 1551 1610 static char * 1552 config_ list_helper2(dbref player1611 config_to_string2(dbref player 1553 1612 __attribute__ ((__unused__)), PENNCONF *cp, int lc 1554 1613 __attribute__ ((__unused__))) … … 1596 1655 for (cp = conftable; cp->name; cp++) { 1597 1656 if (cp->group && !strcasecmp(cp->name, args[0])) { 1598 safe_str(config_ list_helper2(executor, cp, 0), buff, bp);1657 safe_str(config_to_string2(executor, cp, 0), buff, bp); 1599 1658 return; 1600 1659 } … … 1603 1662 cp = (PENNCONF *) hash_nextentry(&local_options)) { 1604 1663 if (cp->group && !strcasecmp(cp->name, args[0])) { 1605 safe_str(config_ list_helper2(executor, cp, 0), buff, bp);1664 safe_str(config_to_string2(executor, cp, 0), buff, bp); 1606 1665 return; 1607 1666 } 1.8.3/branches/devel/src/switchinc.c
r947 r1302 118 118 {"ROOMS", SWITCH_ROOMS}, 119 119 {"RSARGS", SWITCH_RSARGS}, 120 {"SAVE", SWITCH_SAVE}, 120 121 {"SEE", SWITCH_SEE}, 121 122 {"SEEFLAG", SWITCH_SEEFLAG},
