Logo Search packages:      
Sourcecode: dahdi-tools version File versions  Download package

static unsigned int calc_dep_failures ( int  interactive,
int  pre_confload 
) [static]
  • interactive Set to non-zero if being called while user is making changes

Definition at line 402 of file menuselect.c.

References categories, member::defaultenabled, member::depsfailed, member::enabled, depend::member, member::name, depend::name, member::was_defaulted, and member::was_enabled.

Referenced by set_all().

{
      unsigned int result = 0;
      struct category *cat;
      struct member *mem;
      struct depend *dep;
      struct dep_file *dep_file;
      unsigned int changed, old_failure;

      AST_LIST_TRAVERSE(&categories, cat, list) {
            AST_LIST_TRAVERSE(&cat->members, mem, list) {
                  old_failure = mem->depsfailed;
                  AST_LIST_TRAVERSE(&mem->deps, dep, list) {
                        if (dep->member)
                              continue;

                        mem->depsfailed = HARD_FAILURE;
                        AST_LIST_TRAVERSE(&deps_file, dep_file, list) {
                              if (!strcasecmp(dep_file->name, dep->name)) {
                                    if (dep_file->met == DEP_FILE_MET) {
                                          mem->depsfailed = NO_FAILURE;
                                    }
                                    break;
                              }
                        }
                        if (mem->depsfailed != NO_FAILURE) {
                              break; /* This dependency is not met, so we can stop now */
                        }
                  }
                  if (old_failure == SOFT_FAILURE && mem->depsfailed != HARD_FAILURE)
                        mem->depsfailed = SOFT_FAILURE;
            }
      }

      if (pre_confload) {
            return 0;
      }

      do {
            changed = 0;

            AST_LIST_TRAVERSE(&categories, cat, list) {
                  AST_LIST_TRAVERSE(&cat->members, mem, list) {
                        old_failure = mem->depsfailed;

                        if (mem->depsfailed == HARD_FAILURE)
                              continue;

                        mem->depsfailed = NO_FAILURE;

                        AST_LIST_TRAVERSE(&mem->deps, dep, list) {
                              if (!dep->member)
                                    continue;
                              if (dep->member->depsfailed == HARD_FAILURE) {
                                    mem->depsfailed = HARD_FAILURE;
                                    break;
                              } else if (dep->member->depsfailed == SOFT_FAILURE) {
                                    mem->depsfailed = SOFT_FAILURE;
                              } else if (!dep->member->enabled) {
                                    mem->depsfailed = SOFT_FAILURE;
                              }
                        }
                        
                        if (mem->depsfailed != old_failure) {
                              if ((mem->depsfailed == NO_FAILURE) && mem->was_defaulted) {
                                    mem->enabled = !strcasecmp(mem->defaultenabled, "yes");
                                    print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);
                              } else {
                                    mem->enabled = interactive ? 0 : mem->was_enabled;
                                    print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);
                              }
                              changed = 1;
                              break; /* This dependency is not met, so we can stop now */
                        }
                  }
                  if (changed)
                        break;
            }

            if (changed)
                  result = 1;

      } while (changed);

      return result;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index