- if (0 > (rc = tids_send_response(tids, conn, &gssctx, resp))) {
- fprintf(stderr, "Error from tids_send_response(), rc = %d.\n", rc);
- return;
+/**
+ * Create a new TIDS instance
+ *
+ * Deprecated: exists for ABI compatibility, but tids_new() should be used instead
+ *
+ */
+TIDS_INSTANCE *tids_create(void)
+{
+ return talloc_zero(NULL, TIDS_INSTANCE);
+}
+/* Get a listener for tids requests, returns its socket fd. Accept
+ * connections with tids_accept() */
+nfds_t tids_get_listener(TIDS_INSTANCE *tids,
+ TIDS_REQ_FUNC *req_handler,
+ tids_auth_func *auth_handler,
+ const char *hostname,
+ unsigned int port,
+ void *cookie,
+ int *fd_out,
+ size_t max_fd)
+{
+ nfds_t n_fd = 0;
+ nfds_t ii = 0;
+
+ tids->tids_port = port;
+ n_fd = tr_sock_listen_all(port, fd_out, max_fd);
+
+ if (n_fd == 0)
+ tr_err("tids_get_listener: Error opening port %d");
+ else {
+ /* opening port succeeded */
+ tr_info("tids_get_listener: Opened port %d.", port);
+
+ /* make this socket non-blocking */
+ for (ii=0; ii<n_fd; ii++) {
+ if (0 != fcntl(fd_out[ii], F_SETFL, O_NONBLOCK)) {
+ tr_err("tids_get_listener: Error setting O_NONBLOCK.");
+ for (ii=0; ii<n_fd; ii++) {
+ close(fd_out[ii]);
+ fd_out[ii]=-1;
+ }
+ n_fd = 0;
+ break;
+ }