src/sync_driver.c
author Roker <roker@pep-project.org>
Tue, 27 Sep 2016 21:36:31 +0200
branchkeysync
changeset 1201 571f488333be
parent 1162 f8db5c47b7f3
child 1445 5d233bcdde76
permissions -rw-r--r--
add "-luuid" to LDFLAGS due to linker errors on Ubuntu
     1 // Driver for DeviceState state machine
     2 
     3 #include <assert.h>
     4 #include "pEp_internal.h"
     5 
     6 
     7 DYNAMIC_API PEP_STATUS fsm_DeviceState_inject(
     8         PEP_SESSION session,
     9         DeviceState_event event,
    10         Identity partner,
    11         void *extra
    12     )
    13 {
    14     assert(session);
    15     if (!session)
    16         return PEP_ILLEGAL_VALUE;
    17 
    18     while(true)
    19     {
    20         DeviceState_state new_state = fsm_DeviceState(session,
    21             session->sync_state, event, partner, extra);
    22 
    23         if (new_state == DeviceState_state_invalid_out_of_memory)
    24             return PEP_OUT_OF_MEMORY;
    25 
    26         if (new_state < 0)
    27             return PEP_SYNC_STATEMACHINE_ERROR - new_state;
    28         
    29         if (new_state == session->sync_state)
    30             break;
    31 
    32         event = Init;
    33         extra = NULL;
    34         session->sync_state = new_state;
    35     } 
    36 
    37     return PEP_STATUS_OK;
    38 }
    39