1 /*
2  *  Copyright (C) 2009-2012  Christian Heckendorf <heckendorfc@gmail.com>
3  *
4  *  This program is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 3 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "message.h"
19 #include "defs.h"
20 #include "plugins/plugin.h"
21 
debug(const int level,const char * msg)22 void debug(const int level, const char *msg){
23 #ifndef _HARP_PLUGIN
24 	if(arglist[AVERBOSE].active>=level)
25 		fprintf(stderr,"%s\n",msg);
26 	if(debugconf.log==1 && debugconf.level>=level && debugconf.msgfd){
27 		fprintf(debugconf.msgfd,"%s\n",msg);
28 		fflush(debugconf.msgfd);
29 	}
30 #else
31 #ifdef HARP_PLUGIN_DEBUG
32 	if(HARP_PLUGIN_DEBUG>=level)
33 		fprintf(stderr,"%s\n",msg);
34 #endif
35 #endif
36 }
37 
38 #ifndef _HARP_PLUGIN
printSongPubInfo(char ** row)39 void printSongPubInfo(char **row){
40 	printf( "\n=====================\n"
41 			"Title:     %s\n"
42 			"Artist:    %s\n"
43 			"Album:     %s\n"
44 			"Location:  %s\n"
45 			"File Type: %s\n"
46 			"---------------------\n",
47 			row[0],row[3],row[2],row[1],plugin_head[strtol(row[4],NULL,10)]->name);
48 	if(debugconf.log==1 && debugconf.playfd){
49 		fprintf(debugconf.playfd,"%s\t%s\t%s\t%s\t%s\n",row[0],row[3],row[2],row[1],row[4]);
50 		fflush(debugconf.playfd);
51 	}
52 }
53 #endif
54 
addStatusTail(char * msg,struct outputdetail * detail)55 void addStatusTail(char *msg, struct outputdetail *detail){
56 	int len=0;
57 	pthread_mutex_lock(&outstatus);
58 		len=snprintf(detail->tail,OUTPUT_TAIL_SIZE,"    %s",msg);
59 		for(;len<OUTPUT_TAIL_SIZE-2;len++)detail->tail[len]=' ';
60 		detail->tail[OUTPUT_TAIL_SIZE-1]=0;
61 		detail->tail[OUTPUT_TAIL_SIZE-2]='\r';
62 	pthread_mutex_unlock(&outstatus);
63 }
64 
65