/* CoreProperties.c */ #include "CoreProperties.h" #include "Core.h" #include "malloc.h" Property CreateProp(next, key, value) Property next; Atom key; Ref value; { Property prop; prop=New(Property, PropertyRec); prop->next=next; prop->key=key; prop->value=value; return(prop); }; Atom uniqueID=0; String *propNames; PropPrintProc *printProcs; Atom RegisterProp(name, printProc) String name; PropPrintProc printProc; { PropPrintProc *newPrintProcs; String *newPropNames; Nat i; newPropNames=(String *)malloc((uniqueID+1)*sizeof(String)); newPrintProcs=(PropPrintProc *)malloc((uniqueID+1)*sizeof(PropPrintProc)); for (i=0; ikey==prop) return(from->value); from=from->next; }; return(nil); }; Properties PutProp(on, prop, value) Properties on; Atom prop; Ref value; { Properties scan=on; while (scan) { if (scan->key==prop) { scan->value=value; return(on); }; scan=scan->next; }; return(CreateProp(on, prop, value)); }; void PrintProperties(props, indent, cr, level) Properties props; Nat indent; Bool cr; Nat level; { Properties scan=props; while (scan) { if (printProcs[scan->key]!=nil) (printProcs[scan->key])(scan->key, scan->value, indent, level, cr); scan=scan->next; }; }; void PrintPropertyString(prop, value, indent, level, cr) Atom prop; Ref value; Nat indent; Nat level; Bool cr; { level=level; PrintIndent(indent, cr); printf("%s: %s", propNames[prop], value); };