int main (int argc, char **argv) { xmmsc_connection_t *conn; gchar *path; gchar *gp = NULL; gchar **s; gchar **ipcsplit; guint port; int i; printf ("Starting XMMS2 mDNS Agent...\n"); path = getenv ("XMMS_PATH_FULL"); if (!path) { printf ("Sorry you need XMMS_PATH_FULL set\n"); exit (1); } ipcsplit = g_strsplit (path, ";", 0); for (i = 0; ipcsplit[i]; i++) { if (g_ascii_strncasecmp (ipcsplit[i], "tcp://", 6) == 0) { gp = ipcsplit[i]; } } if (!gp) { printf ("Need to have a socket listening to TCP before we can do that!"); exit (1); } s = g_strsplit (gp, ":", 0); if (s && s[2]) { port = strtol (s[2], NULL, 10); } else { port = XMMS_DEFAULT_TCP_PORT; } conn = xmmsc_init ("xmms2-mdns"); if (!conn) { printf ("Could not init xmmsc_connection!\n"); exit (1); } if (!xmmsc_connect (conn, gp)) { printf ("Could not connect to xmms2d: %s\n", xmmsc_get_last_error (conn)); exit (1); } ml = g_main_loop_new (NULL, FALSE); XMMS_CALLBACK_SET (conn, xmmsc_broadcast_quit, handle_quit, ml); xmmsc_disconnect_callback_set (conn, disconnected, NULL); register_service (port); xmmsc_mainloop_gmain_init (conn); g_main_loop_run (ml); DNSServiceRefDeallocate (g_sdref); xmmsc_unref (conn); printf ("XMMS2-mDNS shutting down...\n"); return 0; }
int main (int argc, char **argv) { xmmsc_connection_t *conn; GMainLoop *ml; gchar *path; printf ("Starting XMMS2 phone home agent...\n"); path = getenv ("XMMS_PATH"); conn = xmmsc_init ("xmms2-et"); if (!conn) { printf ("Could not init xmmsc_connection!\n"); exit (1); } if (!xmmsc_connect (conn, path)) { printf ("Could not connect to xmms2d: %s\n", xmmsc_get_last_error (conn)); exit (1); } output_plugin = g_strdup ("unknown"); get_systemname (); send_socket = socket (PF_INET, SOCK_DGRAM, 0); ml = g_main_loop_new (NULL, FALSE); memset (&dest_addr, 0, sizeof (dest_addr)); dest_addr.sin_family = AF_INET; dest_addr.sin_port = htons (DEST_PORT); inet_aton (DEST_IP, &dest_addr.sin_addr); start_time = time (NULL); XMMS_CALLBACK_SET (conn, xmmsc_broadcast_playback_current_id, handle_current_id, conn); XMMS_CALLBACK_SET (conn, xmmsc_main_stats, handle_stats, NULL); XMMS_CALLBACK_SET (conn, xmmsc_broadcast_config_value_changed, handle_config, NULL); XMMS_CALLBACK_SET (conn, xmmsc_broadcast_quit, handle_quit, ml); XMMS_CALLBACK_SET (conn, xmmsc_signal_mediainfo_reader_unindexed, handle_mediainfo_reader, NULL); { xmmsc_result_t *res; res = xmmsc_config_get_value (conn, "output.plugin"); xmmsc_result_notifier_set (res, handle_config_val, NULL); xmmsc_result_unref (res); } xmmsc_disconnect_callback_set (conn, disconnected, NULL); xmmsc_mainloop_gmain_init (conn); g_main_loop_run (ml); xmmsc_unref (conn); printf ("XMMS2-ET shutting down...\n"); send_msg ("Clean shutdown", NULL); return 0; }