summary refs log blame commit diff stats
path: root/plugins/xdcc/xdcc.c
blob: 85d277329bd24a9f33fd90edee5c8ca183b555a7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
                                                    


                   


                   



                   

                                     
 
                                                   

















                                  
                           

                    
                                           


                         
                                          

                                            
                                                             

                                                  
                                                                   



                                      
                                    
















                                                       
                                                                                             




                                         
                                                                                                




                                         

                                                                                              













                                                                     
                                                                                               




























                                                                    
                                                             




                                                 
                                                                         




                                                                                                             
                                                                        
            
                                                                              






                                                                       
                                                                                             




                                                                           
                                                                                         

                            
                                                                                
                 
                                           




                                           
                                           






                                                   
                                                                                 

                      
                                                                           
                 
                                           




                                          
                                                   
                                           




                                              
                                           




                                           
                                                    
                                           

         
                                                                              





                                                                                
                                   














                                              
                                                                            







                                                               
                                                                              









                                                
                                








                           
                                                                                          

























                                                                                        
                                                                                          





















                                                     
                               

                    
                                               


                 
                                                      








                                                                                              


                                                                                        

                    
                                                                 


                 
s\n%s\n%d\n\n\n", offer->file, offer->fullpath,
							 offer->desc, offer->downloads);
		list = list->next;
	}

	fclose(fp);
}

static void xdcc_load(void)
{
	char buf[512];
	char file[128];
	char path[128];
	char desc[128];
	char dl[128];
	FILE *fp;

	snprintf(buf, sizeof(buf), "%s/xdcclist.conf", xchat_get_info(ph, "xchatdir"));

	fp = fopen(buf, "r");
	if(!fp)
		return;

	while(fgets(file, sizeof(file), fp))
	{
		file[strlen(file)-1] = 0;
		fgets(path, sizeof(path), fp);
		path[strlen(path)-1] = 0;
		fgets(desc, sizeof(desc), fp);
		desc[strlen(desc)-1] = 0;
		fgets(dl, sizeof(dl), fp);
		dl[strlen(dl)-1] = 0;
		fgets(buf, sizeof(buf), fp);
		fgets(buf, sizeof(buf), fp);
		xdcc_add(file, path, desc, atoi(dl));
	}

	fclose(fp);
}

int xchat_plugin_deinit(void)
{
	xdcc_save();
	xchat_print(ph, "XDCC List saved\n");
	return 1;
}

int xchat_plugin_init(xchat_plugin *plugin_handle,
				char **plugin_name, char **plugin_desc, char **plugin_version,
				char *arg)
{
	ph = plugin_handle;

	*plugin_name = "XDCC";
	*plugin_desc = "Very simple XDCC server";
	*plugin_version = "0.1";

	xchat_hook_command(ph, "XDCC", XCHAT_PRI_NORM, xdcc_command, 0, 0);
	xchat_hook_print(ph, "CTCP Generic", XCHAT_PRI_NORM, ctcp_cb, 0);
	xchat_hook_print(ph, "CTCP Generic to Channel", XCHAT_PRI_NORM, ctcp_cb, 0);

	xdcc_load();
	xchat_print(ph, "XDCC loaded. Type /XDCC for help.\n");

	return 1;
}