Revision 74564eb3

View differences:

chunker_player/chunker_player.c
25 25
#include <windows.h>
26 26
#endif
27 27

  
28
int ReadALine(FILE* fp, char* Output, int MaxOutputSize)
29
{
30
    int i=0;
31
    int c;
32
    do
33
    {
34
        c=getc(fp);
35
        if(c=='\r' || c=='\n' || c==EOF)
36
        {
37
            Output[i]=0;
38
            return i;
39
        }
40
        Output[i++]=c;
41
    }
42
    while(c!=EOF);
43
    
44
    return -1;
45
}
46

  
28 47
void sigproc()
29 48
{
30 49
	printf("you have pressed ctrl-c, terminating...\n");
......
491 510
	if(ChunkerPlayerCore_IsRunning())
492 511
		ChunkerPlayerCore_Stop();
493 512

  
494
	KILL_PROCESS(P2PProcessHandle);
513
    KILL_PROCESS(P2PProcessHandle);
514
	remove("NetworkID");
495 515
	
496 516
	ratio = channel->Ratio;
497 517
	ChunkerPlayerGUI_SetChannelTitle(channel->Title);
......
628 648
#endif
629 649

  
630 650
	}
651
	// Read the Network ID
652
	int Error=true;
653
	char Line1[255], Line2[255];
654
	while(Error)
655
	{
656
	    FILE* fp=fopen("NetworkID","r");
657
	    if(fp)
658
	    {
659
	        if(ReadALine(fp,Line1,255)!=-1)
660
	            if(ReadALine(fp,Line2,255)!=-1)
661
	            {
662
	                if(strcmp(Line2,"IDEnd")==0)
663
	                {
664
	                    strcpy(NetworkID,Line1);
665
	                    Error=false;
666
	                }
667
	            }
668
	        fclose(fp);
669
	    }
670
	    if(Error) usleep(100000);
671
	}
672
	
673
	printf("NetworkID = %s\n",NetworkID);
674
	
631 675
	ChunkerPlayerCore_Play();
632 676
	ChunkerPlayerGUI_ChannelSwitched();
633 677
	return 0;
chunker_player/chunker_player.h
34 34
int quit;
35 35
short int QueueFillingMode;
36 36
int LogTraces;
37
char NetworkID[255];
37 38

  
38 39
#ifdef EMULATE_CHUNK_LOSS
39 40
typedef struct

Also available in: Unified diff