| 1 |
/* |
| 2 |
control_generic.c: control interface for frontends and real console warriors |
| 3 |
|
| 4 |
copyright 1997-99,2004-26 by the mpg123 project |
| 5 |
free software under the terms of the LGPL 2.1 |
| 6 |
see COPYING and AUTHORS files in distribution or http://mpg123.org |
| 7 |
initially written by Andreas Neuhaus and Michael Hipp |
| 8 |
reworked by Thomas Orgis - it was the entry point for eventually becoming maintainer... |
| 9 |
*/ |
| 10 |
|
| 11 |
/* _BSD_SOURCE needed for setlinebuf, erm, but that's deprecated |
| 12 |
so trying _DEFAULT_SOURCE */ |
| 13 |
#ifndef _DEFAULT_SOURCE |
| 14 |
#define _DEFAULT_SOURCE |
| 15 |
#endif |
| 16 |
/* Defining that after _DEFAULT_SOURCE seems fine and is still |
| 17 |
needed for older glibc. I guess I need a configure check |
| 18 |
about setlinebuf()/setvbuf() if I really care about old |
| 19 |
systems. */ |
| 20 |
#ifndef _BSD_SOURCE |
| 21 |
#define _BSD_SOURCE |
| 22 |
#endif |
| 23 |
|
| 24 |
#include "mpg123app.h" |
| 25 |
#include "out123.h" |
| 26 |
#include <stdarg.h> |
| 27 |
#include <ctype.h> |
| 28 |
#if !defined (_WIN32) || defined (__CYGWIN__) |
| 29 |
#include <sys/wait.h> |
| 30 |
#include <sys/socket.h> |
| 31 |
#endif |
| 32 |
#include <errno.h> |
| 33 |
#include <string.h> |
| 34 |
|
| 35 |
#include "common.h" |
| 36 |
#include "genre.h" |
| 37 |
#include "playlist.h" |
| 38 |
#include "metaprint.h" |
| 39 |
#include "audio.h" |
| 40 |
#define MODE_STOPPED 0 |
| 41 |
#define MODE_PLAYING 1 |
| 42 |
#define MODE_PAUSED 2 |
| 43 |
|
| 44 |
extern out123_handle *ao; |
| 45 |
|
| 46 |
#ifdef FIFO |
| 47 |
#include <sys/stat.h> |
| 48 |
int control_file = STDIN_FILENO; |
| 49 |
#else |
| 50 |
#define control_file STDIN_FILENO |
| 51 |
#ifdef WANT_WIN32_FIFO |
| 52 |
#error Control interface does not work on win32 stdin |
| 53 |
#endif /* WANT_WIN32_FIFO */ |
| 54 |
#endif |
| 55 |
FILE *outstream; |
| 56 |
int out_is_term = FALSE; |
| 57 |
static int mode = MODE_STOPPED; |
| 58 |
static int init = 0; |
| 59 |
static int sendstat_disabled = FALSE; |
| 60 |
|
| 61 |
#include "common/debug.h" |
| 62 |
|
| 63 |
void generic_sendmsg (const char *fmt, ...) |
| 64 |
{ |
| 65 |
va_list ap; |
| 66 |
fprintf(outstream, "@"); |
| 67 |
va_start(ap, fmt); |
| 68 |
vfprintf(outstream, fmt, ap); |
| 69 |
va_end(ap); |
| 70 |
fprintf(outstream, "\n"); |
| 71 |
} |
| 72 |
|
| 73 |
// Variant that takes the first argument as a string subject to filtering. |
| 74 |
static void generic_sendstr(int is_utf8, const char *fmt, char* str, ...) |
| 75 |
{ |
| 76 |
va_list ap; |
| 77 |
va_start(ap, str); |
| 78 |
char *outbuf = NULL; |
| 79 |
outstr(&outbuf, str, is_utf8, out_is_term); |
| 80 |
generic_sendmsg(fmt, PSTR(outbuf), ap); |
| 81 |
free(outbuf); |
| 82 |
va_end(ap); |
| 83 |
} |
| 84 |
|
| 85 |
// Another one for two strings. I want to avoid writing a full format string parser. |
| 86 |
static void generic_send2str( int is_utf8, const char *fmt |
| 87 |
, char* str, char *str2, ... ) |
| 88 |
{ |
| 89 |
va_list ap; |
| 90 |
va_start(ap, str2); |
| 91 |
char *outbuf1 = NULL; |
| 92 |
char *outbuf2 = NULL; |
| 93 |
outstr(&outbuf1, str, is_utf8, out_is_term); |
| 94 |
outstr(&outbuf2, str2, is_utf8, out_is_term); |
| 95 |
generic_sendmsg(fmt, PSTR(outbuf1), PSTR(outbuf2), ap); |
| 96 |
free(outbuf2); |
| 97 |
free(outbuf1); |
| 98 |
va_end(ap); |
| 99 |
} |
| 100 |
|
| 101 |
// Another one for three strings. Meh ... |
| 102 |
static void generic_send3str( int is_utf8, const char *fmt |
| 103 |
, char* str, char *str2, char *str3, ... ) |
| 104 |
{ |
| 105 |
va_list ap; |
| 106 |
va_start(ap, str3); |
| 107 |
char *outbuf1 = NULL; |
| 108 |
char *outbuf2 = NULL; |
| 109 |
char *outbuf3 = NULL; |
| 110 |
outstr(&outbuf1, str, is_utf8, out_is_term); |
| 111 |
outstr(&outbuf2, str2, is_utf8, out_is_term); |
| 112 |
outstr(&outbuf3, str3, is_utf8, out_is_term); |
| 113 |
generic_sendmsg( fmt |
| 114 |
, PSTR(outbuf1), PSTR(outbuf2), PSTR(outbuf3) |
| 115 |
, ap ); |
| 116 |
free(outbuf3); |
| 117 |
free(outbuf2); |
| 118 |
free(outbuf1); |
| 119 |
va_end(ap); |
| 120 |
} |
| 121 |
|
| 122 |
/* Split up a number of lines separated by \n, \r, both or just zero byte |
| 123 |
and print out each line with specified prefix. */ |
| 124 |
static void generic_send_lines(int is_utf8, const char* fmt, mpg123_string *inlines) |
| 125 |
{ |
| 126 |
size_t i; |
| 127 |
int hadcr = 0, hadlf = 0; |
| 128 |
char *lines = NULL; |
| 129 |
char *line = NULL; |
| 130 |
size_t len = 0; |
| 131 |
char *outbuf = NULL; |
| 132 |
|
| 133 |
if(inlines != NULL && inlines->fill) |
| 134 |
{ |
| 135 |
lines = inlines->p; |
| 136 |
len = inlines->fill; |
| 137 |
} |
| 138 |
else return; |
| 139 |
|
| 140 |
line = lines; |
| 141 |
for(i=0; i<len; ++i) |
| 142 |
{ |
| 143 |
if(lines[i] == '\n' || lines[i] == '\r' || lines[i] == 0) |
| 144 |
{ |
| 145 |
char save = lines[i]; /* saving, changing, restoring a byte in the data */ |
| 146 |
if(save == '\n') ++hadlf; |
| 147 |
if(save == '\r') ++hadcr; |
| 148 |
if((hadcr || hadlf) && hadlf % 2 == 0 && hadcr % 2 == 0) line = ""; |
| 149 |
|
| 150 |
if(line) |
| 151 |
{ |
| 152 |
lines[i] = 0; |
| 153 |
outstr(&outbuf, line, is_utf8, out_is_term); |
| 154 |
generic_sendmsg(fmt, outbuf ? outbuf : "???"); |
| 155 |
line = NULL; |
| 156 |
lines[i] = save; |
| 157 |
} |
| 158 |
} |
| 159 |
else |
| 160 |
{ |
| 161 |
hadlf = hadcr = 0; |
| 162 |
if(line == NULL) line = lines+i; |
| 163 |
} |
| 164 |
} |
| 165 |
free(outbuf); |
| 166 |
} |
| 167 |
|
| 168 |
void generic_sendstat (mpg123_handle *fr) |
| 169 |
{ |
| 170 |
if(sendstat_disabled) |
| 171 |
return; |
| 172 |
off_t current_frame, frames_left; |
| 173 |
double current_seconds, seconds_left; |
| 174 |
|
| 175 |
if(!position_info(fr, 0, ao, ¤t_frame, &frames_left, ¤t_seconds, &seconds_left, NULL, NULL)) |
| 176 |
generic_sendmsg("F %" PRIiMAX " %" PRIiMAX " %3.2f %3.2f", (intmax_t)current_frame, (intmax_t)frames_left, current_seconds, seconds_left); |
| 177 |
else |
| 178 |
{ |
| 179 |
sendstat_disabled = TRUE; |
| 180 |
generic_sendmsg("E Error getting position information, disabling playback status."); |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
// This is only valid as herlper to generic_sendv1, observe info memory usage! |
| 185 |
static void v1add(char *buf[], char *info, const char *str, size_t len) |
| 186 |
{ |
| 187 |
memset(info, 0, len); |
| 188 |
if(!unknown2utf8(buf, str, len)) |
| 189 |
{ |
| 190 |
outstr(buf+1, buf[0], 1, out_is_term); |
| 191 |
size_t slen = buf[1] ? strlen(buf[1])+1 : 0; |
| 192 |
memcpy(info, PSTR(buf[1]), slen >=len ? len : slen); |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
static void generic_sendv1(mpg123_id3v1 *v1, const char *prefix) |
| 197 |
{ |
| 198 |
int i; |
| 199 |
char info[125] = ""; |
| 200 |
char *buf[2]; |
| 201 |
buf[0] = NULL; |
| 202 |
buf[1] = NULL; |
| 203 |
|
| 204 |
v1add(buf, info, v1->title, 30); |
| 205 |
v1add(buf, info+30, v1->artist, 30); |
| 206 |
v1add(buf, info+60, v1->album, 30); |
| 207 |
v1add(buf, info+90, v1->year, 4); |
| 208 |
v1add(buf, info+94, v1->comment, 30); |
| 209 |
|
| 210 |
for(i=0;i<124; ++i) if(info[i] == 0) info[i] = ' '; |
| 211 |
info[i] = 0; |
| 212 |
generic_sendmsg("%s ID3:%s%s", prefix, info, (v1->genre<=genre_count) ? genre_table[v1->genre] : "Unknown"); |
| 213 |
generic_sendmsg("%s ID3.genre:%i", prefix, v1->genre); |
| 214 |
if(v1->comment[28] == 0 && v1->comment[29] != 0) |
| 215 |
generic_sendmsg("%s ID3.track:%i", prefix, (unsigned char)v1->comment[29]); |
| 216 |
free(buf[1]); |
| 217 |
free(buf[0]); |
| 218 |
} |
| 219 |
|
| 220 |
static void generic_sendinfoid3(mpg123_handle *mh) |
| 221 |
{ |
| 222 |
mpg123_id3v1 *v1; |
| 223 |
mpg123_id3v2 *v2; |
| 224 |
if(MPG123_OK != mpg123_id3(mh, &v1, &v2)) |
| 225 |
{ |
| 226 |
error1("Cannot get ID3 data: %s", mpg123_strerror(mh)); |
| 227 |
return; |
| 228 |
} |
| 229 |
generic_sendmsg("I {"); |
| 230 |
if(v1 != NULL) |
| 231 |
{ |
| 232 |
generic_sendv1(v1, "I"); |
| 233 |
} |
| 234 |
if(v2 != NULL) |
| 235 |
{ |
| 236 |
generic_send_lines(1, "I ID3v2.title:%s", v2->title); |
| 237 |
generic_send_lines(1, "I ID3v2.artist:%s", v2->artist); |
| 238 |
generic_send_lines(1, "I ID3v2.album:%s", v2->album); |
| 239 |
generic_send_lines(1, "I ID3v2.year:%s", v2->year); |
| 240 |
generic_send_lines(1, "I ID3v2.comment:%s", v2->comment); |
| 241 |
generic_send_lines(1, "I ID3v2.genre:%s", v2->genre); |
| 242 |
} |
| 243 |
generic_sendmsg("I }"); |
| 244 |
} |
| 245 |
|
| 246 |
void generic_sendalltag(mpg123_handle *mh) |
| 247 |
{ |
| 248 |
mpg123_id3v1 *v1; |
| 249 |
mpg123_id3v2 *v2; |
| 250 |
generic_sendmsg("T {"); |
| 251 |
if(MPG123_OK != mpg123_id3(mh, &v1, &v2)) |
| 252 |
{ |
| 253 |
error1("Cannot get ID3 data: %s", mpg123_strerror(mh)); |
| 254 |
v2 = NULL; |
| 255 |
v1 = NULL; |
| 256 |
} |
| 257 |
if(v1 != NULL) generic_sendv1(v1, "T"); |
| 258 |
|
| 259 |
if(v2 != NULL) |
| 260 |
{ |
| 261 |
size_t i; |
| 262 |
for(i=0; i<v2->texts; ++i) |
| 263 |
{ |
| 264 |
char id[5]; |
| 265 |
memcpy(id, v2->text[i].id, 4); |
| 266 |
id[4] = 0; |
| 267 |
generic_sendstr(1, "T ID3v2.%s:", id); |
| 268 |
generic_send_lines(1, "T =%s", &v2->text[i].text); |
| 269 |
} |
| 270 |
for(i=0; i<v2->extras; ++i) |
| 271 |
{ |
| 272 |
char id[5]; |
| 273 |
memcpy(id, v2->extra[i].id, 4); |
| 274 |
id[4] = 0; |
| 275 |
generic_send2str( 1, "T ID3v2.%s desc(%s)" |
| 276 |
, id, MPGSTR(v2->extra[i].description) ); |
| 277 |
generic_send_lines(1, "T =%s", &v2->extra[i].text); |
| 278 |
} |
| 279 |
for(i=0; i<v2->comments; ++i) |
| 280 |
{ |
| 281 |
char id[5]; |
| 282 |
char lang[4]; |
| 283 |
memcpy(id, v2->comment_list[i].id, 4); |
| 284 |
id[4] = 0; |
| 285 |
memcpy(lang, v2->comment_list[i].lang, 3); |
| 286 |
lang[3] = 0; |
| 287 |
generic_send3str( 1, "T ID3v2.%s lang(%s) desc(%s):", |
| 288 |
id, lang, MPGSTR(v2->comment_list[i].description) ); |
| 289 |
generic_send_lines(1, "T =%s", &v2->comment_list[i].text); |
| 290 |
} |
| 291 |
} |
| 292 |
generic_sendmsg("T }"); |
| 293 |
} |
| 294 |
|
| 295 |
void generic_sendinfo (char *filename) |
| 296 |
{ |
| 297 |
char *s, *t; |
| 298 |
s = strrchr(filename, '/'); |
| 299 |
if (!s) |
| 300 |
s = filename; |
| 301 |
else |
| 302 |
s++; |
| 303 |
t = strrchr(s, '.'); |
| 304 |
if (t) |
| 305 |
*t = 0; |
| 306 |
generic_sendstr(0, "I %s", s); |
| 307 |
} |
| 308 |
|
| 309 |
static void generic_load(mpg123_handle *fr, char *arg, int state) |
| 310 |
{ |
| 311 |
sendstat_disabled = FALSE; |
| 312 |
out123_drop(ao); |
| 313 |
if(mode != MODE_STOPPED) |
| 314 |
{ |
| 315 |
close_track(); |
| 316 |
mode = MODE_STOPPED; |
| 317 |
} |
| 318 |
if(!open_track(arg)) |
| 319 |
{ |
| 320 |
generic_sendmsg("E Error opening stream: %s", arg); |
| 321 |
generic_sendmsg("P 0"); |
| 322 |
return; |
| 323 |
} |
| 324 |
mpg123_seek(fr, 0, SEEK_SET); /* This finds ID3v2 at beginning. */ |
| 325 |
if(mpg123_meta_check(fr) & MPG123_NEW_ID3) |
| 326 |
{ |
| 327 |
generic_sendinfoid3(fr); |
| 328 |
} |
| 329 |
else generic_sendinfo(arg); |
| 330 |
|
| 331 |
if(filept->htd.icy_name.fill) generic_sendstr(1, "I ICY-NAME: %s", filept->htd.icy_name.p); |
| 332 |
if(filept->htd.icy_url.fill) generic_sendstr(1, "I ICY-URL: %s", filept->htd.icy_url.p); |
| 333 |
|
| 334 |
mode = state; |
| 335 |
init = 1; |
| 336 |
generic_sendmsg(mode == MODE_PAUSED ? "P 1" : "P 2"); |
| 337 |
} |
| 338 |
|
| 339 |
static void generic_loadlist(mpg123_handle *fr, char *arg) |
| 340 |
{ |
| 341 |
/* arguments are two: first the index to play, then the URL */ |
| 342 |
long entry; |
| 343 |
long i = 0; |
| 344 |
char *file = NULL; |
| 345 |
char *thefile = NULL; |
| 346 |
char *outbuf = NULL; |
| 347 |
|
| 348 |
/* I feel retarted with string parsing outside Perl. */ |
| 349 |
while(*arg && isspace(*arg)) ++arg; |
| 350 |
entry = atol(arg); |
| 351 |
while(*arg && !isspace(*arg)) ++arg; |
| 352 |
while(*arg && isspace(*arg)) ++arg; |
| 353 |
if(!*arg) |
| 354 |
{ |
| 355 |
generic_sendmsg("E empty list name"); |
| 356 |
return; |
| 357 |
} |
| 358 |
|
| 359 |
generic_sendmsg("I {"); |
| 360 |
|
| 361 |
/* Now got the plain playlist path in arg. On to evil manupulation of mpg123's playlist code. */ |
| 362 |
param.listname = arg; |
| 363 |
param.listentry = 0; /* The playlist shall not filter. */ |
| 364 |
param.loop = 1; |
| 365 |
param.shuffle = 0; |
| 366 |
int pl_utf8 = 0; |
| 367 |
prepare_playlist(0, NULL, 0, &pl_utf8); |
| 368 |
while((file = get_next_file())) |
| 369 |
{ |
| 370 |
++i; |
| 371 |
/* semantics: 0 brings you to the last track */ |
| 372 |
if(entry == 0 || entry == i) thefile = file; |
| 373 |
|
| 374 |
outstr(&outbuf, file, pl_utf8, out_is_term); |
| 375 |
generic_sendmsg("I LISTENTRY %li: %s", i, outbuf ? outbuf : "???"); |
| 376 |
} |
| 377 |
if(!i) generic_sendmsg("I LIST EMPTY"); |
| 378 |
|
| 379 |
generic_sendmsg("I }"); |
| 380 |
|
| 381 |
/* If we have something to play, play it. */ |
| 382 |
if(thefile) generic_load(fr, thefile, MODE_PLAYING); |
| 383 |
|
| 384 |
free_playlist(); /* Free memory after it is not needed anymore. */ |
| 385 |
free(outbuf); |
| 386 |
} |
| 387 |
|
| 388 |
int control_generic (mpg123_handle *fr) |
| 389 |
{ |
| 390 |
struct timeval tv; |
| 391 |
fd_set fds; |
| 392 |
int n; |
| 393 |
|
| 394 |
/* ThOr */ |
| 395 |
char alive = 1; |
| 396 |
char silent = 0; |
| 397 |
|
| 398 |
/* responses to stderr for frontends needing audio data from stdout */ |
| 399 |
if (param.remote_err) |
| 400 |
{ |
| 401 |
outstream = stderr; |
| 402 |
out_is_term = stderr_is_term; |
| 403 |
} |
| 404 |
else |
| 405 |
{ |
| 406 |
outstream = stdout; |
| 407 |
out_is_term = stdout_is_term; |
| 408 |
} |
| 409 |
#ifndef _WIN32 |
| 410 |
setlinebuf(outstream); |
| 411 |
#else /* perhaps just use setvbuf as it's C89 */ |
| 412 |
/* |
| 413 |
fprintf(outstream, "You are on Win32 and want to use the control interface... tough luck: We need a replacement for select on STDIN first.\n"); |
| 414 |
return 0; |
| 415 |
setvbuf(outstream, (char*)NULL, _IOLBF, 0); |
| 416 |
*/ |
| 417 |
#endif |
| 418 |
/* the command behaviour is different, so is the ID */ |
| 419 |
/* now also with version for command availability */ |
| 420 |
fprintf(outstream, "@R MPG123 (ThOr) v11\n"); |
| 421 |
#ifdef FIFO |
| 422 |
if(param.fifo) |
| 423 |
{ |
| 424 |
if(param.fifo[0] == 0) |
| 425 |
{ |
| 426 |
error("You wanted an empty FIFO name??"); |
| 427 |
return 1; |
| 428 |
} |
| 429 |
#ifndef WANT_WIN32_FIFO |
| 430 |
unlink(param.fifo); |
| 431 |
if(mkfifo(param.fifo, 0666) == -1) |
| 432 |
{ |
| 433 |
error2("Failed to create FIFO at %s (%s)", param.fifo, INT123_strerror(errno)); |
| 434 |
return 1; |
| 435 |
} |
| 436 |
debug("going to open named pipe ... blocking until someone gives command"); |
| 437 |
#endif /* WANT_WIN32_FIFO */ |
| 438 |
#ifdef WANT_WIN32_FIFO |
| 439 |
control_file = win32_fifo_mkfifo(param.fifo); |
| 440 |
#else |
| 441 |
control_file = open(param.fifo,O_RDONLY); |
| 442 |
#endif /* WANT_WIN32_FIFO */ |
| 443 |
debug("opened"); |
| 444 |
} |
| 445 |
#endif |
| 446 |
|
| 447 |
// Persist over loop iterations to remember unfinished commands. |
| 448 |
char buf[REMOTE_BUFFER_SIZE]; // command buffer |
| 449 |
short int last_len = 0; // length of partial command in there |
| 450 |
|
| 451 |
while (alive) |
| 452 |
{ |
| 453 |
tv.tv_sec = 0; |
| 454 |
tv.tv_usec = 0; |
| 455 |
FD_ZERO(&fds); |
| 456 |
FD_SET(control_file, &fds); |
| 457 |
/* play frame if no command needs to be processed */ |
| 458 |
if (mode == MODE_PLAYING) { |
| 459 |
#ifdef WANT_WIN32_FIFO |
| 460 |
n = win32_fifo_read_peek(&tv); |
| 461 |
#else |
| 462 |
n = select(32, &fds, NULL, NULL, &tv); |
| 463 |
#endif |
| 464 |
if (n == 0) { |
| 465 |
if (!play_frame()) |
| 466 |
{ |
| 467 |
size_t drain_block; |
| 468 |
size_t buffered; |
| 469 |
|
| 470 |
// Ensure that prepared audio really got played, drain buffer. |
| 471 |
// There is no control during draining. This mode was not planned for big buffers. |
| 472 |
play_prebuffer(); |
| 473 |
buffered = out123_buffered(ao); |
| 474 |
if(buffered) |
| 475 |
{ |
| 476 |
int framesize = 1; |
| 477 |
long rate = 1; |
| 478 |
out123_getformat(ao, &rate, NULL, NULL, &framesize); |
| 479 |
generic_sendmsg("DRAIN %.1f", (double)buffered/framesize/rate); |
| 480 |
if(silent == 0) |
| 481 |
{ |
| 482 |
generic_sendstat(fr); |
| 483 |
drain_block = 1152*framesize; |
| 484 |
do |
| 485 |
{ |
| 486 |
out123_ndrain(ao, drain_block); |
| 487 |
generic_sendstat(fr); |
| 488 |
} |
| 489 |
while(out123_buffered(ao)); |
| 490 |
} else |
| 491 |
out123_drain(ao); |
| 492 |
} |
| 493 |
out123_pause(ao); |
| 494 |
generic_sendmsg("P 3"); |
| 495 |
/* When the track ended, user may want to keep it open (to seek back), |
| 496 |
so there is a decision between stopping and pausing at the end. */ |
| 497 |
if(param.keep_open) |
| 498 |
{ |
| 499 |
mode = MODE_PAUSED; |
| 500 |
/* Hm, buffer should be stopped already, shouldn't it? */ |
| 501 |
generic_sendmsg("P 1"); |
| 502 |
} |
| 503 |
else |
| 504 |
{ |
| 505 |
mode = MODE_STOPPED; |
| 506 |
close_track(); |
| 507 |
generic_sendmsg("P 0"); |
| 508 |
} |
| 509 |
continue; |
| 510 |
} |
| 511 |
if (init) { |
| 512 |
print_remote_header(fr); |
| 513 |
init = 0; |
| 514 |
} |
| 515 |
if(silent == 0) |
| 516 |
{ |
| 517 |
generic_sendstat(fr); |
| 518 |
if(mpg123_meta_check(fr) & MPG123_NEW_ICY) |
| 519 |
{ |
| 520 |
char *meta; |
| 521 |
if(mpg123_icy(fr, &meta) == MPG123_OK) |
| 522 |
generic_sendstr( 1, "I ICY-META: %s" |
| 523 |
, meta != NULL ? meta : "<nil>" ); |
| 524 |
} |
| 525 |
} |
| 526 |
} |
| 527 |
} |
| 528 |
else { |
| 529 |
/* wait for command */ |
| 530 |
while (1) { |
| 531 |
#ifdef WANT_WIN32_FIFO |
| 532 |
n = win32_fifo_read_peek(NULL); |
| 533 |
#else |
| 534 |
n = select(32, &fds, NULL, NULL, NULL); |
| 535 |
#endif |
| 536 |
if (n > 0) |
| 537 |
break; |
| 538 |
} |
| 539 |
} |
| 540 |
/* on error */ |
| 541 |
if(n < 0) |
| 542 |
{ |
| 543 |
merror("waiting for command: %s", INT123_strerror(errno)); |
| 544 |
return 1; |
| 545 |
} |
| 546 |
/* read & process commands */ |
| 547 |
if (n > 0) |
| 548 |
{ |
| 549 |
short int len = 1; /* length of buffer */ |
| 550 |
char *cmd, *arg; /* variables for parsing, */ |
| 551 |
char *comstr = NULL; /* gcc thinks that this could be used uninitialited... */ |
| 552 |
short int counter; |
| 553 |
char *next_comstr = buf; /* have it initialized for first command */ |
| 554 |
|
| 555 |
/* read as much as possible, maybe multiple commands */ |
| 556 |
/* When there is nothing to read (EOF) or even an error, it is the end */ |
| 557 |
#ifdef WANT_WIN32_FIFO |
| 558 |
len = win32_fifo_read(buf+last_len,REMOTE_BUFFER_SIZE-last_len); |
| 559 |
#else |
| 560 |
len = read(control_file, buf+last_len, REMOTE_BUFFER_SIZE-last_len); |
| 561 |
#endif |
| 562 |
if(len < 1) |
| 563 |
{ |
| 564 |
#ifdef FIFO |
| 565 |
if(len == 0 && param.fifo) |
| 566 |
{ |
| 567 |
debug("fifo ended... reopening"); |
| 568 |
#ifdef WANT_WIN32_FIFO |
| 569 |
win32_fifo_mkfifo(param.fifo); |
| 570 |
#else |
| 571 |
close(control_file); |
| 572 |
control_file = open(param.fifo,O_RDONLY|O_NONBLOCK); |
| 573 |
#endif |
| 574 |
if(control_file < 0){ error1("open of fifo failed... %s", INT123_strerror(errno)); break; } |
| 575 |
continue; |
| 576 |
} |
| 577 |
#endif |
| 578 |
if(len < 0) error1("command read error: %s", INT123_strerror(errno)); |
| 579 |
break; |
| 580 |
} |
| 581 |
|
| 582 |
debug1("read %i bytes of commands", len); |
| 583 |
len += last_len; // on top of remembered piece |
| 584 |
/* one command on a line - separation by \n -> C strings in a row */ |
| 585 |
last_len = 0; |
| 586 |
for(counter = 0; counter < len; ++counter) |
| 587 |
{ |
| 588 |
/* line end is command end */ |
| 589 |
if( (buf[counter] == '\n') || (buf[counter] == '\r') ) |
| 590 |
{ |
| 591 |
debug1("line end at counter=%i", counter); |
| 592 |
buf[counter] = 0; /* now it's a properly ending C string */ |
| 593 |
comstr = next_comstr; |
| 594 |
|
| 595 |
/* skip the additional line ender of \r\n or \n\r */ |
| 596 |
if( (counter < (len - 1)) && ((buf[counter+1] == '\n') || (buf[counter+1] == '\r')) ) buf[++counter] = 0; |
| 597 |
|
| 598 |
/* next "real" char is first of next command */ |
| 599 |
next_comstr = buf + counter+1; |
| 600 |
|
| 601 |
/* directly process the command now */ |
| 602 |
debug1("interpreting command: %s", comstr); |
| 603 |
if(strlen(comstr) == 0) continue; |
| 604 |
|
| 605 |
/* PAUSE */ |
| 606 |
if (!strcasecmp(comstr, "P") || !strcasecmp(comstr, "PAUSE")) { |
| 607 |
if(mode != MODE_STOPPED) |
| 608 |
{ |
| 609 |
if (mode == MODE_PLAYING) { |
| 610 |
mode = MODE_PAUSED; |
| 611 |
out123_pause(ao); |
| 612 |
generic_sendmsg("P 1"); |
| 613 |
} else { |
| 614 |
mode = MODE_PLAYING; |
| 615 |
out123_continue(ao); |
| 616 |
generic_sendmsg("P 2"); |
| 617 |
} |
| 618 |
} else generic_sendmsg("P 0"); |
| 619 |
continue; |
| 620 |
} |
| 621 |
|
| 622 |
/* STOP */ |
| 623 |
if (!strcasecmp(comstr, "S") || !strcasecmp(comstr, "STOP")) { |
| 624 |
if (mode != MODE_STOPPED) { |
| 625 |
/* Do we want to drop here? */ |
| 626 |
out123_drop(ao); |
| 627 |
out123_pause(ao); |
| 628 |
close_track(); |
| 629 |
mode = MODE_STOPPED; |
| 630 |
generic_sendmsg("P 0"); |
| 631 |
} else generic_sendmsg("P 0"); |
| 632 |
continue; |
| 633 |
} |
| 634 |
|
| 635 |
/* SILENCE */ |
| 636 |
if(!strcasecmp(comstr, "SILENCE")) { |
| 637 |
silent = 1; |
| 638 |
generic_sendmsg("SILENCE"); |
| 639 |
continue; |
| 640 |
} |
| 641 |
|
| 642 |
/* PROGRESS, opposite of silence */ |
| 643 |
if(!strcasecmp(comstr, "PROGRESS")) { |
| 644 |
silent = 0; |
| 645 |
generic_sendmsg("PROGRESS"); |
| 646 |
continue; |
| 647 |
} |
| 648 |
|
| 649 |
if(!strcasecmp(comstr, "MUTE")) { |
| 650 |
set_mute(ao, muted=TRUE); |
| 651 |
generic_sendmsg("MUTE"); |
| 652 |
continue; |
| 653 |
} |
| 654 |
|
| 655 |
if(!strcasecmp(comstr, "UNMUTE")) { |
| 656 |
set_mute(ao, muted=FALSE); |
| 657 |
generic_sendmsg("UNMUTE"); |
| 658 |
continue; |
| 659 |
} |
| 660 |
|
| 661 |
if(!strcasecmp(comstr, "T") || !strcasecmp(comstr, "TAG")) { |
| 662 |
generic_sendalltag(fr); |
| 663 |
continue; |
| 664 |
} |
| 665 |
|
| 666 |
if(!strcasecmp(comstr, "SCAN")) |
| 667 |
{ |
| 668 |
if(mode != MODE_STOPPED) |
| 669 |
{ |
| 670 |
if(mpg123_scan(fr) == MPG123_OK) |
| 671 |
generic_sendmsg("SCAN done"); |
| 672 |
else |
| 673 |
generic_sendmsg("E %s", mpg123_strerror(fr)); |
| 674 |
} |
| 675 |
else generic_sendmsg("E No track loaded!"); |
| 676 |
|
| 677 |
continue; |
| 678 |
} |
| 679 |
|
| 680 |
if(!strcasecmp(comstr, "SAMPLE")) |
| 681 |
{ |
| 682 |
off_t pos = mpg123_tell(fr); |
| 683 |
off_t len = mpg123_length(fr); |
| 684 |
/* I need to have portable printf specifiers that do not truncate the type... more autoconf... */ |
| 685 |
if(len < 0) generic_sendmsg("E %s", mpg123_strerror(fr)); |
| 686 |
else generic_sendmsg("SAMPLE %li %li", (long)pos, (long)len); |
| 687 |
continue; |
| 688 |
} |
| 689 |
|
| 690 |
if(!strcasecmp(comstr, "FORMAT")) |
| 691 |
{ |
| 692 |
long rate; |
| 693 |
int ch; |
| 694 |
int ret = mpg123_getformat2(fr, &rate, &ch, NULL, 0); |
| 695 |
/* I need to have portable printf specifiers that do not truncate the type... more autoconf... */ |
| 696 |
if(ret < 0) generic_sendmsg("E %s", mpg123_strerror(fr)); |
| 697 |
else generic_sendmsg("FORMAT %li %i", rate, ch); |
| 698 |
continue; |
| 699 |
} |
| 700 |
|
| 701 |
if(!strcasecmp(comstr, "SHOWEQ")) |
| 702 |
{ |
| 703 |
int i; |
| 704 |
generic_sendmsg("SHOWEQ {"); |
| 705 |
for(i=0; i<32; ++i) |
| 706 |
{ |
| 707 |
generic_sendmsg("SHOWEQ %i : %i : %f", MPG123_LEFT, i, mpg123_geteq(fr, MPG123_LEFT, i)); |
| 708 |
generic_sendmsg("SHOWEQ %i : %i : %f", MPG123_RIGHT, i, mpg123_geteq(fr, MPG123_RIGHT, i)); |
| 709 |
} |
| 710 |
generic_sendmsg("SHOWEQ }"); |
| 711 |
continue; |
| 712 |
} |
| 713 |
|
| 714 |
if(!strcasecmp(comstr, "STATE")) |
| 715 |
{ |
| 716 |
long val; |
| 717 |
generic_sendmsg("STATE {"); |
| 718 |
/* Get some state information bits and display them. */ |
| 719 |
if(mpg123_getstate(fr, MPG123_ACCURATE, &val, NULL) == MPG123_OK) |
| 720 |
generic_sendmsg("STATE accurate %li", val); |
| 721 |
|
| 722 |
generic_sendmsg("STATE }"); |
| 723 |
continue; |
| 724 |
} |
| 725 |
|
| 726 |
/* QUIT */ |
| 727 |
if (!strcasecmp(comstr, "Q") || !strcasecmp(comstr, "QUIT")){ |
| 728 |
out123_drop(ao); |
| 729 |
alive = FALSE; continue; |
| 730 |
} |
| 731 |
|
| 732 |
/* some HELP */ |
| 733 |
if (!strcasecmp(comstr, "H") || !strcasecmp(comstr, "HELP")) { |
| 734 |
generic_sendmsg("H {"); |
| 735 |
generic_sendmsg("H HELP/H: command listing (LONG/SHORT forms), command case insensitve"); |
| 736 |
generic_sendmsg("H LOAD/L <trackname>: load and start playing resource <trackname>"); |
| 737 |
generic_sendmsg("H LOADPAUSED/LP <trackname>: load but do not start playing resource <trackname>"); |
| 738 |
generic_sendmsg("H LOADLIST/LL <entry> <url>: load a playlist from given <url>, and display its entries, optionally load and play one of these specificed by the integer <entry> (<0: just list, 0: play last track, >0:play track with that position in list)"); |
| 739 |
generic_sendmsg("H PAUSE/P: pause playback"); |
| 740 |
generic_sendmsg("H STOP/S: stop playback (closes file)"); |
| 741 |
generic_sendmsg("H JUMP/J <frame>|<+offset>|<-offset>|<[+|-]seconds>s: jump to mpeg frame <frame> or change position by offset, same in seconds if number followed by \"s\""); |
| 742 |
generic_sendmsg("H VOLUME/V <percent>: set volume in % (0..100...); float value"); |
| 743 |
generic_sendmsg("H MUTE: turn on software mute in output"); |
| 744 |
generic_sendmsg("H UNMUTE: turn off software mute in output"); |
| 745 |
generic_sendmsg("H RVA off|(mix|radio)|(album|audiophile): set rva mode"); |
| 746 |
generic_sendmsg("H EQ/E <channel> <band> <value>: set equalizer value for frequency band 0 to 31 on channel %i (left) or %i (right) or %i (both)", MPG123_LEFT, MPG123_RIGHT, MPG123_LR); |
| 747 |
generic_sendmsg("H EQFILE <filename>: load EQ settings from a file"); |
| 748 |
generic_sendmsg("H SHOWEQ: show all equalizer settings (as <channel> <band> <value> lines in a SHOWEQ block (like TAG))"); |
| 749 |
generic_sendmsg("H SEEK/K <sample>|<+offset>|<-offset>: jump to output sample position <samples> or change position by offset"); |
| 750 |
generic_sendmsg("H SCAN: scan through the file, building seek index"); |
| 751 |
generic_sendmsg("H SAMPLE: print out the sample position and total number of samples"); |
| 752 |
generic_sendmsg("H FORMAT: print out sampling rate in Hz and channel count"); |
| 753 |
generic_sendmsg("H SEQ <bass> <mid> <treble>: simple eq setting..."); |
| 754 |
generic_sendmsg("H PITCH <[+|-]value>: adjust playback speed (+0.01 is 1 %% faster)"); |
| 755 |
generic_sendmsg("H SILENCE: be silent during playback (no progress info, opposite of PROGRESS)"); |
| 756 |
generic_sendmsg("H PROGRESS: turn on progress display (opposite of SILENCE)"); |
| 757 |
generic_sendmsg("H STATE: Print auxiliary state info in several lines (just try it to see what info is there)."); |
| 758 |
generic_sendmsg("H TAG/T: Print all available (ID3) tag info, for ID3v2 that gives output of all collected text fields, using the ID3v2.3/4 4-character names. NOTE: ID3v2 data will be deleted on non-forward seeks."); |
| 759 |
generic_sendmsg("H The output is multiple lines, begin marked by \"@T {\", end by \"@T }\"."); |
| 760 |
generic_sendmsg("H ID3v1 data is like in the @I info lines (see below), just with \"@T\" in front."); |
| 761 |
generic_sendmsg("H An ID3v2 data field is introduced via ([ ... ] means optional):"); |
| 762 |
generic_sendmsg("H @T ID3v2.<NAME>[ [lang(<LANG>)] desc(<description>)]:"); |
| 763 |
generic_sendmsg("H The lines of data follow with \"=\" prefixed:"); |
| 764 |
generic_sendmsg("H @T =<one line of content in UTF-8 encoding>"); |
| 765 |
generic_sendmsg("H meaning of the @S stream info:"); |
| 766 |
generic_sendmsg("H %s", remote_header_help); |
| 767 |
generic_sendmsg("H The @I lines after loading a track give some ID3 info, the format:"); |
| 768 |
generic_sendmsg("H @I ID3:artist album year comment genretext"); |
| 769 |
generic_sendmsg("H where artist,album and comment are exactly 30 characters each, year is 4 characters, genre text unspecified."); |
| 770 |
generic_sendmsg("H You will encounter \"@I ID3.genre:<number>\" and \"@I ID3.track:<number>\"."); |
| 771 |
generic_sendmsg("H Then, there is an excerpt of ID3v2 info in the structure"); |
| 772 |
generic_sendmsg("H @I ID3v2.title:Blabla bla Bla"); |
| 773 |
generic_sendmsg("H for every line of the \"title\" data field. Likewise for other fields (author, album, etc)."); |
| 774 |
generic_sendmsg("H }"); |
| 775 |
continue; |
| 776 |
} |
| 777 |
|
| 778 |
/* commands with arguments */ |
| 779 |
cmd = NULL; |
| 780 |
arg = NULL; |
| 781 |
char *toksave = NULL; |
| 782 |
cmd = INT123_compat_strtok(comstr, " \t", &toksave); /* get the main command */ |
| 783 |
arg = INT123_compat_strtok(NULL, "", &toksave); /* get the args */ |
| 784 |
|
| 785 |
if (cmd && strlen(cmd) && arg && strlen(arg)) |
| 786 |
{ |
| 787 |
#ifndef NO_EQUALIZER |
| 788 |
/* Simple EQ: SEQ <BASS> <MID> <TREBLE> */ |
| 789 |
if (!strcasecmp(cmd, "SEQ")) { |
| 790 |
double b,m,t; |
| 791 |
if(sscanf(arg, "%lf %lf %lf", &b, &m, &t) == 3) |
| 792 |
{ |
| 793 |
mpg123_eq_bands(fr, MPG123_LR, 0, 0, b); |
| 794 |
mpg123_eq_bands(fr, MPG123_LR, 1, 1, m); |
| 795 |
mpg123_eq_bands(fr, MPG123_LR, 2, 31, t); |
| 796 |
generic_sendmsg("bass: %f mid: %f treble: %f", b, m, t); |
| 797 |
} |
| 798 |
else generic_sendmsg("E invalid arguments for SEQ: %s", arg); |
| 799 |
continue; |
| 800 |
} |
| 801 |
|
| 802 |
/* Equalizer control :) (JMG) */ |
| 803 |
if (!strcasecmp(cmd, "E") || !strcasecmp(cmd, "EQ")) { |
| 804 |
double e; /* ThOr: equalizer is of type real... whatever that is */ |
| 805 |
int c, v; |
| 806 |
/*generic_sendmsg("%s",updown);*/ |
| 807 |
if(sscanf(arg, "%i %i %lf", &c, &v, &e) == 3) |
| 808 |
{ |
| 809 |
if(mpg123_eq(fr, c, v, e) == MPG123_OK) |
| 810 |
generic_sendmsg("%i : %i : %f", c, v, e); |
| 811 |
else |
| 812 |
generic_sendmsg("E failed to set eq: %s", mpg123_strerror(fr)); |
| 813 |
} |
| 814 |
else generic_sendmsg("E invalid arguments for EQ: %s", arg); |
| 815 |
continue; |
| 816 |
} |
| 817 |
|
| 818 |
if(!strcasecmp(cmd, "EQFILE")) |
| 819 |
{ |
| 820 |
equalfile = arg; |
| 821 |
if(load_equalizer(fr) == 0) |
| 822 |
generic_sendmsg("EQFILE done"); |
| 823 |
else |
| 824 |
generic_sendmsg("E failed to parse given eq file"); |
| 825 |
|
| 826 |
continue; |
| 827 |
} |
| 828 |
#endif |
| 829 |
/* SEEK to a sample offset */ |
| 830 |
if(!strcasecmp(cmd, "K") || !strcasecmp(cmd, "SEEK")) |
| 831 |
{ |
| 832 |
off_t soff; |
| 833 |
off_t oldpos; |
| 834 |
off_t newpos; |
| 835 |
char *spos = arg; |
| 836 |
int whence = SEEK_SET; |
| 837 |
if(mode == MODE_STOPPED) |
| 838 |
{ |
| 839 |
generic_sendmsg("E No track loaded!"); |
| 840 |
continue; |
| 841 |
} |
| 842 |
oldpos = mpg123_tell(fr); |
| 843 |
|
| 844 |
soff = (off_t) atobigint(spos); |
| 845 |
if(spos[0] == '-' || spos[0] == '+') whence = SEEK_CUR; |
| 846 |
if(0 > (soff = mpg123_seek(fr, soff, whence))) |
| 847 |
{ |
| 848 |
generic_sendmsg("E Error while seeking: %s", mpg123_strerror(fr)); |
| 849 |
mpg123_seek(fr, 0, SEEK_SET); |
| 850 |
} |
| 851 |
out123_drop(ao); |
| 852 |
|
| 853 |
newpos = mpg123_tell(fr); |
| 854 |
if(newpos <= oldpos) mpg123_meta_free(fr); |
| 855 |
|
| 856 |
generic_sendmsg("K %" PRIiMAX, (intmax_t)newpos); |
| 857 |
continue; |
| 858 |
} |
| 859 |
/* JUMP */ |
| 860 |
if (!strcasecmp(cmd, "J") || !strcasecmp(cmd, "JUMP")) { |
| 861 |
char *spos; |
| 862 |
off_t offset; |
| 863 |
off_t oldpos; |
| 864 |
double secs; |
| 865 |
|
| 866 |
spos = arg; |
| 867 |
if(mode == MODE_STOPPED) |
| 868 |
{ |
| 869 |
generic_sendmsg("E No track loaded!"); |
| 870 |
continue; |
| 871 |
} |
| 872 |
oldpos = framenum; |
| 873 |
|
| 874 |
if(spos[strlen(spos)-1] == 's' && sscanf(arg, "%lf", &secs) == 1) offset = mpg123_timeframe(fr, secs); |
| 875 |
else offset = atol(spos); |
| 876 |
/* totally replaced that stuff - it never fully worked |
| 877 |
a bit usure about why +pos -> spos+1 earlier... */ |
| 878 |
if (spos[0] == '-' || spos[0] == '+') offset += framenum; |
| 879 |
|
| 880 |
if(0 > (framenum = mpg123_seek_frame(fr, offset, SEEK_SET))) |
| 881 |
{ |
| 882 |
generic_sendmsg("E Error while seeking"); |
| 883 |
mpg123_seek_frame(fr, 0, SEEK_SET); |
| 884 |
} |
| 885 |
out123_drop(ao); |
| 886 |
|
| 887 |
if(framenum <= oldpos) mpg123_meta_free(fr); |
| 888 |
generic_sendmsg("J %d", framenum); |
| 889 |
continue; |
| 890 |
} |
| 891 |
|
| 892 |
/* VOLUME in percent */ |
| 893 |
if(!strcasecmp(cmd, "V") || !strcasecmp(cmd, "VOLUME")) |
| 894 |
{ |
| 895 |
double v; |
| 896 |
mpg123_volume(fr, atof(arg)/100); |
| 897 |
mpg123_getvolume(fr, &v, NULL, NULL); /* Necessary? */ |
| 898 |
generic_sendmsg("V %f%%", v * 100); |
| 899 |
continue; |
| 900 |
} |
| 901 |
|
| 902 |
/* PITCH (playback speed) in percent */ |
| 903 |
if(!strcasecmp(cmd, "PITCH")) |
| 904 |
{ |
| 905 |
double p; |
| 906 |
if(sscanf(arg, "%lf", &p) == 1) |
| 907 |
{ |
| 908 |
set_pitch(fr, ao, p); |
| 909 |
generic_sendmsg("PITCH %f", param.pitch); |
| 910 |
} |
| 911 |
else generic_sendmsg("E invalid arguments for PITCH: %s", arg); |
| 912 |
continue; |
| 913 |
} |
| 914 |
|
| 915 |
/* RVA mode */ |
| 916 |
if(!strcasecmp(cmd, "RVA")) |
| 917 |
{ |
| 918 |
if(!strcasecmp(arg, "off")) param.rva = MPG123_RVA_OFF; |
| 919 |
else if(!strcasecmp(arg, "mix") || !strcasecmp(arg, "radio")) param.rva = MPG123_RVA_MIX; |
| 920 |
else if(!strcasecmp(arg, "album") || !strcasecmp(arg, "audiophile")) param.rva = MPG123_RVA_ALBUM; |
| 921 |
mpg123_volume_change(fr, 0.); |
| 922 |
generic_sendmsg("RVA %s", rva_name[param.rva]); |
| 923 |
continue; |
| 924 |
} |
| 925 |
|
| 926 |
/* LOAD - actually play */ |
| 927 |
if (!strcasecmp(cmd, "L") || !strcasecmp(cmd, "LOAD")){ generic_load(fr, arg, MODE_PLAYING); continue; } |
| 928 |
|
| 929 |
if (!strcasecmp(cmd, "LL") || !strcasecmp(cmd, "LOADLIST")){ generic_loadlist(fr, arg); continue; } |
| 930 |
|
| 931 |
/* LOADPAUSED */ |
| 932 |
if (!strcasecmp(cmd, "LP") || !strcasecmp(cmd, "LOADPAUSED")){ generic_load(fr, arg, MODE_PAUSED); continue; } |
| 933 |
|
| 934 |
/* no command matched */ |
| 935 |
generic_send2str(0, "E Unknown command with arguments: %s %s", cmd, arg); |
| 936 |
} /* end commands with arguments */ |
| 937 |
else generic_sendstr( 0, "E Unknown command or no arguments: %s" |
| 938 |
, comstr ); |
| 939 |
|
| 940 |
} /* end of single command processing */ |
| 941 |
} /* end of scanning the command buffer */ |
| 942 |
|
| 943 |
// Last character not nulled if we did not use all command text. |
| 944 |
if(buf[len-1] != 0) |
| 945 |
{ |
| 946 |
if(next_comstr == buf && len == REMOTE_BUFFER_SIZE) |
| 947 |
{ |
| 948 |
generic_sendmsg("E Too long command, cannot parse."); |
| 949 |
// Just skipping it, provoking further parsing erros, but maybe not fatal. |
| 950 |
} else |
| 951 |
{ |
| 952 |
last_len = len-(short)(next_comstr-buf); |
| 953 |
mdebug("keeping %d bytes of old command", last_len); |
| 954 |
memmove(buf, next_comstr, last_len); |
| 955 |
} |
| 956 |
} |
| 957 |
} /* end command reading & processing */ |
| 958 |
} /* end main (alive) loop */ |
| 959 |
debug("going to end"); |
| 960 |
/* quit gracefully */ |
| 961 |
debug("closing control"); |
| 962 |
#ifdef FIFO |
| 963 |
#if WANT_WIN32_FIFO |
| 964 |
win32_fifo_close(); |
| 965 |
#else |
| 966 |
close(control_file); /* be it FIFO or STDIN */ |
| 967 |
if(param.fifo) unlink(param.fifo); |
| 968 |
#endif /* WANT_WIN32_FIFO */ |
| 969 |
#endif |
| 970 |
debug("control_generic returning"); |
| 971 |
return 0; |
| 972 |
} |
| 973 |
|
| 974 |
/* EOF */ |