Man Linux: Main Page and Category List

NAME

       YGetNextEvent - event retrieving

SYNTAX

       #include <Y2/Y.h>
       #include <Y2/Ylib.h>

       int YGetNextEvent(
               YConnection *connection,
               YEvent *event,
               Boolean block
       )

ARGUMENTS

       connection
              Specifies  the connection to the Y server, obtained by a call to
              YOpenConnection.

       event  Specifies the event buffer in which to copy the retrieved  event
              values  to. event cannot be a NULL pointer.  See YEvent for more
              information about this structure.

       block  If set to True,  then  specifies  that  the  call  should  block
              execution untill an event is obtained.

DESCRIPTION

       The  YGetNextEvent  function  gets  the  next (oldest or latest, if you
       will) event from the Y server.

       If block is set to True, then the call will block untill  an  event  is
       received.

       If  block  is  set  to False, then the call will check if there are any
       events queued.  If  there  is  atleast  one  queued  event  (being  the
       next/oldest/latest),  its  values will be coppied to the buffer pointed
       to by event and the function will return 1. If there were no events  in
       the queue, then the function returns 0.

       If  you  receive  a  YDisconnect  or  YShutdown  event  then  the given
       YConnection con structure’s connection  would  have  been  closed.  You
       should call YCloseConnection on it immediatly afterwards to deallocated
       the structure formally.

RETURN VALUE

       The YGetNextEvent function returns the number of events received or  0.

EXAMPLE

       #include <stdio.h>
       #include <Y2/Y.h>
       #include <Y2/Ylib.h>

       int main(int argc, char *argv[])
       {
               YEvent event;
               YConnection *con = YOpenConnection(
                       "/usr/sbin/starty",
                       "127.0.0.1:9433"
               );
               if(con == NULL)
                       return(1);

               printf("Waiting for event...\n");

               if(YGetNextEvent(
                       con, &event, True
               ) > 0)
                       printf(
                               "Got event type %i\n",
                               event.type
                       );

               printf("Done.\n");

               YCloseConnection(con, False);

               return(0);
       }

SEE ALSO

       YEvent(3) YPutBackEvent(3)