Changeset 1213
- Timestamp:
- 01/28/08 20:19:55 (8 months ago)
- Files:
-
- 1.8.3/branches/devel/hdrs/attrib.h (modified) (1 diff)
- 1.8.3/branches/devel/hdrs/intmap.h (modified) (1 diff)
- 1.8.3/branches/devel/src/access.c (modified) (2 diffs)
- 1.8.3/branches/devel/src/bsd.c (modified) (10 diffs)
- 1.8.3/branches/devel/src/cmds.c (modified) (1 diff)
- 1.8.3/branches/devel/src/conf.c (modified) (1 diff)
- 1.8.3/branches/devel/src/cque.c (modified) (12 diffs)
- 1.8.3/branches/devel/src/help.c (modified) (1 diff)
- 1.8.3/branches/devel/src/intmap.c (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/devel/hdrs/attrib.h
r1206 r1213 88 88 89 89 int can_read_attr_internal(dbref player, dbref obj, ATTR *attr); 90 int can_write_attr_internal(dbref player, dbref obj, ATTR *attr, 91 int safe); 90 int can_write_attr_internal(dbref player, dbref obj, ATTR *attr, int safe); 92 91 bool can_edit_attr(dbref player, dbref thing, const char *attrname); 93 92 unsigned const char *atr_get_compressed_data(ATTR *atr); 1.8.3/branches/devel/hdrs/intmap.h
r1211 r1213 11 11 typedef struct intmap intmap; 12 12 13 intmap *im_new(void);14 void im_destroy(intmap *);13 intmap *im_new(void); 14 void im_destroy(intmap *); 15 15 16 int im_count(intmap *);16 int im_count(intmap *); 17 17 18 bool im_insert(intmap *, uint32_t, void*);19 void *im_find(intmap *, uint32_t);20 bool im_exists(intmap *, uint32_t);21 bool im_delete(intmap *, uint32_t);22 void im_dump_graph(intmap *, const char *);18 bool im_insert(intmap *, uint32_t, void *); 19 void *im_find(intmap *, uint32_t); 20 bool im_exists(intmap *, uint32_t); 21 bool im_delete(intmap *, uint32_t); 22 void im_dump_graph(intmap *, const char *); 23 23 void im_stats_header(dbref); 24 void im_stats(dbref, intmap *, const char *);25 #endif /* INTMAP_H */24 void im_stats(dbref, intmap *, const char *); 25 #endif /* INTMAP_H */ 1.8.3/branches/devel/src/access.c
r1203 r1213 600 600 } 601 601 } 602 602 603 603 while (ap) { 604 604 rulenum++; 605 605 next = ap->next; 606 606 if (deletethis == -1 ? (strcasecmp(pattern, ap->host) == 0) 607 : deletethis == rulenum) {607 : deletethis == rulenum) { 608 608 n++; 609 609 if (ap->re) 610 free(ap->re);610 free(ap->re); 611 611 mush_free(ap, "sitelock.rule"); 612 612 if (prev) 613 prev->next = next;613 prev->next = next; 614 614 else 615 access_top = next;615 access_top = next; 616 616 if (deletethis >= 0) 617 break;617 break; 618 618 } else { 619 619 prev = ap; … … 621 621 ap = next; 622 622 } 623 623 624 624 return n; 625 625 } 1.8.3/branches/devel/src/bsd.c
r1208 r1213 1111 1111 1112 1112 if (notify_fd >= 0 && FD_ISSET(notify_fd, &input_set)) 1113 file_watch_event(notify_fd);1113 file_watch_event(notify_fd); 1114 1114 1115 1115 for (d = descriptor_list; d; d = dnext) { … … 4737 4737 { 4738 4738 do_rawlog(LT_TRACE, 4739 "Reloading help indexes and cached files after detecting a change.");4739 "Reloading help indexes and cached files after detecting a change."); 4740 4740 fcache_load(NOTHING); 4741 4741 help_reindex(NOTHING); … … 4757 4757 (name), strerror(errno)); \ 4758 4758 } while (0) 4759 4759 4760 4760 do_rawlog(LT_TRACE, 4761 "'No such file or directory' errors immediately following are probably harmless.");4761 "'No such file or directory' errors immediately following are probably harmless."); 4762 4762 for (n = 0; n < 2; n++) { 4763 4763 WATCH(options.connect_file[n]); … … 4770 4770 WATCH(options.guest_file[n]); 4771 4771 } 4772 4773 for (h = hash_firstentry(&help_files); h; h = hash_nextentry(&help_files)) 4772 4773 for (h = hash_firstentry(&help_files); h; h = hash_nextentry(&help_files)) 4774 4774 WATCH(h->file); 4775 4775 … … 4782 4782 int fd = inotify_init(); 4783 4783 4784 if (fd < 0) {4784 if (fd < 0) { 4785 4785 penn_perror("file_watch_init:inotify_init"); 4786 4786 return -1; … … 4829 4829 if (!gamedir) { 4830 4830 do_rawlog(LT_TRACE, 4831 "file_watch_init: Unable to get GAMEDIR environment variable.");4831 "file_watch_init: Unable to get GAMEDIR environment variable."); 4832 4832 return -1; 4833 4833 } 4834 4834 4835 4835 if (FAMOpen(&famc) < 0) { 4836 4836 do_rawlog(LT_TRACE, "file_watch_init: FAMOpen: %s", FamErrlist[FAMErrno]); 4837 4837 return -1; 4838 4838 } 4839 4840 4839 #define WATCH(name) do { \ 4841 4840 const char *fullname = tprintf("%s/%s", gamedir, (name)); \ … … 4845 4844 (name), FamErrlist[FAMErrno]); \ 4846 4845 } while (0) 4847 4846 4848 4847 do_rawlog(LT_TRACE, 4849 "'No such file or directory' errors immediately following are probably harmless.");4848 "'No such file or directory' errors immediately following are probably harmless."); 4850 4849 for (n = 0; n < 2; n++) { 4851 4850 WATCH(options.connect_file[n]); … … 4858 4857 WATCH(options.guest_file[n]); 4859 4858 } 4860 4861 for (h = hash_firstentry(&help_files); h; h = hash_nextentry(&help_files)) 4859 4860 for (h = hash_firstentry(&help_files); h; h = hash_nextentry(&help_files)) 4862 4861 WATCH(h->file); 4863 4862 4864 4863 #undef WATCH 4865 4864 4866 4865 return FAMCONNECTION_GETFD(&famc); 4867 4866 } … … 4874 4873 while (FAMPending(&famc)) { 4875 4874 FAMEvent famev; 4876 4875 4877 4876 memset(&famev, 0, sizeof famev); 4878 4877 4879 4878 if (FAMNextEvent(&famc, &famev) < 0) { 4880 4879 do_rawlog(LT_TRACE, "file_watch_event: FAMNextEvent: %s", 4881 FamErrlist[FAMErrno]);4880 FamErrlist[FAMErrno]); 4882 4881 break; 4883 4882 } 4884 4883 4885 4884 do_rawlog(LT_TRACE, "Code is: %d for %s", famev.code, famev.filename); 4886 4885 … … 4917 4916 */ 4918 4917 void 4919 file_watch_event(int fd __attribute__ ((__unused__)))4918 file_watch_event(int fd __attribute__ ((__unused__))) 4920 4919 { 4921 4920 #ifdef HAVE_INOTIFY 1.8.3/branches/devel/src/cmds.c
r1208 r1213 1077 1077 COMMAND(cmd_wait) 1078 1078 { 1079 if (SW_BY_NAME(sw, "PID")) 1079 if (SW_BY_NAME(sw, "PID")) 1080 1080 do_waitpid(player, arg_left, arg_right, SW_ISSET(sw, SWITCH_UNTIL)); 1081 1081 else 1.8.3/branches/devel/src/conf.c
r1187 r1213 1710 1710 1711 1711 #ifdef HAVE_INOTIFY 1712 notify(player, 1713 T(" Changed help files will be automatically reindexed.")); 1712 notify(player, T(" Changed help files will be automatically reindexed.")); 1714 1713 #endif 1715 1714 1.8.3/branches/devel/src/cque.c
r1212 r1213 965 965 pid = parse_uint32(pidstr, NULL, 10); 966 966 q = im_find(queue_map, pid); 967 967 968 968 if (!q) { 969 969 notify(player, T("That is not a valid pid!")); … … 978 978 if (q->sem != NOTHING && q->left == 0) { 979 979 notify(player, 980 T("You cannot adjust the timeout of an indefinite semaphore."));980 T("You cannot adjust the timeout of an indefinite semaphore.")); 981 981 return; 982 982 } … … 988 988 989 989 if (until) { 990 int when; 990 int when; 991 991 992 992 when = parse_integer(timestr); … … 1002 1002 /* If timestr looks like +NNN or -NNN, add or subtract a number 1003 1003 of seconds to the current timeout. Otherwise, change timeout. 1004 */1004 */ 1005 1005 if (timestr[0] == '+' || timestr[0] == '-') 1006 1006 q->left += offset; … … 1018 1018 if (tmp == q) { 1019 1019 if (last) 1020 last->next = q->next;1020 last->next = q->next; 1021 1021 else 1022 qwait = qwait->next;1022 qwait = qwait->next; 1023 1023 found = true; 1024 1024 break; … … 1041 1041 } 1042 1042 if (!found) { 1043 if (last) 1043 if (last) 1044 1044 last->next = q; 1045 1045 else … … 1075 1075 case 2: /* semaphore queue */ 1076 1076 if (tmp->left != 0) { 1077 notify_format(player, "(Pid: %u) [#%d/%s/%ld]%s: %s", tmp->pid, tmp->sem, 1078 tmp->semattr, (long) difftime(tmp->left, mudtime), 1077 notify_format(player, "(Pid: %u) [#%d/%s/%ld]%s: %s", tmp->pid, 1078 tmp->sem, tmp->semattr, (long) difftime(tmp->left, 1079 mudtime), 1079 1080 unparse_object(player, tmp->player), tmp->comm); 1080 1081 } else { 1081 notify_format(player, "(Pid: %u) [#%d/%s]%s: %s", tmp->pid, tmp->sem, 1082 tmp->semattr, unparse_object(player, tmp->player), 1082 notify_format(player, "(Pid: %u) [#%d/%s]%s: %s", tmp->pid, 1083 tmp->sem, tmp->semattr, unparse_object(player, 1084 tmp->player), 1083 1085 tmp->comm); 1084 1086 } 1085 1087 break; 1086 1088 default: /* player or object queue */ 1087 notify_format(player, "(Pid: %u) %s: %s", tmp->pid, unparse_object(player, 1088 tmp->player), 1089 tmp->comm); 1089 notify_format(player, "(Pid: %u) %s: %s", tmp->pid, 1090 unparse_object(player, tmp->player), tmp->comm); 1090 1091 } 1091 1092 } … … 1304 1305 * \param arg1 string representing the pid to halt. 1305 1306 */ 1306 void 1307 void 1307 1308 do_haltpid(dbref player, const char *arg1) 1308 1309 { … … 1322 1323 if (!q) { 1323 1324 notify(player, T("That is not a valid pid!")); 1324 return;1325 return; 1325 1326 } 1326 1327 … … 1330 1331 return; 1331 1332 } 1332 1333 1333 1334 /* Instead of trying to track what queue this entry currently 1334 1335 belongs too, flag it as halted and just not execute it when its … … 1339 1340 if (q->semattr) { 1340 1341 BQUE *last = NULL, *tmp; 1341 1342 1342 1343 for (tmp = qsemfirst; tmp; last = tmp, tmp = tmp->next) { 1343 1344 if (tmp == q) { 1344 if (last)1345 last->next = tmp->next;1346 else1347 qsemfirst = tmp->next;1348 1349 if (qsemlast == tmp)1350 qsemlast = last;1351 1352 break;1345 if (last) 1346 last->next = tmp->next; 1347 else 1348 qsemfirst = tmp->next; 1349 1350 if (qsemlast == tmp) 1351 qsemlast = last; 1352 1353 break; 1353 1354 } 1354 1355 } … … 1361 1362 notify_format(player, T("Queue entry with pid %u halted."), pid); 1362 1363 } 1363 1364 1364 1365 1365 1.8.3/branches/devel/src/help.c
r1194 r1213 368 368 if ((rfp = fopen(h->file, FOPEN_READ)) == NULL) { 369 369 do_rawlog(LT_ERR, T("Can't open %s for reading: %s"), h->file, 370 strerror(errno));370 strerror(errno)); 371 371 return; 372 372 } 1.8.3/branches/devel/src/intmap.c
r1211 r1213 57 57 #include "mymalloc.h" 58 58 #include "intmap.h" 59 #include "confmagic.h" 59 #include "confmagic.h" 60 60 61 61 /** Structure that represents a node in a patricia tree. */ … … 79 79 /** Return the number of elements in an integer map. */ 80 80 int 81 im_count(intmap * im)81 im_count(intmap * im) 82 82 { 83 83 if (im) … … 88 88 89 89 /** Allocate and initialize a new integer map. */ 90 intmap *90 intmap * 91 91 im_new(void) 92 92 { … … 103 103 104 104 static void 105 pat_destroy(patricia * node)105 pat_destroy(patricia * node) 106 106 { 107 107 int n; … … 110 110 return; 111 111 112 for (n = 0; n < 2; n++) 112 for (n = 0; n < 2; n++) 113 113 if (node->links[n]->bit > node->bit) 114 114 pat_destroy(node->links[n]); … … 123 123 */ 124 124 void 125 im_destroy(intmap * im)125 im_destroy(intmap * im) 126 126 { 127 127 if (im) { … … 138 138 139 139 /* Returns the node matching the key or its prefix */ 140 static patricia *141 pat_search(patricia * node, uint32_t key, int bit)140 static patricia * 141 pat_search(patricia * node, uint32_t key, int bit) 142 142 { 143 143 assert(node); … … 154 154 * \returns the value of the data stored under that key, or NULL 155 155 */ 156 void *157 im_find(intmap * im, uint32_t key)156 void * 157 im_find(intmap * im, uint32_t key) 158 158 { 159 159 patricia *node; … … 161 161 if (!im->root) 162 162 return NULL; 163 163 164 164 node = pat_search(im->root, key, -1); 165 165 … … 176 176 */ 177 177 bool 178 im_exists(intmap * im, uint32_t key)178 im_exists(intmap * im, uint32_t key) 179 179 { 180 180 patricia *node; … … 193 193 */ 194 194 bool 195 im_insert(intmap * im, uint32_t key, void *data)195 im_insert(intmap * im, uint32_t key, void *data) 196 196 { 197 197 patricia *here, *newnode, *prev = NULL; … … 232 232 return true; 233 233 } 234 235 for (here = im->root; ;) {234 235 for (here = im->root;;) { 236 236 int i; 237 237 if (here->bit == bit) { … … 249 249 return true; 250 250 } 251 251 252 252 prev = here; 253 253 i = digit(key, here->bit); … … 255 255 prevbit = i; 256 256 } 257 257 258 258 /* Not reached */ 259 259 assert(0); … … 268 268 */ 269 269 bool 270 im_delete(intmap * im, uint32_t key)270 im_delete(intmap * im, uint32_t key) 271 271 { 272 272 patricia *parent = NULL, *firstparent = NULL, *grandparent = NULL; 273 273 patricia *here = im->root; 274 274 275 275 if (!here) 276 276 return false; … … 282 282 parent = here; 283 283 here = here->links[x]; 284 284 285 285 assert(here); 286 286 287 287 if (here->key == key && !firstparent) 288 288 firstparent = parent; … … 312 312 i = (here->links[0] == here); 313 313 replacement = here->links[i]; 314 314 315 315 if (replacement != here) { 316 316 if (!grandparent || grandparent == here) 317 im->root = replacement;317 im->root = replacement; 318 318 else 319 grandparent->links[grandparent->links[1] == parent] = replacement;320 } else 319 grandparent->links[grandparent->links[1] == parent] = replacement; 320 } else 321 321 grandparent->links[grandparent->links[1] == parent] = grandparent; 322 322 … … 346 346 parent->links[1 - i] = other; 347 347 if (parent->links[0] == here) 348 parent->links[0] = parent;348 parent->links[0] = parent; 349 349 if (parent->links[1] == here) 350 parent->links[1] = parent;350 parent->links[1] = parent; 351 351 parent->bit = here->bit; 352 352 slab_free(intmap_slab, here); … … 355 355 return true; 356 356 } 357 357 358 358 grandparent->links[grandparent->links[1] == parent] = otherlink; 359 359 parent->links[0] = here->links[0]; … … 374 374 375 375 static void 376 pat_list_nodes(patricia * node, FILE *fp)376 pat_list_nodes(patricia * node, FILE * fp) 377 377 { 378 378 int n; … … 387 387 388 388 fprintf(fp, 389 "node%u [label=\"{ <key> key = 0b%s (%u) | bit = %d | { <b0> 0 | <b1> 1 } }\", ",390 node->key, tmpbuf, node->key, node->bit);391 if (node->links[0]->bit > node->bit && node->links[1]->bit > node->bit) 389 "node%u [label=\"{ <key> key = 0b%s (%u) | bit = %d | { <b0> 0 | <b1> 1 } }\", ", 390 node->key, tmpbuf, node->key, node->bit); 391 if (node->links[0]->bit > node->bit && node->links[1]->bit > node->bit) 392 392 fputs("fillcolor=1", fp); 393 393 else if (node->links[0]->bit <= node->bit && node->links[1]->bit <= node->bit) … … 395 395 else 396 396 fputs("fillcolor=2", fp); 397 397 398 398 fputs("];\n", fp); 399 399 … … 405 405 406 406 static void 407 pat_list_links(patricia * node, FILE *fp)407 pat_list_links(patricia * node, FILE * fp) 408 408 { 409 409 int i; 410 410 const char *edge_styles[] = { "style=dashed,arrowhead=open", 411 "style=solid,arrowhead=normal" }; 411 "style=solid,arrowhead=normal" 412 }; 412 413 413 414 if (!node) … … 416 417 for (i = 0; i < 2; i++) { 417 418 if (node->links[i]) { 418 fprintf(fp, "node%u:b%d -> node%u:key [%s];\n", node->key, i, 419 node->links[i]->key,420 edge_styles[node->links[i]->bit > node->bit]);419 fprintf(fp, "node%u:b%d -> node%u:key [%s];\n", node->key, i, 420 node->links[i]->key, 421 edge_styles[node->links[i]->bit > node->bit]); 421 422 if (node->links[i]->bit > node->bit) 422 pat_list_links(node->links[i], fp);423 pat_list_links(node->links[i], fp); 423 424 } 424 425 } … … 439 440 */ 440 441 void 441 im_dump_graph(intmap * im, const char *filename)442 im_dump_graph(intmap * im, const char *filename) 442 443 { 443 444 FILE *fp; … … 452 453 return; 453 454 } 454 455 455 456 fputs("digraph patricia { \n", fp); 456 457 fputs("node [shape=Mrecord, colorscheme=blues3, style=filled];\n", fp); … … 470 471 /** @stats/tables line */ 471 472 void 472 im_stats(dbref player, intmap * im, const char *name)473 im_stats(dbref player, intmap * im, const char *name) 473 474 { 474 475 notify_format(player, "%-11s %7d %7u", name, im->count, 475 (unsigned int) (sizeof(*im) + (sizeof(patricia) * im->count)));476 } 476 (unsigned int) (sizeof(*im) + (sizeof(patricia) * im->count))); 477 }
