PennMUSH Community

Ticket #7625: info-custom.patch.txt

File info-custom.patch.txt, 2.3 kB (added by Talvo, 4 months ago)
Line 
1 *** src/conf.c.orig Fri Oct  5 23:36:32 2007
2 --- src/conf.c  Tue Jul 22 01:06:21 2008
3 ***************
4 *** 969,974 ****
5 --- 969,988 ----
6         return 0;
7       }
8       return 1;
9 +   } else if (!strcasecmp(opt, "info_text")) {
10 +   if (!restrictions)
11 +     return 0;
12 +   for (p = val; *p && !isspace((unsigned char) *p); p++) ;
13 +   if (*p) {
14 +     *p++ = '\0';
15 +     if (!add_info(val, p)) {
16 +       if (source == 0) {
17 +         do_rawlog(LT_ERR, T("CONFIG: Unable to add info '%s' with value '%s'"), p, val);
18 +       }
19 +       return 0;
20 +     }
21 +     }
22 +     return 1;
23     } else if (!strcasecmp(opt, "function_alias")) {
24       if (!restrictions)
25         return 0;
26 *** src/bsd.c.orig  Fri Oct  5 23:36:32 2007
27 --- src/bsd.c   Tue Jul 22 06:20:11 2008
28 ***************
29 *** 127,132 ****
30 --- 127,139 ----
31   void init_rlimit(void);
32   #endif
33  
34 + typedef struct info_text INFO_TEXT;
35 + struct info_text {
36 +   char name[21];
37 +   char value[51];
38 +   INFO_TEXT *next;
39 + };
40 + INFO_TEXT *info_list;
41  
42   /* BSD 4.2 and maybe some others need these defined */
43   #ifndef FD_ZERO
44 ***************
45 *** 2845,2850 ****
46 --- 2852,2859 ----
47   {
48     int count = 0;
49     DESC *d;
50 +   INFO_TEXT *infot;
51 +   
52     queue_string_eol(call_by, tprintf("### Begin INFO %s", INFO_VERSION));
53  
54     /* Count connected players */
55 ***************
56 *** 2867,2873 ****
57 --- 2876,2886 ----
58   #ifdef PATCHES
59     queue_string_eol(call_by, tprintf("Patches: %s", PATCHES));
60   #endif
61 +   for (infot = info_list; infot; infot = infot->next) {
62 +     queue_string_eol(call_by, tprintf("%s: %s", infot->name, infot->value));
63 +   }
64     queue_string_eol(call_by, "### End INFO");
65 +
66   }
67  
68   /** Determine if a new guest can connect at this point. If so, return
69 ***************
70 *** 4671,4673 ****
71 --- 4684,4710 ----
72   #endif                          /* WIN32 */
73     exit(1);                      /* Shouldn't ever get here, but just in case... */
74   }
75 +
76 +
77 + /** Insert an entry for the INFO command into the linked list  */
78 + int
79 + add_info(const char *name, const char *value)
80 + {
81 +   INFO_TEXT *info;
82 +   
83 +   info = (INFO_TEXT *) mush_malloc(sizeof(INFO_TEXT), "infotext");
84 +   if (!info)
85 +       mush_panic("Out of memory.");
86 +
87 +   mush_strncpy(info->name, name, 20);
88 +   mush_strncpy(info->value, value, 50);
89 +
90 +   if (!info_list) {
91 +       info_list = info;
92 +       info->next = NULL;
93 +   } else {
94 +       info->next = info_list;
95 +       info_list = info;
96 +   }
97 +   return 1;
98 + }