From: Anthony F. <Ant...@wa...> - 2002-01-30 23:06:43
|
alex wrote: > > Ok no appologies for this one. When I have no idea what to listen to I > might as well let the internet select the best from my mp3 collection. > As I'm no gtk hacker this is a hardwired kludge but you should get the > idea. Simply put if gtk-gnutella starts uploading a file it passes the > path to an external script (xmms -e in this case). > > Patch follows against CVS: > > [alex@trent src]$ cvs diff uploads.c > Index: uploads.c > =================================================================== > RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/uploads.c,v > retrieving revision 1.19 > diff -r1.19 uploads.c > 10a11 > > #include <stdlib.h> /* For system() */ > 41a43 > > static void run_external_shell(char *); > 828a831,832 > > run_external_shell (fpath); > > > 1049a1054,1081 > > } > > > > /* run_external_shell hack */ > > > > static void run_external_shell (char * path) > > { > > char executable[]="xmms -e "; > > char *execution_string; > > int str_length; > > > > str_length=strlen(path)+strlen(executable)+2; /*+2 for quotes! */ and the final '\0'? -> +3! > > execution_string=calloc(str_length,sizeof(char)); malloc is better/enough here no? > > <snip> > > strcat(execution_string,&executable[0]); > > strcat(execution_string,"\""); > > strcat(execution_string,path); > > strcat(execution_string,"\""); </snip> sprintf(execution_string,"%s/%s/",executable,path); > > > > fprintf (stderr,"Running external shell command with > (%s)\n",execution_string); > > > > system (execution_string); the soft will hang here no? is it in a thread? yes -> no pb no -> execution_string+"&" > > fprintf (stderr,"returned from spawn\n"); > > > > free(execution_string); > > > > return; > > > > Enjoy :-) it's late! I am maybe wrong! Regards, Anthony -- http://www.freeciv.fr.st |