Fri, 11 Dec 2020 04:12:45 -0600
Convert zephyr to gio
Remove `SO_BSDCOMPAT` which has been obsolete for 15+ years.
Remove unused `from` parameter in ZCheckAuthorization.
Make `zuid_addr` into its plain integral type, not `struct in_addr`.
Make `__HM_addr` into a `GSocketAddress`.
Use `GSocketAddress` for `Z_InputQ->from`.
Make `__My_addr` a `guint32` instead of `struct in_addr`.
Change `__Zephyr_port` into a `gint`.
Convert zephyr to `GSocket`.
Remove `hostaddr` argument to `ZhmStat`, as it's always `NULL`.
Use gio to determine self-address.
Use gio to print out bad packet information.
Cleanup remaining indents.
Testing Done:
compile only
Reviewed at https://reviews.imfreedom.org/r/261/
/* This file is part of the Project Athena Zephyr Notification System. * It contains the ZCheckIfNotice/select loop used for waiting for * a notice, with a timeout. * * Copyright (c) 1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file * "mit-copyright.h". */ #include "internal.h" #ifdef WIN32 #include <winsock2.h> #else #include <sys/socket.h> #endif Code_t Z_WaitForNotice(ZNotice_t *notice, int (*pred)(ZNotice_t *, void *), void *arg, int timeout) { Code_t retval; gint64 t0, tdiff, timeout_us; GError *error = NULL; retval = ZCheckIfNotice(notice, NULL, pred, (char *)arg); if (retval == ZERR_NONE) { return ZERR_NONE; } if (retval != ZERR_NONOTICE) { return retval; } timeout_us = timeout * G_USEC_PER_SEC; t0 = g_get_monotonic_time() + timeout_us; while (TRUE) { if (!g_socket_condition_timed_wait(ZGetSocket(), G_IO_IN, timeout_us, NULL, &error)) { gint ret = ZERR_INTERNAL; if (error->code == G_IO_ERROR_TIMED_OUT) { ret = ETIMEDOUT; } g_error_free(error); return ret; } retval = ZCheckIfNotice(notice, NULL, pred, (char *)arg); if (retval != ZERR_NONOTICE) { /* includes ZERR_NONE */ return retval; } tdiff = t0 - g_get_monotonic_time(); if (tdiff < 0) { return ETIMEDOUT; } /* g_socket_condition_timed_wait requires timeout to be an integral * number of milliseconds. */ timeout_us = (tdiff / 1000 + 1) * 1000; } /* NOTREACHED */ }