makecf.c
src_4.06/makecf.c · 9.9 KB
From the archive Mordor_4.0.tgz
Download the archive « Back to the archive contents
/* makecf.c (C) 1997 Paul Telford */
/* This will create a config file suitable for use with
* Mordor v4.0 and above. Compile with:
* make makecf
* or
* cc -o makecf makecf.c
*
* Usage is:
* makecf [filename]
* if a filename is not specified, then BINPATH/mordor.cf will be used.
*
* HISTORY:
* v0.6 Basics
* v0.9 Defaults are now used if the user hits return on a prompt
* v0.99 Email fields now default to smarter values
*
* TODO:
* - Error-checking on input fields. i.e. make sure we enter a number
* not a letter for the port. Make sure DM names are valid. Make
* sure path names are valid.
*/
/* Questions, comments, suggestions and patches to: pdtelford@pobox.com */
#include <stdio.h>
#include <stdlib.h>
#include <sys/utsname.h>
#include "mtype.h"
void print_ans();
void print_str();
FILE *fp;
int main(argc, argv)
int argc;
char *argv[];
{
char file[80], domain[80];
char number[5];
int portnum;
struct utsname buf;
printf("makecf v0.99 for Mordor 4.0+ by Paul Telford\n\n");
if(argc > 2) {
printf("Usage: makecf [filename]\n");
return(0);
}
if(argc == 1)
sprintf(file, "%s/mordor.cf",BINPATH);
else
sprintf(file, "%s",argv[1]);
if((fp=fopen(file, "w")) == NULL) {
printf("Could not open file, exiting...\n");
return(0);
}
uname(&buf);
sprintf(domain, "mordor@%s.%s", buf.nodename, buf.domainname);
printf("This program will help you set up your Mordor MUD by asking\n");
printf("you a few questions. Unless stated otherwise, you may hit\n");
printf("enter to use the default answer (shown in parentheses) if you\n");
printf("don't know what to put.\n\n");
fprintf(fp,"; %s.%s %s %s %s %s\n", buf.nodename,buf.domainname,buf.release,
buf.version,buf.machine,buf.sysname);
fprintf(fp,"; %s --config file for Mordor v4.0+\n",file);
fprintf(fp,"; Config file generated by `makecf` e-mail: pdtelford@pobox.com for info\n");
fprintf(fp,"; Blank lines, and lines starting with a semi-colon are \n");
fprintf(fp,"; considered to be comments.\n\n");
printf("\nThe following responses are free-form up to 80 characters.\n");
fprintf(fp,"[Text Strings]\n");
printf("MUD Title (Mordor MUD): ");
print_str("Title", "Mordor MUD");
printf("General questions email address (%s): ",domain);
print_str("Questions_to_email", domain);
printf("Auth email (%s): ",domain);
print_str("Authorization_questions_email", domain);
printf("Registration email (%s): ",domain);
print_str("Register_questions_email", domain);
fprintf(fp,"\n[DM's names]\n");
printf("\nDM's Names:\n");
printf("DM Name1 (Erech): ");
print_str("DMNAME", "Erech");
printf("DM Name2 (Tesseract): ");
print_str("DMNAME2", "Tesseract");
printf("DM Name3 (Azog): ");
print_str("DMNAME3", "Azog");
printf("DM Name4 (Garth): ");
print_str("DMNAME4", "Garth");
printf("DM Name5 (Darwin): ");
print_str("DMNAME5", "Darwin");
printf("DM Name6 (Eldritch): ");
print_str("DMNAME6", "Eldritch");
printf("DM Name7 (Fangorn): ");
print_str("DMNAME7", "Fangorn");
fprintf(fp,"\n[pathnames]\n");
printf("\nPathnames (you may use relative paths)\n");
printf("Room Path (/home/mordor/rooms): ");
print_str("ROOMPATH", "/home/mordor/rooms");
printf("Monster Path (/home/mordor/objmon): ");
print_str("MONPATH", "/home/mordor/objmon");
printf("Object Path (/home/mordor/objmon): ");
print_str("OBJPATH", "/home/mordor/objmon");
printf("Player Path (/home/mordor/players): ");
print_str("PLAYERPATH", "/home/mordor/players");
printf("Document Path (/home/mordor/help): ");
print_str("DOCPATH", "/home/mordor/help");
printf("Post Path (/home/mordor/post): ");
print_str("POSTPATH", "/home/mordor/post");
printf("Binary Path (/home/mordor/bin): ");
print_str("BINPATH", "/home/mordor/bin");
printf("Log Path (/home/mordor/log): ");
print_str("LOGPATH", "/home/mordor/log");
fprintf(fp,"\n[Game Settings]\n");
fprintf(fp,";Port # for Game. DO NOT change this, and then reload from inside the game!\n");
printf("\nPort # (4040): ");
gets(number);
if(number[0] == '\0') fprintf(fp,"PORTNUM=4040\n");
else {
portnum = atoi(number);
if(portnum < 1000) {
printf("WARNING! Unless you know what you are doing, it is highly\n");
printf("recommended that you use a port number above 1000. Doing\n");
printf("otherwise may cause interruptions to other services on your\n");
printf("machine. Proceed at your own risk.\n");
}
fprintf(fp,"PORTNUM=%d\n",portnum);
}
printf("\nPlease answer Y or N to the following (all default to \"N\"):\n");
fprintf(fp,"\n;ANSI Bottom Line. Only used in character creation at the moment.\n");
printf("Ansi bottom line: ");
print_ans("ANSILINE");
fprintf(fp,";Perform Automatic shutdowns\n");
printf("Automatically shutdown every 6 hours? ");
print_ans("AUTOSHUTDOWN");
fprintf(fp,";Check for double logins\n");
printf("Check for double logins (old style)? ");
print_ans("CHECKDOUBLE");
fprintf(fp,";Enable Crashtrapping with signal functions\n");
printf("Enable Crashtrapping with signal functions? ");
print_ans("CRASHTRAP");
fprintf(fp,";Enable food and drink\n");
printf("Enable food and drink? ");
print_ans("EATNDRINK");
fprintf(fp,";Use hash tables for room directories. r00/r00001 r01/r01001 etc.\n");
printf("Use hash tables for room directories? ");
print_ans("HASHROOMS");
fprintf(fp,";Use heaven specific settings\n");
printf("Use Heaven specific settings? ");
print_ans("HEAVEN");
fprintf(fp,";Use Isengard specific settings\n");
printf("Use Isengard specific settings? ");
print_ans("ISENGARD");
fprintf(fp,";Experience for healing players\n");
printf("Experience for healing players? ");
print_ans("NICEEXP");
fprintf(fp,"; This will block access to all non-RFC1413 accounts.\n");
printf("Block access to all non-RFC1413 accounts? ");
print_ans("PARANOID");
fprintf(fp,";This will output all the keystrokes by all players to ~/log/all_cmd.\n");
printf("Output all the keystrokes by all players to a log? ");
print_ans("RECORD_ALL");
fprintf(fp,";This will block access to broadcasting for all non-RFC1413 accounts that\n");
fprintf(fp,";have not been authorized. It will also prevent them from playing past\n");
fprintf(fp,";level 3.\n");
printf("Use RFC1413 security? ");
print_ans("RFC1413");
fprintf(fp,";Runs schedule_g()\n");
printf("Use schedule_g()? ");
print_ans("SCHED");
fprintf(fp,";This will disallow multiple logins from RFC1413 compliant accounts.\n");
printf("Double log check (RFC1413 style)? ");
print_ans("SECURE");
fprintf(fp,";This keeps track of all suicided characters in ~/log/SUICIDE\n");
printf("Log all Suicides? ");
print_ans("SUICIDE");
fprintf(fp,";This will save a player's file when s/he drops an item\n");
printf("Save after \"drop\" command? ");
print_ans("SAVEONDROP");
/* Don't ask about any of these settings. If the user really wants to change
* them, they'll have to edit the config file manually (for now) */
fprintf(fp,"\n\nAccount_exists=Your account already exists here.\n");
fprintf(fp,"[Weather]\n");
fprintf(fp,";Sunrise=The sun rises.\n");
fprintf(fp,";Sunset=The sun disappears over the horizon.\n");
fprintf(fp,";\n");
fprintf(fp,";Earth_trembles=The earth trembles under your feet.\n");
fprintf(fp,";Heavy_fog=A heavy fog blankets the earth.\n");
fprintf(fp,";\n");
fprintf(fp,";Beautiful_day=It's a beautiful day today.\n");
fprintf(fp,";Bright_sun=The sun shines brightly across the land.\n");
fprintf(fp,";Glaring_sun=The glaring sun beats down upon the inhabitants of the world.\n");
fprintf(fp,";Heat=The heat today is unbearable.\n");
fprintf(fp,";\n");
fprintf(fp,";Still=The air is still and quiet.\n");
fprintf(fp,";Light_breeze=A light breeze blows from the south.\n");
fprintf(fp,";Strong_wind=A strong wind blows across the land.\n");
fprintf(fp,";Wind_gusts=The wind gusts, blowing debris through the streets.\n");
fprintf(fp,";Gale_force=Gale force winds blow in from the Sea of Tranquility.\n");
fprintf(fp,";\n");
fprintf(fp,";Clear_skies=Clear, blue skies cover the land.\n");
fprintf(fp,";Light_clouds=Light clouds appear over the mountains.\n");
fprintf(fp,";Thunderheads=Thunderheads roll in from the east.\n");
fprintf(fp,";Light_rain=A light rain falls quietly.\n");
fprintf(fp,";Heavy_rain=A heavy rain begins to fall.\n");
fprintf(fp,";Sheets_rain=Sheets of rain pour down from the skies.\n");
fprintf(fp,";Torrent_rain=A torrent soaks the ground.\n");
fprintf(fp,";\n");
fprintf(fp,";No_moon=The sky is dark as pitch.\n");
fprintf(fp,";Sliver_moon=A sliver of silver can be seen in the night sky.\n");
fprintf(fp,";Half_moon=Half a moon lights the evening skies.\n");
fprintf(fp,";Waxing_moon=The night sky is lit by the waxing moon.\n");
fprintf(fp,";Full_moon=The full moon shines across the land.\n");
fprintf(fp,"\n[Timed Exit settings]\n");
fprintf(fp,"tx_mesg1=The Ithil Express has docked in Parth.\n");
fprintf(fp,"tx_mesg2=The Ithil Express has docked in Celduin.\n");
printf("\nDone! You may change your responses by running this program\n");
printf("again, or by editing your config file (%s). Please check your\n",file);
printf("answers in the config file before starting the server. Once inside the game\n");
printf("you may reload your choices with \"*gamestat r\".\n");
printf("You may also be interested in changing some advanced settings\n");
printf("contained in the config file.\n");
close(fp);
return(1); /* Exit succesfully! */
}
void print_ans(setting)
char setting[80];
{
char temp;
char answer[80];
gets(answer);
if(answer[0] == '\0') fprintf(fp,"%s=No\n",setting,answer);
else {
temp=toupper(answer[0]);
if(temp == 'Y')
fprintf(fp,"%s=Yes\n",setting,answer);
else
fprintf(fp,"%s=No\n",setting,answer);
}
}
void print_str(setting,default_ans)
char setting[80];
char default_ans[80];
{
char answer[81];
gets(answer);
if (answer[0] == '\0')
fprintf(fp,"%s=%s\n",setting,default_ans);
else {
if(!strncmp(setting, "DMNAME",6)) answer[0] = toupper(answer[0]);
fprintf(fp,"%s=%s\n",setting,answer);
}
}