/** * Checks whether a Task is declared to the Logger. * If so, asks whether to invalidate the declaration. * @return True if a Task is NOT declared to the Logger, False otherwise */ bool ExternalLogger::CheckDeclaration(void) { // if (Task is not declared) -> return true; if (!IsDeclared()) return true; if (MessageBoxX(_("OK to invalidate declaration?"), _("Task declared"), MB_YESNO| MB_ICONQUESTION) == IDYES){ DeclaredToDevice = false; return true; } return false; }
/* * Determine if a field name is already declared in child node types. */ static int IsDeclaredInChildren(TreeCCContext *context, TreeCCNode *node, char *name) { TreeCCNode *child = node->firstChild; while(child != 0) { if(IsDeclared(context, child, name, 1)) { return 1; } if(IsDeclaredInChildren(context, child, name)) { return 1; } child = child->nextSibling; } return 0; }
void TreeCCFieldCreate(TreeCCContext *context, TreeCCNode *node, char *name, char *type, char *value, int flags) { TreeCCNode *current; TreeCCField *field; TreeCCField *prev; /* Print debugging information if required */ if(context->debugMode) { TreeCCDebug(context->input->linenum, "%%field %s %s %s %d", name, (type ? type : "no_type"), (value ? value : "no_value"), flags); } /* Check to make sure that the field does not already exist in this node type or any of its ancestor node types */ current = node; while(current != 0) { if(IsDeclared(context, current, name, 0)) { free(name); free(type); if(value) { free(value); } return; } current = current->parent; } /* Check to make sure that the field does not already exist in any of the child classes. This may happen if a child class is declared before one of its ancestors */ IsDeclaredInChildren(context, node, name); /* Find the end of the node's field list */ field = node->fields; prev = 0; while(field != 0) { prev = field; field = field->next; } /* Create a new field block and fill it in */ field = (TreeCCField *)malloc(sizeof(TreeCCField)); if(!field) { TreeCCOutOfMemory(context->input); } field->name = name; field->type = type; field->value = value; field->flags = flags; field->filename = context->input->filename; field->linenum = context->input->linenum; field->next = 0; /* Add the field to the list */ if(prev) { prev->next = field; } else { node->fields = field; } }