GAtHDLC *g_at_hdlc_new(GIOChannel *channel) { GAtIO *io; GAtHDLC *hdlc; io = g_at_io_new(channel); if (io == NULL) return NULL; hdlc = g_at_hdlc_new_from_io(io); g_at_io_unref(io); return hdlc; }
GAtRawIP *g_at_rawip_new(GIOChannel *channel) { GAtRawIP *rawip; GAtIO *io; io = g_at_io_new(channel); if (io == NULL) return NULL; rawip = g_at_rawip_new_from_io(io); g_at_io_unref(io); return rawip; }
void g_at_rawip_shutdown(GAtRawIP *rawip) { if (rawip == NULL) return; if (rawip->tun_io == NULL) return; g_at_io_set_read_handler(rawip->io, NULL, NULL); g_at_io_set_read_handler(rawip->tun_io, NULL, NULL); rawip->write_buffer = NULL; rawip->tun_write_buffer = NULL; g_at_io_unref(rawip->tun_io); rawip->tun_io = NULL; }
void g_at_rawip_unref(GAtRawIP *rawip) { if (rawip == NULL) return; if (g_atomic_int_dec_and_test(&rawip->ref_count) == FALSE) return; g_at_rawip_shutdown(rawip); g_at_io_unref(rawip->io); rawip->io = NULL; g_free(rawip->ifname); rawip->ifname = NULL; g_free(rawip); }
void g_at_hdlc_unref(GAtHDLC *hdlc) { if (!hdlc) return; if (g_atomic_int_dec_and_test(&hdlc->ref_count) == FALSE) return; if (hdlc->record_fd > fileno(stderr)) { close(hdlc->record_fd); hdlc->record_fd = -1; } g_at_io_unref(hdlc->io); hdlc->io = NULL; ring_buffer_free(hdlc->write_buffer); g_free(hdlc->decode_buffer); if (hdlc->in_read_handler) hdlc->destroyed = TRUE; else g_free(hdlc); }