> For the complete documentation index, see [llms.txt](https://sandbox-docs.verifone.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/files/dir_30aba3d9bf6279a25d84abe4015711f7/dir_f7a957c8f5c8e80b5a8d4b37f193d419/dir_29538a2bbdfe557780da3549d4f67715/_event_scheduler_8c.md).

# EventScheduler.c

[Data Structures](#nested-classes) | [Macros](#define-members) | [Typedefs](#typedef-members) | [Enumerations](#enum-members) | [Functions](#func-members) | [Variables](#var-members)

`#include <errno.h>` `#include <pthread.h>` `#include <fcntl.h>` `#include <libgen.h>` `#include <memory.h>` `#include <signal.h>` `#include <sys/time.h>` `#include <sys/wait.h>` `#include <ucontext.h>` `#include <unistd.h>` `#include <sys/ipc.h>` `#include <sys/msg.h>` `#include <stdarg.h>` `#include <stdio.h>` `#include <stdlib.h>` `#include <svc.h>` `#include "EventScheduler.h"` `#include "EventSchedulerLcl.h"` `#include "VHQFileNames.h"` `#include "VHQConfig.h"` `#include "VHQDebug.h"` `#include "VHQDownloader.h"` `#include "VHQManager.h"` `#include "VHQTypes.h"` `#include "VHQUtils.h"` `#include "VHQSecurity.h"`

Include dependency graph for EventScheduler.c:

![](/files/JViMjdw65G3IxoejHOIK)

|                 |                                                   |
| --------------- | ------------------------------------------------- |
| Data Structures |                                                   |
| struct          | [\_running\_event\_t](#struct__running__event__t) |
| struct          | [callback\_stack\_t](#structcallback__stack__t)   |

|         |                                                                                           |
| ------- | ----------------------------------------------------------------------------------------- |
| Macros  |                                                                                           |
| #define | [MAX\_CONCURRENT\_EVENTS](#a3221a640df87591a436a0460df732805)   1                         |
| #define | [REBOOT\_EVENT\_AFTER\_LAST\_DL\_IN\_OP\_SET](#a0981eccd00e4beb9bf10a1590b13b7fc)   1     |
| #define | [MIDNIGHT](#abc7899affd386ef7900c847dbeeab4a3)   (24 \* 3600)                             |
| #define | [SEVENTY\_YEAR\_OFFSET](#ad9407057ca0915cb462e0d98758aea98)   (2208988800)                |
| #define | [PRINT\_EVENT\_SET\_TABLE](#a42e50623ecd2ee20af7f9286e4bcb05c)(a)   PrintEventSetTable(a) |
| #define | [COMPARE\_EVENT\_SET\_TABLE\_DEBUG](#ac967252b2d9e29dc063628edf75d95e8)   0               |
| #define | [COMPARE\_EVENT\_SET\_TABLE\_DEBUG\_PRINT](#a15f7090c0c71a6af42ae3c65a00ac978)(arg...)    |
| #define | [NO\_EVENTS\_TABLES](#aee19e14cf1f6312bfa7f2a830780988c)   3                              |
| #define | [EVENTS\_TABLE\_FILE\_LENGTH](#a5d7041cb075a605241316790da5e151a)   64                    |
| #define | [DEFAULT\_WAIT](#a49cc942bb646de5cedadd52be0c431d8)   (86400)                             |

|                                                                  |                                                         |
| ---------------------------------------------------------------- | ------------------------------------------------------- |
| Typedefs                                                         |                                                         |
| typedef struct [\_running\_event\_t](#struct__running__event__t) | [running\_event\_t](#ae183d296904392aef11d467e7a38b037) |

|              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Enumerations |                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| enum         | [process\_event\_sets\_state\_t](#a3363138f7723e04024b5d5d5e1ab714c) { [PES\_STATE\_INITIAL](#a3363138f7723e04024b5d5d5e1ab714ca311161859d03acceaa61f305d774057c), [PES\_STATE\_RUNNING](#a3363138f7723e04024b5d5d5e1ab714ca7db86ccd7727481416bbab7357114086), [PES\_STATE\_EVENT\_COMPLETED](#a3363138f7723e04024b5d5d5e1ab714caffdbbb3cb31ee0e837b06cd1ae24a277), [PES\_STATE\_COMPLETED](#a3363138f7723e04024b5d5d5e1ab714ca06d29cab2f4173ba4ded51e52268cb63) } |

|                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Functions         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| void              | [SaveEventSetTable](#adb8fb5cd2323a175072341c00457351a) (void)                                                                                                                                                                                                                                                                                                                                                                                                                             |
|                   | <p>Save the event set table for restoration after rebooting. <a href="#adb8fb5cd2323a175072341c00457351a">More...</a><br></p>                                                                                                                                                                                                                                                                                                                                                              |
| bool              | [RestoreEventSetTable](#ac9194966fa7b39016bdcb3afc619679b) (void)                                                                                                                                                                                                                                                                                                                                                                                                                          |
|                   | <p>Restore the event set table at start. <a href="#ac9194966fa7b39016bdcb3afc619679b">More...</a><br></p>                                                                                                                                                                                                                                                                                                                                                                                  |
| void \*           | [EventSchedulerInitCallbackTable](#a7101b4a88f78442eda98f6365281a281) (char \*pszOperatingMode)                                                                                                                                                                                                                                                                                                                                                                                            |
| void              | [sighandler](#af527a44de9de12ab2d86fe582a05d77d) (int signum, siginfo\_t \*siginfo, void \*context)                                                                                                                                                                                                                                                                                                                                                                                        |
| bool              | [GetTimerExpired](#abd02a5cf4a023f80830bba89001a2c45) ()                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| char \*           | [pesStateToStr](#a7751718dbb8453224e713da617123c91) ([process\_event\_sets\_state\_t](#a3363138f7723e04024b5d5d5e1ab714c) state)                                                                                                                                                                                                                                                                                                                                                           |
| bool              | [ProcessEventSets](#a5a8c06a47fd796c525bd85b4c1c120be) (void)                                                                                                                                                                                                                                                                                                                                                                                                                              |
|                   | <p>Calls the appropriate callbacks for event sets that have expired. <a href="#a5a8c06a47fd796c525bd85b4c1c120be">More...</a><br></p>                                                                                                                                                                                                                                                                                                                                                      |
| void \*           | [EventScheduler](#a3d853fa6f31e30c35451a53624dba4bc) (void \*pvData)                                                                                                                                                                                                                                                                                                                                                                                                                       |
|                   | <p>The event sheduler task's main loop. <a href="#a3d853fa6f31e30c35451a53624dba4bc">More...</a><br></p>                                                                                                                                                                                                                                                                                                                                                                                   |
| bool              | [EventSchedulerInitialized](#aeece40defaff577942adebc7b45ca072) (void)                                                                                                                                                                                                                                                                                                                                                                                                                     |
| event\_set\_id\_t | [ScheduleEventSet](#aa57f4ac0d537b9a86d73ec930bd3f6ff) (bool bRecurring, long int dwFirstRun, recur\_unit\_t recurUnits, uint32 dwRecurPeriod, long int tExpiration, uint32 dwRetryFreq, uint32 opSetId, operation\_set\_event\_t psOpSetData\[], uint32 dwOpSetDataArraySize, event\_set\_id\_t dependency\_event\_set\_id, event\_timer\_t timerType, char \*pszServerInstance, pre\_post\_callback\_t preEventCbType, pre\_post\_callback\_t postEventCbType, bool keyExchangeEventSet) |
| bool              | [CancelEventSet](#a636ae0e877282dcaf7cbd4c07a0245aa) (event\_set\_id\_t event\_set\_id, bool cancel\_dependent\_events)                                                                                                                                                                                                                                                                                                                                                                    |
|                   | <p>Cancels a pending event set. <a href="#a636ae0e877282dcaf7cbd4c07a0245aa">More...</a><br></p>                                                                                                                                                                                                                                                                                                                                                                                           |
| vhq\_result\_t    | [CancelEventSetByOpId](#aebd0382eb19a81b27e1c9ef11fc120c9) (uint32 opSetId)                                                                                                                                                                                                                                                                                                                                                                                                                |
|                   | <p>Cancels a pending event set by Operation Set ID. <a href="#aebd0382eb19a81b27e1c9ef11fc120c9">More...</a><br></p>                                                                                                                                                                                                                                                                                                                                                                       |
| uint32            | [GetInitialTimerVal](#a804732cf9ec603753125a9b245a9403a) (void)                                                                                                                                                                                                                                                                                                                                                                                                                            |
| void              | [LockEventScheduler](#adfedf406d19d3898937515904e7d51b7) (bool lock)                                                                                                                                                                                                                                                                                                                                                                                                                       |
| bool              | [FileRequiredByEvent](#a46943f46089fd5eb8a237716175913a7) (char \*fn)                                                                                                                                                                                                                                                                                                                                                                                                                      |
| bool              | [DownloadOpSetInProgress](#a631a4c3b4f0ebc1276e4c1d47edbe4e1) (void)                                                                                                                                                                                                                                                                                                                                                                                                                       |
| char \*           | [GetOperationIdForEvent](#afe2c1c65af7f47fd1d2cf5a7530b6e24) (int event\_set\_index, int event\_index)                                                                                                                                                                                                                                                                                                                                                                                     |
| void              | [SetCompleteFlag](#ad0cd9982744732224a6013e8fd151798) (uint32 opSetId, char \*OpId, bool continuation\_required, bool event\_failed)                                                                                                                                                                                                                                                                                                                                                       |
| char \*           | [GetApprovalMaskStr](#ae6f45f5cc5d402c19c4b2df33bee1e81) (uint32 approval\_mask)                                                                                                                                                                                                                                                                                                                                                                                                           |
| void              | [SetApprovalFlag](#ac77a2f156fc9f0918d2cda0c03c1fa54) (event\_set\_id\_t event\_set\_id, event\_id\_t event\_id, uint32 approval\_mask)                                                                                                                                                                                                                                                                                                                                                    |
| bool              | [GetApprovalFlag](#a778d644cbc58b0ce5c6b0e8bd9c5d2c1) (uint32 opSetId, char \*OpId, uint32 mask, bool \*isLastOp)                                                                                                                                                                                                                                                                                                                                                                          |
| bool              | [GetExecutingIndex](#ab392c94911089845c07106149f73ec14) (uint32 opSetId, int \*executing\_index)                                                                                                                                                                                                                                                                                                                                                                                           |
| void              | [SetEventSchedulerTimerExpired](#a28073f69e1f658a77b057767fdf7b835) (bool timer\_exp\_val)                                                                                                                                                                                                                                                                                                                                                                                                 |
| void              | [StartEventTimer](#a2c86faa3034cd8aab63a89938a343b67) (struct itimerval new\_tv)                                                                                                                                                                                                                                                                                                                                                                                                           |
| bool              | [EventSchedulerLock](#acb96fb6bd0a10104911786099b314728) (int timeout)                                                                                                                                                                                                                                                                                                                                                                                                                     |
| bool              | [EventSchedulerUnlock](#a8b01e29bab2ffcf325b32a95099f8b17) (void)                                                                                                                                                                                                                                                                                                                                                                                                                          |
| uint32            | [GetSecondsToNextEvent](#a2603fd407a7ba480eb8866dff44ca031) (bool include\_running\_event)                                                                                                                                                                                                                                                                                                                                                                                                 |
| void              | [EventSchedulerPetWatchdog](#a8581bcdb463e7813aa8d368849615e60) (event\_set\_id\_t event\_set\_id, event\_id\_t event\_id)                                                                                                                                                                                                                                                                                                                                                                 |
| time\_t           | [GetEventExpiryTime](#a953cb45f15b2265f216ed87cb8458755) (event\_set\_id\_t event\_set\_id, event\_timer\_t timer\_type)                                                                                                                                                                                                                                                                                                                                                                   |
| bool              | [ClearInstanceEventSetsTable](#ad4b45621db77089dbe5d01ffa6a4899d) (char \*serverInstance, bool isForKeysExchangeReset)                                                                                                                                                                                                                                                                                                                                                                     |
| void              | [ClearEventsTable](#a11aeaec936d5c12e593b97f47d6e4681) (void)                                                                                                                                                                                                                                                                                                                                                                                                                              |

|                                                 |                                                                      |
| ----------------------------------------------- | -------------------------------------------------------------------- |
| Variables                                       |                                                                      |
| const struct timespec                           | [MONITOR\_THREAD\_CHECK\_PERIOD](#aacb56063e96dd2e3d1a27deaa2e1af42) |
| int                                             | [request\_Qid](#a3b2dcf74e5db5d8dded9b16f4877ea02)                   |
| int                                             | [response\_Qid](#a06d9180560d76eb8df03478b85303c47)                  |
| EventSchedulerCB                                | [acbCallbackTable](#a0417615202a7745f4128557a901ac04b) \[]           |
| [callback\_stack\_t](#structcallback__stack__t) | [callback\_stack](#a0b9b4750a3fb18238a741fb731af3552) \[cbMAXTypes]  |

### DetailedDescription <a href="#detailed-description" id="detailed-description"></a>

Main [Event](/adk-5.0-programmers-guide/readme/files/dir_1e776ad494434554ed2e1a73460819d8/dir_dc5dfd6157a1d65d3f69cd65a617f88c/libevt_8h.md#struct_event) Scheduler operations

***

### DataStructure Documentation <a href="#data-structure-documentation" id="data-structure-documentation"></a>

### \_running\_event\_t <a href="#struct__running__event__t" id="struct__running__event__t"></a>

struct \\\_running\_event\_t

|                       |                   |   |
| --------------------- | ----------------- | - |
| Data Fields           |                   |   |
| event\_thread\_arg \* | arg\_p            |   |
| callback\_t           | eCallback         |   |
| event\_id\_t          | event\_id         |   |
| event\_set\_id\_t     | event\_set\_id    |   |
| time\_t               | expire\_time      |   |
| bool                  | in\_use           |   |
| bool                  | release\_instance |   |
| time\_t               | start\_time       |   |
| event\_result\_t      | static\_result    |   |
| event\_result\_t      | status            |   |
| pthread\_t            | thread\_id        |   |
| pthread\_mutex\_t     | wd\_mutex         |   |

### callback\_stack\_t <a href="#structcallback__stack__t" id="structcallback__stack__t"></a>

struct callback\_stack\_t

|                             |          |   |
| --------------------------- | -------- | - |
| Data Fields                 |          |   |
| pre\_post\_event\_result\_t | cbResult |   |
| pre\_post\_callback\_t      | cbType   |   |

### MacroDefinition Documentation <a href="#macro-definition-documentation" id="macro-definition-documentation"></a>

### COMPARE\_EVENT\_SET\_TABLE\_DEBUG <a href="#ac967252b2d9e29dc063628edf75d95e8" id="ac967252b2d9e29dc063628edf75d95e8"></a>

\#define COMPARE\_EVENT\_SET\_TABLE\_DEBUG   0

### COMPARE\_EVENT\_SET\_TABLE\_DEBUG\_PRINT <a href="#a15f7090c0c71a6af42ae3c65a00ac978" id="a15f7090c0c71a6af42ae3c65a00ac978"></a>

\#define COMPARE\_EVENT\_SET\_TABLE\_DEBUG\_PRINT

### DEFAULT\_WAIT <a href="#a49cc942bb646de5cedadd52be0c431d8" id="a49cc942bb646de5cedadd52be0c431d8"></a>

\#define DEFAULT\_WAIT   (86400)

### EVENTS\_TABLE\_FILE\_LENGTH <a href="#a5d7041cb075a605241316790da5e151a" id="a5d7041cb075a605241316790da5e151a"></a>

\#define EVENTS\_TABLE\_FILE\_LENGTH   64

### MAX\_CONCURRENT\_EVENTS <a href="#a3221a640df87591a436a0460df732805" id="a3221a640df87591a436a0460df732805"></a>

\#define MAX\_CONCURRENT\_EVENTS   1

### MIDNIGHT <a href="#abc7899affd386ef7900c847dbeeab4a3" id="abc7899affd386ef7900c847dbeeab4a3"></a>

\#define MIDNIGHT   (24 \\\* 3600)

Local definitions

### NO\_EVENTS\_TABLES <a href="#aee19e14cf1f6312bfa7f2a830780988c" id="aee19e14cf1f6312bfa7f2a830780988c"></a>

\#define NO\_EVENTS\_TABLES   3

### PRINT\_EVENT\_SET\_TABLE <a href="#a42e50623ecd2ee20af7f9286e4bcb05c" id="a42e50623ecd2ee20af7f9286e4bcb05c"></a>

\#define PRINT\_EVENT\_SET\_TABLE

Local functions

### REBOOT\_EVENT\_AFTER\_LAST\_DL\_IN\_OP\_SET <a href="#a0981eccd00e4beb9bf10a1590b13b7fc" id="a0981eccd00e4beb9bf10a1590b13b7fc"></a>

\#define REBOOT\_EVENT\_AFTER\_LAST\_DL\_IN\_OP\_SET   1

### SEVENTY\_YEAR\_OFFSET <a href="#ad9407057ca0915cb462e0d98758aea98" id="ad9407057ca0915cb462e0d98758aea98"></a>

\#define SEVENTY\_YEAR\_OFFSET   (2208988800)

### TypedefDocumentation <a href="#typedef-documentation" id="typedef-documentation"></a>

### running\_event\_t <a href="#ae183d296904392aef11d467e7a38b037" id="ae183d296904392aef11d467e7a38b037"></a>

typedef struct \[\\\_running\_event\_t]\(#struct\_\_running\_\_event\_\_t) \[running\_event\_t]\(#ae183d296904392aef11d467e7a38b037)

### EnumerationType Documentation <a href="#enumeration-type-documentation" id="enumeration-type-documentation"></a>

### process\_event\_sets\_state\_t <a href="#a3363138f7723e04024b5d5d5e1ab714c" id="a3363138f7723e04024b5d5d5e1ab714c"></a>

enum \[process\_event\_sets\_state\_t]\(#a3363138f7723e04024b5d5d5e1ab714c)

|                              |   |
| ---------------------------- | - |
| Enumerator                   |   |
| PES\_STATE\_INITIAL          |   |
| PES\_STATE\_RUNNING          |   |
| PES\_STATE\_EVENT\_COMPLETED |   |
| PES\_STATE\_COMPLETED        |   |

### FunctionDocumentation <a href="#function-documentation" id="function-documentation"></a>

### CancelEventSet() <a href="#a636ae0e877282dcaf7cbd4c07a0245aa" id="a636ae0e877282dcaf7cbd4c07a0245aa"></a>

bool CancelEventSet

Cancels a pending event set.

**Parameters**

**event\_set\_id** - the ID of the event set to cancel **cancel\_dependent\_events** - whether to cancel events that depend on this event set

#### Returns

TRUE if successful, FALSE otherwise

### CancelEventSetByOpId() <a href="#aebd0382eb19a81b27e1c9ef11fc120c9" id="aebd0382eb19a81b27e1c9ef11fc120c9"></a>

vhq\_result\_t CancelEventSetByOpId

Cancels a pending event set by Operation Set ID.

**Parameters**

**opSetId** - the Operation Set ID of the event to cancel

#### Returns

vhq\_result\_t from VHQTypes.h

### ClearEventsTable() <a href="#a11aeaec936d5c12e593b97f47d6e4681" id="a11aeaec936d5c12e593b97f47d6e4681"></a>

void ClearEventsTable

This function calls [ClearInstanceEventSetsTable()](#ad4b45621db77089dbe5d01ffa6a4899d) and sets Device Registration.

### ClearInstanceEventSetsTable() <a href="#ad4b45621db77089dbe5d01ffa6a4899d" id="ad4b45621db77089dbe5d01ffa6a4899d"></a>

bool ClearInstanceEventSetsTable

This function removes an event set with a given server instance and update the event table.

**Parameters**

\[in] **serverInstance** = server instance \[in] **isForKeysExchangeReset** = TRUE, if it is for a key exchange reset.

#### Returns

TRUE, if event set cleared.

### DownloadOpSetInProgress() <a href="#a631a4c3b4f0ebc1276e4c1d47edbe4e1" id="a631a4c3b4f0ebc1276e4c1d47edbe4e1"></a>

bool DownloadOpSetInProgress

This function searches for a download operation set in running events.

#### Returns

TRUE, if download event is present.

### EventScheduler() <a href="#a3d853fa6f31e30c35451a53624dba4bc" id="a3d853fa6f31e30c35451a53624dba4bc"></a>

void \\\* EventScheduler

The event sheduler task's main loop.

**Parameters**

**pvData** - void\* pointer used in pthread\_create functions

#### Returns

should never return

### EventSchedulerInitCallbackTable() <a href="#a7101b4a88f78442eda98f6365281a281" id="a7101b4a88f78442eda98f6365281a281"></a>

void\\\* EventSchedulerInitCallbackTable

This function initializes the event scheduler callback table to launch an event.

**Parameters**

\[in] **pszOperatingMode** = operating mode

#### Returns

pointer to callback table.

### EventSchedulerInitialized() <a href="#aeece40defaff577942adebc7b45ca072" id="aeece40defaff577942adebc7b45ca072"></a>

bool EventSchedulerInitialized

This function checks whether event scheduler is initialized or not and returns the status; TRUE, if initialized.

#### Returns

TRUE, if event scheduler is initialized.

### EventSchedulerLock() <a href="#acb96fb6bd0a10104911786099b314728" id="acb96fb6bd0a10104911786099b314728"></a>

bool EventSchedulerLock

This function tries to lock the event scheduler mutex, event\_sched\_lock\_mutex.

**Parameters**

\[in] **timeout** = timeout to lock the event scheduler mutex.

#### Returns

TRUE, if locked.

### EventSchedulerPetWatchdog() <a href="#a8581bcdb463e7813aa8d368849615e60" id="a8581bcdb463e7813aa8d368849615e60"></a>

void EventSchedulerPetWatchdog

This function sets the watchdog timer for an event.

**Parameters**

\[in] **event\_set\_id** = event set ID \[in] **event\_id** = event ID of the event

#### Returns

void

### EventSchedulerUnlock() <a href="#a8b01e29bab2ffcf325b32a95099f8b17" id="a8b01e29bab2ffcf325b32a95099f8b17"></a>

bool EventSchedulerUnlock

### FileRequiredByEvent() <a href="#a46943f46089fd5eb8a237716175913a7" id="a46943f46089fd5eb8a237716175913a7"></a>

bool FileRequiredByEvent

This function checks if a file is required by any of the download events in event set table.

**Parameters**

\[in] **fn** = filename

#### Returns

TRUE, if required.

### GetApprovalFlag() <a href="#a778d644cbc58b0ce5c6b0e8bd9c5d2c1" id="a778d644cbc58b0ce5c6b0e8bd9c5d2c1"></a>

bool GetApprovalFlag

This function checks for the pre approval mask for events.

**Parameters**

\[in] **opSetId** = operation set ID \[in] **OpId** = operation ID \[in] **mask** = mask to be checked. \[out] **isLastOp** = flag to be set true in case of Last Op in the Set

#### Returns

TRUE, if mask matches.

### GetApprovalMaskStr() <a href="#ae6f45f5cc5d402c19c4b2df33bee1e81" id="ae6f45f5cc5d402c19c4b2df33bee1e81"></a>

char\\\* GetApprovalMaskStr

### GetEventExpiryTime() <a href="#a953cb45f15b2265f216ed87cb8458755" id="a953cb45f15b2265f216ed87cb8458755"></a>

time\_t GetEventExpiryTime

This function gets event expire time

**Parameters**

\[in] **event\_set\_id** = event set ID \[in] **event\_id** = event ID of the event \[in] **time\_type** = RTC or DATE/TIME

#### Returns

[Event](/adk-5.0-programmers-guide/readme/files/dir_1e776ad494434554ed2e1a73460819d8/dir_dc5dfd6157a1d65d3f69cd65a617f88c/libevt_8h.md#struct_event) expiry date in RTC or DATE/TIME

### GetExecutingIndex() <a href="#ab392c94911089845c07106149f73ec14" id="ab392c94911089845c07106149f73ec14"></a>

bool GetExecutingIndex

This function to get executing index in a set.

**Parameters**

\[in] **opSetId** = operation set ID \[out] **executing\_index** = Index of current executing event

#### Returns

TRUE, if OpSetId matches.

### GetInitialTimerVal() <a href="#a804732cf9ec603753125a9b245a9403a" id="a804732cf9ec603753125a9b245a9403a"></a>

uint32 GetInitialTimerVal

### GetOperationIdForEvent() <a href="#afe2c1c65af7f47fd1d2cf5a7530b6e24" id="afe2c1c65af7f47fd1d2cf5a7530b6e24"></a>

char\\\* GetOperationIdForEvent

This function returns the opeartion ID of an event in an event set.

**Parameters**

\[in] **event\_set\_index** = event set index in event table. \[in] **event\_index** = event index in event set.

#### Returns

operation ID.

### GetSecondsToNextEvent() <a href="#a2603fd407a7ba480eb8866dff44ca031" id="a2603fd407a7ba480eb8866dff44ca031"></a>

uint32 GetSecondsToNextEvent

This function returns the number of seconds to execute the next event.If next event is a recurring event, the recurring frequency is returned.

**Parameters**

\[in] **ignore\_executing\_event** =TRUE, to ignore executing event when calculating the time to next event.

#### Returns

uint32 seconds to next event.

### GetTimerExpired() <a href="#abd02a5cf4a023f80830bba89001a2c45" id="abd02a5cf4a023f80830bba89001a2c45"></a>

bool GetTimerExpired

### LockEventScheduler() <a href="#adfedf406d19d3898937515904e7d51b7" id="adfedf406d19d3898937515904e7d51b7"></a>

void LockEventScheduler

### pesStateToStr() <a href="#a7751718dbb8453224e713da617123c91" id="a7751718dbb8453224e713da617123c91"></a>

char\\\* pesStateToStr

### ProcessEventSets() <a href="#a5a8c06a47fd796c525bd85b4c1c120be" id="a5a8c06a47fd796c525bd85b4c1c120be"></a>

bool ProcessEventSets

Calls the appropriate callbacks for event sets that have expired.

#### Returns

TRUE if successful, FALSE oterwise

### RestoreEventSetTable() <a href="#ac9194966fa7b39016bdcb3afc619679b" id="ac9194966fa7b39016bdcb3afc619679b"></a>

void RestoreEventSetTable

Restore the event set table at start.

#### Returns

None: on failure, simply run as if no scheduled events are present

### SaveEventSetTable() <a href="#adb8fb5cd2323a175072341c00457351a" id="adb8fb5cd2323a175072341c00457351a"></a>

static void SaveEventSetTable

Save the event set table for restoration after rebooting.

#### Returns

None

### ScheduleEventSet() <a href="#aa57f4ac0d537b9a86d73ec930bd3f6ff" id="aa57f4ac0d537b9a86d73ec930bd3f6ff"></a>

event\_set\_id\_t ScheduleEventSet

This function is used by outside processes to schedule operation sets for now or the future

**Parameters**

\[in] **bRecurring** - boolean indicating if this event is recurring \[in] **dwFirstRun** - seconds until the callback should be run the first time (0 = now) \[in] **recurUnits** - recurring unit of event \[in] **dwRecurPeriod** - period of recurrence \[in] **tExpiration** - expiration of the event \[in] **dwRetryFreq** - How often to retry the first attempt in case of a failure (in seconds, 0 = no retry) \[in] **opSetId** - operation ID. \[in] **psOpSetData** - an array of operations that will be performed in this operation set \[in] **dwOpSetDataArraySize** - number of operations in the operation set array \[in] **dependency\_event\_set\_id** - if this depends on another event (like install later) then this event will be cancelled if the dependency event fails \[in] **timerType** - RTC or date/time - RTC events will not be affected if the system clock changes \[in] **pszServerInstance** - the server instance that this event set is scheduled for \[in] **preEventCbType** - used for pre-event callbacks that are common across all events in the event set like CommNetConnect, etc. \[in] **postEventCbType** - used for post-event callbacks that are common across all events in the event set like CommNetDisconnect, etc. \[in] **keyExchangeEventSet** - used to determine when "Device Registration Mode" is completed

#### Returns

event\_set\_id\_t, The new event\_id for the operation set that was just added

### SetApprovalFlag() <a href="#ac77a2f156fc9f0918d2cda0c03c1fa54" id="ac77a2f156fc9f0918d2cda0c03c1fa54"></a>

void SetApprovalFlag

This function set a pre-approval mask to a download event and saves the event table.

**Parameters**

\[in] **event\_set\_id** = event set ID of event \[in] **event\_id** = event ID of event \[in] **approval\_mask** = approval mask to set

#### Returns

void

### SetCompleteFlag() <a href="#ad0cd9982744732224a6013e8fd151798" id="ad0cd9982744732224a6013e8fd151798"></a>

void SetCompleteFlag

This function saves the executing flag with continue/complete, when there is a chance of losing executing flag because of a reboot after a download or install operation

**Parameters**

\[in] **opSetId** = operation set ID of event \[in] **OpId** = operation ID \[in] **continuation\_required** = TRUE, if continuation required for operation.

#### Returns

void

### SetEventSchedulerTimerExpired() <a href="#a28073f69e1f658a77b057767fdf7b835" id="a28073f69e1f658a77b057767fdf7b835"></a>

void SetEventSchedulerTimerExpired

### sighandler() <a href="#af527a44de9de12ab2d86fe582a05d77d" id="af527a44de9de12ab2d86fe582a05d77d"></a>

void sighandler

This function handles a particular signal.

**Parameters**

\[in] **signum** = The number of the signal that caused invocation of the handler. \[in] **siginfo** = which is a structure containing further information about the signal \[in] **context** = contains signal context information that was saved on the user-space stack by the kernel.

#### Returns

none

### StartEventTimer() <a href="#a2c86faa3034cd8aab63a89938a343b67" id="a2c86faa3034cd8aab63a89938a343b67"></a>

void StartEventTimer

This function starts a timer to wakeup.In low power mode, we should make sure we use the [sys\_SetWakeupTime()](/adk-5.0-programmers-guide/readme/modules/group___power/namespacevfisyspm.md#ab6864fd6fce20f5e804d9a9a6fe01239) API so that we get woken up from deep sleep state.

**Parameters**

\[in] **new\_tv** = value to set the timer with.

#### Returns

void

### VariableDocumentation <a href="#variable-documentation" id="variable-documentation"></a>

### acbCallbackTable <a href="#a0417615202a7745f4128557a901ac04b" id="a0417615202a7745f4128557a901ac04b"></a>

EventSchedulerCB acbCallbackTable\\\[\\]

**Initial value:**

```cpp
= { LaunchDownloader, GetDataProcessor,
   SetDataProcessor, TermActProcessor, FileUploader, Heartbeat,
   GetDiagDataProcessor, AppActionProcessor, DelFileProcessor,
   DeviceEventProcessor, GetParamUpdateProcessor, GetSwUpdateProcessor, }
```

### callback\_stack <a href="#a0b9b4750a3fb18238a741fb731af3552" id="a0b9b4750a3fb18238a741fb731af3552"></a>

\[callback\_stack\_t]\(#structcallback\_\_stack\_\_t) callback\_stack\\\[cbMAXTypes\\]

### MONITOR\_THREAD\_CHECK\_PERIOD <a href="#aacb56063e96dd2e3d1a27deaa2e1af42" id="aacb56063e96dd2e3d1a27deaa2e1af42"></a>

const struct timespec MONITOR\_THREAD\_CHECK\_PERIOD

**Initial value:**

```cpp
= { .tv_sec = 0, .tv_nsec =
   50000000 }
```

### request\_Qid <a href="#a3b2dcf74e5db5d8dded9b16f4877ea02" id="a3b2dcf74e5db5d8dded9b16f4877ea02"></a>

int request\_Qid

### response\_Qid <a href="#a06d9180560d76eb8df03478b85303c47" id="a06d9180560d76eb8df03478b85303c47"></a>

int response\_Qid


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/files/dir_30aba3d9bf6279a25d84abe4015711f7/dir_f7a957c8f5c8e80b5a8d4b37f193d419/dir_29538a2bbdfe557780da3549d4f67715/_event_scheduler_8c.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
