1
/* the Music Player Daemon (MPD)
2
* (c)2003-2004 by Warren Dukes (shank@mercury.chem.pitt.edu)
3
* This project's homepage is: http://www.musicpd.org
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include <sys/types.h>
25
#include <sys/socket.h>
26
#include <sys/select.h>
30
char * myFgets(char * buffer, int bufferSize, FILE * fp) {
31
char * ret = fgets(buffer,bufferSize,fp);
32
if(ret && strlen(buffer)>0 && buffer[strlen(buffer)-1]=='\n') {
33
buffer[strlen(buffer)-1] = '\0';
35
if(ret && strlen(buffer)>0 && buffer[strlen(buffer)-1]=='\r') {
36
buffer[strlen(buffer)-1] = '\0';
41
char * strDupToUpper(char * str) {
42
char * ret = strdup(str);
45
for(i=0;i<strlen(str);i++) ret[i] = toupper((int)ret[i]);
50
void stripReturnChar(char * string) {
51
while(string && (string = strstr(string,"\n"))) {
56
void my_usleep(long usec) {
62
select(0,NULL,NULL,NULL,&tv);
68
s = socket(AF_INET6,SOCK_STREAM,0);
76
char * appendToString(char * dest, const char * src) {
78
int srclen = strlen(src);
81
dest = malloc(srclen+1);
82
memset(dest, 0, srclen+1);
86
destlen = strlen(dest);
87
dest = realloc(dest, destlen+srclen+1);
90
memcpy(dest+destlen, src, srclen);
91
dest[destlen+srclen] = '\0';