comparison src/ushare.c @ 131:20442921bff5

change display name. modify PES buf size.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Tue, 12 Oct 2010 05:56:26 +0900
parents 5dcaf3785ebe
children 0db6ccf0fe31
comparison
equal deleted inserted replaced
130:cc3e3f370aec 131:20442921bff5
84 { 84 {
85 struct ushare_t *ut = (struct ushare_t *) malloc (sizeof (struct ushare_t)); 85 struct ushare_t *ut = (struct ushare_t *) malloc (sizeof (struct ushare_t));
86 if (!ut) 86 if (!ut)
87 return NULL; 87 return NULL;
88 88
89 ut->name = strdup (DEFAULT_USHARE_NAME); 89 // ut->name = strdup (DEFAULT_USHARE_NAME);
90 ut->name = strdup (PACKAGE_NAME);
90 ut->interface = strdup (DEFAULT_USHARE_IFACE); 91 ut->interface = strdup (DEFAULT_USHARE_IFACE);
91 ut->model_name = strdup (DEFAULT_USHARE_NAME); 92 // ut->model_name = strdup (DEFAULT_USHARE_NAME);
93 ut->model_name = strdup (PACKAGE_NAME);
92 ut->contentlist = NULL; 94 ut->contentlist = NULL;
93 ut->rb = rbinit (rb_compare, NULL); 95 ut->rb = rbinit (rb_compare, NULL);
94 ut->root_entry = NULL; 96 ut->root_entry = NULL;
95 ut->nr_entries = 0; 97 ut->nr_entries = 0;
96 ut->starting_id = STARTING_ENTRY_ID_DEFAULT; 98 ut->starting_id = STARTING_ENTRY_ID_DEFAULT;
423 while (itf) 425 while (itf)
424 { 426 {
425 if ((itf->ifa_flags & IFF_UP) 427 if ((itf->ifa_flags & IFF_UP)
426 && !strncmp (itf->ifa_name, interface, IFNAMSIZ)) 428 && !strncmp (itf->ifa_name, interface, IFNAMSIZ))
427 { 429 {
428 log_error (_("Interface %s is down.\n"), interface); 430 //log_error (_("Interface %s is down.\n"), interface);
429 log_error (_("Recheck uShare's configuration and try again !\n")); 431 //log_error (_("Recheck uShare's configuration and try again !\n"));
430 freeifaddrs (itflist); 432 freeifaddrs (itflist);
431 return true; 433 return true;
432 } 434 }
433 itf = itf->ifa_next; 435 itf = itf->ifa_next;
434 } 436 }
503 create_udn (char *interface) 505 create_udn (char *interface)
504 { 506 {
505 int sock = -1; 507 int sock = -1;
506 char *buf; 508 char *buf;
507 unsigned char *ptr; 509 unsigned char *ptr;
510 pid_t PID = (getpid() & 0xFFFF);
508 511
509 #if (defined(BSD) || defined(__FreeBSD__) || defined(__APPLE__)) 512 #if (defined(BSD) || defined(__FreeBSD__) || defined(__APPLE__))
510 int mib[6]; 513 int mib[6];
511 size_t len; 514 size_t len;
512 struct if_msghdr *ifm; 515 struct if_msghdr *ifm;
569 buf = (char *) malloc (64 * sizeof (char)); 572 buf = (char *) malloc (64 * sizeof (char));
570 memset (buf, 0, 64); 573 memset (buf, 0, 64);
571 ptr = (unsigned char *) ifr.ifr_hwaddr.sa_data; 574 ptr = (unsigned char *) ifr.ifr_hwaddr.sa_data;
572 #endif /* (defined(BSD) || defined(__FreeBSD__)) */ 575 #endif /* (defined(BSD) || defined(__FreeBSD__)) */
573 576
574 snprintf (buf, 64, "%s-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, 577 snprintf (buf, 64, "%s-%04x-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, PID,
575 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377), 578 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
576 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)); 579 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377));
577 580
578 if (sock) 581 if (sock)
579 close (sock); 582 close (sock);
646 UPnPBreak (int s __attribute__ ((unused))) 649 UPnPBreak (int s __attribute__ ((unused)))
647 { 650 {
648 ushare_signal_exit (); 651 ushare_signal_exit ();
649 } 652 }
650 653
654 #if 0
651 static void 655 static void
652 reload_config (int s __attribute__ ((unused))) 656 reload_config (int s __attribute__ ((unused)))
653 { 657 {
654 struct ushare_t *ut2; 658 struct ushare_t *ut2;
655 bool reload = false; 659 bool reload = false;
717 { 721 {
718 log_error (_("Error: no content directory to be shared.\n")); 722 log_error (_("Error: no content directory to be shared.\n"));
719 raise (SIGINT); 723 raise (SIGINT);
720 } 724 }
721 } 725 }
726 #endif
722 727
723 inline void 728 inline void
724 display_headers (void) 729 display_headers (void)
725 { 730 {
726 printf (_("%s (version %s), a lightweight UPnP A/V and DLNA Media Server.\n"), 731 printf (_("%s (version %s), Recoding DTV and a lightweight UPnP A/V and DLNA Media Server.\n"),
727 PACKAGE_NAME, VERSION); 732 PACKAGE_NAME, VERSION);
728 printf (_("Benjamin Zores (C) 2005-2007, for GeeXboX Team.\n")); 733 printf (_("Naoya OYAMA (C) 2010.\n"));
729 printf (_("See http://ushare.geexbox.org/ for updates.\n")); 734 printf (_("See http://hg.honeyplanet.jp/pt1.oyama/ for updates.\n"));
730 } 735 }
731 736
732 inline static void 737 inline static void
733 setup_i18n(void) 738 setup_i18n(void)
734 { 739 {
778 ushare_free (ut); 783 ushare_free (ut);
779 return NULL; 784 return NULL;
780 } 785 }
781 #endif 786 #endif
782 787
788 #if 0
783 if (parse_config_file (ut) < 0) 789 if (parse_config_file (ut) < 0)
784 { 790 {
785 /* fprintf here, because syslog not yet ready */ 791 /* fprintf here, because syslog not yet ready */
786 fprintf (stderr, _("Warning: can't parse file \"%s\".\n"), 792 fprintf (stderr, _("Warning: can't parse file \"%s\".\n"),
787 ut->cfg_file ? ut->cfg_file : SYSCONFDIR "/" USHARE_CONFIG_FILE); 793 ut->cfg_file ? ut->cfg_file : SYSCONFDIR "/" USHARE_CONFIG_FILE);
788 } 794 }
795 #endif
789 ut->verbose = true; 796 ut->verbose = true;
790 ut->port = 0; 797 ut->port = 0;
791 ut->use_presentation = false; 798 ut->use_presentation = false;
792 ut->use_telnet = false; 799 ut->use_telnet = false;
793 ut->dlna_enabled = true; 800 ut->dlna_enabled = true;
794 ut->override_iconv_err = false; 801 ut->override_iconv_err = false;
795 ut->xbox360 = true; 802 ut->xbox360 = true;
796 ut->daemon = false; 803 ut->daemon = false;
797 //ut->interface = "192.168.1.34";
798 ut->contentlist = "/tmp"; 804 ut->contentlist = "/tmp";
799 805
800 if (ut->xbox360) 806 if (ut->xbox360)
801 { 807 {
802 char *name; 808 char *name;
859 { 865 {
860 display_headers (); 866 display_headers ();
861 } 867 }
862 868
863 #if 0 869 #if 0
864 signal (SIGINT, UPnPBreak);
865 signal (SIGTERM, UPnPBreak);
866 signal (SIGUSR1, UPnPBreak);
867 signal (SIGUSR2, UPnPBreak);
868 signal (SIGPIPE, UPnPBreak);
869 signal (SIGHUP, reload_config);
870 #endif
871
872 if (ut->use_telnet) 870 if (ut->use_telnet)
873 { 871 {
874 if (ctrl_telnet_start (ut->telnet_port) < 0) 872 if (ctrl_telnet_start (ut->telnet_port) < 0)
875 { 873 {
876 ushare_free (ut); 874 ushare_free (ut);
878 } 876 }
879 877
880 ctrl_telnet_register ("kill", ushare_kill, 878 ctrl_telnet_register ("kill", ushare_kill,
881 _("Terminates the uShare server")); 879 _("Terminates the uShare server"));
882 } 880 }
881 #endif
883 log_verbose ("init_upnp() start\n"); 882 log_verbose ("init_upnp() start\n");
884 883
885 if (init_upnp (ut) < 0) 884 if (init_upnp (ut) < 0)
886 { 885 {
887 finish_upnp (ut); 886 finish_upnp (ut);
894 /* Let main sleep until it's time to die... */ 893 /* Let main sleep until it's time to die... */
895 pthread_mutex_lock (&ut->termination_mutex); 894 pthread_mutex_lock (&ut->termination_mutex);
896 pthread_cond_wait (&ut->termination_cond, &ut->termination_mutex); 895 pthread_cond_wait (&ut->termination_cond, &ut->termination_mutex);
897 pthread_mutex_unlock (&ut->termination_mutex); 896 pthread_mutex_unlock (&ut->termination_mutex);
898 897
898 #if 0
899 if (ut->use_telnet) 899 if (ut->use_telnet)
900 ctrl_telnet_stop (); 900 ctrl_telnet_stop ();
901 #endif
901 finish_upnp (ut); 902 finish_upnp (ut);
902 free_metadata_list (ut); 903 free_metadata_list (ut);
903 ushare_free (ut); 904 ushare_free (ut);
904 finish_iconv (); 905 finish_iconv ();
905 906