bool RoutingCompiler_iosacl::PrintRule::processNext()
{
    RoutingRule *rule = getNext(); if (rule == nullptr) return false;
    tmp_queue.push_back(rule);
    
    string rl = rule->getLabel();
    string comm = rule->getComment();
    string::size_type c1, c2;
    c1 = 0;
    
    if (!compiler->inSingleRuleCompileMode() && rl != current_rule_label)
    {
        compiler->output << "! " << endl;
        compiler->output << "! Rule " << rl << endl;
        compiler->output << "! " << endl;
    }
   
//    string err = rule->getCompilerMessage();
//    if (!err.empty()) compiler->output << "# " << err << endl;

    if( rule->getRuleType() != RoutingRule::MultiPath )
    {
        if (!compiler->inSingleRuleCompileMode() && rl != current_rule_label)
        {
            while ( (c2 = comm.find('\n',c1)) != string::npos )
            {
                compiler->output << "! " << comm.substr(c1,c2-c1) << endl;
                c1 = c2 + 1;
            }
            compiler->output << "! " << comm.substr(c1) << endl;
            compiler->output << "! " << endl;

            string err = compiler->getErrorsForRule(rule, "! ");
            if (!err.empty()) compiler->output << err << endl;

            current_rule_label = rl;
        }
        
        string command_line = RoutingRuleToString(rule);
        compiler->output << command_line;
    
    } else
    {
        string err = compiler->getErrorsForRule(rule, "! ");
        if (!err.empty()) compiler->output << err << endl;

        compiler->abort(rule, "MultiPath routing not supported by platform");
    }
    return true;
}
bool RoutingCompiler_openbsd::PrintRule::processNext()
{
    RoutingCompiler_openbsd *bsd_comp = 
        dynamic_cast<RoutingCompiler_openbsd*>(compiler);

    slurp();
    if (tmp_queue.size()==0) return false;


    if (!compiler->inSingleRuleCompileMode())
    {
        Configlet routing_functions(compiler->fw,
                                    compiler->fw->getStr("host_OS"),
                                    "routing_functions");

        // we should delete default route if we have a new one to
        // install. IF user did not define any routes that look like
        // default (i.e. where destination is "any"), then we should
        // preserve default so that we won't leave machine with no
        // default at all.
        QString route_pattern = "";
        if (bsd_comp->have_default_route)
        {
            // If we will install default route, delete it now
            route_pattern = "'lo0'";
        } else
        {
            // do not delete default if we won't install new one
            route_pattern = "'lo0|default'";
        }

        routing_functions.setVariable("route_filter", route_pattern);
        compiler->output << routing_functions.expand().toStdString();

        bsd_comp->defined_restore_script_output = true;
    }
    

    for (deque<Rule*>::iterator k=tmp_queue.begin(); k!=tmp_queue.end(); ++k) 
    {
        RoutingRule *rule = RoutingRule::cast( *k );

        string rl = rule->getLabel();
    
        if (!compiler->inSingleRuleCompileMode() && rl!=current_rule_label)
        {
            compiler->output << "# " << endl;
            compiler->output << "# Rule " << rl << endl;
            //compiler->output << "# " << rule->getRuleTypeAsString() << endl;
            compiler->output << "# " << endl;
            compiler->output << "echo \"Routing rule " << rl << "\"" << endl;
            compiler->output << "# " << endl;
        }
    
        if (rule->getRuleType() != RoutingRule::MultiPath )
        {
            if (!compiler->inSingleRuleCompileMode() && rl!=current_rule_label)
            {
                QStringList comment = QString::fromUtf8(
                    rule->getComment().c_str()).split("\n");
                int comment_lines = 0;
                foreach (QString str, comment)
                {
                    if (!str.isEmpty())
                    {
                        compiler->output << "# " << str.toUtf8().data() << endl;
                        ++comment_lines;
                    }
                }
                if (comment_lines) compiler->output << "#" << endl;

                string err = compiler->getErrorsForRule(rule, "# ");
                if (!err.empty()) compiler->output << err << endl;

                current_rule_label = rl;
            }
        
//            string err = rule->getCompilerMessage();
//            if (!err.empty()) compiler->output << "# " << err << endl;

            string  command_line = RoutingRuleToString(rule);
            compiler->output << command_line;
    
        }
    }