summaryrefslogtreecommitdiff
path: root/portland/dapi/tests/test_callbacks.c
blob: 6f4cd408d9621ff77617ab4ec6ed349af1d161f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <unistd.h>

#include <dapi/comm.h>
#include <dapi/calls.h>
#include <dapi/callbacks.h>

static void callback( DapiConnection* conn, int seq, int ord )
    {
    printf( "Order async: %d %d (%s)\n", seq, ord, ord == 0 ? "Failed" : ord == 1 ? "Ok/Cancel" : "Cancel/Ok" );
    }

int main()
    {
    int seq;
    DapiConnection* conn = dapi_connectAndInit();
    if( conn == NULL )
        {
        fprintf( stderr, "Cannot connect!\n" );
        return 1;
        }
    seq = dapi_callbackButtonOrder( conn, callback );
    printf( "Order call1: %d\n", seq );
    seq = dapi_callbackButtonOrder( conn, callback );
    printf( "Order call2: %d\n", seq );
    sleep( 1 ); /* give time to process */
    dapi_processData( conn );
    dapi_close( conn );
    return 0;
    }