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