From 420428c53fe83064331ac2e06297c8a93abc93cf Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 20 Feb 2011 19:54:48 +0100 Subject: Remove CHECK_LOAD and CHECK_TIME completely. --- src/files.c | 257 ------------------------------------------------------------ 1 file changed, 257 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index a1a41c56..7323b426 100644 --- a/src/files.c +++ b/src/files.c @@ -1111,263 +1111,6 @@ errr process_pref_file(cptr name) - - - -#ifdef CHECK_TIME - -/* - * Operating hours for ANGBAND (defaults to non-work hours) - */ -static char days[7][29] = - { - "SUN:XXXXXXXXXXXXXXXXXXXXXXXX", - "MON:XXXXXXXX.........XXXXXXX", - "TUE:XXXXXXXX.........XXXXXXX", - "WED:XXXXXXXX.........XXXXXXX", - "THU:XXXXXXXX.........XXXXXXX", - "FRI:XXXXXXXX.........XXXXXXX", - "SAT:XXXXXXXXXXXXXXXXXXXXXXXX" - }; - -/* - * Restict usage (defaults to no restrictions) - */ -static bool check_time_flag = FALSE; - -#endif - - -/* - * Handle CHECK_TIME - */ -errr check_time(void) -{ - -#ifdef CHECK_TIME - - time_t c; - - struct tm *tp; - - - /* No restrictions */ - if (!check_time_flag) return (0); - - /* Check for time violation */ - c = time((time_t *)0); - tp = localtime(&c); - - /* Violation */ - if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1); - -#endif - - /* Success */ - return (0); -} - - - -/* - * !Ran under the game's permission! - * - * Initialize CHECK_TIME - */ -errr check_time_init(void) -{ - -#ifdef CHECK_TIME - - FILE *fp; - - char buf[1024]; - - - /* Build the filename */ - path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt"); - - /* - * XXX No need to grab permission here because this function is called - * only once before the game drops "game" permission - */ - - /* Open the file */ - fp = my_fopen(buf, "r"); - - /* No file, no restrictions */ - if (!fp) return (0); - - /* Assume restrictions */ - check_time_flag = TRUE; - - /* Parse the file */ - while (0 == my_fgets(fp, buf, 80)) - { - /* Skip comments and blank lines */ - if (!buf[0] || (buf[0] == '#')) continue; - - /* Chop the buffer */ - buf[29] = '\0'; - - /* Extract the info */ - if (prefix(buf, "SUN:")) strcpy(days[0], buf); - if (prefix(buf, "MON:")) strcpy(days[1], buf); - if (prefix(buf, "TUE:")) strcpy(days[2], buf); - if (prefix(buf, "WED:")) strcpy(days[3], buf); - if (prefix(buf, "THU:")) strcpy(days[4], buf); - if (prefix(buf, "FRI:")) strcpy(days[5], buf); - if (prefix(buf, "SAT:")) strcpy(days[6], buf); - } - - /* Close it */ - my_fclose(fp); - -#endif - - /* Success */ - return (0); -} - - - -#ifdef CHECK_LOAD - -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 64 -#endif - -typedef struct statstime statstime; - -struct statstime -{ - int cp_time[4]; - int dk_xfer[4]; - unsigned int v_pgpgin; - unsigned int v_pgpgout; - unsigned int v_pswpin; - unsigned int v_pswpout; - unsigned int v_intr; - int if_ipackets; - int if_ierrors; - int if_opackets; - int if_oerrors; - int if_collisions; - unsigned int v_swtch; - long avenrun[3]; - struct timeval boottime; - struct timeval curtime; -}; - -/* - * Maximal load (if any). - */ -static int check_load_value = 0; - -#endif - - -/* - * Handle CHECK_LOAD - */ -errr check_load(void) -{ - -#ifdef CHECK_LOAD - - struct statstime st; - - - /* Success if not checking */ - if (!check_load_value) return (0); - - /* Check the load */ - if (0 == rstat("localhost", &st)) - { - long val1 = (long)(st.avenrun[2]); - long val2 = (long)(check_load_value) * FSCALE; - - /* Check for violation */ - if (val1 >= val2) return (1); - } - -#endif - - /* Success */ - return (0); -} - - -/* - * !Ran under the game's permission! - * - * Initialize CHECK_LOAD - */ -errr check_load_init(void) -{ - -#ifdef CHECK_LOAD - - FILE *fp; - - char buf[1024]; - - char temphost[MAXHOSTNAMELEN + 1]; - char thishost[MAXHOSTNAMELEN + 1]; - - - /* Build the filename */ - path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt"); - - /* - * XXX No need to grab permission here because this function is called - * only once before the game drops "game" permission - */ - - /* Open the "load" file */ - fp = my_fopen(buf, "r"); - - /* No file, no restrictions */ - if (!fp) return (0); - - /* Default load */ - check_load_value = 100; - - /* Get the host name */ - (void)gethostname(thishost, (sizeof thishost) - 1); - - /* Parse it */ - while (0 == my_fgets(fp, buf, 1024)) - { - int value; - - /* Skip comments and blank lines */ - if (!buf[0] || (buf[0] == '#')) continue; - - /* Parse, or ignore */ - if (sscanf(buf, "%s%d", temphost, &value) != 2) continue; - - /* Skip other hosts */ - if (!streq(temphost, thishost) && - !streq(temphost, "localhost")) continue; - - /* Use that value */ - check_load_value = value; - - /* Done */ - break; - } - - /* Close the file */ - my_fclose(fp); - -#endif - - /* Success */ - return (0); -} - - /* * Print long number with header at given row, column * Use the color for the number, not the header -- cgit v1.2.3