LCOV - code coverage report
Current view: top level - src - ppg_event.c (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 26 27 96.3 %
Date: 2018-01-08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* Copyright 2017 noseglasses <shinynoseglasses@gmail.com>
       2             :  *
       3             :  * This program is free software: you can redistribute it and/or modify
       4             :  * it under the terms of the GNU Lesser General Public License as published by
       5             :  * the Free Software Foundation, either version 3 of the License, or
       6             :  * (at your option) any later version.
       7             :  *
       8             :  * This program is distributed in the hope that it will be useful,
       9             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      10             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      11             :  * GNU Lesser General Public License for more details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
      15             :  */
      16             : 
      17             : #include "ppg_event.h"
      18             : #include "detail/ppg_context_detail.h"
      19             : #include "detail/ppg_global_detail.h"
      20             : #include "detail/ppg_pattern_matching_detail.h"
      21             : #include "detail/ppg_signal_detail.h"
      22             : #include "ppg_debug.h"
      23             : // 
      24             : #include <stdbool.h>
      25             : 
      26             : /** @brief Checks if an arriving event can possibly be ignored
      27             :  */
      28         559 : static bool ppg_check_ignore_event(PPG_Event *event)
      29             : {  
      30             :    /* Check if the pattern is being aborted
      31             :     */
      32         559 :    if(   (ppg_context->abort_input == event->input)
      33           4 :       && (event->flags & PPG_Event_Active)) {
      34             :       
      35             :       // Mark the event as a control event
      36             :       // to ensure that corresponding deactivation of the
      37             :       // respective input is swallowed (i.e. not flushed)
      38             :       //
      39           2 :       event->flags |= PPG_Event_Considered;
      40             :    
      41             :       /* If a pattern is in progress, we abort it and consume the abort input.
      42             :        */
      43           2 :       if(ppg_context->current_token) {
      44             :          
      45           2 :          PPG_LOG("Abrt trggr\n");
      46             :          
      47           2 :          ppg_global_abort_pattern_matching();
      48             :          
      49           2 :          return true;
      50             :       }
      51             :    
      52           0 :       return true;
      53             :    }
      54             :    
      55         557 :    return false;
      56             : }
      57             : 
      58         786 : void ppg_event_process(PPG_Event *event)
      59             : {
      60         786 :    PPG_LOG("ppg_event_process\n");
      61         786 :    if(!ppg_context->properties.papageno_enabled) {
      62             :       
      63           6 :       PPG_LOG("ppg disabled\n");
      64           6 :       return;
      65             :    }
      66             :    
      67         780 :    PPG_LOG("Input 0x%d, active %d\n", event->input, 
      68             :               event->flags & PPG_Event_Active);
      69             :    
      70         780 :    ppg_timeout_check();
      71             :    
      72             :    // Register the time of arrival to check for timeout
      73             :    //
      74         780 :    ppg_context->time_manager.time(&ppg_context->time_last_event);
      75             :    
      76             :    
      77             : //    PPG_LOG("time: %ld\n", ppg_context->time_last_event);
      78             :    
      79         780 :    event = ppg_event_buffer_store_event(event);
      80             :    
      81             :    // If there are active tokens on the stack,
      82             :    // we allow them to consume the event without
      83             :    // storing it.
      84             :    //
      85         780 :    if(ppg_active_tokens_check_consumption(event)) {
      86             :       
      87         221 :       ppg_signal(PPG_On_Flush_Events);       
      88             : 
      89         221 :       ppg_delete_stored_events();
      90             :       
      91         221 :       return;
      92             :    }
      93             : 
      94         559 :    if(ppg_check_ignore_event(event)) {
      95           2 :       return;
      96             :    }
      97             : 
      98         557 :    ppg_pattern_matching_run();
      99             :    
     100         557 :    return;
     101             : }

Generated by: LCOV version 1.10