/******************************************************************************/ int
main(int argc, char **argv)
{ int result = 0; int changes = 10; int fd; struct log_config *lc;
if ((lc = log_config_init_for_console(LOG_LEVEL_DEBUG, NULL)) != NULL)
{
log_start_from_param(lc);
}
if (argc > 1 && atoi(argv[1]) >= 0)
{
changes = atoi(argv[1]); if (changes > 1000)
{
changes = 1000; // Use 0 for more than this
}
} if (changes > 0)
{
printf("Connection monitor : exiting after %d state changes\n", changes);
} else
{
printf("Connection monitor\n");
}
print_current_connection_state();
if (!WTSRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, &fd, 0, NULL))
{
result = 1; // Error occurred (should be logged)
} else
{ int count = 0; while (result == 0)
{ struct pollfd pollarg =
{
.fd = fd,
.events = (POLLIN | POLLERR),
.revents = 0
}; int pollstat;
LRESULT cbresult;
if (changes > 0 && count >= changes)
{ break;
}
if ((pollstat = poll(&pollarg, 1, -1)) < 0)
{
printf("** Error from poll() : %s\n", strerror(errno));
result = 1;
} elseif (pollstat == 0)
{
printf("** Timeout from poll() !?\n");
result = 1;
} elseif ((pollarg.revents & POLLERR))
{
printf("** File descriptor was closed\n");
result = 1;
} elseif (!WTSGetDispatchMessage(&count, callback, &cbresult))
{
printf("** Unexpected faiure to dispatch message\n");
result = 1;
} elseif (!cbresult)
{
printf("** Callback failed\n");
result = 1;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.