├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── Doxyfile ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── TODO ├── autoclean.sh ├── autogen.sh ├── configure.ac ├── doc ├── 005isupport.txt ├── debugging.txt ├── rfc1459.txt ├── rfc2812.txt └── winbuild.txt ├── include ├── Makefile.am └── libsrsirc │ ├── Makefile.am │ ├── defs.h │ ├── irc.h │ ├── irc_ext.h │ ├── irc_track.h │ └── util.h ├── libsrsirc.pc.in ├── libsrsirc ├── Makefile.am ├── bucklist.c ├── bucklist.h ├── cmap.c ├── cmap.h ├── common.c ├── common.h ├── conn.c ├── conn.h ├── intdefs.h ├── io.c ├── io.h ├── irc.c ├── irc_getset.c ├── irc_msghnd.c ├── irc_msghnd.h ├── irc_track.c ├── irc_track_int.h ├── msg.c ├── msg.h ├── px.c ├── px.h ├── skmap.c ├── skmap.h ├── ucbase.c ├── ucbase.h ├── util.c ├── v3.c └── v3.h ├── logger ├── Makefile.am ├── intlog.c └── intlog.h ├── m4 ├── ax_config_feature.m4 ├── ax_have_ctime_r.m4 ├── ax_have_eagain.m4 ├── ax_have_ewouldblock.m4 ├── ax_have_msg_nosignal.m4 ├── ax_have_siginfo.m4 ├── ax_have_sigint.m4 ├── ax_have_sigpipe.m4 ├── ax_have_sigusr1.m4 ├── ax_have_so_nosigpipe.m4 └── ax_have_vsyslog.m4 ├── platform ├── Makefile.am ├── base_io.c ├── base_io.h ├── base_log.c ├── base_log.h ├── base_misc.c ├── base_misc.h ├── base_net.c ├── base_net.h ├── base_string.c ├── base_string.h ├── base_time.c └── base_time.h ├── scripts ├── addtrace.sh ├── gentests.sh ├── mknetlist.sh ├── release.sh ├── replret.sh ├── retprint ├── runtests.sh ├── savetrace.sh └── winbuild.sh ├── src ├── Makefile.am ├── helloworld.c ├── icat_common.h ├── icat_core.c ├── icat_core.h ├── icat_init.c ├── icat_misc.c ├── icat_misc.h ├── icat_serv.c ├── icat_serv.h ├── icat_user.c ├── icat_user.h └── iwat.c ├── tracer ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_clear ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_count ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_del_iter ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_dispose ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_dump ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_find ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_first ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_get ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_init ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_insert ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_isempty ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_next ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_remove ├── tracer@libsrsirc%bucklist.c@lsi_bucklist_replace ├── tracer@libsrsirc%bucklist.c@pfxeq ├── tracer@libsrsirc%common.c@b64_core ├── tracer@libsrsirc%common.c@lsi_com_base64 ├── tracer@libsrsirc%common.c@lsi_com_check_timeout ├── tracer@libsrsirc%common.c@lsi_com_consocket ├── tracer@libsrsirc%common.c@lsi_com_guess_hosttype ├── tracer@libsrsirc%common.c@lsi_com_strCchr ├── tracer@libsrsirc%common.c@lsi_com_update_strprop ├── tracer@libsrsirc%common.c@tryhost ├── tracer@libsrsirc%conn.c@irc_conn_dump ├── tracer@libsrsirc%conn.c@lsi_conn_colon_trail ├── tracer@libsrsirc%conn.c@lsi_conn_connect ├── tracer@libsrsirc%conn.c@lsi_conn_dispose ├── tracer@libsrsirc%conn.c@lsi_conn_eof ├── tracer@libsrsirc%conn.c@lsi_conn_get_host ├── tracer@libsrsirc%conn.c@lsi_conn_get_port ├── tracer@libsrsirc%conn.c@lsi_conn_get_px_host ├── tracer@libsrsirc%conn.c@lsi_conn_get_px_port ├── tracer@libsrsirc%conn.c@lsi_conn_get_px_type ├── tracer@libsrsirc%conn.c@lsi_conn_get_ssl ├── tracer@libsrsirc%conn.c@lsi_conn_init ├── tracer@libsrsirc%conn.c@lsi_conn_online ├── tracer@libsrsirc%conn.c@lsi_conn_read ├── tracer@libsrsirc%conn.c@lsi_conn_reset ├── tracer@libsrsirc%conn.c@lsi_conn_set_px ├── tracer@libsrsirc%conn.c@lsi_conn_set_server ├── tracer@libsrsirc%conn.c@lsi_conn_set_ssl ├── tracer@libsrsirc%conn.c@lsi_conn_sockfd ├── tracer@libsrsirc%conn.c@lsi_conn_write ├── tracer@libsrsirc%io.c@find_delim ├── tracer@libsrsirc%io.c@lsi_io_read ├── tracer@libsrsirc%io.c@lsi_io_write ├── tracer@libsrsirc%io.c@read_more ├── tracer@libsrsirc%io.c@read_wrap ├── tracer@libsrsirc%io.c@send_wrap ├── tracer@libsrsirc%io.c@write_str ├── tracer@libsrsirc%irc.c@irc_connect ├── tracer@libsrsirc%irc.c@irc_dispose ├── tracer@libsrsirc%irc.c@irc_dump ├── tracer@libsrsirc%irc.c@irc_eof ├── tracer@libsrsirc%irc.c@irc_init ├── tracer@libsrsirc%irc.c@irc_printf ├── tracer@libsrsirc%irc.c@irc_read ├── tracer@libsrsirc%irc.c@irc_reg_msghnd ├── tracer@libsrsirc%irc.c@irc_regcb_conread ├── tracer@libsrsirc%irc.c@irc_regcb_mutnick ├── tracer@libsrsirc%irc.c@irc_reset ├── tracer@libsrsirc%irc.c@irc_write ├── tracer@libsrsirc%irc.c@reset_state ├── tracer@libsrsirc%irc.c@send_logon ├── tracer@libsrsirc%irc_getset.c@irc_005attr ├── tracer@libsrsirc%irc_getset.c@irc_005chanmodes ├── tracer@libsrsirc%irc_getset.c@irc_005modepfx ├── tracer@libsrsirc%irc_getset.c@irc_banmsg ├── tracer@libsrsirc%irc_getset.c@irc_banned ├── tracer@libsrsirc%irc_getset.c@irc_casemap ├── tracer@libsrsirc%irc_getset.c@irc_cmodes ├── tracer@libsrsirc%irc_getset.c@irc_colon_trail ├── tracer@libsrsirc%irc_getset.c@irc_get_conflags ├── tracer@libsrsirc%irc_getset.c@irc_get_dumb ├── tracer@libsrsirc%irc_getset.c@irc_get_fname ├── tracer@libsrsirc%irc_getset.c@irc_get_host ├── tracer@libsrsirc%irc_getset.c@irc_get_nick ├── tracer@libsrsirc%irc_getset.c@irc_get_pass ├── tracer@libsrsirc%irc_getset.c@irc_get_port ├── tracer@libsrsirc%irc_getset.c@irc_get_px_host ├── tracer@libsrsirc%irc_getset.c@irc_get_px_port ├── tracer@libsrsirc%irc_getset.c@irc_get_px_type ├── tracer@libsrsirc%irc_getset.c@irc_get_service_connect ├── tracer@libsrsirc%irc_getset.c@irc_get_service_dist ├── tracer@libsrsirc%irc_getset.c@irc_get_service_info ├── tracer@libsrsirc%irc_getset.c@irc_get_service_type ├── tracer@libsrsirc%irc_getset.c@irc_get_ssl ├── tracer@libsrsirc%irc_getset.c@irc_get_uname ├── tracer@libsrsirc%irc_getset.c@irc_lasterror ├── tracer@libsrsirc%irc_getset.c@irc_logonconv ├── tracer@libsrsirc%irc_getset.c@irc_myhost ├── tracer@libsrsirc%irc_getset.c@irc_mynick ├── tracer@libsrsirc%irc_getset.c@irc_online ├── tracer@libsrsirc%irc_getset.c@irc_service ├── tracer@libsrsirc%irc_getset.c@irc_set_conflags ├── tracer@libsrsirc%irc_getset.c@irc_set_connect_timeout ├── tracer@libsrsirc%irc_getset.c@irc_set_dumb ├── tracer@libsrsirc%irc_getset.c@irc_set_fname ├── tracer@libsrsirc%irc_getset.c@irc_set_nick ├── tracer@libsrsirc%irc_getset.c@irc_set_pass ├── tracer@libsrsirc%irc_getset.c@irc_set_px ├── tracer@libsrsirc%irc_getset.c@irc_set_sasl ├── tracer@libsrsirc%irc_getset.c@irc_set_server ├── tracer@libsrsirc%irc_getset.c@irc_set_service_connect ├── tracer@libsrsirc%irc_getset.c@irc_set_service_dist ├── tracer@libsrsirc%irc_getset.c@irc_set_service_info ├── tracer@libsrsirc%irc_getset.c@irc_set_service_type ├── tracer@libsrsirc%irc_getset.c@irc_set_ssl ├── tracer@libsrsirc%irc_getset.c@irc_set_track ├── tracer@libsrsirc%irc_getset.c@irc_set_uname ├── tracer@libsrsirc%irc_getset.c@irc_sockfd ├── tracer@libsrsirc%irc_getset.c@irc_tracking_enab ├── tracer@libsrsirc%irc_getset.c@irc_umodes ├── tracer@libsrsirc%irc_getset.c@irc_version ├── tracer@libsrsirc%irc_msghnd.c@handle_001 ├── tracer@libsrsirc%irc_msghnd.c@handle_002 ├── tracer@libsrsirc%irc_msghnd.c@handle_003 ├── tracer@libsrsirc%irc_msghnd.c@handle_004 ├── tracer@libsrsirc%irc_msghnd.c@handle_005 ├── tracer@libsrsirc%irc_msghnd.c@handle_005_CASEMAPPING ├── tracer@libsrsirc%irc_msghnd.c@handle_005_CHANMODES ├── tracer@libsrsirc%irc_msghnd.c@handle_005_CHANTYPES ├── tracer@libsrsirc%irc_msghnd.c@handle_005_PREFIX ├── tracer@libsrsirc%irc_msghnd.c@handle_383 ├── tracer@libsrsirc%irc_msghnd.c@handle_464 ├── tracer@libsrsirc%irc_msghnd.c@handle_465 ├── tracer@libsrsirc%irc_msghnd.c@handle_466 ├── tracer@libsrsirc%irc_msghnd.c@handle_484 ├── tracer@libsrsirc%irc_msghnd.c@handle_903 ├── tracer@libsrsirc%irc_msghnd.c@handle_904 ├── tracer@libsrsirc%irc_msghnd.c@handle_AUTHENTICATE ├── tracer@libsrsirc%irc_msghnd.c@handle_CAP ├── tracer@libsrsirc%irc_msghnd.c@handle_ERROR ├── tracer@libsrsirc%irc_msghnd.c@handle_MODE ├── tracer@libsrsirc%irc_msghnd.c@handle_NICK ├── tracer@libsrsirc%irc_msghnd.c@handle_PING ├── tracer@libsrsirc%irc_msghnd.c@handle_bad_nick ├── tracer@libsrsirc%irc_msghnd.c@lsi_imh_regall ├── tracer@libsrsirc%irc_msghnd.c@lsi_imh_unregall ├── tracer@libsrsirc%irc_track.c@h_311 ├── tracer@libsrsirc%irc_track.c@h_324 ├── tracer@libsrsirc%irc_track.c@h_332 ├── tracer@libsrsirc%irc_track.c@h_333 ├── tracer@libsrsirc%irc_track.c@h_352 ├── tracer@libsrsirc%irc_track.c@h_353 ├── tracer@libsrsirc%irc_track.c@h_366 ├── tracer@libsrsirc%irc_track.c@h_JOIN ├── tracer@libsrsirc%irc_track.c@h_KICK ├── tracer@libsrsirc%irc_track.c@h_MODE ├── tracer@libsrsirc%irc_track.c@h_MODE_chanmode ├── tracer@libsrsirc%irc_track.c@h_NICK ├── tracer@libsrsirc%irc_track.c@h_NOTICE ├── tracer@libsrsirc%irc_track.c@h_PART ├── tracer@libsrsirc%irc_track.c@h_PRIVMSG ├── tracer@libsrsirc%irc_track.c@h_QUIT ├── tracer@libsrsirc%irc_track.c@h_TOPIC ├── tracer@libsrsirc%irc_track.c@irc_all_chans ├── tracer@libsrsirc%irc_track.c@irc_all_members ├── tracer@libsrsirc%irc_track.c@irc_all_users ├── tracer@libsrsirc%irc_track.c@irc_chan ├── tracer@libsrsirc%irc_track.c@irc_member ├── tracer@libsrsirc%irc_track.c@irc_num_chans ├── tracer@libsrsirc%irc_track.c@irc_num_members ├── tracer@libsrsirc%irc_track.c@irc_num_users ├── tracer@libsrsirc%irc_track.c@irc_tag_chan ├── tracer@libsrsirc%irc_track.c@irc_tag_user ├── tracer@libsrsirc%irc_track.c@irc_user ├── tracer@libsrsirc%irc_track.c@lsi_trk_deinit ├── tracer@libsrsirc%irc_track.c@lsi_trk_dump ├── tracer@libsrsirc%irc_track.c@lsi_trk_init ├── tracer@libsrsirc%irc_track.c@mkchanrep ├── tracer@libsrsirc%irc_track.c@mkuserrep ├── tracer@libsrsirc%msg.c@dispatch_uhnd ├── tracer@libsrsirc%msg.c@lsi_msg_handle ├── tracer@libsrsirc%msg.c@lsi_msg_reghnd ├── tracer@libsrsirc%msg.c@lsi_msg_reguhnd ├── tracer@libsrsirc%msg.c@lsi_msg_unregall ├── tracer@libsrsirc%px.c@lsi_px_logon_http ├── tracer@libsrsirc%px.c@lsi_px_logon_socks4 ├── tracer@libsrsirc%px.c@lsi_px_logon_socks5 ├── tracer@libsrsirc%px.c@lsi_px_typenum ├── tracer@libsrsirc%px.c@lsi_px_typestr ├── tracer@libsrsirc%skmap.c@lsi_skmap_clear ├── tracer@libsrsirc%skmap.c@lsi_skmap_count ├── tracer@libsrsirc%skmap.c@lsi_skmap_del ├── tracer@libsrsirc%skmap.c@lsi_skmap_del_iter ├── tracer@libsrsirc%skmap.c@lsi_skmap_dispose ├── tracer@libsrsirc%skmap.c@lsi_skmap_dump ├── tracer@libsrsirc%skmap.c@lsi_skmap_dumpstat ├── tracer@libsrsirc%skmap.c@lsi_skmap_first ├── tracer@libsrsirc%skmap.c@lsi_skmap_get ├── tracer@libsrsirc%skmap.c@lsi_skmap_init ├── tracer@libsrsirc%skmap.c@lsi_skmap_next ├── tracer@libsrsirc%skmap.c@lsi_skmap_put ├── tracer@libsrsirc%skmap.c@lsi_skmap_stat ├── tracer@libsrsirc%skmap.c@strhash_mid ├── tracer@libsrsirc%skmap.c@strhash_small ├── tracer@libsrsirc%ucbase.c@compare_modepfx ├── tracer@libsrsirc%ucbase.c@lsi_ucb_add_chan ├── tracer@libsrsirc%ucbase.c@lsi_ucb_add_chanmode ├── tracer@libsrsirc%ucbase.c@lsi_ucb_add_memb ├── tracer@libsrsirc%ucbase.c@lsi_ucb_add_user ├── tracer@libsrsirc%ucbase.c@lsi_ucb_alloc_memb ├── tracer@libsrsirc%ucbase.c@lsi_ucb_clear ├── tracer@libsrsirc%ucbase.c@lsi_ucb_clear_chanmodes ├── tracer@libsrsirc%ucbase.c@lsi_ucb_clear_memb ├── tracer@libsrsirc%ucbase.c@lsi_ucb_deinit ├── tracer@libsrsirc%ucbase.c@lsi_ucb_drop_chan ├── tracer@libsrsirc%ucbase.c@lsi_ucb_drop_chanmode ├── tracer@libsrsirc%ucbase.c@lsi_ucb_drop_memb ├── tracer@libsrsirc%ucbase.c@lsi_ucb_drop_user ├── tracer@libsrsirc%ucbase.c@lsi_ucb_dump ├── tracer@libsrsirc%ucbase.c@lsi_ucb_first_chan ├── tracer@libsrsirc%ucbase.c@lsi_ucb_first_memb ├── tracer@libsrsirc%ucbase.c@lsi_ucb_first_user ├── tracer@libsrsirc%ucbase.c@lsi_ucb_get_chan ├── tracer@libsrsirc%ucbase.c@lsi_ucb_get_memb ├── tracer@libsrsirc%ucbase.c@lsi_ucb_get_user ├── tracer@libsrsirc%ucbase.c@lsi_ucb_init ├── tracer@libsrsirc%ucbase.c@lsi_ucb_next_chan ├── tracer@libsrsirc%ucbase.c@lsi_ucb_next_memb ├── tracer@libsrsirc%ucbase.c@lsi_ucb_next_user ├── tracer@libsrsirc%ucbase.c@lsi_ucb_num_chans ├── tracer@libsrsirc%ucbase.c@lsi_ucb_num_memb ├── tracer@libsrsirc%ucbase.c@lsi_ucb_num_users ├── tracer@libsrsirc%ucbase.c@lsi_ucb_rename_user ├── tracer@libsrsirc%ucbase.c@lsi_ucb_tag_chan ├── tracer@libsrsirc%ucbase.c@lsi_ucb_tag_user ├── tracer@libsrsirc%ucbase.c@lsi_ucb_touch_user ├── tracer@libsrsirc%ucbase.c@lsi_ucb_touch_user_int ├── tracer@libsrsirc%ucbase.c@lsi_ucb_update_modepfx ├── tracer@libsrsirc%util.c@lsi_ut_casemap_nam ├── tracer@libsrsirc%util.c@lsi_ut_classify_chanmode ├── tracer@libsrsirc%util.c@lsi_ut_clonearr ├── tracer@libsrsirc%util.c@lsi_ut_conread ├── tracer@libsrsirc%util.c@lsi_ut_dumpmsg ├── tracer@libsrsirc%util.c@lsi_ut_freearr ├── tracer@libsrsirc%util.c@lsi_ut_ident2host ├── tracer@libsrsirc%util.c@lsi_ut_ident2nick ├── tracer@libsrsirc%util.c@lsi_ut_ident2uname ├── tracer@libsrsirc%util.c@lsi_ut_ischan ├── tracer@libsrsirc%util.c@lsi_ut_istrcmp ├── tracer@libsrsirc%util.c@lsi_ut_istrncmp ├── tracer@libsrsirc%util.c@lsi_ut_mut_nick ├── tracer@libsrsirc%util.c@lsi_ut_parse_MODE ├── tracer@libsrsirc%util.c@lsi_ut_parse_hostspec ├── tracer@libsrsirc%util.c@lsi_ut_parse_pxspec ├── tracer@libsrsirc%util.c@lsi_ut_sasl_mkplauth ├── tracer@libsrsirc%util.c@lsi_ut_sndumpmsg ├── tracer@libsrsirc%util.c@lsi_ut_snrcmsg ├── tracer@libsrsirc%util.c@lsi_ut_strtolower ├── tracer@libsrsirc%util.c@lsi_ut_tokenize ├── tracer@libsrsirc%util.c@lsi_ut_tolower ├── tracer@libsrsirc%util.c@next_tok ├── tracer@platform%base_io.c@lsi_b_stdin_canread ├── tracer@platform%base_io.c@lsi_b_stdin_fd ├── tracer@platform%base_io.c@lsi_b_stdin_read ├── tracer@platform%base_misc.c@lsi_b_getopt ├── tracer@platform%base_misc.c@lsi_b_malloc ├── tracer@platform%base_misc.c@lsi_b_optarg ├── tracer@platform%base_misc.c@lsi_b_optind ├── tracer@platform%base_misc.c@lsi_b_regsig ├── tracer@platform%base_misc.c@lsi_b_usleep ├── tracer@platform%base_net.c@addrstr_from_sockaddr ├── tracer@platform%base_net.c@filladdr ├── tracer@platform%base_net.c@lsi_b_blocking ├── tracer@platform%base_net.c@lsi_b_close ├── tracer@platform%base_net.c@lsi_b_connect ├── tracer@platform%base_net.c@lsi_b_freeaddrlist ├── tracer@platform%base_net.c@lsi_b_freesslctx ├── tracer@platform%base_net.c@lsi_b_htons ├── tracer@platform%base_net.c@lsi_b_inet4_addr ├── tracer@platform%base_net.c@lsi_b_inet6_addr ├── tracer@platform%base_net.c@lsi_b_inet_addr ├── tracer@platform%base_net.c@lsi_b_mkaddrlist ├── tracer@platform%base_net.c@lsi_b_mksslctx ├── tracer@platform%base_net.c@lsi_b_read ├── tracer@platform%base_net.c@lsi_b_read_ssl ├── tracer@platform%base_net.c@lsi_b_select ├── tracer@platform%base_net.c@lsi_b_sock_ok ├── tracer@platform%base_net.c@lsi_b_socket ├── tracer@platform%base_net.c@lsi_b_sslfin ├── tracer@platform%base_net.c@lsi_b_sslize ├── tracer@platform%base_net.c@lsi_b_win_inet_pton ├── tracer@platform%base_net.c@lsi_b_write ├── tracer@platform%base_net.c@lsi_b_write_ssl ├── tracer@platform%base_net.c@sockaddr_from_addr ├── tracer@platform%base_net.c@sslinit ├── tracer@platform%base_net.c@wsa_init ├── tracer@platform%base_string.c@lsi_b_strNcat ├── tracer@platform%base_string.c@lsi_b_strNcpy ├── tracer@platform%base_string.c@lsi_b_strcasecmp ├── tracer@platform%base_string.c@lsi_b_strdup ├── tracer@platform%base_string.c@lsi_b_strncasecmp ├── tracer@src%icat_core.c@dump_info ├── tracer@src%icat_core.c@handle_ircmsg ├── tracer@src%icat_core.c@handle_usermsg ├── tracer@src%icat_core.c@icat_core_destroy ├── tracer@src%icat_core.c@icat_core_init ├── tracer@src%icat_core.c@icat_core_run ├── tracer@src%icat_init.c@cleanup ├── tracer@src%icat_init.c@dump_settings ├── tracer@src%icat_init.c@process_args ├── tracer@src%icat_init.c@set_defaults ├── tracer@src%icat_init.c@sighnd ├── tracer@src%icat_init.c@update_logger ├── tracer@src%icat_init.c@usage ├── tracer@src%icat_misc.c@icat_isdigitstr ├── tracer@src%icat_misc.c@icat_ismychan ├── tracer@src%icat_misc.c@icat_strtou64 ├── tracer@src%icat_misc.c@icat_strtou8 ├── tracer@src%icat_serv.c@conread ├── tracer@src%icat_serv.c@do_heartbeat ├── tracer@src%icat_serv.c@first_connect ├── tracer@src%icat_serv.c@handle_005 ├── tracer@src%icat_serv.c@handle_PING ├── tracer@src%icat_serv.c@handle_PONG ├── tracer@src%icat_serv.c@icat_serv_attention_at ├── tracer@src%icat_serv.c@icat_serv_casemap ├── tracer@src%icat_serv.c@icat_serv_destroy ├── tracer@src%icat_serv.c@icat_serv_dump ├── tracer@src%icat_serv.c@icat_serv_fd ├── tracer@src%icat_serv.c@icat_serv_init ├── tracer@src%icat_serv.c@icat_serv_online ├── tracer@src%icat_serv.c@icat_serv_operate ├── tracer@src%icat_serv.c@icat_serv_printf ├── tracer@src%icat_serv.c@icat_serv_read ├── tracer@src%icat_serv.c@icat_serv_sentquit ├── tracer@src%icat_serv.c@icat_serv_ssl ├── tracer@src%icat_serv.c@process_sendq ├── tracer@src%icat_serv.c@to_srv ├── tracer@src%icat_serv.c@tryconnect ├── tracer@src%icat_user.c@buf_cnt ├── tracer@src%icat_user.c@buf_rem ├── tracer@src%icat_user.c@icat_user_canread ├── tracer@src%icat_user.c@icat_user_eof ├── tracer@src%icat_user.c@icat_user_fd ├── tracer@src%icat_user.c@icat_user_printf ├── tracer@src%icat_user.c@icat_user_readline ├── tracer@src%iwat.c@cleanup ├── tracer@src%iwat.c@conread ├── tracer@src%iwat.c@infohnd ├── tracer@src%iwat.c@init ├── tracer@src%iwat.c@iprintf ├── tracer@src%iwat.c@process_args ├── tracer@src%iwat.c@tryconnect └── tracer@src%iwat.c@usage └── unittests ├── Makefile.am ├── README ├── test_bucklist.c └── unittests_common.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lo 3 | Makefile.in 4 | *.core 5 | *.la 6 | Makefile 7 | .deps/ 8 | .libs/ 9 | aclocal.m4 10 | autom4te.cache/ 11 | build-aux/ 12 | config.h 13 | config.h.in 14 | config.log 15 | config.status 16 | configure 17 | libtool 18 | src/icat 19 | src/iwat 20 | src/helloworld 21 | stamp-h1 22 | autoscan.log 23 | config.h.in~ 24 | configure.scan 25 | m4/l* 26 | libsrsirc.pc 27 | unittests/run_test_bucklist.c 28 | unittests/test_bucklist 29 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Timo Buhrmester 2 | Bradley Garagan 3 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2024, Timo Buhrmester 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the srs bsns enterprises corp. nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | see git log 2 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | SUBDIRS = platform logger include libsrsirc src unittests 3 | 4 | EXTRA_DIST = scripts unittests libsrsirc.pc.in 5 | dist-hook: 6 | rm -f $(distdir)/unittests/run_*.c $(distdir)/unittests/Makefile 7 | rm -rf $(distdir)/unittests/.deps 8 | 9 | test: all 10 | scripts/runtests.sh 11 | 12 | pkgconfigdir = $(libdir)/pkgconfig 13 | pkgconfig_DATA = libsrsirc.pc 14 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 2012/08/30 - 0.0.0 release 2 | 2013/07/04 - 0.0.1 release 3 | 2014/04/17 - 0.0.2 release 4 | 2014/05/29 - 0.0.3 release -- utterly broke the interface but well, this is 0.0.x, we're not supposed to have a stable interface (yet) 5 | 2015/01/25 - 0.0.4 release -- major rework of icat 6 | 2015/02/07 - 0.0.5 release -- separated platform-dependent and platform-independent stuff 7 | 2015/05/14 - 0.0.6 release -- fixed an annoying bug sometimes triggered when there's a lot of input 8 | 2015/07/12 - 0.0.7 release -- minor changes only; we seem good and stable 9 | 2015/09/13 - 0.0.8 release -- bugfixes only 10 | 2015/10/03 - 0.0.9 release -- massive function renaming (collision avoidance) -- most of the public interface remains unaffected. Happy birthday, Kerstin Pfeifer. 11 | 2015/10/12 - 0.0.10 release -- another big refactor with huge backwards compatibility implications; added a helloworld-style example because icat/iwat are just too big 12 | 2015/10/15 - 0.0.11 release -- there's a port to windows now...shudder. 13 | 2015/10/25 - 0.0.12 release -- fixed a few glitches, improved SSL, improved icat 14 | 2015/11/04 - 0.0.13 release -- pretty solid right now 15 | 2016/04/09 - 0.0.14 release -- bugfix release 16 | 2024/04/28 - 0.0.14.1 release -- build fix release 17 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is libsrsirc, version 0.0.14 2 | A lightweight, cross-platform IRC library 3 | Written in portable standard C (C99) 4 | 5 | Interface documentation: http://penenen.de/libsrsirc/doxygen/modules.html 6 | 7 | 8 | Some highlights: 9 | ---------------- 10 | - Lightweight: libsrsirc is small and uses very little resources; most of 11 | the protocol handling is essentially zero-copy. It does not 12 | try to offer every conceivable feature an IRC lib could 13 | possibly have, if the costs would outweight the gains. 14 | This allows creating thousands of independent instances. 15 | 16 | - Portable: libsrsirc is written in portable standard C, with all 17 | platform-specifics cleanly separated from the core library. 18 | It compiles and works on BSD, Linux, Mac OS and even Windows. 19 | Porting it to new platforms is relatively straightforward. 20 | 21 | - Robust: libsrsirc is tested against a huge variety of different IRC 22 | networks, and while it is certainly possible for a malicious 23 | IRC server to thoroughly confuse the lib, it will not cause 24 | crashes or security problems. If it does, file a bug report 25 | which will be dealt with promptly. 26 | It will even handle out-of-memory situations gracefully. 27 | 28 | - Flexible: libsrsirc supports IPv4 and IPv6. It can optionally link 29 | against OpenSSL for secure IRC connections. 30 | Apart from that, support for connecting to IRC through 31 | HTTP (CONNECT), SOCKS4 and SOCKS5 proxy servers is provided. 32 | 33 | - Debuggable: libsrsirc comes with a lot of built-in debug statements, 34 | which can be controlled using an environment variable. 35 | This allows troubleshooting even if using a dedicated 36 | debugger isn't feasible for some reason. 37 | 38 | - Useful: libsrsirc should be a decent foundation to build all sort of 39 | IRC-related software upon, from IRC support for a specific 40 | use case in a specific application, to dedicated IRC software 41 | like bots, bouncers, clients. 42 | It comes with 'icat', which implements a netcat-like utility 43 | for writing and reading messages to/from IRC channels. 44 | 45 | 46 | What libsrsirc does NOT do: 47 | --------------------------- 48 | - Servers: libsrsirc can NOT act as an IRC server (currently, anyway, 49 | but it will probably stay that way). While certain functions 50 | might still be useful to help implementing IRC servers 51 | (for example the protocol parser, the casemapping-aware 52 | string comparison and the user and channel maps), the 53 | overall design is clearly that of a client library. 54 | 55 | - Transactions: libsrsirc will NOT attempt to keep track of what 56 | client-issued command a given server response refers to. 57 | Doing this involves heuristical approaches because most ircds 58 | aren't exactly pedantic about following the standard -- and 59 | even if they are, there's two standards. 60 | Since libsrsirc cannot possibly know what non-standard 61 | response codes a server could return, it will leave 62 | correlating commands and responses - fortunately rarely 63 | needed for IRC software - to the user. 64 | 65 | 66 | Quickstart for libsrsirc users: 67 | ------------------------------- 68 | - Get a release tarball off the "tar" branch, DO NOT use the 69 | github-internal "release" feature. 70 | I.e. use https://github.com/fstd/libsrsirc/tree/tar 71 | (use "view raw" for downloading) 72 | 73 | - Extract the tarball, cd into the resulting directory 74 | 75 | - run "./configure && make" to build the lib, "make install" to install. 76 | 77 | 78 | Quickstart for libsrsirc developers: 79 | ------------------------------------ 80 | - Clone the repo 81 | 82 | - Run ./autogen.sh to setup the autohell. 83 | (This requires autoconf >= 2.69, automake >= 1.14, libtool >= 2.4) 84 | 85 | - run "./configure && make" to build the lib, "make install" to install. 86 | 87 | - To tear down the autohell, run ./autoclean.sh 88 | 89 | 90 | See src/helloworld.c for a trivial example application of the lib. 91 | 92 | See http://penenen.de/libsrsirc/doxygen/modules.html for documentation 93 | 94 | See INSTALL for generic autohell compile/install instructions. 95 | 96 | See COPYING for license information (tl;dr: 3-clause BSD) 97 | 98 | (C) 2012-2024 Timo Buhrmester 99 | Contact: #fstd on irc.libera.chat (or by email) 100 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | do libsrsirc's and icat's debug mechanisms collide/overlap? 2 | 3 | in dumb mode, should we handle 001-004 etc anyway? 4 | 5 | tracking only works with servers that use 005 CASEMAPPING. 6 | if skmap could rehash, tracking could be enabled 7 | before connecting and hence we wouldn't depend on 005 8 | 9 | accessor for all 005 attributes 10 | 11 | irc_cmodes -> irc_004chanmodes; then irc_cmodes dispatches to 004 or 12 | 005 depending on whether 005 was there. how to handle classes tho? 13 | 14 | Convenience functions for the typical client-issued commands 15 | -------------------------------------------------------------------------------- /autoclean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | make clean 3 | make distclean 4 | rm -f Makefile.in 5 | rm -f aclocal.m4 6 | rm -rf autom4te.cache/ 7 | rm -rf build-aux 8 | rm -rf m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 9 | rm -f config.h.in 10 | rm -f configure 11 | rm -f include/Makefile.in 12 | rm -f include/libsrsirc/Makefile.in 13 | rm -f libsrsirc/Makefile.in 14 | rm -f logger/Makefile.in 15 | rm -f platform/Makefile.in 16 | rm -f src/Makefile.in 17 | rm -f unittests/Makefile.in 18 | rm -f unittests/run_*.c 19 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir m4 build-aux > /dev/null 2>/dev/null 3 | autoreconf -i 4 | -------------------------------------------------------------------------------- /doc/debugging.txt: -------------------------------------------------------------------------------- 1 | Debugging libsrsirc 2 | =================== 3 | 4 | The preferred way is obviously to use a debugger, however, this isn't 5 | always feasible. libsrsirc therefore supports compiled-in debugging messages, 6 | which are controlled by the LIBSRSIRC_DEBUG environment variable. Additionally 7 | per-loglevel colors can be enabled by setting the LIBSRSIRC_DEBUG_FANCY 8 | variable to 1. 9 | 10 | Cheat sheet (assumes a POSIXish system) 11 | ======================================= 12 | 13 | # Set maximum loglevel for all modules to LOG_DEBUG, and add fancy colors 14 | export LIBSRSIRC_DEBUG=7 ; export LIBSRSIRC_DEBUG_FANCY=1 15 | # Then run the libsrsirc-using program; the debugging output will go to stderr. 16 | 17 | # No more noise than warnings for the IO subsystem, trace icat core, rest is limited to LOG_INFO 18 | # (this is just an arbitray example to demonstrate the syntax. all three 19 | # following lines are equivalent): 20 | export LIBSRSIRC_DEBUG='6 libsrsirc/io=4 icat/core=9' 21 | export LIBSRSIRC_DEBUG='libsrsirc/io=4 6 icat/core=9' 22 | export LIBSRSIRC_DEBUG='libsrsirc/io=4 icat/core=9 6' 23 | 24 | 25 | More specifically 26 | ================= 27 | 28 | LIBSRSIRC_DEBUG should be set to contain a string that is comprised of 29 | 'module=' tokens and an optional stray , separated by 30 | spaces 31 | 32 | The supported loglevels and the numeric values they're most likely to have(*) are: 33 | 34 | 9: Trace - Function call trace. Extremely noisy; traces everything short of the logger itself 35 | 8: Vivi - Debug messages which will produce a LOT of output during normal operation 36 | 7: Debug - Debug messages which will produce quite some output, but not flood stderr along the 'good' code paths 37 | 6: Info - Debug messages about significant (but normal) events which might be interesting to developers 38 | 5: Notice - Information about significant (but normal) events which might be interesting to normal users 39 | 4: Warn - Information about suboptimal conditions which should however not significantly affect functionality 40 | 3: Error - Non-critical (but usually functionality-breaking) error conditions 41 | 2: Critical - Fatal errors, exit() is called after spitting out the diagnostic message 42 | 43 | (The loglevels Critical through Debug are defined in terms of syslog's 44 | loglevels. Therefore their real numeric value may vary between platforms, 45 | however, on POSIX systems the given numbers are very likely to be accurate. 46 | Loglevels below 2 (syslog's LOG_ALERT and LOG_EMERG) are not used.) 47 | 48 | Possible module names are: 49 | libsrsirc/irc 50 | libsrsirc/common 51 | libsrsirc/util 52 | libsrsirc/conn 53 | libsrsirc/io 54 | libsrsirc/px 55 | libsrsirc/msg 56 | libsrsirc/skmap 57 | libsrsirc/plst 58 | libsrsirc/track 59 | libsrsirc/ucbase 60 | libsrsirc/base-io 61 | libsrsirc/base-net 62 | libsrsirc/base-time 63 | libsrsirc/base-str 64 | libsrsirc/base-misc 65 | icat/init 66 | icat/core 67 | icat/serv 68 | icat/user 69 | icat/misc 70 | -------------------------------------------------------------------------------- /doc/winbuild.txt: -------------------------------------------------------------------------------- 1 | Steps to build libsrsirc on Windows 2 | =================================== 3 | - Tested on WinXP 32bit with MinGW 2013072200, MSYS 2013072200, libsrsirc 0.0.11 4 | 5 | 6 | MinGW/MSYS setup (needs to be done just once) 7 | --------------------------------------------- 8 | 1. Download mingw-get-setup.exe (http://sourceforge.net/projects/mingw/files/) 9 | 2. Run it to install the MinGW/MSYS installation manager 10 | Installation directory: C:\MinGW 11 | [x] ...also install support for the graphical user interface 12 | (*) ...just for me 13 | Perform the installation. 14 | 15 | 3. In the MinGW installation manager (should open automatically, run 16 | C:\MinGW\libexec\mingw-get\guimain.exe if it doesn't), select 17 | "Basic Setup" on the left pane, mark "mingw32-base" and "msys-base" 18 | for installation. Apply the changes using the menu. 19 | 20 | 21 | libsrsirc build procedure 22 | ------------------------- 23 | 1. On a Unix-ish machine, create a distribution tarball the usual way 24 | (./autogen.sh && ./configure && make dist). 25 | Copy the tarball over to the Windows machine as C:\libsrsirc-$VERSION.tar.gz 26 | Copy scripts/winbuild.sh over to the Windows machine e.g. as C:\winbuild.sh 27 | (Note: If you want to use other directories, or if your MinGW isn't 28 | in C:\MinGW, edit the three variables at the top of winbuild.sh) 29 | 30 | 2. Run C:\MinGW\msys\1.0\msys.bat, to start a shell (bash) 31 | 32 | 3. Execute in that shell: sh /c/winbuild.sh [] ['release'] 33 | (version can be omitted if only one libsrsirc tarball sits in C:\, 34 | if 'release' is given, creates a tarbomb of the resulting binaries (exe+dll)) 35 | 36 | 37 | qemu (just a little reminder for myself) 38 | ---------------------------------------- 39 | qemu-system-i386 -localtime -m 512 -boot c -netdev user,id=network0 \ 40 | -device rtl8139,netdev=network0 /mnt/fast/qemu_winhdd.qcow2 41 | 42 | # For an extra FAT32 disk for data transfer, add: 43 | # -drive file=/mnt/fast/qemu_winhdd2,format=raw,index=1 44 | # Which is constructed using: 45 | # dd if=/dev/zero of=/mnt/fast/qemu_winhdd2 bs=1m count=50 progress=1 46 | # vnconfig -c vnd0 /mnt/fast/qemu_winhdd2 47 | # fdisk -u vnd0 48 | # (add one partition) 49 | # newfs_msdos /dev/rvnd0e 50 | # vnconfig -u vnd0 51 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = libsrsirc 2 | -------------------------------------------------------------------------------- /include/libsrsirc/Makefile.am: -------------------------------------------------------------------------------- 1 | pkginclude_HEADERS = irc.h util.h defs.h irc_ext.h irc_track.h 2 | -------------------------------------------------------------------------------- /libsrsirc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libsrsirc 7 | Description: lightweight serious IRC lib 8 | URL: http://github.com/fstd/libsrsirc 9 | Version: 0.0.14 10 | Requires: 11 | Libs: -L${libdir} -lsrsirc 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /libsrsirc/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libsrsirc.la 2 | libsrsirc_la_SOURCES = io.c conn.c irc.c util.c px.c msg.c common.c irc_msghnd.c irc_track.c irc_getset.c bucklist.c skmap.c ucbase.c cmap.c v3.c common.h conn.h intdefs.h bucklist.h msg.h io.h cmap.h irc_msghnd.h px.h irc_track_int.h skmap.h ucbase.h v3.h 3 | libsrsirc_la_CPPFLAGS = -I$(top_srcdir)/include 4 | libsrsirc_la_LIBADD = $(top_srcdir)/platform/libsrsircbase.la $(top_srcdir)/logger/libsrsirclog.la 5 | libsrsirc_la_LDFLAGS = -no-undefined 6 | -------------------------------------------------------------------------------- /libsrsirc/bucklist.c: -------------------------------------------------------------------------------- 1 | /* bucklist.c - helper structure for hashmap 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_PLST 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include "bucklist.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include "cmap.h" 25 | #include "common.h" 26 | 27 | 28 | struct pl_node { 29 | char *key; 30 | void *val; 31 | struct pl_node *next; 32 | }; 33 | 34 | struct bucklist { 35 | struct pl_node *head; 36 | struct pl_node *iter; 37 | struct pl_node *previter; //for delete while iteration 38 | const uint8_t *cmap; 39 | }; 40 | 41 | static bool pfxeq(const char *n1, const char *n2, const uint8_t *cmap); 42 | 43 | bucklist * 44 | lsi_bucklist_init(const uint8_t *cmap) 45 | { 46 | struct bucklist *l = MALLOC(sizeof *l); 47 | if (!l) 48 | return NULL; 49 | 50 | l->head = NULL; 51 | l->iter = NULL; 52 | l->cmap = cmap; 53 | return l; 54 | } 55 | 56 | void 57 | lsi_bucklist_dispose(bucklist *l) 58 | { 59 | lsi_bucklist_clear(l); 60 | free(l); 61 | return; 62 | } 63 | 64 | size_t 65 | lsi_bucklist_count(bucklist *l) 66 | { 67 | if (!l || !l->head) 68 | return 0; 69 | 70 | /* XXX cache? */ 71 | struct pl_node *n = l->head; 72 | size_t c = 1; 73 | while ((n = n->next)) 74 | c++; 75 | 76 | return c; 77 | } 78 | 79 | bool 80 | lsi_bucklist_isempty(bucklist *l) 81 | { 82 | return !l->head; 83 | } 84 | 85 | void 86 | lsi_bucklist_clear(bucklist *l) 87 | { 88 | if (!l) 89 | return; 90 | 91 | struct pl_node *n = l->head; 92 | while (n) { 93 | struct pl_node *tmp = n->next; 94 | free(n); 95 | n = tmp; 96 | } 97 | 98 | l->head = NULL; 99 | return; 100 | } 101 | 102 | bool 103 | lsi_bucklist_insert(bucklist *l, size_t i, char *key, void *val) 104 | { 105 | struct pl_node *n = l->head; 106 | struct pl_node *prev = NULL; 107 | 108 | struct pl_node *newnode = MALLOC(sizeof *newnode); 109 | if (!newnode) 110 | return false; 111 | 112 | newnode->key = key; 113 | newnode->val = val; 114 | 115 | if (!n) { //special case: list is empty 116 | newnode->next = NULL; 117 | l->head = newnode; 118 | return true; 119 | } 120 | 121 | while (n->next && i) { 122 | i--; 123 | prev = n; 124 | n = n->next; 125 | } 126 | 127 | if (i) { 128 | n->next = newnode; 129 | newnode->next = NULL; 130 | } else { 131 | newnode->next = n; 132 | if (prev) 133 | prev->next = newnode; 134 | else 135 | l->head = newnode; 136 | } 137 | 138 | return true; 139 | } 140 | 141 | /* key or val == NULL means don't touch */ 142 | bool 143 | lsi_bucklist_replace(bucklist *l, const char *key, void *val) 144 | { 145 | if (!val) 146 | return false; 147 | 148 | struct pl_node *n = l->head; 149 | while (n) { 150 | if (pfxeq(n->key, key, l->cmap)) { 151 | n->val = val; 152 | return true; 153 | } 154 | n = n->next; 155 | } 156 | 157 | return false; 158 | } 159 | 160 | void * 161 | lsi_bucklist_remove(bucklist *l, const char *key, char **origkey) 162 | { 163 | struct pl_node *n = l->head; 164 | struct pl_node *prev = NULL; 165 | while (n) { 166 | if (pfxeq(n->key, key, l->cmap)) { 167 | if (origkey) 168 | *origkey = n->key; 169 | void *val = n->val; 170 | 171 | if (!prev) 172 | l->head = n->next; 173 | else 174 | prev->next = n->next; 175 | 176 | free(n); 177 | return val; 178 | } 179 | prev = n; 180 | n = n->next; 181 | } 182 | 183 | return NULL; 184 | } 185 | 186 | bool 187 | lsi_bucklist_get(bucklist *l, size_t i, char **key, void **val) 188 | { 189 | if (!l->head) 190 | return false; 191 | 192 | struct pl_node *n = l->head; 193 | 194 | while (n->next && i > 0) { 195 | i--; 196 | n = n->next; 197 | } 198 | 199 | if (i > 0) 200 | return false; 201 | 202 | if (key) *key = n->key; 203 | if (val) *val = n->val; 204 | 205 | return true; 206 | } 207 | 208 | void * 209 | lsi_bucklist_find(bucklist *l, const char *key, char **origkey) 210 | { 211 | struct pl_node *n = l->head; 212 | while (n) { 213 | if (pfxeq(n->key, key, l->cmap)) { 214 | if (origkey) 215 | *origkey = n->key; 216 | return n->val; 217 | } 218 | n = n->next; 219 | } 220 | 221 | return NULL; 222 | } 223 | 224 | bool 225 | lsi_bucklist_first(bucklist *l, char **key, void **val) 226 | { 227 | if (!l->head) 228 | return false; 229 | 230 | l->previter = NULL; 231 | l->iter = l->head; 232 | 233 | if (key) *key = l->iter->key; 234 | if (val) *val = l->iter->val; 235 | 236 | return true; 237 | } 238 | 239 | bool 240 | lsi_bucklist_next(bucklist *l, char **key, void **val) 241 | { 242 | if (!l->iter || !l->iter->next) 243 | return false; 244 | 245 | l->previter = l->iter; 246 | l->iter = l->iter->next; 247 | 248 | if (key) *key = l->iter->key; 249 | if (val) *val = l->iter->val; 250 | 251 | return true; 252 | } 253 | 254 | void 255 | lsi_bucklist_del_iter(bucklist *l) 256 | { 257 | struct pl_node *next = l->iter->next; 258 | if (!l->previter) 259 | l->head = next; 260 | else 261 | l->previter->next = next; 262 | 263 | free(l->iter); 264 | l->iter = l->previter; 265 | return; 266 | } 267 | 268 | void 269 | lsi_bucklist_dump(bucklist *l, bucklist_op_fn op) 270 | { 271 | #define M(...) fprintf(stderr, __VA_ARGS__) 272 | if (!l) 273 | return; 274 | 275 | size_t c = lsi_bucklist_count(l); 276 | M("%zu elements: [", c); 277 | struct pl_node *n = l->head; 278 | while(n) { 279 | op(n->key); 280 | if (n->next) 281 | M(" --> "); 282 | n=n->next; 283 | } 284 | 285 | M("]\n"); 286 | #undef M 287 | return; 288 | } 289 | 290 | 291 | static bool 292 | pfxeq(const char *n1, const char *n2, const uint8_t *cmap) 293 | { 294 | unsigned char c1, c2; 295 | while ((c1 = cmap[(unsigned char)*n1]) & /* avoid short circuit */ 296 | (c2 = cmap[(unsigned char)*n2])) { 297 | if (c1 != c2) 298 | return false; 299 | 300 | n1++; n2++; 301 | } 302 | 303 | return c1 == c2; 304 | } 305 | -------------------------------------------------------------------------------- /libsrsirc/bucklist.h: -------------------------------------------------------------------------------- 1 | /* bucklist.h - helper structure for hashmap 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_PTRLIST_H 6 | #define LIBSRSIRC_PTRLIST_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | /* simple and stupid single linked list with void* data elements */ 15 | typedef struct bucklist bucklist; 16 | typedef bool (*bucklist_find_fn)(const void *e); 17 | typedef void (*bucklist_op_fn)(const void *e); 18 | typedef bool (*bucklist_eq_fn)(const void *e1, const void *e2); 19 | 20 | /* alloc/dispose/count/clear */ 21 | bucklist *lsi_bucklist_init(const uint8_t *cmap); 22 | void lsi_bucklist_dispose(bucklist *l); 23 | size_t lsi_bucklist_count(bucklist *l); 24 | bool lsi_bucklist_isempty(bucklist *l); 25 | void lsi_bucklist_clear(bucklist *l); 26 | 27 | /* insert/replace/get by index */ 28 | bool lsi_bucklist_insert(bucklist *l, size_t i, char *key, void *val); 29 | bool lsi_bucklist_get(bucklist *l, size_t i, char **key, void **val); 30 | 31 | /* linear search */ 32 | void *lsi_bucklist_find(bucklist *l, const char *key, char **origkey); 33 | void *lsi_bucklist_remove(bucklist *l, const char *key, char **origkey); 34 | bool lsi_bucklist_replace(bucklist *l, const char *key, void *val); 35 | 36 | /* iteration */ 37 | bool lsi_bucklist_first(bucklist *l, char **key, void **val); 38 | bool lsi_bucklist_next(bucklist *l, char **key, void **val); 39 | void lsi_bucklist_del_iter(bucklist *l); 40 | 41 | /* debug */ 42 | void lsi_bucklist_dump(bucklist *l, bucklist_op_fn op); 43 | 44 | 45 | #endif /* LIBSRSIRC_PTRLIST_H */ 46 | -------------------------------------------------------------------------------- /libsrsirc/cmap.c: -------------------------------------------------------------------------------- 1 | /* cmap.c - character maps 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #if HAVE_CONFIG_H 6 | # include 7 | #endif 8 | 9 | #include 10 | 11 | #include "cmap.h" 12 | 13 | /* ! and @ mapping to \0 is a hack for skmap.c, which is 14 | * the only part actually using this */ 15 | 16 | static const uint8_t s_lower_ascii[256] = { 17 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 18 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 19 | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 20 | 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 21 | 0x20, '\0', 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 22 | 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 23 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 24 | 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 25 | '\0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 26 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 27 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 28 | 'X', 'Y', 'Z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 29 | 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 30 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 31 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 32 | 'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 33 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 34 | 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 35 | 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 36 | 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 37 | 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 38 | 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 39 | 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 40 | 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 41 | 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 42 | 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 43 | 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 44 | 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 45 | 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 46 | 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 47 | 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 48 | 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 49 | }; 50 | 51 | static const uint8_t s_lower_rfc1459[256] = { 52 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 53 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 54 | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 55 | 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 56 | 0x20, '\0', 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 57 | 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 58 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 59 | 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 60 | '\0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 61 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 62 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 63 | 'X', 'Y', 'Z', '[', '\\', ']', 0x5e, 0x5f, 64 | 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 65 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 66 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 67 | 'X', 'Y', 'Z', '[', '\\', ']', 0x7e, 0x7f, 68 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 69 | 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 70 | 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 71 | 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 72 | 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 73 | 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 74 | 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 75 | 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 76 | 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 77 | 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 78 | 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 79 | 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 80 | 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 81 | 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 82 | 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 83 | 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 84 | }; 85 | 86 | static const uint8_t s_lower_strict_rfc1459[256] = { 87 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 88 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 89 | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 90 | 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 91 | 0x20, '\0', 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 92 | 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 93 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 94 | 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 95 | '\0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 96 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 97 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 98 | 'X', 'Y', 'Z', '[', '\\', ']', '^', 0x5f, 99 | 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 100 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 101 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 102 | 'X', 'Y', 'Z', '[', '\\', ']', '^', 0x7f, 103 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 104 | 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 105 | 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 106 | 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 107 | 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 108 | 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 109 | 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 110 | 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 111 | 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 112 | 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 113 | 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 114 | 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 115 | 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 116 | 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 117 | 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 118 | 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 119 | }; 120 | 121 | const uint8_t *g_cmap[3] = 122 | { s_lower_rfc1459, s_lower_strict_rfc1459, s_lower_ascii }; 123 | -------------------------------------------------------------------------------- /libsrsirc/cmap.h: -------------------------------------------------------------------------------- 1 | /* cmap.h - character maps (declaration) 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_CMAP_H 6 | #define LIBSRSIRC_CMAP_H 1 7 | 8 | 9 | extern const uint8_t *g_cmap[]; 10 | 11 | 12 | #endif /* LIBSRSIRC_CMAP_H */ 13 | -------------------------------------------------------------------------------- /libsrsirc/common.c: -------------------------------------------------------------------------------- 1 | /* common.c - lib-internal IRC-unrelated common routines 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_COMMON 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include "common.h" 13 | 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | 30 | 31 | static int tryhost(struct addrlist *ai, const char *laddr, uint16_t lport, 32 | char *remaddr, size_t remaddr_sz, uint16_t *peerport, uint64_t to_us); 33 | 34 | size_t 35 | lsi_com_strCchr(const char *str, char c) 36 | { 37 | size_t r = 0; 38 | while (*str) 39 | if (*str++ == c) 40 | r++; 41 | return r; 42 | } 43 | 44 | 45 | int 46 | lsi_com_consocket(const char *host, uint16_t port, const char *laddr, 47 | uint16_t lport, char *remaddr, size_t remaddr_sz, uint16_t *peerport, 48 | uint64_t softto, uint64_t hardto) 49 | { 50 | uint64_t hardtend = hardto ? lsi_b_tstamp_us() + hardto : 0; 51 | 52 | struct addrlist *alist; 53 | int count = lsi_b_mkaddrlist(host, port, &alist); 54 | if (count <= 0) 55 | return -1; 56 | 57 | if (softto && hardto && softto * count < hardto) 58 | softto = hardto / count; 59 | 60 | int sck = -1; 61 | for (struct addrlist *ai = alist; ai; ai = ai->next) { 62 | uint64_t trem = 0; 63 | 64 | if (lsi_com_check_timeout(hardtend, &trem)) { 65 | W("hard timeout"); 66 | return false; 67 | } 68 | 69 | if (trem > softto) 70 | trem = softto; 71 | 72 | sck = tryhost(ai, laddr, lport, remaddr, remaddr_sz, peerport, 73 | trem); 74 | 75 | if (sck != -1) 76 | break; 77 | } 78 | 79 | lsi_b_freeaddrlist(alist); 80 | 81 | return sck; 82 | } 83 | 84 | static int 85 | tryhost(struct addrlist *ai, const char *laddr, uint16_t lport, char *remaddr, 86 | size_t remaddr_sz, uint16_t *peerport, uint64_t to_us) 87 | { 88 | D("trying host '%s' ('%s')", ai->reqname, ai->addrstr); 89 | int sck = lsi_b_socket(ai->ipv6); 90 | 91 | if (sck == -1) 92 | return -1; 93 | 94 | if ((laddr || lport) && !lsi_b_bind(sck, laddr, lport, ai->ipv6)) 95 | C("can't bind to %s:%"PRIu16, laddr?laddr:"(default)", lport); 96 | 97 | if (!lsi_b_blocking(sck, false)) 98 | W("failed to set socket non-blocking, timeout will not work"); 99 | 100 | int r = lsi_b_connect(sck, ai); 101 | if (r == 1) 102 | return sck; 103 | else if (r == -1) 104 | goto fail; 105 | 106 | r = lsi_b_select(&sck, 1, true, false, to_us); 107 | 108 | if (r == 1) { 109 | //if (!lsi_b_blocking(sck, true)) 110 | // W("failed to clear socket non-blocking mode"); 111 | 112 | if (lsi_b_sock_ok(sck)) { 113 | if (remaddr && remaddr_sz) 114 | lsi_b_strNcpy(remaddr, ai->addrstr, remaddr_sz); 115 | if (peerport) 116 | *peerport = ai->port; 117 | 118 | return sck; 119 | } else 120 | W("could not connect socket"); 121 | 122 | } 123 | 124 | /* fall-thru */ 125 | fail: 126 | if (sck != -1) 127 | lsi_b_close(sck); 128 | return -1; 129 | } 130 | 131 | 132 | bool 133 | lsi_com_update_strprop(char **field, const char *val) 134 | { 135 | char *n = NULL; 136 | if (val && !(n = STRDUP(val))) 137 | return false; 138 | 139 | free(*field); 140 | *field = n; 141 | 142 | return true; 143 | } 144 | 145 | bool 146 | lsi_com_check_timeout(uint64_t tend, uint64_t *trem) 147 | { 148 | if (!tend) { 149 | if (trem) 150 | *trem = 0; 151 | return false; 152 | } 153 | 154 | uint64_t now = lsi_b_tstamp_us(); 155 | if (now >= tend) { 156 | if (trem) 157 | *trem = 0; 158 | return true; 159 | } 160 | 161 | if (trem) 162 | *trem = tend - now; 163 | 164 | return false; 165 | } 166 | 167 | /*dumb heuristic to tell apart domain name/ip4/ip6 addr XXX FIXME */ 168 | enum hosttypes 169 | lsi_com_guess_hosttype(const char *host) 170 | { 171 | if (strchr(host, '[')) 172 | return HOSTTYPE_IPV6; 173 | int dc = 0; 174 | while (*host) { 175 | if (*host == '.') 176 | dc++; 177 | else if (!isdigit((unsigned char)*host)) 178 | return HOSTTYPE_DNS; 179 | host++; 180 | } 181 | return dc == 3 ? HOSTTYPE_IPV4 : HOSTTYPE_DNS; 182 | } 183 | 184 | static const char *b64_alpha = 185 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 186 | 187 | static void 188 | b64_core(char *outquad, const uint8_t *intrip, size_t ntrip) 189 | { 190 | uint8_t t[3] = {0}; 191 | size_t i; 192 | for (i = 0; i < ntrip; i++) 193 | t[i] = intrip[i]; 194 | 195 | uint8_t q[4]; 196 | size_t nquad = ntrip + 1; /* dangerously relies on 1 <= ntrip <= 3 */ 197 | 198 | q[0] = t[0] >> 2; 199 | q[1] = (t[0]&0x03) << 4 | (t[1]&0xf0) >> 4; 200 | q[2] = (t[1]&0x0f) << 2 | (t[2]&0xc0) >> 6; 201 | q[3] = t[2]&0x3f; 202 | 203 | for (i = 0; i < nquad; i++) 204 | outquad[i] = b64_alpha[q[i]]; 205 | 206 | for (; i < 4; i++) 207 | outquad[i] = '='; 208 | return; 209 | } 210 | 211 | size_t 212 | lsi_com_base64(char *dest, size_t destsz, const uint8_t *input, size_t len) 213 | { 214 | size_t reslen = ((len + 2) / 3) * 4; 215 | if (reslen >= destsz) 216 | return 0; /* too big */ 217 | 218 | const uint8_t *iptr = input; 219 | char *optr = dest; 220 | 221 | for (size_t i = 0; i < len; i += 3, iptr += 3, optr += 4) 222 | b64_core(optr, iptr, MIN(len - i, 3)); 223 | 224 | return reslen; 225 | } 226 | 227 | /* \0-terminate the (to-be)-token `buf' points to, then locate the next token, 228 | * if any, and return pointer to it (or NULL) */ 229 | char * 230 | lsi_com_next_tok(char *buf, char delim) 231 | { 232 | while (*buf && *buf != delim) /* walk until end of (former) token */ 233 | buf++; 234 | 235 | if (!*buf) 236 | return NULL; /* there's no next token */ 237 | 238 | while (*buf == delim) /* walk over token delimiter, zero it out */ 239 | *buf++ = '\0'; 240 | 241 | if (!*buf) 242 | return NULL; /* trailing whitespace, but no next token */ 243 | 244 | return buf; /* return pointer to beginning of the next token */ 245 | } 246 | 247 | -------------------------------------------------------------------------------- /libsrsirc/common.h: -------------------------------------------------------------------------------- 1 | /* common.h - lib-internal IRC-unrelated common routines 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_COMMON_H 6 | #define LIBSRSIRC_COMMON_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | #define COUNTOF(ARR) (sizeof (ARR) / sizeof (ARR)[0]) 15 | 16 | #define MIN(A, B) ((A) < (B) ? (A) : (B)) 17 | 18 | enum hosttypes { 19 | HOSTTYPE_IPV4, 20 | HOSTTYPE_IPV6, 21 | HOSTTYPE_DNS 22 | }; 23 | 24 | 25 | size_t lsi_com_strCchr(const char *dst, char c); 26 | 27 | bool lsi_com_check_timeout(uint64_t tend, uint64_t *trem); 28 | 29 | int lsi_com_consocket(const char *host, uint16_t port, const char *laddr, 30 | uint16_t lport, char *remaddr, size_t remaddr_sz, uint16_t *peerport, 31 | uint64_t softto, uint64_t hardto); 32 | 33 | bool lsi_com_update_strprop(char **field, const char *val); 34 | 35 | enum hosttypes lsi_com_guess_hosttype(const char *host); 36 | 37 | size_t lsi_com_base64(char *dest, size_t destsz, 38 | const uint8_t *input, size_t len); 39 | 40 | char * lsi_com_next_tok(char *buf, char delim); 41 | 42 | #endif /* LIBSRSIRC_COMMON_H */ 43 | -------------------------------------------------------------------------------- /libsrsirc/conn.h: -------------------------------------------------------------------------------- 1 | /* conn.h - handles the raw TCP (or proxy) connection 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_CONN_H 6 | #define LIBSRSIRC_CONN_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include "intdefs.h" 14 | 15 | 16 | iconn *lsi_conn_init(void); 17 | void lsi_conn_reset(iconn *ctx); 18 | void lsi_conn_dispose(iconn *ctx); 19 | bool lsi_conn_connect(iconn *ctx, uint64_t softto_us, uint64_t hardto_us); 20 | int lsi_conn_read(iconn *ctx, tokarr *tok, char **tags, size_t *ntags, 21 | uint64_t to_us); // XXX 22 | bool lsi_conn_write_raw(iconn *ctx, const void *buf, size_t n); 23 | bool lsi_conn_write(iconn *ctx, const char *line); 24 | bool lsi_conn_online(iconn *ctx); 25 | bool lsi_conn_eof(iconn *ctx); 26 | 27 | const char *lsi_conn_get_host(iconn *ctx); 28 | uint16_t lsi_conn_get_port(iconn *ctx); 29 | const char *lsi_conn_get_px_host(iconn *ctx); 30 | uint16_t lsi_conn_get_px_port(iconn *ctx); 31 | int lsi_conn_get_px_type(iconn *ctx); 32 | bool lsi_conn_set_server(iconn *ctx, const char *host, uint16_t port); 33 | bool lsi_conn_set_px(iconn *ctx, const char *host, uint16_t port, int ptype); 34 | bool lsi_conn_set_localaddr(iconn *ctx, const char *addr, uint16_t port); 35 | bool lsi_conn_set_ssl(iconn *ctx, bool on); 36 | bool lsi_conn_get_ssl(iconn *ctx); 37 | 38 | /* TODO: replace these by something less insane */ 39 | bool lsi_conn_colon_trail(iconn *ctx); 40 | int lsi_conn_sockfd(iconn *ctx); 41 | 42 | void irc_conn_dump(iconn *ctx); 43 | 44 | #endif /* LIBSRSIRC_CONN_H */ 45 | -------------------------------------------------------------------------------- /libsrsirc/io.c: -------------------------------------------------------------------------------- 1 | /* io.c - i/o processing, protocol tokenization 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_IIO 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include "io.h" 13 | 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include "common.h" 27 | 28 | #include 29 | 30 | 31 | #define ISDELIM(C) ((C) == '\n' || (C) == '\r') 32 | 33 | 34 | /* local helpers */ 35 | static char *find_delim(struct readctx *rctx); 36 | static int read_more(sckhld sh, struct readctx *rctx, uint64_t to_us); 37 | static bool write_str(sckhld sh, const char *str); 38 | static long read_wrap(sckhld sh, void *buf, size_t sz, uint64_t to_us); 39 | static long send_wrap(sckhld sh, const void *buf, size_t len); 40 | 41 | 42 | /* Documented in io.h */ 43 | int 44 | lsi_io_read(sckhld sh, struct readctx *rctx, tokarr *tok, 45 | char **tags, size_t *ntags, uint64_t to_us) 46 | { 47 | uint64_t tend = to_us ? lsi_b_tstamp_us() + to_us : 0; 48 | uint64_t tnow, trem = 0; 49 | 50 | V("Wanna read with%s timeout (%"PRIu64"). %zu bytes in buffer: '%.*s'", 51 | tend?"":" no", to_us, rctx->eptr - rctx->wptr, 52 | (int)(rctx->eptr - rctx->wptr), rctx->wptr); 53 | 54 | while (rctx->wptr < rctx->eptr && ISDELIM(*rctx->wptr)) 55 | rctx->wptr++; /* skip leading line delimiters */ 56 | if (rctx->wptr == rctx->eptr) { /* empty buffer, use the opportunity.. */ 57 | rctx->wptr = rctx->eptr = rctx->workbuf; 58 | V("Opportunistic buffer reset"); 59 | } 60 | 61 | size_t linelen; 62 | char *delim; 63 | char *linestart; 64 | do { 65 | while (!(delim = find_delim(rctx))) { 66 | if (tend) { 67 | tnow = lsi_b_tstamp_us(); 68 | trem = tnow >= tend ? 1 : tend - tnow; 69 | } 70 | 71 | int r = read_more(sh, rctx, trem); 72 | if (r <= 0) 73 | return r; 74 | } 75 | 76 | linestart = rctx->wptr; 77 | linelen = delim - linestart; 78 | rctx->wptr++; 79 | V("Delim found, linelen %zu", linelen); 80 | } while (linelen == 0); 81 | rctx->wptr += linelen; 82 | 83 | *delim = '\0'; 84 | 85 | I("Read: '%s'", linestart); 86 | 87 | if (linestart[0] == '@') { 88 | linestart = lsi_ut_extract_tags(linestart + 1, 89 | tags, ntags); 90 | 91 | if (!linestart || !linestart[0]) { 92 | E("protocol error (just tags?)"); 93 | return -1; 94 | } 95 | } else if (ntags) 96 | *ntags = 0; 97 | 98 | return lsi_ut_tokenize(linestart, tok) ? 1 : -1; 99 | } 100 | 101 | /* Documented in io.h */ 102 | bool 103 | lsi_io_write(sckhld sh, const void *buf, size_t n) 104 | { 105 | long r = send_wrap(sh, buf, n); 106 | bool suc = r >= 0 && (size_t)r == n; 107 | 108 | if (suc) 109 | I("Wrote (%zu bytes): '%.*s'", n, (int) n, (const char *) buf); 110 | else 111 | W("Failed to write '%.*s'", (int) n, (const char *) buf); 112 | 113 | return suc; 114 | } 115 | 116 | /* return pointer to first line delim in our receive buffer, or NULL if none */ 117 | static char * 118 | find_delim(struct readctx *rctx) 119 | { 120 | *rctx->eptr = '\0'; // for tracing 121 | for (char *ptr = rctx->wptr; ptr < rctx->eptr; ptr++) 122 | if (ISDELIM(*ptr)) 123 | return ptr; 124 | return NULL; 125 | } 126 | 127 | /* attempt to read more data from the ircd into our read buffer. 128 | * returns 1 if something was read; 0 on timeout; -1 on failure */ 129 | static int 130 | read_more(sckhld sh, struct readctx *rctx, uint64_t to_us) 131 | { 132 | /* no sizeof rctx->workbuf here because it's one bigger than WORKBUF_SZ 133 | * and we don't want to fill the last byte with data; it's a dummy */ 134 | size_t remain = WORKBUF_SZ - (rctx->eptr - rctx->workbuf); 135 | if (!remain) { /* no more space left in receive buffer */ 136 | D("Buffer is full"); 137 | if (rctx->wptr == rctx->workbuf) { /* completely full */ 138 | E("input too long"); 139 | return -1; 140 | } 141 | 142 | /* make additional room by moving data to the beginning */ 143 | size_t datalen = (size_t)(rctx->eptr - rctx->wptr); 144 | memmove(rctx->workbuf, rctx->wptr, datalen); 145 | rctx->wptr = rctx->workbuf; 146 | rctx->eptr = &rctx->workbuf[datalen]; 147 | 148 | remain = WORKBUF_SZ - (rctx->eptr - rctx->workbuf); 149 | D("Moved %zu bytes to the front; space: %zu", datalen, remain); 150 | } 151 | 152 | V("Reading more data (max. %zu bytes, timeout: %"PRIu64, remain, to_us); 153 | long n = read_wrap(sh, rctx->eptr, remain, to_us); 154 | // >0: Amount of bytes read 155 | // 0: timeout 156 | // -1: Failure 157 | // -2: EOF 158 | if (n <= 0) { 159 | if (n < 0) 160 | n == -2 ? W("read: EOF") : WE("read failed"); 161 | else 162 | V("Timeout"); 163 | return n; 164 | } 165 | 166 | V("Got %ld more bytes", n); 167 | 168 | rctx->eptr += n; 169 | return 1; 170 | } 171 | 172 | 173 | /* write a string to a socket. the underlying write function ensures that 174 | * everything is sent, well, buffered. 175 | * returns true on success, false on failure */ 176 | static bool 177 | write_str(sckhld sh, const char *str) 178 | { 179 | return send_wrap(sh, str, strlen(str)) > 0; 180 | } 181 | 182 | /* wrap around either read() or SSL_read(), depending on whether 183 | * or not SSL is compiled-in and enabled (or not) */ 184 | static long 185 | read_wrap(sckhld sh, void *buf, size_t sz, uint64_t to_us) 186 | { 187 | if (sh.shnd) 188 | return lsi_b_read_ssl(sh.shnd, buf, sz, to_us); 189 | return lsi_b_read(sh.sck, buf, sz, to_us); 190 | } 191 | 192 | /* likewise for send()/SSL_write() */ 193 | static long 194 | send_wrap(sckhld sh, const void *buf, size_t len) 195 | { 196 | if (sh.shnd) 197 | return lsi_b_write_ssl(sh.shnd, buf, len); 198 | return lsi_b_write(sh.sck, buf, len); 199 | } 200 | -------------------------------------------------------------------------------- /libsrsirc/io.h: -------------------------------------------------------------------------------- 1 | /* io.h - i/o processing, protocol tokenization 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_IO_H 6 | #define LIBSRSIRC_IO_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include "intdefs.h" 14 | 15 | /* lsi_io_read 16 | * Read one message from the ircd, tokenize and populate `tok' with the results. 17 | * 18 | * Params: `sh': Structure holding socket and, if enabled, SSL handle 19 | * `rctx': Read context structure primarily holding the read buffer 20 | * `tok': Pointer to result array, where pointers to the identified 21 | * tokens are stored in. 22 | * (*tok)[0] will point to the "prefix" (not including the 23 | * leading colon), or NULL if the message did not 24 | * contain a prefix. 25 | * (*tok)[1] will point to the (mandatory) "command" 26 | * (*tok)[2+n] will point to the n-th "argument", if it 27 | * exists; NULL otherwise (for 0 <= n < sizeof *tok - 2) 28 | * `to_us': Timeout in microseconds (0 = no timeout) 29 | * 30 | * Returns 1 on success; 0 on timeout; -1 on failure 31 | */ 32 | int lsi_io_read(sckhld sh, struct readctx *rctx, tokarr *tok, 33 | char **tags, size_t *ntags, uint64_t to_us); // XXX 34 | 35 | /* lsi_io_write 36 | * Send buffer contents to the ircd 37 | * 38 | * Params: `sh': Structure holding socket and, if enabled, SSL handle 39 | * `buf': Data to send. Typically all or part of a single IRC protocol 40 | * line (but may be multiple if properly separated by \r\n). 41 | * `n': Size of the buffer specified by `buf' in bytes. 42 | * 43 | * Returns true on success, false on failure 44 | */ 45 | bool lsi_io_write(sckhld sh, const void *buf, size_t n); 46 | 47 | 48 | #endif /* LIBSRSIRC_IO_H */ 49 | -------------------------------------------------------------------------------- /libsrsirc/irc_msghnd.h: -------------------------------------------------------------------------------- 1 | /* irc_msghnd.h - core message handlers (see irc_msghnd.c for actual handlers) 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_IRC_MSGHND_H 6 | #define LIBSRSIRC_IRC_MSGHND_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include "intdefs.h" 14 | 15 | 16 | bool lsi_imh_regall(irc *ctx, bool dumb); 17 | void lsi_imh_unregall(irc *ctx); 18 | 19 | 20 | #endif /* LIBSRSIRC_IRC_MSGHND_H */ 21 | -------------------------------------------------------------------------------- /libsrsirc/irc_track_int.h: -------------------------------------------------------------------------------- 1 | /* irc_track_int.h - chan/user tracking, internal helpers 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_IRC_TRACK_INT_H 6 | #define LIBSRSIRC_IRC_TRACK_INT_H 1 7 | 8 | 9 | bool lsi_trk_init(irc *ctx); 10 | void lsi_trk_deinit(irc *ctx); 11 | 12 | 13 | #endif /* LIBSRSIRC_IRC_TRACK_INT_H */ 14 | -------------------------------------------------------------------------------- /libsrsirc/msg.c: -------------------------------------------------------------------------------- 1 | /* msg.c - protocol message handler mechanism and dispatch 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_IMSG 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include "msg.h" 13 | 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "common.h" 26 | #include "conn.h" 27 | 28 | #include 29 | #include 30 | 31 | 32 | bool 33 | lsi_msg_reghnd(irc *ctx, const char *cmd, hnd_fn hndfn, const char *module) 34 | { 35 | size_t i = 0; 36 | D("'%s' registering '%s'-handler", module, cmd); 37 | for (;i < ctx->msghnds_cnt; i++) 38 | if (!ctx->msghnds[i].cmd[0]) 39 | break; 40 | 41 | if (i == ctx->msghnds_cnt) { 42 | size_t ncnt = ctx->msghnds_cnt * 2; 43 | struct msghnd *narr; 44 | if (!(narr = MALLOC(ncnt * sizeof *narr))) 45 | return false; 46 | 47 | memcpy(narr, ctx->msghnds, ctx->msghnds_cnt * sizeof *narr); 48 | for (size_t j = ctx->msghnds_cnt; j < ncnt; j++) 49 | narr[j].cmd[0] = '\0'; 50 | 51 | free(ctx->msghnds); 52 | 53 | ctx->msghnds = narr; 54 | ctx->msghnds_cnt = ncnt; 55 | } 56 | 57 | ctx->msghnds[i].module = module; 58 | ctx->msghnds[i].hndfn = hndfn; 59 | STRACPY(ctx->msghnds[i].cmd, cmd); 60 | return true; 61 | } 62 | 63 | bool 64 | lsi_msg_reguhnd(irc *ctx, const char *cmd, uhnd_fn hndfn, bool pre) 65 | { 66 | size_t hcnt = pre ? ctx->uprehnds_cnt : ctx->uposthnds_cnt; 67 | struct umsghnd *harr = pre ? ctx->uprehnds : ctx->uposthnds; 68 | size_t i = 0; 69 | D("user registering %s-'%s'-handler", pre?"pre":"post", cmd); 70 | for (;i < hcnt; i++) 71 | if (!harr[i].cmd[0]) 72 | break; 73 | 74 | if (i == hcnt) { 75 | size_t ncnt = hcnt * 2; 76 | struct umsghnd *narr; 77 | if (!(narr = MALLOC(ncnt * sizeof *narr))) 78 | return false; 79 | 80 | memcpy(narr, harr, hcnt * sizeof *narr); 81 | for (size_t j = hcnt; j < ncnt; j++) 82 | narr[j].cmd[0] = '\0'; 83 | 84 | free(harr); 85 | 86 | harr = narr; 87 | hcnt = ncnt; 88 | if (pre) { 89 | ctx->uprehnds = harr; 90 | ctx->uprehnds_cnt = hcnt; 91 | } else { 92 | ctx->uposthnds = harr; 93 | ctx->uposthnds_cnt = hcnt; 94 | } 95 | } 96 | 97 | harr[i].hndfn = hndfn; 98 | STRACPY(harr[i].cmd, cmd); 99 | return true; 100 | } 101 | 102 | void 103 | lsi_msg_unregall(irc *ctx, const char *module) 104 | { 105 | size_t i = 0; 106 | for (;i < ctx->msghnds_cnt; i++) 107 | if (ctx->msghnds[i].cmd[0] 108 | && strcmp(ctx->msghnds[i].module, module) == 0) 109 | ctx->msghnds[i].cmd[0] = '\0'; 110 | return; 111 | } 112 | 113 | static bool 114 | dispatch_uhnd(irc *ctx, tokarr *msg, size_t ac, bool pre) 115 | { 116 | size_t hcnt = pre ? ctx->uprehnds_cnt : ctx->uposthnds_cnt; 117 | struct umsghnd *harr = pre ? ctx->uprehnds : ctx->uposthnds; 118 | 119 | for (size_t i = 0; i < hcnt; i++) { 120 | if (!harr[i].cmd[0]) 121 | continue; 122 | 123 | if (strcmp((*msg)[1], harr[i].cmd) != 0) 124 | continue; 125 | 126 | D("dispatch a %s-'%s'", pre?"pre":"post", (*msg)[1]); 127 | if (!harr[i].hndfn(ctx, msg, ac, pre)) 128 | return false; 129 | } 130 | 131 | return true; 132 | } 133 | 134 | uint16_t 135 | lsi_msg_handle(irc *ctx, tokarr *msg, bool logon) 136 | { 137 | uint16_t res = 0; 138 | size_t i = 0; 139 | size_t ac = 2; 140 | while (ac < COUNTOF(*msg) && (*msg)[ac]) 141 | ac++; 142 | 143 | if (!logon && !dispatch_uhnd(ctx, msg, ac, true)) { 144 | res |= USER_ERR; 145 | goto fail; 146 | } 147 | 148 | for (;i < ctx->msghnds_cnt; i++) { 149 | if (!ctx->msghnds[i].cmd[0]) 150 | continue; 151 | 152 | if (strcmp((*msg)[1], ctx->msghnds[i].cmd) != 0) 153 | continue; 154 | 155 | D("dispatch a '%s' to '%s'", (*msg)[1], ctx->msghnds[i].module); 156 | res |= ctx->msghnds[i].hndfn(ctx, msg, ac, logon); 157 | if (res & CANT_PROCEED) 158 | goto fail; 159 | } 160 | 161 | if (!logon && !dispatch_uhnd(ctx, msg, ac, false)) { 162 | res |= USER_ERR; 163 | goto fail; 164 | } 165 | 166 | return res; 167 | 168 | fail:; 169 | uint16_t r = res & ~CANT_PROCEED; 170 | 171 | if (r & USER_ERR) { 172 | E("user-registered message handler denied proceeding"); 173 | } else if (r & AUTH_ERR) { 174 | E("failed to authenticate"); 175 | } else if (r & SASL_ERR) { 176 | E("SASL authentication failed"); 177 | } else if (r & CAP_ERR) { 178 | E("Capability negotiation failed"); 179 | } else if (r & IO_ERR) { 180 | E("i/o error"); 181 | } else if (r & ALLOC_ERR) { 182 | E("memory allocation failed"); 183 | } else if (r & OUT_OF_NICKS) { 184 | E("out of nicks"); 185 | } else if (r & PROTO_ERR) { 186 | char line[1024]; 187 | E("proto error on '%s' (ct:%d)", 188 | lsi_ut_sndumpmsg(line, sizeof line, NULL, msg), 189 | lsi_conn_colon_trail(ctx->con)); 190 | } else { 191 | E("can't proceed for unknown reasons"); 192 | } 193 | 194 | return res; 195 | } 196 | -------------------------------------------------------------------------------- /libsrsirc/msg.h: -------------------------------------------------------------------------------- 1 | /* msg.h - protocol message handler mechanism and dispatch 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_IMSG_H 6 | #define LIBSRSIRC_IMSG_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include "intdefs.h" 14 | 15 | 16 | /* these bits comprise the return value of protocol message handler functions */ 17 | #define CANT_PROCEED (1<<0) // we encountered something we can't deal with 18 | # define OUT_OF_NICKS (CANT_PROCEED|(1<<1)) // logon: nick in use and no alt 19 | # define AUTH_ERR (CANT_PROCEED|(1<<2)) // wrong server password 20 | # define PROTO_ERR (CANT_PROCEED|(1<<3)) // illegal protocol message 21 | # define IO_ERR (CANT_PROCEED|(1<<4)) // i/o failure (lsi_conn_write()) 22 | # define ALLOC_ERR (CANT_PROCEED|(1<<5)) // out of memory 23 | # define USER_ERR (CANT_PROCEED|(1<<6)) // user msg handler failed 24 | # define SASL_ERR (CANT_PROCEED|(1<<7)) // SASL authentication failed 25 | # define CAP_ERR (CANT_PROCEED|(1<<8)) // >= 1 'musthave'-CAP unavailable 26 | #define LOGON_COMPLETE (1<<9) // we now consider ourselves logged on 27 | #define SASL_COMPLETE (1<<10) // SASL authentication succeeded 28 | #define MORE_CAPS (1<<11) // multiline reply to CAP LS 29 | #define STARTTLS_OVER (1<<12) // early starttls finished (or failed) 30 | 31 | bool lsi_msg_reghnd(irc *ctx, const char *cmd, hnd_fn hndfn, const char *module); 32 | void lsi_msg_unregall(irc *ctx, const char *module); 33 | 34 | bool lsi_msg_reguhnd(irc *ctx, const char *cmd, uhnd_fn hndfn, bool pre); 35 | 36 | 37 | /* returns the bitwise OR of one or more of the above 38 | * bitmasks, or 0 for nothing special */ 39 | uint16_t lsi_msg_handle(irc *ctx, tokarr *msg, bool logon); 40 | 41 | 42 | #endif /* LIBSRSIRC_IMSG_H */ 43 | -------------------------------------------------------------------------------- /libsrsirc/px.h: -------------------------------------------------------------------------------- 1 | /* px.h - Proxy subroutines (socks4/socks5/http) 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_PROXY_H 6 | #define LIBSRSIRC_PROXY_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | 13 | bool lsi_px_logon_http(int sck, const char *host, uint16_t port, 14 | uint64_t to_us); 15 | 16 | bool lsi_px_logon_socks4(int sck, const char *host, uint16_t port, 17 | uint64_t to_us); 18 | 19 | bool lsi_px_logon_socks5(int sck, const char *host, uint16_t port, 20 | uint64_t to_us); 21 | 22 | int lsi_px_typenum(const char *typestr); 23 | const char *lsi_px_typestr(int typenum); 24 | 25 | #endif /* LIBSRSIRC_PROXY_H */ 26 | -------------------------------------------------------------------------------- /libsrsirc/skmap.h: -------------------------------------------------------------------------------- 1 | /* skmap.h - hashmap with string keys, interface 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_HASHMAP_H 6 | #define LIBSRSIRC_HASHMAP_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | typedef size_t (*skmap_hash_fn)(const char *elem, const uint8_t *cmap); 15 | typedef void (*skmap_op_fn)(const void *elem); 16 | typedef void *(*skmap_keydup_fn)(const char *key); 17 | typedef bool (*skmap_eq_fn)(const void *elem1, const void *elem2); 18 | typedef struct skmap skmap; 19 | 20 | 21 | skmap *lsi_skmap_init(size_t bucketsz, int cmap); 22 | void lsi_skmap_clear(skmap *m); 23 | void lsi_skmap_dispose(skmap *m); 24 | bool lsi_skmap_put(skmap *m, const char *key, void *elem); 25 | void *lsi_skmap_get(skmap *m, const char *key); 26 | void *lsi_skmap_del(skmap *m, const char *key); 27 | size_t lsi_skmap_count(skmap *m); 28 | 29 | bool lsi_skmap_first(skmap *m, char **key, void **val); 30 | bool lsi_skmap_next(skmap *m, char **key, void **val); 31 | void lsi_skmap_del_iter(skmap *h); 32 | 33 | void lsi_skmap_dump(skmap *m, skmap_op_fn valop); 34 | void lsi_skmap_stat(skmap *h, size_t *nbuck, size_t *nbuckused, size_t *nitems, 35 | double *loadfac, double *avglistlen, size_t *maxlistlen); 36 | void lsi_skmap_dumpstat(skmap *m, const char *dbgname); 37 | //void skmap_test(void); 38 | 39 | 40 | #endif /* LIBSRSIRC_HASHMAP_H */ 41 | -------------------------------------------------------------------------------- /libsrsirc/ucbase.h: -------------------------------------------------------------------------------- 1 | /* ucbase.h - user and channel base, interface (lib-internal) 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_UCBASE_H 6 | #define LIBSRSIRC_UCBASE_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include "intdefs.h" 14 | 15 | 16 | typedef struct chan chan; 17 | typedef struct member memb; 18 | typedef struct user user; 19 | 20 | struct chan { 21 | char name[MAX_CHAN_LEN]; 22 | char *topic; 23 | char *topicnick; 24 | uint64_t tscreate; 25 | uint64_t tstopic; 26 | skmap *memb; //map lnick to struct member 27 | bool desync; 28 | char **modes; //one modechar per elem, i.e. "s" or "l 123" 29 | size_t modes_sz; 30 | void *tag; 31 | bool freetag; 32 | }; 33 | 34 | struct member { 35 | user *u; 36 | char modepfx[MAX_MODEPFX]; 37 | }; 38 | 39 | struct user { 40 | char *nick; 41 | char *uname; 42 | char *host; 43 | char *fname; 44 | size_t nchans; 45 | bool dangling; //debug 46 | void *tag; 47 | bool freetag; 48 | }; 49 | 50 | bool lsi_ucb_init(irc *ctx); 51 | void lsi_ucb_deinit(irc *ctx); 52 | void lsi_ucb_clear(irc *ctx); 53 | void lsi_ucb_dump(irc *ctx, bool full); 54 | 55 | user *lsi_ucb_add_user(irc *ctx, const char *ident); 56 | bool lsi_ucb_drop_user(irc *ctx, user *u); 57 | size_t lsi_ucb_num_users(irc *ctx); 58 | user *lsi_ucb_get_user(irc *ctx, const char *ident, bool complain); 59 | user *lsi_ucb_touch_user(irc *ctx, const char *ident, bool complain); 60 | bool lsi_ucb_rename_user(irc *ctx, const char *ident, const char *newnick, 61 | bool *allocerr); 62 | 63 | chan *lsi_ucb_add_chan(irc *ctx, const char *name); 64 | bool lsi_ucb_drop_chan(irc *ctx, chan *c); 65 | size_t lsi_ucb_num_chans(irc *ctx); 66 | chan *lsi_ucb_get_chan(irc *ctx, const char *name, bool complain); 67 | 68 | void lsi_ucb_clear_chanmodes(irc *ctx, chan *c); 69 | bool lsi_ucb_add_chanmode(irc *ctx, chan *c, const char *modestr); 70 | bool lsi_ucb_drop_chanmode(irc *ctx, chan *c, const char *modestr); 71 | 72 | size_t lsi_ucb_num_memb(irc *ctx, chan *c); 73 | memb *lsi_ucb_get_memb(irc *ctx, chan *c, const char *nick, bool complain); 74 | bool lsi_ucb_add_memb(irc *ctx, chan *c, user *u, const char *mpfxstr); 75 | bool lsi_ucb_drop_memb(irc *ctx, chan *c, user *u, bool purge, bool complain); 76 | void lsi_ucb_clear_memb(irc *ctx, chan *c); 77 | memb *lsi_ucb_alloc_memb(irc *ctx, user *u, const char *mpfxstr); 78 | bool lsi_ucb_update_modepfx(irc *ctx, chan *c, const char *nick, char sym, 79 | bool enab); 80 | 81 | /* these might be dangerous to use, be sure to complete the iteration 82 | * before any other state might change */ 83 | chan *lsi_ucb_first_chan(irc *ctx); 84 | chan *lsi_ucb_next_chan(irc *ctx); 85 | user *lsi_ucb_first_user(irc *ctx); 86 | user *lsi_ucb_next_user(irc *ctx); 87 | memb *lsi_ucb_first_memb(irc *ctx, chan *c); 88 | memb *lsi_ucb_next_memb(irc *ctx, chan *c); 89 | void lsi_ucb_tag_chan(chan *c, void *tag, bool autofree); 90 | void lsi_ucb_tag_user(user *u, void *tag, bool autofree); 91 | 92 | 93 | #endif /* LIBSRSIRC_UCBASE_H */ 94 | -------------------------------------------------------------------------------- /libsrsirc/v3.h: -------------------------------------------------------------------------------- 1 | /* v3.h - v3 protocol support internal interface 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_V3_H 6 | #define LIBSRSIRC_V3_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include "intdefs.h" 14 | 15 | void lsi_v3_init_caps(irc *ctx); 16 | void lsi_v3_reset_caps(irc *ctx); 17 | bool lsi_v3_want_caps(irc *ctx); 18 | bool lsi_v3_want_cap(irc *ctx, const char *cap, bool musthave); 19 | void lsi_v3_clear_cap(irc *ctx, const char *cap); 20 | void lsi_v3_update_caps(irc *ctx, const char *capsline, bool offered); 21 | bool lsi_v3_check_caps(irc *ctx, bool offered); 22 | bool lsi_v3_mk_capreq(irc *ctx, char *dest, size_t destsz); 23 | void lsi_v3_update_cap(irc *ctx, const char *cap, const char *adddata, 24 | int offered, int enabled); //-1: don't upd 25 | 26 | bool lsi_v3_regall(irc *ctx, bool dumb); 27 | void lsi_v3_unregall(irc *ctx); 28 | 29 | #endif /* LIBSRSIRC_V3_H */ 30 | -------------------------------------------------------------------------------- /logger/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libsrsirclog.la 2 | libsrsirclog_la_SOURCES = intlog.c intlog.h 3 | -------------------------------------------------------------------------------- /logger/intlog.h: -------------------------------------------------------------------------------- 1 | /* intlog.h - library debugging interface 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_INTLOG_H 6 | #define LIBSRSIRC_INTLOG_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | 17 | #define MOD_IRC 0 18 | #define MOD_COMMON 1 19 | #define MOD_IRC_UTIL 2 20 | #define MOD_ICONN 3 21 | #define MOD_IIO 4 22 | #define MOD_PROXY 5 23 | #define MOD_IMSG 6 24 | #define MOD_SKMAP 7 25 | #define MOD_PLST 8 26 | #define MOD_TRACK 9 27 | #define MOD_UCBASE 10 28 | #define MOD_V3 11 29 | #define MOD_BASEIO 12 30 | #define MOD_BASENET 13 31 | #define MOD_BASETIME 14 32 | #define MOD_BASESTR 15 33 | #define MOD_BASEMISC 16 34 | #define MOD_ICATINIT 17 35 | #define MOD_ICATCORE 18 36 | #define MOD_ICATSERV 19 37 | #define MOD_ICATUSER 20 38 | #define MOD_ICATMISC 21 39 | #define MOD_IWAT 22 40 | #define MOD_UNKNOWN 23 41 | #define NUM_MODS 24 /* when adding modules, don't forget intlog.c's `modnames' */ 42 | 43 | /* our two higher-than-debug custom loglevels */ 44 | #define LOG_TRACE (LOG_VIVI+1) 45 | #define LOG_VIVI (LOG_DEBUG+1) 46 | 47 | #ifndef LOG_MODULE 48 | # define LOG_MODULE MOD_UNKNOWN 49 | #endif 50 | 51 | //[TVDINWE](): log with Trace, Vivi, Debug, Info, Notice, Warn, Error severity. 52 | //[TVDINWE]E(): similar, but also append ``errno'' message 53 | //C(), CE(): as above, but also call exit(EXIT_FAILURE) 54 | 55 | // ----- logging interface ----- 56 | 57 | #define V(...) \ 58 | lsi_log_log(LOG_MODULE,LOG_VIVI,-1,__FILE__,__LINE__,__func__,__VA_ARGS__) 59 | 60 | #define VE(...) \ 61 | lsi_log_log(LOG_MODULE,LOG_VIVI,errno,__FILE__,__LINE__,__func__,__VA_ARGS__) 62 | 63 | #define D( ...) \ 64 | lsi_log_log(LOG_MODULE,LOG_DEBUG,-1,__FILE__,__LINE__,__func__,__VA_ARGS__) 65 | 66 | #define DE(...) \ 67 | lsi_log_log(LOG_MODULE,LOG_DEBUG,errno,__FILE__,__LINE__,__func__,__VA_ARGS__) 68 | 69 | #define I(...) \ 70 | lsi_log_log(LOG_MODULE,LOG_INFO,-1,__FILE__,__LINE__,__func__,__VA_ARGS__) 71 | 72 | #define IE(...) \ 73 | lsi_log_log(LOG_MODULE,LOG_INFO,errno,__FILE__,__LINE__,__func__,__VA_ARGS__) 74 | 75 | #define N(...) \ 76 | lsi_log_log(LOG_MODULE,LOG_NOTICE,-1,__FILE__,__LINE__,__func__,__VA_ARGS__) 77 | 78 | #define NE(...) \ 79 | lsi_log_log(LOG_MODULE,LOG_NOTICE,errno,__FILE__,__LINE__,__func__,__VA_ARGS__) 80 | 81 | #define W(...) \ 82 | lsi_log_log(LOG_MODULE,LOG_WARNING,-1,__FILE__,__LINE__,__func__,__VA_ARGS__) 83 | 84 | #define WE(...) \ 85 | lsi_log_log(LOG_MODULE,LOG_WARNING,errno,__FILE__,__LINE__,__func__,__VA_ARGS__) 86 | 87 | #define E(...) \ 88 | lsi_log_log(LOG_MODULE,LOG_ERR,-1,__FILE__,__LINE__,__func__,__VA_ARGS__) 89 | 90 | #define EE(...) \ 91 | lsi_log_log(LOG_MODULE,LOG_ERR,errno,__FILE__,__LINE__,__func__,__VA_ARGS__) 92 | 93 | #define C(...) do { \ 94 | lsi_log_log(LOG_MODULE,LOG_CRIT,-1,__FILE__,__LINE__,__func__,__VA_ARGS__); \ 95 | exit(EXIT_FAILURE); } while (0) 96 | 97 | #define CE(...) do { \ 98 | lsi_log_log(LOG_MODULE,LOG_CRIT,errno,__FILE__,__LINE__,__func__,__VA_ARGS__);\ 99 | exit(EXIT_FAILURE); } while (0) 100 | 101 | /* special: always printed, never decorated */ 102 | #define A(...) \ 103 | lsi_log_log(-1,INT_MIN,-1,__FILE__,__LINE__,__func__,__VA_ARGS__) 104 | 105 | /* tracing */ 106 | #if NOTRACE 107 | # define T(...) do{}while(0) 108 | # define TC(...) do{}while(0) 109 | # define TR(...) do{}while(0) 110 | #else 111 | # define T(...) \ 112 | lsi_log_log(LOG_MODULE,LOG_TRACE,-1,__FILE__,__LINE__,__func__,__VA_ARGS__) 113 | 114 | # define TC(...) \ 115 | do{ \ 116 | lsi_log_log(LOG_MODULE,LOG_TRACE,-1,__FILE__,__LINE__,__func__,__VA_ARGS__); \ 117 | lsi_log_tcall(); \ 118 | } while (0) 119 | 120 | # define TR(...) \ 121 | do{ \ 122 | lsi_log_tret(); \ 123 | lsi_log_log(LOG_MODULE,LOG_TRACE,-1,__FILE__,__LINE__,__func__,__VA_ARGS__); \ 124 | } while (0) 125 | #endif 126 | 127 | // ----- logger control interface ----- 128 | 129 | void lsi_log_stderr(void); 130 | void lsi_log_syslog(const char *ident); 131 | 132 | void lsi_log_setlvl(int mod, int lvl); 133 | int lsi_log_getlvl(int mod); 134 | 135 | void lsi_log_setfancy(bool fancy); 136 | bool lsi_log_getfancy(void); 137 | 138 | void lsi_log_tret(void); 139 | void lsi_log_tcall(void); 140 | 141 | // ----- backend ----- 142 | void lsi_log_log(int mod, int lvl, int errn, const char *file, int line, 143 | const char *func, const char *fmt, ...) 144 | #ifdef __GNUC__ 145 | __attribute__ ((format (printf, 7, 8))) 146 | #endif 147 | ; 148 | 149 | void lsi_log_init(void); 150 | 151 | 152 | #endif /* LIBSRSIRC_INTLOG_H */ 153 | -------------------------------------------------------------------------------- /m4/ax_config_feature.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_config_feature.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CONFIG_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, DEFINE, DEFINE-DESCRIPTION, [ACTION-IF-ENABLED [, ACTION-IF-NOT-ENABLED]]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_CONFIG_FEATURE is a simple wrapper for AC_ARG_ENABLE, it enables the 12 | # feature FEATURE-NAME and AC_DEFINEs the passed DEFINE, depending on the 13 | # user choice. DESCRIPTION will be used for AC_DEFINEs. ACTION-IF-ENABLED 14 | # and ACTION-IF-NOT-ENABLED are the actions that will be run. A feature is 15 | # enabled by default, in order to change this behaviour use the 16 | # AX_CONFIG_FEATURE_DEFAULT_ENABLED and AX_CONFIG_FEATURE_DEFAULT_DISABLED 17 | # macros. 18 | # 19 | # A simple example: 20 | # 21 | # AX_CONFIG_FEATURE_DEFAULT_ENABLED 22 | # AX_CONFIG_FEATURE(feature_xxxxx, [turns on/off XXXXX support], 23 | # HAVE_XXXXX, [Define if you want XXXXX support]) 24 | # 25 | # ... 26 | # 27 | # AX_CONFIG_FEATURE_DEFAULT_DISABLED 28 | # AX_CONFIG_FEATURE(feature_yyyyy, [turns on/off YYYYY support], 29 | # HAVE_YYYYY, [Define if you want YYYYY support], 30 | # [enable_yyyyy="yes"], [enable_yyyyy="no"]) 31 | # AM_CONDITIONAL(YYYYY, [test "$enable_yyyyy" = "yes"]) 32 | # 33 | # AX_CONFIG_FEATURE_DEFAULT_ENABLED 34 | # AX_CONFIG_FEATURE(...) 35 | # 36 | # ... 37 | # 38 | # If you have lot of features and you want a verbose dumping of each user 39 | # selection use AX_CONFIG_FEATURE_VERBOSE. Use AX_CONFIG_FEATURE_SILENT in 40 | # order to remove a previously AX_CONFIG_FEATURE_VERBOSE. By default 41 | # features are silent. 42 | # 43 | # Use AX_CONFIG_FEATURE_ENABLE or AX_CONFIG_FEATURE_DISABLE in order to 44 | # enable or disable a specific feature. 45 | # 46 | # Another simple example: 47 | # 48 | # AS_IF([some_test_here],[AX_CONFIG_FEATURE_ENABLE(feature_xxxxx)],[]) 49 | # 50 | # AX_CONFIG_FEATURE(feature_xxxxx, [turns on/off XXXXX support], 51 | # HAVE_XXXXX, [Define if you want XXXXX support]) 52 | # AX_CONFIG_FEATURE(feature_yyyyy, [turns on/off YYYYY support], 53 | # HAVE_YYYYY, [Define if you want YYYYY support], 54 | # [enable_yyyyy="yes"], [enable_yyyyy="no"]) 55 | # 56 | # ... 57 | # 58 | # NOTE: AX_CONFIG_FEATURE_ENABLE() must be placed first of the relative 59 | # AX_CONFIG_FEATURE() macro ... 60 | # 61 | # LICENSE 62 | # 63 | # Copyright (c) 2008 Francesco Salvestrini 64 | # 65 | # This program is free software; you can redistribute it and/or modify it 66 | # under the terms of the GNU General Public License as published by the 67 | # Free Software Foundation; either version 2 of the License, or (at your 68 | # option) any later version. 69 | # 70 | # This program is distributed in the hope that it will be useful, but 71 | # WITHOUT ANY WARRANTY; without even the implied warranty of 72 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 73 | # Public License for more details. 74 | # 75 | # You should have received a copy of the GNU General Public License along 76 | # with this program. If not, see . 77 | # 78 | # As a special exception, the respective Autoconf Macro's copyright owner 79 | # gives unlimited permission to copy, distribute and modify the configure 80 | # scripts that are the output of Autoconf when processing the Macro. You 81 | # need not follow the terms of the GNU General Public License when using 82 | # or distributing such scripts, even though portions of the text of the 83 | # Macro appear in them. The GNU General Public License (GPL) does govern 84 | # all other use of the material that constitutes the Autoconf Macro. 85 | # 86 | # This special exception to the GPL applies to versions of the Autoconf 87 | # Macro released by the Autoconf Archive. When you make and distribute a 88 | # modified version of the Autoconf Macro, you may extend this special 89 | # exception to the GPL to apply to your modified version as well. 90 | 91 | #serial 10 92 | 93 | AC_DEFUN([AX_CONFIG_FEATURE],[ dnl 94 | m4_pushdef([FEATURE], patsubst([$1], -, _))dnl 95 | 96 | AC_ARG_ENABLE([$1],AS_HELP_STRING([--enable-$1],[$2]),[ 97 | case "${enableval}" in 98 | yes) 99 | ax_config_feature_[]FEATURE[]="yes" 100 | ;; 101 | no) 102 | ax_config_feature_[]FEATURE[]="no" 103 | ;; 104 | *) 105 | AC_MSG_ERROR([bad value ${enableval} for feature --$1]) 106 | ;; 107 | esac 108 | ]) 109 | 110 | AS_IF([test "$ax_config_feature_[]FEATURE[]" = yes],[ dnl 111 | AC_DEFINE([$3]) 112 | $5 113 | AS_IF([test "$ax_config_feature_verbose" = yes],[ dnl 114 | AC_MSG_NOTICE([Feature $1 is enabled]) 115 | ]) 116 | ],[ dnl 117 | $6 118 | AS_IF([test "$ax_config_feature_verbose" = yes],[ dnl 119 | AC_MSG_NOTICE([Feature $1 is disabled]) 120 | ]) 121 | ]) 122 | 123 | AH_TEMPLATE([$3],[$4]) 124 | 125 | m4_popdef([FEATURE])dnl 126 | ]) 127 | 128 | dnl Feature global 129 | AC_DEFUN([AX_CONFIG_FEATURE_VERBOSE],[ dnl 130 | ax_config_feature_verbose=yes 131 | ]) 132 | 133 | dnl Feature global 134 | AC_DEFUN([AX_CONFIG_FEATURE_SILENT],[ dnl 135 | ax_config_feature_verbose=no 136 | ]) 137 | 138 | dnl Feature specific 139 | AC_DEFUN([AX_CONFIG_FEATURE_DEFAULT_ENABLED], [ 140 | ax_config_feature_[]FEATURE[]_default=yes 141 | ]) 142 | 143 | dnl Feature specific 144 | AC_DEFUN([AX_CONFIG_FEATURE_DEFAULT_DISABLED], [ 145 | ax_config_feature_[]FEATURE[]_default=no 146 | ]) 147 | 148 | dnl Feature specific 149 | AC_DEFUN([AX_CONFIG_FEATURE_ENABLE],[ dnl 150 | ax_config_feature_[]patsubst([$1], -, _)[]=yes 151 | ]) 152 | 153 | dnl Feature specific 154 | AC_DEFUN([AX_CONFIG_FEATURE_DISABLE],[ dnl 155 | ax_config_feature_[]patsubst([$1], -, _)[]=no 156 | ]) 157 | -------------------------------------------------------------------------------- /m4/ax_have_ctime_r.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_CTIME_R( 2 | # [AX_CONFIG_FEATURE_ENABLE(ctime_r)], 3 | # [AX_CONFIG_FEATURE_DISABLE(ctime_r)]) 4 | # AX_CONFIG_FEATURE( 5 | # [ctime_r], [This platform supports ctime_r(7)], 6 | # [HAVE_CTIME_R], [This platform supports ctime_r(7).]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_CTIME_R], [dnl 10 | ax_have_ctime_r_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for ctime_r()]) 12 | AC_CACHE_VAL([ax_cv_have_ctime_r], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | char timebuf@<:@32@:>@; 18 | time_t now = time(NULL); 19 | return !ctime_r(&now, timebuf);])], 20 | [ax_cv_have_ctime_r=yes], 21 | [ax_cv_have_ctime_r=no])]) 22 | CPPFLAGS="${ax_have_ctime_r_cppflags}" 23 | AS_IF([test "${ax_cv_have_ctime_r}" = "yes"], 24 | [AC_MSG_RESULT([yes]) 25 | $1],[AC_MSG_RESULT([no]) 26 | $2]) 27 | ])dnl 28 | 29 | #Based on the epoll check, hence: 30 | # LICENSE 31 | # 32 | # Copyright (c) 2008 Peter Simons 33 | # 34 | # Copying and distribution of this file, with or without modification, are 35 | # permitted in any medium without royalty provided the copyright notice 36 | # and this notice are preserved. This file is offered as-is, without any 37 | # warranty. 38 | -------------------------------------------------------------------------------- /m4/ax_have_eagain.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_EAGAIN( 2 | # [AX_CONFIG_FEATURE_ENABLE(EAGAIN)], 3 | # [AX_CONFIG_FEATURE_DISABLE(EAGAIN)]) 4 | # AX_CONFIG_FEATURE( 5 | # [EAGAIN], [This platform supports EAGAIN], 6 | # [HAVE_EAGAIN], [This platform supports EAGAIN.]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_EAGAIN], [dnl 10 | ax_have_eagain_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for EAGAIN]) 12 | AC_CACHE_VAL([ax_cv_have_eagain], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | return !EAGAIN;])], 18 | [ax_cv_have_eagain=yes], 19 | [ax_cv_have_eagain=no])]) 20 | CPPFLAGS="${ax_have_eagain_cppflags}" 21 | AS_IF([test "${ax_cv_have_eagain}" = "yes"], 22 | [AC_MSG_RESULT([yes]) 23 | $1],[AC_MSG_RESULT([no]) 24 | $2]) 25 | ])dnl 26 | 27 | #Based on the epoll check, hence: 28 | # LICENSE 29 | # 30 | # Copyright (c) 2008 Peter Simons 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | -------------------------------------------------------------------------------- /m4/ax_have_ewouldblock.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_EWOULDBLOCK( 2 | # [AX_CONFIG_FEATURE_ENABLE(EWOULDBLOCK)], 3 | # [AX_CONFIG_FEATURE_DISABLE(EWOULDBLOCK)]) 4 | # AX_CONFIG_FEATURE( 5 | # [EWOULDBLOCK], [This platform supports EWOULDBLOCK], 6 | # [HAVE_EWOULDBLOCK], [This platform supports EWOULDBLOCK.]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_EWOULDBLOCK], [dnl 10 | ax_have_ewouldblock_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for EWOULDBLOCK]) 12 | AC_CACHE_VAL([ax_cv_have_ewouldblock], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | return !EWOULDBLOCK;])], 18 | [ax_cv_have_ewouldblock=yes], 19 | [ax_cv_have_ewouldblock=no])]) 20 | CPPFLAGS="${ax_have_ewouldblock_cppflags}" 21 | AS_IF([test "${ax_cv_have_ewouldblock}" = "yes"], 22 | [AC_MSG_RESULT([yes]) 23 | $1],[AC_MSG_RESULT([no]) 24 | $2]) 25 | ])dnl 26 | 27 | #Based on the epoll check, hence: 28 | # LICENSE 29 | # 30 | # Copyright (c) 2008 Peter Simons 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | -------------------------------------------------------------------------------- /m4/ax_have_msg_nosignal.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_MSG_NOSIGNAL( 2 | # [AX_CONFIG_FEATURE_ENABLE(MSG_NOSIGNAL)], 3 | # [AX_CONFIG_FEATURE_DISABLE(MSG_NOSIGNAL)]) 4 | # AX_CONFIG_FEATURE( 5 | # [MSG_NOSIGNAL], [This platform supports MSG_NOSIGNAL], 6 | # [HAVE_MSG_NOSIGNAL], [This platform supports MSG_NOSIGNAL.]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_MSG_NOSIGNAL], [dnl 10 | ax_have_msg_nosignal_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for MSG_NOSIGNAL]) 12 | AC_CACHE_VAL([ax_cv_have_msg_nosignal], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | return !MSG_NOSIGNAL;])], 18 | [ax_cv_have_msg_nosignal=yes], 19 | [ax_cv_have_msg_nosignal=no])]) 20 | CPPFLAGS="${ax_have_msg_nosignal_cppflags}" 21 | AS_IF([test "${ax_cv_have_msg_nosignal}" = "yes"], 22 | [AC_MSG_RESULT([yes]) 23 | $1],[AC_MSG_RESULT([no]) 24 | $2]) 25 | ])dnl 26 | 27 | #Based on the epoll check, hence: 28 | # LICENSE 29 | # 30 | # Copyright (c) 2008 Peter Simons 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | -------------------------------------------------------------------------------- /m4/ax_have_siginfo.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_SIGINFO( 2 | # [AX_CONFIG_FEATURE_ENABLE(SIGINFO)], 3 | # [AX_CONFIG_FEATURE_DISABLE(SIGINFO)]) 4 | # AX_CONFIG_FEATURE( 5 | # [SIGINFO], [This platform supports SIGINFO], 6 | # [HAVE_SIGINFO], [This platform supports SIGINFO.]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_SIGINFO], [dnl 10 | ax_have_siginfo_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for SIGINFO]) 12 | AC_CACHE_VAL([ax_cv_have_siginfo], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | return !SIGINFO;])], 18 | [ax_cv_have_siginfo=yes], 19 | [ax_cv_have_siginfo=no])]) 20 | CPPFLAGS="${ax_have_siginfo_cppflags}" 21 | AS_IF([test "${ax_cv_have_siginfo}" = "yes"], 22 | [AC_MSG_RESULT([yes]) 23 | $1],[AC_MSG_RESULT([no]) 24 | $2]) 25 | ])dnl 26 | 27 | #Based on the epoll check, hence: 28 | # LICENSE 29 | # 30 | # Copyright (c) 2008 Peter Simons 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | -------------------------------------------------------------------------------- /m4/ax_have_sigint.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_SIGINT( 2 | # [AX_CONFIG_FEATURE_ENABLE(SIGINT)], 3 | # [AX_CONFIG_FEATURE_DISABLE(SIGINT)]) 4 | # AX_CONFIG_FEATURE( 5 | # [SIGINT], [This platform supports SIGINT], 6 | # [HAVE_SIGINT], [This platform supports SIGINT.]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_SIGINT], [dnl 10 | ax_have_sigint_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for SIGINT]) 12 | AC_CACHE_VAL([ax_cv_have_sigint], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | return !SIGINT;])], 18 | [ax_cv_have_sigint=yes], 19 | [ax_cv_have_sigint=no])]) 20 | CPPFLAGS="${ax_have_sigint_cppflags}" 21 | AS_IF([test "${ax_cv_have_sigint}" = "yes"], 22 | [AC_MSG_RESULT([yes]) 23 | $1],[AC_MSG_RESULT([no]) 24 | $2]) 25 | ])dnl 26 | 27 | #Based on the epoll check, hence: 28 | # LICENSE 29 | # 30 | # Copyright (c) 2008 Peter Simons 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | -------------------------------------------------------------------------------- /m4/ax_have_sigpipe.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_SIGPIPE( 2 | # [AX_CONFIG_FEATURE_ENABLE(SIGPIPE)], 3 | # [AX_CONFIG_FEATURE_DISABLE(SIGPIPE)]) 4 | # AX_CONFIG_FEATURE( 5 | # [SIGPIPE], [This platform supports SIGPIPE], 6 | # [HAVE_SIGPIPE], [This platform supports SIGPIPE.]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_SIGPIPE], [dnl 10 | ax_have_sigpipe_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for SIGPIPE]) 12 | AC_CACHE_VAL([ax_cv_have_sigpipe], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | return !SIGPIPE;])], 18 | [ax_cv_have_sigpipe=yes], 19 | [ax_cv_have_sigpipe=no])]) 20 | CPPFLAGS="${ax_have_sigpipe_cppflags}" 21 | AS_IF([test "${ax_cv_have_sigpipe}" = "yes"], 22 | [AC_MSG_RESULT([yes]) 23 | $1],[AC_MSG_RESULT([no]) 24 | $2]) 25 | ])dnl 26 | 27 | #Based on the epoll check, hence: 28 | # LICENSE 29 | # 30 | # Copyright (c) 2008 Peter Simons 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | -------------------------------------------------------------------------------- /m4/ax_have_sigusr1.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_SIGUSR1( 2 | # [AX_CONFIG_FEATURE_ENABLE(SIGUSR1)], 3 | # [AX_CONFIG_FEATURE_DISABLE(SIGUSR1)]) 4 | # AX_CONFIG_FEATURE( 5 | # [SIGUSR1], [This platform supports SIGUSR1], 6 | # [HAVE_SIGUSR1], [This platform supports SIGUSR1.]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_SIGUSR1], [dnl 10 | ax_have_sigusr1_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for SIGUSR1]) 12 | AC_CACHE_VAL([ax_cv_have_sigusr1], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | return !SIGUSR1;])], 18 | [ax_cv_have_sigusr1=yes], 19 | [ax_cv_have_sigusr1=no])]) 20 | CPPFLAGS="${ax_have_sigusr1_cppflags}" 21 | AS_IF([test "${ax_cv_have_sigusr1}" = "yes"], 22 | [AC_MSG_RESULT([yes]) 23 | $1],[AC_MSG_RESULT([no]) 24 | $2]) 25 | ])dnl 26 | 27 | #Based on the epoll check, hence: 28 | # LICENSE 29 | # 30 | # Copyright (c) 2008 Peter Simons 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | -------------------------------------------------------------------------------- /m4/ax_have_so_nosigpipe.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_SO_NOSIGPIPE( 2 | # [AX_CONFIG_FEATURE_ENABLE(SO_NOSIGPIPE)], 3 | # [AX_CONFIG_FEATURE_DISABLE(SO_NOSIGPIPE)]) 4 | # AX_CONFIG_FEATURE( 5 | # [SO_NOSIGPIPE], [This platform supports SO_NOSIGPIPE], 6 | # [HAVE_SO_NOSIGPIPE], [This platform supports SO_NOSIGPIPE.]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_SO_NOSIGPIPE], [dnl 10 | ax_have_so_nosigpipe_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for SO_NOSIGPIPE]) 12 | AC_CACHE_VAL([ax_cv_have_so_nosigpipe], [dnl 13 | AC_RUN_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | ], [dnl 17 | return !SO_NOSIGPIPE;])], 18 | [ax_cv_have_so_nosigpipe=yes], 19 | [ax_cv_have_so_nosigpipe=no])]) 20 | CPPFLAGS="${ax_have_so_nosigpipe_cppflags}" 21 | AS_IF([test "${ax_cv_have_so_nosigpipe}" = "yes"], 22 | [AC_MSG_RESULT([yes]) 23 | $1],[AC_MSG_RESULT([no]) 24 | $2]) 25 | ])dnl 26 | 27 | #Based on the epoll check, hence: 28 | # LICENSE 29 | # 30 | # Copyright (c) 2008 Peter Simons 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | -------------------------------------------------------------------------------- /m4/ax_have_vsyslog.m4: -------------------------------------------------------------------------------- 1 | # AX_HAVE_VSYSLOG( 2 | # [AX_CONFIG_FEATURE_ENABLE(vsyslog)], 3 | # [AX_CONFIG_FEATURE_DISABLE(vsyslog)]) 4 | # AX_CONFIG_FEATURE( 5 | # [vsyslog], [This platform supports vsyslog(7)], 6 | # [HAVE_VSYSLOG], [This platform supports vsyslog(7).]) 7 | # 8 | 9 | AC_DEFUN([AX_HAVE_VSYSLOG], [dnl 10 | ax_have_vsyslog_cppflags="${CPPFLAGS}" 11 | AC_MSG_CHECKING([for vsyslog() without having to define _DEFAULT_SOURCE]) 12 | AC_CACHE_VAL([ax_cv_have_vsyslog], [dnl 13 | AC_LINK_IFELSE([dnl 14 | AC_LANG_PROGRAM([dnl 15 | #include 16 | #include 17 | ], [dnl 18 | va_list l; 19 | vsyslog(1, "dummy", l);])], 20 | [ax_cv_have_vsyslog=yes], 21 | [ax_cv_have_vsyslog=no])]) 22 | CPPFLAGS="${ax_have_vsyslog_cppflags}" 23 | AS_IF([test "${ax_cv_have_vsyslog}" = "yes"], 24 | [AC_MSG_RESULT([yes]) 25 | $1],[AC_MSG_RESULT([no]) 26 | $2]) 27 | ])dnl 28 | 29 | #Based on the epoll check, hence: 30 | # LICENSE 31 | # 32 | # Copyright (c) 2008 Peter Simons 33 | # 34 | # Copying and distribution of this file, with or without modification, are 35 | # permitted in any medium without royalty provided the copyright notice 36 | # and this notice are preserved. This file is offered as-is, without any 37 | # warranty. 38 | -------------------------------------------------------------------------------- /platform/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libsrsircbase.la 2 | libsrsircbase_la_SOURCES = base_io.c base_net.c base_string.c base_misc.c base_time.c base_log.c base_log.h base_io.h base_misc.h base_net.h base_string.h base_time.h 3 | -------------------------------------------------------------------------------- /platform/base_io.c: -------------------------------------------------------------------------------- 1 | /* base_io.c - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_BASEIO 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include "base_io.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #if HAVE_SYS_SELECT_H 20 | # include 21 | #endif 22 | 23 | #if HAVE_UNISTD_H 24 | # include 25 | #endif 26 | 27 | #if HAVE_WINDOWS_H 28 | # include 29 | #endif 30 | 31 | #include 32 | 33 | 34 | long 35 | lsi_b_stdin_read(void *buf, size_t nbytes) 36 | { 37 | #if HAVE_FILENO 38 | int fd = fileno(stdin); 39 | #else 40 | W("assuming stdin to be fd 0..."); 41 | int fd = 0; 42 | #endif 43 | 44 | #if HAVE_READ 45 | D("reading from stdin"); 46 | ssize_t r = read(fd, buf, nbytes); 47 | if (r > LONG_MAX) { 48 | W("read too long, capping return value"); 49 | r = LONG_MAX; 50 | } else if (r < 0) { 51 | EE("read stdin"); 52 | } 53 | 54 | return (long)r; 55 | #else 56 | # error "We need something like read()" 57 | #endif 58 | } 59 | 60 | int 61 | lsi_b_stdin_fd(void) 62 | { 63 | #if HAVE_FILENO 64 | int fd = fileno(stdin); 65 | #else 66 | W("assuming stdin to be fd 0..."); 67 | int fd = 0; 68 | #endif 69 | return fd; 70 | } 71 | 72 | int 73 | lsi_b_stdin_canread(void) 74 | { 75 | #if HAVE_FILENO 76 | int fd = fileno(stdin); 77 | #else 78 | W("assuming stdin to be fd 0..."); 79 | int fd = 0; 80 | #endif 81 | 82 | int r = -1; 83 | 84 | #if HAVE_WINDOWS_H 85 | HANDLE h = GetStdHandle(STD_INPUT_HANDLE); 86 | uint32_t ret = WaitForSingleObjectEx(h ,0, 0); 87 | switch (ret) { 88 | case WAIT_TIMEOUT: r = 0; break; 89 | case WAIT_FAILED: r = -1; break; 90 | default: r = 1; break; 91 | } 92 | 93 | #elif HAVE_SELECT 94 | struct timeval tout = {0, 0}; 95 | 96 | V("select()ing stdin"); 97 | 98 | fd_set fds; 99 | FD_ZERO(&fds); 100 | FD_SET(fd, &fds); 101 | r = select(fd+1, &fds, NULL, NULL, &tout); 102 | 103 | if (r < 0) { 104 | int e = errno; 105 | EE("select"); 106 | return e == EINTR ? 0 : -1; 107 | } 108 | 109 | V("select: %d", r); 110 | #else 111 | # error "We need a way to tell whether stdin will block" 112 | #endif 113 | 114 | return r; 115 | } 116 | -------------------------------------------------------------------------------- /platform/base_io.h: -------------------------------------------------------------------------------- 1 | /* base_io.h - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_BASE_IO_H 6 | #define LIBSRSIRC_BASE_IO_H 1 7 | 8 | 9 | #include 10 | 11 | 12 | long lsi_b_stdin_read(void *buf, size_t nbytes); 13 | int lsi_b_stdin_canread(void); 14 | int lsi_b_stdin_fd(void); 15 | 16 | 17 | #endif /* LIBSRSIRC_BASE_IO_H */ 18 | -------------------------------------------------------------------------------- /platform/base_log.c: -------------------------------------------------------------------------------- 1 | /* base_misc.c - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #if HAVE_CONFIG_H 6 | # include 7 | #endif 8 | 9 | 10 | #include "base_log.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | #define MAX_LOGMSG 1024 20 | 21 | 22 | int 23 | lsi_b_strerror(int errnum, char *buf, size_t sz) 24 | { 25 | int r = 0; 26 | #if HAVE_STRERROR_R 27 | r = strerror_r(errnum, buf, sz) 28 | # if STRERROR_R_CHAR_P 29 | ? 0 : -1 30 | # endif 31 | ; 32 | #else 33 | snprintf(buf, sz, "Errno %d", errnum); 34 | #endif 35 | return r; 36 | } 37 | 38 | 39 | char * 40 | lsi_b_ctime(const time_t *t, char *buf) 41 | { 42 | #if HAVE_CTIME_R 43 | return ctime_r(t, buf); 44 | #else 45 | sprintf(buf, "%lu", !t ? 0lu : (unsigned long)*t); 46 | return buf; 47 | #endif 48 | } 49 | 50 | 51 | bool 52 | lsi_b_openlog(const char *ident) 53 | { 54 | #if HAVE_SYSLOG_H 55 | openlog(ident, LOG_PID, LOG_USER); 56 | return true; 57 | #endif 58 | return false; 59 | } 60 | 61 | 62 | void 63 | lsi_b_closelog(void) 64 | { 65 | #if HAVE_SYSLOG_H 66 | closelog(); 67 | #endif 68 | } 69 | 70 | 71 | void 72 | lsi_b_syslog(int prio, const char *fmt, ...) 73 | { 74 | #if HAVE_SYSLOG_H 75 | va_list l; 76 | va_start(l, fmt); 77 | // this is a bitch to get a prototype in scope without having 78 | // to define _BSD_SOURCE or _GNU_SOURCE, in glibc 79 | //# if HAVE_VSYSLOG 80 | // vsyslog(prio, fmt, l); 81 | //# else 82 | char buf[2048]; 83 | vsnprintf(buf, sizeof buf, fmt, l); 84 | syslog(prio, "%s", buf); 85 | //# endif 86 | va_end(l); 87 | #endif 88 | } 89 | -------------------------------------------------------------------------------- /platform/base_log.h: -------------------------------------------------------------------------------- 1 | /* base_log.h - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_BASE_LOG_H 6 | #define LIBSRSIRC_BASE_LOG_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | #if HAVE_SYSLOG_H 16 | # include 17 | #else 18 | # define LOG_CRIT 2 19 | # define LOG_ERR 3 20 | # define LOG_WARNING 4 21 | # define LOG_NOTICE 5 22 | # define LOG_INFO 6 23 | # define LOG_DEBUG 7 24 | #endif 25 | 26 | 27 | int lsi_b_strerror(int errnum, char *buf, size_t sz); 28 | char *lsi_b_ctime(const time_t *clock, char *buf); 29 | 30 | bool lsi_b_openlog(const char *ident); 31 | void lsi_b_closelog(void); 32 | void lsi_b_syslog(int prio, const char *fmt, ...); 33 | 34 | 35 | #endif /* LIBSRSIRC_BASE_LOG_H */ 36 | -------------------------------------------------------------------------------- /platform/base_misc.c: -------------------------------------------------------------------------------- 1 | /* base_misc.c - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_BASEMISC 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include "base_misc.h" 13 | 14 | #include 15 | #include 16 | 17 | #if HAVE_UNISTD_H 18 | # include 19 | #endif 20 | 21 | #include 22 | 23 | #include 24 | 25 | void 26 | lsi_b_usleep(uint64_t us) 27 | { 28 | V("Sleeping %"PRIu64" us", us); 29 | uint64_t secs = us / 1000000u; 30 | if (secs > INT_MAX) 31 | secs = INT_MAX; //eh.. yeah. 32 | 33 | #if HAVE_NANOSLEEP 34 | struct timespec tv = {(time_t)secs, (long)(us % 1000000u)*1000}; 35 | if (tv.tv_sec || tv.tv_nsec) 36 | nanosleep(&tv, NULL); 37 | #else 38 | # error "We need something like nanosleep() (or usleep()-ish)" 39 | #endif 40 | return; 41 | } 42 | 43 | int 44 | lsi_b_getopt(int argc, char * const argv[], const char *optstring) 45 | { 46 | #if HAVE_GETOPT 47 | return getopt(argc, argv, optstring); 48 | #else 49 | # error "We need something like getopt()" 50 | #endif 51 | } 52 | 53 | const char * 54 | lsi_b_optarg(void) 55 | { 56 | #if HAVE_GETOPT 57 | return optarg; 58 | #else 59 | # error "We need something like getopt()" 60 | #endif 61 | } 62 | 63 | int 64 | lsi_b_optind(void) 65 | { 66 | #if HAVE_GETOPT 67 | return optind; 68 | #else 69 | # error "We need something like getopt()'s optind" 70 | #endif 71 | } 72 | 73 | void 74 | lsi_b_regsig(int sig, void (*sigfn)(int)) 75 | { 76 | #if HAVE_SIGACTION 77 | struct sigaction act; 78 | act.sa_handler = sigfn; 79 | act.sa_flags = 0; 80 | if (sigemptyset(&act.sa_mask) != 0) { 81 | WE("sigemptyset"); 82 | } else if (sigaction(sig, &act, NULL) != 0) { 83 | WE("sigaction"); 84 | } 85 | #else 86 | W("No signal support; use a real OS for that"); 87 | #endif 88 | return; 89 | } 90 | 91 | void * 92 | lsi_b_malloc(size_t sz, const char *file, int line, const char *func) 93 | { 94 | void *r = malloc(sz); 95 | if (!r) 96 | /* NOTE: This does NOT call exit() or anything */ 97 | EE("malloc in %s() at %s:%d", func, file, line); 98 | return r; 99 | } 100 | -------------------------------------------------------------------------------- /platform/base_misc.h: -------------------------------------------------------------------------------- 1 | /* base_misc.h - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_BASE_MISC_H 6 | #define LIBSRSIRC_BASE_MISC_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | #define MALLOC(SZ) lsi_b_malloc((SZ), __FILE__, __LINE__, __func__) 13 | 14 | void lsi_b_usleep(uint64_t us); 15 | 16 | int lsi_b_getopt(int argc, char * const argv[], const char *optstring); 17 | const char *lsi_b_optarg(void); 18 | int lsi_b_optind(void); 19 | void lsi_b_regsig(int sig, void (*sigfn)(int)); 20 | void *lsi_b_malloc(size_t sz, const char *file, int line, const char *func); 21 | 22 | #endif /* LIBSRSIRC_BASE_MISC_H */ 23 | -------------------------------------------------------------------------------- /platform/base_net.h: -------------------------------------------------------------------------------- 1 | /* base_net.h - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_BASE_NET_H 6 | #define LIBSRSIRC_BASE_NET_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef WITH_SSL 14 | # include 15 | # include 16 | #endif 17 | 18 | 19 | struct addrlist { 20 | char addrstr[64]; 21 | char reqname[256]; 22 | uint16_t port; 23 | bool ipv6; 24 | 25 | struct addrlist *next; 26 | }; 27 | 28 | 29 | #ifdef WITH_SSL 30 | typedef SSL *SSLTYPE; 31 | typedef SSL_CTX *SSLCTXTYPE; 32 | #else 33 | typedef void *SSLTYPE; 34 | typedef void *SSLCTXTYPE; 35 | #endif 36 | 37 | 38 | int lsi_b_socket(bool ipv6); 39 | int lsi_b_connect(int sck, const struct addrlist *srv); 40 | bool lsi_b_bind(int sck, const char *addr, uint16_t port, bool ipv6); 41 | int lsi_b_close(int sck); 42 | int lsi_b_select(int *fds, size_t nfds, bool noresult, bool rdbl, 43 | uint64_t to_us); 44 | 45 | bool lsi_b_blocking(int sck, bool blocking); 46 | bool lsi_b_sock_ok(int sck); 47 | 48 | long lsi_b_read(int sck, void *buf, size_t sz, uint64_t to_us); 49 | long lsi_b_write(int sck, const void *buf, size_t len); 50 | 51 | bool lsi_b_have_ssl(void); 52 | long lsi_b_read_ssl(SSLTYPE ssl, void *buf, size_t sz, uint64_t to_us); 53 | long lsi_b_write_ssl(SSLTYPE ssl, const void *buf, size_t len); 54 | 55 | int lsi_b_mkaddrlist(const char *host, uint16_t port, struct addrlist **res); 56 | void lsi_b_freeaddrlist(struct addrlist *al); 57 | 58 | SSLCTXTYPE lsi_b_mksslctx(void); 59 | void lsi_b_freesslctx(SSLCTXTYPE sslctx); 60 | 61 | SSLTYPE lsi_b_sslize(int sck, SSLCTXTYPE sslctx); 62 | void lsi_b_sslfin(SSLTYPE shnd); 63 | 64 | uint16_t lsi_b_htons(uint16_t h); 65 | uint32_t lsi_b_inet_addr(const char *ip4str); 66 | bool lsi_b_inet4_addr(unsigned char *dest, size_t destsz, const char *ip4str); 67 | bool lsi_b_inet6_addr(unsigned char *dest, size_t destsz, const char *ip6str); 68 | 69 | #endif /* LIBSRSIRC_BASE_NET_H */ 70 | -------------------------------------------------------------------------------- /platform/base_string.c: -------------------------------------------------------------------------------- 1 | /* base_string.c - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_BASESTR 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include 13 | #include 14 | 15 | #if HAVE_STRINGS_H 16 | # include 17 | #endif 18 | 19 | #include "base_string.h" 20 | 21 | #include 22 | 23 | #include 24 | 25 | 26 | void 27 | lsi_b_strNcat(char *dest, const char *src, size_t destsz) 28 | { 29 | const char *osrc = src; 30 | size_t len = strlen(dest); 31 | if (len + 1 >= destsz) { 32 | W("Buffer already full, cannot concatenate '%s'", osrc); 33 | return; 34 | } 35 | size_t rem = destsz - (len + 1); 36 | 37 | char *ptr = dest + len; 38 | while (rem-- && *src) { 39 | *ptr++ = *src++; 40 | } 41 | 42 | if (rem + 1 == 0 && *src) 43 | W("Buffer was too small for '%s', result truncated", osrc); 44 | 45 | *ptr = '\0'; 46 | return; 47 | } 48 | 49 | void 50 | lsi_b_strNcpy(char *dest, const char *src, size_t destsz) 51 | { 52 | if (!destsz) 53 | return; 54 | 55 | do { 56 | destsz--; 57 | if (!(*dest++ = *src++)) 58 | break; 59 | } while (destsz); 60 | 61 | if (!destsz) 62 | dest[-1] = '\0'; 63 | 64 | return; 65 | } 66 | 67 | int 68 | lsi_b_strcasecmp(const char *a, const char *b) 69 | { 70 | #if HAVE_STRCASECMP 71 | return strcasecmp(a, b); 72 | #else 73 | return lsi_b_strncasecmp(a, b, strlen(a) + 1); 74 | #endif 75 | } 76 | 77 | int 78 | lsi_b_strncasecmp(const char *a, const char *b, size_t n) 79 | { 80 | #if HAVE_STRNCASECMP 81 | return strncasecmp(a, b, n); 82 | #else 83 | unsigned char ua, ub; 84 | do { 85 | if (!n--) 86 | break; 87 | 88 | ua = (unsigned char)*a++; 89 | ub = (unsigned char)*b++; 90 | 91 | } while (ua && ub && (ua == ub || tolower(ua) == tolower(ub))); 92 | 93 | if (!ua && !ub) 94 | return 0; 95 | 96 | if (!ua) 97 | return -1; 98 | 99 | if (!ub) 100 | return 1; 101 | 102 | return (int)ua - ub; 103 | #endif 104 | } 105 | 106 | char * 107 | lsi_b_strdup(const char *s, const char *file, int line, const char *func) 108 | { 109 | char *r = NULL; 110 | r = MALLOC(strlen(s)+1); 111 | if (r) 112 | strcpy(r, s); 113 | 114 | return r; 115 | } 116 | -------------------------------------------------------------------------------- /platform/base_string.h: -------------------------------------------------------------------------------- 1 | /* base_string.h - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_BASE_STRING_H 6 | #define LIBSRSIRC_BASE_STRING_H 1 7 | 8 | 9 | #include 10 | 11 | 12 | #define STRACAT(DSTARR, STR) lsi_b_strNcat((DSTARR), (STR), sizeof (DSTARR)) 13 | #define STRACPY(DSTARR, STR) lsi_b_strNcpy((DSTARR), (STR), sizeof (DSTARR)) 14 | 15 | #define STRDUP(STR) lsi_b_strdup((STR), __FILE__, __LINE__, __func__) 16 | 17 | 18 | void lsi_b_strNcat(char *dest, const char *src, size_t destsz); 19 | void lsi_b_strNcpy(char *dest, const char *src, size_t destsz); 20 | 21 | int lsi_b_strcasecmp(const char *a, const char *b); 22 | int lsi_b_strncasecmp(const char *a, const char *b, size_t n); 23 | char *lsi_b_strdup(const char *s, const char *file, int line, const char *func); 24 | 25 | 26 | #endif /* LIBSRSIRC_BASE_STRING_H */ 27 | -------------------------------------------------------------------------------- /platform/base_time.c: -------------------------------------------------------------------------------- 1 | /* base_time.c - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_BASETIME 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "base_time.h" 17 | 18 | #if HAVE_SYS_TIME_H 19 | # include 20 | #endif 21 | 22 | #include 23 | 24 | #if HAVE_GETTIMEOFDAY 25 | static void com_tconv(struct timeval *tv, uint64_t *ts, bool tv_to_ts); 26 | #endif 27 | 28 | uint64_t 29 | lsi_b_tstamp_us(void) 30 | { 31 | #if HAVE_GETTIMEOFDAY 32 | struct timeval t; 33 | uint64_t ts = 0; 34 | if (gettimeofday(&t, NULL) != 0) 35 | EE("gettimeofday"); 36 | else 37 | com_tconv(&t, &ts, true); 38 | 39 | return ts; 40 | #else 41 | # error "We need something like gettimeofday()" 42 | #endif 43 | } 44 | 45 | #if HAVE_GETTIMEOFDAY 46 | static void 47 | com_tconv(struct timeval *tv, uint64_t *ts, bool tv_to_ts) 48 | { 49 | if (tv_to_ts) 50 | *ts = (uint64_t)tv->tv_sec * 1000000 + tv->tv_usec; 51 | else { 52 | tv->tv_sec = *ts / 1000000; 53 | tv->tv_usec = *ts % 1000000; 54 | } 55 | return; 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /platform/base_time.h: -------------------------------------------------------------------------------- 1 | /* base_time.h - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_BASE_TIME_H 6 | #define LIBSRSIRC_BASE_TIME_H 1 7 | 8 | 9 | uint64_t lsi_b_tstamp_us(void); 10 | 11 | 12 | #endif /* LIBSRSIRC_BASE_TIME_H */ 13 | -------------------------------------------------------------------------------- /scripts/addtrace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | noreturns=false 4 | if [ "x$1" = "x-n" ]; then 5 | noreturns=true 6 | shift 7 | fi 8 | 9 | if ! [ -d ./tracer ]; then 10 | echo "please run from top-level directory" >&2 11 | exit 1 12 | fi 13 | 14 | if [ $(git status --porcelain | grep -v '^??' | wc -l) -ne 0 ]; then 15 | echo "please clean up your working directory first (untracked files are okay)" >&2 16 | exit 1 17 | fi 18 | 19 | echo "NOTE: use savetrace.sh to save updated tracers, use git reset --hard to get rid of the mess" >&2 20 | 21 | tmp=$(mktemp /tmp/droptrace.sh.XXXXXXXX) 22 | trap "rm -f '$tmp'" EXIT 23 | 24 | find tracer -name 'tracer@*' | while read -r f; do 25 | file="$(printf '%s\n' "$f" | cut -d '@' -f 2 | tr '%' '/')" 26 | func="$(printf '%s\n' "$f" | cut -d '@' -f 3)" 27 | 28 | lno="$(grep -nh -A4 "^$func(" "$file" | grep '^[0-9][0-9]*-{' | cut -d - -f 1)" 29 | 30 | if [ -z "$lno" ]; then 31 | echo "Not found: '$func' in '$file'" >&2 32 | continue 33 | fi 34 | 35 | echo "File: '$file', Func: '$func', Line: $lno" >&2 36 | cat "$file" | sed -e "${lno}q" | sed '$d' >$tmp 37 | cat "$f" >>$tmp 38 | cat "$file" | sed -n "$((lno+1)),\$p" >>$tmp 39 | cat $tmp >$file 40 | done 41 | 42 | if $noreturns; then 43 | exit 0 44 | fi 45 | 46 | find libsrsirc platform src -name '*.c' | grep -vF -e 'base_log.c' -e 'helloworld.c' -e 'base_time.c' | while read -r f; do 47 | echo "doing returns for $f" >&2 48 | scripts/replret.sh "$f" 49 | done 50 | -------------------------------------------------------------------------------- /scripts/gentests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | tmp=/tmp/gentests.tmp 6 | 7 | trap 'rm -f "$tmp"' EXIT 8 | 9 | cd unittests 10 | for f in test_*.c; do 11 | 12 | echo "#include \"$f\"" >"$tmp" 13 | echo 'int main(void) {' >>"$tmp" 14 | echo 'const char *errmsg;' >>"$tmp" 15 | echo 'int ret = 0;' >>"$tmp" 16 | 17 | grep -FA1 '/*UNITTEST*/' "$f" | while read line1; do 18 | if [ "$line1" = "--" ]; then #grep's context separator; skip it 19 | read line1 20 | fi 21 | read line2 22 | #echo "line1 is '$line1', line2 is '$line2'" 23 | 24 | tname=$(basename "$f" .c) 25 | fname=$(echo "$line2" | sed 's/(.*$//') 26 | arglist="$(echo "$line2" | sed -e 's/^[^(]*(//' -e 's/)[ \t]*$//')" 27 | #echo "fname is '$fname', arglist is '$arglist'" 28 | 29 | if [ "$arglist" != "void" ]; then 30 | echo "non-void args not supported ATM" >&2 31 | exit 1 32 | fi 33 | 34 | 35 | 36 | cat <>"$tmp" 37 | printf("Running UTNAME..."); 38 | fflush(stdout); 39 | errmsg = UTFUNC(); 40 | if (errmsg) { 41 | printf("FAILED: %s\n", errmsg); 42 | ret = 1; 43 | } else 44 | printf("Ok\n"); 45 | EOF 46 | done 47 | 48 | echo 'return ret;' >>"$tmp" 49 | echo '}' >>"$tmp" 50 | 51 | cat "$tmp" >"run_${f}" 52 | done 53 | 54 | -------------------------------------------------------------------------------- /scripts/mknetlist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #set -x 3 | 4 | site="$1" 5 | 6 | prgnam="$(basename "$0")" 7 | 8 | Warn() 9 | { 10 | printf '%s: WARNING: %s\n' "$prgnam" "$*" >&2 11 | } 12 | 13 | Nuke() 14 | { 15 | printf '%s: ERROR: %s\n' "$prgnam" "$*" >&2 16 | exit 1 17 | } 18 | 19 | [ -z "$site" ] && Nuke "Usage: $prgnam []" 20 | 21 | throttle= 22 | [ -n "$2" ] && throttle="$2" 23 | 24 | tmp="$(mktemp /tmp/$prgnam.netlist.XXXXXXXXX)" 25 | netnames="$(mktemp /tmp/$prgnam.netnames.XXXXXXXXX)" 26 | tab="$(printf '\t')" 27 | 28 | trap "rm '$netnames' '$tmp'" EXIT 29 | trap 'exit 1' HUP INT TERM QUIT 30 | 31 | grep='pcregrep' 32 | command -v "$grep" >/dev/null 2>/dev/null || grep="grep -P" 33 | 34 | wget -qO - http://$site/networks/ | grep -o 'href="/networks/[^/]*/"' | sed -n 's,href="/networks/\([^/]*\)/",\1,p' | sort | uniq >"$netnames" 35 | 36 | c=0 37 | while read -r netname; do 38 | chunk="$(mktemp /tmp/$prgnam.chunk.$netname.XXXXXXXXX)" 39 | wget -qO - "http://$site/servers/?net=$(printf '%s\n' "$netname" | sed 's/ /%20/g')" >$chunk 40 | grep -FA9001 "servers used to connect" "$chunk" | grep -FB9001 "servers last connected to" | grep -FA9001 "Main
Server" \ 41 | | sed 's/​//g' | $grep -o '.*?' | sed -e "s/ style='[^']*' *//g" -e "s/ align='[^']*' *//g" | sed 's///g' \ 42 | | sed -e 's,, ,g' -e 's///' -e 's,,,' | while read -r host port ssl rest; do # oh well 43 | case "$ssl" in 44 | [oO][fF][fF]) sslstr= ;; 45 | [oO][nN]) sslstr='/SSL' ;; 46 | *) Nuke "??? (ssl is '$ssl')" ;; 47 | esac 48 | 49 | printf "%s$tab%s:%s%s\\n" "$netname" "$host" "$port" "$sslstr" 50 | done >$tmp 51 | 52 | if ! [ -s "$tmp" ]; then 53 | Warn "Got nothing for netname '$netname', left output in '$chunk'" 54 | else 55 | cat "$tmp" 56 | rm "$chunk" 57 | fi 58 | 59 | [ -n "$throttle" ] && sleep $throttle 60 | done <"$netnames" 61 | -------------------------------------------------------------------------------- /scripts/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! [ "$(git rev-parse --abbrev-ref HEAD)" = 'devel' ]; then 4 | echo 'Be on the devel branch first.' >&2 5 | exit 1 6 | fi 7 | 8 | newver="$(grep '^AC_INIT' configure.ac | grep -o '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*')" 9 | echo "Be on the devel branch." >&2 10 | echo "Manually update AND STAGE all version references, but do not commit yet." >&2 11 | echo "Be sure to not have any unstaged changes to files under version control." >&2 12 | echo "Then, run this script." >&2 13 | echo "Have you done that, and is $newver the correct (new) version? (Answer YES)" >&2 14 | read -r ans 15 | if ! [ "x$ans" = 'xYES' ]; then 16 | echo "That wasn't a YES." >&2 17 | exit 1 18 | fi 19 | 20 | set -e 21 | 22 | git commit -m "bump version to $newver" 23 | git push origin devel 24 | git checkout master 25 | git merge devel 26 | git push origin master 27 | git tag -a "v$newver" -m "version $newver" 28 | git push --tags 29 | 30 | ./autoclean.sh 31 | ./autogen.sh 32 | ./configure 33 | make dist 34 | 35 | echo "Copy libsrsirc-$newver.tar.gz to C:\libsrsirc-$newver.tar.gz" >&2 36 | echo "on the Windows build box." >&2 37 | echo "Follow the build instructions (doc/winbuild.txt) to build the stuff" >&2 38 | echo "Copy back the generated libsrsirc-$newver-winbin.tarbomb.gz here." >&2 39 | echo "Hit enter when done." >&2 40 | 41 | read -r dummy 42 | while ! [ -f libsrsirc-$newver-winbin.tarbomb.gz ]; do 43 | echo "Copy back the generated libsrsirc-$newver-winbin.tarbomb.gz here." >&2 44 | echo "Hit enter when done." >&2 45 | read -r dummy 46 | done 47 | 48 | 49 | mkdir dist windist 50 | cd dist/ 51 | 52 | tar -xzpf ../libsrsirc-$newver.tar.gz 53 | cd ../windist/ 54 | tar -xzf ../libsrsirc-$newver-winbin.tarbomb.gz 55 | cp *.exe libsrsirc-0.dll libgcc*.dll ../dist/libsrsirc-$newver/ 56 | cd ../dist/ 57 | zip -r libsrsirc-$newver-win.zip libsrsirc-$newver 58 | mv libsrsirc-$newver-win.zip .. 59 | cd .. 60 | rm -rf dist windist 61 | 62 | 63 | git checkout tar 64 | git add libsrsirc-$newver.tar.gz 65 | git add libsrsirc-$newver-win.zip 66 | git commit -m "$newver tarball and zip" 67 | git push origin tar 68 | 69 | git checkout devel 70 | 71 | echo "Okay." 72 | exit 0 73 | -------------------------------------------------------------------------------- /scripts/replret.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # this is utterly inefficient 4 | 5 | FmtSpec() 6 | { 7 | t="$1" 8 | fld="$2" # 2: fmt spec, 3: cast type 9 | cat scripts/retprint | while read -r lin; do 10 | rty="$(printf '%s\n' "$lin" | cut -d : -f 1)" 11 | if [ "x$rty" '=' "x$t" ]; then 12 | printf '%s\n' "$lin" | cut -d : -f $fld 13 | break; 14 | fi 15 | done 16 | } 17 | 18 | file="$1" 19 | 20 | tmp="$(mktemp /tmp/replret.sh.XXXXXX)" 21 | work="$(mktemp /tmp/replret.sh.XXXXXX)" 22 | 23 | cat "$file" >$work 24 | 25 | TAB="$(printf '\tx')"; TAB="${TAB%x}" 26 | 27 | grep -whn "^[ $TAB]*return" "$file" | while read -r ln; do 28 | lno="$(printf '%s\n' "$ln" | cut -d : -f 1)" 29 | ln="${ln#*:}" 30 | 31 | semilno="$lno" 32 | if ! printf '%s\n' "$ln" | grep -qF ';'; then 33 | while ! sed -n ${semilno}p "$file" | grep -qF ';'; do 34 | semilno=$((semilno+1)) 35 | done 36 | fi 37 | 38 | typelno=$lno 39 | while ! sed -n ${typelno}p "$file" | grep -q '^{'; do 40 | typelno=$((typelno-1)) 41 | done 42 | 43 | typelno=$((typelno-1)) 44 | 45 | while sed -n ${typelno}p "$file" | grep -q "^[ $TAB]"; do 46 | typelno=$((typelno-1)) 47 | done 48 | 49 | typelno=$((typelno-1)) 50 | 51 | type="$(sed -n ${typelno}p "$file")" 52 | type="${type#static }" 53 | 54 | fmtspec="$(FmtSpec "$type" 2)" 55 | castto="$(FmtSpec "$type" 3)" 56 | if [ -z "$fmtspec" ]; then 57 | printf 'No fmt spec found for type `%s`!\n' "$type" >&2 58 | exit 1 59 | fi 60 | 61 | if [ "x$type" '=' "xtokarr *(*" ]; then 62 | # special case, the logonconv function 63 | type="void *" 64 | fi 65 | 66 | if [ "x$type" '=' "xvoid" ]; then 67 | sed "${lno}s/return/TRCRETURNVOID/" $work >$tmp 68 | cat $tmp >$work 69 | else 70 | sed "${lno}s/return/TRCRETURN($type, \"$fmtspec\", $castto, (/" $work >$tmp 71 | sed "${semilno}s/;/));/" $tmp >$work 72 | fi 73 | done 74 | 75 | cat >$tmp <<'EOF' 76 | #define TRCRETURN(TYPE, FMTSPEC, CASTTO, EXPR) do { TYPE _ret = (EXPR); TR("RET: " FMTSPEC, (CASTTO)_ret); return _ret; } while(0) 77 | #define TRCRETURNVOID do { TR("RET: (void)"); return; } while(0) 78 | EOF 79 | 80 | cat $work >>$tmp 81 | cat $tmp >"$file" 82 | -------------------------------------------------------------------------------- /scripts/retprint: -------------------------------------------------------------------------------- 1 | SSLCTXTYPE:%p:void * 2 | SSLTYPE:%p:void * 3 | bool:%d:int 4 | bucklist *:%p:void * 5 | chan *:%p:void * 6 | chanrep *:%p:void * 7 | char:%d:int 8 | char *:'%s':char * 9 | char **:%p:void * 10 | const char *:'%s':const char * 11 | enum hosttypes:%d:int 12 | iconn *:%p:void * 13 | int:%d:int 14 | irc *:%p:void * 15 | long:%ld:long 16 | memb *:%p:void * 17 | size_t:%zu:size_t 18 | skmap *:%p:void * 19 | tokarr *:%p:void * 20 | tokarr *(*:%p:void * 21 | uint16_t:%"PRIu16":uint16_t 22 | uint32_t:%"PRIu32":uint32_t 23 | uint64_t:%"PRIu64":uint64_t 24 | uint8_t:%"PRIu8":uint8_t 25 | user *:%p:void * 26 | userrep *:%p:void * 27 | void *:%p:void * 28 | void:(void):void 29 | -------------------------------------------------------------------------------- /scripts/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | tmp=$(mktemp /tmp/runtests.XXXXX) 6 | 7 | trap 'rm -f "$tmp"' EXIT 8 | 9 | cd unittests 10 | for f in test_*; do 11 | if [ ! -x "$f" -o ! -f "$f" ]; then 12 | continue 13 | fi 14 | 15 | if ! ./${f}; then 16 | echo 1 >"$tmp" 17 | fi 18 | done 19 | 20 | if [ -z "$(cat "$tmp")" ]; then 21 | exit 0 22 | else 23 | echo "!!! Some unit tests failed !!!" 24 | exit 1 25 | fi 26 | -------------------------------------------------------------------------------- /scripts/savetrace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! [ -d ./tracer ]; then 4 | echo "please run from top-level directory" >&2 5 | exit 1 6 | fi 7 | 8 | tmp3=$(mktemp /tmp/droptrace.sh.XXXXXXXX) 9 | tmp2=$(mktemp /tmp/droptrace.sh.XXXXXXXX) 10 | tmp4=$(mktemp /tmp/droptrace.sh.XXXXXXXX) 11 | tmp=$(mktemp /tmp/droptrace.sh.XXXXXXXX) 12 | trap "rm -f '$tmp' '$tmp2' '$tmp3' '$tmp4'" EXIT 13 | 14 | rm ./tracer/* 15 | 16 | find libsrsirc src platform -name '*.c' | while read -r f; do 17 | echo "Processing $f" >&2 18 | sed 's/^/x/' "$f" >$tmp4 19 | 20 | fnn="$(printf '%s\n' "$f" | tr '/' '%')" 21 | 22 | lno=0 23 | cat "$tmp4" | while read -r ln; do 24 | ln="${ln#x}" 25 | if [ -z "$lno" ]; then 26 | lno=1 27 | else 28 | lno=$((lno+1)) 29 | fi 30 | 31 | if printf '%s\n' "$ln" | grep -o '^[a-zA-Z_][a-zA-Z0-9_]*(' >$tmp3; then 32 | lastfunc="$(cat $tmp3)" 33 | lastfunc="${lastfunc%?}" 34 | continue; 35 | fi 36 | 37 | case "$ln" in 38 | "{ TC("*) sed -n ${lno}p $f >"tracer/tracer@${fnn}@${lastfunc}" ;; 39 | esac 40 | done 41 | done 42 | -------------------------------------------------------------------------------- /scripts/winbuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mingwroot='/c/MinGW' #MUST be an absolute path starting with // 4 | tardir='/c/' #where the tarball has to sit 5 | workdir='/c/libsrsirc' #where we build. NOTE THAT we rm -rf and recreate this 6 | 7 | # Constructed from $mingwroot 8 | compiler="$(printf '%c' "${mingwroot#?}"):/${mingwroot#???}/bin/gcc.exe" 9 | 10 | if [ "x$1" = 'x-h' ]; then 11 | echo "Usage: $0 [] ["release"]" >&2 12 | echo " version can be omitted if there is only one libsrsirc tarball in C:/" >&2 13 | echo " if the string 'release' is present, tar up the resulted executables and the DLL" >&2 14 | exit 0 15 | fi 16 | 17 | if [ -z "$1" ] || [ "x$1" = 'xrelease' ]; then 18 | if [ $(ls $tardir | grep 'libsrsirc-[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.tar\.gz' | wc -l) -eq 1 ]; then 19 | VERSION="$(ls $tardir | grep 'libsrsirc-[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.tar\.gz' | grep -o '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*')" 20 | printf "autodetected " >&2 21 | else 22 | echo "Usage: $0 ["release"]" >&2 23 | exit 1 24 | fi 25 | else 26 | if ! printf '%s\n' "$1" | grep -q '^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$'; then 27 | echo "'$1' does not look like a correct version" >&2 28 | exit 1 29 | fi 30 | VERSION="$1" 31 | shift 32 | fi 33 | 34 | echo "version: $VERSION" >&2 35 | 36 | rel=false 37 | if [ "x$1" = "xrelease" ]; then 38 | rel=true 39 | fi 40 | 41 | if ! [ -f $tardir/libsrsirc-$VERSION.tar.gz ]; then 42 | echo "Coult not find $tardir/libsrsirc-$VERSION.tar.gz" >&2 43 | exit 1 44 | fi 45 | 46 | rm -rf $workdir 47 | 48 | if [ -e $workdir ]; then 49 | echo "Could not get rid of $workdir; remove manually" >&2 50 | exit 1 51 | fi 52 | 53 | mkdir $workdir 54 | 55 | if ! [ -d $workdir ]; then 56 | echo "Could not create $workdir; bad permissions?" >&2 57 | exit 1 58 | fi 59 | 60 | cd $workdir 61 | tar -xzf $tardir/libsrsirc-$VERSION.tar.gz 62 | cd libsrsirc-$VERSION 63 | export PATH="$mingwroot/bin:/bin" 64 | echo "Configuring (stdout goes to configure.out, stderr to configure.err)" >&2 65 | if ! ./configure CC=$compiler >configure.out 2>configure.err; then 66 | echo "Configure failed" >&2 67 | exit 1 68 | fi 69 | 70 | echo "Building (stdout goes to make.out, stderr to make.err)" >&2 71 | if ! make >make.out 2>make.err; then 72 | echo "Make failed" >&2 73 | exit 1 74 | fi 75 | 76 | if ! $rel; then 77 | echo "All done" >&2 78 | exit 0 79 | fi 80 | 81 | mkdir disttmp 82 | 83 | cd disttmp 84 | 85 | mkdir buildinfo 86 | cp ../configure.out ../configure.err ../make.out ../make.err ../config.status ../config.log ../config.h buildinfo/ 87 | date >buildinfo/timestamp 88 | uname -a >buildinfo/buildbox 89 | 90 | for f in ../src/*.exe; do 91 | cp "$f" "stripped_$(basename $f)" 92 | done 93 | cp ../src/.libs/*.exe ./ 94 | cp ../libsrsirc/.libs/*.dll $mingwroot/bin/libgcc_s_dw2-1.dll ./ 95 | 96 | tar -czf ../libsrsirc-$VERSION-winbin.tarbomb.gz * 97 | cd .. 98 | #rm -rf disttmp 99 | 100 | echo "Tarbomb with .exe and .dll created: libsrsirc-$VERSION-winbin.tarbomb.gz" >&2 101 | echo "All done" >&2 102 | exit 0 103 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = icat iwat 2 | noinst_PROGRAMS = helloworld 3 | 4 | icat_SOURCES = icat_core.c icat_init.c icat_misc.c icat_serv.c icat_user.c icat_common.h icat_core.h icat_misc.h icat_serv.h icat_user.h 5 | icat_CPPFLAGS = -I$(top_srcdir)/include 6 | icat_LDADD = $(top_srcdir)/logger/libsrsirclog.la $(top_srcdir)/libsrsirc/libsrsirc.la 7 | 8 | iwat_SOURCES = iwat.c 9 | iwat_CPPFLAGS = -I$(top_srcdir)/include 10 | iwat_LDADD = $(top_srcdir)/libsrsirc/libsrsirc.la 11 | 12 | helloworld_SOURCES = helloworld.c 13 | helloworld_CPPFLAGS = -I$(top_srcdir)/include 14 | helloworld_LDADD = $(top_srcdir)/libsrsirc/libsrsirc.la 15 | -------------------------------------------------------------------------------- /src/helloworld.c: -------------------------------------------------------------------------------- 1 | /* helloworld.c - trivial libsrsirc example. Join a chan, write a message 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | #include 11 | 12 | 13 | #define IRC_SERVER "irc.libera.chat" 14 | #define IRC_PORT 6667 15 | #define IRC_CHANNEL "#fstd" 16 | #define IRC_NICK "libsrsirc" 17 | #define IRC_MESSAGE "Hello world!" 18 | 19 | 20 | int 21 | main(void) 22 | { 23 | /* Allocate and initialize new IRC context */ 24 | irc *ihnd = irc_init(); 25 | 26 | /* Set connection parameters */ 27 | irc_set_server(ihnd, IRC_SERVER, IRC_PORT); 28 | irc_set_nick(ihnd, IRC_NICK); 29 | 30 | /* Connect and logon to IRC */ 31 | if (!irc_connect(ihnd)) { 32 | fprintf(stderr, "could not connect/logon\n"); 33 | exit(EXIT_FAILURE); 34 | } 35 | 36 | /* Join channel, send message */ 37 | irc_printf(ihnd, "JOIN %s", IRC_CHANNEL); 38 | irc_printf(ihnd, "PRIVMSG %s :%s", IRC_CHANNEL, IRC_MESSAGE); 39 | 40 | for (;;) { 41 | tokarr msg; /* This is an array */ 42 | 43 | /* Read a protocol message into `msg`, 500ms timeout */ 44 | int r = irc_read(ihnd, &msg, 500000); 45 | 46 | /* Read failure, connection closed? */ 47 | if (r < 0) 48 | break; 49 | 50 | /* Read timeout */ 51 | if (r == 0) 52 | continue; 53 | 54 | /* r is >0, so we have read something. 55 | * msg[0] points to the prefix, if any 56 | * msg[1] points to the command 57 | * msg[2+] point to the arguments, if any */ 58 | 59 | /* This COULD also be done by registering dedicated 60 | * handler functions for PING and PRIVMSG */ 61 | if (strcmp(msg[1], "PING") == 0) 62 | irc_printf(ihnd, "PONG %s", msg[2]); 63 | else if (strcmp(msg[1], "PRIVMSG") == 0) { 64 | printf("Message from %s to %s: %s\n", msg[0], msg[2], msg[3]); 65 | /* If someone says "die", we die. */ 66 | if (strcmp(msg[3], "die") == 0) 67 | break; 68 | } 69 | } 70 | 71 | /* Clean up */ 72 | irc_dispose(ihnd); 73 | 74 | return EXIT_SUCCESS; 75 | } 76 | -------------------------------------------------------------------------------- /src/icat_common.h: -------------------------------------------------------------------------------- 1 | /* icat_common.h - Declarations used across icat 2 | * icat - IRC netcat on top of libsrsirc - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_ICAT_COMMON_H 6 | #define LIBSRSIRC_ICAT_COMMON_H 1 7 | 8 | 9 | #include 10 | #include 11 | 12 | 13 | #define MOD_INIT 0 14 | #define MOD_CORE 1 15 | #define MOD_SERV 2 16 | #define MOD_USER 3 17 | #define MOD_MISC 4 18 | 19 | #define MAX_CHANLIST 512 20 | 21 | #define DEF_CONTO_SOFT_MS 15000u 22 | #define DEF_CONTO_HARD_MS 120000u 23 | #define DEF_LINEDELAY_MS 2000u 24 | #define DEF_FREELINES 0u 25 | #define DEF_WAITQUIT_MS 3000u 26 | #define DEF_CONFAILWAIT_MS 10000u 27 | #define DEF_HEARTBEAT_MS 30000 28 | #define DEF_IGNORE_PM true 29 | #define DEF_IGNORE_CHANSERV true 30 | #define DEF_VERB 1 31 | #define DEF_QMSG "IRC netcat - http://github.com/fstd/libsrsirc" 32 | 33 | 34 | struct srvlist_s { 35 | char *host; 36 | uint16_t port; 37 | bool ssl; 38 | struct srvlist_s *next; 39 | }; 40 | 41 | struct settings_s { 42 | char nick[64]; 43 | char uname[64]; 44 | char fname[128]; 45 | uint8_t conflags; 46 | char pass[64]; 47 | 48 | char pxhost[128]; 49 | uint16_t pxport; 50 | int pxtype; 51 | 52 | char laddr[64]; 53 | uint16_t lport; 54 | 55 | char saslname[128]; 56 | char saslpass[128]; 57 | bool starttls; 58 | bool starttls_req; 59 | int starttls_mode; 60 | 61 | bool trgmode; 62 | uint64_t cto_soft_us; 63 | uint64_t cto_hard_us; 64 | uint64_t linedelay; 65 | unsigned freelines; 66 | uint64_t waitquit_us; 67 | bool keeptrying; 68 | uint64_t cfwait_us; 69 | uint64_t hbeat_us; 70 | bool reconnect; 71 | bool nojoin; 72 | bool ignore_pm; 73 | bool ignore_cs; 74 | bool notices; 75 | char chanlist[MAX_CHANLIST]; 76 | char keylist[MAX_CHANLIST]; 77 | char *esc; 78 | char qmsg[512]; 79 | struct srvlist_s *srvlist; 80 | }; 81 | 82 | 83 | extern struct settings_s g_sett; 84 | extern bool g_interrupted; 85 | extern bool g_inforequest; 86 | 87 | 88 | #endif /* LIBSRSIRC_ICAT_COMMON_H */ 89 | -------------------------------------------------------------------------------- /src/icat_core.h: -------------------------------------------------------------------------------- 1 | /* icat_core.h - icat core, mainly links together icat_serv and icat_user 2 | * icat - IRC netcat on top of libsrsirc - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_ICAT_CORE_H 6 | #define LIBSRSIRC_ICAT_CORE_H 1 7 | 8 | 9 | void icat_core_init(void); 10 | void icat_core_destroy(void); 11 | 12 | int icat_core_run(void); 13 | 14 | 15 | #endif /* LIBSRSIRC_ICAT_CORE_H */ 16 | -------------------------------------------------------------------------------- /src/icat_misc.c: -------------------------------------------------------------------------------- 1 | /* icat_misc.c - Miscellaneous routines used in icat 2 | * icat - IRC netcat on top of libsrsirc - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_ICATMISC 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include "icat_misc.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include "icat_common.h" 27 | 28 | 29 | uint8_t 30 | icat_strtou8(const char *nptr, char **endptr, int base) 31 | { 32 | return (uint8_t)strtoul(nptr, endptr, base); 33 | } 34 | 35 | uint64_t 36 | icat_strtou64(const char *nptr, char **endptr, int base) 37 | { 38 | return (uint64_t)strtoull(nptr, endptr, base); 39 | } 40 | 41 | bool 42 | icat_ismychan(const char *chan) 43 | { 44 | char chans[sizeof g_sett.chanlist+2]; 45 | char search[512]; 46 | snprintf(chans, sizeof chans, ",%s,", g_sett.chanlist); 47 | snprintf(search, sizeof search, ",%s,", chan); 48 | 49 | return strstr(chans, search); 50 | } 51 | 52 | bool 53 | icat_isdigitstr(const char *str) 54 | { 55 | while (*str) 56 | if (!isdigit((unsigned char)*str++)) 57 | return false; 58 | 59 | return true; 60 | } 61 | -------------------------------------------------------------------------------- /src/icat_misc.h: -------------------------------------------------------------------------------- 1 | /* icat_misc.h - Miscellaneous routines used in icat 2 | * icat - IRC netcat on top of libsrsirc - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_ICAT_MISC_H 6 | #define LIBSRSIRC_ICAT_MISC_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | 15 | uint8_t icat_strtou8(const char *nptr, char **endptr, int base); 16 | uint64_t icat_strtou64(const char *nptr, char **endptr, int base); 17 | 18 | bool icat_ismychan(const char *chan); 19 | bool icat_isdigitstr(const char *str); 20 | 21 | 22 | 23 | #endif /* LIBSRSIRC_ICAT_MISC_H */ 24 | -------------------------------------------------------------------------------- /src/icat_serv.h: -------------------------------------------------------------------------------- 1 | /* icat_serv.h - Server I/O (i.e. IRC) handling 2 | * icat - IRC netcat on top of libsrsirc - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_ICAT_SERV_H 6 | #define LIBSRSIRC_ICAT_SERV_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | 16 | void icat_serv_init(void); 17 | void icat_serv_destroy(void); 18 | 19 | bool icat_serv_operate(void); 20 | 21 | int icat_serv_read(tokarr *t, uint64_t to_us); 22 | int icat_serv_printf(const char *fmt, ...); 23 | int icat_serv_fd(void); 24 | bool icat_serv_ssl(void); 25 | 26 | bool icat_serv_online(void); 27 | int icat_serv_casemap(void); 28 | uint64_t icat_serv_sentquit(void); 29 | uint64_t icat_serv_attention_at(void); 30 | 31 | void icat_serv_dump(void); 32 | 33 | #endif /* LIBSRSIRC_ICAT_SERV_H */ 34 | -------------------------------------------------------------------------------- /src/icat_user.c: -------------------------------------------------------------------------------- 1 | /* icat_user.c - User I/O (i.e. stdin/stdout) handling 2 | * icat - IRC netcat on top of libsrsirc - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #define LOG_MODULE MOD_ICATUSER 6 | 7 | #if HAVE_CONFIG_H 8 | # include 9 | #endif 10 | 11 | 12 | #include "icat_user.h" 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "icat_common.h" 23 | 24 | 25 | #define BUFSZ 4096 26 | 27 | 28 | static const size_t s_bufsz = BUFSZ; 29 | static char s_inbuf[BUFSZ+1]; 30 | static char *s_bufhead = s_inbuf; 31 | static char *s_buftail = s_inbuf; 32 | static bool s_eof; 33 | 34 | 35 | static size_t buf_cnt(void); 36 | static size_t buf_rem(void); 37 | 38 | 39 | bool 40 | icat_user_canread(void) 41 | { 42 | if (buf_cnt()) { 43 | *s_buftail = '\0'; 44 | if (strchr(s_bufhead, '\n')) 45 | return true; 46 | } 47 | 48 | int r = lsi_b_stdin_canread(); 49 | 50 | if (r < 0) 51 | EE("select"); 52 | if (r <= 0) 53 | return false; 54 | 55 | if (!buf_rem()) { 56 | if (s_inbuf == s_bufhead) { 57 | WE("Line too long, truncating"); 58 | s_buftail[0] = '\n'; 59 | s_buftail[1] = '\0'; 60 | return true; 61 | } else { 62 | size_t n = buf_cnt(); 63 | size_t off = (size_t)(s_bufhead - s_inbuf); 64 | D("Moving %zu bytes to front (off %zu)", n, off); 65 | memmove(s_inbuf, s_bufhead, n); 66 | s_buftail -= off; 67 | s_bufhead = s_inbuf; 68 | } 69 | } 70 | 71 | if (s_eof) 72 | return false; 73 | 74 | long n = lsi_b_stdin_read(s_buftail, buf_rem()); 75 | 76 | if (n < 0) { 77 | EE("read"); 78 | return false; 79 | } 80 | 81 | if (n == 0) { 82 | I("EOF on stdin"); 83 | s_eof = true; 84 | return false; 85 | } 86 | 87 | s_buftail += n; 88 | *s_buftail = '\0'; 89 | 90 | return strchr(s_bufhead, '\n'); 91 | } 92 | 93 | int 94 | icat_user_fd(void) 95 | { 96 | return lsi_b_stdin_fd(); 97 | } 98 | 99 | size_t 100 | icat_user_readline(char *dest, size_t destsz) 101 | { 102 | if (!icat_user_canread()) 103 | return 0; 104 | 105 | *s_buftail = '\0'; 106 | char *end = strchr(s_bufhead, '\n') + 1; 107 | 108 | size_t origlen = (size_t)(end - s_bufhead); 109 | size_t cplen = origlen; 110 | if (cplen >= destsz) 111 | cplen = destsz - 1; 112 | strncpy(dest, s_bufhead, cplen); 113 | dest[cplen] = '\0'; 114 | 115 | s_bufhead = end; 116 | 117 | D("Read line from buffer: '%s'", dest); 118 | 119 | return origlen; 120 | } 121 | 122 | int 123 | icat_user_printf(const char *fmt, ...) 124 | { 125 | char buf[1024]; 126 | va_list l; 127 | va_start(l, fmt); 128 | int r = vsnprintf(buf, sizeof buf, fmt, l); 129 | va_end(l); 130 | 131 | I("To user: %s", buf); 132 | fputs(buf, stdout); 133 | 134 | return r; 135 | } 136 | 137 | bool 138 | icat_user_eof(void) 139 | { 140 | return s_eof; 141 | } 142 | 143 | 144 | static size_t 145 | buf_cnt(void) 146 | { 147 | return (size_t)(s_buftail - s_bufhead); 148 | } 149 | 150 | static size_t 151 | buf_rem(void) 152 | { 153 | size_t unusable = (size_t)(s_bufhead - s_inbuf); 154 | return s_bufsz - buf_cnt() - unusable; 155 | } 156 | -------------------------------------------------------------------------------- /src/icat_user.h: -------------------------------------------------------------------------------- 1 | /* icat_user.h - User I/O (i.e. stdin/stdout) handling 2 | * icat - IRC netcat on top of libsrsirc - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_ICAT_USER_H 6 | #define LIBSRSIRC_ICAT_USER_H 1 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | bool icat_user_canread(void); 15 | size_t icat_user_readline(char *dest, size_t destsz); 16 | int icat_user_printf(const char *fmt, ...); 17 | int icat_user_fd(void); 18 | 19 | bool icat_user_eof(void); 20 | 21 | 22 | #endif /* LIBSRSIRC_ICAT_USER_H */ 23 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_clear: -------------------------------------------------------------------------------- 1 | { TC("l=%p", (void *)l); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_count: -------------------------------------------------------------------------------- 1 | { TC("l=%p", (void *)l); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_del_iter: -------------------------------------------------------------------------------- 1 | { TC("l=%p", (void *)l); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_dispose: -------------------------------------------------------------------------------- 1 | { TC("l=%p", (void *)l); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_dump: -------------------------------------------------------------------------------- 1 | { TC("l=%p, op=(fp)", (void *)l); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_find: -------------------------------------------------------------------------------- 1 | { TC("l=%p, key='%s', origkey=%p", (void *)l, key, (void *)origkey); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_first: -------------------------------------------------------------------------------- 1 | { TC("l=%p, key=%p, val=%p", (void *)l, (void *)key, (void *)val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_get: -------------------------------------------------------------------------------- 1 | { TC("l=%p, i=%zu, key=%p, val=%p", (void *)l, i, (void *)key, (void *)val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_init: -------------------------------------------------------------------------------- 1 | { TC("cmap=%p", (void *)cmap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_insert: -------------------------------------------------------------------------------- 1 | { TC("l=%p, i=%zu, key='%s', val=%p", (void *)l, i, key, val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_isempty: -------------------------------------------------------------------------------- 1 | { TC("l=%p", (void *)l); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_next: -------------------------------------------------------------------------------- 1 | { TC("l=%p, key=%p, val=%p", (void *)l, (void *)key, (void *)val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_remove: -------------------------------------------------------------------------------- 1 | { TC("l=%p, key='%s', origkey=%p", (void *)l, key, (void *)origkey); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@lsi_bucklist_replace: -------------------------------------------------------------------------------- 1 | { TC("l=%p, key='%s', val=%p", (void *)l, key, val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%bucklist.c@pfxeq: -------------------------------------------------------------------------------- 1 | { TC("n1='%s', n2='%s', cmap=%p", n1, n2, (void *)cmap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%common.c@b64_core: -------------------------------------------------------------------------------- 1 | { TC("outquad=%p, intrip=%p, ntrip=%zu", (void *)outquad, (void *)intrip, ntrip); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%common.c@lsi_com_base64: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, destsz=%zu, input=%p, len=%zu", (void *)dest, destsz, (void *)input, len); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%common.c@lsi_com_check_timeout: -------------------------------------------------------------------------------- 1 | { TC("tend=%"PRIu64", trem=%p", tend, (void *)trem); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%common.c@lsi_com_consocket: -------------------------------------------------------------------------------- 1 | { TC("host='%s', port=%"PRIu16", remaddr=%p, remaddr_sz=%zu, peerport=%p" "softto=%"PRIu64", hardto=%"PRIu64, host, port, (void *)remaddr, remaddr_sz, (void *)peerport, softto, hardto); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%common.c@lsi_com_guess_hosttype: -------------------------------------------------------------------------------- 1 | { TC("host='%s'", host); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%common.c@lsi_com_strCchr: -------------------------------------------------------------------------------- 1 | { TC("str='%s', c=0x%"PRIx8, str, (uint8_t)c); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%common.c@lsi_com_update_strprop: -------------------------------------------------------------------------------- 1 | { TC("field=%p, val='%s'", (void *)field, val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%common.c@tryhost: -------------------------------------------------------------------------------- 1 | { TC("ai=%p, remaddr=%p, remaddr_sz=%zu, peerport=%p, to_us=%"PRIu64, (void *)ai, (void *)remaddr, remaddr_sz, (void *)peerport, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@irc_conn_dump: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_colon_trail: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_connect: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, softto_us=%"PRIu64", hardto_us=%"PRIu64, (void *)ctx, softto_us, hardto_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_dispose: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_eof: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_get_host: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_get_port: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_get_px_host: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_get_px_port: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_get_px_type: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_get_ssl: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_init: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_online: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_read: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, tokarr=%p, to_us=%"PRIu64, (void *)ctx, (void *)tok, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_reset: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_set_px: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, host='%s', port=%"PRIu16", ptype=%d", (void *)ctx, host, port, ptype); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_set_server: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, host='%s', port=%"PRIu16, (void *)ctx, host, port); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_set_ssl: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, on=%d", (void *)ctx, on); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_sockfd: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%conn.c@lsi_conn_write: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, line='%s'", (void *)ctx, line); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%io.c@find_delim: -------------------------------------------------------------------------------- 1 | { TC("rctx=%p", (void *)rctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%io.c@lsi_io_read: -------------------------------------------------------------------------------- 1 | { TC("sh={.sck=%d, .shnd=%p}, rctx=%p, tok=%p, to_us=%"PRIu64, sh.sck, (void *)sh.shnd, (void *)rctx, (void *)tok, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%io.c@lsi_io_write: -------------------------------------------------------------------------------- 1 | { TC("sh={.sck=%d, .shnd=%p}, line='%s'", sh.sck, (void *)sh.shnd, line); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%io.c@read_more: -------------------------------------------------------------------------------- 1 | { TC("sh={.sck=%d, .shnd=%p}, rctx=%p, to_us=%"PRIu64, sh.sck, (void *)sh.shnd, (void *)rctx, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%io.c@read_wrap: -------------------------------------------------------------------------------- 1 | { TC("sh={.sck=%d, .shnd=%p}, buf=%p, sz=%zu", sh.sck, (void *)sh.shnd, buf, sz); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%io.c@send_wrap: -------------------------------------------------------------------------------- 1 | { TC("sh={.sck=%d, .shnd=%p}, buf=%p, len=%zu", sh.sck, (void *)sh.shnd, buf, len); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%io.c@write_str: -------------------------------------------------------------------------------- 1 | { TC("sh={.sck=%d, .shnd=%p}, str='%s'", sh.sck, (void *)sh.shnd, str); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_connect: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_dispose: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_dump: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_eof: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_init: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_printf: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, fmt='%s', ...", (void *)ctx, fmt); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_read: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, tok=%p, to_us=%"PRIu64, (void *)ctx, (void *)tok, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_reg_msghnd: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, cmd='%s', hndfn=(fp), pre=%d", (void *)ctx, cmd, pre); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_regcb_conread: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, cb=(fp), tag=%p", (void *)ctx, tag); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_regcb_mutnick: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, cb=(fp)", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_reset: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@irc_write: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, line='%s'", (void *)ctx, line); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@reset_state: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc.c@send_logon: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_005attr: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, name='%s'", (void *)ctx, name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_005chanmodes: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, class=%zu", (void *)ctx, class); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_005modepfx: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, symbols=%d", (void *)ctx, symbols); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_banmsg: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_banned: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_casemap: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_cmodes: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_colon_trail: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_conflags: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_dumb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_fname: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_host: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_nick: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_pass: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_port: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_px_host: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_px_port: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_px_type: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_service_connect: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_service_dist: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_service_info: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_service_type: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_ssl: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_get_uname: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_lasterror: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_logonconv: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_myhost: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_mynick: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_online: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_service: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_conflags: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, flags=0x%"PRIx8, (void *)ctx, flags); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_connect_timeout: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, soft=%"PRIu64", hard=%"PRIu64, (void *)ctx, soft, hard); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_dumb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, dumbmode=%d", (void *)ctx, dumbmode); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_fname: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, fname='%s'", (void *)ctx, fname); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_nick: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, nick='%s'", (void *)ctx, nick); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_pass: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, srvpass='%s'", (void *)ctx, srvpass); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_px: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, host='%s', port=%"PRIu16", ptype=%d", (void *)ctx, host, port, ptype); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_sasl: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, mech='%s', msg=%p, n=%zu", (void *)ctx, mech, msg, n); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_server: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, host='%s' port=%"PRIu16, (void *)ctx, host, port); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_service_connect: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, enabled=%d", (void *)ctx, enabled); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_service_dist: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, dist='%s'", (void *)ctx, dist); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_service_info: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, info='%s'", (void *)ctx, info); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_service_type: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, type=%ld", (void *)ctx, type); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_ssl: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, on=%d", (void *)ctx, on); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_track: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, on=%d", (void *)ctx, on); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_set_uname: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, uname='%s'", (void *)ctx, uname); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_sockfd: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_tracking_enab: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_umodes: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_getset.c@irc_version: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_001: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_002: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_003: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_004: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_005: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_005_CASEMAPPING: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, val='%s'", (void *)ctx, val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_005_CHANMODES: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, val='%s'", (void *)ctx, val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_005_CHANTYPES: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, val='%s'", (void *)ctx, val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_005_PREFIX: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, val='%s'", (void *)ctx, val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_383: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_464: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_465: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_466: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_484: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_903: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_904: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_AUTHENTICATE: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_CAP: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_ERROR: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_MODE: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_NICK: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_PING: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@handle_bad_nick: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@lsi_imh_regall: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, dumb=%d", (void *)ctx, dumb); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_msghnd.c@lsi_imh_unregall: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_311: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_324: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_332: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_333: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_352: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_353: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_366: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_JOIN: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_KICK: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_MODE: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_MODE_chanmode: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_NICK: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_NOTICE: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_PART: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_PRIVMSG: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_QUIT: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@h_TOPIC: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, nargs=%zu, logon=%d", (void *)ctx, (void *)msg, nargs, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_all_chans: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, chanarr=%p, chanarr_cnt=%zu", (void *)ctx, (void *)chanarr, chanarr_cnt); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_all_members: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, chname='%s', userarr=%p, userarr_cnt=%zu", (void *)ctx, chname, (void *)userarr, userarr_cnt); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_all_users: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, userarr=%p, userarr_cnt=%zu", (void *)ctx, (void *)userarr, userarr_cnt); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_chan: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, dest=%p, name='%s'", (void *)ctx, (void *)dest, name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_member: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, dest=%p, chname='%s', ident='%s'", (void *)ctx, (void *)dest, chname, ident); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_num_chans: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_num_members: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, chname='%s'", (void *)ctx, chname); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_num_users: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_tag_chan: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, chname='%s', tag=%p, autofree=%d", (void *)ctx, chname, tag, autofree); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_tag_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, ident='%s', tag=%p, autofree=%d", (void *)ctx, ident, tag, autofree); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@irc_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, dest=%p, name='%s'", (void *)ctx, (void *)dest, ident); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@lsi_trk_deinit: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@lsi_trk_dump: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, full=%d", (void *)ctx, full); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@lsi_trk_init: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@mkchanrep: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, c=%p (%s)", (void *)dest, (void *)c, c->name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%irc_track.c@mkuserrep: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, u=%p (%s), modepfx='%s'", (void *)dest, (void *)u, u->nick, modepfx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%msg.c@dispatch_uhnd: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, ac=%zu, pre=%d", (void *)ctx, (void *)msg, ac, pre); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%msg.c@lsi_msg_handle: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, logon=%d", (void *)ctx, (void *)msg, logon); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%msg.c@lsi_msg_reghnd: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, cmd='%s', hndfn=(fp), module='%s'", (void *)ctx, cmd, module); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%msg.c@lsi_msg_reguhnd: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, cmd='%s', hndfn=(fp), pre=%d", (void *)ctx, cmd, pre); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%msg.c@lsi_msg_unregall: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, module='%s'", (void *)ctx, module); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%px.c@lsi_px_logon_http: -------------------------------------------------------------------------------- 1 | { TC("sck=%d, host='%s', port=%"PRIu16", to_us=%"PRIu64, sck, host, port, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%px.c@lsi_px_logon_socks4: -------------------------------------------------------------------------------- 1 | { TC("sck=%d, host='%s', port=%"PRIu16", to_us=%"PRIu64, sck, host, port, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%px.c@lsi_px_logon_socks5: -------------------------------------------------------------------------------- 1 | { TC("sck=%d, host='%s', port=%"PRIu16", to_us=%"PRIu64, sck, host, port, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%px.c@lsi_px_typenum: -------------------------------------------------------------------------------- 1 | { TC("typestr='%s'", typestr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%px.c@lsi_px_typestr: -------------------------------------------------------------------------------- 1 | { TC("typenum=%d", typenum); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_clear: -------------------------------------------------------------------------------- 1 | { TC("h=%p", (void *)h); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_count: -------------------------------------------------------------------------------- 1 | { TC("h=%p", (void *)h); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_del: -------------------------------------------------------------------------------- 1 | { TC("h=%p, key='%s'", (void *)h, key); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_del_iter: -------------------------------------------------------------------------------- 1 | { TC("h=%p", (void *)h); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_dispose: -------------------------------------------------------------------------------- 1 | { TC("h=%p", (void *)h); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_dump: -------------------------------------------------------------------------------- 1 | { TC("h=%p, valop=(fp)", (void *)h); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_dumpstat: -------------------------------------------------------------------------------- 1 | { TC("h=%p, dbgname='%s'", (void *)h, dbgname); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_first: -------------------------------------------------------------------------------- 1 | { TC("h=%p, key=%p, val=%p", (void *)h, (void *)key, (void *)val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_get: -------------------------------------------------------------------------------- 1 | { TC("h=%p, key='%s'", (void *)h, key); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_init: -------------------------------------------------------------------------------- 1 | { TC("bsz=%zu, cmap=%d", bsz, cmap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_next: -------------------------------------------------------------------------------- 1 | { TC("h=%p, key=%p, val=%p", (void *)h, (void *)key, (void *)val); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_put: -------------------------------------------------------------------------------- 1 | { TC("h=%p, key='%s', elem=%p", (void *)h, key, elem); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@lsi_skmap_stat: -------------------------------------------------------------------------------- 1 | { TC("h=%p, nbuck=%p, nbuckused=%p, nitems=%p, loadfac=%p, avglistlen=%p, maxlistlen=%p", (void *)h, (void *)nbuck, (void *)nbuckused, (void *)nitems, (void *)loadfac, (void *)avglistlen, (void *)maxlistlen); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@strhash_mid: -------------------------------------------------------------------------------- 1 | { TC("s='%s', cmap=%p", s, (void *)cmap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%skmap.c@strhash_small: -------------------------------------------------------------------------------- 1 | { TC("s='%s', cmap=%p", s, (void *)cmap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@compare_modepfx: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c1=0x%"PRIx8", c2=0x%"PRIx8, (void *)ctx, (uint8_t)c1, (uint8_t)c2); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_add_chan: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, name='%s'", (void *)ctx, name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_add_chanmode: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s), modestr='%s'", (void *)ctx, (void *)c, c->name, modestr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_add_memb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s), u=%p (%s), mpfxstr='%s'", (void *)ctx, (void *)c, c->name, (void *)u, u->nick, mpfxstr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_add_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, ident='%s'", (void *)ctx, ident); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_alloc_memb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, u=%p (%s), mpfxstr='%s'", (void *)ctx, (void *)u, u->nick, mpfxstr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_clear: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_clear_chanmodes: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s)", (void *)ctx, (void *)c, c->name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_clear_memb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s)", (void *)ctx, (void *)c, c->name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_deinit: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_drop_chan: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s)", (void *)ctx, (void *)c, c->name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_drop_chanmode: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s), modestr='%s'", (void *)ctx, (void *)c, c->name, modestr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_drop_memb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s), u=%p (%s), purge=%d, complain=%d", (void *)ctx, (void *)c, c->name, (void *)u, u->nick, purge, complain); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_drop_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, u=%p (%s)", (void *)ctx, (void *)u, u->nick); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_dump: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, full=%d", (void *)ctx, full); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_first_chan: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_first_memb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s)", (void *)ctx, (void *)c, c->name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_first_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_get_chan: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, name='%s', complain=%d", (void *)ctx, name, complain); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_get_memb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s), nick='%s', complain=%d", (void *)ctx, (void *)c, c->name, nick, complain); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_get_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, ident='%s', complain=%d", (void *)ctx, ident, complain); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_init: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_next_chan: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_next_memb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s)", (void *)ctx, (void *)c, c->name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_next_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_num_chans: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_num_memb: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s)", (void *)ctx, (void *)c, c->name); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_num_users: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p", (void *)ctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_rename_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, ident='%s', newnick='%s', allocerr=%p", (void *)ctx, ident, newnick, (void *)allocerr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_tag_chan: -------------------------------------------------------------------------------- 1 | { TC("c=%p (%s), tag=%p, autofree=%d", (void *)c, c->name, tag, autofree); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_tag_user: -------------------------------------------------------------------------------- 1 | { TC("u=%p (%s), tag=%p, autofree=%d", (void *)u, u->nick, tag, autofree); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_touch_user: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, ident='%s', complain=%d", (void *)ctx, ident, complain); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_touch_user_int: -------------------------------------------------------------------------------- 1 | { TC("u=%p (%s), ident='%s'", (void *)u, u->nick, ident); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%ucbase.c@lsi_ucb_update_modepfx: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%p (%s), nick='%s', mpfxsym=0x%"PRIx8", enab=%d", (void *)ctx, (void *)c, c->name, nick, (uint8_t)mpfxsym, enab); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_casemap_nam: -------------------------------------------------------------------------------- 1 | { TC("cm=%d", cm); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_classify_chanmode: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, c=%c", (void *)ctx, c); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_clonearr: -------------------------------------------------------------------------------- 1 | { TC("arr=%p", (void *)arr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_conread: -------------------------------------------------------------------------------- 1 | { TC("msg=%p, tag=%p", (void *)msg, tag); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_dumpmsg: -------------------------------------------------------------------------------- 1 | { TC("tag=%p, msg=%p", tag, (void *)msg); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_freearr: -------------------------------------------------------------------------------- 1 | { TC("arr=%p", (void *)arr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_ident2host: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, dest_sz=%zu, pfx='%s'", (void *)dest, dest_sz, pfx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_ident2nick: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, dest_sz=%zu, pfx='%s'", (void *)dest, dest_sz, pfx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_ident2uname: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, dest_sz=%zu, pfx='%s'", (void *)dest, dest_sz, pfx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_ischan: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, str='%s'", (void *)ctx, str); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_istrcmp: -------------------------------------------------------------------------------- 1 | { TC("n1='%s', n2='%s', casemap=%d", n1, n2, casemap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_istrncmp: -------------------------------------------------------------------------------- 1 | { TC("n1='%s', n2='%s', len=%zu, casemap=%d", n1, n2, len, casemap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_mut_nick: -------------------------------------------------------------------------------- 1 | { TC("nick='%s', nick_sz=%zu", nick, nick_sz); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_parse_MODE: -------------------------------------------------------------------------------- 1 | { TC("ctx=%p, msg=%p, num=%p, is324=%d", (void *)ctx, (void *)msg, (void *)num, is324); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_parse_hostspec: -------------------------------------------------------------------------------- 1 | { TC("hoststr=%p, hoststr_sz=%zu, port=%p, ssl=%p, hostspec='%s'", (void *)hoststr, hoststr_sz, (void *)port, (void *)ssl, hostspec); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_parse_pxspec: -------------------------------------------------------------------------------- 1 | { TC("ptype=%p, hoststr=%p, hoststr_sz=%zu, port=%p, pxspec='%s'", (void *)ptype, (void *)hoststr, hoststr_sz, (void *)port, pxspec); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_sasl_mkplauth: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, destsz=%p (%zu), name='%s', pass='%s', base64=%d", (void *)dest, destsz, *destsz, name, pass, base64); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_sndumpmsg: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, dest_sz=%zu, tag=%p, msg=%p", (void *)dest, dest_sz, tag, (void *)msg); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_snrcmsg: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, destsz=%zu, msg=%p, coltr=%d", (void *)dest, destsz, (void *)msg, coltr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_strtolower: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, destsz=%zu, str='%s', casemap=%d", (void *)dest, destsz, str, casemap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_tokenize: -------------------------------------------------------------------------------- 1 | { TC("buf='%s', tok=%p", buf, (void *)tok); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@lsi_ut_tolower: -------------------------------------------------------------------------------- 1 | { TC("c=%c, casemap=%d", c, casemap); 2 | -------------------------------------------------------------------------------- /tracer/tracer@libsrsirc%util.c@next_tok: -------------------------------------------------------------------------------- 1 | { TC("buf='%s'", buf); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_io.c@lsi_b_stdin_canread: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_io.c@lsi_b_stdin_fd: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_io.c@lsi_b_stdin_read: -------------------------------------------------------------------------------- 1 | { TC("buf=%p, nbytes=%zu", buf, nbytes); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_misc.c@lsi_b_getopt: -------------------------------------------------------------------------------- 1 | { TC("argc=%d, argv=%p, optstring='%s'", argc, (void *)argv, optstring); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_misc.c@lsi_b_malloc: -------------------------------------------------------------------------------- 1 | { TC("sz=%zu, file='%s', line=%d, func='%s'", sz, file, line, func); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_misc.c@lsi_b_optarg: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_misc.c@lsi_b_optind: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_misc.c@lsi_b_regsig: -------------------------------------------------------------------------------- 1 | { TC("sig=%d, sigfn=(fp)", sig); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_misc.c@lsi_b_usleep: -------------------------------------------------------------------------------- 1 | { TC("us=%"PRIu64, us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@addrstr_from_sockaddr: -------------------------------------------------------------------------------- 1 | { TC("addr=%p, addrsz=%zu, port=%p, ai=%p", addr, addrsz, (void *)port, (void *)ai); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@filladdr: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, addr='%s'", (void *)dest, addr); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_blocking: -------------------------------------------------------------------------------- 1 | { TC("sck=%d, blocking=%d", sck, blocking); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_close: -------------------------------------------------------------------------------- 1 | { TC("sck=%d", sck); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_connect: -------------------------------------------------------------------------------- 1 | { TC("sck=%d, srv=%p", sck, (void *)srv); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_freeaddrlist: -------------------------------------------------------------------------------- 1 | { TC("al=%p", (void *)al); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_freesslctx: -------------------------------------------------------------------------------- 1 | { TC("sslctx=%p", (void *)sslctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_htons: -------------------------------------------------------------------------------- 1 | { TC("h=%"PRIu16, h); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_inet4_addr: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, destsz=%zu, ip4str='%s'", (void *)dest, destsz, ip4str); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_inet6_addr: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, destsz=%zu, ip6str='%s'", (void *)dest, destsz, ip6str); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_inet_addr: -------------------------------------------------------------------------------- 1 | { TC("ip4str='%s'", ip4str); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_mkaddrlist: -------------------------------------------------------------------------------- 1 | { TC("host='%s', port=%"PRIu16", res=%p", host, port, (void *)res); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_mksslctx: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_read: -------------------------------------------------------------------------------- 1 | { TC("sck=%d, buf=%p, sz=%zu, to_us=%"PRIu64, sck, buf, sz, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_read_ssl: -------------------------------------------------------------------------------- 1 | { TC("ssl=%p, buf=%p, sz=%zu, to_us=%"PRIu64, (void *)ssl, buf, sz, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_select: -------------------------------------------------------------------------------- 1 | { TC("fds=%p, nfds=%zu, noresult=%d, rdbl=%d, to_us=%"PRIu64, (void *)fds, nfds, noresult, rdbl, to_us); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_sock_ok: -------------------------------------------------------------------------------- 1 | { TC("sck=%d", sck); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_socket: -------------------------------------------------------------------------------- 1 | { TC("ipv6=%d", ipv6); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_sslfin: -------------------------------------------------------------------------------- 1 | { TC("shnd=%p", (void *)shnd); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_sslize: -------------------------------------------------------------------------------- 1 | { TC("sck=%d, sslctx=%p", sck, (void *)sslctx); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_win_inet_pton: -------------------------------------------------------------------------------- 1 | { TC("af=%d, src='%s', dst=%p", af, src, dst); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_write: -------------------------------------------------------------------------------- 1 | { TC("sck=%d, buf=%p, len=%zu", sck, buf, len); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@lsi_b_write_ssl: -------------------------------------------------------------------------------- 1 | { TC("ssl=%p, buf=%p, len=%zu", (void *)ssl, buf, len); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@sockaddr_from_addr: -------------------------------------------------------------------------------- 1 | { TC("dst=%p, dstlen=%p, ai=%p", (void *)dst, (void *)dstlen, (void *)ai); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@sslinit: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_net.c@wsa_init: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_string.c@lsi_b_strNcat: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, src='%s', destsz=%zu", (void *)dest, src, destsz); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_string.c@lsi_b_strNcpy: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, src='%s', destsz=%zu", (void *)dest, src, destsz); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_string.c@lsi_b_strcasecmp: -------------------------------------------------------------------------------- 1 | { TC("a='%s', b='%s'", a, b); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_string.c@lsi_b_strdup: -------------------------------------------------------------------------------- 1 | { TC("s='%s', file='%s', line=%d, func='%s'", s, file, line, func); 2 | -------------------------------------------------------------------------------- /tracer/tracer@platform%base_string.c@lsi_b_strncasecmp: -------------------------------------------------------------------------------- 1 | { TC("a='%s', b='%s', n=%zu", a, b, n); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_core.c@dump_info: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_core.c@handle_ircmsg: -------------------------------------------------------------------------------- 1 | { TC("tok=%p", (void *)tok); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_core.c@handle_usermsg: -------------------------------------------------------------------------------- 1 | { TC("lnbuf='%s'", lnbuf); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_core.c@icat_core_destroy: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_core.c@icat_core_init: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_core.c@icat_core_run: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_init.c@cleanup: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_init.c@dump_settings: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_init.c@process_args: -------------------------------------------------------------------------------- 1 | { TC("argc=%p (%d), argv=%p", (void *)argc, *argc, (void *)argv); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_init.c@set_defaults: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_init.c@sighnd: -------------------------------------------------------------------------------- 1 | { TC("s=%d", s); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_init.c@update_logger: -------------------------------------------------------------------------------- 1 | { TC("verb=%d, fancy=%d", verb, fancy); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_init.c@usage: -------------------------------------------------------------------------------- 1 | { TC("str=%p, a0='%s', ec=%d, sh=%d", (void *)str, a0, ec, sh); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_misc.c@icat_isdigitstr: -------------------------------------------------------------------------------- 1 | { TC("str='%s'", str); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_misc.c@icat_ismychan: -------------------------------------------------------------------------------- 1 | { TC("chan='%s'", chan); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_misc.c@icat_strtou64: -------------------------------------------------------------------------------- 1 | { TC("nptr='%s', endptr=%p, base=%d", nptr, (void *)endptr, base); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_misc.c@icat_strtou8: -------------------------------------------------------------------------------- 1 | { TC("nptr='%s', endptr=%p, base=%d", nptr, (void *)endptr, base); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@conread: -------------------------------------------------------------------------------- 1 | { TC("msg=%p, tag=%p", (void *)msg, tag); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@do_heartbeat: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@first_connect: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@handle_005: -------------------------------------------------------------------------------- 1 | { TC("irchnd=%p, tok=%p, nargs=%zu, pre=%d", (void *)irchnd, (void *)tok, nargs, pre); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@handle_PING: -------------------------------------------------------------------------------- 1 | { TC("irchnd=%p, tok=%p, nargs=%zu, pre=%d", (void *)irchnd, (void *)tok, nargs, pre); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@handle_PONG: -------------------------------------------------------------------------------- 1 | { TC("irchnd=%p, tok=%p, nargs=%zu, pre=%d", (void *)irchnd, (void *)tok, nargs, pre); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_attention_at: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_casemap: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_destroy: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_dump: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_fd: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_init: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_online: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_operate: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_printf: -------------------------------------------------------------------------------- 1 | { TC("fmt='%s', ...", fmt); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_read: -------------------------------------------------------------------------------- 1 | { TC("t=%p", (void *)t); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_sentquit: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@icat_serv_ssl: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@process_sendq: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@to_srv: -------------------------------------------------------------------------------- 1 | { TC("line='%s'", line); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_serv.c@tryconnect: -------------------------------------------------------------------------------- 1 | { TC("s=%p", (void *)s); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_user.c@buf_cnt: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_user.c@buf_rem: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_user.c@icat_user_canread: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_user.c@icat_user_eof: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_user.c@icat_user_fd: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_user.c@icat_user_printf: -------------------------------------------------------------------------------- 1 | { TC("fmt='%s', ...", fmt); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%icat_user.c@icat_user_readline: -------------------------------------------------------------------------------- 1 | { TC("dest=%p, destsz=%zu", (void *)dest, destsz); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%iwat.c@cleanup: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%iwat.c@conread: -------------------------------------------------------------------------------- 1 | { TC("msg=%p, tag=%p", (void *)msg, tag); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%iwat.c@infohnd: -------------------------------------------------------------------------------- 1 | { TC("s=%d", s); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%iwat.c@init: -------------------------------------------------------------------------------- 1 | { TC("argc=%p (%d), argv=%p, sett=%p", (void *)argc, *argc, (void *)argv, (void *)sett); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%iwat.c@iprintf: -------------------------------------------------------------------------------- 1 | { TC("fmt='%s', ...", fmt); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%iwat.c@process_args: -------------------------------------------------------------------------------- 1 | { TC("argc=%p (%d), argv=%p, sett=%p", (void *)argc, *argc, (void *)argv, (void *)sett); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%iwat.c@tryconnect: -------------------------------------------------------------------------------- 1 | { TC("(no args)"); 2 | -------------------------------------------------------------------------------- /tracer/tracer@src%iwat.c@usage: -------------------------------------------------------------------------------- 1 | { TC("str=%p, a0='%s', ec=%d", (void *)str, a0, ec); 2 | -------------------------------------------------------------------------------- /unittests/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = test_bucklist 2 | test_bucklist_SOURCES = run_test_bucklist.c unittests_common.h 3 | test_bucklist_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libsrsirc 4 | test_bucklist_LDADD = $(top_srcdir)/libsrsirc/libsrsirc.la 5 | -------------------------------------------------------------------------------- /unittests/README: -------------------------------------------------------------------------------- 1 | Adding new unit tests: 2 | ====================== 3 | 1. unit tests for libsrsirc module 'foo' go inside 'unittests/test_foo.c'. 4 | If that file exists already, proceed with step 4. 5 | 6 | 2. Otherwise, create it. See test_ptrlist.c for how the top lines should look 7 | (in particular, the unit test file should #include "unittests_common.h". 8 | 9 | 3. Edit unittests/Makefile.am, add 'test_foo' to the top line (words are separated by space). 10 | Then add three new lines similar to those starting with 'test_ptrlist_'. Obviously adjust 11 | 'ptrlist' to your module name, keep everything else. 12 | NOTE THE 'run_' prefix in the _SOURCES line! Don't forget it! 13 | 14 | 4. Now inside unittests/test_foo.c, each unit test is made up by one function 15 | like this: 16 | const char* /*UNITTEST*/ 17 | test_whatever(void) 18 | { 19 | /* test someting */ 20 | return "error message on failure"; 21 | // return NULL; if the test succeeded 22 | /* ... */ 23 | } 24 | The format of the first two lines MUST be kept, don't add whitespace or 25 | anything, simply do not mess with it :). Return NULL if a test went good. 26 | Multiple such functions per file are okay. 27 | 28 | 5. That's kind of it. You will need to ./configure again and may, after 29 | building, run the tests with 'make test' 30 | 31 | -------------------------------------------------------------------------------- /unittests/test_bucklist.c: -------------------------------------------------------------------------------- 1 | /* test_bucklist.c - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #include "unittests_common.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | ///* simple and stupid single linked list with void* data elements */ 12 | //typedef struct bucklist bucklist; 13 | //typedef bool (*bucklist_find_fn)(const void *e); 14 | //typedef void (*bucklist_op_fn)(const void *e); 15 | //typedef bool (*bucklist_eq_fn)(const void *e1, const void *e2); 16 | // 17 | ///* alloc/dispose/count/clear */ 18 | //bucklist *lsi_bucklist_init(const uint8_t *cmap); 19 | //void lsi_bucklist_dispose(bucklist *l); 20 | //size_t lsi_bucklist_count(bucklist *l); 21 | //bool lsi_bucklist_isempty(bucklist *l); 22 | //void lsi_bucklist_clear(bucklist *l); 23 | // 24 | ///* insert/replace/get by index */ 25 | //bool lsi_bucklist_insert(bucklist *l, size_t i, char *key, void *val); 26 | //bool lsi_bucklist_get(bucklist *l, size_t i, char **key, void **val); 27 | // 28 | ///* linear search */ 29 | //void *lsi_bucklist_find(bucklist *l, const char *key, char **origkey); 30 | //void *lsi_bucklist_remove(bucklist *l, const char *key, char **origkey); 31 | //bool lsi_bucklist_replace(bucklist *l, const char *key, void *val); 32 | // 33 | ///* iteration */ 34 | //bool lsi_bucklist_first(bucklist *l, char **key, void **val); 35 | //bool lsi_bucklist_next(bucklist *l, char **key, void **val); 36 | //void lsi_bucklist_del_iter(bucklist *l); 37 | // 38 | ///* debug */ 39 | //void lsi_bucklist_dump(bucklist *l, bucklist_op_fn op); 40 | 41 | const char * /*UNITTEST*/ 42 | test_basic(void) 43 | { 44 | bucklist *l = lsi_bucklist_init(g_cmap[CMAP_RFC1459]); 45 | if (!l) 46 | return "bucklist alloc failed"; 47 | 48 | if (lsi_bucklist_count(l) != 0) 49 | return "newly allocated list not empty"; 50 | 51 | lsi_bucklist_dispose(l); 52 | 53 | return NULL; 54 | } 55 | -------------------------------------------------------------------------------- /unittests/unittests_common.h: -------------------------------------------------------------------------------- 1 | /* unittests_common.h - 2 | * libsrsirc - a lightweight serious IRC lib - (C) 2012-2024, Timo Buhrmester 3 | * See README for contact-, COPYING for license information. */ 4 | 5 | #ifndef LIBSRSIRC_UNITTESTS_COMMON_H 6 | #define LIBSRSIRC_UNITTESTS_COMMON_H 1 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #endif /* LIBSRSIRC_UNITTESTS_COMMON_H */ 15 | --------------------------------------------------------------------------------