… | |
… | |
206 | * Last, make a check on the full name. |
206 | * Last, make a check on the full name. |
207 | */ |
207 | */ |
208 | int |
208 | int |
209 | item_matched_string (object *pl, object *op, const char *name) |
209 | item_matched_string (object *pl, object *op, const char *name) |
210 | { |
210 | { |
211 | char * |
|
|
212 | cp, |
|
|
213 | local_name[MAX_BUF]; |
211 | char *cp, local_name[MAX_BUF]; |
214 | int |
212 | int count, retval = 0; |
215 | count, |
|
|
216 | retval = 0; |
|
|
217 | |
213 | |
218 | strcpy (local_name, name); /* strtok is destructive to name */ |
214 | strcpy (local_name, name); /* strtok is destructive to name */ |
219 | |
215 | |
220 | for (cp = strtok (local_name, ","); cp; cp = strtok (NULL, ",")) |
216 | for (cp = strtok (local_name, ","); cp; cp = strtok (NULL, ",")) |
221 | { |
217 | { |
… | |
… | |
361 | */ |
357 | */ |
362 | |
358 | |
363 | void |
359 | void |
364 | init_archetable (void) |
360 | init_archetable (void) |
365 | { |
361 | { |
366 | archetype * |
362 | archetype *at; |
367 | at; |
|
|
368 | |
363 | |
369 | LOG (llevDebug, " Setting up archetable...\n"); |
364 | LOG (llevDebug, " Setting up archetable...\n"); |
370 | |
365 | |
371 | for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) |
366 | for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) |
372 | add_arch (at); |
367 | add_arch (at); |
… | |
… | |
391 | */ |
386 | */ |
392 | |
387 | |
393 | void |
388 | void |
394 | dump_all_archetypes (void) |
389 | dump_all_archetypes (void) |
395 | { |
390 | { |
396 | archetype * |
391 | archetype *at; |
397 | at; |
|
|
398 | |
392 | |
399 | for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) |
393 | for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) |
400 | { |
394 | { |
401 | dump_arch (at); |
395 | dump_arch (at); |
402 | fprintf (logfile, "%s\n", errmsg); |
396 | fprintf (logfile, "%s\n", errmsg); |
… | |
… | |
404 | } |
398 | } |
405 | |
399 | |
406 | void |
400 | void |
407 | free_all_archs (void) |
401 | free_all_archs (void) |
408 | { |
402 | { |
409 | archetype * |
403 | archetype *at, *next; |
410 | at, * |
|
|
411 | next; |
|
|
412 | int |
|
|
413 | i = 0, f = 0; |
404 | int i = 0, f = 0; |
414 | |
405 | |
415 | for (at = first_archetype; at != NULL; at = next) |
406 | for (at = first_archetype; at != NULL; at = next) |
416 | { |
407 | { |
417 | if (at->more) |
408 | if (at->more) |
418 | next = at->more; |
409 | next = at->more; |
… | |
… | |
443 | * of archetype-structures. |
434 | * of archetype-structures. |
444 | */ |
435 | */ |
445 | void |
436 | void |
446 | first_arch_pass (object_thawer & fp) |
437 | first_arch_pass (object_thawer & fp) |
447 | { |
438 | { |
448 | archetype * |
|
|
449 | at, * |
|
|
450 | head = NULL, *last_more = NULL; |
439 | archetype *at, *head = NULL, *last_more = NULL; |
451 | |
440 | |
452 | at->clone.arch = first_archetype = at = new archetype; |
441 | at->clone.arch = first_archetype = at = new archetype; |
453 | |
442 | |
454 | while (int i = load_object (fp, &at->clone, 0)) |
443 | while (int i = load_object (fp, &at->clone, 0)) |
455 | { |
444 | { |
… | |
… | |
524 | */ |
513 | */ |
525 | |
514 | |
526 | void |
515 | void |
527 | second_arch_pass (object_thawer & thawer) |
516 | second_arch_pass (object_thawer & thawer) |
528 | { |
517 | { |
529 | char |
|
|
530 | buf[MAX_BUF], * |
|
|
531 | variable = buf, *argument, *cp; |
518 | char buf[MAX_BUF], *variable = buf, *argument, *cp; |
532 | archetype * |
|
|
533 | at = NULL, *other; |
519 | archetype *at = NULL, *other; |
534 | |
520 | |
535 | while (fgets (buf, MAX_BUF, thawer) != NULL) |
521 | while (fgets (buf, MAX_BUF, thawer) != NULL) |
536 | { |
522 | { |
537 | if (*buf == '#') |
523 | if (*buf == '#') |
538 | continue; |
524 | continue; |
… | |
… | |
579 | |
565 | |
580 | #ifdef DEBUG |
566 | #ifdef DEBUG |
581 | void |
567 | void |
582 | check_generators (void) |
568 | check_generators (void) |
583 | { |
569 | { |
584 | archetype * |
570 | archetype *at; |
585 | at; |
|
|
586 | |
571 | |
587 | for (at = first_archetype; at != NULL; at = at->next) |
572 | for (at = first_archetype; at != NULL; at = at->next) |
588 | if (QUERY_FLAG (&at->clone, FLAG_GENERATOR) && at->clone.other_arch == NULL) |
573 | if (QUERY_FLAG (&at->clone, FLAG_GENERATOR) && at->clone.other_arch == NULL) |
589 | LOG (llevError, "Warning: %s is generator but lacks other_arch.\n", &at->name); |
574 | LOG (llevError, "Warning: %s is generator but lacks other_arch.\n", &at->name); |
590 | } |
575 | } |
… | |
… | |
598 | */ |
583 | */ |
599 | |
584 | |
600 | void |
585 | void |
601 | load_archetypes (void) |
586 | load_archetypes (void) |
602 | { |
587 | { |
603 | char |
|
|
604 | filename[MAX_BUF]; |
588 | char filename[MAX_BUF]; |
605 | |
589 | |
606 | #if TIME_ARCH_LOAD |
590 | #if TIME_ARCH_LOAD |
607 | struct timeval |
591 | struct timeval |
608 | tv1, |
592 | tv1, |
609 | tv2; |
593 | tv2; |
… | |
… | |
647 | */ |
631 | */ |
648 | |
632 | |
649 | object * |
633 | object * |
650 | arch_to_object (archetype *at) |
634 | arch_to_object (archetype *at) |
651 | { |
635 | { |
652 | object * |
636 | object *op; |
653 | op; |
|
|
654 | |
637 | |
655 | if (at == NULL) |
638 | if (at == NULL) |
656 | { |
639 | { |
657 | if (warn_archetypes) |
640 | if (warn_archetypes) |
658 | LOG (llevError, "Couldn't find archetype.\n"); |
641 | LOG (llevError, "Couldn't find archetype.\n"); |
… | |
… | |
675 | */ |
658 | */ |
676 | |
659 | |
677 | object * |
660 | object * |
678 | create_singularity (const char *name) |
661 | create_singularity (const char *name) |
679 | { |
662 | { |
680 | object * op; |
663 | object *op; |
681 | char buf[MAX_BUF]; |
664 | char buf[MAX_BUF]; |
682 | |
665 | |
683 | sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); |
666 | sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); |
684 | op = get_object (); |
667 | op = get_object (); |
685 | op->name = op->name_pl = buf; |
668 | op->name = op->name_pl = buf; |