comparison libaudacious/beepctrl.c @ 1439:bd0b46c8a70e trunk

[svn] - i believe we've got it!
author nenolod
date Fri, 28 Jul 2006 00:46:34 -0700
parents ce0285d8cede
children ed80e946f30b
comparison
equal deleted inserted replaced
1438:ce0285d8cede 1439:bd0b46c8a70e
311 311
312 db = bmp_cfg_db_open(); 312 db = bmp_cfg_db_open();
313 313
314 if (audacious_session_uri != NULL) 314 if (audacious_session_uri != NULL)
315 { 315 {
316 printf("%p\n", audacious_session_uri);
317 return audacious_session_uri; 316 return audacious_session_uri;
318 } 317 }
319 318
320 bmp_cfg_db_get_string(db, NULL, "session_uri_base", &value); 319 bmp_cfg_db_get_string(db, NULL, "session_uri_base", &value);
321 320
345 344
346 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */ 345 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */
347 void 346 void
348 audacious_decode_tcp_uri(gint session, gchar *in, gchar **host, gint *port, gchar **key) 347 audacious_decode_tcp_uri(gint session, gchar *in, gchar **host, gint *port, gchar **key)
349 { 348 {
350 static gchar workbuf[1024], keybuf[1024]; 349 static gchar *workbuf, *keybuf;
351 gint iport; 350 gint iport;
351 gchar *tmp = g_strdup(in);
352 352
353 /* split out the host/port and key */ 353 /* split out the host/port and key */
354 sscanf(in, "tcp://%s/%s", workbuf, keybuf); 354 tmp += 6;
355 workbuf = tmp;
356
357 keybuf = strchr(tmp, '/');
358 *keybuf++ = '\0';
355 359
356 *key = keybuf; 360 *key = keybuf;
357 361
358 if (strchr(workbuf, ':') == NULL) 362 if (strchr(workbuf, ':') == NULL)
359 { 363 {
369 } 373 }
370 } 374 }
371 375
372 /* unix://localhost/tmp/audacious_nenolod.0 */ 376 /* unix://localhost/tmp/audacious_nenolod.0 */
373 void 377 void
374 audacious_decode_unix_uri(gint session, gchar *in, gchar **out) 378 audacious_decode_unix_uri(gint session, gchar *in, gchar **key)
375 { 379 {
376 static gchar workbuf[1024], pathbuf[1024]; 380 static gchar *workbuf, *keybuf;
377 381 gchar *tmp = g_strdup(in);
378 /* retrieve the pathbuf */ 382
379 sscanf(in, "unix://%s/%s", workbuf, pathbuf); 383 /* split out the host/port and key */
380 384 tmp += 7;
381 *out = pathbuf; 385 workbuf = tmp;
386
387 keybuf = strchr(tmp, '/');
388 *keybuf++ = '\0';
389
390 *key = keybuf;
382 } 391 }
383 392
384 gint 393 gint
385 xmms_connect_to_session(gint session) 394 xmms_connect_to_session(gint session)
386 { 395 {
401 euid = geteuid(); 410 euid = geteuid();
402 setuid(euid); 411 setuid(euid);
403 412
404 audacious_decode_unix_uri(session, uri, &path); 413 audacious_decode_unix_uri(session, uri, &path);
405 414
406 /*
407 g_snprintf(saddr.sun_path, 108, "%s/%s_%s.%d", g_get_tmp_dir(),
408 CTRLSOCKET_NAME, g_get_user_name(), session);
409 */
410 g_strlcpy(saddr.sun_path, path, 108); 415 g_strlcpy(saddr.sun_path, path, 108);
411 setreuid(stored_uid, euid); 416 setreuid(stored_uid, euid);
412 if (connect(fd, (struct sockaddr *) &saddr, sizeof(saddr)) != -1) 417 if (connect(fd, (struct sockaddr *) &saddr, sizeof(saddr)) != -1)
413 return fd; 418 return fd;
414 } 419 }